From 77f64bb7779ec2195f9bc4dc82497d12c18fc6b7 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Thu, 5 Oct 2017 21:03:57 -0700 Subject: Add well known types to php runtime. (#3697) * Add well known types to php runtime. * Fix php7.0 tests * No longer generate empty.proto in test as it has been included in runtime. * Fix zts build * Clean code * Rename g_p_b_empty to empty. * Don't generate code for empty.proto in compatibility test * Fix 32-bit * Fix mac build * Fix Makefile.am to add new files --- Makefile.am | 118 +- php/ext/google/protobuf/message.c | 1405 +++++++++++++++++++- php/ext/google/protobuf/protobuf.c | 28 + php/ext/google/protobuf/protobuf.h | 336 ++++- php/ext/google/protobuf/storage.c | 35 +- php/ext/google/protobuf/type_check.c | 37 +- php/src/GPBMetadata/Google/Protobuf/Api.php | 49 + php/src/GPBMetadata/Google/Protobuf/FieldMask.php | 31 + php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php | 30 + .../GPBMetadata/Google/Protobuf/SourceContext.php | 32 + php/src/GPBMetadata/Google/Protobuf/Struct.php | 45 + php/src/GPBMetadata/Google/Protobuf/Type.php | 78 ++ php/src/GPBMetadata/Google/Protobuf/Wrappers.php | 38 + php/src/Google/Protobuf/Api.php | 310 +++++ php/src/Google/Protobuf/BoolValue.php | 58 + php/src/Google/Protobuf/BytesValue.php | 58 + php/src/Google/Protobuf/DoubleValue.php | 58 + php/src/Google/Protobuf/Enum.php | 185 +++ php/src/Google/Protobuf/EnumValue.php | 121 ++ php/src/Google/Protobuf/Field.php | 351 +++++ php/src/Google/Protobuf/FieldMask.php | 209 +++ php/src/Google/Protobuf/Field_Cardinality.php | 39 + php/src/Google/Protobuf/Field_Kind.php | 129 ++ php/src/Google/Protobuf/FloatValue.php | 58 + php/src/Google/Protobuf/GPBEmpty.php | 31 + php/src/Google/Protobuf/Int32Value.php | 58 + php/src/Google/Protobuf/Int64Value.php | 58 + php/src/Google/Protobuf/ListValue.php | 58 + php/src/Google/Protobuf/Method.php | 249 ++++ php/src/Google/Protobuf/Mixin.php | 153 +++ php/src/Google/Protobuf/NullValue.php | 23 + php/src/Google/Protobuf/Option.php | 108 ++ php/src/Google/Protobuf/SourceContext.php | 61 + php/src/Google/Protobuf/StringValue.php | 58 + php/src/Google/Protobuf/Struct.php | 63 + php/src/Google/Protobuf/Syntax.php | 27 + php/src/Google/Protobuf/Type.php | 217 +++ php/src/Google/Protobuf/UInt32Value.php | 58 + php/src/Google/Protobuf/UInt64Value.php | 58 + php/src/Google/Protobuf/Value.php | 194 +++ php/tests/compatibility_test.sh | 1 - php/tests/well_known_test.php | 280 +++- tests.sh | 1 - 43 files changed, 5450 insertions(+), 144 deletions(-) create mode 100644 php/src/GPBMetadata/Google/Protobuf/Api.php create mode 100644 php/src/GPBMetadata/Google/Protobuf/FieldMask.php create mode 100644 php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php create mode 100644 php/src/GPBMetadata/Google/Protobuf/SourceContext.php create mode 100644 php/src/GPBMetadata/Google/Protobuf/Struct.php create mode 100644 php/src/GPBMetadata/Google/Protobuf/Type.php create mode 100644 php/src/GPBMetadata/Google/Protobuf/Wrappers.php create mode 100644 php/src/Google/Protobuf/Api.php create mode 100644 php/src/Google/Protobuf/BoolValue.php create mode 100644 php/src/Google/Protobuf/BytesValue.php create mode 100644 php/src/Google/Protobuf/DoubleValue.php create mode 100644 php/src/Google/Protobuf/Enum.php create mode 100644 php/src/Google/Protobuf/EnumValue.php create mode 100644 php/src/Google/Protobuf/Field.php create mode 100644 php/src/Google/Protobuf/FieldMask.php create mode 100644 php/src/Google/Protobuf/Field_Cardinality.php create mode 100644 php/src/Google/Protobuf/Field_Kind.php create mode 100644 php/src/Google/Protobuf/FloatValue.php create mode 100644 php/src/Google/Protobuf/GPBEmpty.php create mode 100644 php/src/Google/Protobuf/Int32Value.php create mode 100644 php/src/Google/Protobuf/Int64Value.php create mode 100644 php/src/Google/Protobuf/ListValue.php create mode 100644 php/src/Google/Protobuf/Method.php create mode 100644 php/src/Google/Protobuf/Mixin.php create mode 100644 php/src/Google/Protobuf/NullValue.php create mode 100644 php/src/Google/Protobuf/Option.php create mode 100644 php/src/Google/Protobuf/SourceContext.php create mode 100644 php/src/Google/Protobuf/StringValue.php create mode 100644 php/src/Google/Protobuf/Struct.php create mode 100644 php/src/Google/Protobuf/Syntax.php create mode 100644 php/src/Google/Protobuf/Type.php create mode 100644 php/src/Google/Protobuf/UInt32Value.php create mode 100644 php/src/Google/Protobuf/UInt64Value.php create mode 100644 php/src/Google/Protobuf/Value.php diff --git a/Makefile.am b/Makefile.am index 12ff8931..3222ec6f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -585,93 +585,132 @@ objectivec_EXTRA_DIST= \ Protobuf.podspec php_EXTRA_DIST= \ - php/ext/google/protobuf/utf8.h \ - php/ext/google/protobuf/message.c \ - php/ext/google/protobuf/utf8.c \ - php/ext/google/protobuf/package.xml \ - php/ext/google/protobuf/upb.h \ + composer.json \ + php/README.md \ + php/composer.json \ php/ext/google/protobuf/array.c \ + php/ext/google/protobuf/config.m4 \ + php/ext/google/protobuf/def.c \ php/ext/google/protobuf/encode_decode.c \ + php/ext/google/protobuf/map.c \ + php/ext/google/protobuf/message.c \ + php/ext/google/protobuf/package.xml \ + php/ext/google/protobuf/protobuf.c \ php/ext/google/protobuf/protobuf.h \ - php/ext/google/protobuf/type_check.c \ - php/ext/google/protobuf/def.c \ php/ext/google/protobuf/storage.c \ - php/ext/google/protobuf/map.c \ - php/ext/google/protobuf/config.m4 \ + php/ext/google/protobuf/type_check.c \ php/ext/google/protobuf/upb.c \ - php/ext/google/protobuf/protobuf.c \ - php/src/phpdoc.dist.xml \ + php/ext/google/protobuf/upb.h \ + php/ext/google/protobuf/utf8.c \ + php/ext/google/protobuf/utf8.h \ + php/generate_descriptor_protos.sh \ + php/phpunit.xml \ + php/src/GPBMetadata/Google/Protobuf/Any.php \ + php/src/GPBMetadata/Google/Protobuf/Api.php \ + php/src/GPBMetadata/Google/Protobuf/Duration.php \ + php/src/GPBMetadata/Google/Protobuf/FieldMask.php \ + php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php \ + php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \ + php/src/GPBMetadata/Google/Protobuf/SourceContext.php \ + php/src/GPBMetadata/Google/Protobuf/Struct.php \ + php/src/GPBMetadata/Google/Protobuf/Timestamp.php \ + php/src/GPBMetadata/Google/Protobuf/Type.php \ + php/src/GPBMetadata/Google/Protobuf/Wrappers.php \ php/src/Google/Protobuf/Any.php \ + php/src/Google/Protobuf/Api.php \ + php/src/Google/Protobuf/BoolValue.php \ + php/src/Google/Protobuf/BytesValue.php \ php/src/Google/Protobuf/Descriptor.php \ php/src/Google/Protobuf/DescriptorPool.php \ + php/src/Google/Protobuf/DoubleValue.php \ php/src/Google/Protobuf/Duration.php \ + php/src/Google/Protobuf/Enum.php \ php/src/Google/Protobuf/EnumDescriptor.php \ + php/src/Google/Protobuf/EnumValue.php \ php/src/Google/Protobuf/EnumValueDescriptor.php \ + php/src/Google/Protobuf/Field.php \ php/src/Google/Protobuf/FieldDescriptor.php \ - php/src/Google/Protobuf/OneofDescriptor.php \ - php/src/Google/Protobuf/Timestamp.php \ + php/src/Google/Protobuf/FieldMask.php \ + php/src/Google/Protobuf/Field_Cardinality.php \ + php/src/Google/Protobuf/Field_Kind.php \ + php/src/Google/Protobuf/FloatValue.php \ + php/src/Google/Protobuf/GPBEmpty.php \ + php/src/Google/Protobuf/Int32Value.php \ + php/src/Google/Protobuf/Int64Value.php \ php/src/Google/Protobuf/Internal/CodedInputStream.php \ php/src/Google/Protobuf/Internal/CodedOutputStream.php \ + php/src/Google/Protobuf/Internal/Descriptor.php \ php/src/Google/Protobuf/Internal/DescriptorPool.php \ + php/src/Google/Protobuf/Internal/DescriptorProto.php \ php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \ php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php \ - php/src/Google/Protobuf/Internal/DescriptorProto.php \ - php/src/Google/Protobuf/Internal/Descriptor.php \ php/src/Google/Protobuf/Internal/EnumBuilderContext.php \ php/src/Google/Protobuf/Internal/EnumDescriptor.php \ php/src/Google/Protobuf/Internal/EnumDescriptorProto.php \ php/src/Google/Protobuf/Internal/EnumOptions.php \ php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \ php/src/Google/Protobuf/Internal/EnumValueOptions.php \ - php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \ - php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \ php/src/Google/Protobuf/Internal/FieldDescriptor.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \ php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \ + php/src/Google/Protobuf/Internal/FieldOptions.php \ php/src/Google/Protobuf/Internal/FieldOptions_CType.php \ php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \ - php/src/Google/Protobuf/Internal/FieldOptions.php \ + php/src/Google/Protobuf/Internal/FileDescriptor.php \ php/src/Google/Protobuf/Internal/FileDescriptorProto.php \ php/src/Google/Protobuf/Internal/FileDescriptorSet.php \ - php/src/Google/Protobuf/Internal/FileDescriptor.php \ - php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \ php/src/Google/Protobuf/Internal/FileOptions.php \ - php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \ - php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \ - php/src/Google/Protobuf/Internal/GetPublicDescriptorTrait.php \ + php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \ php/src/Google/Protobuf/Internal/GPBDecodeException.php \ php/src/Google/Protobuf/Internal/GPBJsonWire.php \ php/src/Google/Protobuf/Internal/GPBLabel.php \ php/src/Google/Protobuf/Internal/GPBType.php \ php/src/Google/Protobuf/Internal/GPBUtil.php \ - php/src/Google/Protobuf/Internal/GPBWireType.php \ php/src/Google/Protobuf/Internal/GPBWire.php \ + php/src/Google/Protobuf/Internal/GPBWireType.php \ + php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \ + php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \ + php/src/Google/Protobuf/Internal/GetPublicDescriptorTrait.php \ php/src/Google/Protobuf/Internal/HasPublicDescriptorTrait.php \ php/src/Google/Protobuf/Internal/MapEntry.php \ - php/src/Google/Protobuf/Internal/MapFieldIter.php \ php/src/Google/Protobuf/Internal/MapField.php \ + php/src/Google/Protobuf/Internal/MapFieldIter.php \ + php/src/Google/Protobuf/Internal/Message.php \ php/src/Google/Protobuf/Internal/MessageBuilderContext.php \ php/src/Google/Protobuf/Internal/MessageOptions.php \ - php/src/Google/Protobuf/Internal/Message.php \ php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \ - php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \ php/src/Google/Protobuf/Internal/MethodOptions.php \ - php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \ + php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \ php/src/Google/Protobuf/Internal/OneofDescriptor.php \ + php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \ php/src/Google/Protobuf/Internal/OneofField.php \ php/src/Google/Protobuf/Internal/OneofOptions.php \ php/src/Google/Protobuf/Internal/RawInputStream.php \ - php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \ php/src/Google/Protobuf/Internal/RepeatedField.php \ + php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \ php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \ php/src/Google/Protobuf/Internal/ServiceOptions.php \ - php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \ php/src/Google/Protobuf/Internal/SourceCodeInfo.php \ - php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \ + php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \ php/src/Google/Protobuf/Internal/UninterpretedOption.php \ - php/src/GPBMetadata/Google/Protobuf/Any.php \ - php/src/GPBMetadata/Google/Protobuf/Duration.php \ - php/src/GPBMetadata/Google/Protobuf/Timestamp.php \ - php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \ + php/src/Google/Protobuf/ListValue.php \ + php/src/Google/Protobuf/Method.php \ + php/src/Google/Protobuf/Mixin.php \ + php/src/Google/Protobuf/NullValue.php \ + php/src/Google/Protobuf/OneofDescriptor.php \ + php/src/Google/Protobuf/Option.php \ + php/src/Google/Protobuf/SourceContext.php \ + php/src/Google/Protobuf/StringValue.php \ + php/src/Google/Protobuf/Struct.php \ + php/src/Google/Protobuf/Syntax.php \ + php/src/Google/Protobuf/Timestamp.php \ + php/src/Google/Protobuf/Type.php \ + php/src/Google/Protobuf/UInt32Value.php \ + php/src/Google/Protobuf/UInt64Value.php \ + php/src/Google/Protobuf/Value.php \ + php/src/phpdoc.dist.xml \ php/tests/array_test.php \ php/tests/autoload.php \ php/tests/bootstrap_phpunit.php \ @@ -685,11 +724,11 @@ php_EXTRA_DIST= \ php/tests/map_field_test.php \ php/tests/memory_leak_test.php \ php/tests/php_implementation_test.php \ + php/tests/proto/test.proto \ php/tests/proto/test_descriptors.proto \ php/tests/proto/test_empty_php_namespace.proto \ php/tests/proto/test_import_descriptor_proto.proto \ php/tests/proto/test_include.proto \ - php/tests/proto/test.proto \ php/tests/proto/test_no_namespace.proto \ php/tests/proto/test_php_namespace.proto \ php/tests/proto/test_prefix.proto \ @@ -698,13 +737,8 @@ php_EXTRA_DIST= \ php/tests/test.sh \ php/tests/test_base.php \ php/tests/test_util.php \ - php/tests/well_known_test.php \ php/tests/undefined_test.php \ - php/README.md \ - php/composer.json \ - php/generate_descriptor_protos.sh \ - php/phpunit.xml \ - composer.json + php/tests/well_known_test.php python_EXTRA_DIST= \ python/MANIFEST.in \ diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 50a0430c..6ebf1b9d 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -38,6 +38,7 @@ zend_class_entry* message_type; zend_object_handlers* message_handlers; static const char TYPE_URL_PREFIX[] = "type.googleapis.com/"; +static void hex_to_binary(const char* hex, char** binary, int* binary_len); static zend_function_entry message_methods[] = { PHP_ME(Message, clear, NULL, ZEND_ACC_PUBLIC) @@ -158,16 +159,26 @@ static zval* message_get_property_internal(zval* object, #if PHP_MAJOR_VERSION < 7 property_info = zend_get_property_info(Z_OBJCE_P(object), member, true TSRMLS_CC); - return layout_get( - self->descriptor->layout, message_data(self), field, - OBJ_PROP(Z_OBJ_P(object), property_info->offset) TSRMLS_CC); #else property_info = zend_get_property_info(Z_OBJCE_P(object), Z_STR_P(member), true); +#endif return layout_get( self->descriptor->layout, message_data(self), field, OBJ_PROP(Z_OBJ_P(object), property_info->offset) TSRMLS_CC); -#endif +} + +static void message_get_oneof_property_internal(zval* object, zval* member, + zval* return_value TSRMLS_DC) { + MessageHeader* self = UNBOX(MessageHeader, object); + const upb_fielddef* field; + field = upb_msgdef_ntofz(self->descriptor->msgdef, Z_STRVAL_P(member)); + if (field == NULL) { + return; + } + + layout_get(self->descriptor->layout, message_data(self), field, + ZVAL_PTR_TO_CACHED_PTR(return_value) TSRMLS_CC); } #if PHP_MAJOR_VERSION < 7 @@ -311,11 +322,6 @@ PHP_METHOD(Message, readOneof) { const upb_fielddef* field = upb_msgdef_itof(msg->descriptor->msgdef, index); - int property_cache_index = - msg->descriptor->layout->fields[upb_fielddef_index(field)].cache_index; - zval* property_ptr = CACHED_PTR_TO_ZVAL_PTR( - OBJ_PROP(Z_OBJ_P(getThis()), property_cache_index)); - // Unlike singular fields, oneof fields share cached property. So we cannot // let lay_get modify the cached property. Instead, we pass in the return // value directly. @@ -382,6 +388,474 @@ PHP_METHOD(Message, whichOneof) { PHP_PROTO_RETVAL_ZVAL(getThis()); \ } +#define PHP_PROTO_ONEOF_FIELD_ACCESSORS(UPPER_CLASS, LOWER_CLASS, UPPER_FIELD, \ + LOWER_FIELD) \ + PHP_METHOD(UPPER_CLASS, get##UPPER_FIELD) { \ + zval member; \ + PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 1); \ + PHP_PROTO_FAKE_SCOPE_BEGIN(LOWER_CLASS##_type); \ + message_get_oneof_property_internal(getThis(), &member, \ + return_value TSRMLS_CC); \ + PHP_PROTO_FAKE_SCOPE_END; \ + } \ + PHP_METHOD(UPPER_CLASS, set##UPPER_FIELD) { \ + zval* value = NULL; \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == \ + FAILURE) { \ + return; \ + } \ + zval member; \ + PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 1); \ + message_set_property_internal(getThis(), &member, value TSRMLS_CC); \ + PHP_PROTO_RETVAL_ZVAL(getThis()); \ + } + +#define PHP_PROTO_ONEOF_ACCESSORS(UPPER_CLASS, LOWER_CLASS, UPPER_FIELD, \ + LOWER_FIELD) \ + PHP_METHOD(UPPER_CLASS, get##UPPER_FIELD) { \ + MessageHeader* msg = UNBOX(MessageHeader, getThis()); \ + PHP_PROTO_FAKE_SCOPE_BEGIN(LOWER_CLASS##_type); \ + const upb_oneofdef* oneof = upb_msgdef_ntoo( \ + msg->descriptor->msgdef, LOWER_FIELD, strlen(LOWER_FIELD)); \ + const char* oneof_case_name = layout_get_oneof_case( \ + msg->descriptor->layout, message_data(msg), oneof TSRMLS_CC); \ + PHP_PROTO_FAKE_SCOPE_END; \ + PHP_PROTO_RETURN_STRING(oneof_case_name, 1); \ + } + +// Forward declare file init functions +static void init_file_any(TSRMLS_D); +static void init_file_api(TSRMLS_D); +static void init_file_duration(TSRMLS_D); +static void init_file_field_mask(TSRMLS_D); +static void init_file_empty(TSRMLS_D); +static void init_file_source_context(TSRMLS_D); +static void init_file_struct(TSRMLS_D); +static void init_file_timestamp(TSRMLS_D); +static void init_file_type(TSRMLS_D); +static void init_file_wrappers(TSRMLS_D); + +// Define file init functions +static void init_file_any(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0acd010a19676f6f676c652f70726f746f6275662f616e792e70726f746f" + "120f676f6f676c652e70726f746f62756622260a03416e7912100a087479" + "70655f75726c180120012809120d0a0576616c756518022001280c426f0a" + "13636f6d2e676f6f676c652e70726f746f6275664208416e7950726f746f" + "50015a256769746875622e636f6d2f676f6c616e672f70726f746f627566" + "2f7074797065732f616e79a20203475042aa021e476f6f676c652e50726f" + "746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +static void init_file_api(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_file_source_context(TSRMLS_C); + init_file_type(TSRMLS_C); + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0aee050a19676f6f676c652f70726f746f6275662f6170692e70726f746f" + "120f676f6f676c652e70726f746f6275661a24676f6f676c652f70726f74" + "6f6275662f736f757263655f636f6e746578742e70726f746f1a1a676f6f" + "676c652f70726f746f6275662f747970652e70726f746f2281020a034170" + "69120c0a046e616d6518012001280912280a076d6574686f647318022003" + "280b32172e676f6f676c652e70726f746f6275662e4d6574686f6412280a" + "076f7074696f6e7318032003280b32172e676f6f676c652e70726f746f62" + "75662e4f7074696f6e120f0a0776657273696f6e18042001280912360a0e" + "736f757263655f636f6e7465787418052001280b321e2e676f6f676c652e" + "70726f746f6275662e536f75726365436f6e7465787412260a066d697869" + "6e7318062003280b32162e676f6f676c652e70726f746f6275662e4d6978" + "696e12270a0673796e74617818072001280e32172e676f6f676c652e7072" + "6f746f6275662e53796e74617822d5010a064d6574686f64120c0a046e61" + "6d6518012001280912180a10726571756573745f747970655f75726c1802" + "2001280912190a11726571756573745f73747265616d696e671803200128" + "0812190a11726573706f6e73655f747970655f75726c180420012809121a" + "0a12726573706f6e73655f73747265616d696e6718052001280812280a07" + "6f7074696f6e7318062003280b32172e676f6f676c652e70726f746f6275" + "662e4f7074696f6e12270a0673796e74617818072001280e32172e676f6f" + "676c652e70726f746f6275662e53796e74617822230a054d6978696e120c" + "0a046e616d65180120012809120c0a04726f6f7418022001280942750a13" + "636f6d2e676f6f676c652e70726f746f627566420841706950726f746f50" + "015a2b676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f" + "70726f746f6275662f6170693b617069a20203475042aa021e476f6f676c" + "652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f" + "746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +static void init_file_duration(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0ae3010a1e676f6f676c652f70726f746f6275662f6475726174696f6e2e" + "70726f746f120f676f6f676c652e70726f746f627566222a0a0844757261" + "74696f6e120f0a077365636f6e6473180120012803120d0a056e616e6f73" + "180220012805427c0a13636f6d2e676f6f676c652e70726f746f62756642" + "0d4475726174696f6e50726f746f50015a2a6769746875622e636f6d2f67" + "6f6c616e672f70726f746f6275662f7074797065732f6475726174696f6e" + "f80101a20203475042aa021e476f6f676c652e50726f746f6275662e5765" + "6c6c4b6e6f776e5479706573620670726f746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +static void init_file_field_mask(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0ae3010a20676f6f676c652f70726f746f6275662f6669656c645f6d6173" + "6b2e70726f746f120f676f6f676c652e70726f746f627566221a0a094669" + "656c644d61736b120d0a0570617468731801200328094289010a13636f6d" + "2e676f6f676c652e70726f746f627566420e4669656c644d61736b50726f" + "746f50015a39676f6f676c652e676f6c616e672e6f72672f67656e70726f" + "746f2f70726f746f6275662f6669656c645f6d61736b3b6669656c645f6d" + "61736ba20203475042aa021e476f6f676c652e50726f746f6275662e5765" + "6c6c4b6e6f776e5479706573620670726f746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +static void init_file_empty(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0ab7010a1b676f6f676c652f70726f746f6275662f656d7074792e70726f" + "746f120f676f6f676c652e70726f746f62756622070a05456d7074794276" + "0a13636f6d2e676f6f676c652e70726f746f627566420a456d7074795072" + "6f746f50015a276769746875622e636f6d2f676f6c616e672f70726f746f" + "6275662f7074797065732f656d707479f80101a20203475042aa021e476f" + "6f676c652e50726f746f6275662e57656c6c4b6e6f776e54797065736206" + "70726f746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +static void init_file_source_context(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0afb010a24676f6f676c652f70726f746f6275662f736f757263655f636f" + "6e746578742e70726f746f120f676f6f676c652e70726f746f6275662222" + "0a0d536f75726365436f6e7465787412110a0966696c655f6e616d651801" + "200128094295010a13636f6d2e676f6f676c652e70726f746f6275664212" + "536f75726365436f6e7465787450726f746f50015a41676f6f676c652e67" + "6f6c616e672e6f72672f67656e70726f746f2f70726f746f6275662f736f" + "757263655f636f6e746578743b736f757263655f636f6e74657874a20203" + "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77" + "6e5479706573620670726f746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +static void init_file_struct(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0a81050a1c676f6f676c652f70726f746f6275662f7374727563742e7072" + "6f746f120f676f6f676c652e70726f746f6275662284010a065374727563" + "7412330a066669656c647318012003280b32232e676f6f676c652e70726f" + "746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669" + "656c6473456e747279120b0a036b657918012001280912250a0576616c75" + "6518022001280b32162e676f6f676c652e70726f746f6275662e56616c75" + "653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518" + "012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c5661" + "6c7565480012160a0c6e756d6265725f76616c7565180220012801480012" + "160a0c737472696e675f76616c7565180320012809480012140a0a626f6f" + "6c5f76616c75651804200128084800122f0a0c7374727563745f76616c75" + "6518052001280b32172e676f6f676c652e70726f746f6275662e53747275" + "6374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f" + "676c652e70726f746f6275662e4c69737456616c7565480042060a046b69" + "6e6422330a094c69737456616c756512260a0676616c7565731801200328" + "0b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e" + "756c6c56616c7565120e0a0a4e554c4c5f56414c554510004281010a1363" + "6f6d2e676f6f676c652e70726f746f627566420b53747275637450726f74" + "6f50015a316769746875622e636f6d2f676f6c616e672f70726f746f6275" + "662f7074797065732f7374727563743b7374727563747062f80101a20203" + "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77" + "6e5479706573620670726f746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +static void init_file_timestamp(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0ae7010a1f676f6f676c652f70726f746f6275662f74696d657374616d70" + "2e70726f746f120f676f6f676c652e70726f746f627566222b0a0954696d" + "657374616d70120f0a077365636f6e6473180120012803120d0a056e616e" + "6f73180220012805427e0a13636f6d2e676f6f676c652e70726f746f6275" + "66420e54696d657374616d7050726f746f50015a2b6769746875622e636f" + "6d2f676f6c616e672f70726f746f6275662f7074797065732f74696d6573" + "74616d70f80101a20203475042aa021e476f6f676c652e50726f746f6275" + "662e57656c6c4b6e6f776e5479706573620670726f746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +static void init_file_type(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_file_any(TSRMLS_C); + init_file_source_context(TSRMLS_C); + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0aba0c0a1a676f6f676c652f70726f746f6275662f747970652e70726f74" + "6f120f676f6f676c652e70726f746f6275661a19676f6f676c652f70726f" + "746f6275662f616e792e70726f746f1a24676f6f676c652f70726f746f62" + "75662f736f757263655f636f6e746578742e70726f746f22d7010a045479" + "7065120c0a046e616d6518012001280912260a066669656c647318022003" + "280b32162e676f6f676c652e70726f746f6275662e4669656c64120e0a06" + "6f6e656f667318032003280912280a076f7074696f6e7318042003280b32" + "172e676f6f676c652e70726f746f6275662e4f7074696f6e12360a0e736f" + "757263655f636f6e7465787418052001280b321e2e676f6f676c652e7072" + "6f746f6275662e536f75726365436f6e7465787412270a0673796e746178" + "18062001280e32172e676f6f676c652e70726f746f6275662e53796e7461" + "7822d5050a054669656c6412290a046b696e6418012001280e321b2e676f" + "6f676c652e70726f746f6275662e4669656c642e4b696e6412370a0b6361" + "7264696e616c69747918022001280e32222e676f6f676c652e70726f746f" + "6275662e4669656c642e43617264696e616c697479120e0a066e756d6265" + "72180320012805120c0a046e616d6518042001280912100a08747970655f" + "75726c18062001280912130a0b6f6e656f665f696e646578180720012805" + "120e0a067061636b656418082001280812280a076f7074696f6e73180920" + "03280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e1211" + "0a096a736f6e5f6e616d65180a2001280912150a0d64656661756c745f76" + "616c7565180b2001280922c8020a044b696e6412100a0c545950455f554e" + "4b4e4f574e1000120f0a0b545950455f444f55424c451001120e0a0a5459" + "50455f464c4f41541002120e0a0a545950455f494e5436341003120f0a0b" + "545950455f55494e5436341004120e0a0a545950455f494e543332100512" + "100a0c545950455f46495845443634100612100a0c545950455f46495845" + "4433321007120d0a09545950455f424f4f4c1008120f0a0b545950455f53" + "5452494e471009120e0a0a545950455f47524f5550100a12100a0c545950" + "455f4d455353414745100b120e0a0a545950455f4259544553100c120f0a" + "0b545950455f55494e543332100d120d0a09545950455f454e554d100e12" + "110a0d545950455f5346495845443332100f12110a0d545950455f534649" + "58454436341010120f0a0b545950455f53494e5433321011120f0a0b5459" + "50455f53494e543634101222740a0b43617264696e616c69747912170a13" + "43415244494e414c4954595f554e4b4e4f574e100012180a144341524449" + "4e414c4954595f4f5054494f4e414c100112180a1443415244494e414c49" + "54595f5245515549524544100212180a1443415244494e414c4954595f52" + "45504541544544100322ce010a04456e756d120c0a046e616d6518012001" + "2809122d0a09656e756d76616c756518022003280b321a2e676f6f676c65" + "2e70726f746f6275662e456e756d56616c756512280a076f7074696f6e73" + "18032003280b32172e676f6f676c652e70726f746f6275662e4f7074696f" + "6e12360a0e736f757263655f636f6e7465787418042001280b321e2e676f" + "6f676c652e70726f746f6275662e536f75726365436f6e7465787412270a" + "0673796e74617818052001280e32172e676f6f676c652e70726f746f6275" + "662e53796e74617822530a09456e756d56616c7565120c0a046e616d6518" + "0120012809120e0a066e756d62657218022001280512280a076f7074696f" + "6e7318032003280b32172e676f6f676c652e70726f746f6275662e4f7074" + "696f6e223b0a064f7074696f6e120c0a046e616d6518012001280912230a" + "0576616c756518022001280b32142e676f6f676c652e70726f746f627566" + "2e416e792a2e0a0653796e74617812110a0d53594e5441585f50524f544f" + "32100012110a0d53594e5441585f50524f544f331001427d0a13636f6d2e" + "676f6f676c652e70726f746f62756642095479706550726f746f50015a2f" + "676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f70726f" + "746f6275662f70747970653b7074797065f80101a20203475042aa021e47" + "6f6f676c652e50726f746f6275662e57656c6c4b6e6f776e547970657362" + "0670726f746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +static void init_file_wrappers(TSRMLS_D) { + static bool is_initialized = false; + if (is_initialized) return; + init_generated_pool_once(TSRMLS_C); + const char* generated_file = + "0abf030a1e676f6f676c652f70726f746f6275662f77726170706572732e" + "70726f746f120f676f6f676c652e70726f746f627566221c0a0b446f7562" + "6c6556616c7565120d0a0576616c7565180120012801221b0a0a466c6f61" + "7456616c7565120d0a0576616c7565180120012802221b0a0a496e743634" + "56616c7565120d0a0576616c7565180120012803221c0a0b55496e743634" + "56616c7565120d0a0576616c7565180120012804221b0a0a496e74333256" + "616c7565120d0a0576616c7565180120012805221c0a0b55496e74333256" + "616c7565120d0a0576616c756518012001280d221a0a09426f6f6c56616c" + "7565120d0a0576616c7565180120012808221c0a0b537472696e6756616c" + "7565120d0a0576616c7565180120012809221b0a0a427974657356616c75" + "65120d0a0576616c756518012001280c427c0a13636f6d2e676f6f676c65" + "2e70726f746f627566420d577261707065727350726f746f50015a2a6769" + "746875622e636f6d2f676f6c616e672f70726f746f6275662f7074797065" + "732f7772617070657273f80101a20203475042aa021e476f6f676c652e50" + "726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"; + char* binary; + int binary_len; + hex_to_binary(generated_file, &binary, &binary_len); + internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); + FREE(binary); + is_initialized = true; +} + +// ----------------------------------------------------------------------------- +// Define enum +// ----------------------------------------------------------------------------- + +// ----------------------------------------------------------------------------- +// Field_Cardinality +// ----------------------------------------------------------------------------- + +static zend_function_entry field_cardinality_methods[] = { + {NULL, NULL, NULL} +}; + +zend_class_entry* field_cardinality_type; + +// Init class entry. +PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\Field_Cardinality", + Field_Cardinality, field_cardinality) + zend_declare_class_constant_long(field_cardinality_type, + "CARDINALITY_UNKNOWN", 19, 0 TSRMLS_CC); + zend_declare_class_constant_long(field_cardinality_type, + "CARDINALITY_OPTIONAL", 20, 1 TSRMLS_CC); + zend_declare_class_constant_long(field_cardinality_type, + "CARDINALITY_REQUIRED", 20, 2 TSRMLS_CC); + zend_declare_class_constant_long(field_cardinality_type, + "CARDINALITY_REPEATED", 20, 3 TSRMLS_CC); +PHP_PROTO_INIT_ENUMCLASS_END + +// ----------------------------------------------------------------------------- +// Field_Kind +// ----------------------------------------------------------------------------- + +static zend_function_entry field_kind_methods[] = { + {NULL, NULL, NULL} +}; + +zend_class_entry* field_kind_type; + +// Init class entry. +PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\Field_Kind", + Field_Kind, field_kind) + zend_declare_class_constant_long(field_kind_type, + "TYPE_UNKNOWN", 12, 0 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_DOUBLE", 11, 1 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_FLOAT", 10, 2 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_INT64", 10, 3 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_UINT64", 11, 4 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_INT32", 10, 5 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_FIXED64", 12, 6 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_FIXED32", 12, 7 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_BOOL", 9, 8 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_STRING", 11, 9 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_GROUP", 10, 10 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_MESSAGE", 12, 11 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_BYTES", 10, 12 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_UINT32", 11, 13 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_ENUM", 9, 14 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_SFIXED32", 13, 15 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_SFIXED64", 13, 16 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_SINT32", 11, 17 TSRMLS_CC); + zend_declare_class_constant_long(field_kind_type, + "TYPE_SINT64", 11, 18 TSRMLS_CC); +PHP_PROTO_INIT_ENUMCLASS_END + +// ----------------------------------------------------------------------------- +// NullValue +// ----------------------------------------------------------------------------- + +static zend_function_entry null_value_methods[] = { + {NULL, NULL, NULL} +}; + +zend_class_entry* null_value_type; + +// Init class entry. +PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\NullValue", + NullValue, null_value) + zend_declare_class_constant_long(null_value_type, + "NULL_VALUE", 10, 0 TSRMLS_CC); +PHP_PROTO_INIT_ENUMCLASS_END + +// ----------------------------------------------------------------------------- +// Syntax +// ----------------------------------------------------------------------------- + +static zend_function_entry syntax_methods[] = { + {NULL, NULL, NULL} +}; + +zend_class_entry* syntax_type; + +// Init class entry. +PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\Syntax", + Syntax, syntax) + zend_declare_class_constant_long(syntax_type, + "SYNTAX_PROTO2", 13, 0 TSRMLS_CC); + zend_declare_class_constant_long(syntax_type, + "SYNTAX_PROTO3", 13, 1 TSRMLS_CC); +PHP_PROTO_INIT_ENUMCLASS_END + + + +// ----------------------------------------------------------------------------- +// Define message +// ----------------------------------------------------------------------------- + // ----------------------------------------------------------------------------- // Any // ----------------------------------------------------------------------------- @@ -409,7 +883,7 @@ PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Any", Any, any) "" ,ZEND_ACC_PRIVATE TSRMLS_CC); PHP_PROTO_INIT_SUBMSGCLASS_END -void hex_to_binary(const char* hex, char** binary, int* binary_len) { +static void hex_to_binary(const char* hex, char** binary, int* binary_len) { int i; int hex_len = strlen(hex); *binary_len = hex_len / 2; @@ -431,25 +905,7 @@ void hex_to_binary(const char* hex, char** binary, int* binary_len) { } PHP_METHOD(Any, __construct) { - PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(any_type); - if (desc_php == NULL) { - init_generated_pool_once(TSRMLS_C); - const char* generated_file = - "0acd010a19676f6f676c652f70726f746f6275662f616e792e70726f746f" - "120f676f6f676c652e70726f746f62756622260a03416e7912100a087479" - "70655f75726c180120012809120d0a0576616c756518022001280c426f0a" - "13636f6d2e676f6f676c652e70726f746f6275664208416e7950726f746f" - "50015a256769746875622e636f6d2f676f6c616e672f70726f746f627566" - "2f7074797065732f616e79a20203475042aa021e476f6f676c652e50726f" - "746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"; - char* binary; - int binary_len; - hex_to_binary(generated_file, &binary, &binary_len); - - internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); - FREE(binary); - } - + init_file_any(TSRMLS_C); MessageHeader* intern = UNBOX(MessageHeader, getThis()); custom_data_init(any_type, intern PHP_PROTO_TSRMLS_CC); } @@ -611,26 +1067,7 @@ PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Duration", PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Duration, __construct) { - PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(duration_type); - if (desc_php == NULL) { - init_generated_pool_once(TSRMLS_C); - const char* generated_file = - "0ae3010a1e676f6f676c652f70726f746f6275662f6475726174696f6e2e" - "70726f746f120f676f6f676c652e70726f746f627566222a0a0844757261" - "74696f6e120f0a077365636f6e6473180120012803120d0a056e616e6f73" - "180220012805427c0a13636f6d2e676f6f676c652e70726f746f62756642" - "0d4475726174696f6e50726f746f50015a2a6769746875622e636f6d2f67" - "6f6c616e672f70726f746f6275662f7074797065732f6475726174696f6e" - "f80101a20203475042aa021e476f6f676c652e50726f746f6275662e5765" - "6c6c4b6e6f776e5479706573620670726f746f33"; - char* binary; - int binary_len; - hex_to_binary(generated_file, &binary, &binary_len); - - internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); - FREE(binary); - } - + init_file_duration(TSRMLS_C); MessageHeader* intern = UNBOX(MessageHeader, getThis()); custom_data_init(duration_type, intern PHP_PROTO_TSRMLS_CC); } @@ -666,26 +1103,7 @@ PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Timestamp", PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Timestamp, __construct) { - PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(timestamp_type); - if (desc_php == NULL) { - init_generated_pool_once(TSRMLS_C); - const char* generated_file = - "0ae7010a1f676f6f676c652f70726f746f6275662f74696d657374616d70" - "2e70726f746f120f676f6f676c652e70726f746f627566222b0a0954696d" - "657374616d70120f0a077365636f6e6473180120012803120d0a056e616e" - "6f73180220012805427e0a13636f6d2e676f6f676c652e70726f746f6275" - "66420e54696d657374616d7050726f746f50015a2b6769746875622e636f" - "6d2f676f6c616e672f70726f746f6275662f7074797065732f74696d6573" - "74616d70f80101a20203475042aa021e476f6f676c652e50726f746f6275" - "662e57656c6c4b6e6f776e5479706573620670726f746f33"; - char* binary; - int binary_len; - hex_to_binary(generated_file, &binary, &binary_len); - - internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC); - FREE(binary); - } - + init_file_timestamp(TSRMLS_C); MessageHeader* intern = UNBOX(MessageHeader, getThis()); custom_data_init(timestamp_type, intern PHP_PROTO_TSRMLS_CC); } @@ -758,3 +1176,852 @@ PHP_METHOD(Timestamp, toDateTime) { zval* datetime_ptr = &datetime; PHP_PROTO_RETVAL_ZVAL(datetime_ptr); } + +// ----------------------------------------------------------------------------- +// Api +// ----------------------------------------------------------------------------- + +static zend_function_entry api_methods[] = { + PHP_ME(Api, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, getMethods, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, setMethods, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, getVersion, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, setVersion, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, getSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, setSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, getMixins, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, setMixins, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Api, setSyntax, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* api_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Api", + Api, api) + zend_class_implements(api_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(api_type, "name", strlen("name"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(api_type, "methods", strlen("methods"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(api_type, "options", strlen("options"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(api_type, "version", strlen("version"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(api_type, "source_context", strlen("source_context"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(api_type, "mixins", strlen("mixins"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(api_type, "syntax", strlen("syntax"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Api, __construct) { + init_file_api(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(api_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Api, api, Name, "name") +PHP_PROTO_FIELD_ACCESSORS(Api, api, Methods, "methods") +PHP_PROTO_FIELD_ACCESSORS(Api, api, Options, "options") +PHP_PROTO_FIELD_ACCESSORS(Api, api, Version, "version") +PHP_PROTO_FIELD_ACCESSORS(Api, api, SourceContext, "source_context") +PHP_PROTO_FIELD_ACCESSORS(Api, api, Mixins, "mixins") +PHP_PROTO_FIELD_ACCESSORS(Api, api, Syntax, "syntax") + +// ----------------------------------------------------------------------------- +// BoolValue +// ----------------------------------------------------------------------------- + +static zend_function_entry bool_value_methods[] = { + PHP_ME(BoolValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(BoolValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(BoolValue, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* bool_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\BoolValue", + BoolValue, bool_value) + zend_class_implements(bool_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(bool_value_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(BoolValue, __construct) { + init_file_wrappers(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(bool_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(BoolValue, bool_value, Value, "value") + +// ----------------------------------------------------------------------------- +// BytesValue +// ----------------------------------------------------------------------------- + +static zend_function_entry bytes_value_methods[] = { + PHP_ME(BytesValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(BytesValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(BytesValue, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* bytes_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\BytesValue", + BytesValue, bytes_value) + zend_class_implements(bytes_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(bytes_value_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(BytesValue, __construct) { + init_file_wrappers(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(bytes_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(BytesValue, bytes_value, Value, "value") + +// ----------------------------------------------------------------------------- +// DoubleValue +// ----------------------------------------------------------------------------- + +static zend_function_entry double_value_methods[] = { + PHP_ME(DoubleValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(DoubleValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(DoubleValue, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* double_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\DoubleValue", + DoubleValue, double_value) + zend_class_implements(double_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(double_value_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(DoubleValue, __construct) { + init_file_wrappers(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(double_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(DoubleValue, double_value, Value, "value") + +// ----------------------------------------------------------------------------- +// Enum +// ----------------------------------------------------------------------------- + +static zend_function_entry enum_methods[] = { + PHP_ME(Enum, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, getEnumvalue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, setEnumvalue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, getSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, setSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Enum, setSyntax, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* enum_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Enum", + Enum, enum) + zend_class_implements(enum_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(enum_type, "name", strlen("name"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(enum_type, "enumvalue", strlen("enumvalue"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(enum_type, "options", strlen("options"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(enum_type, "source_context", strlen("source_context"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(enum_type, "syntax", strlen("syntax"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Enum, __construct) { + init_file_type(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(enum_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Enum, enum, Name, "name") +PHP_PROTO_FIELD_ACCESSORS(Enum, enum, Enumvalue, "enumvalue") +PHP_PROTO_FIELD_ACCESSORS(Enum, enum, Options, "options") +PHP_PROTO_FIELD_ACCESSORS(Enum, enum, SourceContext, "source_context") +PHP_PROTO_FIELD_ACCESSORS(Enum, enum, Syntax, "syntax") + +// ----------------------------------------------------------------------------- +// EnumValue +// ----------------------------------------------------------------------------- + +static zend_function_entry enum_value_methods[] = { + PHP_ME(EnumValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(EnumValue, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(EnumValue, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(EnumValue, getNumber, NULL, ZEND_ACC_PUBLIC) + PHP_ME(EnumValue, setNumber, NULL, ZEND_ACC_PUBLIC) + PHP_ME(EnumValue, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(EnumValue, setOptions, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* enum_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\EnumValue", + EnumValue, enum_value) + zend_class_implements(enum_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(enum_value_type, "name", strlen("name"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(enum_value_type, "number", strlen("number"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(enum_value_type, "options", strlen("options"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(EnumValue, __construct) { + init_file_type(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(enum_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(EnumValue, enum_value, Name, "name") +PHP_PROTO_FIELD_ACCESSORS(EnumValue, enum_value, Number, "number") +PHP_PROTO_FIELD_ACCESSORS(EnumValue, enum_value, Options, "options") + +// ----------------------------------------------------------------------------- +// FieldMask +// ----------------------------------------------------------------------------- + +static zend_function_entry field_mask_methods[] = { + PHP_ME(FieldMask, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(FieldMask, getPaths, NULL, ZEND_ACC_PUBLIC) + PHP_ME(FieldMask, setPaths, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* field_mask_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\FieldMask", + FieldMask, field_mask) + zend_class_implements(field_mask_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(field_mask_type, "paths", strlen("paths"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(FieldMask, __construct) { + init_file_field_mask(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(field_mask_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(FieldMask, field_mask, Paths, "paths") + +// ----------------------------------------------------------------------------- +// Field +// ----------------------------------------------------------------------------- + +static zend_function_entry field_methods[] = { + PHP_ME(Field, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getKind, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setKind, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getCardinality, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setCardinality, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getNumber, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setNumber, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getOneofIndex, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setOneofIndex, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getPacked, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setPacked, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getJsonName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setJsonName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, getDefaultValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Field, setDefaultValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* field_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Field", + Field, field) + zend_class_implements(field_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(field_type, "kind", strlen("kind"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(field_type, "cardinality", strlen("cardinality"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(field_type, "number", strlen("number"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(field_type, "name", strlen("name"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(field_type, "type_url", strlen("type_url"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(field_type, "oneof_index", strlen("oneof_index"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(field_type, "packed", strlen("packed"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(field_type, "options", strlen("options"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(field_type, "json_name", strlen("json_name"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(field_type, "default_value", strlen("default_value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Field, __construct) { + init_file_type(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(field_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Field, field, Kind, "kind") +PHP_PROTO_FIELD_ACCESSORS(Field, field, Cardinality, "cardinality") +PHP_PROTO_FIELD_ACCESSORS(Field, field, Number, "number") +PHP_PROTO_FIELD_ACCESSORS(Field, field, Name, "name") +PHP_PROTO_FIELD_ACCESSORS(Field, field, TypeUrl, "type_url") +PHP_PROTO_FIELD_ACCESSORS(Field, field, OneofIndex, "oneof_index") +PHP_PROTO_FIELD_ACCESSORS(Field, field, Packed, "packed") +PHP_PROTO_FIELD_ACCESSORS(Field, field, Options, "options") +PHP_PROTO_FIELD_ACCESSORS(Field, field, JsonName, "json_name") +PHP_PROTO_FIELD_ACCESSORS(Field, field, DefaultValue, "default_value") + +// ----------------------------------------------------------------------------- +// FloatValue +// ----------------------------------------------------------------------------- + +static zend_function_entry float_value_methods[] = { + PHP_ME(FloatValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(FloatValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(FloatValue, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* float_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\FloatValue", + FloatValue, float_value) + zend_class_implements(float_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(float_value_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(FloatValue, __construct) { + init_file_wrappers(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(float_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(FloatValue, float_value, Value, "value") + +// ----------------------------------------------------------------------------- +// GPBEmpty +// ----------------------------------------------------------------------------- + +static zend_function_entry empty_methods[] = { + PHP_ME(GPBEmpty, __construct, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* empty_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\GPBEmpty", + GPBEmpty, empty) + zend_class_implements(empty_type TSRMLS_CC, 1, message_type); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(GPBEmpty, __construct) { + init_file_empty(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(empty_type, intern PHP_PROTO_TSRMLS_CC); +} + + +// ----------------------------------------------------------------------------- +// Int32Value +// ----------------------------------------------------------------------------- + +static zend_function_entry int32_value_methods[] = { + PHP_ME(Int32Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Int32Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Int32Value, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* int32_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Int32Value", + Int32Value, int32_value) + zend_class_implements(int32_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(int32_value_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Int32Value, __construct) { + init_file_wrappers(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(int32_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Int32Value, int32_value, Value, "value") + +// ----------------------------------------------------------------------------- +// Int64Value +// ----------------------------------------------------------------------------- + +static zend_function_entry int64_value_methods[] = { + PHP_ME(Int64Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Int64Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Int64Value, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* int64_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Int64Value", + Int64Value, int64_value) + zend_class_implements(int64_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(int64_value_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Int64Value, __construct) { + init_file_wrappers(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(int64_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Int64Value, int64_value, Value, "value") + +// ----------------------------------------------------------------------------- +// ListValue +// ----------------------------------------------------------------------------- + +static zend_function_entry list_value_methods[] = { + PHP_ME(ListValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(ListValue, getValues, NULL, ZEND_ACC_PUBLIC) + PHP_ME(ListValue, setValues, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* list_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\ListValue", + ListValue, list_value) + zend_class_implements(list_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(list_value_type, "values", strlen("values"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(ListValue, __construct) { + init_file_struct(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(list_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(ListValue, list_value, Values, "values") + +// ----------------------------------------------------------------------------- +// Method +// ----------------------------------------------------------------------------- + +static zend_function_entry method_methods[] = { + PHP_ME(Method, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, getRequestTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, setRequestTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, getRequestStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, setRequestStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, getResponseTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, setResponseTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, getResponseStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, setResponseStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Method, setSyntax, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* method_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Method", + Method, method) + zend_class_implements(method_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(method_type, "name", strlen("name"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(method_type, "request_type_url", strlen("request_type_url"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(method_type, "request_streaming", strlen("request_streaming"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(method_type, "response_type_url", strlen("response_type_url"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(method_type, "response_streaming", strlen("response_streaming"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(method_type, "options", strlen("options"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(method_type, "syntax", strlen("syntax"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Method, __construct) { + init_file_api(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(method_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Method, method, Name, "name") +PHP_PROTO_FIELD_ACCESSORS(Method, method, RequestTypeUrl, "request_type_url") +PHP_PROTO_FIELD_ACCESSORS(Method, method, RequestStreaming, "request_streaming") +PHP_PROTO_FIELD_ACCESSORS(Method, method, ResponseTypeUrl, "response_type_url") +PHP_PROTO_FIELD_ACCESSORS(Method, method, ResponseStreaming, "response_streaming") +PHP_PROTO_FIELD_ACCESSORS(Method, method, Options, "options") +PHP_PROTO_FIELD_ACCESSORS(Method, method, Syntax, "syntax") + +// ----------------------------------------------------------------------------- +// Mixin +// ----------------------------------------------------------------------------- + +static zend_function_entry mixin_methods[] = { + PHP_ME(Mixin, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Mixin, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Mixin, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Mixin, getRoot, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Mixin, setRoot, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* mixin_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Mixin", + Mixin, mixin) + zend_class_implements(mixin_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(mixin_type, "name", strlen("name"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(mixin_type, "root", strlen("root"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Mixin, __construct) { + init_file_api(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(mixin_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Mixin, mixin, Name, "name") +PHP_PROTO_FIELD_ACCESSORS(Mixin, mixin, Root, "root") + +// ----------------------------------------------------------------------------- +// Option +// ----------------------------------------------------------------------------- + +static zend_function_entry option_methods[] = { + PHP_ME(Option, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Option, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Option, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Option, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Option, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* option_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Option", + Option, option) + zend_class_implements(option_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(option_type, "name", strlen("name"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(option_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Option, __construct) { + init_file_type(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(option_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Option, option, Name, "name") +PHP_PROTO_FIELD_ACCESSORS(Option, option, Value, "value") + +// ----------------------------------------------------------------------------- +// SourceContext +// ----------------------------------------------------------------------------- + +static zend_function_entry source_context_methods[] = { + PHP_ME(SourceContext, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(SourceContext, getFileName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(SourceContext, setFileName, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* source_context_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\SourceContext", + SourceContext, source_context) + zend_class_implements(source_context_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(source_context_type, "file_name", strlen("file_name"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(SourceContext, __construct) { + init_file_source_context(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(source_context_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(SourceContext, source_context, FileName, "file_name") + +// ----------------------------------------------------------------------------- +// StringValue +// ----------------------------------------------------------------------------- + +static zend_function_entry string_value_methods[] = { + PHP_ME(StringValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(StringValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(StringValue, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* string_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\StringValue", + StringValue, string_value) + zend_class_implements(string_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(string_value_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(StringValue, __construct) { + init_file_wrappers(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(string_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(StringValue, string_value, Value, "value") + +// ----------------------------------------------------------------------------- +// Struct +// ----------------------------------------------------------------------------- + +static zend_function_entry struct_methods[] = { + PHP_ME(Struct, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Struct, getFields, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Struct, setFields, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* struct_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Struct", + Struct, struct) + zend_class_implements(struct_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(struct_type, "fields", strlen("fields"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Struct, __construct) { + init_file_struct(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(struct_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Struct, struct, Fields, "fields") + +// ----------------------------------------------------------------------------- +// Type +// ----------------------------------------------------------------------------- + +static zend_function_entry type_methods[] = { + PHP_ME(Type, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, getFields, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, setFields, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, getOneofs, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, setOneofs, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, getSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, setSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Type, setSyntax, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* type_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Type", + Type, type) + zend_class_implements(type_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(type_type, "name", strlen("name"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(type_type, "fields", strlen("fields"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(type_type, "oneofs", strlen("oneofs"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(type_type, "options", strlen("options"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(type_type, "source_context", strlen("source_context"), + ZEND_ACC_PRIVATE TSRMLS_CC); + zend_declare_property_null(type_type, "syntax", strlen("syntax"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Type, __construct) { + init_file_type(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(type_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(Type, type, Name, "name") +PHP_PROTO_FIELD_ACCESSORS(Type, type, Fields, "fields") +PHP_PROTO_FIELD_ACCESSORS(Type, type, Oneofs, "oneofs") +PHP_PROTO_FIELD_ACCESSORS(Type, type, Options, "options") +PHP_PROTO_FIELD_ACCESSORS(Type, type, SourceContext, "source_context") +PHP_PROTO_FIELD_ACCESSORS(Type, type, Syntax, "syntax") + +// ----------------------------------------------------------------------------- +// UInt32Value +// ----------------------------------------------------------------------------- + +static zend_function_entry u_int32_value_methods[] = { + PHP_ME(UInt32Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(UInt32Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(UInt32Value, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* u_int32_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\UInt32Value", + UInt32Value, u_int32_value) + zend_class_implements(u_int32_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(u_int32_value_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(UInt32Value, __construct) { + init_file_wrappers(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(u_int32_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(UInt32Value, u_int32_value, Value, "value") + +// ----------------------------------------------------------------------------- +// UInt64Value +// ----------------------------------------------------------------------------- + +static zend_function_entry u_int64_value_methods[] = { + PHP_ME(UInt64Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(UInt64Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(UInt64Value, setValue, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* u_int64_value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\UInt64Value", + UInt64Value, u_int64_value) + zend_class_implements(u_int64_value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(u_int64_value_type, "value", strlen("value"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(UInt64Value, __construct) { + init_file_wrappers(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(u_int64_value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_FIELD_ACCESSORS(UInt64Value, u_int64_value, Value, "value") + +// ----------------------------------------------------------------------------- +// Value +// ----------------------------------------------------------------------------- + +static zend_function_entry value_methods[] = { + PHP_ME(Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, getNullValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, setNullValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, getNumberValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, setNumberValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, getStringValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, setStringValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, getBoolValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, setBoolValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, getStructValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, setStructValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, getListValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, setListValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Value, getKind, NULL, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; + +zend_class_entry* value_type; + +// Init class entry. +PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Value", + Value, value) + zend_class_implements(value_type TSRMLS_CC, 1, message_type); + zend_declare_property_null(value_type, "kind", strlen("kind"), + ZEND_ACC_PRIVATE TSRMLS_CC); +PHP_PROTO_INIT_SUBMSGCLASS_END + +PHP_METHOD(Value, __construct) { + init_file_struct(TSRMLS_C); + MessageHeader* intern = UNBOX(MessageHeader, getThis()); + custom_data_init(value_type, intern PHP_PROTO_TSRMLS_CC); +} + +PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, NullValue, "null_value") +PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, NumberValue, "number_value") +PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, StringValue, "string_value") +PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, BoolValue, "bool_value") +PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, StructValue, "struct_value") +PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, ListValue, "list_value") +PHP_PROTO_ONEOF_ACCESSORS(Value, value, Kind, "kind") diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index 42bc31cf..2f394ba5 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -256,9 +256,37 @@ static PHP_MINIT_FUNCTION(protobuf) { repeated_field_init(TSRMLS_C); repeated_field_iter_init(TSRMLS_C); util_init(TSRMLS_C); + any_init(TSRMLS_C); + api_init(TSRMLS_C); + bool_value_init(TSRMLS_C); + bytes_value_init(TSRMLS_C); + double_value_init(TSRMLS_C); duration_init(TSRMLS_C); + enum_init(TSRMLS_C); + enum_value_init(TSRMLS_C); + field_cardinality_init(TSRMLS_C); + field_init(TSRMLS_C); + field_kind_init(TSRMLS_C); + field_mask_init(TSRMLS_C); + float_value_init(TSRMLS_C); + empty_init(TSRMLS_C); + int32_value_init(TSRMLS_C); + int64_value_init(TSRMLS_C); + list_value_init(TSRMLS_C); + method_init(TSRMLS_C); + mixin_init(TSRMLS_C); + null_value_init(TSRMLS_C); + option_init(TSRMLS_C); + source_context_init(TSRMLS_C); + string_value_init(TSRMLS_C); + struct_init(TSRMLS_C); + syntax_init(TSRMLS_C); timestamp_init(TSRMLS_C); + type_init(TSRMLS_C); + u_int32_value_init(TSRMLS_C); + u_int64_value_init(TSRMLS_C); + value_init(TSRMLS_C); return 0; } diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index d4ab2ce8..c8a360d8 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -127,6 +127,16 @@ #define PHP_PROTO_INIT_SUBMSGCLASS_END \ } +#define PHP_PROTO_INIT_ENUMCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ + void LOWWERNAME##_init(TSRMLS_D) { \ + zend_class_entry class_type; \ + const char* class_name = CLASSNAME; \ + INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ + LOWWERNAME##_methods); \ + LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); +#define PHP_PROTO_INIT_ENUMCLASS_END \ + } + #define PHP_PROTO_INIT_CLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ void LOWWERNAME##_init(TSRMLS_D) { \ zend_class_entry class_type; \ @@ -365,6 +375,16 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht, #define PHP_PROTO_INIT_SUBMSGCLASS_END \ } +#define PHP_PROTO_INIT_ENUMCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ + void LOWWERNAME##_init(TSRMLS_D) { \ + zend_class_entry class_type; \ + const char* class_name = CLASSNAME; \ + INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ + LOWWERNAME##_methods); \ + LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); +#define PHP_PROTO_INIT_ENUMCLASS_END \ + } + #define PHP_PROTO_INIT_CLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ void LOWWERNAME##_init(TSRMLS_D) { \ zend_class_entry class_type; \ @@ -517,40 +537,108 @@ static inline int php_proto_zend_lookup_class( // ---------------------------------------------------------------------------- struct Any; -struct DescriptorPool; +struct Api; +struct BoolValue; +struct BytesValue; struct Descriptor; +struct DescriptorPool; +struct DoubleValue; struct Duration; +struct Enum; struct EnumDescriptor; +struct EnumValue; struct EnumValueDescriptor; +struct Field; struct FieldDescriptor; +struct FieldMask; +struct Field_Cardinality; +struct Field_Kind; +struct FloatValue; +struct GPBEmpty; +struct Int32Value; +struct Int64Value; struct InternalDescriptorPool; +struct ListValue; +struct Map; +struct MapIter; struct MessageField; struct MessageHeader; struct MessageLayout; +struct Method; +struct Mixin; +struct NullValue; +struct Oneof; +struct Option; struct RepeatedField; struct RepeatedFieldIter; -struct Map; -struct MapIter; -struct Oneof; +struct SourceContext; +struct StringValue; +struct Struct; +struct Syntax; struct Timestamp; +struct Type; +struct UInt32Value; +struct UInt64Value; +struct Value; typedef struct Any Any; -typedef struct DescriptorPool DescriptorPool; +typedef struct Api Api; +typedef struct BoolValue BoolValue; +typedef struct BytesValue BytesValue; +typedef struct Descriptor Descriptor; typedef struct Descriptor Descriptor; +typedef struct DescriptorPool DescriptorPool; +typedef struct DescriptorPool DescriptorPool; +typedef struct DoubleValue DoubleValue; typedef struct Duration Duration; +typedef struct Enum Enum; +typedef struct EnumDescriptor EnumDescriptor; typedef struct EnumDescriptor EnumDescriptor; +typedef struct EnumValue EnumValue; typedef struct EnumValueDescriptor EnumValueDescriptor; +typedef struct EnumValueDescriptor EnumValueDescriptor; +typedef struct Field Field; +typedef struct FieldDescriptor FieldDescriptor; typedef struct FieldDescriptor FieldDescriptor; +typedef struct FieldMask FieldMask; +typedef struct Field_Cardinality Field_Cardinality; +typedef struct Field_Kind Field_Kind; +typedef struct FloatValue FloatValue; +typedef struct GPBEmpty GPBEmpty; +typedef struct Int32Value Int32Value; +typedef struct Int64Value Int64Value; typedef struct InternalDescriptorPool InternalDescriptorPool; +typedef struct InternalDescriptorPool InternalDescriptorPool; +typedef struct ListValue ListValue; +typedef struct Map Map; +typedef struct Map Map; +typedef struct MapIter MapIter; +typedef struct MapIter MapIter; +typedef struct MessageField MessageField; typedef struct MessageField MessageField; typedef struct MessageHeader MessageHeader; +typedef struct MessageHeader MessageHeader; +typedef struct MessageLayout MessageLayout; typedef struct MessageLayout MessageLayout; +typedef struct Method Method; +typedef struct Mixin Mixin; +typedef struct NullValue NullValue; +typedef struct Oneof Oneof; +typedef struct Oneof Oneof; +typedef struct Option Option; +typedef struct RepeatedField RepeatedField; typedef struct RepeatedField RepeatedField; typedef struct RepeatedFieldIter RepeatedFieldIter; -typedef struct Map Map; -typedef struct MapIter MapIter; -typedef struct Oneof Oneof; +typedef struct RepeatedFieldIter RepeatedFieldIter; +typedef struct SourceContext SourceContext; +typedef struct StringValue StringValue; +typedef struct Struct Struct; +typedef struct Syntax Syntax; typedef struct Timestamp Timestamp; +typedef struct Type Type; +typedef struct UInt32Value UInt32Value; +typedef struct UInt64Value UInt64Value; +typedef struct Value Value; // ----------------------------------------------------------------------------- // Globals. @@ -561,21 +649,48 @@ ZEND_END_MODULE_GLOBALS(protobuf) // Init module and PHP classes. void any_init(TSRMLS_D); +void api_init(TSRMLS_D); +void bool_value_init(TSRMLS_D); +void bytes_value_init(TSRMLS_D); void descriptor_init(TSRMLS_D); +void descriptor_pool_init(TSRMLS_D); +void double_value_init(TSRMLS_D); void duration_init(TSRMLS_D); +void empty_init(TSRMLS_D); void enum_descriptor_init(TSRMLS_D); -void descriptor_pool_init(TSRMLS_D); -void internal_descriptor_pool_init(TSRMLS_D); +void enum_init(TSRMLS_D); +void enum_value_init(TSRMLS_D); +void field_cardinality_init(TSRMLS_D); void field_descriptor_init(TSRMLS_D); +void field_init(TSRMLS_D); +void field_kind_init(TSRMLS_D); +void field_mask_init(TSRMLS_D); +void float_value_init(TSRMLS_D); void gpb_type_init(TSRMLS_D); +void int32_value_init(TSRMLS_D); +void int64_value_init(TSRMLS_D); +void internal_descriptor_pool_init(TSRMLS_D); +void list_value_init(TSRMLS_D); void map_field_init(TSRMLS_D); void map_field_iter_init(TSRMLS_D); void message_init(TSRMLS_D); +void method_init(TSRMLS_D); +void mixin_init(TSRMLS_D); +void null_value_init(TSRMLS_D); void oneof_descriptor_init(TSRMLS_D); +void option_init(TSRMLS_D); void repeated_field_init(TSRMLS_D); void repeated_field_iter_init(TSRMLS_D); +void source_context_init(TSRMLS_D); +void string_value_init(TSRMLS_D); +void struct_init(TSRMLS_D); +void syntax_init(TSRMLS_D); void timestamp_init(TSRMLS_D); +void type_init(TSRMLS_D); +void uint32_value_init(TSRMLS_D); +void uint64_value_init(TSRMLS_D); void util_init(TSRMLS_D); +void value_init(TSRMLS_D); // Global map from upb {msg,enum}defs to wrapper Descriptor/EnumDescriptor // instances. @@ -837,6 +952,11 @@ bool protobuf_convert_to_double(zval* from, double* to); bool protobuf_convert_to_bool(zval* from, int8_t* to); bool protobuf_convert_to_string(zval* from); +void check_repeated_field(const zend_class_entry* klass, PHP_PROTO_LONG type, + zval* val, zval* return_value); +void check_map_field(const zend_class_entry* klass, PHP_PROTO_LONG key_type, + PHP_PROTO_LONG value_type, zval* val, zval* return_value); + PHP_METHOD(Util, checkInt32); PHP_METHOD(Util, checkUint32); PHP_METHOD(Util, checkInt64); @@ -1051,9 +1171,205 @@ PHP_METHOD(Timestamp, setSeconds); PHP_METHOD(Timestamp, getNanos); PHP_METHOD(Timestamp, setNanos); +PHP_METHOD(Api, __construct); +PHP_METHOD(Api, getName); +PHP_METHOD(Api, setName); +PHP_METHOD(Api, getMethods); +PHP_METHOD(Api, setMethods); +PHP_METHOD(Api, getOptions); +PHP_METHOD(Api, setOptions); +PHP_METHOD(Api, getVersion); +PHP_METHOD(Api, setVersion); +PHP_METHOD(Api, getSourceContext); +PHP_METHOD(Api, setSourceContext); +PHP_METHOD(Api, getMixins); +PHP_METHOD(Api, setMixins); +PHP_METHOD(Api, getSyntax); +PHP_METHOD(Api, setSyntax); + +PHP_METHOD(BoolValue, __construct); +PHP_METHOD(BoolValue, getValue); +PHP_METHOD(BoolValue, setValue); + +PHP_METHOD(BytesValue, __construct); +PHP_METHOD(BytesValue, getValue); +PHP_METHOD(BytesValue, setValue); + +PHP_METHOD(DoubleValue, __construct); +PHP_METHOD(DoubleValue, getValue); +PHP_METHOD(DoubleValue, setValue); + +PHP_METHOD(Enum, __construct); +PHP_METHOD(Enum, getName); +PHP_METHOD(Enum, setName); +PHP_METHOD(Enum, getEnumvalue); +PHP_METHOD(Enum, setEnumvalue); +PHP_METHOD(Enum, getOptions); +PHP_METHOD(Enum, setOptions); +PHP_METHOD(Enum, getSourceContext); +PHP_METHOD(Enum, setSourceContext); +PHP_METHOD(Enum, getSyntax); +PHP_METHOD(Enum, setSyntax); + +PHP_METHOD(EnumValue, __construct); +PHP_METHOD(EnumValue, getName); +PHP_METHOD(EnumValue, setName); +PHP_METHOD(EnumValue, getNumber); +PHP_METHOD(EnumValue, setNumber); +PHP_METHOD(EnumValue, getOptions); +PHP_METHOD(EnumValue, setOptions); + +PHP_METHOD(FieldMask, __construct); +PHP_METHOD(FieldMask, getPaths); +PHP_METHOD(FieldMask, setPaths); + +PHP_METHOD(Field, __construct); +PHP_METHOD(Field, getKind); +PHP_METHOD(Field, setKind); +PHP_METHOD(Field, getCardinality); +PHP_METHOD(Field, setCardinality); +PHP_METHOD(Field, getNumber); +PHP_METHOD(Field, setNumber); +PHP_METHOD(Field, getName); +PHP_METHOD(Field, setName); +PHP_METHOD(Field, getTypeUrl); +PHP_METHOD(Field, setTypeUrl); +PHP_METHOD(Field, getOneofIndex); +PHP_METHOD(Field, setOneofIndex); +PHP_METHOD(Field, getPacked); +PHP_METHOD(Field, setPacked); +PHP_METHOD(Field, getOptions); +PHP_METHOD(Field, setOptions); +PHP_METHOD(Field, getJsonName); +PHP_METHOD(Field, setJsonName); +PHP_METHOD(Field, getDefaultValue); +PHP_METHOD(Field, setDefaultValue); + +PHP_METHOD(FloatValue, __construct); +PHP_METHOD(FloatValue, getValue); +PHP_METHOD(FloatValue, setValue); + +PHP_METHOD(GPBEmpty, __construct); + +PHP_METHOD(Int32Value, __construct); +PHP_METHOD(Int32Value, getValue); +PHP_METHOD(Int32Value, setValue); + +PHP_METHOD(Int64Value, __construct); +PHP_METHOD(Int64Value, getValue); +PHP_METHOD(Int64Value, setValue); + +PHP_METHOD(ListValue, __construct); +PHP_METHOD(ListValue, getValues); +PHP_METHOD(ListValue, setValues); + +PHP_METHOD(Method, __construct); +PHP_METHOD(Method, getName); +PHP_METHOD(Method, setName); +PHP_METHOD(Method, getRequestTypeUrl); +PHP_METHOD(Method, setRequestTypeUrl); +PHP_METHOD(Method, getRequestStreaming); +PHP_METHOD(Method, setRequestStreaming); +PHP_METHOD(Method, getResponseTypeUrl); +PHP_METHOD(Method, setResponseTypeUrl); +PHP_METHOD(Method, getResponseStreaming); +PHP_METHOD(Method, setResponseStreaming); +PHP_METHOD(Method, getOptions); +PHP_METHOD(Method, setOptions); +PHP_METHOD(Method, getSyntax); +PHP_METHOD(Method, setSyntax); + +PHP_METHOD(Mixin, __construct); +PHP_METHOD(Mixin, getName); +PHP_METHOD(Mixin, setName); +PHP_METHOD(Mixin, getRoot); +PHP_METHOD(Mixin, setRoot); + +PHP_METHOD(Option, __construct); +PHP_METHOD(Option, getName); +PHP_METHOD(Option, setName); +PHP_METHOD(Option, getValue); +PHP_METHOD(Option, setValue); + +PHP_METHOD(SourceContext, __construct); +PHP_METHOD(SourceContext, getFileName); +PHP_METHOD(SourceContext, setFileName); + +PHP_METHOD(StringValue, __construct); +PHP_METHOD(StringValue, getValue); +PHP_METHOD(StringValue, setValue); + +PHP_METHOD(Struct, __construct); +PHP_METHOD(Struct, getFields); +PHP_METHOD(Struct, setFields); + +PHP_METHOD(Type, __construct); +PHP_METHOD(Type, getName); +PHP_METHOD(Type, setName); +PHP_METHOD(Type, getFields); +PHP_METHOD(Type, setFields); +PHP_METHOD(Type, getOneofs); +PHP_METHOD(Type, setOneofs); +PHP_METHOD(Type, getOptions); +PHP_METHOD(Type, setOptions); +PHP_METHOD(Type, getSourceContext); +PHP_METHOD(Type, setSourceContext); +PHP_METHOD(Type, getSyntax); +PHP_METHOD(Type, setSyntax); + +PHP_METHOD(UInt32Value, __construct); +PHP_METHOD(UInt32Value, getValue); +PHP_METHOD(UInt32Value, setValue); + +PHP_METHOD(UInt64Value, __construct); +PHP_METHOD(UInt64Value, getValue); +PHP_METHOD(UInt64Value, setValue); + +PHP_METHOD(Value, __construct); +PHP_METHOD(Value, getNullValue); +PHP_METHOD(Value, setNullValue); +PHP_METHOD(Value, getNumberValue); +PHP_METHOD(Value, setNumberValue); +PHP_METHOD(Value, getStringValue); +PHP_METHOD(Value, setStringValue); +PHP_METHOD(Value, getBoolValue); +PHP_METHOD(Value, setBoolValue); +PHP_METHOD(Value, getStructValue); +PHP_METHOD(Value, setStructValue); +PHP_METHOD(Value, getListValue); +PHP_METHOD(Value, setListValue); +PHP_METHOD(Value, getKind); + extern zend_class_entry* any_type; +extern zend_class_entry* api_type; +extern zend_class_entry* bool_value_type; +extern zend_class_entry* bytes_value_type; +extern zend_class_entry* double_value_type; extern zend_class_entry* duration_type; +extern zend_class_entry* empty_type; +extern zend_class_entry* enum_type; +extern zend_class_entry* enum_value_type; +extern zend_class_entry* field_cardinality_type; +extern zend_class_entry* field_kind_type; +extern zend_class_entry* field_mask_type; +extern zend_class_entry* field_type; +extern zend_class_entry* float_value_type; +extern zend_class_entry* int32_value_type; +extern zend_class_entry* int64_value_type; +extern zend_class_entry* list_value_type; +extern zend_class_entry* method_type; +extern zend_class_entry* mixin_type; +extern zend_class_entry* null_value_type; +extern zend_class_entry* option_type; +extern zend_class_entry* source_context_type; +extern zend_class_entry* string_value_type; +extern zend_class_entry* struct_type; +extern zend_class_entry* syntax_type; extern zend_class_entry* timestamp_type; +extern zend_class_entry* type_type; +extern zend_class_entry* uint32_value_type; +extern zend_class_entry* uint64_value_type; +extern zend_class_entry* value_type; // ----------------------------------------------------------------------------- // Upb. diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c index cc34dcf6..a0488ecb 100644 --- a/php/ext/google/protobuf/storage.c +++ b/php/ext/google/protobuf/storage.c @@ -856,12 +856,41 @@ void layout_set(MessageLayout* layout, MessageHeader* header, zval* property_ptr = CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory); if (EXPECTED(property_ptr != val)) { + zend_class_entry *subce = NULL; + zval converted_value; + + if (upb_fielddef_ismap(field)) { + const upb_msgdef* mapmsg = upb_fielddef_msgsubdef(field); + const upb_fielddef* keyfield = upb_msgdef_ntof(mapmsg, "key", 3); + const upb_fielddef* valuefield = upb_msgdef_ntof(mapmsg, "value", 5); + if (upb_fielddef_descriptortype(valuefield) == + UPB_DESCRIPTOR_TYPE_MESSAGE) { + const upb_msgdef* submsg = upb_fielddef_msgsubdef(valuefield); + Descriptor* subdesc = + UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(submsg)); + subce = subdesc->klass; + } + check_map_field(subce, upb_fielddef_descriptortype(keyfield), + upb_fielddef_descriptortype(valuefield), val, + &converted_value); + } else { + if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) { + const upb_msgdef* submsg = upb_fielddef_msgsubdef(field); + Descriptor* subdesc = + UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(submsg)); + subce = subdesc->klass; + } + + check_repeated_field(subce, upb_fielddef_descriptortype(field), val, + &converted_value); + } #if PHP_MAJOR_VERSION < 7 - REPLACE_ZVAL_VALUE((zval**)memory, val, 1); + REPLACE_ZVAL_VALUE((zval**)memory, &converted_value, 1); #else - php_proto_zval_ptr_dtor(property_ptr); - ZVAL_ZVAL(property_ptr, val, 1, 0); + php_proto_zval_ptr_dtor(property_ptr); + ZVAL_ZVAL(property_ptr, &converted_value, 1, 0); #endif + zval_dtor(&converted_value); } } else { upb_fieldtype_t type = upb_fielddef_type(field); diff --git a/php/ext/google/protobuf/type_check.c b/php/ext/google/protobuf/type_check.c index fada8d6a..f588774c 100644 --- a/php/ext/google/protobuf/type_check.c +++ b/php/ext/google/protobuf/type_check.c @@ -428,21 +428,15 @@ PHP_METHOD(Util, checkMessage) { RETURN_ZVAL(val, 1, 0); } -PHP_METHOD(Util, checkRepeatedField) { - zval* val; - PHP_PROTO_LONG type; - const zend_class_entry* klass = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl|C", &val, &type, - &klass) == FAILURE) { - return; - } - +void check_repeated_field(const zend_class_entry* klass, PHP_PROTO_LONG type, + zval* val, zval* return_value) { #if PHP_MAJOR_VERSION >= 7 if (Z_ISREF_P(val)) { ZVAL_DEREF(val); } #endif + TSRMLS_FETCH(); if (Z_TYPE_P(val) == IS_ARRAY) { HashTable* table = HASH_OF(val); HashPosition pointer; @@ -492,24 +486,28 @@ PHP_METHOD(Util, checkRepeatedField) { zend_error(E_USER_ERROR, "Incorrect repeated field type."); return; } - } -PHP_METHOD(Util, checkMapField) { +PHP_METHOD(Util, checkRepeatedField) { zval* val; - PHP_PROTO_LONG key_type, value_type; + PHP_PROTO_LONG type; const zend_class_entry* klass = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zll|C", &val, &key_type, - &value_type, &klass) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl|C", &val, &type, + &klass) == FAILURE) { return; } + RETURN_ZVAL(val, 1, 0); +} +void check_map_field(const zend_class_entry* klass, PHP_PROTO_LONG key_type, + PHP_PROTO_LONG value_type, zval* val, zval* return_value) { #if PHP_MAJOR_VERSION >= 7 if (Z_ISREF_P(val)) { ZVAL_DEREF(val); } #endif + TSRMLS_FETCH(); if (Z_TYPE_P(val) == IS_ARRAY) { HashTable* table = Z_ARRVAL_P(val); HashPosition pointer; @@ -565,3 +563,14 @@ PHP_METHOD(Util, checkMapField) { return; } } + +PHP_METHOD(Util, checkMapField) { + zval* val; + PHP_PROTO_LONG key_type, value_type; + const zend_class_entry* klass = NULL; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zll|C", &val, &key_type, + &value_type, &klass) == FAILURE) { + return; + } + RETURN_ZVAL(val, 1, 0); +} diff --git a/php/src/GPBMetadata/Google/Protobuf/Api.php b/php/src/GPBMetadata/Google/Protobuf/Api.php new file mode 100644 index 00000000..b18e0d33 --- /dev/null +++ b/php/src/GPBMetadata/Google/Protobuf/Api.php @@ -0,0 +1,49 @@ +internalAddGeneratedFile(hex2bin( + "0ac8050a19676f6f676c652f70726f746f6275662f6170692e70726f746f" . + "120f676f6f676c652e70726f746f6275661a1a676f6f676c652f70726f74" . + "6f6275662f747970652e70726f746f2281020a03417069120c0a046e616d" . + "6518012001280912280a076d6574686f647318022003280b32172e676f6f" . + "676c652e70726f746f6275662e4d6574686f6412280a076f7074696f6e73" . + "18032003280b32172e676f6f676c652e70726f746f6275662e4f7074696f" . + "6e120f0a0776657273696f6e18042001280912360a0e736f757263655f63" . + "6f6e7465787418052001280b321e2e676f6f676c652e70726f746f627566" . + "2e536f75726365436f6e7465787412260a066d6978696e7318062003280b" . + "32162e676f6f676c652e70726f746f6275662e4d6978696e12270a067379" . + "6e74617818072001280e32172e676f6f676c652e70726f746f6275662e53" . + "796e74617822d5010a064d6574686f64120c0a046e616d65180120012809" . + "12180a10726571756573745f747970655f75726c18022001280912190a11" . + "726571756573745f73747265616d696e6718032001280812190a11726573" . + "706f6e73655f747970655f75726c180420012809121a0a12726573706f6e" . + "73655f73747265616d696e6718052001280812280a076f7074696f6e7318" . + "062003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e" . + "12270a0673796e74617818072001280e32172e676f6f676c652e70726f74" . + "6f6275662e53796e74617822230a054d6978696e120c0a046e616d651801" . + "20012809120c0a04726f6f7418022001280942750a13636f6d2e676f6f67" . + "6c652e70726f746f627566420841706950726f746f50015a2b676f6f676c" . + "652e676f6c616e672e6f72672f67656e70726f746f2f70726f746f627566" . + "2f6170693b617069a20203475042aa021e476f6f676c652e50726f746f62" . + "75662e57656c6c4b6e6f776e5479706573620670726f746f33" + )); + + static::$is_initialized = true; + } +} + diff --git a/php/src/GPBMetadata/Google/Protobuf/FieldMask.php b/php/src/GPBMetadata/Google/Protobuf/FieldMask.php new file mode 100644 index 00000000..5812be1e --- /dev/null +++ b/php/src/GPBMetadata/Google/Protobuf/FieldMask.php @@ -0,0 +1,31 @@ +internalAddGeneratedFile(hex2bin( + "0ae3010a20676f6f676c652f70726f746f6275662f6669656c645f6d6173" . + "6b2e70726f746f120f676f6f676c652e70726f746f627566221a0a094669" . + "656c644d61736b120d0a0570617468731801200328094289010a13636f6d" . + "2e676f6f676c652e70726f746f627566420e4669656c644d61736b50726f" . + "746f50015a39676f6f676c652e676f6c616e672e6f72672f67656e70726f" . + "746f2f70726f746f6275662f6669656c645f6d61736b3b6669656c645f6d" . + "61736ba20203475042aa021e476f6f676c652e50726f746f6275662e5765" . + "6c6c4b6e6f776e5479706573620670726f746f33" + )); + + static::$is_initialized = true; + } +} + diff --git a/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php b/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php new file mode 100644 index 00000000..88f42a11 --- /dev/null +++ b/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php @@ -0,0 +1,30 @@ +internalAddGeneratedFile(hex2bin( + "0ab7010a1b676f6f676c652f70726f746f6275662f656d7074792e70726f" . + "746f120f676f6f676c652e70726f746f62756622070a05456d7074794276" . + "0a13636f6d2e676f6f676c652e70726f746f627566420a456d7074795072" . + "6f746f50015a276769746875622e636f6d2f676f6c616e672f70726f746f" . + "6275662f7074797065732f656d707479f80101a20203475042aa021e476f" . + "6f676c652e50726f746f6275662e57656c6c4b6e6f776e54797065736206" . + "70726f746f33" + )); + + static::$is_initialized = true; + } +} + diff --git a/php/src/GPBMetadata/Google/Protobuf/SourceContext.php b/php/src/GPBMetadata/Google/Protobuf/SourceContext.php new file mode 100644 index 00000000..495c6de4 --- /dev/null +++ b/php/src/GPBMetadata/Google/Protobuf/SourceContext.php @@ -0,0 +1,32 @@ +internalAddGeneratedFile(hex2bin( + "0afb010a24676f6f676c652f70726f746f6275662f736f757263655f636f" . + "6e746578742e70726f746f120f676f6f676c652e70726f746f6275662222" . + "0a0d536f75726365436f6e7465787412110a0966696c655f6e616d651801" . + "200128094295010a13636f6d2e676f6f676c652e70726f746f6275664212" . + "536f75726365436f6e7465787450726f746f50015a41676f6f676c652e67" . + "6f6c616e672e6f72672f67656e70726f746f2f70726f746f6275662f736f" . + "757263655f636f6e746578743b736f757263655f636f6e74657874a20203" . + "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77" . + "6e5479706573620670726f746f33" + )); + + static::$is_initialized = true; + } +} + diff --git a/php/src/GPBMetadata/Google/Protobuf/Struct.php b/php/src/GPBMetadata/Google/Protobuf/Struct.php new file mode 100644 index 00000000..96b42af4 --- /dev/null +++ b/php/src/GPBMetadata/Google/Protobuf/Struct.php @@ -0,0 +1,45 @@ +internalAddGeneratedFile(hex2bin( + "0a81050a1c676f6f676c652f70726f746f6275662f7374727563742e7072" . + "6f746f120f676f6f676c652e70726f746f6275662284010a065374727563" . + "7412330a066669656c647318012003280b32232e676f6f676c652e70726f" . + "746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669" . + "656c6473456e747279120b0a036b657918012001280912250a0576616c75" . + "6518022001280b32162e676f6f676c652e70726f746f6275662e56616c75" . + "653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518" . + "012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c5661" . + "6c7565480012160a0c6e756d6265725f76616c7565180220012801480012" . + "160a0c737472696e675f76616c7565180320012809480012140a0a626f6f" . + "6c5f76616c75651804200128084800122f0a0c7374727563745f76616c75" . + "6518052001280b32172e676f6f676c652e70726f746f6275662e53747275" . + "6374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f" . + "676c652e70726f746f6275662e4c69737456616c7565480042060a046b69" . + "6e6422330a094c69737456616c756512260a0676616c7565731801200328" . + "0b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e" . + "756c6c56616c7565120e0a0a4e554c4c5f56414c554510004281010a1363" . + "6f6d2e676f6f676c652e70726f746f627566420b53747275637450726f74" . + "6f50015a316769746875622e636f6d2f676f6c616e672f70726f746f6275" . + "662f7074797065732f7374727563743b7374727563747062f80101a20203" . + "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77" . + "6e5479706573620670726f746f33" + )); + + static::$is_initialized = true; + } +} + diff --git a/php/src/GPBMetadata/Google/Protobuf/Type.php b/php/src/GPBMetadata/Google/Protobuf/Type.php new file mode 100644 index 00000000..8fbe8cbf --- /dev/null +++ b/php/src/GPBMetadata/Google/Protobuf/Type.php @@ -0,0 +1,78 @@ +internalAddGeneratedFile(hex2bin( + "0a9f0c0a1a676f6f676c652f70726f746f6275662f747970652e70726f74" . + "6f120f676f6f676c652e70726f746f6275661a24676f6f676c652f70726f" . + "746f6275662f736f757263655f636f6e746578742e70726f746f22d7010a" . + "0454797065120c0a046e616d6518012001280912260a066669656c647318" . + "022003280b32162e676f6f676c652e70726f746f6275662e4669656c6412" . + "0e0a066f6e656f667318032003280912280a076f7074696f6e7318042003" . + "280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e12360a" . + "0e736f757263655f636f6e7465787418052001280b321e2e676f6f676c65" . + "2e70726f746f6275662e536f75726365436f6e7465787412270a0673796e" . + "74617818062001280e32172e676f6f676c652e70726f746f6275662e5379" . + "6e74617822d5050a054669656c6412290a046b696e6418012001280e321b" . + "2e676f6f676c652e70726f746f6275662e4669656c642e4b696e6412370a" . + "0b63617264696e616c69747918022001280e32222e676f6f676c652e7072" . + "6f746f6275662e4669656c642e43617264696e616c697479120e0a066e75" . + "6d626572180320012805120c0a046e616d6518042001280912100a087479" . + "70655f75726c18062001280912130a0b6f6e656f665f696e646578180720" . + "012805120e0a067061636b656418082001280812280a076f7074696f6e73" . + "18092003280b32172e676f6f676c652e70726f746f6275662e4f7074696f" . + "6e12110a096a736f6e5f6e616d65180a2001280912150a0d64656661756c" . + "745f76616c7565180b2001280922c8020a044b696e6412100a0c54595045" . + "5f554e4b4e4f574e1000120f0a0b545950455f444f55424c451001120e0a" . + "0a545950455f464c4f41541002120e0a0a545950455f494e543634100312" . + "0f0a0b545950455f55494e5436341004120e0a0a545950455f494e543332" . + "100512100a0c545950455f46495845443634100612100a0c545950455f46" . + "4958454433321007120d0a09545950455f424f4f4c1008120f0a0b545950" . + "455f535452494e471009120e0a0a545950455f47524f5550100a12100a0c" . + "545950455f4d455353414745100b120e0a0a545950455f4259544553100c" . + "120f0a0b545950455f55494e543332100d120d0a09545950455f454e554d" . + "100e12110a0d545950455f5346495845443332100f12110a0d545950455f" . + "53464958454436341010120f0a0b545950455f53494e5433321011120f0a" . + "0b545950455f53494e543634101222740a0b43617264696e616c69747912" . + "170a1343415244494e414c4954595f554e4b4e4f574e100012180a144341" . + "5244494e414c4954595f4f5054494f4e414c100112180a1443415244494e" . + "414c4954595f5245515549524544100212180a1443415244494e414c4954" . + "595f5245504541544544100322ce010a04456e756d120c0a046e616d6518" . + "0120012809122d0a09656e756d76616c756518022003280b321a2e676f6f" . + "676c652e70726f746f6275662e456e756d56616c756512280a076f707469" . + "6f6e7318032003280b32172e676f6f676c652e70726f746f6275662e4f70" . + "74696f6e12360a0e736f757263655f636f6e7465787418042001280b321e" . + "2e676f6f676c652e70726f746f6275662e536f75726365436f6e74657874" . + "12270a0673796e74617818052001280e32172e676f6f676c652e70726f74" . + "6f6275662e53796e74617822530a09456e756d56616c7565120c0a046e61" . + "6d65180120012809120e0a066e756d62657218022001280512280a076f70" . + "74696f6e7318032003280b32172e676f6f676c652e70726f746f6275662e" . + "4f7074696f6e223b0a064f7074696f6e120c0a046e616d65180120012809" . + "12230a0576616c756518022001280b32142e676f6f676c652e70726f746f" . + "6275662e416e792a2e0a0653796e74617812110a0d53594e5441585f5052" . + "4f544f32100012110a0d53594e5441585f50524f544f331001427d0a1363" . + "6f6d2e676f6f676c652e70726f746f62756642095479706550726f746f50" . + "015a2f676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f" . + "70726f746f6275662f70747970653b7074797065f80101a20203475042aa" . + "021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e547970" . + "6573620670726f746f33" + )); + + static::$is_initialized = true; + } +} + diff --git a/php/src/GPBMetadata/Google/Protobuf/Wrappers.php b/php/src/GPBMetadata/Google/Protobuf/Wrappers.php new file mode 100644 index 00000000..dd72ff48 --- /dev/null +++ b/php/src/GPBMetadata/Google/Protobuf/Wrappers.php @@ -0,0 +1,38 @@ +internalAddGeneratedFile(hex2bin( + "0abf030a1e676f6f676c652f70726f746f6275662f77726170706572732e" . + "70726f746f120f676f6f676c652e70726f746f627566221c0a0b446f7562" . + "6c6556616c7565120d0a0576616c7565180120012801221b0a0a466c6f61" . + "7456616c7565120d0a0576616c7565180120012802221b0a0a496e743634" . + "56616c7565120d0a0576616c7565180120012803221c0a0b55496e743634" . + "56616c7565120d0a0576616c7565180120012804221b0a0a496e74333256" . + "616c7565120d0a0576616c7565180120012805221c0a0b55496e74333256" . + "616c7565120d0a0576616c756518012001280d221a0a09426f6f6c56616c" . + "7565120d0a0576616c7565180120012808221c0a0b537472696e6756616c" . + "7565120d0a0576616c7565180120012809221b0a0a427974657356616c75" . + "65120d0a0576616c756518012001280c427c0a13636f6d2e676f6f676c65" . + "2e70726f746f627566420d577261707065727350726f746f50015a2a6769" . + "746875622e636f6d2f676f6c616e672f70726f746f6275662f7074797065" . + "732f7772617070657273f80101a20203475042aa021e476f6f676c652e50" . + "726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + )); + + static::$is_initialized = true; + } +} + diff --git a/php/src/Google/Protobuf/Api.php b/php/src/Google/Protobuf/Api.php new file mode 100644 index 00000000..d0dda3cd --- /dev/null +++ b/php/src/Google/Protobuf/Api.php @@ -0,0 +1,310 @@ +google.protobuf.Api + */ +class Api extends \Google\Protobuf\Internal\Message +{ + /** + * The fully qualified name of this interface, including package name + * followed by the interface's simple name. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * The methods of this interface, in unspecified order. + * + * Generated from protobuf field repeated .google.protobuf.Method methods = 2; + */ + private $methods; + /** + * Any metadata attached to the interface. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 3; + */ + private $options; + /** + * A version string for this interface. If specified, must have the form + * `major-version.minor-version`, as in `1.10`. If the minor version is + * omitted, it defaults to zero. If the entire version field is empty, the + * major version is derived from the package name, as outlined below. If the + * field is not empty, the version in the package name will be verified to be + * consistent with what is provided here. + * The versioning schema uses [semantic + * versioning](http://semver.org) where the major version number + * indicates a breaking change and the minor version an additive, + * non-breaking change. Both version numbers are signals to users + * what to expect from different versions, and should be carefully + * chosen based on the product plan. + * The major version is also reflected in the package name of the + * interface, which must end in `v`, as in + * `google.feature.v1`. For major versions 0 and 1, the suffix can + * be omitted. Zero major versions must only be used for + * experimental, non-GA interfaces. + * + * Generated from protobuf field string version = 4; + */ + private $version = ''; + /** + * Source context for the protocol buffer service represented by this + * message. + * + * Generated from protobuf field .google.protobuf.SourceContext source_context = 5; + */ + private $source_context = null; + /** + * Included interfaces. See [Mixin][]. + * + * Generated from protobuf field repeated .google.protobuf.Mixin mixins = 6; + */ + private $mixins; + /** + * The source syntax of the service. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 7; + */ + private $syntax = 0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Api::initOnce(); + parent::__construct(); + } + + /** + * The fully qualified name of this interface, including package name + * followed by the interface's simple name. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The fully qualified name of this interface, including package name + * followed by the interface's simple name. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The methods of this interface, in unspecified order. + * + * Generated from protobuf field repeated .google.protobuf.Method methods = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMethods() + { + return $this->methods; + } + + /** + * The methods of this interface, in unspecified order. + * + * Generated from protobuf field repeated .google.protobuf.Method methods = 2; + * @param \Google\Protobuf\Method[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMethods($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Method::class); + $this->methods = $arr; + + return $this; + } + + /** + * Any metadata attached to the interface. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOptions() + { + return $this->options; + } + + /** + * Any metadata attached to the interface. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 3; + * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOptions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class); + $this->options = $arr; + + return $this; + } + + /** + * A version string for this interface. If specified, must have the form + * `major-version.minor-version`, as in `1.10`. If the minor version is + * omitted, it defaults to zero. If the entire version field is empty, the + * major version is derived from the package name, as outlined below. If the + * field is not empty, the version in the package name will be verified to be + * consistent with what is provided here. + * The versioning schema uses [semantic + * versioning](http://semver.org) where the major version number + * indicates a breaking change and the minor version an additive, + * non-breaking change. Both version numbers are signals to users + * what to expect from different versions, and should be carefully + * chosen based on the product plan. + * The major version is also reflected in the package name of the + * interface, which must end in `v`, as in + * `google.feature.v1`. For major versions 0 and 1, the suffix can + * be omitted. Zero major versions must only be used for + * experimental, non-GA interfaces. + * + * Generated from protobuf field string version = 4; + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * A version string for this interface. If specified, must have the form + * `major-version.minor-version`, as in `1.10`. If the minor version is + * omitted, it defaults to zero. If the entire version field is empty, the + * major version is derived from the package name, as outlined below. If the + * field is not empty, the version in the package name will be verified to be + * consistent with what is provided here. + * The versioning schema uses [semantic + * versioning](http://semver.org) where the major version number + * indicates a breaking change and the minor version an additive, + * non-breaking change. Both version numbers are signals to users + * what to expect from different versions, and should be carefully + * chosen based on the product plan. + * The major version is also reflected in the package name of the + * interface, which must end in `v`, as in + * `google.feature.v1`. For major versions 0 and 1, the suffix can + * be omitted. Zero major versions must only be used for + * experimental, non-GA interfaces. + * + * Generated from protobuf field string version = 4; + * @param string $var + * @return $this + */ + public function setVersion($var) + { + GPBUtil::checkString($var, True); + $this->version = $var; + + return $this; + } + + /** + * Source context for the protocol buffer service represented by this + * message. + * + * Generated from protobuf field .google.protobuf.SourceContext source_context = 5; + * @return \Google\Protobuf\SourceContext + */ + public function getSourceContext() + { + return $this->source_context; + } + + /** + * Source context for the protocol buffer service represented by this + * message. + * + * Generated from protobuf field .google.protobuf.SourceContext source_context = 5; + * @param \Google\Protobuf\SourceContext $var + * @return $this + */ + public function setSourceContext($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\SourceContext::class); + $this->source_context = $var; + + return $this; + } + + /** + * Included interfaces. See [Mixin][]. + * + * Generated from protobuf field repeated .google.protobuf.Mixin mixins = 6; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMixins() + { + return $this->mixins; + } + + /** + * Included interfaces. See [Mixin][]. + * + * Generated from protobuf field repeated .google.protobuf.Mixin mixins = 6; + * @param \Google\Protobuf\Mixin[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMixins($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Mixin::class); + $this->mixins = $arr; + + return $this; + } + + /** + * The source syntax of the service. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 7; + * @return int + */ + public function getSyntax() + { + return $this->syntax; + } + + /** + * The source syntax of the service. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 7; + * @param int $var + * @return $this + */ + public function setSyntax($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Syntax::class); + $this->syntax = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/BoolValue.php b/php/src/Google/Protobuf/BoolValue.php new file mode 100644 index 00000000..c28bf941 --- /dev/null +++ b/php/src/Google/Protobuf/BoolValue.php @@ -0,0 +1,58 @@ +google.protobuf.BoolValue + */ +class BoolValue extends \Google\Protobuf\Internal\Message +{ + /** + * The bool value. + * + * Generated from protobuf field bool value = 1; + */ + private $value = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Wrappers::initOnce(); + parent::__construct(); + } + + /** + * The bool value. + * + * Generated from protobuf field bool value = 1; + * @return bool + */ + public function getValue() + { + return $this->value; + } + + /** + * The bool value. + * + * Generated from protobuf field bool value = 1; + * @param bool $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkBool($var); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/BytesValue.php b/php/src/Google/Protobuf/BytesValue.php new file mode 100644 index 00000000..d6a6b2e6 --- /dev/null +++ b/php/src/Google/Protobuf/BytesValue.php @@ -0,0 +1,58 @@ +google.protobuf.BytesValue + */ +class BytesValue extends \Google\Protobuf\Internal\Message +{ + /** + * The bytes value. + * + * Generated from protobuf field bytes value = 1; + */ + private $value = ''; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Wrappers::initOnce(); + parent::__construct(); + } + + /** + * The bytes value. + * + * Generated from protobuf field bytes value = 1; + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * The bytes value. + * + * Generated from protobuf field bytes value = 1; + * @param string $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkString($var, False); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/DoubleValue.php b/php/src/Google/Protobuf/DoubleValue.php new file mode 100644 index 00000000..6718ce3c --- /dev/null +++ b/php/src/Google/Protobuf/DoubleValue.php @@ -0,0 +1,58 @@ +google.protobuf.DoubleValue + */ +class DoubleValue extends \Google\Protobuf\Internal\Message +{ + /** + * The double value. + * + * Generated from protobuf field double value = 1; + */ + private $value = 0.0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Wrappers::initOnce(); + parent::__construct(); + } + + /** + * The double value. + * + * Generated from protobuf field double value = 1; + * @return float + */ + public function getValue() + { + return $this->value; + } + + /** + * The double value. + * + * Generated from protobuf field double value = 1; + * @param float $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkDouble($var); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/Enum.php b/php/src/Google/Protobuf/Enum.php new file mode 100644 index 00000000..c63efc74 --- /dev/null +++ b/php/src/Google/Protobuf/Enum.php @@ -0,0 +1,185 @@ +google.protobuf.Enum + */ +class Enum extends \Google\Protobuf\Internal\Message +{ + /** + * Enum type name. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Enum value definitions. + * + * Generated from protobuf field repeated .google.protobuf.EnumValue enumvalue = 2; + */ + private $enumvalue; + /** + * Protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 3; + */ + private $options; + /** + * The source context. + * + * Generated from protobuf field .google.protobuf.SourceContext source_context = 4; + */ + private $source_context = null; + /** + * The source syntax. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 5; + */ + private $syntax = 0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Type::initOnce(); + parent::__construct(); + } + + /** + * Enum type name. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Enum type name. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Enum value definitions. + * + * Generated from protobuf field repeated .google.protobuf.EnumValue enumvalue = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEnumvalue() + { + return $this->enumvalue; + } + + /** + * Enum value definitions. + * + * Generated from protobuf field repeated .google.protobuf.EnumValue enumvalue = 2; + * @param \Google\Protobuf\EnumValue[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEnumvalue($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\EnumValue::class); + $this->enumvalue = $arr; + + return $this; + } + + /** + * Protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOptions() + { + return $this->options; + } + + /** + * Protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 3; + * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOptions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class); + $this->options = $arr; + + return $this; + } + + /** + * The source context. + * + * Generated from protobuf field .google.protobuf.SourceContext source_context = 4; + * @return \Google\Protobuf\SourceContext + */ + public function getSourceContext() + { + return $this->source_context; + } + + /** + * The source context. + * + * Generated from protobuf field .google.protobuf.SourceContext source_context = 4; + * @param \Google\Protobuf\SourceContext $var + * @return $this + */ + public function setSourceContext($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\SourceContext::class); + $this->source_context = $var; + + return $this; + } + + /** + * The source syntax. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 5; + * @return int + */ + public function getSyntax() + { + return $this->syntax; + } + + /** + * The source syntax. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 5; + * @param int $var + * @return $this + */ + public function setSyntax($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Syntax::class); + $this->syntax = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/EnumValue.php b/php/src/Google/Protobuf/EnumValue.php new file mode 100644 index 00000000..e102c29f --- /dev/null +++ b/php/src/Google/Protobuf/EnumValue.php @@ -0,0 +1,121 @@ +google.protobuf.EnumValue + */ +class EnumValue extends \Google\Protobuf\Internal\Message +{ + /** + * Enum value name. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * Enum value number. + * + * Generated from protobuf field int32 number = 2; + */ + private $number = 0; + /** + * Protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 3; + */ + private $options; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Type::initOnce(); + parent::__construct(); + } + + /** + * Enum value name. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Enum value name. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Enum value number. + * + * Generated from protobuf field int32 number = 2; + * @return int + */ + public function getNumber() + { + return $this->number; + } + + /** + * Enum value number. + * + * Generated from protobuf field int32 number = 2; + * @param int $var + * @return $this + */ + public function setNumber($var) + { + GPBUtil::checkInt32($var); + $this->number = $var; + + return $this; + } + + /** + * Protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOptions() + { + return $this->options; + } + + /** + * Protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 3; + * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOptions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class); + $this->options = $arr; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/Field.php b/php/src/Google/Protobuf/Field.php new file mode 100644 index 00000000..0b560d89 --- /dev/null +++ b/php/src/Google/Protobuf/Field.php @@ -0,0 +1,351 @@ +google.protobuf.Field + */ +class Field extends \Google\Protobuf\Internal\Message +{ + /** + * The field type. + * + * Generated from protobuf field .google.protobuf.Field.Kind kind = 1; + */ + private $kind = 0; + /** + * The field cardinality. + * + * Generated from protobuf field .google.protobuf.Field.Cardinality cardinality = 2; + */ + private $cardinality = 0; + /** + * The field number. + * + * Generated from protobuf field int32 number = 3; + */ + private $number = 0; + /** + * The field name. + * + * Generated from protobuf field string name = 4; + */ + private $name = ''; + /** + * The field type URL, without the scheme, for message or enumeration + * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. + * + * Generated from protobuf field string type_url = 6; + */ + private $type_url = ''; + /** + * The index of the field type in `Type.oneofs`, for message or enumeration + * types. The first type has index 1; zero means the type is not in the list. + * + * Generated from protobuf field int32 oneof_index = 7; + */ + private $oneof_index = 0; + /** + * Whether to use alternative packed wire representation. + * + * Generated from protobuf field bool packed = 8; + */ + private $packed = false; + /** + * The protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 9; + */ + private $options; + /** + * The field JSON name. + * + * Generated from protobuf field string json_name = 10; + */ + private $json_name = ''; + /** + * The string value of the default value of this field. Proto2 syntax only. + * + * Generated from protobuf field string default_value = 11; + */ + private $default_value = ''; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Type::initOnce(); + parent::__construct(); + } + + /** + * The field type. + * + * Generated from protobuf field .google.protobuf.Field.Kind kind = 1; + * @return int + */ + public function getKind() + { + return $this->kind; + } + + /** + * The field type. + * + * Generated from protobuf field .google.protobuf.Field.Kind kind = 1; + * @param int $var + * @return $this + */ + public function setKind($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Field_Kind::class); + $this->kind = $var; + + return $this; + } + + /** + * The field cardinality. + * + * Generated from protobuf field .google.protobuf.Field.Cardinality cardinality = 2; + * @return int + */ + public function getCardinality() + { + return $this->cardinality; + } + + /** + * The field cardinality. + * + * Generated from protobuf field .google.protobuf.Field.Cardinality cardinality = 2; + * @param int $var + * @return $this + */ + public function setCardinality($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Field_Cardinality::class); + $this->cardinality = $var; + + return $this; + } + + /** + * The field number. + * + * Generated from protobuf field int32 number = 3; + * @return int + */ + public function getNumber() + { + return $this->number; + } + + /** + * The field number. + * + * Generated from protobuf field int32 number = 3; + * @param int $var + * @return $this + */ + public function setNumber($var) + { + GPBUtil::checkInt32($var); + $this->number = $var; + + return $this; + } + + /** + * The field name. + * + * Generated from protobuf field string name = 4; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The field name. + * + * Generated from protobuf field string name = 4; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The field type URL, without the scheme, for message or enumeration + * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. + * + * Generated from protobuf field string type_url = 6; + * @return string + */ + public function getTypeUrl() + { + return $this->type_url; + } + + /** + * The field type URL, without the scheme, for message or enumeration + * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. + * + * Generated from protobuf field string type_url = 6; + * @param string $var + * @return $this + */ + public function setTypeUrl($var) + { + GPBUtil::checkString($var, True); + $this->type_url = $var; + + return $this; + } + + /** + * The index of the field type in `Type.oneofs`, for message or enumeration + * types. The first type has index 1; zero means the type is not in the list. + * + * Generated from protobuf field int32 oneof_index = 7; + * @return int + */ + public function getOneofIndex() + { + return $this->oneof_index; + } + + /** + * The index of the field type in `Type.oneofs`, for message or enumeration + * types. The first type has index 1; zero means the type is not in the list. + * + * Generated from protobuf field int32 oneof_index = 7; + * @param int $var + * @return $this + */ + public function setOneofIndex($var) + { + GPBUtil::checkInt32($var); + $this->oneof_index = $var; + + return $this; + } + + /** + * Whether to use alternative packed wire representation. + * + * Generated from protobuf field bool packed = 8; + * @return bool + */ + public function getPacked() + { + return $this->packed; + } + + /** + * Whether to use alternative packed wire representation. + * + * Generated from protobuf field bool packed = 8; + * @param bool $var + * @return $this + */ + public function setPacked($var) + { + GPBUtil::checkBool($var); + $this->packed = $var; + + return $this; + } + + /** + * The protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 9; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOptions() + { + return $this->options; + } + + /** + * The protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 9; + * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOptions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class); + $this->options = $arr; + + return $this; + } + + /** + * The field JSON name. + * + * Generated from protobuf field string json_name = 10; + * @return string + */ + public function getJsonName() + { + return $this->json_name; + } + + /** + * The field JSON name. + * + * Generated from protobuf field string json_name = 10; + * @param string $var + * @return $this + */ + public function setJsonName($var) + { + GPBUtil::checkString($var, True); + $this->json_name = $var; + + return $this; + } + + /** + * The string value of the default value of this field. Proto2 syntax only. + * + * Generated from protobuf field string default_value = 11; + * @return string + */ + public function getDefaultValue() + { + return $this->default_value; + } + + /** + * The string value of the default value of this field. Proto2 syntax only. + * + * Generated from protobuf field string default_value = 11; + * @param string $var + * @return $this + */ + public function setDefaultValue($var) + { + GPBUtil::checkString($var, True); + $this->default_value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/FieldMask.php b/php/src/Google/Protobuf/FieldMask.php new file mode 100644 index 00000000..e18586af --- /dev/null +++ b/php/src/Google/Protobuf/FieldMask.php @@ -0,0 +1,209 @@ +google.protobuf.FieldMask + */ +class FieldMask extends \Google\Protobuf\Internal\Message +{ + /** + * The set of field mask paths. + * + * Generated from protobuf field repeated string paths = 1; + */ + private $paths; + + public function __construct() { + \GPBMetadata\Google\Protobuf\FieldMask::initOnce(); + parent::__construct(); + } + + /** + * The set of field mask paths. + * + * Generated from protobuf field repeated string paths = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPaths() + { + return $this->paths; + } + + /** + * The set of field mask paths. + * + * Generated from protobuf field repeated string paths = 1; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPaths($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->paths = $arr; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/Field_Cardinality.php b/php/src/Google/Protobuf/Field_Cardinality.php new file mode 100644 index 00000000..422587ca --- /dev/null +++ b/php/src/Google/Protobuf/Field_Cardinality.php @@ -0,0 +1,39 @@ +Google\Protobuf\Field\Cardinality + */ +class Field_Cardinality +{ + /** + * For fields with unknown cardinality. + * + * Generated from protobuf enum CARDINALITY_UNKNOWN = 0; + */ + const CARDINALITY_UNKNOWN = 0; + /** + * For optional fields. + * + * Generated from protobuf enum CARDINALITY_OPTIONAL = 1; + */ + const CARDINALITY_OPTIONAL = 1; + /** + * For required fields. Proto2 syntax only. + * + * Generated from protobuf enum CARDINALITY_REQUIRED = 2; + */ + const CARDINALITY_REQUIRED = 2; + /** + * For repeated fields. + * + * Generated from protobuf enum CARDINALITY_REPEATED = 3; + */ + const CARDINALITY_REPEATED = 3; +} + diff --git a/php/src/Google/Protobuf/Field_Kind.php b/php/src/Google/Protobuf/Field_Kind.php new file mode 100644 index 00000000..d0774970 --- /dev/null +++ b/php/src/Google/Protobuf/Field_Kind.php @@ -0,0 +1,129 @@ +Google\Protobuf\Field\Kind + */ +class Field_Kind +{ + /** + * Field type unknown. + * + * Generated from protobuf enum TYPE_UNKNOWN = 0; + */ + const TYPE_UNKNOWN = 0; + /** + * Field type double. + * + * Generated from protobuf enum TYPE_DOUBLE = 1; + */ + const TYPE_DOUBLE = 1; + /** + * Field type float. + * + * Generated from protobuf enum TYPE_FLOAT = 2; + */ + const TYPE_FLOAT = 2; + /** + * Field type int64. + * + * Generated from protobuf enum TYPE_INT64 = 3; + */ + const TYPE_INT64 = 3; + /** + * Field type uint64. + * + * Generated from protobuf enum TYPE_UINT64 = 4; + */ + const TYPE_UINT64 = 4; + /** + * Field type int32. + * + * Generated from protobuf enum TYPE_INT32 = 5; + */ + const TYPE_INT32 = 5; + /** + * Field type fixed64. + * + * Generated from protobuf enum TYPE_FIXED64 = 6; + */ + const TYPE_FIXED64 = 6; + /** + * Field type fixed32. + * + * Generated from protobuf enum TYPE_FIXED32 = 7; + */ + const TYPE_FIXED32 = 7; + /** + * Field type bool. + * + * Generated from protobuf enum TYPE_BOOL = 8; + */ + const TYPE_BOOL = 8; + /** + * Field type string. + * + * Generated from protobuf enum TYPE_STRING = 9; + */ + const TYPE_STRING = 9; + /** + * Field type group. Proto2 syntax only, and deprecated. + * + * Generated from protobuf enum TYPE_GROUP = 10; + */ + const TYPE_GROUP = 10; + /** + * Field type message. + * + * Generated from protobuf enum TYPE_MESSAGE = 11; + */ + const TYPE_MESSAGE = 11; + /** + * Field type bytes. + * + * Generated from protobuf enum TYPE_BYTES = 12; + */ + const TYPE_BYTES = 12; + /** + * Field type uint32. + * + * Generated from protobuf enum TYPE_UINT32 = 13; + */ + const TYPE_UINT32 = 13; + /** + * Field type enum. + * + * Generated from protobuf enum TYPE_ENUM = 14; + */ + const TYPE_ENUM = 14; + /** + * Field type sfixed32. + * + * Generated from protobuf enum TYPE_SFIXED32 = 15; + */ + const TYPE_SFIXED32 = 15; + /** + * Field type sfixed64. + * + * Generated from protobuf enum TYPE_SFIXED64 = 16; + */ + const TYPE_SFIXED64 = 16; + /** + * Field type sint32. + * + * Generated from protobuf enum TYPE_SINT32 = 17; + */ + const TYPE_SINT32 = 17; + /** + * Field type sint64. + * + * Generated from protobuf enum TYPE_SINT64 = 18; + */ + const TYPE_SINT64 = 18; +} + diff --git a/php/src/Google/Protobuf/FloatValue.php b/php/src/Google/Protobuf/FloatValue.php new file mode 100644 index 00000000..68787ef9 --- /dev/null +++ b/php/src/Google/Protobuf/FloatValue.php @@ -0,0 +1,58 @@ +google.protobuf.FloatValue + */ +class FloatValue extends \Google\Protobuf\Internal\Message +{ + /** + * The float value. + * + * Generated from protobuf field float value = 1; + */ + private $value = 0.0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Wrappers::initOnce(); + parent::__construct(); + } + + /** + * The float value. + * + * Generated from protobuf field float value = 1; + * @return float + */ + public function getValue() + { + return $this->value; + } + + /** + * The float value. + * + * Generated from protobuf field float value = 1; + * @param float $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkFloat($var); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/GPBEmpty.php b/php/src/Google/Protobuf/GPBEmpty.php new file mode 100644 index 00000000..24a93f96 --- /dev/null +++ b/php/src/Google/Protobuf/GPBEmpty.php @@ -0,0 +1,31 @@ +google.protobuf.Empty + */ +class GPBEmpty extends \Google\Protobuf\Internal\Message +{ + + public function __construct() { + \GPBMetadata\Google\Protobuf\GPBEmpty::initOnce(); + parent::__construct(); + } + +} + diff --git a/php/src/Google/Protobuf/Int32Value.php b/php/src/Google/Protobuf/Int32Value.php new file mode 100644 index 00000000..d48aff1b --- /dev/null +++ b/php/src/Google/Protobuf/Int32Value.php @@ -0,0 +1,58 @@ +google.protobuf.Int32Value + */ +class Int32Value extends \Google\Protobuf\Internal\Message +{ + /** + * The int32 value. + * + * Generated from protobuf field int32 value = 1; + */ + private $value = 0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Wrappers::initOnce(); + parent::__construct(); + } + + /** + * The int32 value. + * + * Generated from protobuf field int32 value = 1; + * @return int + */ + public function getValue() + { + return $this->value; + } + + /** + * The int32 value. + * + * Generated from protobuf field int32 value = 1; + * @param int $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkInt32($var); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/Int64Value.php b/php/src/Google/Protobuf/Int64Value.php new file mode 100644 index 00000000..a6fb9c5d --- /dev/null +++ b/php/src/Google/Protobuf/Int64Value.php @@ -0,0 +1,58 @@ +google.protobuf.Int64Value + */ +class Int64Value extends \Google\Protobuf\Internal\Message +{ + /** + * The int64 value. + * + * Generated from protobuf field int64 value = 1; + */ + private $value = 0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Wrappers::initOnce(); + parent::__construct(); + } + + /** + * The int64 value. + * + * Generated from protobuf field int64 value = 1; + * @return int|string + */ + public function getValue() + { + return $this->value; + } + + /** + * The int64 value. + * + * Generated from protobuf field int64 value = 1; + * @param int|string $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkInt64($var); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/ListValue.php b/php/src/Google/Protobuf/ListValue.php new file mode 100644 index 00000000..12552ef4 --- /dev/null +++ b/php/src/Google/Protobuf/ListValue.php @@ -0,0 +1,58 @@ +google.protobuf.ListValue + */ +class ListValue extends \Google\Protobuf\Internal\Message +{ + /** + * Repeated field of dynamically typed values. + * + * Generated from protobuf field repeated .google.protobuf.Value values = 1; + */ + private $values; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Struct::initOnce(); + parent::__construct(); + } + + /** + * Repeated field of dynamically typed values. + * + * Generated from protobuf field repeated .google.protobuf.Value values = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getValues() + { + return $this->values; + } + + /** + * Repeated field of dynamically typed values. + * + * Generated from protobuf field repeated .google.protobuf.Value values = 1; + * @param \Google\Protobuf\Value[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setValues($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class); + $this->values = $arr; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/Method.php b/php/src/Google/Protobuf/Method.php new file mode 100644 index 00000000..f55cb764 --- /dev/null +++ b/php/src/Google/Protobuf/Method.php @@ -0,0 +1,249 @@ +google.protobuf.Method + */ +class Method extends \Google\Protobuf\Internal\Message +{ + /** + * The simple name of this method. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * A URL of the input message type. + * + * Generated from protobuf field string request_type_url = 2; + */ + private $request_type_url = ''; + /** + * If true, the request is streamed. + * + * Generated from protobuf field bool request_streaming = 3; + */ + private $request_streaming = false; + /** + * The URL of the output message type. + * + * Generated from protobuf field string response_type_url = 4; + */ + private $response_type_url = ''; + /** + * If true, the response is streamed. + * + * Generated from protobuf field bool response_streaming = 5; + */ + private $response_streaming = false; + /** + * Any metadata attached to the method. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 6; + */ + private $options; + /** + * The source syntax of this method. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 7; + */ + private $syntax = 0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Api::initOnce(); + parent::__construct(); + } + + /** + * The simple name of this method. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The simple name of this method. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * A URL of the input message type. + * + * Generated from protobuf field string request_type_url = 2; + * @return string + */ + public function getRequestTypeUrl() + { + return $this->request_type_url; + } + + /** + * A URL of the input message type. + * + * Generated from protobuf field string request_type_url = 2; + * @param string $var + * @return $this + */ + public function setRequestTypeUrl($var) + { + GPBUtil::checkString($var, True); + $this->request_type_url = $var; + + return $this; + } + + /** + * If true, the request is streamed. + * + * Generated from protobuf field bool request_streaming = 3; + * @return bool + */ + public function getRequestStreaming() + { + return $this->request_streaming; + } + + /** + * If true, the request is streamed. + * + * Generated from protobuf field bool request_streaming = 3; + * @param bool $var + * @return $this + */ + public function setRequestStreaming($var) + { + GPBUtil::checkBool($var); + $this->request_streaming = $var; + + return $this; + } + + /** + * The URL of the output message type. + * + * Generated from protobuf field string response_type_url = 4; + * @return string + */ + public function getResponseTypeUrl() + { + return $this->response_type_url; + } + + /** + * The URL of the output message type. + * + * Generated from protobuf field string response_type_url = 4; + * @param string $var + * @return $this + */ + public function setResponseTypeUrl($var) + { + GPBUtil::checkString($var, True); + $this->response_type_url = $var; + + return $this; + } + + /** + * If true, the response is streamed. + * + * Generated from protobuf field bool response_streaming = 5; + * @return bool + */ + public function getResponseStreaming() + { + return $this->response_streaming; + } + + /** + * If true, the response is streamed. + * + * Generated from protobuf field bool response_streaming = 5; + * @param bool $var + * @return $this + */ + public function setResponseStreaming($var) + { + GPBUtil::checkBool($var); + $this->response_streaming = $var; + + return $this; + } + + /** + * Any metadata attached to the method. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 6; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOptions() + { + return $this->options; + } + + /** + * Any metadata attached to the method. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 6; + * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOptions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class); + $this->options = $arr; + + return $this; + } + + /** + * The source syntax of this method. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 7; + * @return int + */ + public function getSyntax() + { + return $this->syntax; + } + + /** + * The source syntax of this method. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 7; + * @param int $var + * @return $this + */ + public function setSyntax($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Syntax::class); + $this->syntax = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/Mixin.php b/php/src/Google/Protobuf/Mixin.php new file mode 100644 index 00000000..eb5117e0 --- /dev/null +++ b/php/src/Google/Protobuf/Mixin.php @@ -0,0 +1,153 @@ +google.protobuf.Mixin + */ +class Mixin extends \Google\Protobuf\Internal\Message +{ + /** + * The fully qualified name of the interface which is included. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * If non-empty specifies a path under which inherited HTTP paths + * are rooted. + * + * Generated from protobuf field string root = 2; + */ + private $root = ''; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Api::initOnce(); + parent::__construct(); + } + + /** + * The fully qualified name of the interface which is included. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The fully qualified name of the interface which is included. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * If non-empty specifies a path under which inherited HTTP paths + * are rooted. + * + * Generated from protobuf field string root = 2; + * @return string + */ + public function getRoot() + { + return $this->root; + } + + /** + * If non-empty specifies a path under which inherited HTTP paths + * are rooted. + * + * Generated from protobuf field string root = 2; + * @param string $var + * @return $this + */ + public function setRoot($var) + { + GPBUtil::checkString($var, True); + $this->root = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/NullValue.php b/php/src/Google/Protobuf/NullValue.php new file mode 100644 index 00000000..d4022ccc --- /dev/null +++ b/php/src/Google/Protobuf/NullValue.php @@ -0,0 +1,23 @@ +Google\Protobuf\NullValue + */ +class NullValue +{ + /** + * Null value. + * + * Generated from protobuf enum NULL_VALUE = 0; + */ + const NULL_VALUE = 0; +} + diff --git a/php/src/Google/Protobuf/Option.php b/php/src/Google/Protobuf/Option.php new file mode 100644 index 00000000..f8038681 --- /dev/null +++ b/php/src/Google/Protobuf/Option.php @@ -0,0 +1,108 @@ +google.protobuf.Option + */ +class Option extends \Google\Protobuf\Internal\Message +{ + /** + * The option's name. For protobuf built-in options (options defined in + * descriptor.proto), this is the short name. For example, `"map_entry"`. + * For custom options, it should be the fully-qualified name. For example, + * `"google.api.http"`. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * The option's value packed in an Any message. If the value is a primitive, + * the corresponding wrapper type defined in google/protobuf/wrappers.proto + * should be used. If the value is an enum, it should be stored as an int32 + * value using the google.protobuf.Int32Value type. + * + * Generated from protobuf field .google.protobuf.Any value = 2; + */ + private $value = null; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Type::initOnce(); + parent::__construct(); + } + + /** + * The option's name. For protobuf built-in options (options defined in + * descriptor.proto), this is the short name. For example, `"map_entry"`. + * For custom options, it should be the fully-qualified name. For example, + * `"google.api.http"`. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The option's name. For protobuf built-in options (options defined in + * descriptor.proto), this is the short name. For example, `"map_entry"`. + * For custom options, it should be the fully-qualified name. For example, + * `"google.api.http"`. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The option's value packed in an Any message. If the value is a primitive, + * the corresponding wrapper type defined in google/protobuf/wrappers.proto + * should be used. If the value is an enum, it should be stored as an int32 + * value using the google.protobuf.Int32Value type. + * + * Generated from protobuf field .google.protobuf.Any value = 2; + * @return \Google\Protobuf\Any + */ + public function getValue() + { + return $this->value; + } + + /** + * The option's value packed in an Any message. If the value is a primitive, + * the corresponding wrapper type defined in google/protobuf/wrappers.proto + * should be used. If the value is an enum, it should be stored as an int32 + * value using the google.protobuf.Int32Value type. + * + * Generated from protobuf field .google.protobuf.Any value = 2; + * @param \Google\Protobuf\Any $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Any::class); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/SourceContext.php b/php/src/Google/Protobuf/SourceContext.php new file mode 100644 index 00000000..07d90c68 --- /dev/null +++ b/php/src/Google/Protobuf/SourceContext.php @@ -0,0 +1,61 @@ +google.protobuf.SourceContext + */ +class SourceContext extends \Google\Protobuf\Internal\Message +{ + /** + * The path-qualified name of the .proto file that contained the associated + * protobuf element. For example: `"google/protobuf/source_context.proto"`. + * + * Generated from protobuf field string file_name = 1; + */ + private $file_name = ''; + + public function __construct() { + \GPBMetadata\Google\Protobuf\SourceContext::initOnce(); + parent::__construct(); + } + + /** + * The path-qualified name of the .proto file that contained the associated + * protobuf element. For example: `"google/protobuf/source_context.proto"`. + * + * Generated from protobuf field string file_name = 1; + * @return string + */ + public function getFileName() + { + return $this->file_name; + } + + /** + * The path-qualified name of the .proto file that contained the associated + * protobuf element. For example: `"google/protobuf/source_context.proto"`. + * + * Generated from protobuf field string file_name = 1; + * @param string $var + * @return $this + */ + public function setFileName($var) + { + GPBUtil::checkString($var, True); + $this->file_name = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/StringValue.php b/php/src/Google/Protobuf/StringValue.php new file mode 100644 index 00000000..f6bcc48a --- /dev/null +++ b/php/src/Google/Protobuf/StringValue.php @@ -0,0 +1,58 @@ +google.protobuf.StringValue + */ +class StringValue extends \Google\Protobuf\Internal\Message +{ + /** + * The string value. + * + * Generated from protobuf field string value = 1; + */ + private $value = ''; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Wrappers::initOnce(); + parent::__construct(); + } + + /** + * The string value. + * + * Generated from protobuf field string value = 1; + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * The string value. + * + * Generated from protobuf field string value = 1; + * @param string $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkString($var, True); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/Struct.php b/php/src/Google/Protobuf/Struct.php new file mode 100644 index 00000000..721e991c --- /dev/null +++ b/php/src/Google/Protobuf/Struct.php @@ -0,0 +1,63 @@ +google.protobuf.Struct + */ +class Struct extends \Google\Protobuf\Internal\Message +{ + /** + * Unordered map of dynamically typed values. + * + * Generated from protobuf field map fields = 1; + */ + private $fields; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Struct::initOnce(); + parent::__construct(); + } + + /** + * Unordered map of dynamically typed values. + * + * Generated from protobuf field map fields = 1; + * @return \Google\Protobuf\Internal\MapField + */ + public function getFields() + { + return $this->fields; + } + + /** + * Unordered map of dynamically typed values. + * + * Generated from protobuf field map fields = 1; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setFields($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class); + $this->fields = $arr; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/Syntax.php b/php/src/Google/Protobuf/Syntax.php new file mode 100644 index 00000000..bb7b7896 --- /dev/null +++ b/php/src/Google/Protobuf/Syntax.php @@ -0,0 +1,27 @@ +Google\Protobuf\Syntax + */ +class Syntax +{ + /** + * Syntax `proto2`. + * + * Generated from protobuf enum SYNTAX_PROTO2 = 0; + */ + const SYNTAX_PROTO2 = 0; + /** + * Syntax `proto3`. + * + * Generated from protobuf enum SYNTAX_PROTO3 = 1; + */ + const SYNTAX_PROTO3 = 1; +} + diff --git a/php/src/Google/Protobuf/Type.php b/php/src/Google/Protobuf/Type.php new file mode 100644 index 00000000..7dbe2cab --- /dev/null +++ b/php/src/Google/Protobuf/Type.php @@ -0,0 +1,217 @@ +google.protobuf.Type + */ +class Type extends \Google\Protobuf\Internal\Message +{ + /** + * The fully qualified message name. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * The list of fields. + * + * Generated from protobuf field repeated .google.protobuf.Field fields = 2; + */ + private $fields; + /** + * The list of types appearing in `oneof` definitions in this type. + * + * Generated from protobuf field repeated string oneofs = 3; + */ + private $oneofs; + /** + * The protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 4; + */ + private $options; + /** + * The source context. + * + * Generated from protobuf field .google.protobuf.SourceContext source_context = 5; + */ + private $source_context = null; + /** + * The source syntax. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 6; + */ + private $syntax = 0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Type::initOnce(); + parent::__construct(); + } + + /** + * The fully qualified message name. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The fully qualified message name. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The list of fields. + * + * Generated from protobuf field repeated .google.protobuf.Field fields = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getFields() + { + return $this->fields; + } + + /** + * The list of fields. + * + * Generated from protobuf field repeated .google.protobuf.Field fields = 2; + * @param \Google\Protobuf\Field[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setFields($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Field::class); + $this->fields = $arr; + + return $this; + } + + /** + * The list of types appearing in `oneof` definitions in this type. + * + * Generated from protobuf field repeated string oneofs = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOneofs() + { + return $this->oneofs; + } + + /** + * The list of types appearing in `oneof` definitions in this type. + * + * Generated from protobuf field repeated string oneofs = 3; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOneofs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->oneofs = $arr; + + return $this; + } + + /** + * The protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 4; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOptions() + { + return $this->options; + } + + /** + * The protocol buffer options. + * + * Generated from protobuf field repeated .google.protobuf.Option options = 4; + * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOptions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class); + $this->options = $arr; + + return $this; + } + + /** + * The source context. + * + * Generated from protobuf field .google.protobuf.SourceContext source_context = 5; + * @return \Google\Protobuf\SourceContext + */ + public function getSourceContext() + { + return $this->source_context; + } + + /** + * The source context. + * + * Generated from protobuf field .google.protobuf.SourceContext source_context = 5; + * @param \Google\Protobuf\SourceContext $var + * @return $this + */ + public function setSourceContext($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\SourceContext::class); + $this->source_context = $var; + + return $this; + } + + /** + * The source syntax. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 6; + * @return int + */ + public function getSyntax() + { + return $this->syntax; + } + + /** + * The source syntax. + * + * Generated from protobuf field .google.protobuf.Syntax syntax = 6; + * @param int $var + * @return $this + */ + public function setSyntax($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Syntax::class); + $this->syntax = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/UInt32Value.php b/php/src/Google/Protobuf/UInt32Value.php new file mode 100644 index 00000000..61a3ddf1 --- /dev/null +++ b/php/src/Google/Protobuf/UInt32Value.php @@ -0,0 +1,58 @@ +google.protobuf.UInt32Value + */ +class UInt32Value extends \Google\Protobuf\Internal\Message +{ + /** + * The uint32 value. + * + * Generated from protobuf field uint32 value = 1; + */ + private $value = 0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Wrappers::initOnce(); + parent::__construct(); + } + + /** + * The uint32 value. + * + * Generated from protobuf field uint32 value = 1; + * @return int + */ + public function getValue() + { + return $this->value; + } + + /** + * The uint32 value. + * + * Generated from protobuf field uint32 value = 1; + * @param int $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkUint32($var); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/UInt64Value.php b/php/src/Google/Protobuf/UInt64Value.php new file mode 100644 index 00000000..69f7eb8e --- /dev/null +++ b/php/src/Google/Protobuf/UInt64Value.php @@ -0,0 +1,58 @@ +google.protobuf.UInt64Value + */ +class UInt64Value extends \Google\Protobuf\Internal\Message +{ + /** + * The uint64 value. + * + * Generated from protobuf field uint64 value = 1; + */ + private $value = 0; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Wrappers::initOnce(); + parent::__construct(); + } + + /** + * The uint64 value. + * + * Generated from protobuf field uint64 value = 1; + * @return int|string + */ + public function getValue() + { + return $this->value; + } + + /** + * The uint64 value. + * + * Generated from protobuf field uint64 value = 1; + * @param int|string $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkUint64($var); + $this->value = $var; + + return $this; + } + +} + diff --git a/php/src/Google/Protobuf/Value.php b/php/src/Google/Protobuf/Value.php new file mode 100644 index 00000000..052a3779 --- /dev/null +++ b/php/src/Google/Protobuf/Value.php @@ -0,0 +1,194 @@ +google.protobuf.Value + */ +class Value extends \Google\Protobuf\Internal\Message +{ + protected $kind; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Struct::initOnce(); + parent::__construct(); + } + + /** + * Represents a null value. + * + * Generated from protobuf field .google.protobuf.NullValue null_value = 1; + * @return int + */ + public function getNullValue() + { + return $this->readOneof(1); + } + + /** + * Represents a null value. + * + * Generated from protobuf field .google.protobuf.NullValue null_value = 1; + * @param int $var + * @return $this + */ + public function setNullValue($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\NullValue::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Represents a double value. + * + * Generated from protobuf field double number_value = 2; + * @return float + */ + public function getNumberValue() + { + return $this->readOneof(2); + } + + /** + * Represents a double value. + * + * Generated from protobuf field double number_value = 2; + * @param float $var + * @return $this + */ + public function setNumberValue($var) + { + GPBUtil::checkDouble($var); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Represents a string value. + * + * Generated from protobuf field string string_value = 3; + * @return string + */ + public function getStringValue() + { + return $this->readOneof(3); + } + + /** + * Represents a string value. + * + * Generated from protobuf field string string_value = 3; + * @param string $var + * @return $this + */ + public function setStringValue($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Represents a boolean value. + * + * Generated from protobuf field bool bool_value = 4; + * @return bool + */ + public function getBoolValue() + { + return $this->readOneof(4); + } + + /** + * Represents a boolean value. + * + * Generated from protobuf field bool bool_value = 4; + * @param bool $var + * @return $this + */ + public function setBoolValue($var) + { + GPBUtil::checkBool($var); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * Represents a structured value. + * + * Generated from protobuf field .google.protobuf.Struct struct_value = 5; + * @return \Google\Protobuf\Struct + */ + public function getStructValue() + { + return $this->readOneof(5); + } + + /** + * Represents a structured value. + * + * Generated from protobuf field .google.protobuf.Struct struct_value = 5; + * @param \Google\Protobuf\Struct $var + * @return $this + */ + public function setStructValue($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class); + $this->writeOneof(5, $var); + + return $this; + } + + /** + * Represents a repeated `Value`. + * + * Generated from protobuf field .google.protobuf.ListValue list_value = 6; + * @return \Google\Protobuf\ListValue + */ + public function getListValue() + { + return $this->readOneof(6); + } + + /** + * Represents a repeated `Value`. + * + * Generated from protobuf field .google.protobuf.ListValue list_value = 6; + * @param \Google\Protobuf\ListValue $var + * @return $this + */ + public function setListValue($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\ListValue::class); + $this->writeOneof(6, $var); + + return $this; + } + + /** + * @return string + */ + public function getKind() + { + return $this->whichOneof("kind"); + } + +} + diff --git a/php/tests/compatibility_test.sh b/php/tests/compatibility_test.sh index 6f1e4900..7caa46e7 100755 --- a/php/tests/compatibility_test.sh +++ b/php/tests/compatibility_test.sh @@ -20,7 +20,6 @@ function generate_proto() { $PROTOC1 --php_out=generated proto/test_include.proto $PROTOC2 --php_out=generated proto/test.proto proto/test_no_namespace.proto proto/test_prefix.proto pushd ../../src - $PROTOC2 --php_out=../php/tests/generated google/protobuf/empty.proto $PROTOC2 --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto popd } diff --git a/php/tests/well_known_test.php b/php/tests/well_known_test.php index 690ce5f5..a7760685 100644 --- a/php/tests/well_known_test.php +++ b/php/tests/well_known_test.php @@ -3,18 +3,43 @@ require_once('test_base.php'); require_once('test_util.php'); -use Google\Protobuf\GPBEmpty; +use Foo\TestMessage; use Google\Protobuf\Any; +use Google\Protobuf\Api; +use Google\Protobuf\BoolValue; +use Google\Protobuf\BytesValue; +use Google\Protobuf\DoubleValue; use Google\Protobuf\Duration; +use Google\Protobuf\Enum; +use Google\Protobuf\EnumValue; +use Google\Protobuf\Field; +use Google\Protobuf\FieldMask; +use Google\Protobuf\Field_Cardinality; +use Google\Protobuf\Field_Kind; +use Google\Protobuf\FloatValue; +use Google\Protobuf\GPBEmpty; +use Google\Protobuf\Int32Value; +use Google\Protobuf\Int64Value; +use Google\Protobuf\ListValue; +use Google\Protobuf\Method; +use Google\Protobuf\Mixin; +use Google\Protobuf\NullValue; +use Google\Protobuf\Option; +use Google\Protobuf\SourceContext; +use Google\Protobuf\StringValue; +use Google\Protobuf\Struct; +use Google\Protobuf\Syntax; use Google\Protobuf\Timestamp; - -use Foo\TestMessage; +use Google\Protobuf\Type; +use Google\Protobuf\UInt32Value; +use Google\Protobuf\UInt64Value; +use Google\Protobuf\Value; class NotMessage {} class WellKnownTest extends TestBase { - public function testNone() + public function testEmpty() { $msg = new GPBEmpty(); } @@ -89,6 +114,191 @@ class WellKnownTest extends TestBase { $any->unpack(); } + public function testApi() + { + $m = new Api(); + + $m->setName("a"); + $this->assertSame("a", $m->getName()); + + $m->setMethods([new Method()]); + $this->assertSame(1, count($m->getMethods())); + + $m->setOptions([new Option()]); + $this->assertSame(1, count($m->getOptions())); + + $m->setVersion("a"); + $this->assertSame("a", $m->getVersion()); + + $m->setSourceContext(new SourceContext()); + $this->assertFalse(is_null($m->getSourceContext())); + + $m->setMixins([new Mixin()]); + $this->assertSame(1, count($m->getMixins())); + + $m->setSyntax(Syntax::SYNTAX_PROTO2); + $this->assertSame(Syntax::SYNTAX_PROTO2, $m->getSyntax()); + + $m = new Method(); + + $m->setName("a"); + $this->assertSame("a", $m->getName()); + + $m->setRequestTypeUrl("a"); + $this->assertSame("a", $m->getRequestTypeUrl()); + + $m->setRequestStreaming(true); + $this->assertSame(true, $m->getRequestStreaming()); + + $m->setResponseTypeUrl("a"); + $this->assertSame("a", $m->getResponseTypeUrl()); + + $m->setResponseStreaming(true); + $this->assertSame(true, $m->getResponseStreaming()); + + $m->setOptions([new Option()]); + $this->assertSame(1, count($m->getOptions())); + + $m = new Mixin(); + + $m->setName("a"); + $this->assertSame("a", $m->getName()); + + $m->setRoot("a"); + $this->assertSame("a", $m->getRoot()); + } + + public function testEnum() + { + $m = new Enum(); + + $m->setName("a"); + $this->assertSame("a", $m->getName()); + + $m->setEnumvalue([new EnumValue()]); + $this->assertSame(1, count($m->getEnumvalue())); + + $m->setOptions([new Option()]); + $this->assertSame(1, count($m->getOptions())); + + $m->setSourceContext(new SourceContext()); + $this->assertFalse(is_null($m->getSourceContext())); + + $m->setSyntax(Syntax::SYNTAX_PROTO2); + $this->assertSame(Syntax::SYNTAX_PROTO2, $m->getSyntax()); + } + + public function testEnumValue() + { + $m = new EnumValue(); + + $m->setName("a"); + $this->assertSame("a", $m->getName()); + + $m->setNumber(1); + $this->assertSame(1, $m->getNumber()); + + $m->setOptions([new Option()]); + $this->assertSame(1, count($m->getOptions())); + } + + public function testField() + { + $m = new Field(); + + $m->setKind(Field_Kind::TYPE_DOUBLE); + $this->assertSame(Field_Kind::TYPE_DOUBLE, $m->getKind()); + + $m->setCardinality(Field_Cardinality::CARDINALITY_OPTIONAL); + $this->assertSame(Field_Cardinality::CARDINALITY_OPTIONAL, $m->getCardinality()); + + $m->setNumber(1); + $this->assertSame(1, $m->getNumber()); + + $m->setName("a"); + $this->assertSame("a", $m->getName()); + + $m->setTypeUrl("a"); + $this->assertSame("a", $m->getTypeUrl()); + + $m->setOneofIndex(1); + $this->assertSame(1, $m->getOneofIndex()); + + $m->setPacked(true); + $this->assertSame(true, $m->getPacked()); + + $m->setOptions([new Option()]); + $this->assertSame(1, count($m->getOptions())); + + $m->setJsonName("a"); + $this->assertSame("a", $m->getJsonName()); + + $m->setDefaultValue("a"); + $this->assertSame("a", $m->getDefaultValue()); + } + + public function testFieldMask() + { + $m = new FieldMask(); + $m->setPaths(["a"]); + $this->assertSame(1, count($m->getPaths())); + } + + public function testOption() + { + $m = new Option(); + + $m->setName("a"); + $this->assertSame("a", $m->getName()); + + $m->setValue(new Any()); + $this->assertFalse(is_null($m->getValue())); + } + + public function testSourceContext() + { + $m = new SourceContext(); + $m->setFileName("a"); + $this->assertSame("a", $m->getFileName()); + } + + public function testStruct() + { + $m = new ListValue(); + $m->setValues([new Value()]); + $this->assertSame(1, count($m->getValues())); + + $m = new Value(); + + $m->setNullValue(NullValue::NULL_VALUE); + $this->assertSame(NullValue::NULL_VALUE, $m->getNullValue()); + $this->assertSame("null_value", $m->getKind()); + + $m->setNumberValue(1.0); + $this->assertSame(1.0, $m->getNumberValue()); + $this->assertSame("number_value", $m->getKind()); + + $m->setStringValue("a"); + $this->assertSame("a", $m->getStringValue()); + $this->assertSame("string_value", $m->getKind()); + + $m->setBoolValue(true); + $this->assertSame(true, $m->getBoolValue()); + $this->assertSame("bool_value", $m->getKind()); + + $m->setStructValue(new Struct()); + $this->assertFalse(is_null($m->getStructValue())); + $this->assertSame("struct_value", $m->getKind()); + + $m->setListValue(new ListValue()); + $this->assertFalse(is_null($m->getListValue())); + $this->assertSame("list_value", $m->getKind()); + + $m = new Struct(); + $m->setFields(array("a"=>new Value())); + $this->assertSame(1, count($m->getFields())); + } + public function testTimestamp() { $timestamp = new Timestamp(); @@ -109,6 +319,29 @@ class WellKnownTest extends TestBase { $this->assertSame($from->format('U'), $to->format('U')); } + public function testType() + { + $m = new Type(); + + $m->setName("a"); + $this->assertSame("a", $m->getName()); + + $m->setFields([new Field()]); + $this->assertSame(1, count($m->getFields())); + + $m->setOneofs(["a"]); + $this->assertSame(1, count($m->getOneofs())); + + $m->setOptions([new Option()]); + $this->assertSame(1, count($m->getOptions())); + + $m->setSourceContext(new SourceContext()); + $this->assertFalse(is_null($m->getSourceContext())); + + $m->setSyntax(Syntax::SYNTAX_PROTO2); + $this->assertSame(Syntax::SYNTAX_PROTO2, $m->getSyntax()); + } + public function testDuration() { $duration = new Duration(); @@ -118,4 +351,43 @@ class WellKnownTest extends TestBase { $this->assertEquals(1, $duration->getSeconds()); $this->assertSame(2, $duration->getNanos()); } + + public function testWrappers() + { + $m = new DoubleValue(); + $m->setValue(1.0); + $this->assertSame(1.0, $m->getValue()); + + $m = new FloatValue(); + $m->setValue(1.0); + $this->assertSame(1.0, $m->getValue()); + + $m = new Int64Value(); + $m->setValue(1); + $this->assertEquals(1, $m->getValue()); + + $m = new UInt64Value(); + $m->setValue(1); + $this->assertEquals(1, $m->getValue()); + + $m = new Int32Value(); + $m->setValue(1); + $this->assertSame(1, $m->getValue()); + + $m = new UInt32Value(); + $m->setValue(1); + $this->assertSame(1, $m->getValue()); + + $m = new BoolValue(); + $m->setValue(true); + $this->assertSame(true, $m->getValue()); + + $m = new StringValue(); + $m->setValue("a"); + $this->assertSame("a", $m->getValue()); + + $m = new BytesValue(); + $m->setValue("a"); + $this->assertSame("a", $m->getValue()); + } } diff --git a/tests.sh b/tests.sh index 689b8913..3d0a6d22 100755 --- a/tests.sh +++ b/tests.sh @@ -358,7 +358,6 @@ generate_php_test_proto() { proto/test_service_namespace.proto \ proto/test_descriptors.proto pushd ../../src - ./protoc --php_out=../php/tests/generated google/protobuf/empty.proto ./protoc --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto popd popd -- cgit v1.2.3