33 #include <Zend/zend_API.h>
34 #include <Zend/zend_interfaces.h>
36 #include <ext/spl/spl_iterators.h>
39 #include <Zend/zend_exceptions.h>
74 zend_object_std_init(&
intern->std, class_type);
92 zval_ptr_dtor(&
intern->arena);
93 zend_object_std_dtor(&
intern->std);
128 for (
i = 0;
i <
n;
i++) {
144 int type,
void **cache_slot) {
174 if (Z_ISREF_P(val)) {
178 if (Z_TYPE_P(val) == IS_ARRAY) {
181 HashTable *
table = HASH_OF(val);
184 zend_hash_internal_pointer_reset_ex(
table, &
pos);
187 zval *zv = zend_hash_get_current_data_ex(
table, &
pos);
197 zend_hash_move_forward_ex(
table, &
pos);
199 }
else if (Z_TYPE_P(val) == IS_OBJECT &&
205 php_error_docref(NULL, E_USER_ERROR,
206 "Wrong type for this repeated field.");
212 php_error_docref(NULL, E_USER_ERROR,
"Must be a repeated field");
221 if ((
a1 == NULL) != (
a2 == NULL))
return false;
222 if (
a1 == NULL)
return true;
227 for (
i = 0;
i <
n;
i++) {
250 zend_class_entry*
klass = NULL;
252 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"l|C", &
type, &
klass) !=
SUCCESS) {
260 php_error_docref(NULL, E_USER_ERROR,
261 "Message/enum type must have concrete class.");
281 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"z", &php_val) !=
SUCCESS ||
304 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"l", &
index) == FAILURE) {
329 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"l", &
index) == FAILURE) {
334 zend_error(E_USER_ERROR,
"Element at %ld doesn't exist.\n",
index);
365 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"zz", &
offset, &val) !=
SUCCESS) {
369 if (Z_TYPE_P(
offset) == IS_NULL) {
380 zend_error(E_USER_ERROR,
"Element at index %ld doesn't exist.\n",
index);
405 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"l", &
index) !=
SUCCESS) {
410 php_error_docref(NULL, E_USER_ERROR,
"Cannot remove element at %ld.\n",
431 if (zend_parse_parameters_none() == FAILURE) {
453 ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 1)
454 ZEND_ARG_INFO(0,
type)
455 ZEND_ARG_INFO(0, class)
458 ZEND_BEGIN_ARG_INFO_EX(arginfo_append, 0, 0, 1)
459 ZEND_ARG_INFO(0, newval)
462 ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
463 ZEND_ARG_INFO(0,
index)
466 ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetSet, 0, 0, 2)
467 ZEND_ARG_INFO(0,
index)
468 ZEND_ARG_INFO(0, newval)
472 PHP_ME(
RepeatedField, __construct, arginfo_construct, ZEND_ACC_PUBLIC)
473 PHP_ME(
RepeatedField, append, arginfo_append, ZEND_ACC_PUBLIC)
474 PHP_ME(
RepeatedField, offsetExists, arginfo_offsetGet, ZEND_ACC_PUBLIC)
475 PHP_ME(
RepeatedField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC)
476 PHP_ME(
RepeatedField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC)
477 PHP_ME(
RepeatedField, offsetUnset, arginfo_offsetGet, ZEND_ACC_PUBLIC)
479 PHP_ME(
RepeatedField, getIterator, arginfo_void, ZEND_ACC_PUBLIC)
504 zend_object_std_init(&
intern->std, class_type);
506 ZVAL_NULL(&
intern->repeated_field);
521 zval_ptr_dtor(&
intern->repeated_field);
522 zend_object_std_dtor(&
intern->std);
576 zend_error(E_USER_ERROR,
"Element at %ld doesn't exist.\n",
index);
592 RETURN_LONG(
intern->position);
635 zend_class_entry tmp_ce;
636 zend_object_handlers *h;
639 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\Internal\\RepeatedField",
649 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));
651 #if PHP_VERSION_ID < 80000
661 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\Internal\\RepeatedFieldIter",
670 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));