33 #include <Zend/zend_API.h>
34 #include <Zend/zend_interfaces.h>
36 #include <ext/spl/spl_iterators.h>
89 zend_object_std_init(&
intern->std, class_type);
107 zval_ptr_dtor(&
intern->arena);
108 zend_object_std_dtor(&
intern->std);
155 int type,
void **cache_slot) {
188 if (Z_ISREF_P(val)) {
192 if (Z_TYPE_P(val) == IS_ARRAY) {
194 HashTable *
table = HASH_OF(val);
197 zend_hash_internal_pointer_reset_ex(
table, &
pos);
205 zend_hash_get_current_key_zval_ex(
table, &php_key, &
pos);
206 php_val = zend_hash_get_current_data_ex(
table, &
pos);
208 if (!php_val)
return map;
216 zend_hash_move_forward_ex(
table, &
pos);
219 }
else if (Z_TYPE_P(val) == IS_OBJECT &&
224 php_error_docref(NULL, E_USER_ERROR,
"Wrong type for this map field.");
231 php_error_docref(NULL, E_USER_ERROR,
"Must be a map");
239 if ((m1 == NULL) != (m2 == NULL))
return false;
240 if (m1 == NULL)
return true;
270 zend_class_entry*
klass = NULL;
272 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"ll|C", &
key_type, &val_type,
282 switch (
intern->type.key_type) {
293 zend_error(E_USER_ERROR,
"Invalid key type for map.");
297 php_error_docref(NULL, E_USER_ERROR,
298 "Message/enum type must have concrete class.");
323 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"z", &
key) !=
SUCCESS ||
349 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"z", &
key) !=
SUCCESS ||
355 zend_error(E_USER_ERROR,
"Given key doesn't exist.");
382 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"zz", &
key, &val) !=
SUCCESS ||
407 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"z", &
key) !=
SUCCESS ||
428 if (zend_parse_parameters_none() == FAILURE) {
450 ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 2)
453 ZEND_ARG_INFO(0, value_class)
456 ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
457 ZEND_ARG_INFO(0,
index)
460 ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetSet, 0, 0, 2)
461 ZEND_ARG_INFO(0,
index)
462 ZEND_ARG_INFO(0, newval)
466 PHP_ME(
MapField, __construct, arginfo_construct, ZEND_ACC_PUBLIC)
467 PHP_ME(
MapField, offsetExists, arginfo_offsetGet, ZEND_ACC_PUBLIC)
468 PHP_ME(
MapField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC)
469 PHP_ME(
MapField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC)
470 PHP_ME(
MapField, offsetUnset, arginfo_offsetGet, ZEND_ACC_PUBLIC)
472 PHP_ME(
MapField, getIterator, arginfo_void, ZEND_ACC_PUBLIC)
497 zend_object_std_init(&
intern->std, class_type);
499 ZVAL_NULL(&
intern->map_field);
514 zval_ptr_dtor(&
intern->map_field);
515 zend_object_std_dtor(&
intern->std);
528 ZVAL_COPY(&
iter->map_field, map_field);
613 PHP_ME(
MapFieldIter, rewind, arginfo_void, ZEND_ACC_PUBLIC)
614 PHP_ME(
MapFieldIter, current, arginfo_void, ZEND_ACC_PUBLIC)
632 zend_class_entry tmp_ce;
633 zend_object_handlers *h;
635 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\Internal\\MapField",
645 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));
647 #if PHP_VERSION_ID < 80000
656 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\Internal\\MapFieldIter",
666 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));