Skip to content

Commit da1f707

Browse files
committed
Merge pull request #194
2 parents a14c93c + 24ed832 commit da1f707

File tree

12 files changed

+52
-51
lines changed

12 files changed

+52
-51
lines changed

php_bson.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ typedef struct {
7676
#define PHONGO_BSON_STATE_INITIALIZER { NULL, { PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL, PHONGO_TYPEMAP_NONE, NULL}, NULL}
7777
#endif
7878

79-
PHONGO_API void zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *bson, bson_t **bson_out TSRMLS_DC);
80-
PHONGO_API int bson_to_zval_ex(const unsigned char *data, int data_len, php_phongo_bson_state *state);
79+
PHONGO_API void phongo_zval_to_bson(zval *data, php_phongo_bson_flags_t flags, bson_t *bson, bson_t **bson_out TSRMLS_DC);
80+
PHONGO_API int phongo_bson_to_zval_ex(const unsigned char *data, int data_len, php_phongo_bson_state *state);
8181
#if PHP_VERSION_ID >= 70000
82-
PHONGO_API int bson_to_zval(const unsigned char *data, int data_len, zval *out);
82+
PHONGO_API int phongo_bson_to_zval(const unsigned char *data, int data_len, zval *out);
8383
#else
84-
PHONGO_API int bson_to_zval(const unsigned char *data, int data_len, zval **out);
84+
PHONGO_API int phongo_bson_to_zval(const unsigned char *data, int data_len, zval **out);
8585
#endif
86-
PHONGO_API void php_phongo_bson_typemap_to_state(zval *typemap, php_phongo_bson_typemap *map TSRMLS_DC);
86+
PHONGO_API void phongo_bson_typemap_to_state(zval *typemap, php_phongo_bson_typemap *map TSRMLS_DC);
8787

8888
PHP_FUNCTION(toPHP);
8989
PHP_FUNCTION(fromPHP);

php_phongo.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ zend_bool phongo_writeconcernerror_init(zval *return_value, bson_t *bson TSRMLS_
414414
return false;
415415
}
416416

