Skip to content

Commit f73b37f

Browse files
WL#11960: Methods refactoring
Implementation.
1 parent 4171234 commit f73b37f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1070
-1604
lines changed

mysqlx_collection.cc

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ ZEND_END_ARG_INFO()
133133

134134
struct st_mysqlx_collection : public util::custom_allocable
135135
{
136-
XMYSQLND_COLLECTION * collection;
136+
xmysqlnd_collection * collection;
137137
};
138138

139139

@@ -175,7 +175,7 @@ MYSQL_XDEVAPI_PHP_METHOD(mysqlx_collection, getSession)
175175

176176
RETVAL_FALSE;
177177

178-
XMYSQLND_SESSION session{ data_object.collection->data->schema->data->session };
178+
XMYSQLND_SESSION session{ data_object.collection->get_schema()->get_session()};
179179
mysqlx_new_session(return_value, session);
180180

181181
DBG_VOID_RETURN;
@@ -199,7 +199,7 @@ MYSQL_XDEVAPI_PHP_METHOD(mysqlx_collection, getName)
199199
MYSQLX_FETCH_COLLECTION_FROM_ZVAL(object, object_zv);
200200

201201
if (object->collection) {
202-
RETVAL_STRINGL(object->collection->data->collection_name.s, object->collection->data->collection_name.l);
202+
RETVAL_STRINGL(object->collection->get_name().s, object->collection->get_name().l);
203203
} else {
204204
RETVAL_FALSE;
205205
}
@@ -212,7 +212,7 @@ MYSQL_XDEVAPI_PHP_METHOD(mysqlx_collection, getName)
212212
/* {{{ mysqlx_collection_on_error */
213213
static const enum_hnd_func_status
214214
mysqlx_collection_on_error(void * context, XMYSQLND_SESSION session,
215-
st_xmysqlnd_stmt* const stmt,
215+
xmysqlnd_stmt* const stmt,
216216
const unsigned int code,
217217
const MYSQLND_CSTRING sql_state,
218218
const MYSQLND_CSTRING message)
@@ -246,12 +246,12 @@ MYSQL_XDEVAPI_PHP_METHOD(mysqlx_collection, existsInDatabase)
246246

247247
RETVAL_FALSE;
248248

