Skip to content

Commit 24b65ca

Browse files
committed
PHPC-619: Implement Decimal128 type (again)
1 parent 7f761be commit 24b65ca

File tree

8 files changed

+2
-40
lines changed

8 files changed

+2
-40
lines changed

config.m4

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ if test "$MONGODB" != "no"; then
206206
bson-atomic.c \
207207
bson-clock.c \
208208
bson-context.c \
209+
bson-decimal128.c \
209210
bson-error.c \
210211
bson-iter.c \
211212
bson-iso8601.c \
@@ -352,8 +353,6 @@ PHP_ARG_WITH(libbson, whether to use system libbson,
352353
else
353354
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/yajl], $YAJL_SOURCES, [$STD_CFLAGS], shared_objects_mongodb, yes)
354355
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/bson], $BSON_SOURCES, [$STD_CFLAGS], shared_objects_mongodb, yes)
355-
356-
AC_SUBST(BSON_EXPERIMENTAL_FEATURES, 0)
357356
fi
358357

359358
dnl libmongoc stuff {{{
@@ -419,7 +418,6 @@ PHP_ARG_WITH(libmongoc, whether to use system libmongoc,
419418
AC_SUBST(MONGOC_ENABLE_SSL_LIBRESSL, 0)
420419

421420
AC_SUBST(MONGOC_NO_AUTOMATIC_GLOBALS, 1)
422-
AC_SUBST(MONGOC_EXPERIMENTAL_FEATURES, 0)
423421
fi
424422

425423

config.w32

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ if (PHP_MONGODB != "no") {
5151
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Exception", "Exception.c LogicException.c RuntimeException.c UnexpectedValueException.c InvalidArgumentException.c ConnectionException.c AuthenticationException.c SSLConnectionException.c ExecutionTimeoutException.c ConnectionTimeoutException.c WriteException.c BulkWriteException.c", "mongodb");
5252
ADD_SOURCES(configure_module_dirname + "/src/contrib/", "php-ssl.c", "mongodb");
5353
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/yajl", "yajl_version.c yajl.c yajl_encode.c yajl_lex.c yajl_parser.c yajl_buf.c yajl_tree.c yajl_alloc.c yajl_gen.c", "mongodb");
54-
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/bson", "bcon.c bson.c bson-atomic.c bson-clock.c bson-context.c bson-error.c bson-iter.c bson-iso8601.c bson-json.c bson-keys.c bson-md5.c bson-memory.c bson-oid.c bson-reader.c bson-string.c bson-timegm.c bson-utf8.c bson-value.c bson-version-functions.c bson-writer.c", "mongodb");
54+
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/bson", "bcon.c bson.c bson-atomic.c bson-clock.c bson-context.c bson-decimal128.c bson-error.c bson-iter.c bson-iso8601.c bson-json.c bson-keys.c bson-md5.c bson-memory.c bson-oid.c bson-reader.c bson-string.c bson-timegm.c bson-utf8.c bson-value.c bson-version-functions.c bson-writer.c", "mongodb");
5555
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-b64.c mongoc-client.c mongoc-client-pool.c mongoc-cluster.c mongoc-collection.c mongoc-counters.c mongoc-cursor.c mongoc-cursor-array.c mongoc-cursor-cursorid.c mongoc-cursor-transform.c mongoc-database.c mongoc-find-and-modify.c mongoc-host-list.c mongoc-init.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-page.c mongoc-gridfs-file-list.c mongoc-index.c mongoc-list.c mongoc-log.c mongoc-matcher-op.c mongoc-matcher.c mongoc-memcmp.c mongoc-opcode.c mongoc-queue.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-server-description.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-stream.c mongoc-stream-buffered.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-socket.c mongoc-topology.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-concern.c", "mongodb");
5656
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-crypto.c mongoc-scram.c", "mongodb");
5757
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-stream-tls.c mongoc-ssl.c", "mongodb");
@@ -81,7 +81,6 @@ if (PHP_MONGODB != "no") {
8181
BSON_EXTRA_ALIGN: 0,
8282
BSON_HAVE_SYSCALL_TID: 0,
8383
BSON_HAVE_DECIMAL128: 0,
84-
BSON_EXPERIMENTAL_FEATURES: 0
8584
};
8685

8786
if (CHECK_FUNC_IN_HEADER("stdio.h", "_set_output_format")) {
@@ -116,7 +115,6 @@ if (PHP_MONGODB != "no") {
116115
MONGOC_HAVE_SASL_CLIENT_DONE: 0,
117116
MONGOC_HAVE_WEAK_SYMBOLS: 0,
118117
MONGOC_NO_AUTOMATIC_GLOBALS: 1,
119-
MONGOC_EXPERIMENTAL_FEATURES: 0
120118
};
121119

122120
if (CHECK_LIB("ssleay32.lib", "mongodb", PHP_MONGODB) &&

php_phongo.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,6 @@ void php_phongo_new_binary_from_binary_and_type(zval *object, const char *data,
15221522
intern->type = (uint8_t) type;
15231523
} /* }}} */
15241524

1525-
#ifdef BSON_EXPERIMENTAL_FEATURES
15261525
void php_phongo_new_decimal128(zval *object, const bson_decimal128_t *decimal TSRMLS_DC) /* {{{ */
15271526
{
15281527
php_phongo_decimal128_t *intern;
@@ -1533,7 +1532,6 @@ void php_phongo_new_decimal128(zval *object, const bson_decimal128_t *decimal TS
15331532
memcpy(&intern->decimal, decimal, sizeof(bson_decimal128_t));
15341533
intern->initialized = true;
15351534
} /* }}} */
1536-
#endif
15371535

15381536
void php_phongo_new_regex_from_regex_and_options(zval *object, const char *pattern, const char *flags TSRMLS_DC) /* {{{ */
15391537
{
@@ -1931,9 +1929,7 @@ PHP_MINIT_FUNCTION(mongodb)
19311929
PHP_MINIT(Unserializable)(INIT_FUNC_ARGS_PASSTHRU);
19321930
PHP_MINIT(Persistable)(INIT_FUNC_ARGS_PASSTHRU);
19331931
PHP_MINIT(Binary)(INIT_FUNC_ARGS_PASSTHRU);
1934-
#ifdef BSON_EXPERIMENTAL_FEATURES
19351932
PHP_MINIT(Decimal128)(INIT_FUNC_ARGS_PASSTHRU);
1936-
#endif
19371933
PHP_MINIT(Javascript)(INIT_FUNC_ARGS_PASSTHRU);
19381934
PHP_MINIT(MaxKey)(INIT_FUNC_ARGS_PASSTHRU);
19391935
PHP_MINIT(MinKey)(INIT_FUNC_ARGS_PASSTHRU);

php_phongo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ void php_phongo_new_timestamp_from_increment_and_timestamp(zval *object, uint32_
142142
void php_phongo_new_javascript_from_javascript(int init, zval *object, const char *code, size_t code_len TSRMLS_DC);
143143
void php_phongo_new_javascript_from_javascript_and_scope(int init, zval *object, const char *code, size_t code_len, const bson_t *scope TSRMLS_DC);
144144
void php_phongo_new_binary_from_binary_and_type(zval *object, const char *data, size_t data_len, bson_subtype_t type TSRMLS_DC);
145-
#ifdef BSON_EXPERIMENTAL_FEATURES
146145
void php_phongo_new_decimal128(zval *object, const bson_decimal128_t *decimal TSRMLS_DC);
147-
#endif
148146
void php_phongo_new_regex_from_regex_and_options(zval *object, const char *pattern, const char *flags TSRMLS_DC);
149147

150148
zend_bool phongo_writeerror_init(zval *return_value, bson_t *bson TSRMLS_DC);

php_phongo_classes.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ static inline php_phongo_writeresult_t* php_writeresult_fetch_object(zend_object
6565
static inline php_phongo_binary_t* php_binary_fetch_object(zend_object *obj) {
6666
return (php_phongo_binary_t *)((char *)obj - XtOffsetOf(php_phongo_binary_t, std));
6767
}
68-
#ifdef BSON_EXPERIMENTAL_FEATURES
6968
static inline php_phongo_decimal128_t* php_decimal128_fetch_object(zend_object *obj) {
7069
return (php_phongo_decimal128_t *)((char *)obj - XtOffsetOf(php_phongo_decimal128_t, std));
7170
}
72-
#endif
7371
static inline php_phongo_javascript_t* php_javascript_fetch_object(zend_object *obj) {
7472
return (php_phongo_javascript_t *)((char *)obj - XtOffsetOf(php_phongo_javascript_t, std));
7573
}
@@ -106,9 +104,7 @@ static inline php_phongo_utcdatetime_t* php_utcdatetime_fetch_object(zend_object
106104
# define Z_WRITEERROR_OBJ_P(zv) (php_writeerror_fetch_object(Z_OBJ_P(zv)))
107105
# define Z_WRITERESULT_OBJ_P(zv) (php_writeresult_fetch_object(Z_OBJ_P(zv)))
108106
# define Z_BINARY_OBJ_P(zv) (php_binary_fetch_object(Z_OBJ_P(zv)))
109-
#ifdef BSON_EXPERIMENTAL_FEATURES
110107
# define Z_DECIMAL128_OBJ_P(zv) (php_decimal128_fetch_object(Z_OBJ_P(zv)))
111-
#endif
112108
# define Z_JAVASCRIPT_OBJ_P(zv) (php_javascript_fetch_object(Z_OBJ_P(zv)))
113109
# define Z_MAXKEY_OBJ_P(zv) (php_maxkey_fetch_object(Z_OBJ_P(zv)))
114110
# define Z_MINKEY_OBJ_P(zv) (php_minkey_fetch_object(Z_OBJ_P(zv)))
@@ -131,9 +127,7 @@ static inline php_phongo_utcdatetime_t* php_utcdatetime_fetch_object(zend_object
131127
# define Z_OBJ_WRITEERROR(zo) (php_writeerror_fetch_object(zo))
132128
# define Z_OBJ_WRITERESULT(zo) (php_writeresult_fetch_object(zo))
133129
# define Z_OBJ_BINARY(zo) (php_binary_fetch_object(zo))
134-
#ifdef BSON_EXPERIMENTAL_FEATURES
135130
# define Z_OBJ_DECIMAL128(zo) (php_decimal128_fetch_object(zo))
136-
#endif
137131
# define Z_OBJ_JAVASCRIPT(zo) (php_javascript_fetch_object(zo))
138132
# define Z_OBJ_MAXKEY(zo) (php_maxkey_fetch_object(zo))
139133
# define Z_OBJ_MINKEY(zo) (php_minkey_fetch_object(zo))
@@ -158,9 +152,7 @@ static inline php_phongo_utcdatetime_t* php_utcdatetime_fetch_object(zend_object
158152
# define Z_WRITEERROR_OBJ_P(zv) ((php_phongo_writeerror_t *)zend_object_store_get_object(zv TSRMLS_CC))
159153
# define Z_WRITERESULT_OBJ_P(zv) ((php_phongo_writeresult_t *)zend_object_store_get_object(zv TSRMLS_CC))
160154
# define Z_BINARY_OBJ_P(zv) ((php_phongo_binary_t *)zend_object_store_get_object(zv TSRMLS_CC))
161-
#ifdef BSON_EXPERIMENTAL_FEATURES
162155
# define Z_DECIMAL128_OBJ_P(zv) ((php_phongo_decimal128_t *)zend_object_store_get_object(zv TSRMLS_CC))
163-
#endif
164156
# define Z_JAVASCRIPT_OBJ_P(zv) ((php_phongo_javascript_t *)zend_object_store_get_object(zv TSRMLS_CC))
165157
# define Z_MAXKEY_OBJ_P(zv) ((php_phongo_maxkey_t *)zend_object_store_get_object(zv TSRMLS_CC))
166158
# define Z_MINKEY_OBJ_P(zv) ((php_phongo_minkey_t *)zend_object_store_get_object(zv TSRMLS_CC))
@@ -183,9 +175,7 @@ static inline php_phongo_utcdatetime_t* php_utcdatetime_fetch_object(zend_object
183175
# define Z_OBJ_WRITEERROR(zo) ((php_phongo_writeerror_t *)zo)
184176
# define Z_OBJ_WRITERESULT(zo) ((php_phongo_writeresult_t *)zo)
185177
# define Z_OBJ_BINARY(zo) ((php_phongo_binary_t *)zo)
186-
#ifdef BSON_EXPERIMENTAL_FEATURES
187178
# define Z_OBJ_DECIMAL128(zo) ((php_phongo_decimal128_t *)zo)
188-
#endif
189179
# define Z_OBJ_JAVASCRIPT(zo) ((php_phongo_javascript_t *)zo)
190180
# define Z_OBJ_MAXKEY(zo) ((php_phongo_maxkey_t *)zo)
191181
# define Z_OBJ_MINKEY(zo) ((php_phongo_minkey_t *)zo)
@@ -235,9 +225,7 @@ extern PHONGO_API zend_class_entry *php_phongo_persistable_ce;
235225
extern PHONGO_API zend_class_entry *php_phongo_unserializable_ce;
236226
extern PHONGO_API zend_class_entry *php_phongo_serializable_ce;
237227
extern PHONGO_API zend_class_entry *php_phongo_binary_ce;
238-
#ifdef BSON_EXPERIMENTAL_FEATURES
239228
extern PHONGO_API zend_class_entry *php_phongo_decimal128_ce;
240-
#endif
241229
extern PHONGO_API zend_class_entry *php_phongo_javascript_ce;
242230
extern PHONGO_API zend_class_entry *php_phongo_maxkey_ce;
243231
extern PHONGO_API zend_class_entry *php_phongo_minkey_ce;
@@ -284,9 +272,7 @@ PHP_MINIT_FUNCTION(Unserializable);
284272
PHP_MINIT_FUNCTION(Serializable);
285273
PHP_MINIT_FUNCTION(Persistable);
286274
PHP_MINIT_FUNCTION(Binary);
287-
#ifdef BSON_EXPERIMENTAL_FEATURES
288275
PHP_MINIT_FUNCTION(Decimal128);
289-
#endif
290276
PHP_MINIT_FUNCTION(Javascript);
291277
PHP_MINIT_FUNCTION(MaxKey);
292278
PHP_MINIT_FUNCTION(MinKey);

php_phongo_structs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,12 @@ typedef struct {
158158
PHONGO_ZEND_OBJECT_POST
159159
} php_phongo_binary_t;
160160

161-
#ifdef BSON_EXPERIMENTAL_FEATURES
162161
typedef struct {
163162
PHONGO_ZEND_OBJECT_PRE
164163
bool initialized;
165164
bson_decimal128_t decimal;
166165
PHONGO_ZEND_OBJECT_POST
167166
} php_phongo_decimal128_t;
168-
#endif
169167

170168
typedef struct {
171169
PHONGO_ZEND_OBJECT_PRE

src/BSON/Decimal128.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include <bson.h>
2929
#include <mongoc.h>
3030

31-
#ifdef BSON_EXPERIMENTAL_FEATURES
32-
3331
/* PHP Core stuff */
3432
#include <php.h>
3533
#include <php_ini.h>
@@ -285,8 +283,6 @@ PHP_MINIT_FUNCTION(Decimal128)
285283
}
286284
/* }}} */
287285

288-
#endif /* BSON_EXPERIMENTAL_FEATURES */
289-
290286
/*
291287
* Local variables:
292288
* tab-width: 4

src/bson.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ uint8_t php_phongo_binary_get_type(zval *object TSRMLS_DC)
151151
return intern->type;
152152
}
153153

154-
#ifdef BSON_EXPERIMENTAL_FEATURES
155154
static bson_decimal128_t *php_phongo_decimal128_get_decimal128(zval *object TSRMLS_DC)
156155
{
157156
php_phongo_decimal128_t *intern;
@@ -160,7 +159,6 @@ static bson_decimal128_t *php_phongo_decimal128_get_decimal128(zval *object TSRM
160159

161160
return &intern->decimal;
162161
}
163-
#endif
164162

165163
char *php_phongo_regex_get_pattern(zval *object TSRMLS_DC)
166164
{
@@ -349,7 +347,6 @@ bool php_phongo_bson_visit_date_time(const bson_iter_t *iter ARG_UNUSED, const c
349347
}
350348
/* }}} */
351349

352-
#ifdef BSON_EXPERIMENTAL_FEATURES
353350
bool php_phongo_bson_visit_decimal128(const bson_iter_t *iter ARG_UNUSED, const char *key, const bson_decimal128_t *decimal, void *data) /* {{{ */
354351
{
355352
#if PHP_VERSION_ID >= 70000
@@ -373,7 +370,6 @@ bool php_phongo_bson_visit_decimal128(const bson_iter_t *iter ARG_UNUSED, const
373370
return false;
374371
}
375372
/* }}} */
376-
#endif
377373

378374
bool php_phongo_bson_visit_null(const bson_iter_t *iter ARG_UNUSED, const char *key, void *data) /* {{{ */
379375
{
@@ -620,9 +616,7 @@ static const bson_visitor_t php_bson_visitors = {
620616
php_phongo_bson_visit_maxkey,
621617
php_phongo_bson_visit_minkey,
622618
php_phongo_bson_visit_unsupported_type,
623-
#ifdef BSON_EXPERIMENTAL_FEATURES
624619
php_phongo_bson_visit_decimal128,
625-
#endif
626620
{ NULL }
627621
};
628622

@@ -976,13 +970,11 @@ void object_to_bson(zval *object, php_phongo_bson_flags_t flags, const char *key
976970
bson_append_binary(bson, key, key_len, php_phongo_binary_get_type(object TSRMLS_CC), data, data_len);
977971
return;
978972
}
979-
#ifdef BSON_EXPERIMENTAL_FEATURES
980973
if (instanceof_function(Z_OBJCE_P(object), php_phongo_decimal128_ce TSRMLS_CC)) {
981974
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding Decimal128");
982975
bson_append_decimal128(bson, key, key_len, php_phongo_decimal128_get_decimal128(object TSRMLS_CC));
983976
return;
984977
}
985-
#endif
986978
if (instanceof_function(Z_OBJCE_P(object), php_phongo_regex_ce TSRMLS_CC)) {
987979
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding Regex");
988980
bson_append_regex(bson, key, key_len, php_phongo_regex_get_pattern(object TSRMLS_CC), php_phongo_regex_get_flags(object TSRMLS_CC));

0 commit comments

Comments
 (0)