Skip to content

Commit 2be8af5

Browse files
committed
Merged pull request #700
2 parents a081085 + d3953f6 commit 2be8af5

39 files changed

+1641
-97
lines changed

config.m4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ if test "$MONGODB" != "no"; then
157157
src/bson-encode.c \
158158
src/BSON/Binary.c \
159159
src/BSON/BinaryInterface.c \
160+
src/BSON/DBPointer.c \
160161
src/BSON/Decimal128.c \
161162
src/BSON/Decimal128Interface.c \
162163
src/BSON/Javascript.c \
@@ -171,9 +172,11 @@ if test "$MONGODB" != "no"; then
171172
src/BSON/Regex.c \
172173
src/BSON/RegexInterface.c \
173174
src/BSON/Serializable.c \
175+
src/BSON/Symbol.c \
174176
src/BSON/Timestamp.c \
175177
src/BSON/TimestampInterface.c \
176178
src/BSON/Type.c \
179+
src/BSON/Undefined.c \
177180
src/BSON/Unserializable.c \
178181
src/BSON/UTCDateTime.c \
179182
src/BSON/UTCDateTimeInterface.c \

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if (PHP_MONGODB != "no") {
8484

8585
EXTENSION("mongodb", "php_phongo.c phongo_compat.c", null, PHP_MONGODB_CFLAGS);
8686
ADD_SOURCES(configure_module_dirname + "/src", "bson.c bson-encode.c", "mongodb");
87-
ADD_SOURCES(configure_module_dirname + "/src/BSON", "Binary.c BinaryInterface.c Decimal128.c Decimal128Interface.c Javascript.c JavascriptInterface.c MaxKey.c MaxKeyInterface.c MinKey.c MinKeyInterface.c ObjectId.c ObjectIdInterface.c Persistable.c Regex.c RegexInterface.c Serializable.c Timestamp.c TimestampInterface.c Type.c Unserializable.c UTCDateTime.c UTCDateTimeInterface.c functions.c", "mongodb");
87+
ADD_SOURCES(configure_module_dirname + "/src/BSON", "Binary.c BinaryInterface.c DBPointer.c Decimal128.c Decimal128Interface.c Javascript.c JavascriptInterface.c MaxKey.c MaxKeyInterface.c MinKey.c MinKeyInterface.c ObjectId.c ObjectIdInterface.c Persistable.c Regex.c RegexInterface.c Serializable.c Symbol.c Timestamp.c TimestampInterface.c Type.c Undefined.c Unserializable.c UTCDateTime.c UTCDateTimeInterface.c functions.c", "mongodb");
8888
ADD_SOURCES(configure_module_dirname + "/src/MongoDB", "BulkWrite.c Command.c Cursor.c CursorId.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c", "mongodb");
8989
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c ConnectionException.c ConnectionTimeoutException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c", "mongodb");
9090
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Monitoring", "CommandFailedEvent.c CommandStartedEvent.c CommandSubscriber.c CommandSucceededEvent.c Subscriber.c functions.c", "mongodb");

php_phongo.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,6 +2386,29 @@ void php_phongo_new_regex_from_regex_and_options(zval *object, const char *patte
23862386
qsort((void *) intern->flags, intern->flags_len, 1, php_phongo_regex_compare_flags);
23872387
} /* }}} */
23882388

2389+
void php_phongo_new_symbol(zval *object, const char *symbol, size_t symbol_len TSRMLS_DC) /* {{{ */
2390+
{
2391+
php_phongo_symbol_t *intern;
2392+
2393+
object_init_ex(object, php_phongo_symbol_ce);
2394+
2395+
intern = Z_SYMBOL_OBJ_P(object);
2396+
intern->symbol = estrndup(symbol, symbol_len);
2397+
intern->symbol_len = symbol_len;
2398+
} /* }}} */
2399+
2400+
void php_phongo_new_dbpointer(zval *object, const char *ref, size_t ref_len, const bson_oid_t *oid TSRMLS_DC) /* {{{ */
2401+
{
2402+
php_phongo_dbpointer_t *intern;
2403+
2404+
object_init_ex(object, php_phongo_dbpointer_ce);
2405+
2406+
intern = Z_DBPOINTER_OBJ_P(object);
2407+
intern->ref = estrndup(ref, ref_len);
2408+
intern->ref_len = ref_len;
2409+
bson_oid_to_string(oid, intern->id);
2410+
} /* }}} */
2411+
23892412
/* {{{ Memory allocation wrappers */
23902413
static void* php_phongo_malloc(size_t num_bytes) /* {{{ */
23912414
{
@@ -2647,14 +2670,17 @@ PHP_MINIT_FUNCTION(mongodb)
26472670
php_phongo_utcdatetime_interface_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26482671

26492672
php_phongo_binary_init_ce(INIT_FUNC_ARGS_PASSTHRU);
2673+
php_phongo_dbpointer_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26502674
php_phongo_decimal128_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26512675
php_phongo_javascript_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26522676
php_phongo_maxkey_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26532677
php_phongo_minkey_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26542678
php_phongo_objectid_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26552679
php_phongo_persistable_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26562680
php_phongo_regex_init_ce(INIT_FUNC_ARGS_PASSTHRU);
2681+
php_phongo_symbol_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26572682
php_phongo_timestamp_init_ce(INIT_FUNC_ARGS_PASSTHRU);
2683+
php_phongo_undefined_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26582684
php_phongo_utcdatetime_init_ce(INIT_FUNC_ARGS_PASSTHRU);
26592685

26602686
php_phongo_bulkwrite_init_ce(INIT_FUNC_ARGS_PASSTHRU);

php_phongo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ void php_phongo_new_javascript_from_javascript_and_scope(int init, zval *object,
159159
void php_phongo_new_binary_from_binary_and_type(zval *object, const char *data, size_t data_len, bson_subtype_t type TSRMLS_DC);
160160
void php_phongo_new_decimal128(zval *object, const bson_decimal128_t *decimal TSRMLS_DC);
161161
void php_phongo_new_regex_from_regex_and_options(zval *object, const char *pattern, const char *flags TSRMLS_DC);
162+
void php_phongo_new_symbol(zval *object, const char *symbol, size_t symbol_len TSRMLS_DC);
163+
void php_phongo_new_dbpointer(zval *object, const char *namespace, size_t namespace_len, const bson_oid_t *oid TSRMLS_DC);
162164

163165
zend_bool phongo_writeerror_init(zval *return_value, bson_t *bson TSRMLS_DC);
164166
zend_bool phongo_writeconcernerror_init(zval *return_value, bson_t *bson TSRMLS_DC);

php_phongo_classes.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ static inline php_phongo_writeresult_t* php_writeresult_fetch_object(zend_object
6767
static inline php_phongo_binary_t* php_binary_fetch_object(zend_object *obj) {
6868
return (php_phongo_binary_t *)((char *)obj - XtOffsetOf(php_phongo_binary_t, std));
6969
}
70+
static inline php_phongo_dbpointer_t* php_dbpointer_fetch_object(zend_object *obj) {
71+
return (php_phongo_dbpointer_t *)((char *)obj - XtOffsetOf(php_phongo_dbpointer_t, std));
72+
}
7073
static inline php_phongo_decimal128_t* php_decimal128_fetch_object(zend_object *obj) {
7174
return (php_phongo_decimal128_t *)((char *)obj - XtOffsetOf(php_phongo_decimal128_t, std));
7275
}
@@ -85,9 +88,15 @@ static inline php_phongo_objectid_t* php_objectid_fetch_object(zend_object *obj)
8588
static inline php_phongo_regex_t* php_regex_fetch_object(zend_object *obj) {
8689
return (php_phongo_regex_t *)((char *)obj - XtOffsetOf(php_phongo_regex_t, std));
8790
}
91+
static inline php_phongo_symbol_t* php_symbol_fetch_object(zend_object *obj) {
92+
return (php_phongo_symbol_t *)((char *)obj - XtOffsetOf(php_phongo_symbol_t, std));
93+
}
8894
static inline php_phongo_timestamp_t* php_timestamp_fetch_object(zend_object *obj) {
8995
return (php_phongo_timestamp_t *)((char *)obj - XtOffsetOf(php_phongo_timestamp_t, std));
9096
}
97+
static inline php_phongo_undefined_t* php_undefined_fetch_object(zend_object *obj) {
98+
return (php_phongo_undefined_t *)((char *)obj - XtOffsetOf(php_phongo_undefined_t, std));
99+
}
91100
static inline php_phongo_utcdatetime_t* php_utcdatetime_fetch_object(zend_object *obj) {
92101
return (php_phongo_utcdatetime_t *)((char *)obj - XtOffsetOf(php_phongo_utcdatetime_t, std));
93102
}
@@ -115,13 +124,16 @@ static inline php_phongo_commandsucceededevent_t* php_commandsucceededevent_fetc
115124
# define Z_WRITEERROR_OBJ_P(zv) (php_writeerror_fetch_object(Z_OBJ_P(zv)))
116125
# define Z_WRITERESULT_OBJ_P(zv) (php_writeresult_fetch_object(Z_OBJ_P(zv)))
117126
# define Z_BINARY_OBJ_P(zv) (php_binary_fetch_object(Z_OBJ_P(zv)))
127+
# define Z_DBPOINTER_OBJ_P(zv) (php_dbpointer_fetch_object(Z_OBJ_P(zv)))
118128
# define Z_DECIMAL128_OBJ_P(zv) (php_decimal128_fetch_object(Z_OBJ_P(zv)))
119129
# define Z_JAVASCRIPT_OBJ_P(zv) (php_javascript_fetch_object(Z_OBJ_P(zv)))
120130
# define Z_MAXKEY_OBJ_P(zv) (php_maxkey_fetch_object(Z_OBJ_P(zv)))
121131
# define Z_MINKEY_OBJ_P(zv) (php_minkey_fetch_object(Z_OBJ_P(zv)))
122132
# define Z_OBJECTID_OBJ_P(zv) (php_objectid_fetch_object(Z_OBJ_P(zv)))
123133
# define Z_REGEX_OBJ_P(zv) (php_regex_fetch_object(Z_OBJ_P(zv)))
134+
# define Z_SYMBOL_OBJ_P(zv) (php_symbol_fetch_object(Z_OBJ_P(zv)))
124135
# define Z_TIMESTAMP_OBJ_P(zv) (php_timestamp_fetch_object(Z_OBJ_P(zv)))
136+
# define Z_UNDEFINED_OBJ_P(zv) (php_undefined_fetch_object(Z_OBJ_P(zv)))
125137
# define Z_UTCDATETIME_OBJ_P(zv) (php_utcdatetime_fetch_object(Z_OBJ_P(zv)))
126138
# define Z_COMMANDFAILEDEVENT_OBJ_P(zv) (php_commandfailedevent_fetch_object(Z_OBJ_P(zv)))
127139
# define Z_COMMANDSTARTEDEVENT_OBJ_P(zv) (php_commandstartedevent_fetch_object(Z_OBJ_P(zv)))
@@ -141,13 +153,16 @@ static inline php_phongo_commandsucceededevent_t* php_commandsucceededevent_fetc
141153
# define Z_OBJ_WRITEERROR(zo) (php_writeerror_fetch_object(zo))
142154
# define Z_OBJ_WRITERESULT(zo) (php_writeresult_fetch_object(zo))
143155
# define Z_OBJ_BINARY(zo) (php_binary_fetch_object(zo))
156+
# define Z_OBJ_DBPOINTER(zo) (php_dbpointer_fetch_object(zo))
144157
# define Z_OBJ_DECIMAL128(zo) (php_decimal128_fetch_object(zo))
145158
# define Z_OBJ_JAVASCRIPT(zo) (php_javascript_fetch_object(zo))
146159
# define Z_OBJ_MAXKEY(zo) (php_maxkey_fetch_object(zo))
147160
# define Z_OBJ_MINKEY(zo) (php_minkey_fetch_object(zo))
148161
# define Z_OBJ_OBJECTID(zo) (php_objectid_fetch_object(zo))
149162
# define Z_OBJ_REGEX(zo) (php_regex_fetch_object(zo))
163+
# define Z_OBJ_SYMBOL(zo) (php_symbol_fetch_object(zo))
150164
# define Z_OBJ_TIMESTAMP(zo) (php_timestamp_fetch_object(zo))
165+
# define Z_OBJ_UNDEFINED(zo) (php_undefined_fetch_object(zo))
151166
# define Z_OBJ_UTCDATETIME(zo) (php_utcdatetime_fetch_object(zo))
152167
# define Z_OBJ_COMMANDFAILEDEVENT(zo) (php_commandfailedevent_fetch_object(zo))
153168
# define Z_OBJ_COMMANDSTARTEDEVENT(zo) (php_commandstartedevent_fetch_object(zo))
@@ -169,13 +184,16 @@ static inline php_phongo_commandsucceededevent_t* php_commandsucceededevent_fetc
169184
# define Z_WRITEERROR_OBJ_P(zv) ((php_phongo_writeerror_t *)zend_object_store_get_object(zv TSRMLS_CC))
170185
# define Z_WRITERESULT_OBJ_P(zv) ((php_phongo_writeresult_t *)zend_object_store_get_object(zv TSRMLS_CC))
171186
# define Z_BINARY_OBJ_P(zv) ((php_phongo_binary_t *)zend_object_store_get_object(zv TSRMLS_CC))
187+
# define Z_DBPOINTER_OBJ_P(zv) ((php_phongo_dbpointer_t *)zend_object_store_get_object(zv TSRMLS_CC))
172188
# define Z_DECIMAL128_OBJ_P(zv) ((php_phongo_decimal128_t *)zend_object_store_get_object(zv TSRMLS_CC))
173189
# define Z_JAVASCRIPT_OBJ_P(zv) ((php_phongo_javascript_t *)zend_object_store_get_object(zv TSRMLS_CC))
174190
# define Z_MAXKEY_OBJ_P(zv) ((php_phongo_maxkey_t *)zend_object_store_get_object(zv TSRMLS_CC))
175191
# define Z_MINKEY_OBJ_P(zv) ((php_phongo_minkey_t *)zend_object_store_get_object(zv TSRMLS_CC))
176192
# define Z_OBJECTID_OBJ_P(zv) ((php_phongo_objectid_t *)zend_object_store_get_object(zv TSRMLS_CC))
177193
# define Z_REGEX_OBJ_P(zv) ((php_phongo_regex_t *)zend_object_store_get_object(zv TSRMLS_CC))
194+
# define Z_SYMBOL_OBJ_P(zv) ((php_phongo_symbol_t *)zend_object_store_get_object(zv TSRMLS_CC))
178195
# define Z_TIMESTAMP_OBJ_P(zv) ((php_phongo_timestamp_t *)zend_object_store_get_object(zv TSRMLS_CC))
196+
# define Z_UNDEFINED_OBJ_P(zv) ((php_phongo_undefined_t *)zend_object_store_get_object(zv TSRMLS_CC))
179197
# define Z_UTCDATETIME_OBJ_P(zv) ((php_phongo_utcdatetime_t *)zend_object_store_get_object(zv TSRMLS_CC))
180198
# define Z_COMMANDFAILEDEVENT_OBJ_P(zv) ((php_phongo_commandfailedevent_t *)zend_object_store_get_object(zv TSRMLS_CC))
181199
# define Z_COMMANDSTARTEDEVENT_OBJ_P(zv) ((php_phongo_commandstartedevent_t *)zend_object_store_get_object(zv TSRMLS_CC))
@@ -195,13 +213,16 @@ static inline php_phongo_commandsucceededevent_t* php_commandsucceededevent_fetc
195213
# define Z_OBJ_WRITEERROR(zo) ((php_phongo_writeerror_t *)zo)
196214
# define Z_OBJ_WRITERESULT(zo) ((php_phongo_writeresult_t *)zo)
197215
# define Z_OBJ_BINARY(zo) ((php_phongo_binary_t *)zo)
216+
# define Z_OBJ_DBPOINTER(zo) ((php_phongo_dbpointer_t *)zo)
198217
# define Z_OBJ_DECIMAL128(zo) ((php_phongo_decimal128_t *)zo)
199218
# define Z_OBJ_JAVASCRIPT(zo) ((php_phongo_javascript_t *)zo)
200219
# define Z_OBJ_MAXKEY(zo) ((php_phongo_maxkey_t *)zo)
201220
# define Z_OBJ_MINKEY(zo) ((php_phongo_minkey_t *)zo)
202221
# define Z_OBJ_OBJECTID(zo) ((php_phongo_objectid_t *)zo)
203222
# define Z_OBJ_REGEX(zo) ((php_phongo_regex_t *)zo)
223+
# define Z_OBJ_SYMBOL(zo) ((php_phongo_symbol_t *)zo)
204224
# define Z_OBJ_TIMESTAMP(zo) ((php_phongo_timestamp_t *)zo)
225+
# define Z_OBJ_UNDEFINED(zo) ((php_phongo_undefined_t *)zo)
205226
# define Z_OBJ_UTCDATETIME(zo) ((php_phongo_utcdatetime_t *)zo)
206227
# define Z_OBJ_COMMANDFAILEDEVENT(zo) ((php_phongo_commandfailedevent_t *)zo)
207228
# define Z_OBJ_COMMANDSTARTEDEVENT(zo) ((php_phongo_commandstartedevent_t *)zo)
@@ -247,13 +268,16 @@ extern zend_class_entry *php_phongo_persistable_ce;
247268
extern zend_class_entry *php_phongo_unserializable_ce;
248269
extern zend_class_entry *php_phongo_serializable_ce;
249270
extern zend_class_entry *php_phongo_binary_ce;
271+
extern zend_class_entry *php_phongo_dbpointer_ce;
250272
extern zend_class_entry *php_phongo_decimal128_ce;
251273
extern zend_class_entry *php_phongo_javascript_ce;
252274
extern zend_class_entry *php_phongo_maxkey_ce;
253275
extern zend_class_entry *php_phongo_minkey_ce;
254276
extern zend_class_entry *php_phongo_objectid_ce;
255277
extern zend_class_entry *php_phongo_regex_ce;
278+
extern zend_class_entry *php_phongo_symbol_ce;
256279
extern zend_class_entry *php_phongo_timestamp_ce;
280+
extern zend_class_entry *php_phongo_undefined_ce;
257281
extern zend_class_entry *php_phongo_utcdatetime_ce;
258282

259283
extern zend_class_entry *php_phongo_binary_interface_ce;
@@ -273,6 +297,7 @@ extern zend_class_entry *php_phongo_commandsucceededevent_ce;
273297
extern zend_class_entry *php_phongo_subscriber_ce;
274298

275299
extern void php_phongo_binary_init_ce(INIT_FUNC_ARGS);
300+
extern void php_phongo_dbpointer_init_ce(INIT_FUNC_ARGS);
276301
extern void php_phongo_decimal128_init_ce(INIT_FUNC_ARGS);
277302
extern void php_phongo_javascript_init_ce(INIT_FUNC_ARGS);
278303
extern void php_phongo_maxkey_init_ce(INIT_FUNC_ARGS);
@@ -281,10 +306,12 @@ extern void php_phongo_objectid_init_ce(INIT_FUNC_ARGS);
281306
extern void php_phongo_persistable_init_ce(INIT_FUNC_ARGS);
282307
extern void php_phongo_regex_init_ce(INIT_FUNC_ARGS);
283308
extern void php_phongo_serializable_init_ce(INIT_FUNC_ARGS);
309+
extern void php_phongo_symbol_init_ce(INIT_FUNC_ARGS);
284310
extern void php_phongo_timestamp_init_ce(INIT_FUNC_ARGS);
285311
extern void php_phongo_type_init_ce(INIT_FUNC_ARGS);
286-
extern void php_phongo_utcdatetime_init_ce(INIT_FUNC_ARGS);
312+
extern void php_phongo_undefined_init_ce(INIT_FUNC_ARGS);
287313
extern void php_phongo_unserializable_init_ce(INIT_FUNC_ARGS);
314+
extern void php_phongo_utcdatetime_init_ce(INIT_FUNC_ARGS);
288315

289316
extern void php_phongo_binary_interface_init_ce(INIT_FUNC_ARGS);
290317
extern void php_phongo_decimal128_interface_init_ce(INIT_FUNC_ARGS);

php_phongo_structs.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ typedef struct {
147147
PHONGO_ZEND_OBJECT_POST
148148
} php_phongo_binary_t;
149149

150+
typedef struct {
151+
PHONGO_ZEND_OBJECT_PRE
152+
char *ref;
153+
size_t ref_len;
154+
char id[25];
155+
HashTable *properties;
156+
PHONGO_ZEND_OBJECT_POST
157+
} php_phongo_dbpointer_t;
158+
150159
typedef struct {
151160
PHONGO_ZEND_OBJECT_PRE
152161
bool initialized;
@@ -192,6 +201,14 @@ typedef struct {
192201
PHONGO_ZEND_OBJECT_POST
193202
} php_phongo_regex_t;
194203

204+
typedef struct {
205+
PHONGO_ZEND_OBJECT_PRE
206+
char *symbol;
207+
size_t symbol_len;
208+
HashTable *properties;
209+
PHONGO_ZEND_OBJECT_POST
210+
} php_phongo_symbol_t;
211+
195212
typedef struct {
196213
PHONGO_ZEND_OBJECT_PRE
197214
bool initialized;
@@ -201,6 +218,11 @@ typedef struct {
201218
PHONGO_ZEND_OBJECT_POST
202219
} php_phongo_timestamp_t;
203220

221+
typedef struct {
222+
PHONGO_ZEND_OBJECT_PRE
223+
PHONGO_ZEND_OBJECT_POST
224+
} php_phongo_undefined_t;
225+
204226
typedef struct {
205227
PHONGO_ZEND_OBJECT_PRE
206228
bool initialized;

0 commit comments

Comments
 (0)