249-
XMYSQLND_COLLECTION * collection = object->collection;
249+
xmysqlnd_collection * collection = object->collection;
250250
if (collection) {
251251
const struct st_xmysqlnd_session_on_error_bind on_error = { mysqlx_collection_on_error, nullptr };
252252
zval exists;
253253
ZVAL_UNDEF(&exists);
254-
if (PASS == collection->data->m.exists_in_database(collection, on_error, &exists)) {
254+
if (PASS == collection->exists_in_database( on_error, &exists)) {
255255
ZVAL_COPY_VALUE(return_value, &exists);
256256
}
257257
}
@@ -278,12 +278,12 @@ MYSQL_XDEVAPI_PHP_METHOD(mysqlx_collection, count)
278278

279279
RETVAL_FALSE;
280280

281-
XMYSQLND_COLLECTION * collection = object->collection;
281+
xmysqlnd_collection * collection = object->collection;
282282
if (collection) {
283283
const struct st_xmysqlnd_session_on_error_bind on_error = { mysqlx_collection_on_error, nullptr };
284284
zval counter;
285285
ZVAL_UNDEF(&counter);
286-
if (PASS == collection->data->m.count(collection, on_error, &counter)) {
286+
if (PASS == collection->count(on_error, &counter)) {
287287
ZVAL_COPY_VALUE(return_value, &counter);
288288
}
289289
}
@@ -314,15 +314,13 @@ MYSQL_XDEVAPI_PHP_METHOD(mysqlx_collection, getSchema)
314314
RETVAL_FALSE;
315315

316316
if( object->collection &&
317-
object->collection->data &&
318-
object->collection->data->schema &&
319-
object->collection->data->schema->data ) {
320-
session = object->collection->data->schema->data->session;
317+
object->collection->get_schema() ) {
318+
session = object->collection->get_schema()->get_session();
321319
}
322320

323321
if(session != nullptr) {
324-
MYSQLND_STRING& schema_name{ object->collection->data->schema->data->schema_name };
325-
XMYSQLND_SCHEMA * schema = session->create_schema_object(
322+
MYSQLND_STRING schema_name{ object->collection->get_schema()->get_name() };
323+
xmysqlnd_schema * schema = session->create_schema_object(
326324
mnd_str2c(schema_name));
327325
if (schema) {
328326
mysqlx_new_schema(return_value, schema);
@@ -705,8 +703,8 @@ mysqlx_collection_property__name(const st_mysqlx_object* obj, zval * return_valu
705703
{
706704
const st_mysqlx_collection* object = (const st_mysqlx_collection* ) (obj->ptr);
707705
DBG_ENTER("mysqlx_collection_property__name");
708-
if (object->collection && object->collection->data->collection_name.s) {
709-
ZVAL_STRINGL(return_value, object->collection->data->collection_name.s, object->collection->data->collection_name.l);
706+
if (object->collection && object->collection->get_name().s) {
707+
ZVAL_STRINGL(return_value, object->collection->get_name().s, object->collection->get_name().l);
710708
} else {
711709
/*
712710
This means EG(uninitialized_value). If we return just return_value, this is an UNDEF-ed value
@@ -801,15 +799,15 @@ mysqlx_unregister_collection_class(SHUTDOWN_FUNC_ARGS)
801799

802800
/* {{{ mysqlx_new_collection */
803801
void
804-
mysqlx_new_collection(zval * return_value, XMYSQLND_COLLECTION * collection, const zend_bool clone)
802+
mysqlx_new_collection(zval * return_value, xmysqlnd_collection * collection, const zend_bool clone)
805803
{
806804
DBG_ENTER("mysqlx_new_collection");
807805

808806
if (SUCCESS == object_init_ex(return_value, mysqlx_collection_class_entry) && IS_OBJECT == Z_TYPE_P(return_value)) {
809807
const st_mysqlx_object* const mysqlx_object = Z_MYSQLX_P(return_value);
810808
st_mysqlx_collection* const object = (st_mysqlx_collection*) mysqlx_object->ptr;
811809
if (object) {
812-
object->collection = clone? collection->data->m.get_reference(collection) : collection;
810+
object->collection = clone? collection->get_reference() : collection;
813811
} else {
814812
php_error_docref(nullptr, E_WARNING, "invalid object of class %s", ZSTR_VAL(mysqlx_object->zo.ce->name));
815813
zval_ptr_dtor(return_value);

mysqlx_collection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
namespace mysqlx {
2222

2323
namespace drv {
24-
struct st_xmysqlnd_collection;
24+
struct xmysqlnd_collection;
2525
}
2626

2727
namespace devapi {
2828

29-
void mysqlx_new_collection(zval * return_value, drv::st_xmysqlnd_collection* schema, const zend_bool clone);
29+
void mysqlx_new_collection(zval * return_value, drv::xmysqlnd_collection* schema, const zend_bool clone);
3030
void mysqlx_register_collection_class(INIT_FUNC_ARGS, zend_object_handlers * mysqlx_std_object_handlers);
3131
void mysqlx_unregister_collection_class(SHUTDOWN_FUNC_ARGS);
3232

mysqlx_collection__add.cc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ZEND_END_ARG_INFO()
6262

6363
/* {{{ execute_statement */
6464
enum_func_status
65-
execute_statement(XMYSQLND_STMT* stmt,zval* return_value)
65+
execute_statement(xmysqlnd_stmt* stmt,zval* return_value)
6666
{
6767
enum_func_status ret{FAIL};
6868
if (stmt) {
@@ -179,7 +179,7 @@ collection_add_array(
179179
/* {{{ Collection_add::init() */
180180
bool Collection_add::init(
181181
zval* obj_zv,
182-
XMYSQLND_COLLECTION* coll,
182+
xmysqlnd_collection* coll,
183183
zval* documents,
184184
int num_of_documents)
185185
{
@@ -195,10 +195,10 @@ bool Collection_add::init(
195195
}
196196

197197
object_zv = obj_zv;
198-
collection = coll->data->m.get_reference(coll);
198+
collection = coll->get_reference();
199199
add_op = xmysqlnd_crud_collection_add__create(
200-
mnd_str2c(collection->data->schema->data->schema_name),
201-
mnd_str2c(collection->data->collection_name));
200+
mnd_str2c(collection->get_schema()->get_name()),
201+
mnd_str2c(collection->get_name()));
202202

203203
if (!add_op) return false;
204204

@@ -216,7 +216,7 @@ bool Collection_add::init(
216216
/* {{{ Collection_add::init() */
217217
bool Collection_add::init(
218218
zval* obj_zv,
219-
XMYSQLND_COLLECTION* coll,
219+
xmysqlnd_collection* coll,
220220
const util::string_view& doc_id,
221221
zval* doc)
222222
{
@@ -281,8 +281,7 @@ void Collection_add::execute(zval* return_value)
281281
}
282282

283283
if ( execute_ret_status != FAIL && num_of_docs > noop_cnt ) {
284-
XMYSQLND_STMT* stmt = collection->data->m.add(collection,
285-
add_op);
284+
xmysqlnd_stmt* stmt = collection->add(add_op);
286285
if( nullptr != stmt ) {
287286
execute_ret_status = execute_statement(stmt,return_value);
288287
} else {
@@ -346,8 +345,8 @@ mysqlx_collection__add_property__name(const st_mysqlx_object* obj, zval* return_
346345
{
347346
const Collection_add* object = (const Collection_add *) (obj->ptr);
348347
DBG_ENTER("mysqlx_collection__add_property__name");
349-
if (object->collection && object->collection->data->collection_name.s) {
350-
ZVAL_STRINGL(return_value, object->collection->data->collection_name.s, object->collection->data->collection_name.l);
348+
if (object->collection && object->collection->get_name().s) {
349+
ZVAL_STRINGL(return_value, object->collection->get_name().s, object->collection->get_name().l);
351350
} else {
352351
/*
353352
This means EG(uninitialized_value). If we return just return_value, this is an UNDEF-ed value
@@ -434,7 +433,7 @@ mysqlx_unregister_collection__add_class(SHUTDOWN_FUNC_ARGS)
434433
void
435434
mysqlx_new_collection__add(
436435
zval* return_value,
437-
XMYSQLND_COLLECTION* collection,
436+
xmysqlnd_collection* collection,
438437
zval* docs,
439438
int num_of_docs)
440439
{

mysqlx_collection__add.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace mysqlx {
2222

2323
namespace drv {
2424

25-
struct st_xmysqlnd_collection;
25+
struct xmysqlnd_collection;
2626
struct st_xmysqlnd_crud_collection_op__add;
2727

2828
} // namespace drv
@@ -35,12 +35,12 @@ class Collection_add : public util::custom_allocable
3535
public:
3636
bool init(
3737
zval* object_zv,
38-
drv::st_xmysqlnd_collection* collection,
38+
drv::xmysqlnd_collection* collection,
3939
zval* docs,
4040
int num_of_docs);
4141
bool init(
4242
zval* object_zv,
43-
drv::st_xmysqlnd_collection* collection,
43+
drv::xmysqlnd_collection* collection,
4444
const util::string_view& single_doc_id,
4545
zval* doc);
4646
~Collection_add();
@@ -50,7 +50,7 @@ class Collection_add : public util::custom_allocable
5050

5151
private:
5252
zval* object_zv{nullptr};
53-
drv::st_xmysqlnd_collection* collection{nullptr};
53+
drv::xmysqlnd_collection* collection{nullptr};
5454
drv::st_xmysqlnd_crud_collection_op__add* add_op{nullptr};
5555
zval* docs{nullptr};
5656
int num_of_docs{0};
@@ -60,7 +60,7 @@ class Collection_add : public util::custom_allocable
6060

6161
void mysqlx_new_collection__add(
6262
zval* return_value,
63-
drv::st_xmysqlnd_collection* schema,
63+
drv::xmysqlnd_collection* schema,
6464
zval* docs,
6565
int num_of_docs);
6666
void mysqlx_register_collection__add_class(INIT_FUNC_ARGS, zend_object_handlers* mysqlx_std_object_handlers);

mysqlx_collection__find.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,16 @@ ZEND_END_ARG_INFO()
101101
/* {{{ Collection_find::init() */
102102
bool Collection_find::init(
103103
zval* obj_zv,
104-
XMYSQLND_COLLECTION* coll,
104+
xmysqlnd_collection* coll,
105105
const util::string_view& search_expression)
106106
{
107107
if (!obj_zv || !coll) return false;
108108

109109
object_zv = obj_zv;
110-
collection = coll->data->m.get_reference(coll);
110+
collection = coll->get_reference();
111111
find_op = xmysqlnd_crud_collection_find__create(
112-
mnd_str2c(collection->data->schema->data->schema_name),
113-
mnd_str2c(collection->data->collection_name));
112+
mnd_str2c(collection->get_schema()->get_name()),
113+
mnd_str2c(collection->get_name()));
114114

115115
if (!find_op) return false;
116116

@@ -441,7 +441,7 @@ void Collection_find::execute(
441441
if (FALSE == xmysqlnd_crud_collection_find__is_initialized(find_op)) {
442442
RAISE_EXCEPTION(err_msg_find_fail);
443443
} else {
444-
XMYSQLND_STMT* stmt = collection->data->m.find(collection, find_op);
444+
xmysqlnd_stmt* stmt = collection->find(find_op);
445445
{
446446
if (stmt) {
447447
zval stmt_zv;
@@ -820,7 +820,7 @@ void
820820
mysqlx_new_collection__find(
821821
zval * return_value,
822822
const util::string_view& search_expression,
823-
drv::st_xmysqlnd_collection* collection)
823+
drv::xmysqlnd_collection* collection)
824824
{
825825
DBG_ENTER("mysqlx_new_collection__find");
826826
if (SUCCESS == object_init_ex(return_value, collection_find_class_entry) && IS_OBJECT == Z_TYPE_P(return_value)) {

mysqlx_collection__find.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace mysqlx {
2424

2525
namespace drv {
2626

27-
struct st_xmysqlnd_collection;
27+
struct xmysqlnd_collection;
2828
struct st_xmysqlnd_crud_collection_op__find;
2929

3030
} // namespace drv
@@ -37,7 +37,7 @@ class Collection_find : public util::custom_allocable
3737
public:
3838
bool init(
3939
zval* object_zv,
40-
drv::st_xmysqlnd_collection* collection,
40+
drv::xmysqlnd_collection* collection,
4141
const util::string_view& search_expression);
4242
~Collection_find();
4343

@@ -95,7 +95,7 @@ class Collection_find : public util::custom_allocable
9595

9696
private:
9797
zval* object_zv{nullptr};
98-
drv::st_xmysqlnd_collection* collection{nullptr};
98+
drv::xmysqlnd_collection* collection{nullptr};
9999
drv::st_xmysqlnd_crud_collection_op__find* find_op{nullptr};
100100

101101
};
@@ -107,7 +107,7 @@ extern zend_class_entry* collection_find_class_entry;
107107
void mysqlx_new_collection__find(
108108
zval * return_value,
109109
const util::string_view& search_expression,
110-
drv::st_xmysqlnd_collection* collection);
110+
drv::xmysqlnd_collection* collection);
111111
void mysqlx_register_collection__find_class(INIT_FUNC_ARGS, zend_object_handlers * mysqlx_std_object_handlers);
112112
void mysqlx_unregister_collection__find_class(SHUTDOWN_FUNC_ARGS);
113113

mysqlx_collection__modify.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ ZEND_END_ARG_INFO()
115115
/* {{{ Collection_modify::init() */
116116
bool Collection_modify::init(
117117
zval* obj_zv,
118-
XMYSQLND_COLLECTION* coll,
118+
xmysqlnd_collection* coll,
119119
const util::string_view& search_expression)
120120
{
121121
if (!obj_zv || !coll || search_expression.empty()) return false;
122122

123123
object_zv = obj_zv;
124-
collection = coll->data->m.get_reference(coll);
124+
collection = coll->get_reference();
125125
modify_op = xmysqlnd_crud_collection_modify__create(
126-
mnd_str2c(collection->data->schema->data->schema_name),
127-
mnd_str2c(collection->data->collection_name));
126+
mnd_str2c(collection->get_schema()->get_name()),
127+
mnd_str2c(collection->get_name()));
128128

129129
if (!modify_op) return false;
130130

@@ -506,7 +506,7 @@ void Collection_modify::execute(
506506
if (FALSE == xmysqlnd_crud_collection_modify__is_initialized(modify_op)) {
507507
RAISE_EXCEPTION(err_msg_modify_fail);
508508
} else {
509-
XMYSQLND_STMT* stmt = collection->data->m.modify(collection, modify_op);
509+
xmysqlnd_stmt* stmt = collection->modify(modify_op);
510510
if (stmt) {
511511
zval stmt_zv;
512512
ZVAL_UNDEF(&stmt_zv);
@@ -879,7 +879,7 @@ void
879879
mysqlx_new_collection__modify(
880880
zval* return_value,
881881
const util::string_view& search_expression,
882-
XMYSQLND_COLLECTION* collection)
882+
xmysqlnd_collection* collection)
883883
{
884884
DBG_ENTER("mysqlx_new_collection__modify");
885885

mysqlx_collection__modify.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace mysqlx {
2222

2323
namespace drv {
2424

25-
struct st_xmysqlnd_collection;
25+
struct xmysqlnd_collection;
2626
struct st_xmysqlnd_crud_collection_op__modify;
2727

2828
} // namespace drv
@@ -35,7 +35,7 @@ class Collection_modify : public util::custom_allocable
3535
public:
3636
bool init(
3737
zval* object_zv,
38-
drv::st_xmysqlnd_collection* collection,
38+
drv::xmysqlnd_collection* collection,
3939
const util::string_view& search_expression);
4040
~Collection_modify();
4141

@@ -99,7 +99,7 @@ class Collection_modify : public util::custom_allocable
9999

100100
private:
101101
zval* object_zv{nullptr};
102-
drv::st_xmysqlnd_collection* collection{nullptr};
102+
drv::xmysqlnd_collection* collection{nullptr};
103103
drv::st_xmysqlnd_crud_collection_op__modify* modify_op{nullptr};
104104

105105
};
@@ -109,7 +109,7 @@ class Collection_modify : public util::custom_allocable
109109
void mysqlx_new_collection__modify(
110110
zval* return_value,
111111
const util::string_view& search_expression,
112-
drv::st_xmysqlnd_collection* collection);
112+
drv::xmysqlnd_collection* collection);
113113
void mysqlx_register_collection__modify_class(INIT_FUNC_ARGS, zend_object_handlers * mysqlx_std_object_handlers);
114114
void mysqlx_unregister_collection__modify_class(SHUTDOWN_FUNC_ARGS);
115115

0 commit comments

Comments
 (0)