|
50 | 50 |
|
51 | 51 | PHONGO_API zend_class_entry *php_phongo_writebatch_ce;
|
52 | 52 |
|
| 53 | +zend_object_handlers php_phongo_handler_writebatch; |
| 54 | + |
53 | 55 | /* {{{ proto MongoDB\Driver\WriteBatch WriteBatch::__construct(boolean $ordered)
|
54 | 56 | Constructs a new WriteBatch */
|
55 | 57 | PHP_METHOD(WriteBatch, __construct)
|
@@ -292,29 +294,72 @@ zend_object_value php_phongo_writebatch_create_object(zend_class_entry *class_ty
|
292 | 294 | zend_object_value retval;
|
293 | 295 | php_phongo_writebatch_t *intern = NULL;
|
294 | 296 |
|
295 |
| - intern = (php_phongo_writebatch_t *)emalloc(sizeof(php_phongo_writebatch_t)); |
296 |
| - memset(intern, 0, sizeof(php_phongo_writebatch_t)); |
| 297 | + intern = (php_phongo_writebatch_t *)ecalloc(1, sizeof *intern); |
297 | 298 |
|
298 | 299 | zend_object_std_init(&intern->std, class_type TSRMLS_CC);
|
299 | 300 | object_properties_init(&intern->std, class_type);
|
300 | 301 |
|
301 | 302 | retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_writebatch_free_object, NULL TSRMLS_CC);
|
302 |
| - retval.handlers = phongo_get_std_object_handlers(); |
| 303 | + retval.handlers = &php_phongo_handler_writebatch; |
303 | 304 |
|
304 | 305 | return retval;
|
305 | 306 | } /* }}} */
|
| 307 | + |
| 308 | +HashTable *php_phongo_writebatch_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ |
| 309 | +{ |
| 310 | + zval retval = zval_used_for_init; |
| 311 | + php_phongo_writebatch_t *intern = NULL; |
| 312 | + |
| 313 | + |
| 314 | + *is_temp = 1; |
| 315 | + intern = (php_phongo_writebatch_t *)zend_object_store_get_object(object TSRMLS_CC); |
| 316 | + array_init(&retval); |
| 317 | + |
| 318 | + if (intern->batch->database) { |
| 319 | + add_assoc_string_ex(&retval, ZEND_STRS("database"), intern->batch->database, 1); |
| 320 | + } else { |
| 321 | + add_assoc_null_ex(&retval, ZEND_STRS("database")); |
| 322 | + } |
| 323 | + |
| 324 | + if (intern->batch->collection) { |
| 325 | + add_assoc_string_ex(&retval, ZEND_STRS("collection"), intern->batch->collection, 1); |
| 326 | + } else { |
| 327 | + add_assoc_null_ex(&retval, ZEND_STRS("collection")); |
| 328 | + } |
| 329 | + |
| 330 | + add_assoc_bool_ex(&retval, ZEND_STRS("ordered"), intern->batch->ordered); |
| 331 | + add_assoc_bool_ex(&retval, ZEND_STRS("executed"), intern->batch->executed); |
| 332 | + add_assoc_long_ex(&retval, ZEND_STRS("hint"), intern->batch->hint); |
| 333 | + |
| 334 | + if (intern->batch->write_concern) { |
| 335 | + zval *write_concern = NULL; |
| 336 | + MAKE_STD_ZVAL(write_concern); |
| 337 | + |
| 338 | + php_phongo_write_concern_to_zval(write_concern, intern->batch->write_concern); |
| 339 | + add_assoc_zval_ex(&retval, ZEND_STRS("write_concern"), write_concern); |
| 340 | + } else { |
| 341 | + add_assoc_null_ex(&retval, ZEND_STRS("write_concern")); |
| 342 | + } |
| 343 | + |
| 344 | + |
| 345 | + |
| 346 | + return Z_ARRVAL(retval); |
| 347 | +} /* }}} */ |
306 | 348 | /* }}} */
|
307 | 349 |
|
308 | 350 | /* {{{ PHP_MINIT_FUNCTION */
|
309 | 351 | PHP_MINIT_FUNCTION(WriteBatch)
|
310 | 352 | {
|
311 |
| - (void)type; /* We don't care if we are loaded via dl() or extension= */ |
312 |
| - (void)module_number; /* We don't care if we are loaded via dl() or extension= */ |
| 353 | + (void)type; (void)module_number; |
313 | 354 | zend_class_entry ce;
|
314 | 355 |
|
315 | 356 | INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "WriteBatch", php_phongo_writebatch_me);
|
316 |
| - ce.create_object = php_phongo_writebatch_create_object; |
317 | 357 | php_phongo_writebatch_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
| 358 | + php_phongo_writebatch_ce->create_object = php_phongo_writebatch_create_object; |
| 359 | + php_phongo_writebatch_ce->ce_flags |= ZEND_ACC_FINAL_CLASS; |
| 360 | + |
| 361 | + memcpy(&php_phongo_handler_writebatch, phongo_get_std_object_handlers(), sizeof(zend_object_handlers)); |
| 362 | + php_phongo_handler_writebatch.get_debug_info = php_phongo_writebatch_get_debug_info; |
318 | 363 |
|
319 | 364 | zend_class_implements(php_phongo_writebatch_ce TSRMLS_CC, 1, spl_ce_Countable);
|
320 | 365 |
|
|
0 commit comments