417-
if (!bson_to_zval(data, len, &writeconcernerror->info)) {
417+
if (!phongo_bson_to_zval(data, len, &writeconcernerror->info)) {
418418
zval_ptr_dtor(&writeconcernerror->info);
419419
#if PHP_VERSION_ID >= 70000
420420
ZVAL_UNDEF(&writeconcernerror->info);
@@ -448,7 +448,7 @@ zend_bool phongo_writeerror_init(zval *return_value, bson_t *bson TSRMLS_DC) /*
448448
bson_init(&info);
449449
bson_append_iter(&info, NULL, 0, &iter);
450450

451-
if (!bson_to_zval(bson_get_data(&info), info.len, &writeerror->info)) {
451+
if (!phongo_bson_to_zval(bson_get_data(&info), info.len, &writeerror->info)) {
452452
zval_ptr_dtor(&writeerror->info);
453453
#if PHP_VERSION_ID >= 70000
454454
ZVAL_UNDEF(&writeerror->info);
@@ -1326,7 +1326,7 @@ void php_phongo_server_to_zval(zval *retval, const mongoc_server_description_t *
13261326
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
13271327
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
13281328

1329-
bson_to_zval_ex(bson_get_data(&sd->tags), sd->tags.len, &state);
1329+
phongo_bson_to_zval_ex(bson_get_data(&sd->tags), sd->tags.len, &state);
13301330
#if PHP_VERSION_ID >= 70000
13311331
ADD_ASSOC_ZVAL_EX(retval, "tags", &state.zchild);
13321332
#else
@@ -1339,7 +1339,7 @@ void php_phongo_server_to_zval(zval *retval, const mongoc_server_description_t *
13391339
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
13401340
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
13411341

1342-
bson_to_zval_ex(bson_get_data(&sd->last_is_master), sd->last_is_master.len, &state);
1342+
phongo_bson_to_zval_ex(bson_get_data(&sd->last_is_master), sd->last_is_master.len, &state);
13431343
#if PHP_VERSION_ID >= 70000
13441344
ADD_ASSOC_ZVAL_EX(retval, "last_is_master", &state.zchild);
13451345
#else
@@ -1375,7 +1375,7 @@ void php_phongo_read_preference_to_zval(zval *retval, const mongoc_read_prefs_t
13751375
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
13761376
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
13771377

1378-
bson_to_zval_ex(bson_get_data(&read_prefs->tags), read_prefs->tags.len, &state);
1378+
phongo_bson_to_zval_ex(bson_get_data(&read_prefs->tags), read_prefs->tags.len, &state);
13791379
#if PHP_VERSION_ID >= 70000
13801380
ADD_ASSOC_ZVAL_EX(retval, "tags", &state.zchild);
13811381
#else
@@ -1439,7 +1439,7 @@ void php_phongo_cursor_to_zval(zval *retval, const mongoc_cursor_t *cursor) /* {
14391439
zval *zv;
14401440
#endif
14411441

1442-
bson_to_zval(bson_get_data(&cursor->query), cursor->query.len, &zv);
1442+
phongo_bson_to_zval(bson_get_data(&cursor->query), cursor->query.len, &zv);
14431443
#if PHP_VERSION_ID >= 70000
14441444
ADD_ASSOC_ZVAL_EX(retval, "query", &zv);
14451445
#else
@@ -1453,7 +1453,7 @@ void php_phongo_cursor_to_zval(zval *retval, const mongoc_cursor_t *cursor) /* {
14531453
zval *zv;
14541454
#endif
14551455

1456-
bson_to_zval(bson_get_data(&cursor->fields), cursor->fields.len, &zv);
1456+
phongo_bson_to_zval(bson_get_data(&cursor->fields), cursor->fields.len, &zv);
14571457
#if PHP_VERSION_ID >= 70000
14581458
ADD_ASSOC_ZVAL_EX(retval, "fields", &zv);
14591459
#else
@@ -1491,7 +1491,7 @@ void php_phongo_cursor_to_zval(zval *retval, const mongoc_cursor_t *cursor) /* {
14911491
zval *zv;
14921492
#endif
14931493

1494-
bson_to_zval(bson_get_data(cursor->current), cursor->current->len, &zv);
1494+
phongo_bson_to_zval(bson_get_data(cursor->current), cursor->current->len, &zv);
14951495
#if PHP_VERSION_ID >= 70000
14961496
ADD_ASSOC_ZVAL_EX(retval, "current_doc", &zv);
14971497
#else
@@ -2146,7 +2146,7 @@ static void php_phongo_cursor_iterator_move_forward(zend_object_iterator *iter T
21462146
cursor_it->current++;
21472147

21482148
if (mongoc_cursor_next(cursor->cursor, &doc)) {
2149-
bson_to_zval_ex(bson_get_data(doc), doc->len, &cursor->visitor_data);
2149+
phongo_bson_to_zval_ex(bson_get_data(doc), doc->len, &cursor->visitor_data);
21502150
} else {
21512151
bson_error_t error;
21522152

@@ -2174,7 +2174,7 @@ static void php_phongo_cursor_iterator_rewind(zend_object_iterator *iter TSRMLS_
21742174
doc = mongoc_cursor_current(cursor->cursor);
21752175

21762176
if (doc) {
2177-
bson_to_zval_ex(bson_get_data(doc), doc->len, &cursor->visitor_data);
2177+
phongo_bson_to_zval_ex(bson_get_data(doc), doc->len, &cursor->visitor_data);
21782178
}
21792179
} /* }}} */
21802180

src/BSON/Javascript.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ PHP_METHOD(Javascript, __construct)
6969
zend_restore_error_handling(&error_handling TSRMLS_CC);
7070

7171
if (document) {
72-
zval_to_bson(document, PHONGO_BSON_NONE, &scope, NULL TSRMLS_CC);
72+
phongo_zval_to_bson(document, PHONGO_BSON_NONE, &scope, NULL TSRMLS_CC);
7373
}
7474

7575
php_phongo_new_javascript_from_javascript_and_scope(0, getThis(), javascript, javascript_len, &scope TSRMLS_CC);
@@ -158,7 +158,7 @@ HashTable *php_phongo_javascript_get_debug_info(zval *object, int *is_temp TSRML
158158
if (intern->document) {
159159
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
160160

161-
if (bson_to_zval_ex(bson_get_data(intern->document), intern->document->len, &state)) {
161+
if (phongo_bson_to_zval_ex(bson_get_data(intern->document), intern->document->len, &state)) {
162162
#if PHP_VERSION_ID >= 70000
163163
Z_ADDREF(state.zchild);
164164
ADD_ASSOC_ZVAL_EX(&retval, "scope", &state.zchild);

src/MongoDB/BulkWrite.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ PHP_METHOD(BulkWrite, insert)
108108
bson_flags |= PHONGO_BSON_ADD_ODS|PHONGO_BSON_ADD_CHILD_ODS;
109109

110110
bson = bson_new();
111-
zval_to_bson(document, bson_flags, bson, &bson_out TSRMLS_CC);
111+
phongo_zval_to_bson(document, bson_flags, bson, &bson_out TSRMLS_CC);
112112
mongoc_bulk_operation_insert(intern->bulk, bson);
113113
bson_clear(&bson);
114114

@@ -149,8 +149,8 @@ PHP_METHOD(BulkWrite, update)
149149
bquery = bson_new();
150150
bupdate = bson_new();
151151

152-
zval_to_bson(query, PHONGO_BSON_NONE, bquery, NULL TSRMLS_CC);
153-
zval_to_bson(newObj, PHONGO_BSON_NONE, bupdate, NULL TSRMLS_CC);
152+
phongo_zval_to_bson(query, PHONGO_BSON_NONE, bquery, NULL TSRMLS_CC);
153+
phongo_zval_to_bson(newObj, PHONGO_BSON_NONE, bupdate, NULL TSRMLS_CC);
154154

155155
if (updateOptions) {
156156
flags |= php_array_fetch_bool(updateOptions, "multi") ? MONGOC_UPDATE_MULTI_UPDATE : 0;
@@ -201,7 +201,7 @@ PHP_METHOD(BulkWrite, delete)
201201

202202

203203
bson = bson_new();
204-
zval_to_bson(query, PHONGO_BSON_NONE, bson, NULL TSRMLS_CC);
204+
phongo_zval_to_bson(query, PHONGO_BSON_NONE, bson, NULL TSRMLS_CC);
205205

206206
if (deleteOptions && php_array_fetch_bool(deleteOptions, "limit")) {
207207
mongoc_bulk_operation_remove_one(intern->bulk, bson);

src/MongoDB/Command.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ PHP_METHOD(Command, __construct)
6767
zend_restore_error_handling(&error_handling TSRMLS_CC);
6868

6969

70-
zval_to_bson(document, PHONGO_BSON_NONE, bson, NULL TSRMLS_CC);
70+
phongo_zval_to_bson(document, PHONGO_BSON_NONE, bson, NULL TSRMLS_CC);
7171
intern->bson = bson;
7272
}
7373
/* }}} */
@@ -153,7 +153,7 @@ HashTable *php_phongo_command_get_debug_info(zval *object, int *is_temp TSRMLS_D
153153
zval *zv;
154154
#endif
155155

156-
bson_to_zval(bson_get_data(intern->bson), intern->bson->len, &zv);
156+
phongo_bson_to_zval(bson_get_data(intern->bson), intern->bson->len, &zv);
157157
#if PHP_VERSION_ID >= 70000
158158
ADD_ASSOC_ZVAL_EX(&retval, "command", &zv);
159159
#else

src/MongoDB/Cursor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ PHP_METHOD(Cursor, setTypeMap)
6464
return;
6565
}
6666

67-
php_phongo_bson_typemap_to_state(typemap, &state.map TSRMLS_CC);
67+
phongo_bson_typemap_to_state(typemap, &state.map TSRMLS_CC);
6868

6969
intern->visitor_data = state;
7070
}

src/MongoDB/Manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ PHP_METHOD(Manager, __construct)
7878
zend_restore_error_handling(&error_handling TSRMLS_CC);
7979

8080
if (options) {
81-
zval_to_bson(options, PHONGO_BSON_NONE, &bson_options, NULL TSRMLS_CC);
81+
phongo_zval_to_bson(options, PHONGO_BSON_NONE, &bson_options, NULL TSRMLS_CC);
8282
}
8383

8484
phongo_manager_init(intern, uri_string, &bson_options, driverOptions TSRMLS_CC);

src/MongoDB/Query.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ PHP_METHOD(Query, __construct)
7676
intern->query = bson_new();
7777

7878
bson_init(&bfilter);
79-
zval_to_bson(zfilter, PHONGO_BSON_NONE, &bfilter, NULL TSRMLS_CC);
79+
phongo_zval_to_bson(zfilter, PHONGO_BSON_NONE, &bfilter, NULL TSRMLS_CC);
8080

8181
if (zoptions) {
8282
if (php_array_exists(zoptions, "readConcern")) {
@@ -96,7 +96,7 @@ PHP_METHOD(Query, __construct)
9696
php_array_unsetc(zoptions, "readConcern");
9797
}
9898

99-
zval_to_bson(zoptions, PHONGO_BSON_NONE, &boptions, NULL TSRMLS_CC);
99+
phongo_zval_to_bson(zoptions, PHONGO_BSON_NONE, &boptions, NULL TSRMLS_CC);
100100
}
101101

102102
if (!phongo_query_init(intern, &bfilter, &boptions TSRMLS_CC)) {
@@ -196,7 +196,7 @@ HashTable *php_phongo_query_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
196196
zval *zv;
197197
#endif
198198

199-
bson_to_zval(bson_get_data(intern->query), intern->query->len, &zv);
199+
phongo_bson_to_zval(bson_get_data(intern->query), intern->query->len, &zv);
200200
#if PHP_VERSION_ID >= 70000
201201
ADD_ASSOC_ZVAL_EX(&retval, "query", &zv);
202202
#else
@@ -213,7 +213,7 @@ HashTable *php_phongo_query_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
213213
zval *zv;
214214
#endif
215215

216-
bson_to_zval(bson_get_data(intern->selector), intern->selector->len, &zv);
216+
phongo_bson_to_zval(bson_get_data(intern->selector), intern->selector->len, &zv);
217217
#if PHP_VERSION_ID >= 70000
218218
ADD_ASSOC_ZVAL_EX(&retval, "selector", &zv);
219219
#else

src/MongoDB/ReadPreference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ PHP_METHOD(ReadPreference, __construct)
7979
if (tagSets) {
8080
bson_t *tags = bson_new();
8181

82-
zval_to_bson(tagSets, PHONGO_BSON_NONE, (bson_t *)tags, NULL TSRMLS_CC);
82+
phongo_zval_to_bson(tagSets, PHONGO_BSON_NONE, (bson_t *)tags, NULL TSRMLS_CC);
8383
mongoc_read_prefs_set_tags(intern->read_preference, tags);
8484
bson_destroy(tags);
8585
if (!mongoc_read_prefs_is_valid(intern->read_preference)) {
@@ -131,7 +131,7 @@ PHP_METHOD(ReadPreference, getTagSets)
131131
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
132132
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
133133

134-
bson_to_zval_ex(bson_get_data(&intern->read_preference->tags), intern->read_preference->tags.len, &state);
134+
phongo_bson_to_zval_ex(bson_get_data(&intern->read_preference->tags), intern->read_preference->tags.len, &state);
135135
#if PHP_VERSION_ID >= 70000
136136
RETURN_ZVAL(&state.zchild, 0, 1);
137137
#else

src/MongoDB/Server.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ PHP_METHOD(Server, getTags)
175175
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
176176
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
177177

178-
bson_to_zval_ex(bson_get_data(&sd->tags), sd->tags.len, &state);
178+
phongo_bson_to_zval_ex(bson_get_data(&sd->tags), sd->tags.len, &state);
179179
#if PHP_VERSION_ID >= 70000
180180
RETURN_ZVAL(&state.zchild, 0, 1);
181181
#else
@@ -208,7 +208,7 @@ PHP_METHOD(Server, getInfo)
208208
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
209209
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
210210

211-
bson_to_zval_ex(bson_get_data(&sd->last_is_master), sd->last_is_master.len, &state);
211+
phongo_bson_to_zval_ex(bson_get_data(&sd->last_is_master), sd->last_is_master.len, &state);
212212

213213
#if PHP_VERSION_ID >= 70000
214214
RETURN_ZVAL(&state.zchild, 0, 1);

0 commit comments

Comments
 (0)