36 #include <Zend/zend_exceptions.h>
55 ZEND_BEGIN_ARG_INFO_EX(arginfo_getByIndex, 0, 0, 1)
56 ZEND_ARG_INFO(0,
index)
95 RETURN_STRING(
intern->name);
105 RETURN_LONG(
intern->number);
166 zend_string *
str = zend_string_init(classname, strlen(classname), 0);
167 zend_class_entry *ce = zend_lookup_class(
str);
169 zend_string_release (
str);
172 zend_error(E_ERROR,
"Couldn't load generated class %s", classname);
191 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"l", &
index) == FAILURE) {
192 zend_error(E_USER_ERROR,
"Expect integer for index.\n");
197 if (index < 0 || index >= field_num) {
198 zend_error(E_USER_ERROR,
"Cannot get element at %ld.\n",
index);
235 PHP_ME(
EnumDescriptor, getPublicDescriptor, arginfo_void, ZEND_ACC_PUBLIC)
236 PHP_ME(
EnumDescriptor, getValueCount, arginfo_void, ZEND_ACC_PUBLIC)
237 PHP_ME(
EnumDescriptor, getValue, arginfo_getByIndex, ZEND_ACC_PUBLIC)
295 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"l", &
index) == FAILURE) {
296 zend_error(E_USER_ERROR,
"Expect integer for index.\n");
301 if (index < 0 || index >= field_num) {
302 zend_error(E_USER_ERROR,
"Cannot get element at %ld.\n",
index);
370 #define CASE(descriptor_type, type) \
371 case UPB_DESCRIPTOR_TYPE_##descriptor_type: \
372 return UPB_TYPE_##type;
375 CASE(DOUBLE, DOUBLE);
377 CASE(STRING, STRING);
384 CASE(UINT32, UINT32);
385 CASE(UINT64, UINT64);
388 CASE(FIXED32, UINT32);
389 CASE(FIXED64, UINT64);
390 CASE(SFIXED32, INT32);
391 CASE(SFIXED64, INT64);
397 zend_error(E_ERROR,
"Unknown field type.");
462 zend_throw_exception_ex(NULL, 0,
463 "Cannot get enum type for non-enum field '%s'",
482 zend_throw_exception_ex(
483 NULL, 0,
"Cannot get message type for non-message field '%s'",
517 zend_string *
str = zend_string_init(classname, strlen(classname), 0);
518 zend_class_entry *ce = zend_lookup_class(
str);
520 zend_string_release (
str);
523 zend_error(E_ERROR,
"Couldn't load generated class %s", classname);
537 zend_class_entry *ce = NULL;
548 ret->class_entry = ce;
565 if (Z_TYPE_P(val) == IS_NULL) {
627 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"l", &
index) == FAILURE) {
628 zend_error(E_USER_ERROR,
"Expect integer for index.\n");
632 if (index < 0 || index >=
count) {
633 zend_error(E_USER_ERROR,
"Cannot get element at %ld.\n",
index);
662 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"l", &
index) == FAILURE) {
663 zend_error(E_USER_ERROR,
"Expect integer for index.\n");
668 if (index < 0 || index >= field_num) {
669 zend_error(E_USER_ERROR,
"Cannot get element at %ld.\n",
index);
701 const char* classname = ZSTR_VAL(
intern->class_entry->name);
702 RETURN_STRING(classname);
707 PHP_ME(
Descriptor, getClass, arginfo_void, ZEND_ACC_PUBLIC)
708 PHP_ME(
Descriptor, getFullName, arginfo_void, ZEND_ACC_PUBLIC)
709 PHP_ME(
Descriptor, getField, arginfo_getByIndex, ZEND_ACC_PUBLIC)
710 PHP_ME(
Descriptor, getFieldCount, arginfo_void, ZEND_ACC_PUBLIC)
711 PHP_ME(
Descriptor, getOneofDecl, arginfo_getByIndex, ZEND_ACC_PUBLIC)
712 PHP_ME(
Descriptor, getOneofDeclCount, arginfo_void, ZEND_ACC_PUBLIC)
713 PHP_ME(
Descriptor, getPublicDescriptor, arginfo_void, ZEND_ACC_PUBLIC)
743 zend_object_std_dtor(&
intern->std);
778 char *classname = NULL;
779 zend_long classname_len;
780 zend_class_entry *ce;
784 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"s", &classname, &classname_len) ==
789 str = zend_string_init(classname, strlen(classname), 0);
790 ce = zend_lookup_class(
str);
791 zend_string_release (
str);
807 char *classname = NULL;
808 zend_long classname_len;
809 zend_class_entry *ce;
813 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"s", &classname, &classname_len) ==
818 str = zend_string_init(classname, strlen(classname), 0);
819 ce = zend_lookup_class(
str);
820 zend_string_release (
str);
837 char *protoname = NULL;
838 zend_long protoname_len;
841 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"s", &protoname, &protoname_len) ==
846 if (*protoname ==
'.') protoname++;
868 for (
i = 0;
i <
n;
i++) {
937 zend_error(E_ERROR,
"Failed to parse binary descriptor\n");
943 for (
i = 0;
i <
n;
i++) {
961 zend_error(E_ERROR,
"Failed to parse binary descriptor for %s\n",
filename);
978 zend_bool use_nested_submsg =
false;
981 if (zend_parse_parameters(ZEND_NUM_ARGS(),
"s|b", &
data, &data_len,
982 &use_nested_submsg) !=
SUCCESS) {
991 ZEND_BEGIN_ARG_INFO_EX(arginfo_lookupByName, 0, 0, 1)
992 ZEND_ARG_INFO(0,
name)
995 ZEND_BEGIN_ARG_INFO_EX(arginfo_addgeneratedfile, 0, 0, 2)
996 ZEND_ARG_INFO(0,
data)
997 ZEND_ARG_INFO(0, data_len)
1002 ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
1003 PHP_ME(
DescriptorPool, getDescriptorByClassName, arginfo_lookupByName, ZEND_ACC_PUBLIC)
1004 PHP_ME(
DescriptorPool, getDescriptorByProtoName, arginfo_lookupByName, ZEND_ACC_PUBLIC)
1005 PHP_ME(
DescriptorPool, getEnumDescriptorByClassName, arginfo_lookupByName, ZEND_ACC_PUBLIC)
1006 PHP_ME(
DescriptorPool, internalAddGeneratedFile, arginfo_addgeneratedfile, ZEND_ACC_PUBLIC)
1033 ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
1052 zend_class_entry tmp_ce;
1053 zend_object_handlers *h;
1055 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\OneofDescriptor",
1061 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));
1064 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\EnumValueDescriptor",
1070 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));
1072 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\EnumDescriptor",
1078 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));
1081 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\Descriptor",
1088 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));
1091 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\FieldDescriptor",
1097 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));
1100 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\DescriptorPool",
1106 memcpy(h, &std_object_handlers,
sizeof(zend_object_handlers));
1109 INIT_CLASS_ENTRY(tmp_ce,
"Google\\Protobuf\\Internal\\DescriptorPool",
1114 #define STR(str) (str), strlen(str)
1115 zend_class_entry class_type;
1116 INIT_CLASS_ENTRY(class_type,
"Google\\Protobuf\\Internal\\GPBType",