From a0eef68bbdeca5e7f9afa1701ad3ca83e0020611 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 29 Sep 2020 15:47:47 -0700 Subject: [PATCH 01/12] Regenerated well-known types and moved hand-written messages into base classes. --- php/src/GPBMetadata/Google/Protobuf/Any.php | 10 +- php/src/GPBMetadata/Google/Protobuf/Api.php | 27 +---- .../GPBMetadata/Google/Protobuf/Duration.php | 11 +- .../GPBMetadata/Google/Protobuf/FieldMask.php | 11 +- .../GPBMetadata/Google/Protobuf/GPBEmpty.php | 10 +- .../Google/Protobuf/SourceContext.php | 12 +-- .../GPBMetadata/Google/Protobuf/Struct.php | 2 +- .../GPBMetadata/Google/Protobuf/Timestamp.php | 11 +- php/src/GPBMetadata/Google/Protobuf/Type.php | 56 +--------- .../GPBMetadata/Google/Protobuf/Wrappers.php | 18 +--- php/src/Google/Protobuf/Any.php | 101 +++--------------- php/src/Google/Protobuf/Api.php | 20 +++- php/src/Google/Protobuf/BoolValue.php | 2 +- php/src/Google/Protobuf/BytesValue.php | 2 +- php/src/Google/Protobuf/DoubleValue.php | 2 +- php/src/Google/Protobuf/Duration.php | 6 +- php/src/Google/Protobuf/Enum.php | 18 +++- php/src/Google/Protobuf/EnumValue.php | 4 +- php/src/Google/Protobuf/Field.php | 22 ++-- php/src/Google/Protobuf/Field/Cardinality.php | 1 + php/src/Google/Protobuf/Field/Kind.php | 1 + php/src/Google/Protobuf/FieldMask.php | 42 ++++---- php/src/Google/Protobuf/FloatValue.php | 2 +- php/src/Google/Protobuf/Int32Value.php | 2 +- php/src/Google/Protobuf/Int64Value.php | 2 +- php/src/Google/Protobuf/Method.php | 12 +-- php/src/Google/Protobuf/Mixin.php | 4 +- php/src/Google/Protobuf/Option.php | 16 ++- php/src/Google/Protobuf/SourceContext.php | 2 +- php/src/Google/Protobuf/StringValue.php | 2 +- php/src/Google/Protobuf/Syntax.php | 1 + php/src/Google/Protobuf/Timestamp.php | 68 +++++------- php/src/Google/Protobuf/Type.php | 18 +++- php/src/Google/Protobuf/UInt32Value.php | 2 +- php/src/Google/Protobuf/UInt64Value.php | 2 +- .../protobuf/compiler/php/php_generator.cc | 17 ++- 36 files changed, 189 insertions(+), 350 deletions(-) diff --git a/php/src/GPBMetadata/Google/Protobuf/Any.php b/php/src/GPBMetadata/Google/Protobuf/Any.php index 22cc25008fc8..c786a9462e8b 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Any.php +++ b/php/src/GPBMetadata/Google/Protobuf/Any.php @@ -15,14 +15,8 @@ public static function initOnce() { return; } $pool->internalAddGeneratedFile(hex2bin( - "0acd010a19676f6f676c652f70726f746f6275662f616e792e70726f746f" . - "120f676f6f676c652e70726f746f62756622260a03416e7912100a087479" . - "70655f75726c180120012809120d0a0576616c756518022001280c426f0a" . - "13636f6d2e676f6f676c652e70726f746f6275664208416e7950726f746f" . - "50015a256769746875622e636f6d2f676f6c616e672f70726f746f627566" . - "2f7074797065732f616e79a20203475042aa021e476f6f676c652e50726f" . - "746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" - )); + "0ad4010a19676f6f676c652f70726f746f6275662f616e792e70726f746f120f676f6f676c652e70726f746f62756622260a03416e7912100a08747970655f75726c180120012809120d0a0576616c756518022001280c42760a13636f6d2e676f6f676c652e70726f746f6275664208416e7950726f746f50015a2c676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f616e797062a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + ), true); static::$is_initialized = true; } diff --git a/php/src/GPBMetadata/Google/Protobuf/Api.php b/php/src/GPBMetadata/Google/Protobuf/Api.php index b18e0d33ac03..3791a1c97e15 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Api.php +++ b/php/src/GPBMetadata/Google/Protobuf/Api.php @@ -17,31 +17,8 @@ public static function initOnce() { \GPBMetadata\Google\Protobuf\SourceContext::initOnce(); \GPBMetadata\Google\Protobuf\Type::initOnce(); $pool->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" - )); + "0ac9050a19676f6f676c652f70726f746f6275662f6170692e70726f746f120f676f6f676c652e70726f746f6275661a1a676f6f676c652f70726f746f6275662f747970652e70726f746f2281020a03417069120c0a046e616d6518012001280912280a076d6574686f647318022003280b32172e676f6f676c652e70726f746f6275662e4d6574686f6412280a076f7074696f6e7318032003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e120f0a0776657273696f6e18042001280912360a0e736f757263655f636f6e7465787418052001280b321e2e676f6f676c652e70726f746f6275662e536f75726365436f6e7465787412260a066d6978696e7318062003280b32162e676f6f676c652e70726f746f6275662e4d6978696e12270a0673796e74617818072001280e32172e676f6f676c652e70726f746f6275662e53796e74617822d5010a064d6574686f64120c0a046e616d6518012001280912180a10726571756573745f747970655f75726c18022001280912190a11726571756573745f73747265616d696e6718032001280812190a11726573706f6e73655f747970655f75726c180420012809121a0a12726573706f6e73655f73747265616d696e6718052001280812280a076f7074696f6e7318062003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e12270a0673796e74617818072001280e32172e676f6f676c652e70726f746f6275662e53796e74617822230a054d6978696e120c0a046e616d65180120012809120c0a04726f6f7418022001280942760a13636f6d2e676f6f676c652e70726f746f627566420841706950726f746f50015a2c676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f6170697062a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + ), true); static::$is_initialized = true; } diff --git a/php/src/GPBMetadata/Google/Protobuf/Duration.php b/php/src/GPBMetadata/Google/Protobuf/Duration.php index b1c85ad8894e..7d15906b022b 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Duration.php +++ b/php/src/GPBMetadata/Google/Protobuf/Duration.php @@ -15,15 +15,8 @@ public static function initOnce() { return; } $pool->internalAddGeneratedFile(hex2bin( - "0ae3010a1e676f6f676c652f70726f746f6275662f6475726174696f6e2e" . - "70726f746f120f676f6f676c652e70726f746f627566222a0a0844757261" . - "74696f6e120f0a077365636f6e6473180120012803120d0a056e616e6f73" . - "180220012805427c0a13636f6d2e676f6f676c652e70726f746f62756642" . - "0d4475726174696f6e50726f746f50015a2a6769746875622e636f6d2f67" . - "6f6c616e672f70726f746f6275662f7074797065732f6475726174696f6e" . - "f80101a20203475042aa021e476f6f676c652e50726f746f6275662e5765" . - "6c6c4b6e6f776e5479706573620670726f746f33" - )); + "0aeb010a1e676f6f676c652f70726f746f6275662f6475726174696f6e2e70726f746f120f676f6f676c652e70726f746f627566222a0a084475726174696f6e120f0a077365636f6e6473180120012803120d0a056e616e6f731802200128054283010a13636f6d2e676f6f676c652e70726f746f627566420d4475726174696f6e50726f746f50015a31676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f6475726174696f6e7062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + ), true); static::$is_initialized = true; } diff --git a/php/src/GPBMetadata/Google/Protobuf/FieldMask.php b/php/src/GPBMetadata/Google/Protobuf/FieldMask.php index 5812be1e2447..656fc212d881 100644 --- a/php/src/GPBMetadata/Google/Protobuf/FieldMask.php +++ b/php/src/GPBMetadata/Google/Protobuf/FieldMask.php @@ -15,15 +15,8 @@ public static function initOnce() { return; } $pool->internalAddGeneratedFile(hex2bin( - "0ae3010a20676f6f676c652f70726f746f6275662f6669656c645f6d6173" . - "6b2e70726f746f120f676f6f676c652e70726f746f627566221a0a094669" . - "656c644d61736b120d0a0570617468731801200328094289010a13636f6d" . - "2e676f6f676c652e70726f746f627566420e4669656c644d61736b50726f" . - "746f50015a39676f6f676c652e676f6c616e672e6f72672f67656e70726f" . - "746f2f70726f746f6275662f6669656c645f6d61736b3b6669656c645f6d" . - "61736ba20203475042aa021e476f6f676c652e50726f746f6275662e5765" . - "6c6c4b6e6f776e5479706573620670726f746f33" - )); + "0adf010a20676f6f676c652f70726f746f6275662f6669656c645f6d61736b2e70726f746f120f676f6f676c652e70726f746f627566221a0a094669656c644d61736b120d0a0570617468731801200328094285010a13636f6d2e676f6f676c652e70726f746f627566420e4669656c644d61736b50726f746f50015a32676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f6669656c646d61736b7062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + ), true); static::$is_initialized = true; } diff --git a/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php b/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php index 88f42a11a462..936bac2cc89c 100644 --- a/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php +++ b/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php @@ -15,14 +15,8 @@ public static function initOnce() { return; } $pool->internalAddGeneratedFile(hex2bin( - "0ab7010a1b676f6f676c652f70726f746f6275662f656d7074792e70726f" . - "746f120f676f6f676c652e70726f746f62756622070a05456d7074794276" . - "0a13636f6d2e676f6f676c652e70726f746f627566420a456d7074795072" . - "6f746f50015a276769746875622e636f6d2f676f6c616e672f70726f746f" . - "6275662f7074797065732f656d707479f80101a20203475042aa021e476f" . - "6f676c652e50726f746f6275662e57656c6c4b6e6f776e54797065736206" . - "70726f746f33" - )); + "0abe010a1b676f6f676c652f70726f746f6275662f656d7074792e70726f746f120f676f6f676c652e70726f746f62756622070a05456d707479427d0a13636f6d2e676f6f676c652e70726f746f627566420a456d70747950726f746f50015a2e676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f656d7074797062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + ), true); static::$is_initialized = true; } diff --git a/php/src/GPBMetadata/Google/Protobuf/SourceContext.php b/php/src/GPBMetadata/Google/Protobuf/SourceContext.php index 495c6de410ec..edf743d2f44a 100644 --- a/php/src/GPBMetadata/Google/Protobuf/SourceContext.php +++ b/php/src/GPBMetadata/Google/Protobuf/SourceContext.php @@ -15,16 +15,8 @@ public static function initOnce() { return; } $pool->internalAddGeneratedFile(hex2bin( - "0afb010a24676f6f676c652f70726f746f6275662f736f757263655f636f" . - "6e746578742e70726f746f120f676f6f676c652e70726f746f6275662222" . - "0a0d536f75726365436f6e7465787412110a0966696c655f6e616d651801" . - "200128094295010a13636f6d2e676f6f676c652e70726f746f6275664212" . - "536f75726365436f6e7465787450726f746f50015a41676f6f676c652e67" . - "6f6c616e672e6f72672f67656e70726f746f2f70726f746f6275662f736f" . - "757263655f636f6e746578743b736f757263655f636f6e74657874a20203" . - "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77" . - "6e5479706573620670726f746f33" - )); + "0af0010a24676f6f676c652f70726f746f6275662f736f757263655f636f6e746578742e70726f746f120f676f6f676c652e70726f746f62756622220a0d536f75726365436f6e7465787412110a0966696c655f6e616d65180120012809428a010a13636f6d2e676f6f676c652e70726f746f6275664212536f75726365436f6e7465787450726f746f50015a36676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f736f75726365636f6e746578747062a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + ), true); static::$is_initialized = true; } diff --git a/php/src/GPBMetadata/Google/Protobuf/Struct.php b/php/src/GPBMetadata/Google/Protobuf/Struct.php index 8e6191dc7a26..4bfa63e2525e 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Struct.php +++ b/php/src/GPBMetadata/Google/Protobuf/Struct.php @@ -15,7 +15,7 @@ public static function initOnce() { return; } $pool->internalAddGeneratedFile(hex2bin( - "0a81050a1c676f6f676c652f70726f746f6275662f7374727563742e70726f746f120f676f6f676c652e70726f746f6275662284010a0653747275637412330a066669656c647318012003280b32232e676f6f676c652e70726f746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669656c6473456e747279120b0a036b657918012001280912250a0576616c756518022001280b32162e676f6f676c652e70726f746f6275662e56616c75653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c56616c7565480012160a0c6e756d6265725f76616c7565180220012801480012160a0c737472696e675f76616c7565180320012809480012140a0a626f6f6c5f76616c75651804200128084800122f0a0c7374727563745f76616c756518052001280b32172e676f6f676c652e70726f746f6275662e537472756374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f676c652e70726f746f6275662e4c69737456616c7565480042060a046b696e6422330a094c69737456616c756512260a0676616c75657318012003280b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e756c6c56616c7565120e0a0a4e554c4c5f56414c554510004281010a13636f6d2e676f6f676c652e70726f746f627566420b53747275637450726f746f50015a316769746875622e636f6d2f676f6c616e672f70726f746f6275662f7074797065732f7374727563743b7374727563747062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + "0afe040a1c676f6f676c652f70726f746f6275662f7374727563742e70726f746f120f676f6f676c652e70726f746f6275662284010a0653747275637412330a066669656c647318012003280b32232e676f6f676c652e70726f746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669656c6473456e747279120b0a036b657918012001280912250a0576616c756518022001280b32162e676f6f676c652e70726f746f6275662e56616c75653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c56616c7565480012160a0c6e756d6265725f76616c7565180220012801480012160a0c737472696e675f76616c7565180320012809480012140a0a626f6f6c5f76616c75651804200128084800122f0a0c7374727563745f76616c756518052001280b32172e676f6f676c652e70726f746f6275662e537472756374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f676c652e70726f746f6275662e4c69737456616c7565480042060a046b696e6422330a094c69737456616c756512260a0676616c75657318012003280b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e756c6c56616c7565120e0a0a4e554c4c5f56414c55451000427f0a13636f6d2e676f6f676c652e70726f746f627566420b53747275637450726f746f50015a2f676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f7374727563747062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" ), true); static::$is_initialized = true; diff --git a/php/src/GPBMetadata/Google/Protobuf/Timestamp.php b/php/src/GPBMetadata/Google/Protobuf/Timestamp.php index 373665c977c0..502be48e00fe 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Timestamp.php +++ b/php/src/GPBMetadata/Google/Protobuf/Timestamp.php @@ -15,15 +15,8 @@ public static function initOnce() { return; } $pool->internalAddGeneratedFile(hex2bin( - "0ae7010a1f676f6f676c652f70726f746f6275662f74696d657374616d70" . - "2e70726f746f120f676f6f676c652e70726f746f627566222b0a0954696d" . - "657374616d70120f0a077365636f6e6473180120012803120d0a056e616e" . - "6f73180220012805427e0a13636f6d2e676f6f676c652e70726f746f6275" . - "66420e54696d657374616d7050726f746f50015a2b6769746875622e636f" . - "6d2f676f6c616e672f70726f746f6275662f7074797065732f74696d6573" . - "74616d70f80101a20203475042aa021e476f6f676c652e50726f746f6275" . - "662e57656c6c4b6e6f776e5479706573620670726f746f33" - )); + "0aef010a1f676f6f676c652f70726f746f6275662f74696d657374616d702e70726f746f120f676f6f676c652e70726f746f627566222b0a0954696d657374616d70120f0a077365636f6e6473180120012803120d0a056e616e6f731802200128054285010a13636f6d2e676f6f676c652e70726f746f627566420e54696d657374616d7050726f746f50015a32676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f74696d657374616d707062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + ), true); static::$is_initialized = true; } diff --git a/php/src/GPBMetadata/Google/Protobuf/Type.php b/php/src/GPBMetadata/Google/Protobuf/Type.php index 8fbe8cbfe0d4..3e80a7fb452f 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Type.php +++ b/php/src/GPBMetadata/Google/Protobuf/Type.php @@ -17,60 +17,8 @@ public static function initOnce() { \GPBMetadata\Google\Protobuf\Any::initOnce(); \GPBMetadata\Google\Protobuf\SourceContext::initOnce(); $pool->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" - )); + "0a9d0c0a1a676f6f676c652f70726f746f6275662f747970652e70726f746f120f676f6f676c652e70726f746f6275661a24676f6f676c652f70726f746f6275662f736f757263655f636f6e746578742e70726f746f22d7010a0454797065120c0a046e616d6518012001280912260a066669656c647318022003280b32162e676f6f676c652e70726f746f6275662e4669656c64120e0a066f6e656f667318032003280912280a076f7074696f6e7318042003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e12360a0e736f757263655f636f6e7465787418052001280b321e2e676f6f676c652e70726f746f6275662e536f75726365436f6e7465787412270a0673796e74617818062001280e32172e676f6f676c652e70726f746f6275662e53796e74617822d5050a054669656c6412290a046b696e6418012001280e321b2e676f6f676c652e70726f746f6275662e4669656c642e4b696e6412370a0b63617264696e616c69747918022001280e32222e676f6f676c652e70726f746f6275662e4669656c642e43617264696e616c697479120e0a066e756d626572180320012805120c0a046e616d6518042001280912100a08747970655f75726c18062001280912130a0b6f6e656f665f696e646578180720012805120e0a067061636b656418082001280812280a076f7074696f6e7318092003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e12110a096a736f6e5f6e616d65180a2001280912150a0d64656661756c745f76616c7565180b2001280922c8020a044b696e6412100a0c545950455f554e4b4e4f574e1000120f0a0b545950455f444f55424c451001120e0a0a545950455f464c4f41541002120e0a0a545950455f494e5436341003120f0a0b545950455f55494e5436341004120e0a0a545950455f494e543332100512100a0c545950455f46495845443634100612100a0c545950455f464958454433321007120d0a09545950455f424f4f4c1008120f0a0b545950455f535452494e471009120e0a0a545950455f47524f5550100a12100a0c545950455f4d455353414745100b120e0a0a545950455f4259544553100c120f0a0b545950455f55494e543332100d120d0a09545950455f454e554d100e12110a0d545950455f5346495845443332100f12110a0d545950455f53464958454436341010120f0a0b545950455f53494e5433321011120f0a0b545950455f53494e543634101222740a0b43617264696e616c69747912170a1343415244494e414c4954595f554e4b4e4f574e100012180a1443415244494e414c4954595f4f5054494f4e414c100112180a1443415244494e414c4954595f5245515549524544100212180a1443415244494e414c4954595f5245504541544544100322ce010a04456e756d120c0a046e616d65180120012809122d0a09656e756d76616c756518022003280b321a2e676f6f676c652e70726f746f6275662e456e756d56616c756512280a076f7074696f6e7318032003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e12360a0e736f757263655f636f6e7465787418042001280b321e2e676f6f676c652e70726f746f6275662e536f75726365436f6e7465787412270a0673796e74617818052001280e32172e676f6f676c652e70726f746f6275662e53796e74617822530a09456e756d56616c7565120c0a046e616d65180120012809120e0a066e756d62657218022001280512280a076f7074696f6e7318032003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e223b0a064f7074696f6e120c0a046e616d6518012001280912230a0576616c756518022001280b32142e676f6f676c652e70726f746f6275662e416e792a2e0a0653796e74617812110a0d53594e5441585f50524f544f32100012110a0d53594e5441585f50524f544f331001427b0a13636f6d2e676f6f676c652e70726f746f62756642095479706550726f746f50015a2d676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f747970657062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + ), true); static::$is_initialized = true; } diff --git a/php/src/GPBMetadata/Google/Protobuf/Wrappers.php b/php/src/GPBMetadata/Google/Protobuf/Wrappers.php index dd72ff48ce0e..35c52e5cb51b 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Wrappers.php +++ b/php/src/GPBMetadata/Google/Protobuf/Wrappers.php @@ -15,22 +15,8 @@ public static function initOnce() { return; } $pool->internalAddGeneratedFile(hex2bin( - "0abf030a1e676f6f676c652f70726f746f6275662f77726170706572732e" . - "70726f746f120f676f6f676c652e70726f746f627566221c0a0b446f7562" . - "6c6556616c7565120d0a0576616c7565180120012801221b0a0a466c6f61" . - "7456616c7565120d0a0576616c7565180120012802221b0a0a496e743634" . - "56616c7565120d0a0576616c7565180120012803221c0a0b55496e743634" . - "56616c7565120d0a0576616c7565180120012804221b0a0a496e74333256" . - "616c7565120d0a0576616c7565180120012805221c0a0b55496e74333256" . - "616c7565120d0a0576616c756518012001280d221a0a09426f6f6c56616c" . - "7565120d0a0576616c7565180120012808221c0a0b537472696e6756616c" . - "7565120d0a0576616c7565180120012809221b0a0a427974657356616c75" . - "65120d0a0576616c756518012001280c427c0a13636f6d2e676f6f676c65" . - "2e70726f746f627566420d577261707065727350726f746f50015a2a6769" . - "746875622e636f6d2f676f6c616e672f70726f746f6275662f7074797065" . - "732f7772617070657273f80101a20203475042aa021e476f6f676c652e50" . - "726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" - )); + "0ac7030a1e676f6f676c652f70726f746f6275662f77726170706572732e70726f746f120f676f6f676c652e70726f746f627566221c0a0b446f75626c6556616c7565120d0a0576616c7565180120012801221b0a0a466c6f617456616c7565120d0a0576616c7565180120012802221b0a0a496e74363456616c7565120d0a0576616c7565180120012803221c0a0b55496e74363456616c7565120d0a0576616c7565180120012804221b0a0a496e74333256616c7565120d0a0576616c7565180120012805221c0a0b55496e74333256616c7565120d0a0576616c756518012001280d221a0a09426f6f6c56616c7565120d0a0576616c7565180120012808221c0a0b537472696e6756616c7565120d0a0576616c7565180120012809221b0a0a427974657356616c7565120d0a0576616c756518012001280c4283010a13636f6d2e676f6f676c652e70726f746f627566420d577261707065727350726f746f50015a31676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f77726170706572737062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33" + ), true); static::$is_initialized = true; } diff --git a/php/src/Google/Protobuf/Any.php b/php/src/Google/Protobuf/Any.php index 2c7bc7545403..8fdc3c483d22 100644 --- a/php/src/Google/Protobuf/Any.php +++ b/php/src/Google/Protobuf/Any.php @@ -5,7 +5,6 @@ namespace Google\Protobuf; use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\Message; use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; @@ -39,10 +38,13 @@ * ... * Example 4: Pack and unpack a message in Go * foo := &pb.Foo{...} - * any, err := ptypes.MarshalAny(foo) + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } * ... * foo := &pb.Foo{} - * if err := ptypes.UnmarshalAny(any, foo); err != nil { + * if err := any.UnmarshalTo(foo); err != nil { * ... * } * The pack methods provided by protobuf library will by default use @@ -76,11 +78,12 @@ * * Generated from protobuf message google.protobuf.Any */ -class Any extends \Google\Protobuf\Internal\Message +class Any extends \Google\Protobuf\Internal\AnyBase { /** * A URL/resource name that uniquely identifies the type of the serialized - * protocol buffer message. The last segment of the URL's path must represent + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent * the fully qualified name of the type (as in * `path/google.protobuf.Duration`). The name should be in a canonical form * (e.g., leading "." is not accepted). @@ -104,15 +107,13 @@ class Any extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string type_url = 1; */ - private $type_url = ''; + protected $type_url = ''; /** * Must be a valid serialized protocol buffer of the above specified type. * * Generated from protobuf field bytes value = 2; */ - private $value = ''; - - const TYPE_URL_PREFIX = 'type.googleapis.com/'; + protected $value = ''; /** * Constructor. @@ -122,7 +123,8 @@ class Any extends \Google\Protobuf\Internal\Message * * @type string $type_url * A URL/resource name that uniquely identifies the type of the serialized - * protocol buffer message. The last segment of the URL's path must represent + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent * the fully qualified name of the type (as in * `path/google.protobuf.Duration`). The name should be in a canonical form * (e.g., leading "." is not accepted). @@ -154,7 +156,8 @@ public function __construct($data = NULL) { /** * A URL/resource name that uniquely identifies the type of the serialized - * protocol buffer message. The last segment of the URL's path must represent + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent * the fully qualified name of the type (as in * `path/google.protobuf.Duration`). The name should be in a canonical form * (e.g., leading "." is not accepted). @@ -186,7 +189,8 @@ public function getTypeUrl() /** * A URL/resource name that uniquely identifies the type of the serialized - * protocol buffer message. The last segment of the URL's path must represent + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent * the fully qualified name of the type (as in * `path/google.protobuf.Duration`). The name should be in a canonical form * (e.g., leading "." is not accepted). @@ -246,78 +250,5 @@ public function setValue($var) return $this; } - /** - * This method will try to resolve the type_url in Any message to get the - * targeted message type. If failed, an error will be thrown. Otherwise, - * the method will create a message of the targeted type and fill it with - * the decoded value in Any. - * @return Message unpacked message - * @throws \Exception Type url needs to be type.googleapis.com/fully-qualified. - * @throws \Exception Class hasn't been added to descriptor pool. - * @throws \Exception cannot decode data in value field. - */ - public function unpack() - { - // Get fully qualified name from type url. - $url_prifix_len = strlen(GPBUtil::TYPE_URL_PREFIX); - if (substr($this->type_url, 0, $url_prifix_len) != - GPBUtil::TYPE_URL_PREFIX) { - throw new \Exception( - "Type url needs to be type.googleapis.com/fully-qulified"); - } - $fully_qualifed_name = - substr($this->type_url, $url_prifix_len); - - // Create message according to fully qualified name. - $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); - $desc = $pool->getDescriptorByProtoName($fully_qualifed_name); - if (is_null($desc)) { - throw new \Exception("Class ".$fully_qualifed_name - ." hasn't been added to descriptor pool"); - } - $klass = $desc->getClass(); - $msg = new $klass(); - - // Merge data into message. - $msg->mergeFromString($this->value); - return $msg; - } - - /** - * The type_url will be created according to the given message’s type and - * the value is encoded data from the given message.. - * @param message: A proto message. - */ - public function pack($msg) - { - if (!$msg instanceof Message) { - trigger_error("Given parameter is not a message instance.", - E_USER_ERROR); - return; - } - - // Set value using serialized message. - $this->value = $msg->serializeToString(); - - // Set type url. - $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); - $desc = $pool->getDescriptorByClassName(get_class($msg)); - $fully_qualifed_name = $desc->getFullName(); - $this->type_url = GPBUtil::TYPE_URL_PREFIX . $fully_qualifed_name; - } - - /** - * This method returns whether the type_url in any_message is corresponded - * to the given class. - * @param klass: The fully qualified PHP class name of a proto message type. - */ - public function is($klass) - { - $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); - $desc = $pool->getDescriptorByClassName($klass); - $fully_qualifed_name = $desc->getFullName(); - $type_url = GPBUtil::TYPE_URL_PREFIX . $fully_qualifed_name; - return $this->type_url === $type_url; - } } diff --git a/php/src/Google/Protobuf/Api.php b/php/src/Google/Protobuf/Api.php index db37ffb0194e..773397565c08 100644 --- a/php/src/Google/Protobuf/Api.php +++ b/php/src/Google/Protobuf/Api.php @@ -28,7 +28,7 @@ class Api extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The methods of this interface, in unspecified order. * @@ -62,14 +62,14 @@ class Api extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string version = 4; */ - private $version = ''; + protected $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; + protected $source_context = null; /** * Included interfaces. See [Mixin][]. * @@ -81,7 +81,7 @@ class Api extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Syntax syntax = 7; */ - private $syntax = 0; + protected $syntax = 0; /** * Constructor. @@ -275,7 +275,17 @@ public function setVersion($var) */ public function getSourceContext() { - return $this->source_context; + return isset($this->source_context) ? $this->source_context : null; + } + + public function hasSourceContext() + { + return isset($this->source_context); + } + + public function clearSourceContext() + { + unset($this->source_context); } /** diff --git a/php/src/Google/Protobuf/BoolValue.php b/php/src/Google/Protobuf/BoolValue.php index 13872eb1e464..ecdbf4dcc265 100644 --- a/php/src/Google/Protobuf/BoolValue.php +++ b/php/src/Google/Protobuf/BoolValue.php @@ -21,7 +21,7 @@ class BoolValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool value = 1; */ - private $value = false; + protected $value = false; /** * Constructor. diff --git a/php/src/Google/Protobuf/BytesValue.php b/php/src/Google/Protobuf/BytesValue.php index f1b381718564..1582e14acd90 100644 --- a/php/src/Google/Protobuf/BytesValue.php +++ b/php/src/Google/Protobuf/BytesValue.php @@ -21,7 +21,7 @@ class BytesValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes value = 1; */ - private $value = ''; + protected $value = ''; /** * Constructor. diff --git a/php/src/Google/Protobuf/DoubleValue.php b/php/src/Google/Protobuf/DoubleValue.php index 236d91822354..b72399f460d6 100644 --- a/php/src/Google/Protobuf/DoubleValue.php +++ b/php/src/Google/Protobuf/DoubleValue.php @@ -21,7 +21,7 @@ class DoubleValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double value = 1; */ - private $value = 0.0; + protected $value = 0.0; /** * Constructor. diff --git a/php/src/Google/Protobuf/Duration.php b/php/src/Google/Protobuf/Duration.php index 414a1868b748..531cd50b5791 100644 --- a/php/src/Google/Protobuf/Duration.php +++ b/php/src/Google/Protobuf/Duration.php @@ -25,7 +25,7 @@ * if (duration.seconds < 0 && duration.nanos > 0) { * duration.seconds += 1; * duration.nanos -= 1000000000; - * } else if (durations.seconds > 0 && duration.nanos < 0) { + * } else if (duration.seconds > 0 && duration.nanos < 0) { * duration.seconds -= 1; * duration.nanos += 1000000000; * } @@ -66,7 +66,7 @@ class Duration extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 seconds = 1; */ - private $seconds = 0; + protected $seconds = 0; /** * Signed fractions of a second at nanosecond resolution of the span * of time. Durations less than one second are represented with a 0 @@ -77,7 +77,7 @@ class Duration extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 nanos = 2; */ - private $nanos = 0; + protected $nanos = 0; /** * Constructor. diff --git a/php/src/Google/Protobuf/Enum.php b/php/src/Google/Protobuf/Enum.php index 243c40d2899d..ed5afc447fec 100644 --- a/php/src/Google/Protobuf/Enum.php +++ b/php/src/Google/Protobuf/Enum.php @@ -20,7 +20,7 @@ class Enum extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Enum value definitions. * @@ -38,13 +38,13 @@ class Enum extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.SourceContext source_context = 4; */ - private $source_context = null; + protected $source_context = null; /** * The source syntax. * * Generated from protobuf field .google.protobuf.Syntax syntax = 5; */ - private $syntax = 0; + protected $syntax = 0; /** * Constructor. @@ -155,7 +155,17 @@ public function setOptions($var) */ public function getSourceContext() { - return $this->source_context; + return isset($this->source_context) ? $this->source_context : null; + } + + public function hasSourceContext() + { + return isset($this->source_context); + } + + public function clearSourceContext() + { + unset($this->source_context); } /** diff --git a/php/src/Google/Protobuf/EnumValue.php b/php/src/Google/Protobuf/EnumValue.php index 1dc3c7a6eee0..905f4ad14b29 100644 --- a/php/src/Google/Protobuf/EnumValue.php +++ b/php/src/Google/Protobuf/EnumValue.php @@ -20,13 +20,13 @@ class EnumValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Enum value number. * * Generated from protobuf field int32 number = 2; */ - private $number = 0; + protected $number = 0; /** * Protocol buffer options. * diff --git a/php/src/Google/Protobuf/Field.php b/php/src/Google/Protobuf/Field.php index 8da43e34da4f..76a505ea567d 100644 --- a/php/src/Google/Protobuf/Field.php +++ b/php/src/Google/Protobuf/Field.php @@ -20,45 +20,45 @@ class Field extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Field.Kind kind = 1; */ - private $kind = 0; + protected $kind = 0; /** * The field cardinality. * * Generated from protobuf field .google.protobuf.Field.Cardinality cardinality = 2; */ - private $cardinality = 0; + protected $cardinality = 0; /** * The field number. * * Generated from protobuf field int32 number = 3; */ - private $number = 0; + protected $number = 0; /** * The field name. * * Generated from protobuf field string name = 4; */ - private $name = ''; + protected $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 = ''; + protected $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; + protected $oneof_index = 0; /** * Whether to use alternative packed wire representation. * * Generated from protobuf field bool packed = 8; */ - private $packed = false; + protected $packed = false; /** * The protocol buffer options. * @@ -70,13 +70,13 @@ class Field extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string json_name = 10; */ - private $json_name = ''; + protected $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 = ''; + protected $default_value = ''; /** * Constructor. @@ -133,7 +133,7 @@ public function getKind() */ public function setKind($var) { - GPBUtil::checkEnum($var, \Google\Protobuf\Field_Kind::class); + GPBUtil::checkEnum($var, \Google\Protobuf\Field\Kind::class); $this->kind = $var; return $this; @@ -159,7 +159,7 @@ public function getCardinality() */ public function setCardinality($var) { - GPBUtil::checkEnum($var, \Google\Protobuf\Field_Cardinality::class); + GPBUtil::checkEnum($var, \Google\Protobuf\Field\Cardinality::class); $this->cardinality = $var; return $this; diff --git a/php/src/Google/Protobuf/Field/Cardinality.php b/php/src/Google/Protobuf/Field/Cardinality.php index 479dc0bfc2db..a42219957696 100644 --- a/php/src/Google/Protobuf/Field/Cardinality.php +++ b/php/src/Google/Protobuf/Field/Cardinality.php @@ -54,6 +54,7 @@ public static function name($value) return self::$valueToName[$value]; } + public static function value($name) { $const = __CLASS__ . '::' . strtoupper($name); diff --git a/php/src/Google/Protobuf/Field/Kind.php b/php/src/Google/Protobuf/Field/Kind.php index f30bd2f59bdf..2d8dd77c1cb4 100644 --- a/php/src/Google/Protobuf/Field/Kind.php +++ b/php/src/Google/Protobuf/Field/Kind.php @@ -159,6 +159,7 @@ public static function name($value) return self::$valueToName[$value]; } + public static function value($name) { $const = __CLASS__ . '::' . strtoupper($name); diff --git a/php/src/Google/Protobuf/FieldMask.php b/php/src/Google/Protobuf/FieldMask.php index 8fb38cbfb22c..0b9659d38f5c 100644 --- a/php/src/Google/Protobuf/FieldMask.php +++ b/php/src/Google/Protobuf/FieldMask.php @@ -62,45 +62,39 @@ * and leave the others untouched. If a resource is passed in to * describe the updated values, the API ignores the values of all * fields not covered by the mask. - * If a repeated field is specified for an update operation, the existing - * repeated values in the target resource will be overwritten by the new values. - * Note that a repeated field is only allowed in the last position of a `paths` - * string. + * If a repeated field is specified for an update operation, new values will + * be appended to the existing repeated field in the target resource. Note that + * a repeated field is only allowed in the last position of a `paths` string. * If a sub-message is specified in the last position of the field mask for an - * update operation, then the existing sub-message in the target resource is - * overwritten. Given the target message: + * update operation, then new value will be merged into the existing sub-message + * in the target resource. + * For example, given the target message: * f { * b { - * d : 1 - * x : 2 + * d: 1 + * x: 2 * } - * c : 1 + * c: [1] * } * And an update message: * f { * b { - * d : 10 + * d: 10 * } + * c: [2] * } * then if the field mask is: - * paths: "f.b" + * paths: ["f.b", "f.c"] * then the result will be: * f { * b { - * d : 10 - * } - * c : 1 - * } - * However, if the update mask was: - * paths: "f.b.d" - * then the result would be: - * f { - * b { - * d : 10 - * x : 2 + * d: 10 + * x: 2 * } - * c : 1 + * c: [1, 2] * } + * An implementation may provide options to override this default behavior for + * repeated and message fields. * In order to reset a field's value to the default, the field must * be in the mask and set to the default value in the provided resource. * Hence, in order to reset all fields of a resource, provide a default @@ -165,7 +159,7 @@ * ## Field Mask Verification * The implementation of any API method which has a FieldMask type field in the * request should verify the included field paths, and return an - * `INVALID_ARGUMENT` error if any path is duplicated or unmappable. + * `INVALID_ARGUMENT` error if any path is unmappable. * * Generated from protobuf message google.protobuf.FieldMask */ diff --git a/php/src/Google/Protobuf/FloatValue.php b/php/src/Google/Protobuf/FloatValue.php index 47ba52e6af3a..4285358d5e8c 100644 --- a/php/src/Google/Protobuf/FloatValue.php +++ b/php/src/Google/Protobuf/FloatValue.php @@ -21,7 +21,7 @@ class FloatValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float value = 1; */ - private $value = 0.0; + protected $value = 0.0; /** * Constructor. diff --git a/php/src/Google/Protobuf/Int32Value.php b/php/src/Google/Protobuf/Int32Value.php index d7fd528d21bf..cfd73cdc90f5 100644 --- a/php/src/Google/Protobuf/Int32Value.php +++ b/php/src/Google/Protobuf/Int32Value.php @@ -21,7 +21,7 @@ class Int32Value extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 value = 1; */ - private $value = 0; + protected $value = 0; /** * Constructor. diff --git a/php/src/Google/Protobuf/Int64Value.php b/php/src/Google/Protobuf/Int64Value.php index ca663055839c..143474fcd7cf 100644 --- a/php/src/Google/Protobuf/Int64Value.php +++ b/php/src/Google/Protobuf/Int64Value.php @@ -21,7 +21,7 @@ class Int64Value extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 value = 1; */ - private $value = 0; + protected $value = 0; /** * Constructor. diff --git a/php/src/Google/Protobuf/Method.php b/php/src/Google/Protobuf/Method.php index 8e803506885c..2755baa0e8b0 100644 --- a/php/src/Google/Protobuf/Method.php +++ b/php/src/Google/Protobuf/Method.php @@ -20,31 +20,31 @@ class Method extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * A URL of the input message type. * * Generated from protobuf field string request_type_url = 2; */ - private $request_type_url = ''; + protected $request_type_url = ''; /** * If true, the request is streamed. * * Generated from protobuf field bool request_streaming = 3; */ - private $request_streaming = false; + protected $request_streaming = false; /** * The URL of the output message type. * * Generated from protobuf field string response_type_url = 4; */ - private $response_type_url = ''; + protected $response_type_url = ''; /** * If true, the response is streamed. * * Generated from protobuf field bool response_streaming = 5; */ - private $response_streaming = false; + protected $response_streaming = false; /** * Any metadata attached to the method. * @@ -56,7 +56,7 @@ class Method extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Syntax syntax = 7; */ - private $syntax = 0; + protected $syntax = 0; /** * Constructor. diff --git a/php/src/Google/Protobuf/Mixin.php b/php/src/Google/Protobuf/Mixin.php index cf6277eb7064..4f7bf844ccfe 100644 --- a/php/src/Google/Protobuf/Mixin.php +++ b/php/src/Google/Protobuf/Mixin.php @@ -81,14 +81,14 @@ class Mixin extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * If non-empty specifies a path under which inherited HTTP paths * are rooted. * * Generated from protobuf field string root = 2; */ - private $root = ''; + protected $root = ''; /** * Constructor. diff --git a/php/src/Google/Protobuf/Option.php b/php/src/Google/Protobuf/Option.php index 22ecfc5f5c6c..9b2cc6c22c32 100644 --- a/php/src/Google/Protobuf/Option.php +++ b/php/src/Google/Protobuf/Option.php @@ -24,7 +24,7 @@ class Option extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $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 @@ -33,7 +33,7 @@ class Option extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Any value = 2; */ - private $value = null; + protected $value = null; /** * Constructor. @@ -101,7 +101,17 @@ public function setName($var) */ public function getValue() { - return $this->value; + return isset($this->value) ? $this->value : null; + } + + public function hasValue() + { + return isset($this->value); + } + + public function clearValue() + { + unset($this->value); } /** diff --git a/php/src/Google/Protobuf/SourceContext.php b/php/src/Google/Protobuf/SourceContext.php index cbc50c684260..8b3ea11220cd 100644 --- a/php/src/Google/Protobuf/SourceContext.php +++ b/php/src/Google/Protobuf/SourceContext.php @@ -22,7 +22,7 @@ class SourceContext extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string file_name = 1; */ - private $file_name = ''; + protected $file_name = ''; /** * Constructor. diff --git a/php/src/Google/Protobuf/StringValue.php b/php/src/Google/Protobuf/StringValue.php index 8fb354f3881e..ad98316b2247 100644 --- a/php/src/Google/Protobuf/StringValue.php +++ b/php/src/Google/Protobuf/StringValue.php @@ -21,7 +21,7 @@ class StringValue extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string value = 1; */ - private $value = ''; + protected $value = ''; /** * Constructor. diff --git a/php/src/Google/Protobuf/Syntax.php b/php/src/Google/Protobuf/Syntax.php index 9812669dacac..10952bfd42ce 100644 --- a/php/src/Google/Protobuf/Syntax.php +++ b/php/src/Google/Protobuf/Syntax.php @@ -40,6 +40,7 @@ public static function name($value) return self::$valueToName[$value]; } + public static function value($name) { $const = __CLASS__ . '::' . strtoupper($name); diff --git a/php/src/Google/Protobuf/Timestamp.php b/php/src/Google/Protobuf/Timestamp.php index 6d26f6c5cfdf..a12f48520bf2 100644 --- a/php/src/Google/Protobuf/Timestamp.php +++ b/php/src/Google/Protobuf/Timestamp.php @@ -9,17 +9,17 @@ use Google\Protobuf\Internal\GPBUtil; /** - * A Timestamp represents a point in time independent of any time zone - * or calendar, represented as seconds and fractions of seconds at - * nanosecond resolution in UTC Epoch time. It is encoded using the - * Proleptic Gregorian Calendar which extends the Gregorian calendar - * backwards to year one. It is encoded assuming all minutes are 60 - * seconds long, i.e. leap seconds are "smeared" so that no leap second - * table is needed for interpretation. Range is from - * 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. - * By restricting to that range, we ensure that we can convert to - * and from RFC 3339 date strings. - * See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. * # Examples * Example 1: Compute Timestamp from POSIX `time()`. * Timestamp timestamp; @@ -44,7 +44,12 @@ * long millis = System.currentTimeMillis(); * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) * .setNanos((int) ((millis % 1000) * 1000000)).build(); - * Example 5: Compute Timestamp from current time in Python. + * Example 5: Compute Timestamp from Java `Instant.now()`. + * Instant now = Instant.now(); + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * Example 6: Compute Timestamp from current time in Python. * timestamp = Timestamp() * timestamp.GetCurrentTime() * # JSON Mapping @@ -61,17 +66,19 @@ * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past * 01:30 UTC on January 15, 2017. * In JavaScript, one can convert a Date object to this format using the - * standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) * method. In Python, a standard `datetime.datetime` object can be converted - * to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) - * with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one - * can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( - * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime-- + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D * ) to obtain a formatter capable of generating timestamps in this format. * * Generated from protobuf message google.protobuf.Timestamp */ -class Timestamp extends \Google\Protobuf\Internal\Message +class Timestamp extends \Google\Protobuf\Internal\TimestampBase { /** * Represents seconds of UTC time since Unix epoch @@ -80,7 +87,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 seconds = 1; */ - private $seconds = 0; + protected $seconds = 0; /** * Non-negative fractions of a second at nanosecond resolution. Negative * second values with fractions must still have non-negative nanos values @@ -89,7 +96,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 nanos = 2; */ - private $nanos = 0; + protected $nanos = 0; /** * Constructor. @@ -175,26 +182,5 @@ public function setNanos($var) return $this; } - /* - * Converts PHP DateTime to Timestamp. - * - * @param \DateTime $datetime - */ - public function fromDateTime(\DateTime $datetime) - { - $this->seconds = $datetime->getTimestamp(); - $this->nanos = 1000 * $datetime->format('u'); - } - - /** - * Converts Timestamp to PHP DateTime. - * - * @return \DateTime $datetime - */ - public function toDateTime() - { - $time = sprintf('%s.%06d', $this->seconds, $this->nanos / 1000); - return \DateTime::createFromFormat('U.u', $time); - } } diff --git a/php/src/Google/Protobuf/Type.php b/php/src/Google/Protobuf/Type.php index 1b47811050a4..f60686665cd3 100644 --- a/php/src/Google/Protobuf/Type.php +++ b/php/src/Google/Protobuf/Type.php @@ -20,7 +20,7 @@ class Type extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The list of fields. * @@ -44,13 +44,13 @@ class Type extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.SourceContext source_context = 5; */ - private $source_context = null; + protected $source_context = null; /** * The source syntax. * * Generated from protobuf field .google.protobuf.Syntax syntax = 6; */ - private $syntax = 0; + protected $syntax = 0; /** * Constructor. @@ -189,7 +189,17 @@ public function setOptions($var) */ public function getSourceContext() { - return $this->source_context; + return isset($this->source_context) ? $this->source_context : null; + } + + public function hasSourceContext() + { + return isset($this->source_context); + } + + public function clearSourceContext() + { + unset($this->source_context); } /** diff --git a/php/src/Google/Protobuf/UInt32Value.php b/php/src/Google/Protobuf/UInt32Value.php index f5a522d2e8ef..ae5fc5b42c8d 100644 --- a/php/src/Google/Protobuf/UInt32Value.php +++ b/php/src/Google/Protobuf/UInt32Value.php @@ -21,7 +21,7 @@ class UInt32Value extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 value = 1; */ - private $value = 0; + protected $value = 0; /** * Constructor. diff --git a/php/src/Google/Protobuf/UInt64Value.php b/php/src/Google/Protobuf/UInt64Value.php index 89e69cd89206..aa9686726b93 100644 --- a/php/src/Google/Protobuf/UInt64Value.php +++ b/php/src/Google/Protobuf/UInt64Value.php @@ -21,7 +21,7 @@ class UInt64Value extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint64 value = 1; */ - private $value = 0; + protected $value = 0; /** * Constructor. diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 365cb64e5327..1ccef9129c1a 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -1402,9 +1402,24 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, fullname = fullname.substr(lastindex + 1); } + std::string base; + + switch (message->well_known_type()) { + case Descriptor::WELLKNOWNTYPE_ANY: + base = "\\Google\\Protobuf\\Internal\\AnyBase"; + break; + case Descriptor::WELLKNOWNTYPE_TIMESTAMP: + base = "\\Google\\Protobuf\\Internal\\TimestampBase"; + break; + default: + base = "\\Google\\Protobuf\\Internal\\Message"; + break; + } + printer.Print( - "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n" + "class ^name^ extends ^base^\n" "{\n", + "base", base, "name", fullname); Indent(&printer); From b4140770418f43b007268a8315d0030d970c4dc3 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 29 Sep 2020 15:57:45 -0700 Subject: [PATCH 02/12] Added an anonymous namespace and removed unused code. --- .../protobuf/compiler/php/php_generator.cc | 43 ++----------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 1ccef9129c1a..7296b9b5e749 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -78,15 +78,14 @@ namespace protobuf { namespace compiler { namespace php { +namespace { + // Forward decls. std::string PhpName(const std::string& full_name, bool is_descriptor); -std::string DefaultForField(FieldDescriptor* field); std::string IntToString(int32 value); std::string FilenameToClassname(const string& filename); std::string GeneratedMetadataFileName(const FileDescriptor* file, bool is_descriptor); -std::string LabelForField(FieldDescriptor* field); -std::string TypeName(FieldDescriptor* field); std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter); std::string BinaryToHex(const string& binary); void Indent(io::Printer* printer); @@ -178,18 +177,6 @@ std::string GeneratedClassNameImpl(const ServiceDescriptor* desc) { return ClassNamePrefix(classname, desc) + classname; } -std::string GeneratedClassName(const Descriptor* desc) { - return GeneratedClassNameImpl(desc); -} - -std::string GeneratedClassName(const EnumDescriptor* desc) { - return GeneratedClassNameImpl(desc); -} - -std::string GeneratedClassName(const ServiceDescriptor* desc) { - return GeneratedClassNameImpl(desc); -} - template std::string LegacyGeneratedClassName(const DescriptorType* desc) { std::string classname = desc->name(); @@ -435,30 +422,6 @@ std::string LabelForField(const FieldDescriptor* field) { } } -std::string TypeName(const FieldDescriptor* field) { - switch (field->type()) { - case FieldDescriptor::TYPE_INT32: return "int32"; - case FieldDescriptor::TYPE_INT64: return "int64"; - case FieldDescriptor::TYPE_UINT32: return "uint32"; - case FieldDescriptor::TYPE_UINT64: return "uint64"; - case FieldDescriptor::TYPE_SINT32: return "sint32"; - case FieldDescriptor::TYPE_SINT64: return "sint64"; - case FieldDescriptor::TYPE_FIXED32: return "fixed32"; - case FieldDescriptor::TYPE_FIXED64: return "fixed64"; - case FieldDescriptor::TYPE_SFIXED32: return "sfixed32"; - case FieldDescriptor::TYPE_SFIXED64: return "sfixed64"; - case FieldDescriptor::TYPE_DOUBLE: return "double"; - case FieldDescriptor::TYPE_FLOAT: return "float"; - case FieldDescriptor::TYPE_BOOL: return "bool"; - case FieldDescriptor::TYPE_ENUM: return "enum"; - case FieldDescriptor::TYPE_STRING: return "string"; - case FieldDescriptor::TYPE_BYTES: return "bytes"; - case FieldDescriptor::TYPE_MESSAGE: return "message"; - case FieldDescriptor::TYPE_GROUP: return "group"; - default: assert(false); return ""; - } -} - std::string PhpSetterTypeName(const FieldDescriptor* field, bool is_descriptor) { if (field->is_map()) { return "array|\\Google\\Protobuf\\Internal\\MapField"; @@ -1816,6 +1779,8 @@ void GenerateServiceMethodDocComment(io::Printer* printer, "return_type", EscapePhpdoc(FullClassName(method->output_type(), false))); } +} // namespace + bool Generator::Generate(const FileDescriptor* file, const string& parameter, GeneratorContext* generator_context, string* error) const { From f1256df893dfcfa4a30371d038f2398012ba1857 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 29 Sep 2020 16:43:38 -0700 Subject: [PATCH 03/12] Created Options struct for PHP codegen options. --- .../protobuf/compiler/php/php_generator.cc | 320 +++++++++--------- .../protobuf/compiler/php/php_generator.h | 6 +- 2 files changed, 170 insertions(+), 156 deletions(-) diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 7296b9b5e749..177ca90cee12 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -78,34 +78,39 @@ namespace protobuf { namespace compiler { namespace php { +struct Options { + bool is_descriptor = false; + bool aggregate_metadata = false; + std::set aggregate_metadata_prefixes; +}; + namespace { // Forward decls. -std::string PhpName(const std::string& full_name, bool is_descriptor); +std::string PhpName(const std::string& full_name, const Options& options); std::string IntToString(int32 value); std::string FilenameToClassname(const string& filename); std::string GeneratedMetadataFileName(const FileDescriptor* file, - bool is_descriptor); + const Options& options); std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter); std::string BinaryToHex(const string& binary); void Indent(io::Printer* printer); void Outdent(io::Printer* printer); -void GenerateAddFilesToPool(const FileDescriptor* file, - const std::set& aggregate_metadata_prefixes, +void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options, io::Printer* printer); void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message, - int is_descriptor); + const Options& options); void GenerateMessageConstructorDocComment(io::Printer* printer, const Descriptor* message, - int is_descriptor); + const Options& options); void GenerateFieldDocComment(io::Printer* printer, const FieldDescriptor* field, - int is_descriptor, int function_type); + const Options& options, int function_type); void GenerateWrapperFieldGetterDocComment(io::Printer* printer, const FieldDescriptor* field); void GenerateWrapperFieldSetterDocComment(io::Printer* printer, const FieldDescriptor* field); void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, - int is_descriptor); + const Options& options); void GenerateEnumValueDocComment(io::Printer* printer, const EnumValueDescriptor* value); void GenerateServiceDocComment(io::Printer* printer, @@ -139,8 +144,8 @@ std::string ReservedNamePrefix(const string& classname, } template -std::string DescriptorFullName(const DescriptorType* desc, bool is_descriptor) { - if (is_descriptor) { +std::string DescriptorFullName(const DescriptorType* desc, bool is_internal) { + if (is_internal) { return StringReplace(desc->full_name(), "google.protobuf", "google.protobuf.internal", false); @@ -229,7 +234,8 @@ std::string ConstantNamePrefix(const string& classname) { } template -std::string RootPhpNamespace(const DescriptorType* desc, bool is_descriptor) { +std::string RootPhpNamespace(const DescriptorType* desc, + const Options& options) { if (desc->file()->options().has_php_namespace()) { const string& php_namespace = desc->file()->options().php_namespace(); if (!php_namespace.empty()) { @@ -239,15 +245,15 @@ std::string RootPhpNamespace(const DescriptorType* desc, bool is_descriptor) { } if (!desc->file()->package().empty()) { - return PhpName(desc->file()->package(), is_descriptor); + return PhpName(desc->file()->package(), options); } return ""; } template -std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { +std::string FullClassName(const DescriptorType* desc, const Options& options) { string classname = GeneratedClassNameImpl(desc); - string php_namespace = RootPhpNamespace(desc, is_descriptor); + string php_namespace = RootPhpNamespace(desc, options); if (!php_namespace.empty()) { return php_namespace + "\\" + classname; } @@ -255,17 +261,25 @@ std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { } template -std::string LegacyFullClassName(const DescriptorType* desc, bool is_descriptor) { +std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { + Options options; + options.is_descriptor = is_descriptor; + return FullClassName(desc, options); +} + +template +std::string LegacyFullClassName(const DescriptorType* desc, + const Options& options) { string classname = LegacyGeneratedClassName(desc); - string php_namespace = RootPhpNamespace(desc, is_descriptor); + string php_namespace = RootPhpNamespace(desc, options); if (!php_namespace.empty()) { return php_namespace + "\\" + classname; } return classname; } -std::string PhpName(const std::string& full_name, bool is_descriptor) { - if (is_descriptor) { +std::string PhpName(const std::string& full_name, const Options& options) { + if (options.is_descriptor) { return kDescriptorPackageName; } @@ -314,7 +328,7 @@ std::string DefaultForField(const FieldDescriptor* field) { } std::string GeneratedMetadataFileName(const FileDescriptor* file, - bool is_descriptor) { + const Options& options) { const string& proto_file = file->name(); int start_index = 0; int first_index = proto_file.find_first_of("/", start_index); @@ -324,7 +338,7 @@ std::string GeneratedMetadataFileName(const FileDescriptor* file, if (proto_file == kEmptyFile) { return kEmptyMetadataFile; } - if (is_descriptor) { + if (options.is_descriptor) { return kDescriptorMetadataFile; } @@ -371,10 +385,17 @@ std::string GeneratedMetadataFileName(const FileDescriptor* file, return result + ReservedNamePrefix(segment, file) + segment + ".php"; } +std::string GeneratedMetadataFileName(const FileDescriptor* file, + bool is_descriptor) { + Options options; + options.is_descriptor = is_descriptor; + return GeneratedMetadataFileName(file, options); +} + template std::string GeneratedClassFileName(const DescriptorType* desc, - bool is_descriptor) { - std::string result = FullClassName(desc, is_descriptor); + const Options& options) { + std::string result = FullClassName(desc, options); for (int i = 0; i < result.size(); i++) { if (result[i] == '\\') { result[i] = '/'; @@ -385,8 +406,8 @@ std::string GeneratedClassFileName(const DescriptorType* desc, template std::string LegacyGeneratedClassFileName(const DescriptorType* desc, - bool is_descriptor) { - std::string result = LegacyFullClassName(desc, is_descriptor); + const Options& options) { + std::string result = LegacyFullClassName(desc, options); for (int i = 0; i < result.size(); i++) { if (result[i] == '\\') { @@ -397,8 +418,8 @@ std::string LegacyGeneratedClassFileName(const DescriptorType* desc, } std::string GeneratedServiceFileName(const ServiceDescriptor* service, - bool is_descriptor) { - std::string result = FullClassName(service, is_descriptor) + "Interface"; + const Options& options) { + std::string result = FullClassName(service, options) + "Interface"; for (int i = 0; i < result.size(); i++) { if (result[i] == '\\') { result[i] = '/'; @@ -422,7 +443,8 @@ std::string LabelForField(const FieldDescriptor* field) { } } -std::string PhpSetterTypeName(const FieldDescriptor* field, bool is_descriptor) { +std::string PhpSetterTypeName(const FieldDescriptor* field, + const Options& options) { if (field->is_map()) { return "array|\\Google\\Protobuf\\Internal\\MapField"; } @@ -455,7 +477,7 @@ std::string PhpSetterTypeName(const FieldDescriptor* field, bool is_descriptor) type = "string"; break; case FieldDescriptor::TYPE_MESSAGE: - type = "\\" + FullClassName(field->message_type(), is_descriptor); + type = "\\" + FullClassName(field->message_type(), options); break; case FieldDescriptor::TYPE_GROUP: return "null"; @@ -472,7 +494,15 @@ std::string PhpSetterTypeName(const FieldDescriptor* field, bool is_descriptor) return type; } -std::string PhpGetterTypeName(const FieldDescriptor* field, bool is_descriptor) { +std::string PhpSetterTypeName(const FieldDescriptor* field, + bool is_descriptor) { + Options options; + options.is_descriptor = is_descriptor; + return PhpSetterTypeName(field, options); +} + +std::string PhpGetterTypeName(const FieldDescriptor* field, + const Options& options) { if (field->is_map()) { return "\\Google\\Protobuf\\Internal\\MapField"; } @@ -497,23 +527,40 @@ std::string PhpGetterTypeName(const FieldDescriptor* field, bool is_descriptor) case FieldDescriptor::TYPE_STRING: case FieldDescriptor::TYPE_BYTES: return "string"; case FieldDescriptor::TYPE_MESSAGE: - return "\\" + FullClassName(field->message_type(), is_descriptor); + return "\\" + FullClassName(field->message_type(), options); case FieldDescriptor::TYPE_GROUP: return "null"; default: assert(false); return ""; } } -std::string EnumOrMessageSuffix( - const FieldDescriptor* field, bool is_descriptor) { +std::string PhpGetterTypeName(const FieldDescriptor* field, + bool is_descriptor) { + Options options; + options.is_descriptor = is_descriptor; + return PhpGetterTypeName(field, options); +} + +std::string EnumOrMessageSuffix(const FieldDescriptor* field, + const Options& options) { if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - return ", '" + DescriptorFullName(field->message_type(), is_descriptor) + "'"; + return ", '" + + DescriptorFullName(field->message_type(), options.is_descriptor) + + "'"; } if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { - return ", '" + DescriptorFullName(field->enum_type(), is_descriptor) + "'"; + return ", '" + + DescriptorFullName(field->enum_type(), options.is_descriptor) + "'"; } return ""; } +std::string EnumOrMessageSuffix(const FieldDescriptor* field, + bool is_descriptor) { + Options options; + options.is_descriptor = is_descriptor; + return EnumOrMessageSuffix(field, options); +} + // Converts a name to camel-case. If cap_first_letter is true, capitalize the // first letter. std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter) { @@ -581,9 +628,9 @@ void Outdent(io::Printer* printer) { } void GenerateField(const FieldDescriptor* field, io::Printer* printer, - bool is_descriptor) { + const Options& options) { if (field->is_repeated()) { - GenerateFieldDocComment(printer, field, is_descriptor, kFieldProperty); + GenerateFieldDocComment(printer, field, options, kFieldProperty); printer->Print( "private $^name^;\n", "name", field->name()); @@ -593,7 +640,7 @@ void GenerateField(const FieldDescriptor* field, io::Printer* printer, } else { std::string initial_value = field->has_presence() ? "null" : DefaultForField(field); - GenerateFieldDocComment(printer, field, is_descriptor, kFieldProperty); + GenerateFieldDocComment(printer, field, options, kFieldProperty); printer->Print( "protected $^name^ = ^initial_value^;\n", "name", field->name(), @@ -609,12 +656,12 @@ void GenerateOneofField(const OneofDescriptor* oneof, io::Printer* printer) { "name", oneof->name()); } -void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, +void GenerateFieldAccessor(const FieldDescriptor* field, const Options& options, io::Printer* printer) { const OneofDescriptor* oneof = field->real_containing_oneof(); // Generate getter. - GenerateFieldDocComment(printer, field, is_descriptor, kFieldGetter); + GenerateFieldDocComment(printer, field, options, kFieldGetter); if (oneof != NULL) { printer->Print( @@ -671,7 +718,7 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, } // Generate setter. - GenerateFieldDocComment(printer, field, is_descriptor, kFieldSetter); + GenerateFieldDocComment(printer, field, options, kFieldSetter); printer->Print( "public function set^camel_name^($var)\n" "{\n", @@ -694,12 +741,12 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, printer->Print( ", \\^class_name^);\n", "class_name", - FullClassName(value->message_type(), is_descriptor) + "::class"); + FullClassName(value->message_type(), options) + "::class"); } else if (value->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { printer->Print( ", \\^class_name^);\n", "class_name", - FullClassName(value->enum_type(), is_descriptor) + "::class"); + FullClassName(value->enum_type(), options) + "::class"); } else { printer->Print(");\n"); } @@ -712,23 +759,23 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, printer->Print( ", \\^class_name^);\n", "class_name", - FullClassName(field->message_type(), is_descriptor) + "::class"); + FullClassName(field->message_type(), options) + "::class"); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { printer->Print( ", \\^class_name^);\n", "class_name", - FullClassName(field->enum_type(), is_descriptor) + "::class"); + FullClassName(field->enum_type(), options) + "::class"); } else { printer->Print(");\n"); } } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { printer->Print( "GPBUtil::checkMessage($var, \\^class_name^::class);\n", - "class_name", FullClassName(field->message_type(), is_descriptor)); + "class_name", FullClassName(field->message_type(), options)); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { printer->Print( "GPBUtil::checkEnum($var, \\^class_name^::class);\n", - "class_name", FullClassName(field->enum_type(), is_descriptor)); + "class_name", FullClassName(field->enum_type(), options)); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { printer->Print( "GPBUtil::checkString($var, ^utf8^);\n", @@ -888,19 +935,15 @@ void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, } } -void GenerateAddFileToPool( - const FileDescriptor* file, - bool is_descriptor, - bool aggregate_metadata, - const std::set& aggregate_metadata_prefixes, - io::Printer* printer) { +void GenerateAddFileToPool(const FileDescriptor* file, const Options& options, + io::Printer* printer) { printer->Print( "public static $is_initialized = false;\n\n" "public static function initOnce() {\n"); Indent(printer); - if (aggregate_metadata) { - GenerateAddFilesToPool(file, aggregate_metadata_prefixes, printer); + if (options.aggregate_metadata) { + GenerateAddFilesToPool(file, options, printer); } else { printer->Print( "$pool = \\Google\\Protobuf\\Internal\\" @@ -909,7 +952,7 @@ void GenerateAddFileToPool( " return;\n" "}\n"); - if (is_descriptor) { + if (options.is_descriptor) { for (int i = 0; i < file->message_type_count(); i++) { GenerateMessageToPool("", file->message_type(i), printer); } @@ -929,7 +972,7 @@ void GenerateAddFileToPool( continue; } std::string dependency_filename = - GeneratedMetadataFileName(file->dependency(i), is_descriptor); + GeneratedMetadataFileName(file->dependency(i), options); printer->Print( "\\^name^::initOnce();\n", "name", FilenameToClassname(dependency_filename)); @@ -1016,12 +1059,12 @@ static void AnalyzeDependencyForFile( static bool NeedsUnwrapping( const FileDescriptor* file, - const std::set& aggregate_metadata_prefixes) { + const Options& options) { bool has_aggregate_metadata_prefix = false; - if (aggregate_metadata_prefixes.empty()) { + if (options.aggregate_metadata_prefixes.empty()) { has_aggregate_metadata_prefix = true; } else { - for (const auto& prefix : aggregate_metadata_prefixes) { + for (const auto& prefix : options.aggregate_metadata_prefixes) { if (HasPrefixString(file->package(), prefix)) { has_aggregate_metadata_prefix = true; break; @@ -1034,7 +1077,7 @@ static bool NeedsUnwrapping( void GenerateAddFilesToPool( const FileDescriptor* file, - const std::set& aggregate_metadata_prefixes, + const Options& options, io::Printer* printer) { printer->Print( "$pool = \\Google\\Protobuf\\Internal\\" @@ -1064,7 +1107,7 @@ void GenerateAddFilesToPool( } } - bool needs_aggregate = NeedsUnwrapping(file, aggregate_metadata_prefixes); + bool needs_aggregate = NeedsUnwrapping(file, options); if (needs_aggregate) { auto file_proto = sorted_file_set.add_file(); @@ -1089,8 +1132,7 @@ void GenerateAddFilesToPool( it->clear_extension(); } } else { - std::string dependency_filename = - GeneratedMetadataFileName(file, false); + std::string dependency_filename = GeneratedMetadataFileName(file, false); printer->Print( "\\^name^::initOnce();\n", "name", FilenameToClassname(dependency_filename)); @@ -1115,8 +1157,8 @@ void GenerateAddFilesToPool( "static::$is_initialized = true;\n"); } -void GenerateUseDeclaration(bool is_descriptor, io::Printer* printer) { - if (!is_descriptor) { +void GenerateUseDeclaration(const Options& options, io::Printer* printer) { + if (!options.is_descriptor) { printer->Print( "use Google\\Protobuf\\Internal\\GPBType;\n" "use Google\\Protobuf\\Internal\\RepeatedField;\n" @@ -1151,12 +1193,9 @@ std::string FilenameToClassname(const string& filename) { return result; } -void GenerateMetadataFile(const FileDescriptor* file, - bool is_descriptor, - bool aggregate_metadata, - const std::set& aggregate_metadata_prefixes, +void GenerateMetadataFile(const FileDescriptor* file, const Options& options, GeneratorContext* generator_context) { - std::string filename = GeneratedMetadataFileName(file, is_descriptor); + std::string filename = GeneratedMetadataFileName(file, options); std::unique_ptr output( generator_context->Open(filename)); io::Printer printer(output.get(), '^'); @@ -1183,32 +1222,30 @@ void GenerateMetadataFile(const FileDescriptor* file, } Indent(&printer); - GenerateAddFileToPool(file, is_descriptor, aggregate_metadata, - aggregate_metadata_prefixes, &printer); + GenerateAddFileToPool(file, options, &printer); Outdent(&printer); printer.Print("}\n\n"); } template -void LegacyGenerateClassFile(const FileDescriptor* file, const DescriptorType* desc, - bool is_descriptor, - GeneratorContext* generator_context) { - - std::string filename = LegacyGeneratedClassFileName(desc, is_descriptor); +void LegacyGenerateClassFile(const FileDescriptor* file, + const DescriptorType* desc, const Options& options, + GeneratorContext* generator_context) { + std::string filename = LegacyGeneratedClassFileName(desc, options); std::unique_ptr output( generator_context->Open(filename)); io::Printer printer(output.get(), '^'); GenerateHead(file, &printer); - std::string php_namespace = RootPhpNamespace(desc, is_descriptor); + std::string php_namespace = RootPhpNamespace(desc, options); if (!php_namespace.empty()) { printer.Print( "namespace ^name^;\n\n", "name", php_namespace); } - std::string newname = FullClassName(desc, is_descriptor); + std::string newname = FullClassName(desc, options); printer.Print("if (false) {\n"); Indent(&printer); printer.Print("/**\n"); @@ -1224,13 +1261,14 @@ void LegacyGenerateClassFile(const FileDescriptor* file, const DescriptorType* d "new", GeneratedClassNameImpl(desc)); printer.Print("@trigger_error('^old^ is deprecated and will be removed in " "the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n", - "old", LegacyFullClassName(desc, is_descriptor), + "old", LegacyFullClassName(desc, options), "fullname", newname); } void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, - bool is_descriptor, GeneratorContext* generator_context) { - std::string filename = GeneratedClassFileName(en, is_descriptor); + const Options& options, + GeneratorContext* generator_context) { + std::string filename = GeneratedClassFileName(en, options); std::unique_ptr output( generator_context->Open(filename)); io::Printer printer(output.get(), '^'); @@ -1250,7 +1288,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, printer.Print("use UnexpectedValueException;\n\n"); } - GenerateEnumDocComment(&printer, en, is_descriptor); + GenerateEnumDocComment(&printer, en, options); if (lastindex != string::npos) { fullname = fullname.substr(lastindex + 1); @@ -1327,14 +1365,13 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, printer.Print( "class_alias(^new^::class, \\^old^::class);\n\n", "new", fullname, - "old", LegacyFullClassName(en, is_descriptor)); - LegacyGenerateClassFile(file, en, is_descriptor, generator_context); + "old", LegacyFullClassName(en, options)); + LegacyGenerateClassFile(file, en, options, generator_context); } } void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, - bool is_descriptor, - bool aggregate_metadata, + const Options& options, GeneratorContext* generator_context) { // Don't generate MapEntry messages -- we use the PHP extension's native // support for map fields instead. @@ -1342,7 +1379,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, return; } - std::string filename = GeneratedClassFileName(message, is_descriptor); + std::string filename = GeneratedClassFileName(message, options); std::unique_ptr output( generator_context->Open(filename)); io::Printer printer(output.get(), '^'); @@ -1358,9 +1395,9 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, "name", fullname.substr(0, lastindex)); } - GenerateUseDeclaration(is_descriptor, &printer); + GenerateUseDeclaration(options, &printer); - GenerateMessageDocComment(&printer, message, is_descriptor); + GenerateMessageDocComment(&printer, message, options); if (lastindex != string::npos) { fullname = fullname.substr(lastindex + 1); } @@ -1389,7 +1426,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, // Field and oneof definitions. for (int i = 0; i < message->field_count(); i++) { const FieldDescriptor* field = message->field(i); - GenerateField(field, &printer, is_descriptor); + GenerateField(field, &printer, options); } for (int i = 0; i < message->real_oneof_decl_count(); i++) { const OneofDescriptor* oneof = message->oneof_decl(i); @@ -1397,13 +1434,12 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, } printer.Print("\n"); - GenerateMessageConstructorDocComment(&printer, message, is_descriptor); + GenerateMessageConstructorDocComment(&printer, message, options); printer.Print( "public function __construct($data = NULL) {\n"); Indent(&printer); - std::string metadata_filename = - GeneratedMetadataFileName(file, is_descriptor); + std::string metadata_filename = GeneratedMetadataFileName(file, options); std::string metadata_fullname = FilenameToClassname(metadata_filename); printer.Print( "\\^fullname^::initOnce();\n", @@ -1418,7 +1454,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, // Field and oneof accessors. for (int i = 0; i < message->field_count(); i++) { const FieldDescriptor* field = message->field(i); - GenerateFieldAccessor(field, is_descriptor, &printer); + GenerateFieldAccessor(field, options, &printer); } for (int i = 0; i < message->real_oneof_decl_count(); i++) { const OneofDescriptor* oneof = message->oneof_decl(i); @@ -1444,26 +1480,24 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, printer.Print( "class_alias(^new^::class, \\^old^::class);\n\n", "new", fullname, - "old", LegacyFullClassName(message, is_descriptor)); - LegacyGenerateClassFile(file, message, is_descriptor, generator_context); + "old", LegacyFullClassName(message, options)); + LegacyGenerateClassFile(file, message, options, generator_context); } // Nested messages and enums. for (int i = 0; i < message->nested_type_count(); i++) { - GenerateMessageFile(file, message->nested_type(i), is_descriptor, - aggregate_metadata, + GenerateMessageFile(file, message->nested_type(i), options, generator_context); } for (int i = 0; i < message->enum_type_count(); i++) { - GenerateEnumFile(file, message->enum_type(i), is_descriptor, - generator_context); + GenerateEnumFile(file, message->enum_type(i), options, generator_context); } } -void GenerateServiceFile(const FileDescriptor* file, - const ServiceDescriptor* service, bool is_descriptor, - GeneratorContext* generator_context) { - std::string filename = GeneratedServiceFileName(service, is_descriptor); +void GenerateServiceFile( + const FileDescriptor* file, const ServiceDescriptor* service, + const Options& options, GeneratorContext* generator_context) { + std::string filename = GeneratedServiceFileName(service, options); std::unique_ptr output( generator_context->Open(filename)); io::Printer printer(output.get(), '^'); @@ -1507,26 +1541,20 @@ void GenerateServiceFile(const FileDescriptor* file, printer.Print("}\n\n"); } -void GenerateFile(const FileDescriptor* file, bool is_descriptor, - bool aggregate_metadata, - const std::set& aggregate_metadata_prefixes, +void GenerateFile(const FileDescriptor* file, const Options& options, GeneratorContext* generator_context) { - GenerateMetadataFile(file, is_descriptor, aggregate_metadata, - aggregate_metadata_prefixes, generator_context); + GenerateMetadataFile(file, options, generator_context); for (int i = 0; i < file->message_type_count(); i++) { - GenerateMessageFile(file, file->message_type(i), is_descriptor, - aggregate_metadata, + GenerateMessageFile(file, file->message_type(i), options, generator_context); } for (int i = 0; i < file->enum_type_count(); i++) { - GenerateEnumFile(file, file->enum_type(i), is_descriptor, - generator_context); + GenerateEnumFile(file, file->enum_type(i), options, generator_context); } if (file->options().php_generic_services()) { for (int i = 0; i < file->service_count(); i++) { - GenerateServiceFile(file, file->service(i), is_descriptor, - generator_context); + GenerateServiceFile(file, file->service(i), options, generator_context); } } } @@ -1629,20 +1657,20 @@ static string FirstLineOf(const string& value) { return result; } -void GenerateMessageDocComment(io::Printer* printer, - const Descriptor* message, int is_descriptor) { +void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message, + const Options& options) { printer->Print("/**\n"); GenerateDocCommentBody(printer, message); printer->Print( " * Generated from protobuf message ^messagename^\n" " */\n", - "fullname", EscapePhpdoc(FullClassName(message, is_descriptor)), + "fullname", EscapePhpdoc(FullClassName(message, options)), "messagename", EscapePhpdoc(message->full_name())); } void GenerateMessageConstructorDocComment(io::Printer* printer, const Descriptor* message, - int is_descriptor) { + const Options& options) { // In theory we should have slightly different comments for setters, getters, // etc., but in practice everyone already knows the difference between these // so it's redundant information. @@ -1660,7 +1688,7 @@ void GenerateMessageConstructorDocComment(io::Printer* printer, for (int i = 0; i < message->field_count(); i++) { const FieldDescriptor* field = message->field(i); printer->Print(" * @type ^php_type^ $^var^\n", - "php_type", PhpSetterTypeName(field, is_descriptor), + "php_type", PhpSetterTypeName(field, options), "var", field->name()); SourceLocation location; if (field->GetSourceLocation(&location)) { @@ -1682,7 +1710,7 @@ void GenerateServiceDocComment(io::Printer* printer, } void GenerateFieldDocComment(io::Printer* printer, const FieldDescriptor* field, - int is_descriptor, int function_type) { + const Options& options, int function_type) { // In theory we should have slightly different comments for setters, getters, // etc., but in practice everyone already knows the difference between these // so it's redundant information. @@ -1698,11 +1726,11 @@ void GenerateFieldDocComment(io::Printer* printer, const FieldDescriptor* field, "def", EscapePhpdoc(FirstLineOf(field->DebugString()))); if (function_type == kFieldSetter) { printer->Print(" * @param ^php_type^ $var\n", - "php_type", PhpSetterTypeName(field, is_descriptor)); + "php_type", PhpSetterTypeName(field, options)); printer->Print(" * @return $this\n"); } else if (function_type == kFieldGetter) { printer->Print(" * @return ^php_type^\n", - "php_type", PhpGetterTypeName(field, is_descriptor)); + "php_type", PhpGetterTypeName(field, options)); } printer->Print(" */\n"); } @@ -1743,7 +1771,7 @@ void GenerateWrapperFieldSetterDocComment(io::Printer* printer, const FieldDescr } void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, - int is_descriptor) { + const Options& options) { printer->Print("/**\n"); GenerateDocCommentBody(printer, enum_); printer->Print( @@ -1784,32 +1812,26 @@ void GenerateServiceMethodDocComment(io::Printer* printer, bool Generator::Generate(const FileDescriptor* file, const string& parameter, GeneratorContext* generator_context, string* error) const { - return Generate(file, false, false, std::set(), - generator_context, error); + return Generate(file, Options(), generator_context, error); } -bool Generator::Generate( - const FileDescriptor* file, - bool is_descriptor, - bool aggregate_metadata, - const std::set& aggregate_metadata_prefixes, - GeneratorContext* generator_context, - string* error) const { - if (is_descriptor && file->name() != kDescriptorFile) { +bool Generator::Generate(const FileDescriptor* file, const Options& options, + GeneratorContext* generator_context, + string* error) const { + if (options.is_descriptor && file->name() != kDescriptorFile) { *error = "Can only generate PHP code for google/protobuf/descriptor.proto.\n"; return false; } - if (!is_descriptor && file->syntax() != FileDescriptor::SYNTAX_PROTO3) { + if (!options.is_descriptor && file->syntax() != FileDescriptor::SYNTAX_PROTO3) { *error = "Can only generate PHP code for proto3 .proto files.\n" "Please add 'syntax = \"proto3\";' to the top of your .proto file.\n"; return false; } - GenerateFile(file, is_descriptor, aggregate_metadata, - aggregate_metadata_prefixes, generator_context); + GenerateFile(file, options, generator_context); return true; } @@ -1818,32 +1840,24 @@ bool Generator::GenerateAll(const std::vector& files, const std::string& parameter, GeneratorContext* generator_context, std::string* error) const { - bool is_descriptor = false; - bool aggregate_metadata = false; - std::set aggregate_metadata_prefixes; + Options options; for (const auto& option : Split(parameter, ",", true)) { const std::vector option_pair = Split(option, "=", true); if (HasPrefixString(option_pair[0], "aggregate_metadata")) { - string options_string = option_pair[1]; - const std::vector options = - Split(options_string, "#", false); - aggregate_metadata = true; - for (int i = 0; i < options.size(); i++) { - aggregate_metadata_prefixes.insert(options[i]); - GOOGLE_LOG(INFO) << options[i]; + options.aggregate_metadata = true; + for (const auto& prefix : Split(option_pair[1], "#", false)) { + options.aggregate_metadata_prefixes.insert(prefix); + GOOGLE_LOG(INFO) << prefix; } } if (option_pair[0] == "internal") { - is_descriptor = true; + options.is_descriptor = true; } } for (auto file : files) { - if (!Generate( - file, is_descriptor, aggregate_metadata, - aggregate_metadata_prefixes, - generator_context, error)) { + if (!Generate(file, options, generator_context, error)) { return false; } } diff --git a/src/google/protobuf/compiler/php/php_generator.h b/src/google/protobuf/compiler/php/php_generator.h index f67bb4041760..1fc0088ffc21 100644 --- a/src/google/protobuf/compiler/php/php_generator.h +++ b/src/google/protobuf/compiler/php/php_generator.h @@ -43,6 +43,8 @@ namespace protobuf { namespace compiler { namespace php { +struct Options; + class PROTOC_EXPORT Generator : public CodeGenerator { public: virtual bool Generate( @@ -63,9 +65,7 @@ class PROTOC_EXPORT Generator : public CodeGenerator { private: bool Generate( const FileDescriptor* file, - bool is_descriptor, - bool aggregate_metadata, - const std::set& aggregate_metadata_prefixes, + const Options& options, GeneratorContext* generator_context, string* error) const; }; From a93d840881945603c6bcc41a71e5cfaee7876034 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 1 Oct 2020 23:17:10 -0700 Subject: [PATCH 04/12] WIP. --- php/ext/google/protobuf/bundled_php.h | 46 - php/ext/google/protobuf/config.m4 | 2 +- php/ext/google/protobuf/def.c | 71 +- php/ext/google/protobuf/def.h | 6 + php/ext/google/protobuf/make-preload.php | 62 - php/ext/google/protobuf/message.c | 232 +- php/ext/google/protobuf/php-upb.c | 348 +- php/ext/google/protobuf/php-upb.h | 96 +- php/ext/google/protobuf/protobuf.c | 34 - php/ext/google/protobuf/wkt.inc | 2920 +++++++++++++++++ php/tests/compile_extension.sh | 1 - .../protobuf/compiler/php/php_generator.cc | 236 +- 12 files changed, 3653 insertions(+), 401 deletions(-) delete mode 100644 php/ext/google/protobuf/bundled_php.h delete mode 100644 php/ext/google/protobuf/make-preload.php create mode 100644 php/ext/google/protobuf/wkt.inc diff --git a/php/ext/google/protobuf/bundled_php.h b/php/ext/google/protobuf/bundled_php.h deleted file mode 100644 index 76147677a177..000000000000 --- a/php/ext/google/protobuf/bundled_php.h +++ /dev/null @@ -1,46 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef PHP_PROTOBUF_BUNDLED_PHP_H_ -#define PHP_PROTOBUF_BUNDLED_PHP_H_ - -// We embed PHP source code into the binary for things we don't want to -// implement in C. This struct serves as a table of contents for all of -// the embedded files. -typedef struct { - const char *filename; - const char *contents; -} BundledPhp_File; - -// An array of all the embedded file structs. This array is terminated with a -// {NULL, NULL} entry. -extern BundledPhp_File *bundled_files; - -#endif // PHP_PROTOBUF_BUNDLED_PHP_H_ diff --git a/php/ext/google/protobuf/config.m4 b/php/ext/google/protobuf/config.m4 index 3fdcb00480d4..635cb19a520a 100644 --- a/php/ext/google/protobuf/config.m4 +++ b/php/ext/google/protobuf/config.m4 @@ -4,7 +4,7 @@ if test "$PHP_PROTOBUF" != "no"; then PHP_NEW_EXTENSION( protobuf, - arena.c array.c bundled_php.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c, + arena.c array.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c, $ext_shared) fi diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index 37dd50c1824a..c3ffd3154ec4 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -772,6 +772,7 @@ upb_symtab *DescriptorPool_GetSymbolTable() { return intern->symtab; } + /* * DescriptorPool::getGeneratedPool() * @@ -906,13 +907,38 @@ static void add_name_mappings(const upb_filedef *file) { } } +static void add_descriptor(DescriptorPool *pool, + const google_protobuf_FileDescriptorProto *file) { + upb_strview name = google_protobuf_FileDescriptorProto_name(file); + upb_status status; + const upb_filedef *file_def; + upb_status_clear(&status); + + if (upb_symtab_lookupfile2(pool->symtab, name.data, name.size)) { + // Already added. + fprintf(stderr, "WARNING: file was already added\n"); + return; + } + + // The PHP code generator currently special-cases descriptor.proto. It + // doesn't add it as a dependency even if the proto file actually does + // depend on it. + if (depends_on_descriptor(file)) { + google_protobuf_FileDescriptorProto_getmsgdef(pool->symtab); + } + + file_def = upb_symtab_addfile(pool->symtab, file, &status); + CheckUpbStatus(&status, "Unable to load descriptor"); + add_name_mappings(file_def); +} + /* - * add_name_mappings() + * add_descriptor() * * Adds the given descriptor data to this DescriptorPool. */ -static void add_descriptor(DescriptorPool *pool, const char *data, - int data_len, upb_arena *arena) { +static void add_descriptor_set(DescriptorPool *pool, const char *data, + int data_len, upb_arena *arena) { size_t i, n; google_protobuf_FileDescriptorSet *set; const google_protobuf_FileDescriptorProto* const* files; @@ -928,27 +954,28 @@ static void add_descriptor(DescriptorPool *pool, const char *data, for (i = 0; i < n; i++) { const google_protobuf_FileDescriptorProto* file = files[i]; - upb_strview name = google_protobuf_FileDescriptorProto_name(file); - upb_status status; - const upb_filedef *file_def; - upb_status_clear(&status); - - if (upb_symtab_lookupfile2(pool->symtab, name.data, name.size)) { - // Already added. - continue; - } + add_descriptor(pool, file); + } +} - // The PHP code generator currently special-cases descriptor.proto. It - // doesn't add it as a dependency even if the proto file actually does - // depend on it. - if (depends_on_descriptor(file)) { - google_protobuf_FileDescriptorProto_getmsgdef(pool->symtab); - } +bool DescriptorPool_HasFile(const char *filename) { + DescriptorPool *intern = GetPool(get_generated_pool()); + return upb_symtab_lookupfile(intern->symtab, filename) != NULL; +} + +void DescriptorPool_AddDescriptor(const char *filename, const char *data, + int size) { + upb_arena *arena = upb_arena_new(); + const google_protobuf_FileDescriptorProto *file = + google_protobuf_FileDescriptorProto_parse(data, size, arena); - file_def = upb_symtab_addfile(pool->symtab, file, &status); - CheckUpbStatus(&status, "Unable to load descriptor"); - add_name_mappings(file_def); + if (!file) { + zend_error(E_ERROR, "Failed to parse binary descriptor for %s\n", filename); + return; } + + add_descriptor(GetPool(get_generated_pool()), file); + upb_arena_free(arena); } /* @@ -969,7 +996,7 @@ PHP_METHOD(DescriptorPool, internalAddGeneratedFile) { } arena = upb_arena_new(); - add_descriptor(intern, data, data_len, arena); + add_descriptor_set(intern, data, data_len, arena); upb_arena_free(arena); } diff --git a/php/ext/google/protobuf/def.h b/php/ext/google/protobuf/def.h index 515a83eca7da..2a89cd0fd4e6 100644 --- a/php/ext/google/protobuf/def.h +++ b/php/ext/google/protobuf/def.h @@ -49,6 +49,12 @@ upb_symtab *DescriptorPool_Steal(zval *zv); upb_symtab *DescriptorPool_GetSymbolTable(); +// Returns true if the global descriptor pool already has the given filename. +bool DescriptorPool_HasFile(const char *filename); + +// Adds the given descriptor with the given filename to the global pool. +void DescriptorPool_AddDescriptor(const char *filename, const char *data, int size); + typedef struct Descriptor { zend_object std; const upb_msgdef *msgdef; diff --git a/php/ext/google/protobuf/make-preload.php b/php/ext/google/protobuf/make-preload.php deleted file mode 100644 index 4b1ce7f676fa..000000000000 --- a/php/ext/google/protobuf/make-preload.php +++ /dev/null @@ -1,62 +0,0 @@ - Google\\Protobuf\\BoolValue - $ret = stripSuffix($filename, ".php"); - return str_replace("/", "\\\\", $ret); -} - -function toCSymbolName($filename) { - # Google/Protobuf/BoolValue.php -> Google__Protobuf__BoolValue - $ret = stripSuffix($filename, ".php"); - return str_replace("/", "__", $ret); -} - -$f = fopen($output, "w"); - -fwrite($f, "#include \"bundled_php.h\"\n"); -fwrite($f, "#include \"stdlib.h\"\n"); - -foreach ($filenames as $filename) { - print("Reading $filename...\n"); - $contents = file_get_contents($filename); - $contents = substr($contents, 5); // Strip diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index b2a03063f52d..8dd8edf3c9a8 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -36,6 +36,7 @@ // This is not self-contained: it must be after other Zend includes. #include +#include #include "arena.h" #include "array.h" @@ -108,6 +109,43 @@ static const upb_fielddef *get_field(Message *msg, PROTO_STR *member) { return f; } +static void Message_get(Message *intern, const upb_fielddef *f, zval *rv) { + upb_arena *arena = Arena_Get(&intern->arena); + + if (upb_fielddef_ismap(f)) { + upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena); + MapField_GetPhpWrapper(rv, msgval.map, f, &intern->arena); + } else if (upb_fielddef_isseq(f)) { + upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena); + RepeatedField_GetPhpWrapper(rv, msgval.array, f, &intern->arena); + } else { + upb_msgval msgval = upb_msg_get(intern->msg, f); + const Descriptor *subdesc = Descriptor_GetFromFieldDef(f); + Convert_UpbToPhp(msgval, rv, upb_fielddef_type(f), subdesc, &intern->arena); + } +} + +static bool Message_set(Message *intern, const upb_fielddef *f, zval *val) { + upb_arena *arena = Arena_Get(&intern->arena); + upb_msgval msgval; + + if (upb_fielddef_ismap(f)) { + msgval.map_val = MapField_GetUpbMap(val, f, arena); + if (!msgval.map_val) return false; + } else if (upb_fielddef_isseq(f)) { + msgval.array_val = RepeatedField_GetUpbArray(val, f, arena); + if (!msgval.array_val) return false; + } else { + upb_fieldtype_t type = upb_fielddef_type(f); + const Descriptor *subdesc = Descriptor_GetFromFieldDef(f); + bool ok = Convert_PhpToUpb(val, &msgval, type, subdesc, arena); + if (!ok) return false; + } + + upb_msg_set(intern->msg, f, msgval, arena); + return true; +} + static bool MessageEq(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m); /** @@ -271,6 +309,7 @@ static void Message_unset_property(PROTO_VAL *obj, PROTO_STR *member, upb_msg_clearfield(intern->msg, f); } + /** * Message_read_property() * @@ -293,22 +332,9 @@ static zval *Message_read_property(PROTO_VAL *obj, PROTO_STR *member, int type, void **cache_slot, zval *rv) { Message* intern = PROTO_MSG_P(obj); const upb_fielddef *f = get_field(intern, member); - upb_arena *arena = Arena_Get(&intern->arena); if (!f) return NULL; - - if (upb_fielddef_ismap(f)) { - upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena); - MapField_GetPhpWrapper(rv, msgval.map, f, &intern->arena); - } else if (upb_fielddef_isseq(f)) { - upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena); - RepeatedField_GetPhpWrapper(rv, msgval.array, f, &intern->arena); - } else { - upb_msgval msgval = upb_msg_get(intern->msg, f); - const Descriptor *subdesc = Descriptor_GetFromFieldDef(f); - Convert_UpbToPhp(msgval, rv, upb_fielddef_type(f), subdesc, &intern->arena); - } - + Message_get(intern, f, rv); return rv; } @@ -337,37 +363,20 @@ static PROTO_RETURN_VAL Message_write_property( PROTO_VAL *obj, PROTO_STR *member, zval *val, void **cache_slot) { Message* intern = PROTO_MSG_P(obj); const upb_fielddef *f = get_field(intern, member); - upb_arena *arena = Arena_Get(&intern->arena); - upb_msgval msgval; - if (!f) goto error; - - if (upb_fielddef_ismap(f)) { - msgval.map_val = MapField_GetUpbMap(val, f, arena); - if (!msgval.map_val) goto error; - } else if (upb_fielddef_isseq(f)) { - msgval.array_val = RepeatedField_GetUpbArray(val, f, arena); - if (!msgval.array_val) goto error; - } else { - upb_fieldtype_t type = upb_fielddef_type(f); - const Descriptor *subdesc = Descriptor_GetFromFieldDef(f); - bool ok = Convert_PhpToUpb(val, &msgval, type, subdesc, arena); - if (!ok) goto error; - } - - upb_msg_set(intern->msg, f, msgval, arena); + if (f && Message_set(intern, f, val)) { #if PHP_VERSION_ID < 704000 - return; + return; #else - return val; + return val; #endif - -error: + } else { #if PHP_VERSION_ID < 704000 - return; + return; #else - return &EG(error_zval); + return &EG(error_zval); #endif + } } /** @@ -1009,6 +1018,151 @@ static zend_function_entry Message_methods[] = { ZEND_FE_END }; +// Well-known types //////////////////////////////////////////////////////////// + +static const char TYPE_URL_PREFIX[] = "type.googleapis.com/"; + +static upb_msgval Message_getval(Message *intern, const char *field_name) { + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, field_name); + return upb_msg_get(intern->msg, f); +} + +PHP_METHOD(google_protobuf_Any, unpack) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + upb_strview type_url = Message_getval(intern, "type_url").str_val; + upb_strview value = Message_getval(intern, "value").str_val; + size_t prefix_len = strlen(TYPE_URL_PREFIX); + upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_msgdef *m; + Descriptor *desc; + zend_class_entry *klass; + zval ret; + + // Ensure that type_url has TYPE_URL_PREFIX as a prefix. + if (type_url.size < prefix_len || + strncmp(TYPE_URL_PREFIX, type_url.data, prefix_len) != 0) { + zend_throw_exception( + NULL, "Type url needs to be type.googleapis.com/fully-qualified", + 0 TSRMLS_CC); + return; + } + + type_url.size -= prefix_len; + type_url.data += prefix_len; + m = upb_symtab_lookupmsg2(symtab, type_url.data, type_url.size); + + if (m == NULL) { + zend_throw_exception( + NULL, "Specified message in any hasn't been added to descriptor pool", + 0 TSRMLS_CC); + return; + } + + desc = Descriptor_GetFromMessageDef(m); + klass = desc->class_entry; + ZVAL_OBJ(&ret, klass->create_object(klass)); + Message *msg = (Message*)Z_OBJ_P(&ret); + + // Get value. + if (!upb_decode(value.data, value.size, msg->msg, + upb_msgdef_layout(desc->msgdef), Arena_Get(&msg->arena))) { + zend_throw_exception_ex(NULL, 0, "Error occurred during parsing"); + return; + } + + // Fuse since the parsed message could alias "value". + upb_arena_fuse(Arena_Get(&intern->arena), Arena_Get(&msg->arena)); + + RETURN_ZVAL(&ret, 1, 0); +} + +/* +PHP_METHOD(Any, pack) { + zval* val; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &val) == + FAILURE) { + return; + } + + if (!instanceof_function(Z_OBJCE_P(val), message_ce)) { + zend_error(E_USER_ERROR, "Given value is not an instance of Message."); + return; + } + + // Set value by serialized data. + zval data; + serialize_to_string(val, &data TSRMLS_CC); + + zval member; + PHP_PROTO_ZVAL_STRING(&member, "value", 1); + + PHP_PROTO_FAKE_SCOPE_BEGIN(any_type); + message_handlers->write_property(getThis(), &member, &data, + NULL PHP_PROTO_TSRMLS_CC); + zval_dtor(&data); + zval_dtor(&member); + PHP_PROTO_FAKE_SCOPE_END; + + // Set type url. + DescriptorInternal* desc = get_ce_desc(Z_OBJCE_P(val)); + const char* fully_qualified_name = upb_msgdef_fullname(desc->msgdef); + size_t type_url_len = + strlen(TYPE_URL_PREFIX) + strlen(fully_qualified_name) + 1; + char* type_url = ALLOC_N(char, type_url_len); + sprintf(type_url, "%s%s", TYPE_URL_PREFIX, fully_qualified_name); + zval type_url_php; + PHP_PROTO_ZVAL_STRING(&type_url_php, type_url, 1); + PHP_PROTO_ZVAL_STRING(&member, "type_url", 1); + + PHP_PROTO_FAKE_SCOPE_RESTART(any_type); + message_handlers->write_property(getThis(), &member, &type_url_php, + NULL PHP_PROTO_TSRMLS_CC); + zval_dtor(&type_url_php); + zval_dtor(&member); + PHP_PROTO_FAKE_SCOPE_END; + FREE(type_url); +} + +PHP_METHOD(Any, is) { + zend_class_entry *klass = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "C", &klass) == + FAILURE) { + return; + } + + DescriptorInternal* desc = get_ce_desc(klass); + if (desc == NULL) { + RETURN_BOOL(false); + } + + // Create corresponded type url. + const char* fully_qualified_name = upb_msgdef_fullname(desc->msgdef); + size_t type_url_len = + strlen(TYPE_URL_PREFIX) + strlen(fully_qualified_name) + 1; + char* type_url = ALLOC_N(char, type_url_len); + sprintf(type_url, "%s%s", TYPE_URL_PREFIX, fully_qualified_name); + + // Fetch stored type url. + zval member; + PHP_PROTO_ZVAL_STRING(&member, "type_url", 1); + PHP_PROTO_FAKE_SCOPE_BEGIN(any_type); + zval* value = + php_proto_message_read_property(getThis(), &member PHP_PROTO_TSRMLS_CC); + zval_dtor(&member); + PHP_PROTO_FAKE_SCOPE_END; + + // Compare two type url. + bool is = strcmp(type_url, Z_STRVAL_P(value)) == 0; + FREE(type_url); + + RETURN_BOOL(is); +} +*/ + +#include "wkt.inc" + /** * Message_ModuleInit() * @@ -1033,4 +1187,6 @@ void Message_ModuleInit() { h->unset_property = Message_unset_property; h->get_properties = Message_get_properties; h->get_property_ptr_ptr = Message_get_property_ptr_ptr; + + WellKnownTypes_ModuleInit(); /* From wkt.inc. */ } diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index d1fc36663dfc..2ed7114e7fdd 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -81,6 +81,10 @@ #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) #define UPB_NOINLINE __attribute__((noinline)) #define UPB_NORETURN __attribute__((__noreturn__)) +#elif defined(_MSC_VER) +#define UPB_NOINLINE +#define UPB_FORCEINLINE +#define UPB_NORETURN __declspec(noreturn) #else /* !defined(__GNUC__) */ #define UPB_FORCEINLINE #define UPB_NOINLINE @@ -143,7 +147,7 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); #elif defined _MSC_VER #define UPB_ASSUME(expr) if (!(expr)) __assume(0) #else -#define UPB_ASSUME(expr) do {} if (false && (expr)) +#define UPB_ASSUME(expr) do {} while (false && (expr)) #endif #else #define UPB_ASSUME(expr) assert(expr) @@ -323,8 +327,6 @@ typedef struct { typedef union { bool bool_val; - int32_t int32_val; - int64_t int64_val; uint32_t uint32_val; uint64_t uint64_val; upb_strview str_val; @@ -424,14 +426,21 @@ static void decode_munge(int type, wireval *val) { break; case UPB_DESCRIPTOR_TYPE_SINT32: { uint32_t n = val->uint32_val; - val->int32_val = (n >> 1) ^ -(int32_t)(n & 1); + val->uint32_val = (n >> 1) ^ -(int32_t)(n & 1); break; } case UPB_DESCRIPTOR_TYPE_SINT64: { uint64_t n = val->uint64_val; - val->int64_val = (n >> 1) ^ -(int64_t)(n & 1); + val->uint64_val = (n >> 1) ^ -(int64_t)(n & 1); break; } + case UPB_DESCRIPTOR_TYPE_INT32: + case UPB_DESCRIPTOR_TYPE_UINT32: + if (!_upb_isle()) { + /* The next stage will memcpy(dst, &val, 4) */ + val->uint32_val = val->uint64_val; + } + break; } } @@ -607,7 +616,7 @@ static void decode_tomap(upb_decstate *d, upb_msg *msg, if (entry->fields[1].descriptortype == UPB_DESCRIPTOR_TYPE_MESSAGE || entry->fields[1].descriptortype == UPB_DESCRIPTOR_TYPE_GROUP) { /* Create proactively to handle the case where it doesn't appear. */ - ent.v.val.val = (uint64_t)_upb_msg_new(entry->submsgs[0], d->arena); + ent.v.val = upb_value_ptr(_upb_msg_new(entry->submsgs[0], d->arena)); } decode_tosubmsg(d, &ent.k, layout, field, val.str_val); @@ -698,14 +707,16 @@ static const char *decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg, break; case UPB_WIRE_TYPE_32BIT: if (d->limit - ptr < 4) decode_err(d); - memcpy(&val, ptr, 4); + memcpy(&val.uint32_val, ptr, 4); + val.uint32_val = _upb_be_swap32(val.uint32_val); ptr += 4; op = OP_SCALAR_LG2(2); if (((1 << field->descriptortype) & fixed32_ok) == 0) goto unknown; break; case UPB_WIRE_TYPE_64BIT: if (d->limit - ptr < 8) decode_err(d); - memcpy(&val, ptr, 8); + memcpy(&val.uint64_val, ptr, 8); + val.uint64_val = _upb_be_swap64(val.uint64_val); ptr += 8; op = OP_SCALAR_LG2(3); if (((1 << field->descriptortype) & fixed64_ok) == 0) goto unknown; @@ -725,7 +736,7 @@ static const char *decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg, break; } case UPB_WIRE_TYPE_START_GROUP: - val.int32_val = field_number; + val.uint32_val = field_number; op = OP_SUBMSG; if (field->descriptortype != UPB_DTYPE_GROUP) goto unknown; break; @@ -794,30 +805,30 @@ bool upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l, /* We encode backwards, to avoid pre-computing lengths (one-pass encode). */ +#include #include #define UPB_PB_VARINT_MAX_LEN 10 -#define CHK(x) do { if (!(x)) { return false; } } while(0) -static size_t upb_encode_varint(uint64_t val, char *buf) { - size_t i; - if (val < 128) { buf[0] = val; return 1; } - i = 0; - while (val) { +UPB_NOINLINE +static size_t encode_varint64(uint64_t val, char *buf) { + size_t i = 0; + do { uint8_t byte = val & 0x7fU; val >>= 7; if (val) byte |= 0x80U; buf[i++] = byte; - } + } while (val); return i; } -static uint32_t upb_zzencode_32(int32_t n) { return ((uint32_t)n << 1) ^ (n >> 31); } -static uint64_t upb_zzencode_64(int64_t n) { return ((uint64_t)n << 1) ^ (n >> 63); } +static uint32_t encode_zz32(int32_t n) { return ((uint32_t)n << 1) ^ (n >> 31); } +static uint64_t encode_zz64(int64_t n) { return ((uint64_t)n << 1) ^ (n >> 63); } typedef struct { + jmp_buf err; upb_alloc *alloc; char *buf, *ptr, *limit; } upb_encstate; @@ -830,11 +841,15 @@ static size_t upb_roundup_pow2(size_t bytes) { return ret; } -static bool upb_encode_growbuffer(upb_encstate *e, size_t bytes) { +UPB_NORETURN static void encode_err(upb_encstate *e) { longjmp(e->err, 1); } + +UPB_NOINLINE +static void encode_growbuffer(upb_encstate *e, size_t bytes) { size_t old_size = e->limit - e->buf; size_t new_size = upb_roundup_pow2(bytes + (e->limit - e->ptr)); char *new_buf = upb_realloc(e->alloc, e->buf, old_size, new_size); - CHK(new_buf); + + if (!new_buf) encode_err(e); /* We want previous data at the end, realloc() put it at the beginning. */ if (old_size > 0) { @@ -844,99 +859,115 @@ static bool upb_encode_growbuffer(upb_encstate *e, size_t bytes) { e->ptr = new_buf + new_size - (e->limit - e->ptr); e->limit = new_buf + new_size; e->buf = new_buf; - return true; + + e->ptr -= bytes; } /* Call to ensure that at least "bytes" bytes are available for writing at * e->ptr. Returns false if the bytes could not be allocated. */ -static bool upb_encode_reserve(upb_encstate *e, size_t bytes) { - CHK(UPB_LIKELY((size_t)(e->ptr - e->buf) >= bytes) || - upb_encode_growbuffer(e, bytes)); +UPB_FORCEINLINE +static void encode_reserve(upb_encstate *e, size_t bytes) { + if ((size_t)(e->ptr - e->buf) < bytes) { + encode_growbuffer(e, bytes); + return; + } e->ptr -= bytes; - return true; } /* Writes the given bytes to the buffer, handling reserve/advance. */ -static bool upb_put_bytes(upb_encstate *e, const void *data, size_t len) { - if (len == 0) return true; - CHK(upb_encode_reserve(e, len)); +static void encode_bytes(upb_encstate *e, const void *data, size_t len) { + if (len == 0) return; /* memcpy() with zero size is UB */ + encode_reserve(e, len); memcpy(e->ptr, data, len); - return true; } -static bool upb_put_fixed64(upb_encstate *e, uint64_t val) { - /* TODO(haberman): byte-swap for big endian. */ - return upb_put_bytes(e, &val, sizeof(uint64_t)); +static void encode_fixed64(upb_encstate *e, uint64_t val) { + val = _upb_be_swap64(val); + encode_bytes(e, &val, sizeof(uint64_t)); } -static bool upb_put_fixed32(upb_encstate *e, uint32_t val) { - /* TODO(haberman): byte-swap for big endian. */ - return upb_put_bytes(e, &val, sizeof(uint32_t)); +static void encode_fixed32(upb_encstate *e, uint32_t val) { + val = _upb_be_swap32(val); + encode_bytes(e, &val, sizeof(uint32_t)); } -static bool upb_put_varint(upb_encstate *e, uint64_t val) { +UPB_NOINLINE +static void encode_longvarint(upb_encstate *e, uint64_t val) { size_t len; char *start; - CHK(upb_encode_reserve(e, UPB_PB_VARINT_MAX_LEN)); - len = upb_encode_varint(val, e->ptr); + + encode_reserve(e, UPB_PB_VARINT_MAX_LEN); + len = encode_varint64(val, e->ptr); start = e->ptr + UPB_PB_VARINT_MAX_LEN - len; memmove(start, e->ptr, len); e->ptr = start; - return true; } -static bool upb_put_double(upb_encstate *e, double d) { +UPB_FORCEINLINE +static void encode_varint(upb_encstate *e, uint64_t val) { + if (val < 128 && e->ptr != e->buf) { + --e->ptr; + *e->ptr = val; + } else { + encode_longvarint(e, val); + } +} + +static void encode_double(upb_encstate *e, double d) { uint64_t u64; UPB_ASSERT(sizeof(double) == sizeof(uint64_t)); memcpy(&u64, &d, sizeof(uint64_t)); - return upb_put_fixed64(e, u64); + encode_fixed64(e, u64); } -static bool upb_put_float(upb_encstate *e, float d) { +static void encode_float(upb_encstate *e, float d) { uint32_t u32; UPB_ASSERT(sizeof(float) == sizeof(uint32_t)); memcpy(&u32, &d, sizeof(uint32_t)); - return upb_put_fixed32(e, u32); + encode_fixed32(e, u32); } -static bool upb_put_tag(upb_encstate *e, int field_number, int wire_type) { - return upb_put_varint(e, (field_number << 3) | wire_type); +static void encode_tag(upb_encstate *e, int field_number, int wire_type) { + encode_varint(e, (field_number << 3) | wire_type); } -static bool upb_put_fixedarray(upb_encstate *e, const upb_array *arr, +static void encode_fixedarray(upb_encstate *e, const upb_array *arr, size_t elem_size, uint32_t tag) { size_t bytes = arr->len * elem_size; const char* data = _upb_array_constptr(arr); const char* ptr = data + bytes - elem_size; if (tag) { while (true) { - CHK(upb_put_bytes(e, ptr, elem_size) && upb_put_varint(e, tag)); + encode_bytes(e, ptr, elem_size); + encode_varint(e, tag); if (ptr == data) break; ptr -= elem_size; } - return true; } else { - return upb_put_bytes(e, data, bytes) && upb_put_varint(e, bytes); + encode_bytes(e, data, bytes); } } -bool upb_encode_message(upb_encstate *e, const char *msg, - const upb_msglayout *m, size_t *size); +static void encode_message(upb_encstate *e, const char *msg, + const upb_msglayout *m, size_t *size); -static bool upb_encode_scalarfield(upb_encstate *e, const void *_field_mem, - const upb_msglayout *m, - const upb_msglayout_field *f, - bool skip_zero_value) { +static void encode_scalar(upb_encstate *e, const void *_field_mem, + const upb_msglayout *m, const upb_msglayout_field *f, + bool skip_zero_value) { const char *field_mem = _field_mem; -#define CASE(ctype, type, wire_type, encodeval) do { \ - ctype val = *(ctype*)field_mem; \ - if (skip_zero_value && val == 0) { \ - return true; \ - } \ - return upb_put_ ## type(e, encodeval) && \ - upb_put_tag(e, f->number, wire_type); \ -} while(0) + int wire_type; + +#define CASE(ctype, type, wtype, encodeval) \ + { \ + ctype val = *(ctype *)field_mem; \ + if (skip_zero_value && val == 0) { \ + return; \ + } \ + encode_##type(e, encodeval); \ + wire_type = wtype; \ + break; \ + } switch (f->descriptortype) { case UPB_DESCRIPTOR_TYPE_DOUBLE: @@ -960,90 +991,91 @@ static bool upb_encode_scalarfield(upb_encstate *e, const void *_field_mem, case UPB_DESCRIPTOR_TYPE_BOOL: CASE(bool, varint, UPB_WIRE_TYPE_VARINT, val); case UPB_DESCRIPTOR_TYPE_SINT32: - CASE(int32_t, varint, UPB_WIRE_TYPE_VARINT, upb_zzencode_32(val)); + CASE(int32_t, varint, UPB_WIRE_TYPE_VARINT, encode_zz32(val)); case UPB_DESCRIPTOR_TYPE_SINT64: - CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT, upb_zzencode_64(val)); + CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT, encode_zz64(val)); case UPB_DESCRIPTOR_TYPE_STRING: case UPB_DESCRIPTOR_TYPE_BYTES: { upb_strview view = *(upb_strview*)field_mem; if (skip_zero_value && view.size == 0) { - return true; + return; } - return upb_put_bytes(e, view.data, view.size) && - upb_put_varint(e, view.size) && - upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); + encode_bytes(e, view.data, view.size); + encode_varint(e, view.size); + wire_type = UPB_WIRE_TYPE_DELIMITED; + break; } case UPB_DESCRIPTOR_TYPE_GROUP: { size_t size; void *submsg = *(void **)field_mem; const upb_msglayout *subm = m->submsgs[f->submsg_index]; if (submsg == NULL) { - return true; + return; } - return upb_put_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP) && - upb_encode_message(e, submsg, subm, &size) && - upb_put_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP); + encode_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP); + encode_message(e, submsg, subm, &size); + wire_type = UPB_WIRE_TYPE_START_GROUP; + break; } case UPB_DESCRIPTOR_TYPE_MESSAGE: { size_t size; void *submsg = *(void **)field_mem; const upb_msglayout *subm = m->submsgs[f->submsg_index]; if (submsg == NULL) { - return true; + return; } - return upb_encode_message(e, submsg, subm, &size) && - upb_put_varint(e, size) && - upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); + encode_message(e, submsg, subm, &size); + encode_varint(e, size); + wire_type = UPB_WIRE_TYPE_DELIMITED; + break; } + default: + UPB_UNREACHABLE(); } #undef CASE - UPB_UNREACHABLE(); + + encode_tag(e, f->number, wire_type); } -static bool upb_encode_array(upb_encstate *e, const char *field_mem, - const upb_msglayout *m, - const upb_msglayout_field *f) { +static void encode_array(upb_encstate *e, const char *field_mem, + const upb_msglayout *m, const upb_msglayout_field *f) { const upb_array *arr = *(const upb_array**)field_mem; bool packed = f->label == _UPB_LABEL_PACKED; + size_t pre_len = e->limit - e->ptr; if (arr == NULL || arr->len == 0) { - return true; + return; } #define VARINT_CASE(ctype, encode) \ { \ const ctype *start = _upb_array_constptr(arr); \ const ctype *ptr = start + arr->len; \ - size_t pre_len = e->limit - e->ptr; \ uint32_t tag = packed ? 0 : (f->number << 3) | UPB_WIRE_TYPE_VARINT; \ do { \ ptr--; \ - CHK(upb_put_varint(e, encode)); \ - if (tag) CHK(upb_put_varint(e, tag)); \ + encode_varint(e, encode); \ + if (tag) encode_varint(e, tag); \ } while (ptr != start); \ - if (!tag) CHK(upb_put_varint(e, e->limit - e->ptr - pre_len)); \ } \ - break; \ - do { \ - ; \ - } while (0) + break; #define TAG(wire_type) (packed ? 0 : (f->number << 3 | wire_type)) switch (f->descriptortype) { case UPB_DESCRIPTOR_TYPE_DOUBLE: - CHK(upb_put_fixedarray(e, arr, sizeof(double), TAG(UPB_WIRE_TYPE_64BIT))); + encode_fixedarray(e, arr, sizeof(double), TAG(UPB_WIRE_TYPE_64BIT)); break; case UPB_DESCRIPTOR_TYPE_FLOAT: - CHK(upb_put_fixedarray(e, arr, sizeof(float), TAG(UPB_WIRE_TYPE_32BIT))); + encode_fixedarray(e, arr, sizeof(float), TAG(UPB_WIRE_TYPE_32BIT)); break; case UPB_DESCRIPTOR_TYPE_SFIXED64: case UPB_DESCRIPTOR_TYPE_FIXED64: - CHK(upb_put_fixedarray(e, arr, sizeof(uint64_t), TAG(UPB_WIRE_TYPE_64BIT))); + encode_fixedarray(e, arr, sizeof(uint64_t), TAG(UPB_WIRE_TYPE_64BIT)); break; case UPB_DESCRIPTOR_TYPE_FIXED32: case UPB_DESCRIPTOR_TYPE_SFIXED32: - CHK(upb_put_fixedarray(e, arr, sizeof(uint32_t), TAG(UPB_WIRE_TYPE_32BIT))); + encode_fixedarray(e, arr, sizeof(uint32_t), TAG(UPB_WIRE_TYPE_32BIT)); break; case UPB_DESCRIPTOR_TYPE_INT64: case UPB_DESCRIPTOR_TYPE_UINT64: @@ -1056,20 +1088,20 @@ static bool upb_encode_array(upb_encstate *e, const char *field_mem, case UPB_DESCRIPTOR_TYPE_BOOL: VARINT_CASE(bool, *ptr); case UPB_DESCRIPTOR_TYPE_SINT32: - VARINT_CASE(int32_t, upb_zzencode_32(*ptr)); + VARINT_CASE(int32_t, encode_zz32(*ptr)); case UPB_DESCRIPTOR_TYPE_SINT64: - VARINT_CASE(int64_t, upb_zzencode_64(*ptr)); + VARINT_CASE(int64_t, encode_zz64(*ptr)); case UPB_DESCRIPTOR_TYPE_STRING: case UPB_DESCRIPTOR_TYPE_BYTES: { const upb_strview *start = _upb_array_constptr(arr); const upb_strview *ptr = start + arr->len; do { ptr--; - CHK(upb_put_bytes(e, ptr->data, ptr->size) && - upb_put_varint(e, ptr->size) && - upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED)); + encode_bytes(e, ptr->data, ptr->size); + encode_varint(e, ptr->size); + encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); } while (ptr != start); - return true; + return; } case UPB_DESCRIPTOR_TYPE_GROUP: { const void *const*start = _upb_array_constptr(arr); @@ -1078,11 +1110,11 @@ static bool upb_encode_array(upb_encstate *e, const char *field_mem, do { size_t size; ptr--; - CHK(upb_put_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP) && - upb_encode_message(e, *ptr, subm, &size) && - upb_put_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP)); + encode_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP); + encode_message(e, *ptr, subm, &size); + encode_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP); } while (ptr != start); - return true; + return; } case UPB_DESCRIPTOR_TYPE_MESSAGE: { const void *const*start = _upb_array_constptr(arr); @@ -1091,31 +1123,30 @@ static bool upb_encode_array(upb_encstate *e, const char *field_mem, do { size_t size; ptr--; - CHK(upb_encode_message(e, *ptr, subm, &size) && - upb_put_varint(e, size) && - upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED)); + encode_message(e, *ptr, subm, &size); + encode_varint(e, size); + encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); } while (ptr != start); - return true; + return; } } #undef VARINT_CASE if (packed) { - CHK(upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED)); + encode_varint(e, e->limit - e->ptr - pre_len); + encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); } - return true; } -static bool upb_encode_map(upb_encstate *e, const char *field_mem, - const upb_msglayout *m, - const upb_msglayout_field *f) { +static void encode_map(upb_encstate *e, const char *field_mem, + const upb_msglayout *m, const upb_msglayout_field *f) { const upb_map *map = *(const upb_map**)field_mem; const upb_msglayout *entry = m->submsgs[f->submsg_index]; const upb_msglayout_field *key_field = &entry->fields[0]; const upb_msglayout_field *val_field = &entry->fields[1]; upb_strtable_iter i; if (map == NULL) { - return true; + return; } upb_strtable_begin(&i, &map->table); @@ -1127,59 +1158,57 @@ static bool upb_encode_map(upb_encstate *e, const char *field_mem, upb_map_entry ent; _upb_map_fromkey(key, &ent.k, map->key_size); _upb_map_fromvalue(val, &ent.v, map->val_size); - CHK(upb_encode_scalarfield(e, &ent.v, entry, val_field, false)); - CHK(upb_encode_scalarfield(e, &ent.k, entry, key_field, false)); + encode_scalar(e, &ent.v, entry, val_field, false); + encode_scalar(e, &ent.k, entry, key_field, false); size = (e->limit - e->ptr) - pre_len; - CHK(upb_put_varint(e, size)); - CHK(upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED)); + encode_varint(e, size); + encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); } - - return true; } +static void encode_scalarfield(upb_encstate *e, const char *msg, + const upb_msglayout *m, + const upb_msglayout_field *f) { + bool skip_empty = false; + if (f->presence == 0) { + /* Proto3 presence. */ + skip_empty = true; + } else if (f->presence > 0) { + /* Proto2 presence: hasbit. */ + if (!_upb_hasbit_field(msg, f)) return; + } else { + /* Field is in a oneof. */ + if (_upb_getoneofcase_field(msg, f) != f->number) return; + } + encode_scalar(e, msg + f->offset, m, f, skip_empty); +} -bool upb_encode_message(upb_encstate *e, const char *msg, - const upb_msglayout *m, size_t *size) { - int i; +static void encode_message(upb_encstate *e, const char *msg, + const upb_msglayout *m, size_t *size) { size_t pre_len = e->limit - e->ptr; const char *unknown; size_t unknown_size; + const upb_msglayout_field *f = &m->fields[m->field_count]; + const upb_msglayout_field *first = &m->fields[0]; unknown = upb_msg_getunknown(msg, &unknown_size); if (unknown) { - upb_put_bytes(e, unknown, unknown_size); + encode_bytes(e, unknown, unknown_size); } - for (i = m->field_count - 1; i >= 0; i--) { - const upb_msglayout_field *f = &m->fields[i]; - + while (f != first) { + f--; if (_upb_isrepeated(f)) { - CHK(upb_encode_array(e, msg + f->offset, m, f)); + encode_array(e, msg + f->offset, m, f); } else if (f->label == _UPB_LABEL_MAP) { - CHK(upb_encode_map(e, msg + f->offset, m, f)); + encode_map(e, msg + f->offset, m, f); } else { - bool skip_empty = false; - if (f->presence == 0) { - /* Proto3 presence. */ - skip_empty = true; - } else if (f->presence > 0) { - /* Proto2 presence: hasbit. */ - if (!_upb_hasbit_field(msg, f)) { - continue; - } - } else { - /* Field is in a oneof. */ - if (_upb_getoneofcase_field(msg, f) != f->number) { - continue; - } - } - CHK(upb_encode_scalarfield(e, msg + f->offset, m, f, skip_empty)); + encode_scalarfield(e, msg, m, f); } } *size = (e->limit - e->ptr) - pre_len; - return true; } char *upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, @@ -1190,11 +1219,13 @@ char *upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, e.limit = NULL; e.ptr = NULL; - if (!upb_encode_message(&e, msg, m, size)) { + if (setjmp(e.err)) { *size = 0; return NULL; } + encode_message(&e, msg, m, size); + *size = e.limit - e.ptr; if (*size == 0) { @@ -1206,8 +1237,6 @@ char *upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, } } -#undef CHK - @@ -3063,7 +3092,7 @@ extern const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit; extern const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit; extern const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit; -static const upb_msglayout *layouts[27] = { +static const upb_msglayout *google_protobuf_descriptor_proto_layouts[27] = { &google_protobuf_FileDescriptorSet_msginit, &google_protobuf_FileDescriptorProto_msginit, &google_protobuf_DescriptorProto_msginit, @@ -3093,7 +3122,8 @@ static const upb_msglayout *layouts[27] = { &google_protobuf_GeneratedCodeInfo_Annotation_msginit, }; -static const char descriptor[7619] = {'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'd', 'e', 's', 'c', 'r', 'i', 'p', +static const char google_protobuf_descriptor_proto_descriptor[7619] = { +'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', 'M', '\n', '\021', 'F', 'i', 'l', 'e', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'S', 'e', 't', '\022', '8', '\n', '\004', 'f', 'i', 'l', 'e', '\030', '\001', ' ', '\003', '(', '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', @@ -3400,15 +3430,15 @@ static const char descriptor[7619] = {'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', ' 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'R', 'e', 'f', 'l', 'e', 'c', 't', 'i', 'o', 'n', }; -static upb_def_init *deps[1] = { +static upb_def_init *google_protobuf_descriptor_proto_deps[1] = { NULL }; -upb_def_init google_protobuf_descriptor_proto_upbdefinit = { - deps, - layouts, +upb_def_init google_protobuf_descriptor_proto_definit = { + google_protobuf_descriptor_proto_deps, + google_protobuf_descriptor_proto_layouts, "google/protobuf/descriptor.proto", - UPB_STRVIEW_INIT(descriptor, 7619) + UPB_STRVIEW_INIT(google_protobuf_descriptor_proto_descriptor, 7619) }; @@ -5666,11 +5696,7 @@ const upb_fielddef *upb_msg_whichoneof(const upb_msg *msg, if (upb_oneof_done(&i)) return false; f = upb_oneof_iter_field(&i); field = upb_fielddef_layout(f); - if (in_oneof(field)) { - oneof_case = _upb_getoneofcase_field(msg, field); - } else { - return _upb_hasbit_field(msg, field) ? f : NULL; - } + oneof_case = _upb_getoneofcase_field(msg, field); return oneof_case ? upb_msgdef_itof(m, oneof_case) : NULL; } diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index 666ec76d05e5..973635214edc 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -80,6 +80,10 @@ #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) #define UPB_NOINLINE __attribute__((noinline)) #define UPB_NORETURN __attribute__((__noreturn__)) +#elif defined(_MSC_VER) +#define UPB_NOINLINE +#define UPB_FORCEINLINE +#define UPB_NORETURN __declspec(noreturn) #else /* !defined(__GNUC__) */ #define UPB_FORCEINLINE #define UPB_NOINLINE @@ -142,7 +146,7 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); #elif defined _MSC_VER #define UPB_ASSUME(expr) if (!(expr)) __assume(0) #else -#define UPB_ASSUME(expr) do {} if (false && (expr)) +#define UPB_ASSUME(expr) do {} while (false && (expr)) #endif #else #define UPB_ASSUME(expr) assert(expr) @@ -213,7 +217,7 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); ** store pointers or integers of at least 32 bits (upb isn't really useful on ** systems where sizeof(void*) < 4). ** -** The table must be homogeneous (all values of the same type). In debug +** The table must be homogenous (all values of the same type). In debug ** mode, we check this on insert and lookup. */ @@ -496,6 +500,32 @@ typedef enum { #define UPB_MAP_BEGIN ((size_t)-1) +UPB_INLINE bool _upb_isle(void) { + int x = 1; + return *(char*)&x == 1; +} + +UPB_INLINE uint32_t _upb_be_swap32(uint32_t val) { + if (_upb_isle()) { + return val; + } else { + return ((val & 0xff) << 24) | ((val & 0xff00) << 8) | + ((val & 0xff0000ULL) >> 8) | ((val & 0xff000000ULL) >> 24); + } +} + +UPB_INLINE uint64_t _upb_be_swap64(uint64_t val) { + if (_upb_isle()) { + return val; + } else { + return ((val & 0xff) << 56) | ((val & 0xff00) << 40) | + ((val & 0xff0000) << 24) | ((val & 0xff000000) << 8) | + ((val & 0xff00000000ULL) >> 8) | ((val & 0xff0000000000ULL) >> 24) | + ((val & 0xff000000000000ULL) >> 40) | + ((val & 0xff00000000000000ULL) >> 56); + } +} + #ifdef __cplusplus } /* extern "C" */ @@ -1251,7 +1281,7 @@ UPB_INLINE upb_value _upb_map_tovalue(const void *val, size_t size, if (size == UPB_MAPTYPE_STRING) { upb_strview *strp = (upb_strview*)upb_arena_malloc(a, sizeof(*strp)); *strp = *(upb_strview*)val; - memcpy(&ret, &strp, sizeof(strp)); + ret = upb_value_ptr(strp); } else { memcpy(&ret, val, size); } @@ -1382,7 +1412,7 @@ UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val, size_t size) /* This is like _upb_map_tovalue() except the entry already exists so we can * reuse the allocated upb_strview for string fields. */ if (size == UPB_MAPTYPE_STRING) { - upb_strview *strp = (upb_strview*)ent->val.val; + upb_strview *strp = (upb_strview*)(uintptr_t)ent->val.val; memcpy(strp, val, sizeof(*strp)); } else { memcpy(&ent->val.val, val, size); @@ -3489,140 +3519,140 @@ extern "C" { -extern upb_def_init google_protobuf_descriptor_proto_upbdefinit; +extern upb_def_init google_protobuf_descriptor_proto_definit; UPB_INLINE const upb_msgdef *google_protobuf_FileDescriptorSet_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorSet"); } UPB_INLINE const upb_msgdef *google_protobuf_FileDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_DescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_DescriptorProto_ExtensionRange_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ExtensionRange"); } UPB_INLINE const upb_msgdef *google_protobuf_DescriptorProto_ReservedRange_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ReservedRange"); } UPB_INLINE const upb_msgdef *google_protobuf_ExtensionRangeOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.ExtensionRangeOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_FieldDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.FieldDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_OneofDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.OneofDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumDescriptorProto_EnumReservedRange_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto.EnumReservedRange"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumValueDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumValueDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_ServiceDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.ServiceDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_MethodDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.MethodDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_FileOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.FileOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_MessageOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.MessageOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_FieldOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.FieldOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_OneofOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.OneofOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumValueOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumValueOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_ServiceOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.ServiceOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_MethodOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.MethodOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_UninterpretedOption_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption"); } UPB_INLINE const upb_msgdef *google_protobuf_UninterpretedOption_NamePart_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption.NamePart"); } UPB_INLINE const upb_msgdef *google_protobuf_SourceCodeInfo_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo"); } UPB_INLINE const upb_msgdef *google_protobuf_SourceCodeInfo_Location_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo.Location"); } UPB_INLINE const upb_msgdef *google_protobuf_GeneratedCodeInfo_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.GeneratedCodeInfo"); } UPB_INLINE const upb_msgdef *google_protobuf_GeneratedCodeInfo_Annotation_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); return upb_symtab_lookupmsg(s, "google.protobuf.GeneratedCodeInfo.Annotation"); } @@ -3827,7 +3857,7 @@ extern "C" { #endif enum { - /* When set, emits 0/default values. TODO(haberman): proto3 only? */ + /* When set, emits 0/default values. TOOD(haberman): proto3 only? */ UPB_JSONENC_EMITDEFAULTS = 1, /* When set, use normal (snake_caes) field names instead of JSON (camelCase) diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index fa1cc114b1f4..05095a0f36c0 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -35,7 +35,6 @@ #include "arena.h" #include "array.h" -#include "bundled_php.h" #include "convert.h" #include "def.h" #include "map.h" @@ -162,10 +161,6 @@ static PHP_RINIT_FUNCTION(protobuf) { upb_symtab *symtab = PROTOBUF_G(saved_symtab); DescriptorPool_CreateWithSymbolTable(&PROTOBUF_G(generated_pool), symtab); - // Set up autoloader for bundled sources. - zend_eval_string("spl_autoload_register('protobuf_internal_loadbundled');", - NULL, "autoload_register.php"); - zend_hash_init(&PROTOBUF_G(object_cache), 64, NULL, NULL, 0); zend_hash_init(&PROTOBUF_G(name_msg_cache), 64, NULL, NULL, 0); zend_hash_init(&PROTOBUF_G(name_enum_cache), 64, NULL, NULL, 0); @@ -193,34 +188,6 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) { return SUCCESS; } -// ----------------------------------------------------------------------------- -// Bundled PHP sources -// ----------------------------------------------------------------------------- - -// We bundle PHP sources for well-known types into the C extension. There is no -// need to implement these in C. - -static PHP_FUNCTION(protobuf_internal_loadbundled) { - char *name = NULL; - zend_long size; - BundledPhp_File *file; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &size) != SUCCESS) { - return; - } - - for (file = bundled_files; file->filename; file++) { - if (strcmp(file->filename, name) == 0) { - zend_eval_string((char*)file->contents, NULL, (char*)file->filename); - return; - } - } -} - -ZEND_BEGIN_ARG_INFO_EX(arginfo_load_bundled_source, 0, 0, 1) - ZEND_ARG_INFO(0, class_name) -ZEND_END_ARG_INFO() - // ----------------------------------------------------------------------------- // Object Cache. // ----------------------------------------------------------------------------- @@ -303,7 +270,6 @@ const upb_enumdef *NameMap_GetEnum(zend_class_entry *ce) { // ----------------------------------------------------------------------------- zend_function_entry protobuf_functions[] = { - PHP_FE(protobuf_internal_loadbundled, arginfo_load_bundled_source) ZEND_FE_END }; diff --git a/php/ext/google/protobuf/wkt.inc b/php/ext/google/protobuf/wkt.inc new file mode 100644 index 000000000000..c7a469f951ae --- /dev/null +++ b/php/ext/google/protobuf/wkt.inc @@ -0,0 +1,2920 @@ +// This file is generated from the .proto files for the well-known +// types. Do not edit! +static void google_protobuf_timestamp_proto_AddDescriptor(); +static void google_protobuf_wrappers_proto_AddDescriptor(); +static void google_protobuf_any_proto_AddDescriptor(); +static void google_protobuf_duration_proto_AddDescriptor(); +static void google_protobuf_api_proto_AddDescriptor(); +static void google_protobuf_empty_proto_AddDescriptor(); +static void google_protobuf_type_proto_AddDescriptor(); +static void google_protobuf_struct_proto_AddDescriptor(); +static void google_protobuf_source_context_proto_AddDescriptor(); +static void google_protobuf_field_mask_proto_AddDescriptor(); +/* google/protobuf/timestamp.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Timestamp_ce; + +const char google_protobuf_timestamp_proto_descriptor [239] = { +'\n', '\037', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'i', 'm', 'e', 's', 't', 'a', +'m', 'p', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', +'\"', '+', '\n', '\t', 'T', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', '\022', '\017', '\n', '\007', 's', 'e', 'c', 'o', 'n', 'd', 's', '\030', +'\001', ' ', '\001', '(', '\003', '\022', '\r', '\n', '\005', 'n', 'a', 'n', 'o', 's', '\030', '\002', ' ', '\001', '(', '\005', 'B', '\205', '\001', '\n', '\023', +'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\016', 'T', 'i', 'm', 'e', +'s', 't', 'a', 'm', 'p', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', +'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', +'w', 'n', '/', 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', +'\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', +'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_timestamp_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/timestamp.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/timestamp.proto", google_protobuf_timestamp_proto_descriptor, + sizeof(google_protobuf_timestamp_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_Timestamp, initOnce) { + google_protobuf_timestamp_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Timestamp_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Timestamp, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_Timestamp_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Timestamp", + GPBMetadata_Google_Protobuf_Timestamp_methods); + + GPBMetadata_Google_Protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_Timestamp */ + +zend_class_entry* google_protobuf_Timestamp_ce; + +static PHP_METHOD(google_protobuf_Timestamp, __construct) { + google_protobuf_timestamp_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Timestamp, getSeconds) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "seconds"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Timestamp, setSeconds) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "seconds"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Timestamp, getNanos) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "nanos"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Timestamp, setNanos) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "nanos"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Timestamp_phpmethods[] = { + PHP_ME(google_protobuf_Timestamp, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, getSeconds, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, setSeconds, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, getNanos, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, setNanos, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Timestamp_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Timestamp", + google_protobuf_Timestamp_phpmethods); + + google_protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Timestamp_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Timestamp_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Timestamp_ce, message_ce); +} + +/* google/protobuf/wrappers.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Wrappers_ce; + +const char google_protobuf_wrappers_proto_descriptor [455] = { +'\n', '\036', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'w', 'r', 'a', 'p', 'p', 'e', 'r', +'s', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', +'\034', '\n', '\013', 'D', 'o', 'u', 'b', 'l', 'e', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', +' ', '\001', '(', '\001', '\"', '\033', '\n', '\n', 'F', 'l', 'o', 'a', 't', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', +'u', 'e', '\030', '\001', ' ', '\001', '(', '\002', '\"', '\033', '\n', '\n', 'I', 'n', 't', '6', '4', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', +'\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\003', '\"', '\034', '\n', '\013', 'U', 'I', 'n', 't', '6', '4', 'V', 'a', 'l', +'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\004', '\"', '\033', '\n', '\n', 'I', 'n', 't', '3', +'2', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\005', '\"', '\034', '\n', '\013', +'U', 'I', 'n', 't', '3', '2', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', +'\r', '\"', '\032', '\n', '\t', 'B', 'o', 'o', 'l', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', +' ', '\001', '(', '\010', '\"', '\034', '\n', '\013', 'S', 't', 'r', 'i', 'n', 'g', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', +'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\"', '\033', '\n', '\n', 'B', 'y', 't', 'e', 's', 'V', 'a', 'l', 'u', 'e', '\022', '\r', +'\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\014', 'B', '\203', '\001', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', +'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\r', 'W', 'r', 'a', 'p', 'p', 'e', 'r', 's', 'P', 'r', 'o', +'t', 'o', 'P', '\001', 'Z', '1', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', +'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'w', 'r', 'a', 'p', 'p', +'e', 'r', 's', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', +'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', +'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_wrappers_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/wrappers.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/wrappers.proto", google_protobuf_wrappers_proto_descriptor, + sizeof(google_protobuf_wrappers_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_Wrappers, initOnce) { + google_protobuf_wrappers_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Wrappers_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Wrappers, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_Wrappers_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Wrappers", + GPBMetadata_Google_Protobuf_Wrappers_methods); + + GPBMetadata_Google_Protobuf_Wrappers_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_DoubleValue */ + +zend_class_entry* google_protobuf_DoubleValue_ce; + +static PHP_METHOD(google_protobuf_DoubleValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_DoubleValue, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_DoubleValue, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_DoubleValue_phpmethods[] = { + PHP_ME(google_protobuf_DoubleValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_DoubleValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_DoubleValue, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_DoubleValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\DoubleValue", + google_protobuf_DoubleValue_phpmethods); + + google_protobuf_DoubleValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_DoubleValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_DoubleValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_DoubleValue_ce, message_ce); +} + +/* google_protobuf_FloatValue */ + +zend_class_entry* google_protobuf_FloatValue_ce; + +static PHP_METHOD(google_protobuf_FloatValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_FloatValue, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_FloatValue, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_FloatValue_phpmethods[] = { + PHP_ME(google_protobuf_FloatValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_FloatValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_FloatValue, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_FloatValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\FloatValue", + google_protobuf_FloatValue_phpmethods); + + google_protobuf_FloatValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_FloatValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_FloatValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_FloatValue_ce, message_ce); +} + +/* google_protobuf_Int64Value */ + +zend_class_entry* google_protobuf_Int64Value_ce; + +static PHP_METHOD(google_protobuf_Int64Value, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Int64Value, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Int64Value, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Int64Value_phpmethods[] = { + PHP_ME(google_protobuf_Int64Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Int64Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Int64Value, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Int64Value_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Int64Value", + google_protobuf_Int64Value_phpmethods); + + google_protobuf_Int64Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Int64Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Int64Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Int64Value_ce, message_ce); +} + +/* google_protobuf_UInt64Value */ + +zend_class_entry* google_protobuf_UInt64Value_ce; + +static PHP_METHOD(google_protobuf_UInt64Value, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_UInt64Value, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_UInt64Value, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_UInt64Value_phpmethods[] = { + PHP_ME(google_protobuf_UInt64Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_UInt64Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_UInt64Value, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_UInt64Value_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\UInt64Value", + google_protobuf_UInt64Value_phpmethods); + + google_protobuf_UInt64Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_UInt64Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_UInt64Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_UInt64Value_ce, message_ce); +} + +/* google_protobuf_Int32Value */ + +zend_class_entry* google_protobuf_Int32Value_ce; + +static PHP_METHOD(google_protobuf_Int32Value, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Int32Value, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Int32Value, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Int32Value_phpmethods[] = { + PHP_ME(google_protobuf_Int32Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Int32Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Int32Value, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Int32Value_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Int32Value", + google_protobuf_Int32Value_phpmethods); + + google_protobuf_Int32Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Int32Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Int32Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Int32Value_ce, message_ce); +} + +/* google_protobuf_UInt32Value */ + +zend_class_entry* google_protobuf_UInt32Value_ce; + +static PHP_METHOD(google_protobuf_UInt32Value, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_UInt32Value, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_UInt32Value, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_UInt32Value_phpmethods[] = { + PHP_ME(google_protobuf_UInt32Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_UInt32Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_UInt32Value, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_UInt32Value_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\UInt32Value", + google_protobuf_UInt32Value_phpmethods); + + google_protobuf_UInt32Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_UInt32Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_UInt32Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_UInt32Value_ce, message_ce); +} + +/* google_protobuf_BoolValue */ + +zend_class_entry* google_protobuf_BoolValue_ce; + +static PHP_METHOD(google_protobuf_BoolValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_BoolValue, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_BoolValue, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_BoolValue_phpmethods[] = { + PHP_ME(google_protobuf_BoolValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_BoolValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_BoolValue, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_BoolValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\BoolValue", + google_protobuf_BoolValue_phpmethods); + + google_protobuf_BoolValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_BoolValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_BoolValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_BoolValue_ce, message_ce); +} + +/* google_protobuf_StringValue */ + +zend_class_entry* google_protobuf_StringValue_ce; + +static PHP_METHOD(google_protobuf_StringValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_StringValue, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_StringValue, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_StringValue_phpmethods[] = { + PHP_ME(google_protobuf_StringValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_StringValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_StringValue, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_StringValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\StringValue", + google_protobuf_StringValue_phpmethods); + + google_protobuf_StringValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_StringValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_StringValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_StringValue_ce, message_ce); +} + +/* google_protobuf_BytesValue */ + +zend_class_entry* google_protobuf_BytesValue_ce; + +static PHP_METHOD(google_protobuf_BytesValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_BytesValue, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_BytesValue, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_BytesValue_phpmethods[] = { + PHP_ME(google_protobuf_BytesValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_BytesValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_BytesValue, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_BytesValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\BytesValue", + google_protobuf_BytesValue_phpmethods); + + google_protobuf_BytesValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_BytesValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_BytesValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_BytesValue_ce, message_ce); +} + +/* google/protobuf/any.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Any_ce; + +const char google_protobuf_any_proto_descriptor [212] = { +'\n', '\031', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'n', 'y', '.', 'p', 'r', 'o', +'t', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '&', '\n', '\003', 'A', 'n', +'y', '\022', '\020', '\n', '\010', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\r', '\n', '\005', 'v', 'a', +'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\014', 'B', 'v', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', +'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\010', 'A', 'n', 'y', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', ',', 'g', 'o', 'o', 'g', +'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', +'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'a', 'n', 'y', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', +'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', +'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_any_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/any.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/any.proto", google_protobuf_any_proto_descriptor, + sizeof(google_protobuf_any_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_Any, initOnce) { + google_protobuf_any_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Any_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Any, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_Any_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Any", + GPBMetadata_Google_Protobuf_Any_methods); + + GPBMetadata_Google_Protobuf_Any_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_Any */ + +zend_class_entry* google_protobuf_Any_ce; + +static PHP_METHOD(google_protobuf_Any, __construct) { + google_protobuf_any_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Any, getTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "type_url"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Any, setTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "type_url"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Any, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Any, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Any_phpmethods[] = { + PHP_ME(google_protobuf_Any, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, getTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, setTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, setValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, unpack, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Any_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Any", + google_protobuf_Any_phpmethods); + + google_protobuf_Any_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Any_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Any_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Any_ce, message_ce); +} + +/* google/protobuf/duration.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Duration_ce; + +const char google_protobuf_duration_proto_descriptor [235] = { +'\n', '\036', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'd', 'u', 'r', 'a', 't', 'i', 'o', +'n', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', +'*', '\n', '\010', 'D', 'u', 'r', 'a', 't', 'i', 'o', 'n', '\022', '\017', '\n', '\007', 's', 'e', 'c', 'o', 'n', 'd', 's', '\030', '\001', ' ', +'\001', '(', '\003', '\022', '\r', '\n', '\005', 'n', 'a', 'n', 'o', 's', '\030', '\002', ' ', '\001', '(', '\005', 'B', '\203', '\001', '\n', '\023', 'c', 'o', +'m', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\r', 'D', 'u', 'r', 'a', 't', 'i', +'o', 'n', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '1', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', +'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', +'d', 'u', 'r', 'a', 't', 'i', 'o', 'n', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', +'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', +'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_duration_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/duration.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/duration.proto", google_protobuf_duration_proto_descriptor, + sizeof(google_protobuf_duration_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_Duration, initOnce) { + google_protobuf_duration_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Duration_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Duration, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_Duration_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Duration", + GPBMetadata_Google_Protobuf_Duration_methods); + + GPBMetadata_Google_Protobuf_Duration_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_Duration */ + +zend_class_entry* google_protobuf_Duration_ce; + +static PHP_METHOD(google_protobuf_Duration, __construct) { + google_protobuf_duration_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Duration, getSeconds) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "seconds"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Duration, setSeconds) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "seconds"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Duration, getNanos) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "nanos"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Duration, setNanos) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "nanos"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Duration_phpmethods[] = { + PHP_ME(google_protobuf_Duration, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Duration, getSeconds, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Duration, setSeconds, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Duration, getNanos, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Duration, setNanos, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Duration_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Duration", + google_protobuf_Duration_phpmethods); + + google_protobuf_Duration_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Duration_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Duration_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Duration_ce, message_ce); +} + +/* google/protobuf/api.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Api_ce; + +const char google_protobuf_api_proto_descriptor [751] = { +'\n', '\031', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'p', 'i', '.', 'p', 'r', 'o', +'t', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\032', '$', 'g', 'o', 'o', 'g', +'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', +'t', '.', 'p', 'r', 'o', 't', 'o', '\032', '\032', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', +'t', 'y', 'p', 'e', '.', 'p', 'r', 'o', 't', 'o', '\"', '\201', '\002', '\n', '\003', 'A', 'p', 'i', '\022', '\014', '\n', '\004', 'n', 'a', 'm', +'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '(', '\n', '\007', 'm', 'e', 't', 'h', 'o', 'd', 's', '\030', '\002', ' ', '\003', '(', '\013', '2', +'\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', 'e', 't', 'h', 'o', 'd', '\022', +'(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', +'.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\017', '\n', '\007', 'v', 'e', 'r', 's', 'i', +'o', 'n', '\030', '\004', ' ', '\001', '(', '\t', '\022', '6', '\n', '\016', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', +'t', '\030', '\005', ' ', '\001', '(', '\013', '2', '\036', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', +'.', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '&', '\n', '\006', 'm', 'i', 'x', 'i', 'n', 's', '\030', +'\006', ' ', '\003', '(', '\013', '2', '\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', +'i', 'x', 'i', 'n', '\022', '\'', '\n', '\006', 's', 'y', 'n', 't', 'a', 'x', '\030', '\007', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', +'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', '\325', '\001', '\n', '\006', +'M', 'e', 't', 'h', 'o', 'd', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\030', '\n', '\020', 'r', +'e', 'q', 'u', 'e', 's', 't', '_', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\002', ' ', '\001', '(', '\t', '\022', '\031', '\n', '\021', +'r', 'e', 'q', 'u', 'e', 's', 't', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\003', ' ', '\001', '(', '\010', '\022', '\031', +'\n', '\021', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e', '_', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\004', ' ', '\001', '(', '\t', +'\022', '\032', '\n', '\022', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\005', ' ', +'\001', '(', '\010', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\006', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', +'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\'', '\n', '\006', 's', +'y', 'n', 't', 'a', 'x', '\030', '\007', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', +'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', '#', '\n', '\005', 'M', 'i', 'x', 'i', 'n', '\022', '\014', '\n', '\004', 'n', +'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\014', '\n', '\004', 'r', 'o', 'o', 't', '\030', '\002', ' ', '\001', '(', '\t', 'B', 'v', +'\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\010', 'A', 'p', +'i', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', ',', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', +'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'a', +'p', 'i', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', +'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', +'3', +}; + +static void google_protobuf_api_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/api.proto")) return; + google_protobuf_source_context_proto_AddDescriptor(); + google_protobuf_type_proto_AddDescriptor(); + DescriptorPool_AddDescriptor("google/protobuf/api.proto", google_protobuf_api_proto_descriptor, + sizeof(google_protobuf_api_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_Api, initOnce) { + google_protobuf_api_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Api_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Api, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_Api_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Api", + GPBMetadata_Google_Protobuf_Api_methods); + + GPBMetadata_Google_Protobuf_Api_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_Api */ + +zend_class_entry* google_protobuf_Api_ce; + +static PHP_METHOD(google_protobuf_Api, __construct) { + google_protobuf_api_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Api, getName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, setName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, getMethods) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "methods"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, setMethods) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "methods"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, getOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, setOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, getVersion) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "version"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, setVersion) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "version"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, getSourceContext) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "source_context"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, setSourceContext) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "source_context"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, getMixins) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "mixins"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, setMixins) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "mixins"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, getSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Api, setSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Api_phpmethods[] = { + PHP_ME(google_protobuf_Api, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getMethods, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setMethods, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getVersion, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setVersion, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getMixins, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setMixins, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setSyntax, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Api_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Api", + google_protobuf_Api_phpmethods); + + google_protobuf_Api_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Api_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Api_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Api_ce, message_ce); +} + +/* google_protobuf_Method */ + +zend_class_entry* google_protobuf_Method_ce; + +static PHP_METHOD(google_protobuf_Method, __construct) { + google_protobuf_api_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Method, getName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, setName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, getRequestTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "request_type_url"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, setRequestTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "request_type_url"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, getRequestStreaming) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "request_streaming"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, setRequestStreaming) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "request_streaming"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, getResponseTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "response_type_url"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, setResponseTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "response_type_url"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, getResponseStreaming) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "response_streaming"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, setResponseStreaming) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "response_streaming"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, getOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, setOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, getSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Method, setSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Method_phpmethods[] = { + PHP_ME(google_protobuf_Method, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getRequestTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setRequestTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getRequestStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setRequestStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getResponseTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setResponseTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getResponseStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setResponseStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setSyntax, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Method_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Method", + google_protobuf_Method_phpmethods); + + google_protobuf_Method_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Method_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Method_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Method_ce, message_ce); +} + +/* google_protobuf_Mixin */ + +zend_class_entry* google_protobuf_Mixin_ce; + +static PHP_METHOD(google_protobuf_Mixin, __construct) { + google_protobuf_api_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Mixin, getName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Mixin, setName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Mixin, getRoot) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "root"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Mixin, setRoot) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "root"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Mixin_phpmethods[] = { + PHP_ME(google_protobuf_Mixin, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Mixin, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Mixin, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Mixin, getRoot, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Mixin, setRoot, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Mixin_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Mixin", + google_protobuf_Mixin_phpmethods); + + google_protobuf_Mixin_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Mixin_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Mixin_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Mixin_ce, message_ce); +} + +/* google/protobuf/empty.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_GPBEmpty_ce; + +const char google_protobuf_empty_proto_descriptor [190] = { +'\n', '\033', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'e', 'm', 'p', 't', 'y', '.', 'p', +'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '\007', '\n', '\005', +'E', 'm', 'p', 't', 'y', 'B', '}', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', +'b', 'u', 'f', 'B', '\n', 'E', 'm', 'p', 't', 'y', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '.', 'g', 'o', 'o', 'g', 'l', 'e', +'.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', +'s', '/', 'k', 'n', 'o', 'w', 'n', '/', 'e', 'm', 'p', 't', 'y', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', +'\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', +'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_empty_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/empty.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/empty.proto", google_protobuf_empty_proto_descriptor, + sizeof(google_protobuf_empty_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_GPBEmpty, initOnce) { + google_protobuf_empty_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_GPBEmpty_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_GPBEmpty, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_GPBEmpty_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\GPBEmpty", + GPBMetadata_Google_Protobuf_GPBEmpty_methods); + + GPBMetadata_Google_Protobuf_GPBEmpty_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_Empty */ + +zend_class_entry* google_protobuf_Empty_ce; + +static PHP_METHOD(google_protobuf_Empty, __construct) { + google_protobuf_empty_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static zend_function_entry google_protobuf_Empty_phpmethods[] = { + PHP_ME(google_protobuf_Empty, __construct, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Empty_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\GPBEmpty", + google_protobuf_Empty_phpmethods); + + google_protobuf_Empty_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Empty_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Empty_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Empty_ce, message_ce); +} + +/* google/protobuf/type.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Type_ce; + +const char google_protobuf_type_proto_descriptor [1592] = { +'\n', '\032', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', '.', 'p', 'r', +'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\032', '\031', 'g', 'o', 'o', +'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'n', 'y', '.', 'p', 'r', 'o', 't', 'o', '\032', '$', 'g', +'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', +'t', 'e', 'x', 't', '.', 'p', 'r', 'o', 't', 'o', '\"', '\327', '\001', '\n', '\004', 'T', 'y', 'p', 'e', '\022', '\014', '\n', '\004', 'n', 'a', +'m', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '&', '\n', '\006', 'f', 'i', 'e', 'l', 'd', 's', '\030', '\002', ' ', '\003', '(', '\013', '2', +'\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 'd', '\022', '\016', +'\n', '\006', 'o', 'n', 'e', 'o', 'f', 's', '\030', '\003', ' ', '\003', '(', '\t', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', +'\030', '\004', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', +'O', 'p', 't', 'i', 'o', 'n', '\022', '6', '\n', '\016', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', 't', '\030', +'\005', ' ', '\001', '(', '\013', '2', '\036', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', +'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '\'', '\n', '\006', 's', 'y', 'n', 't', 'a', 'x', '\030', '\006', ' ', +'\001', '(', '\016', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', +'t', 'a', 'x', '\"', '\325', '\005', '\n', '\005', 'F', 'i', 'e', 'l', 'd', '\022', ')', '\n', '\004', 'k', 'i', 'n', 'd', '\030', '\001', ' ', '\001', +'(', '\016', '2', '\033', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', +'d', '.', 'K', 'i', 'n', 'd', '\022', '7', '\n', '\013', 'c', 'a', 'r', 'd', 'i', 'n', 'a', 'l', 'i', 't', 'y', '\030', '\002', ' ', '\001', +'(', '\016', '2', '\"', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', +'d', '.', 'C', 'a', 'r', 'd', 'i', 'n', 'a', 'l', 'i', 't', 'y', '\022', '\016', '\n', '\006', 'n', 'u', 'm', 'b', 'e', 'r', '\030', '\003', +' ', '\001', '(', '\005', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\004', ' ', '\001', '(', '\t', '\022', '\020', '\n', '\010', 't', 'y', 'p', +'e', '_', 'u', 'r', 'l', '\030', '\006', ' ', '\001', '(', '\t', '\022', '\023', '\n', '\013', 'o', 'n', 'e', 'o', 'f', '_', 'i', 'n', 'd', 'e', +'x', '\030', '\007', ' ', '\001', '(', '\005', '\022', '\016', '\n', '\006', 'p', 'a', 'c', 'k', 'e', 'd', '\030', '\010', ' ', '\001', '(', '\010', '\022', '(', +'\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\t', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', +'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\021', '\n', '\t', 'j', 's', 'o', 'n', '_', 'n', +'a', 'm', 'e', '\030', '\n', ' ', '\001', '(', '\t', '\022', '\025', '\n', '\r', 'd', 'e', 'f', 'a', 'u', 'l', 't', '_', 'v', 'a', 'l', 'u', +'e', '\030', '\013', ' ', '\001', '(', '\t', '\"', '\310', '\002', '\n', '\004', 'K', 'i', 'n', 'd', '\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', +'U', 'N', 'K', 'N', 'O', 'W', 'N', '\020', '\000', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'D', 'O', 'U', 'B', 'L', 'E', '\020', +'\001', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', '_', 'F', 'L', 'O', 'A', 'T', '\020', '\002', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', +'_', 'I', 'N', 'T', '6', '4', '\020', '\003', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'U', 'I', 'N', 'T', '6', '4', '\020', '\004', +'\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', '_', 'I', 'N', 'T', '3', '2', '\020', '\005', '\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', +'F', 'I', 'X', 'E', 'D', '6', '4', '\020', '\006', '\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', 'F', 'I', 'X', 'E', 'D', '3', '2', +'\020', '\007', '\022', '\r', '\n', '\t', 'T', 'Y', 'P', 'E', '_', 'B', 'O', 'O', 'L', '\020', '\010', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', +'_', 'S', 'T', 'R', 'I', 'N', 'G', '\020', '\t', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', '_', 'G', 'R', 'O', 'U', 'P', '\020', '\n', +'\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', 'M', 'E', 'S', 'S', 'A', 'G', 'E', '\020', '\013', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', +'E', '_', 'B', 'Y', 'T', 'E', 'S', '\020', '\014', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'U', 'I', 'N', 'T', '3', '2', '\020', +'\r', '\022', '\r', '\n', '\t', 'T', 'Y', 'P', 'E', '_', 'E', 'N', 'U', 'M', '\020', '\016', '\022', '\021', '\n', '\r', 'T', 'Y', 'P', 'E', '_', +'S', 'F', 'I', 'X', 'E', 'D', '3', '2', '\020', '\017', '\022', '\021', '\n', '\r', 'T', 'Y', 'P', 'E', '_', 'S', 'F', 'I', 'X', 'E', 'D', +'6', '4', '\020', '\020', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'S', 'I', 'N', 'T', '3', '2', '\020', '\021', '\022', '\017', '\n', '\013', +'T', 'Y', 'P', 'E', '_', 'S', 'I', 'N', 'T', '6', '4', '\020', '\022', '\"', 't', '\n', '\013', 'C', 'a', 'r', 'd', 'i', 'n', 'a', 'l', +'i', 't', 'y', '\022', '\027', '\n', '\023', 'C', 'A', 'R', 'D', 'I', 'N', 'A', 'L', 'I', 'T', 'Y', '_', 'U', 'N', 'K', 'N', 'O', 'W', +'N', '\020', '\000', '\022', '\030', '\n', '\024', 'C', 'A', 'R', 'D', 'I', 'N', 'A', 'L', 'I', 'T', 'Y', '_', 'O', 'P', 'T', 'I', 'O', 'N', +'A', 'L', '\020', '\001', '\022', '\030', '\n', '\024', 'C', 'A', 'R', 'D', 'I', 'N', 'A', 'L', 'I', 'T', 'Y', '_', 'R', 'E', 'Q', 'U', 'I', +'R', 'E', 'D', '\020', '\002', '\022', '\030', '\n', '\024', 'C', 'A', 'R', 'D', 'I', 'N', 'A', 'L', 'I', 'T', 'Y', '_', 'R', 'E', 'P', 'E', +'A', 'T', 'E', 'D', '\020', '\003', '\"', '\316', '\001', '\n', '\004', 'E', 'n', 'u', 'm', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', +' ', '\001', '(', '\t', '\022', '-', '\n', '\t', 'e', 'n', 'u', 'm', 'v', 'a', 'l', 'u', 'e', '\030', '\002', ' ', '\003', '(', '\013', '2', '\032', +'.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'E', 'n', 'u', 'm', 'V', 'a', 'l', 'u', +'e', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', +'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '6', '\n', '\016', 's', 'o', 'u', +'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', 't', '\030', '\004', ' ', '\001', '(', '\013', '2', '\036', '.', 'g', 'o', 'o', 'g', 'l', +'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', +'\'', '\n', '\006', 's', 'y', 'n', 't', 'a', 'x', '\030', '\005', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', +'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', 'S', '\n', '\t', 'E', 'n', 'u', 'm', 'V', 'a', +'l', 'u', 'e', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\016', '\n', '\006', 'n', 'u', 'm', 'b', +'e', 'r', '\030', '\002', ' ', '\001', '(', '\005', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\003', '(', '\013', +'2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', +'\"', ';', '\n', '\006', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', +'#', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\013', '2', '\024', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', +'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'A', 'n', 'y', '*', '.', '\n', '\006', 'S', 'y', 'n', 't', 'a', 'x', '\022', '\021', '\n', '\r', +'S', 'Y', 'N', 'T', 'A', 'X', '_', 'P', 'R', 'O', 'T', 'O', '2', '\020', '\000', '\022', '\021', '\n', '\r', 'S', 'Y', 'N', 'T', 'A', 'X', +'_', 'P', 'R', 'O', 'T', 'O', '3', '\020', '\001', 'B', '{', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', +'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\t', 'T', 'y', 'p', 'e', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '-', 'g', 'o', 'o', +'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', +'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 't', 'y', 'p', 'e', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', +'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', +'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_type_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/type.proto")) return; + google_protobuf_any_proto_AddDescriptor(); + google_protobuf_source_context_proto_AddDescriptor(); + DescriptorPool_AddDescriptor("google/protobuf/type.proto", google_protobuf_type_proto_descriptor, + sizeof(google_protobuf_type_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_Type, initOnce) { + google_protobuf_type_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Type_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Type, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_Type_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Type", + GPBMetadata_Google_Protobuf_Type_methods); + + GPBMetadata_Google_Protobuf_Type_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_Type */ + +zend_class_entry* google_protobuf_Type_ce; + +static PHP_METHOD(google_protobuf_Type, __construct) { + google_protobuf_type_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Type, getName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, setName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, getFields) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "fields"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, setFields) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "fields"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, getOneofs) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "oneofs"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, setOneofs) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "oneofs"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, getOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, setOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, getSourceContext) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "source_context"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, setSourceContext) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "source_context"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, getSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Type, setSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Type_phpmethods[] = { + PHP_ME(google_protobuf_Type, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, getFields, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, setFields, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, getOneofs, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, setOneofs, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, getSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, setSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Type, setSyntax, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Type_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Type", + google_protobuf_Type_phpmethods); + + google_protobuf_Type_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Type_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Type_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Type_ce, message_ce); +} + +/* google_protobuf_Field */ + +zend_class_entry* google_protobuf_Field_ce; + +static PHP_METHOD(google_protobuf_Field, __construct) { + google_protobuf_type_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Field, getKind) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "kind"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setKind) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "kind"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, getCardinality) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "cardinality"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setCardinality) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "cardinality"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, getNumber) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "number"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setNumber) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "number"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, getName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, getTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "type_url"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "type_url"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, getOneofIndex) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "oneof_index"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setOneofIndex) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "oneof_index"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, getPacked) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "packed"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setPacked) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "packed"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, getOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, getJsonName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "json_name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setJsonName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "json_name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, getDefaultValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "default_value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Field, setDefaultValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "default_value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Field_phpmethods[] = { + PHP_ME(google_protobuf_Field, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getKind, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setKind, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getCardinality, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setCardinality, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getNumber, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setNumber, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getOneofIndex, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setOneofIndex, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getPacked, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setPacked, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getJsonName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setJsonName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, getDefaultValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Field, setDefaultValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Field_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Field", + google_protobuf_Field_phpmethods); + + google_protobuf_Field_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Field_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Field_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Field_ce, message_ce); +} + +/* google_protobuf_Enum */ + +zend_class_entry* google_protobuf_Enum_ce; + +static PHP_METHOD(google_protobuf_Enum, __construct) { + google_protobuf_type_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Enum, getName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Enum, setName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Enum, getEnumvalue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "enumvalue"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Enum, setEnumvalue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "enumvalue"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Enum, getOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Enum, setOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Enum, getSourceContext) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "source_context"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Enum, setSourceContext) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "source_context"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Enum, getSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Enum, setSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Enum_phpmethods[] = { + PHP_ME(google_protobuf_Enum, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, getEnumvalue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, setEnumvalue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, getSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, setSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Enum, setSyntax, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Enum_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Enum", + google_protobuf_Enum_phpmethods); + + google_protobuf_Enum_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Enum_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Enum_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Enum_ce, message_ce); +} + +/* google_protobuf_EnumValue */ + +zend_class_entry* google_protobuf_EnumValue_ce; + +static PHP_METHOD(google_protobuf_EnumValue, __construct) { + google_protobuf_type_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_EnumValue, getName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_EnumValue, setName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_EnumValue, getNumber) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "number"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_EnumValue, setNumber) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "number"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_EnumValue, getOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_EnumValue, setOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_EnumValue_phpmethods[] = { + PHP_ME(google_protobuf_EnumValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_EnumValue, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_EnumValue, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_EnumValue, getNumber, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_EnumValue, setNumber, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_EnumValue, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_EnumValue, setOptions, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_EnumValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\EnumValue", + google_protobuf_EnumValue_phpmethods); + + google_protobuf_EnumValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_EnumValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_EnumValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_EnumValue_ce, message_ce); +} + +/* google_protobuf_Option */ + +zend_class_entry* google_protobuf_Option_ce; + +static PHP_METHOD(google_protobuf_Option, __construct) { + google_protobuf_type_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Option, getName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Option, setName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Option, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Option, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Option_phpmethods[] = { + PHP_ME(google_protobuf_Option, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Option, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Option, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Option, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Option, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Option_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Option", + google_protobuf_Option_phpmethods); + + google_protobuf_Option_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Option_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Option_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Option_ce, message_ce); +} + +/* google/protobuf/struct.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Struct_ce; + +const char google_protobuf_struct_proto_descriptor [638] = { +'\n', '\034', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 't', 'r', 'u', 'c', 't', '.', +'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '\204', '\001', +'\n', '\006', 'S', 't', 'r', 'u', 'c', 't', '\022', '3', '\n', '\006', 'f', 'i', 'e', 'l', 'd', 's', '\030', '\001', ' ', '\003', '(', '\013', '2', +'#', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 't', 'r', 'u', 'c', 't', '.', +'F', 'i', 'e', 'l', 'd', 's', 'E', 'n', 't', 'r', 'y', '\032', 'E', '\n', '\013', 'F', 'i', 'e', 'l', 'd', 's', 'E', 'n', 't', 'r', +'y', '\022', '\013', '\n', '\003', 'k', 'e', 'y', '\030', '\001', ' ', '\001', '(', '\t', '\022', '%', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\002', +' ', '\001', '(', '\013', '2', '\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'V', 'a', +'l', 'u', 'e', ':', '\002', '8', '\001', '\"', '\352', '\001', '\n', '\005', 'V', 'a', 'l', 'u', 'e', '\022', '0', '\n', '\n', 'n', 'u', 'l', 'l', +'_', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\016', '2', '\032', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', +'t', 'o', 'b', 'u', 'f', '.', 'N', 'u', 'l', 'l', 'V', 'a', 'l', 'u', 'e', 'H', '\000', '\022', '\026', '\n', '\014', 'n', 'u', 'm', 'b', +'e', 'r', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\001', 'H', '\000', '\022', '\026', '\n', '\014', 's', 't', 'r', 'i', 'n', +'g', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\003', ' ', '\001', '(', '\t', 'H', '\000', '\022', '\024', '\n', '\n', 'b', 'o', 'o', 'l', '_', 'v', +'a', 'l', 'u', 'e', '\030', '\004', ' ', '\001', '(', '\010', 'H', '\000', '\022', '/', '\n', '\014', 's', 't', 'r', 'u', 'c', 't', '_', 'v', 'a', +'l', 'u', 'e', '\030', '\005', ' ', '\001', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', +'u', 'f', '.', 'S', 't', 'r', 'u', 'c', 't', 'H', '\000', '\022', '0', '\n', '\n', 'l', 'i', 's', 't', '_', 'v', 'a', 'l', 'u', 'e', +'\030', '\006', ' ', '\001', '(', '\013', '2', '\032', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', +'L', 'i', 's', 't', 'V', 'a', 'l', 'u', 'e', 'H', '\000', 'B', '\006', '\n', '\004', 'k', 'i', 'n', 'd', '\"', '3', '\n', '\t', 'L', 'i', +'s', 't', 'V', 'a', 'l', 'u', 'e', '\022', '&', '\n', '\006', 'v', 'a', 'l', 'u', 'e', 's', '\030', '\001', ' ', '\003', '(', '\013', '2', '\026', +'.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'V', 'a', 'l', 'u', 'e', '*', '\033', '\n', +'\t', 'N', 'u', 'l', 'l', 'V', 'a', 'l', 'u', 'e', '\022', '\016', '\n', '\n', 'N', 'U', 'L', 'L', '_', 'V', 'A', 'L', 'U', 'E', '\020', +'\000', 'B', '\177', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', +'\013', 'S', 't', 'r', 'u', 'c', 't', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '/', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', +'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', +'n', 'o', 'w', 'n', '/', 's', 't', 'r', 'u', 'c', 't', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', +'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', +'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_struct_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/struct.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/struct.proto", google_protobuf_struct_proto_descriptor, + sizeof(google_protobuf_struct_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_Struct, initOnce) { + google_protobuf_struct_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Struct_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Struct, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_Struct_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Struct", + GPBMetadata_Google_Protobuf_Struct_methods); + + GPBMetadata_Google_Protobuf_Struct_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_Struct */ + +zend_class_entry* google_protobuf_Struct_ce; + +static PHP_METHOD(google_protobuf_Struct, __construct) { + google_protobuf_struct_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Struct, getFields) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "fields"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Struct, setFields) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "fields"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Struct_phpmethods[] = { + PHP_ME(google_protobuf_Struct, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct, getFields, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct, setFields, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Struct_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Struct", + google_protobuf_Struct_phpmethods); + + google_protobuf_Struct_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Struct_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Struct_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Struct_ce, message_ce); +} + +/* google_protobuf_Struct_FieldsEntry */ + +zend_class_entry* google_protobuf_Struct_FieldsEntry_ce; + +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, __construct) { + google_protobuf_struct_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, getKey) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "key"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, setKey) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "key"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Struct_FieldsEntry_phpmethods[] = { + PHP_ME(google_protobuf_Struct_FieldsEntry, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct_FieldsEntry, getKey, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct_FieldsEntry, setKey, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct_FieldsEntry, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct_FieldsEntry, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Struct_FieldsEntry_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Struct\\FieldsEntry", + google_protobuf_Struct_FieldsEntry_phpmethods); + + google_protobuf_Struct_FieldsEntry_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Struct_FieldsEntry_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Struct_FieldsEntry_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Struct_FieldsEntry_ce, message_ce); +} + +/* google_protobuf_Value */ + +zend_class_entry* google_protobuf_Value_ce; + +static PHP_METHOD(google_protobuf_Value, __construct) { + google_protobuf_struct_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Value, getNullValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "null_value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, setNullValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "null_value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, getNumberValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "number_value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, setNumberValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "number_value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, getStringValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "string_value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, setStringValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "string_value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, getBoolValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "bool_value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, setBoolValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "bool_value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, getStructValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "struct_value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, setStructValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "struct_value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, getListValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "list_value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Value, setListValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "list_value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_Value_phpmethods[] = { + PHP_ME(google_protobuf_Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getNullValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setNullValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getNumberValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setNumberValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getStringValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setStringValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getBoolValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setBoolValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getStructValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setStructValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getListValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setListValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Value_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Value", + google_protobuf_Value_phpmethods); + + google_protobuf_Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Value_ce, message_ce); +} + +/* google_protobuf_ListValue */ + +zend_class_entry* google_protobuf_ListValue_ce; + +static PHP_METHOD(google_protobuf_ListValue, __construct) { + google_protobuf_struct_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_ListValue, getValues) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "values"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_ListValue, setValues) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "values"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_ListValue_phpmethods[] = { + PHP_ME(google_protobuf_ListValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_ListValue, getValues, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_ListValue, setValues, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_ListValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\ListValue", + google_protobuf_ListValue_phpmethods); + + google_protobuf_ListValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_ListValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_ListValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_ListValue_ce, message_ce); +} + +/* google/protobuf/source_context.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_SourceContext_ce; + +const char google_protobuf_source_context_proto_descriptor [240] = { +'\n', '$', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', +'c', 'o', 'n', 't', 'e', 'x', 't', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', +'t', 'o', 'b', 'u', 'f', '\"', '\"', '\n', '\r', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '\021', '\n', +'\t', 'f', 'i', 'l', 'e', '_', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'B', '\212', '\001', '\n', '\023', 'c', 'o', 'm', '.', +'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\022', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', +'n', 't', 'e', 'x', 't', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '6', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', +'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', +'w', 'n', '/', 's', 'o', 'u', 'r', 'c', 'e', 'c', 'o', 'n', 't', 'e', 'x', 't', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', +'\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', +'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_source_context_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/source_context.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/source_context.proto", google_protobuf_source_context_proto_descriptor, + sizeof(google_protobuf_source_context_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_SourceContext, initOnce) { + google_protobuf_source_context_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_SourceContext_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_SourceContext, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_SourceContext_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\SourceContext", + GPBMetadata_Google_Protobuf_SourceContext_methods); + + GPBMetadata_Google_Protobuf_SourceContext_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_SourceContext */ + +zend_class_entry* google_protobuf_SourceContext_ce; + +static PHP_METHOD(google_protobuf_SourceContext, __construct) { + google_protobuf_source_context_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_SourceContext, getFileName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "file_name"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_SourceContext, setFileName) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "file_name"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_SourceContext_phpmethods[] = { + PHP_ME(google_protobuf_SourceContext, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_SourceContext, getFileName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_SourceContext, setFileName, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_SourceContext_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\SourceContext", + google_protobuf_SourceContext_phpmethods); + + google_protobuf_SourceContext_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_SourceContext_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_SourceContext_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_SourceContext_ce, message_ce); +} + +/* google/protobuf/field_mask.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_FieldMask_ce; + +const char google_protobuf_field_mask_proto_descriptor [223] = { +'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'f', 'i', 'e', 'l', 'd', '_', 'm', +'a', 's', 'k', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', +'f', '\"', '\032', '\n', '\t', 'F', 'i', 'e', 'l', 'd', 'M', 'a', 's', 'k', '\022', '\r', '\n', '\005', 'p', 'a', 't', 'h', 's', '\030', '\001', +' ', '\003', '(', '\t', 'B', '\205', '\001', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', +'b', 'u', 'f', 'B', '\016', 'F', 'i', 'e', 'l', 'd', 'M', 'a', 's', 'k', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', +'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', +'t', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'f', 'i', 'e', 'l', 'd', 'm', 'a', 's', 'k', 'p', 'b', '\370', '\001', +'\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', +'.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_field_mask_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/field_mask.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/field_mask.proto", google_protobuf_field_mask_proto_descriptor, + sizeof(google_protobuf_field_mask_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_FieldMask, initOnce) { + google_protobuf_field_mask_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_FieldMask_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_FieldMask, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_FieldMask_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\FieldMask", + GPBMetadata_Google_Protobuf_FieldMask_methods); + + GPBMetadata_Google_Protobuf_FieldMask_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_FieldMask */ + +zend_class_entry* google_protobuf_FieldMask_ce; + +static PHP_METHOD(google_protobuf_FieldMask, __construct) { + google_protobuf_field_mask_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_FieldMask, getPaths) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "paths"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_FieldMask, setPaths) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "paths"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} + +static zend_function_entry google_protobuf_FieldMask_phpmethods[] = { + PHP_ME(google_protobuf_FieldMask, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_FieldMask, getPaths, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_FieldMask, setPaths, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_FieldMask_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\FieldMask", + google_protobuf_FieldMask_phpmethods); + + google_protobuf_FieldMask_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_FieldMask_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_FieldMask_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_FieldMask_ce, message_ce); +} + +static void WellKnownTypes_ModuleInit() { + GPBMetadata_Google_Protobuf_Timestamp_ModuleInit(); + google_protobuf_Timestamp_ModuleInit(); + GPBMetadata_Google_Protobuf_Wrappers_ModuleInit(); + google_protobuf_DoubleValue_ModuleInit(); + google_protobuf_FloatValue_ModuleInit(); + google_protobuf_Int64Value_ModuleInit(); + google_protobuf_UInt64Value_ModuleInit(); + google_protobuf_Int32Value_ModuleInit(); + google_protobuf_UInt32Value_ModuleInit(); + google_protobuf_BoolValue_ModuleInit(); + google_protobuf_StringValue_ModuleInit(); + google_protobuf_BytesValue_ModuleInit(); + GPBMetadata_Google_Protobuf_Any_ModuleInit(); + google_protobuf_Any_ModuleInit(); + GPBMetadata_Google_Protobuf_Duration_ModuleInit(); + google_protobuf_Duration_ModuleInit(); + GPBMetadata_Google_Protobuf_Api_ModuleInit(); + google_protobuf_Api_ModuleInit(); + google_protobuf_Method_ModuleInit(); + google_protobuf_Mixin_ModuleInit(); + GPBMetadata_Google_Protobuf_GPBEmpty_ModuleInit(); + google_protobuf_Empty_ModuleInit(); + GPBMetadata_Google_Protobuf_Type_ModuleInit(); + google_protobuf_Type_ModuleInit(); + google_protobuf_Field_ModuleInit(); + google_protobuf_Enum_ModuleInit(); + google_protobuf_EnumValue_ModuleInit(); + google_protobuf_Option_ModuleInit(); + GPBMetadata_Google_Protobuf_Struct_ModuleInit(); + google_protobuf_Struct_ModuleInit(); + google_protobuf_Struct_FieldsEntry_ModuleInit(); + google_protobuf_Value_ModuleInit(); + google_protobuf_ListValue_ModuleInit(); + GPBMetadata_Google_Protobuf_SourceContext_ModuleInit(); + google_protobuf_SourceContext_ModuleInit(); + GPBMetadata_Google_Protobuf_FieldMask_ModuleInit(); + google_protobuf_FieldMask_ModuleInit(); +} diff --git a/php/tests/compile_extension.sh b/php/tests/compile_extension.sh index d6dcabcbbb8d..01ec79f0c123 100755 --- a/php/tests/compile_extension.sh +++ b/php/tests/compile_extension.sh @@ -7,7 +7,6 @@ cd $(dirname $0) pushd ../ext/google/protobuf phpize --clean rm -f configure.in configure.ac -php make-preload.php phpize if [ "$1" = "--release" ]; then ./configure --with-php-config=$(which php-config) diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 177ca90cee12..9b518f508c0c 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -81,6 +81,7 @@ namespace php { struct Options { bool is_descriptor = false; bool aggregate_metadata = false; + bool gen_c_wkt = false; std::set aggregate_metadata_prefixes; }; @@ -1791,7 +1792,7 @@ void GenerateEnumValueDocComment(io::Printer* printer, } void GenerateServiceMethodDocComment(io::Printer* printer, - const MethodDescriptor* method) { + const MethodDescriptor* method) { printer->Print("/**\n"); GenerateDocCommentBody(printer, method); printer->Print( @@ -1807,6 +1808,231 @@ void GenerateServiceMethodDocComment(io::Printer* printer, "return_type", EscapePhpdoc(FullClassName(method->output_type(), false))); } +std::string FilenameCName(const FileDescriptor* file) { + std::string c_name = file->name(); + c_name = StringReplace(c_name, ".", "_", true); + c_name = StringReplace(c_name, "/", "_", true); + return c_name; +} + +void GenerateCMessage(const Descriptor* message, io::Printer* printer) { + std::string c_name = message->full_name(); + c_name = StringReplace(c_name, ".", "_", true); + std::string php_name = FullClassName(message, Options()); + php_name = StringReplace(php_name, "\\", "\\\\", true); + printer->Print( + "/* $c_name$ */\n" + "\n" + "zend_class_entry* $c_name$_ce;\n" + "\n" + "static PHP_METHOD($c_name$, __construct) {\n" + " $file_c_name$_AddDescriptor();\n" + " zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n" + "}\n" + "\n", + "file_c_name", FilenameCName(message->file()), + "c_name", c_name); + + for (int i = 0; i < message->field_count(); i++) { + auto field = message->field(i); + printer->Print( + "static PHP_METHOD($c_name$, get$camel_name$) {\n" + " Message* intern = (Message*)Z_OBJ_P(getThis());\n" + " const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,\n" + " \"$name$\");\n" + " zval ret;\n" + " Message_get(intern, f, &ret);\n" + " RETURN_ZVAL(&ret, 1, 0);\n" + "}\n" + "\n" + "static PHP_METHOD($c_name$, set$camel_name$) {\n" + " Message* intern = (Message*)Z_OBJ_P(getThis());\n" + " const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,\n" + " \"$name$\");\n" + " zval *val;\n" + " if (zend_parse_parameters(ZEND_NUM_ARGS(), \"z\", &val)\n" + " == FAILURE) {\n" + " return;\n" + " }\n" + " Message_set(intern, f, val);\n" + " RETURN_ZVAL(getThis(), 1, 0);\n" + "}\n" + "\n", + "c_name", c_name, + "name", field->name(), + "camel_name", UnderscoresToCamelCase(field->name(), true)); + } + + printer->Print( + "static zend_function_entry $c_name$_phpmethods[] = {\n" + " PHP_ME($c_name$, __construct, NULL, ZEND_ACC_PUBLIC)\n", + "c_name", c_name); + + for (int i = 0; i < message->field_count(); i++) { + auto field = message->field(i); + printer->Print( + " PHP_ME($c_name$, get$camel_name$, NULL, ZEND_ACC_PUBLIC)\n" + " PHP_ME($c_name$, set$camel_name$, NULL, ZEND_ACC_PUBLIC)\n", + "c_name", c_name, + "camel_name", UnderscoresToCamelCase(field->name(), true)); + } + + if (message->well_known_type() == Descriptor::WELLKNOWNTYPE_ANY) { + printer->Print( + " PHP_ME($c_name$, unpack, NULL, ZEND_ACC_PUBLIC)\n", + "c_name", c_name); + } + + printer->Print( + " ZEND_FE_END\n" + "};\n" + "\n" + "static void $c_name$_ModuleInit() {\n" + " zend_class_entry tmp_ce;\n" + "\n" + " INIT_CLASS_ENTRY(tmp_ce, \"$php_name$\",\n" + " $c_name$_phpmethods);\n" + "\n" + " $c_name$_ce = zend_register_internal_class(&tmp_ce);\n" + " $c_name$_ce->ce_flags |= ZEND_ACC_FINAL;\n" + " $c_name$_ce->create_object = Message_create;\n" + " zend_do_inheritance($c_name$_ce, message_ce);\n" + "}\n" + "\n", + "c_name", c_name, + "php_name", php_name); + + for (int i = 0; i < message->nested_type_count(); i++) { + GenerateCMessage(message->nested_type(i), printer); + } +} + +void GenerateCInit(const Descriptor* message, io::Printer* printer) { + std::string c_name = message->full_name(); + c_name = StringReplace(c_name, ".", "_", true); + + printer->Print( + " $c_name$_ModuleInit();\n", + "c_name", c_name); + + for (int i = 0; i < message->nested_type_count(); i++) { + GenerateCInit(message->nested_type(i), printer); + } +} + +void GenerateCWellKnownTypes(const std::vector& files, + GeneratorContext* context) { + std::unique_ptr output( + context->Open("../ext/google/protobuf/wkt.inc")); + io::Printer printer(output.get(), '$'); + + printer.Print( + "// This file is generated from the .proto files for the well-known\n" + "// types. Do not edit!\n"); + + for (auto file : files) { + printer.Print( + "static void $c_name$_AddDescriptor();\n", + "c_name", FilenameCName(file)); + } + + for (auto file : files) { + std::string c_name = FilenameCName(file); + std::string metadata_filename = GeneratedMetadataFileName(file, Options()); + std::string metadata_classname = FilenameToClassname(metadata_filename); + std::string metadata_c_name = + StringReplace(metadata_classname, "\\", "_", true); + metadata_classname = StringReplace(metadata_classname, "\\", "\\\\", true); + FileDescriptorProto file_proto; + file->CopyTo(&file_proto); + std::string serialized; + file_proto.SerializeToString(&serialized); + printer.Print( + "/* $filename$ */\n" + "\n" + "zend_class_entry* $metadata_c_name$_ce;\n" + "\n" + "const char $c_name$_descriptor [$size$] = {\n", + "filename", file->name(), + "c_name", c_name, + "metadata_c_name", metadata_c_name, + "size", std::to_string(serialized.size())); + + for (size_t i = 0; i < serialized.size();) { + for (size_t j = 0; j < 25 && i < serialized.size(); ++i, ++j) { + printer.Print("'$ch$', ", "ch", CEscape(serialized.substr(i, 1))); + } + printer.Print("\n"); + } + + printer.Print( + "};\n" + "\n" + "static void $c_name$_AddDescriptor() {\n" + " if (DescriptorPool_HasFile(\"$filename$\")) return;\n", + "filename", file->name(), + "c_name", c_name, + "metadata_c_name", metadata_c_name); + + for (int i = 0; i < file->dependency_count(); i++) { + std::string dep_c_name = FilenameCName(file->dependency(i)); + printer.Print( + " $dep_c_name$_AddDescriptor();\n", + "dep_c_name", dep_c_name); + } + + printer.Print( + " DescriptorPool_AddDescriptor(\"$filename$\", $c_name$_descriptor,\n" + " sizeof($c_name$_descriptor));\n" + "}\n" + "\n" + "static PHP_METHOD($metadata_c_name$, initOnce) {\n" + " $c_name$_AddDescriptor();\n" + "}\n" + "\n" + "static zend_function_entry $metadata_c_name$_methods[] = {\n" + " PHP_ME($metadata_c_name$, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)\n" + " ZEND_FE_END\n" + "};\n" + "\n" + "static void $metadata_c_name$_ModuleInit() {\n" + " zend_class_entry tmp_ce;\n" + "\n" + " INIT_CLASS_ENTRY(tmp_ce, \"$metadata_classname$\",\n" + " $metadata_c_name$_methods);\n" + "\n" + " $metadata_c_name$_ce = zend_register_internal_class(&tmp_ce);\n" + "}\n" + "\n", + "filename", file->name(), + "c_name", c_name, + "metadata_c_name", metadata_c_name, + "metadata_classname", metadata_classname); + for (int i = 0; i < file->message_type_count(); i++) { + GenerateCMessage(file->message_type(i), &printer); + } + } + + printer.Print( + "static void WellKnownTypes_ModuleInit() {\n"); + + for (auto file : files) { + std::string metadata_filename = GeneratedMetadataFileName(file, Options()); + std::string metadata_classname = FilenameToClassname(metadata_filename); + std::string metadata_c_name = + StringReplace(metadata_classname, "\\", "_", true); + printer.Print( + " $metadata_c_name$_ModuleInit();\n", + "metadata_c_name", metadata_c_name); + for (int i = 0; i < file->message_type_count(); i++) { + GenerateCInit(file->message_type(i), &printer); + } + } + + printer.Print( + "}\n"); +} + } // namespace bool Generator::Generate(const FileDescriptor* file, const string& parameter, @@ -1850,9 +2076,12 @@ bool Generator::GenerateAll(const std::vector& files, options.aggregate_metadata_prefixes.insert(prefix); GOOGLE_LOG(INFO) << prefix; } - } - if (option_pair[0] == "internal") { + } else if (option_pair[0] == "internal") { options.is_descriptor = true; + } else if (option_pair[0] == "internal_generate_c_wkt") { + GenerateCWellKnownTypes(files, generator_context); + } else { + GOOGLE_LOG(FATAL) << "Unknown codegen option: " << option_pair[0]; } } @@ -1861,6 +2090,7 @@ bool Generator::GenerateAll(const std::vector& files, return false; } } + return true; } From cfc0c2b5e0be120302d4ded615c80c70240ed584 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 5 Oct 2020 22:24:34 -0700 Subject: [PATCH 05/12] Passes all tests. --- php/ext/google/protobuf/def.c | 21 +- php/ext/google/protobuf/message.c | 258 +++++++++++---- php/ext/google/protobuf/wkt.inc | 312 ++++++++++++++++++ php/generate_descriptor_protos.sh | 11 + .../protobuf/compiler/php/php_generator.cc | 148 ++++++++- 5 files changed, 673 insertions(+), 77 deletions(-) diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index c3ffd3154ec4..1ae5c4d67cfb 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -1010,6 +1010,21 @@ static zend_function_entry DescriptorPool_methods[] = { ZEND_FE_END }; +// ----------------------------------------------------------------------------- +// InternalDescriptorPool +// ----------------------------------------------------------------------------- + +// For the C extension, Google\Protobuf\Internal\DescriptorPool is not a +// separate instantiable object, it just returns a +// Google\Protobuf\DescriptorPool. + +zend_class_entry *InternalDescriptorPool_class_entry; + +static zend_function_entry InternalDescriptorPool_methods[] = { + PHP_ME(DescriptorPool, getGeneratedPool, NULL, + ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) +}; + // ----------------------------------------------------------------------------- // GPBType // ----------------------------------------------------------------------------- @@ -1071,7 +1086,7 @@ void Def_ModuleInit() { h = &FieldDescriptor_object_handlers; memcpy(h, &std_object_handlers, sizeof(zend_object_handlers)); - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Internal\\DescriptorPool", + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\DescriptorPool", DescriptorPool_methods); DescriptorPool_class_entry = zend_register_internal_class(&tmp_ce); DescriptorPool_class_entry->ce_flags |= ZEND_ACC_FINAL; @@ -1080,6 +1095,10 @@ void Def_ModuleInit() { memcpy(h, &std_object_handlers, sizeof(zend_object_handlers)); h->dtor_obj = DescriptorPool_destructor; + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Internal\\DescriptorPool", + InternalDescriptorPool_methods); + InternalDescriptorPool_class_entry = zend_register_internal_class(&tmp_ce); + // GPBType. #define STR(str) (str), strlen(str) zend_class_entry class_type; diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 8dd8edf3c9a8..3cc5a7700fc8 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -540,6 +540,12 @@ bool Message_InitFromPhp(upb_msg *msg, const upb_msgdef *m, zval *init, } } +static void Message_Initialize(Message *intern, const Descriptor *desc) { + intern->desc = desc; + intern->msg = upb_msg_new(desc->msgdef, Arena_Get(&intern->arena)); + ObjCache_Add(intern->msg, &intern->std); +} + /** * Message::__construct() * @@ -549,13 +555,10 @@ bool Message_InitFromPhp(upb_msg *msg, const upb_msgdef *m, zval *init, PHP_METHOD(Message, __construct) { Message* intern = (Message*)Z_OBJ_P(getThis()); const Descriptor* desc = Descriptor_GetFromClassEntry(Z_OBJCE_P(getThis())); - const upb_msgdef *msgdef = desc->msgdef; upb_arena *arena = Arena_Get(&intern->arena); zval *init_arr = NULL; - intern->desc = desc; - intern->msg = upb_msg_new(msgdef, arena); - ObjCache_Add(intern->msg, &intern->std); + Message_Initialize(intern, desc); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|a!", &init_arr) == FAILURE) { return; @@ -1024,31 +1027,55 @@ static const char TYPE_URL_PREFIX[] = "type.googleapis.com/"; static upb_msgval Message_getval(Message *intern, const char *field_name) { const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, field_name); + PBPHP_ASSERT(f); return upb_msg_get(intern->msg, f); } +static void Message_setval(Message *intern, const char *field_name, + upb_msgval val) { + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, field_name); + PBPHP_ASSERT(f); + return upb_msg_set(intern->msg, f, val, Arena_Get(&intern->arena)); +} + +static upb_msgval StringVal(upb_strview view) { + upb_msgval ret; + ret.str_val = view; + return ret; +} + +static bool TryStripUrlPrefix(upb_strview *str) { + size_t size = strlen(TYPE_URL_PREFIX); + if (str->size < size || memcmp(TYPE_URL_PREFIX, str->data, size) != 0) { + return false; + } + str->data += size; + str->size -= size; + return true; +} + +static bool StrViewEq(upb_strview view, const char *str) { + size_t size = strlen(str); + return view.size == size && memcmp(view.data, str, size) == 0; +} + PHP_METHOD(google_protobuf_Any, unpack) { Message* intern = (Message*)Z_OBJ_P(getThis()); upb_strview type_url = Message_getval(intern, "type_url").str_val; upb_strview value = Message_getval(intern, "value").str_val; - size_t prefix_len = strlen(TYPE_URL_PREFIX); upb_symtab *symtab = DescriptorPool_GetSymbolTable(); const upb_msgdef *m; Descriptor *desc; - zend_class_entry *klass; zval ret; // Ensure that type_url has TYPE_URL_PREFIX as a prefix. - if (type_url.size < prefix_len || - strncmp(TYPE_URL_PREFIX, type_url.data, prefix_len) != 0) { + if (!TryStripUrlPrefix(&type_url)) { zend_throw_exception( NULL, "Type url needs to be type.googleapis.com/fully-qualified", 0 TSRMLS_CC); return; } - type_url.size -= prefix_len; - type_url.data += prefix_len; m = upb_symtab_lookupmsg2(symtab, type_url.data, type_url.size); if (m == NULL) { @@ -1059,9 +1086,11 @@ PHP_METHOD(google_protobuf_Any, unpack) { } desc = Descriptor_GetFromMessageDef(m); - klass = desc->class_entry; - ZVAL_OBJ(&ret, klass->create_object(klass)); - Message *msg = (Message*)Z_OBJ_P(&ret); + PBPHP_ASSERT(desc->class_entry->create_object == Message_create); + zend_object *obj = Message_create(desc->class_entry); + Message *msg = (Message*)obj; + Message_Initialize(msg, desc); + ZVAL_OBJ(&ret, obj); // Get value. if (!upb_decode(value.data, value.size, msg->msg, @@ -1076,9 +1105,15 @@ PHP_METHOD(google_protobuf_Any, unpack) { RETURN_ZVAL(&ret, 1, 0); } -/* -PHP_METHOD(Any, pack) { - zval* val; +PHP_METHOD(google_protobuf_Any, pack) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + upb_arena *arena = Arena_Get(&intern->arena); + zval *val; + Message *msg; + upb_strview value; + upb_strview type_url; + const char *full_name; + char *buf; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &val) == FAILURE) { @@ -1090,76 +1125,153 @@ PHP_METHOD(Any, pack) { return; } - // Set value by serialized data. - zval data; - serialize_to_string(val, &data TSRMLS_CC); - - zval member; - PHP_PROTO_ZVAL_STRING(&member, "value", 1); - - PHP_PROTO_FAKE_SCOPE_BEGIN(any_type); - message_handlers->write_property(getThis(), &member, &data, - NULL PHP_PROTO_TSRMLS_CC); - zval_dtor(&data); - zval_dtor(&member); - PHP_PROTO_FAKE_SCOPE_END; - - // Set type url. - DescriptorInternal* desc = get_ce_desc(Z_OBJCE_P(val)); - const char* fully_qualified_name = upb_msgdef_fullname(desc->msgdef); - size_t type_url_len = - strlen(TYPE_URL_PREFIX) + strlen(fully_qualified_name) + 1; - char* type_url = ALLOC_N(char, type_url_len); - sprintf(type_url, "%s%s", TYPE_URL_PREFIX, fully_qualified_name); - zval type_url_php; - PHP_PROTO_ZVAL_STRING(&type_url_php, type_url, 1); - PHP_PROTO_ZVAL_STRING(&member, "type_url", 1); - - PHP_PROTO_FAKE_SCOPE_RESTART(any_type); - message_handlers->write_property(getThis(), &member, &type_url_php, - NULL PHP_PROTO_TSRMLS_CC); - zval_dtor(&type_url_php); - zval_dtor(&member); - PHP_PROTO_FAKE_SCOPE_END; - FREE(type_url); + msg = (Message*)Z_OBJ_P(val); + + // Serialize and set value. + value.data = upb_encode(msg->msg, upb_msgdef_layout(msg->desc->msgdef), arena, + &value.size); + Message_setval(intern, "value", StringVal(value)); + + // Set type url: type_url_prefix + fully_qualified_name + full_name = upb_msgdef_fullname(msg->desc->msgdef); + type_url.size = strlen(TYPE_URL_PREFIX) + strlen(full_name); + buf = upb_arena_malloc(arena, type_url.size + 1); + memcpy(buf, TYPE_URL_PREFIX, strlen(TYPE_URL_PREFIX)); + memcpy(buf + strlen(TYPE_URL_PREFIX), full_name, strlen(full_name)); + type_url.data = buf; + Message_setval(intern, "type_url", StringVal(type_url)); } -PHP_METHOD(Any, is) { +PHP_METHOD(google_protobuf_Any, is) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + upb_strview type_url = Message_getval(intern, "type_url").str_val; zend_class_entry *klass = NULL; + const upb_msgdef *m; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "C", &klass) == FAILURE) { return; } - DescriptorInternal* desc = get_ce_desc(klass); - if (desc == NULL) { + m = NameMap_GetMessage(klass); + + if (m == NULL) { RETURN_BOOL(false); } - // Create corresponded type url. - const char* fully_qualified_name = upb_msgdef_fullname(desc->msgdef); - size_t type_url_len = - strlen(TYPE_URL_PREFIX) + strlen(fully_qualified_name) + 1; - char* type_url = ALLOC_N(char, type_url_len); - sprintf(type_url, "%s%s", TYPE_URL_PREFIX, fully_qualified_name); - - // Fetch stored type url. - zval member; - PHP_PROTO_ZVAL_STRING(&member, "type_url", 1); - PHP_PROTO_FAKE_SCOPE_BEGIN(any_type); - zval* value = - php_proto_message_read_property(getThis(), &member PHP_PROTO_TSRMLS_CC); - zval_dtor(&member); - PHP_PROTO_FAKE_SCOPE_END; - - // Compare two type url. - bool is = strcmp(type_url, Z_STRVAL_P(value)) == 0; - FREE(type_url); - - RETURN_BOOL(is); + RETURN_BOOL(TryStripUrlPrefix(&type_url) && + StrViewEq(type_url, upb_msgdef_fullname(m))); +} + +PHP_METHOD(google_protobuf_Timestamp, fromDateTime) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + zval* datetime; + const char *classname = "\\DatetimeInterface"; + zend_string *classname_str = zend_string_init(classname, strlen(classname), 0); + zend_class_entry *date_interface_ce = zend_lookup_class(classname_str); + + if (date_interface_ce == NULL) { + zend_error(E_ERROR, "Make sure date extension is enabled."); + return; + } + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &datetime, + date_interface_ce) == FAILURE) { + zend_error(E_USER_ERROR, "Expect DatetimeInterface."); + return; + } + + upb_msgval timestamp_seconds; + { + zval retval; + zval function_name; + + ZVAL_STRING(&function_name, "date_timestamp_get"); + + if (call_user_function(EG(function_table), NULL, &function_name, &retval, 1, + datetime) == FAILURE || + !Convert_PhpToUpb(&retval, ×tamp_seconds, UPB_TYPE_INT64, NULL, + NULL)) { + zend_error(E_ERROR, "Cannot get timestamp from DateTime."); + return; + } + + zval_dtor(&retval); + zval_dtor(&function_name); + } + + upb_msgval timestamp_nanos; + { + zval retval; + zval function_name; + zval format_string; + + ZVAL_STRING(&function_name, "date_format"); + ZVAL_STRING(&format_string, "u"); + + zval params[2] = { + *datetime, + format_string, + }; + + if (call_user_function(EG(function_table), NULL, &function_name, &retval, 2, + params) == FAILURE || + !Convert_PhpToUpb(&retval, ×tamp_nanos, UPB_TYPE_INT32, NULL, + NULL)) { + zend_error(E_ERROR, "Cannot format DateTime."); + return; + } + + timestamp_nanos.int32_val *= 1000; + + zval_dtor(&retval); + zval_dtor(&function_name); + zval_dtor(&format_string); + } + + Message_setval(intern, "seconds", timestamp_seconds); + Message_setval(intern, "nanos", timestamp_nanos); + + RETURN_NULL(); +} + +PHP_METHOD(google_protobuf_Timestamp, toDateTime) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + upb_msgval seconds = Message_getval(intern, "seconds"); + upb_msgval nanos = Message_getval(intern, "nanos"); + + // Get formatted time string. + char formatted_time[32]; + snprintf(formatted_time, sizeof(formatted_time), "%" PRId64 ".%06" PRId32, + seconds.int64_val, nanos.int32_val / 1000); + + // Create Datetime object. + zval datetime; + zval function_name; + zval format_string; + zval formatted_time_php; + + ZVAL_STRING(&function_name, "date_create_from_format"); + ZVAL_STRING(&format_string, "U.u"); + ZVAL_STRING(&formatted_time_php, formatted_time); + + zval params[2] = { + format_string, + formatted_time_php, + }; + + if (call_user_function(EG(function_table), NULL, &function_name, &datetime, 2, + params) == FAILURE) { + zend_error(E_ERROR, "Cannot create DateTime."); + return; + } + + zval_dtor(&function_name); + zval_dtor(&format_string); + zval_dtor(&formatted_time_php); + + ZVAL_OBJ(return_value, Z_OBJ(datetime)); } -*/ #include "wkt.inc" diff --git a/php/ext/google/protobuf/wkt.inc b/php/ext/google/protobuf/wkt.inc index c7a469f951ae..29a6e514e778 100644 --- a/php/ext/google/protobuf/wkt.inc +++ b/php/ext/google/protobuf/wkt.inc @@ -110,6 +110,8 @@ static zend_function_entry google_protobuf_Timestamp_phpmethods[] = { PHP_ME(google_protobuf_Timestamp, setSeconds, NULL, ZEND_ACC_PUBLIC) PHP_ME(google_protobuf_Timestamp, getNanos, NULL, ZEND_ACC_PUBLIC) PHP_ME(google_protobuf_Timestamp, setNanos, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, fromDateTime, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, toDateTime, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; @@ -724,6 +726,8 @@ static zend_function_entry google_protobuf_Any_phpmethods[] = { PHP_ME(google_protobuf_Any, setTypeUrl, NULL, ZEND_ACC_PUBLIC) PHP_ME(google_protobuf_Any, getValue, NULL, ZEND_ACC_PUBLIC) PHP_ME(google_protobuf_Any, setValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, is, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, pack, NULL, ZEND_ACC_PUBLIC) PHP_ME(google_protobuf_Any, unpack, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; @@ -1979,6 +1983,174 @@ static void google_protobuf_Field_ModuleInit() { zend_do_inheritance(google_protobuf_Field_ce, message_ce); } +/* google_protobuf_Field_Kind */ + +zend_class_entry* google_protobuf_Field_Kind_ce; + +PHP_METHOD(google_protobuf_Field_Kind, name) { + google_protobuf_type_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Field.Kind"); + const char *name; + zend_long value; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == + FAILURE) { + return; + } + name = upb_enumdef_iton(e, value); + if (!name) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\Field\\Kind has no name " + "defined for value " ZEND_LONG_FMT ".", + value); + return; + } + RETURN_STRING(name); +} + +PHP_METHOD(google_protobuf_Field_Kind, value) { + google_protobuf_type_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Field.Kind"); + char *name = NULL; + size_t name_len; + int32_t num; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, + &name_len) == FAILURE) { + return; + } + if (!upb_enumdef_ntoi(e, name, name_len, &num)) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\Field\\Kind has no value " + "defined for name %s.", + name); + return; + } + RETURN_LONG(num); +} + +static zend_function_entry google_protobuf_Field_Kind_phpmethods[] = { + PHP_ME(google_protobuf_Field_Kind, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(google_protobuf_Field_Kind, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void google_protobuf_Field_Kind_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Field\\Kind", + google_protobuf_Field_Kind_phpmethods); + + google_protobuf_Field_Kind_ce = zend_register_internal_class(&tmp_ce); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_UNKNOWN", + strlen("TYPE_UNKNOWN"), 0); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_DOUBLE", + strlen("TYPE_DOUBLE"), 1); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_FLOAT", + strlen("TYPE_FLOAT"), 2); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_INT64", + strlen("TYPE_INT64"), 3); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_UINT64", + strlen("TYPE_UINT64"), 4); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_INT32", + strlen("TYPE_INT32"), 5); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_FIXED64", + strlen("TYPE_FIXED64"), 6); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_FIXED32", + strlen("TYPE_FIXED32"), 7); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_BOOL", + strlen("TYPE_BOOL"), 8); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_STRING", + strlen("TYPE_STRING"), 9); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_GROUP", + strlen("TYPE_GROUP"), 10); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_MESSAGE", + strlen("TYPE_MESSAGE"), 11); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_BYTES", + strlen("TYPE_BYTES"), 12); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_UINT32", + strlen("TYPE_UINT32"), 13); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_ENUM", + strlen("TYPE_ENUM"), 14); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_SFIXED32", + strlen("TYPE_SFIXED32"), 15); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_SFIXED64", + strlen("TYPE_SFIXED64"), 16); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_SINT32", + strlen("TYPE_SINT32"), 17); + zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_SINT64", + strlen("TYPE_SINT64"), 18); +} + +/* google_protobuf_Field_Cardinality */ + +zend_class_entry* google_protobuf_Field_Cardinality_ce; + +PHP_METHOD(google_protobuf_Field_Cardinality, name) { + google_protobuf_type_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Field.Cardinality"); + const char *name; + zend_long value; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == + FAILURE) { + return; + } + name = upb_enumdef_iton(e, value); + if (!name) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\Field\\Cardinality has no name " + "defined for value " ZEND_LONG_FMT ".", + value); + return; + } + RETURN_STRING(name); +} + +PHP_METHOD(google_protobuf_Field_Cardinality, value) { + google_protobuf_type_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Field.Cardinality"); + char *name = NULL; + size_t name_len; + int32_t num; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, + &name_len) == FAILURE) { + return; + } + if (!upb_enumdef_ntoi(e, name, name_len, &num)) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\Field\\Cardinality has no value " + "defined for name %s.", + name); + return; + } + RETURN_LONG(num); +} + +static zend_function_entry google_protobuf_Field_Cardinality_phpmethods[] = { + PHP_ME(google_protobuf_Field_Cardinality, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(google_protobuf_Field_Cardinality, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void google_protobuf_Field_Cardinality_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Field\\Cardinality", + google_protobuf_Field_Cardinality_phpmethods); + + google_protobuf_Field_Cardinality_ce = zend_register_internal_class(&tmp_ce); + zend_declare_class_constant_long(google_protobuf_Field_Cardinality_ce, "CARDINALITY_UNKNOWN", + strlen("CARDINALITY_UNKNOWN"), 0); + zend_declare_class_constant_long(google_protobuf_Field_Cardinality_ce, "CARDINALITY_OPTIONAL", + strlen("CARDINALITY_OPTIONAL"), 1); + zend_declare_class_constant_long(google_protobuf_Field_Cardinality_ce, "CARDINALITY_REQUIRED", + strlen("CARDINALITY_REQUIRED"), 2); + zend_declare_class_constant_long(google_protobuf_Field_Cardinality_ce, "CARDINALITY_REPEATED", + strlen("CARDINALITY_REPEATED"), 3); +} + /* google_protobuf_Enum */ zend_class_entry* google_protobuf_Enum_ce; @@ -2297,6 +2469,71 @@ static void google_protobuf_Option_ModuleInit() { zend_do_inheritance(google_protobuf_Option_ce, message_ce); } +/* google_protobuf_Syntax */ + +zend_class_entry* google_protobuf_Syntax_ce; + +PHP_METHOD(google_protobuf_Syntax, name) { + google_protobuf_type_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Syntax"); + const char *name; + zend_long value; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == + FAILURE) { + return; + } + name = upb_enumdef_iton(e, value); + if (!name) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\Syntax has no name " + "defined for value " ZEND_LONG_FMT ".", + value); + return; + } + RETURN_STRING(name); +} + +PHP_METHOD(google_protobuf_Syntax, value) { + google_protobuf_type_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Syntax"); + char *name = NULL; + size_t name_len; + int32_t num; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, + &name_len) == FAILURE) { + return; + } + if (!upb_enumdef_ntoi(e, name, name_len, &num)) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\Syntax has no value " + "defined for name %s.", + name); + return; + } + RETURN_LONG(num); +} + +static zend_function_entry google_protobuf_Syntax_phpmethods[] = { + PHP_ME(google_protobuf_Syntax, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(google_protobuf_Syntax, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void google_protobuf_Syntax_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Syntax", + google_protobuf_Syntax_phpmethods); + + google_protobuf_Syntax_ce = zend_register_internal_class(&tmp_ce); + zend_declare_class_constant_long(google_protobuf_Syntax_ce, "SYNTAX_PROTO2", + strlen("SYNTAX_PROTO2"), 0); + zend_declare_class_constant_long(google_protobuf_Syntax_ce, "SYNTAX_PROTO3", + strlen("SYNTAX_PROTO3"), 1); +} + /* google/protobuf/struct.proto */ zend_class_entry* GPBMetadata_Google_Protobuf_Struct_ce; @@ -2619,6 +2856,13 @@ static PHP_METHOD(google_protobuf_Value, setListValue) { RETURN_ZVAL(getThis(), 1, 0); } +static PHP_METHOD(google_protobuf_Value, getKind) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_oneofdef *oneof = upb_msgdef_ntooz(intern->desc->msgdef, + "kind"); + const upb_fielddef *field = upb_msg_whichoneof(intern->msg, oneof); + RETURN_STRING(field ? upb_fielddef_name(field) : ""); +} static zend_function_entry google_protobuf_Value_phpmethods[] = { PHP_ME(google_protobuf_Value, __construct, NULL, ZEND_ACC_PUBLIC) PHP_ME(google_protobuf_Value, getNullValue, NULL, ZEND_ACC_PUBLIC) @@ -2633,6 +2877,7 @@ static zend_function_entry google_protobuf_Value_phpmethods[] = { PHP_ME(google_protobuf_Value, setStructValue, NULL, ZEND_ACC_PUBLIC) PHP_ME(google_protobuf_Value, getListValue, NULL, ZEND_ACC_PUBLIC) PHP_ME(google_protobuf_Value, setListValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getKind, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; @@ -2698,6 +2943,69 @@ static void google_protobuf_ListValue_ModuleInit() { zend_do_inheritance(google_protobuf_ListValue_ce, message_ce); } +/* google_protobuf_NullValue */ + +zend_class_entry* google_protobuf_NullValue_ce; + +PHP_METHOD(google_protobuf_NullValue, name) { + google_protobuf_struct_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.NullValue"); + const char *name; + zend_long value; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == + FAILURE) { + return; + } + name = upb_enumdef_iton(e, value); + if (!name) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\NullValue has no name " + "defined for value " ZEND_LONG_FMT ".", + value); + return; + } + RETURN_STRING(name); +} + +PHP_METHOD(google_protobuf_NullValue, value) { + google_protobuf_struct_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.NullValue"); + char *name = NULL; + size_t name_len; + int32_t num; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, + &name_len) == FAILURE) { + return; + } + if (!upb_enumdef_ntoi(e, name, name_len, &num)) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\NullValue has no value " + "defined for name %s.", + name); + return; + } + RETURN_LONG(num); +} + +static zend_function_entry google_protobuf_NullValue_phpmethods[] = { + PHP_ME(google_protobuf_NullValue, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(google_protobuf_NullValue, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void google_protobuf_NullValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\NullValue", + google_protobuf_NullValue_phpmethods); + + google_protobuf_NullValue_ce = zend_register_internal_class(&tmp_ce); + zend_declare_class_constant_long(google_protobuf_NullValue_ce, "NULL_VALUE", + strlen("NULL_VALUE"), 0); +} + /* google/protobuf/source_context.proto */ zend_class_entry* GPBMetadata_Google_Protobuf_SourceContext_ce; @@ -2905,14 +3213,18 @@ static void WellKnownTypes_ModuleInit() { GPBMetadata_Google_Protobuf_Type_ModuleInit(); google_protobuf_Type_ModuleInit(); google_protobuf_Field_ModuleInit(); + google_protobuf_Field_Kind_ModuleInit(); + google_protobuf_Field_Cardinality_ModuleInit(); google_protobuf_Enum_ModuleInit(); google_protobuf_EnumValue_ModuleInit(); google_protobuf_Option_ModuleInit(); + google_protobuf_Syntax_ModuleInit(); GPBMetadata_Google_Protobuf_Struct_ModuleInit(); google_protobuf_Struct_ModuleInit(); google_protobuf_Struct_FieldsEntry_ModuleInit(); google_protobuf_Value_ModuleInit(); google_protobuf_ListValue_ModuleInit(); + google_protobuf_NullValue_ModuleInit(); GPBMetadata_Google_Protobuf_SourceContext_ModuleInit(); google_protobuf_SourceContext_ModuleInit(); GPBMetadata_Google_Protobuf_FieldMask_ModuleInit(); diff --git a/php/generate_descriptor_protos.sh b/php/generate_descriptor_protos.sh index f636cc0ebb48..fc2ed8040df3 100755 --- a/php/generate_descriptor_protos.sh +++ b/php/generate_descriptor_protos.sh @@ -13,4 +13,15 @@ fi pushd src ./protoc --php_out=internal:../php/src google/protobuf/descriptor.proto +./protoc --php_out=internal_generate_c_wkt:src \ + google/protobuf/any.proto \ + google/protobuf/api.proto \ + google/protobuf/duration.proto \ + google/protobuf/empty.proto \ + google/protobuf/field_mask.proto \ + google/protobuf/source_context.proto \ + google/protobuf/struct.proto \ + google/protobuf/type.proto \ + google/protobuf/timestamp.proto \ + google/protobuf/wrappers.proto popd diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 9b518f508c0c..8560979d07c2 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -1815,6 +1815,91 @@ std::string FilenameCName(const FileDescriptor* file) { return c_name; } +void GenerateCEnum(const EnumDescriptor* desc, io::Printer* printer) { + std::string c_name = desc->full_name(); + c_name = StringReplace(c_name, ".", "_", true); + std::string php_name = FullClassName(desc, Options()); + php_name = StringReplace(php_name, "\\", "\\\\", true); + printer->Print( + "/* $c_name$ */\n" + "\n" + "zend_class_entry* $c_name$_ce;\n" + "\n" + "PHP_METHOD($c_name$, name) {\n" + " $file_c_name$_AddDescriptor();\n" + " const upb_symtab *symtab = DescriptorPool_GetSymbolTable();\n" + " const upb_enumdef *e = upb_symtab_lookupenum(symtab, \"$name$\");\n" + " const char *name;\n" + " zend_long value;\n" + " if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"l\", &value) ==\n" + " FAILURE) {\n" + " return;\n" + " }\n" + " name = upb_enumdef_iton(e, value);\n" + " if (!name) {\n" + " zend_throw_exception_ex(NULL, 0,\n" + " \"$php_name$ has no name \"\n" + " \"defined for value \" ZEND_LONG_FMT \".\",\n" + " value);\n" + " return;\n" + " }\n" + " RETURN_STRING(name);\n" + "}\n" + "\n" + "PHP_METHOD($c_name$, value) {\n" + " $file_c_name$_AddDescriptor();\n" + " const upb_symtab *symtab = DescriptorPool_GetSymbolTable();\n" + " const upb_enumdef *e = upb_symtab_lookupenum(symtab, \"$name$\");\n" + " char *name = NULL;\n" + " size_t name_len;\n" + " int32_t num;\n" + " if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"s\", &name,\n" + " &name_len) == FAILURE) {\n" + " return;\n" + " }\n" + " if (!upb_enumdef_ntoi(e, name, name_len, &num)) {\n" + " zend_throw_exception_ex(NULL, 0,\n" + " \"$php_name$ has no value \"\n" + " \"defined for name %s.\",\n" + " name);\n" + " return;\n" + " }\n" + " RETURN_LONG(num);\n" + "}\n" + "\n" + "static zend_function_entry $c_name$_phpmethods[] = {\n" + " PHP_ME($c_name$, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)\n" + " PHP_ME($c_name$, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)\n" + " ZEND_FE_END\n" + "};\n" + "\n" + "static void $c_name$_ModuleInit() {\n" + " zend_class_entry tmp_ce;\n" + "\n" + " INIT_CLASS_ENTRY(tmp_ce, \"$php_name$\",\n" + " $c_name$_phpmethods);\n" + "\n" + " $c_name$_ce = zend_register_internal_class(&tmp_ce);\n", + "name", desc->full_name(), + "file_c_name", FilenameCName(desc->file()), + "c_name", c_name, + "php_name", php_name); + + for (int i = 0; i < desc->value_count(); i++) { + const EnumValueDescriptor* value = desc->value(i); + printer->Print( + " zend_declare_class_constant_long($c_name$_ce, \"$name$\",\n" + " strlen(\"$name$\"), $num$);\n", + "c_name", c_name, + "name", value->name(), + "num", std::to_string(value->number())); + } + + printer->Print( + "}\n" + "\n"); +} + void GenerateCMessage(const Descriptor* message, io::Printer* printer) { std::string c_name = message->full_name(); c_name = StringReplace(c_name, ".", "_", true); @@ -1863,6 +1948,21 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) { "camel_name", UnderscoresToCamelCase(field->name(), true)); } + for (int i = 0; i < message->real_oneof_decl_count(); i++) { + auto oneof = message->oneof_decl(i); + printer->Print( + "static PHP_METHOD($c_name$, get$camel_name$) {\n" + " Message* intern = (Message*)Z_OBJ_P(getThis());\n" + " const upb_oneofdef *oneof = upb_msgdef_ntooz(intern->desc->msgdef,\n" + " \"$name$\");\n" + " const upb_fielddef *field = upb_msg_whichoneof(intern->msg, oneof);\n" + " RETURN_STRING(field ? upb_fielddef_name(field) : \"\");\n" + "}\n", + "c_name", c_name, + "name", oneof->name(), + "camel_name", UnderscoresToCamelCase(oneof->name(), true)); + } + printer->Print( "static zend_function_entry $c_name$_phpmethods[] = {\n" " PHP_ME($c_name$, __construct, NULL, ZEND_ACC_PUBLIC)\n", @@ -1877,12 +1977,33 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) { "camel_name", UnderscoresToCamelCase(field->name(), true)); } - if (message->well_known_type() == Descriptor::WELLKNOWNTYPE_ANY) { + for (int i = 0; i < message->real_oneof_decl_count(); i++) { + auto oneof = message->oneof_decl(i); printer->Print( - " PHP_ME($c_name$, unpack, NULL, ZEND_ACC_PUBLIC)\n", - "c_name", c_name); + " PHP_ME($c_name$, get$camel_name$, NULL, ZEND_ACC_PUBLIC)\n", + "c_name", c_name, + "camel_name", UnderscoresToCamelCase(oneof->name(), true)); } + // Extra hand-written functions added to the well-known types. + switch (message->well_known_type()) { + case Descriptor::WELLKNOWNTYPE_ANY: + printer->Print( + " PHP_ME($c_name$, is, NULL, ZEND_ACC_PUBLIC)\n" + " PHP_ME($c_name$, pack, NULL, ZEND_ACC_PUBLIC)\n" + " PHP_ME($c_name$, unpack, NULL, ZEND_ACC_PUBLIC)\n", + "c_name", c_name); + break; + case Descriptor::WELLKNOWNTYPE_TIMESTAMP: + printer->Print( + " PHP_ME($c_name$, fromDateTime, NULL, ZEND_ACC_PUBLIC)\n" + " PHP_ME($c_name$, toDateTime, NULL, ZEND_ACC_PUBLIC)\n", + "c_name", c_name); + break; + default: + break; + } + printer->Print( " ZEND_FE_END\n" "};\n" @@ -1905,6 +2026,18 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) { for (int i = 0; i < message->nested_type_count(); i++) { GenerateCMessage(message->nested_type(i), printer); } + for (int i = 0; i < message->enum_type_count(); i++) { + GenerateCEnum(message->enum_type(i), printer); + } +} + +void GenerateEnumCInit(const EnumDescriptor* desc, io::Printer* printer) { + std::string c_name = desc->full_name(); + c_name = StringReplace(c_name, ".", "_", true); + + printer->Print( + " $c_name$_ModuleInit();\n", + "c_name", c_name); } void GenerateCInit(const Descriptor* message, io::Printer* printer) { @@ -1918,6 +2051,9 @@ void GenerateCInit(const Descriptor* message, io::Printer* printer) { for (int i = 0; i < message->nested_type_count(); i++) { GenerateCInit(message->nested_type(i), printer); } + for (int i = 0; i < message->enum_type_count(); i++) { + GenerateEnumCInit(message->enum_type(i), printer); + } } void GenerateCWellKnownTypes(const std::vector& files, @@ -2011,6 +2147,9 @@ void GenerateCWellKnownTypes(const std::vector& files, for (int i = 0; i < file->message_type_count(); i++) { GenerateCMessage(file->message_type(i), &printer); } + for (int i = 0; i < file->enum_type_count(); i++) { + GenerateCEnum(file->enum_type(i), &printer); + } } printer.Print( @@ -2027,6 +2166,9 @@ void GenerateCWellKnownTypes(const std::vector& files, for (int i = 0; i < file->message_type_count(); i++) { GenerateCInit(file->message_type(i), &printer); } + for (int i = 0; i < file->enum_type_count(); i++) { + GenerateEnumCInit(file->enum_type(i), &printer); + } } printer.Print( From ec4b19460896164cfe3a980de1a0d6ed200f7904 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 5 Oct 2020 22:27:56 -0700 Subject: [PATCH 06/12] Regenerated protos with new script. --- php/ext/google/protobuf/wkt.inc | 2204 ++++++++++++++--------------- php/generate_descriptor_protos.sh | 4 +- 2 files changed, 1105 insertions(+), 1103 deletions(-) diff --git a/php/ext/google/protobuf/wkt.inc b/php/ext/google/protobuf/wkt.inc index 29a6e514e778..573ff30c1478 100644 --- a/php/ext/google/protobuf/wkt.inc +++ b/php/ext/google/protobuf/wkt.inc @@ -1,78 +1,77 @@ // This file is generated from the .proto files for the well-known // types. Do not edit! -static void google_protobuf_timestamp_proto_AddDescriptor(); -static void google_protobuf_wrappers_proto_AddDescriptor(); static void google_protobuf_any_proto_AddDescriptor(); -static void google_protobuf_duration_proto_AddDescriptor(); static void google_protobuf_api_proto_AddDescriptor(); +static void google_protobuf_duration_proto_AddDescriptor(); static void google_protobuf_empty_proto_AddDescriptor(); -static void google_protobuf_type_proto_AddDescriptor(); -static void google_protobuf_struct_proto_AddDescriptor(); -static void google_protobuf_source_context_proto_AddDescriptor(); static void google_protobuf_field_mask_proto_AddDescriptor(); -/* google/protobuf/timestamp.proto */ +static void google_protobuf_source_context_proto_AddDescriptor(); +static void google_protobuf_struct_proto_AddDescriptor(); +static void google_protobuf_type_proto_AddDescriptor(); +static void google_protobuf_timestamp_proto_AddDescriptor(); +static void google_protobuf_wrappers_proto_AddDescriptor(); +/* google/protobuf/any.proto */ -zend_class_entry* GPBMetadata_Google_Protobuf_Timestamp_ce; +zend_class_entry* GPBMetadata_Google_Protobuf_Any_ce; -const char google_protobuf_timestamp_proto_descriptor [239] = { -'\n', '\037', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'i', 'm', 'e', 's', 't', 'a', -'m', 'p', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', -'\"', '+', '\n', '\t', 'T', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', '\022', '\017', '\n', '\007', 's', 'e', 'c', 'o', 'n', 'd', 's', '\030', -'\001', ' ', '\001', '(', '\003', '\022', '\r', '\n', '\005', 'n', 'a', 'n', 'o', 's', '\030', '\002', ' ', '\001', '(', '\005', 'B', '\205', '\001', '\n', '\023', -'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\016', 'T', 'i', 'm', 'e', -'s', 't', 'a', 'm', 'p', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', -'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', -'w', 'n', '/', 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', -'\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', -'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +const char google_protobuf_any_proto_descriptor [212] = { +'\n', '\031', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'n', 'y', '.', 'p', 'r', 'o', +'t', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '&', '\n', '\003', 'A', 'n', +'y', '\022', '\020', '\n', '\010', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\r', '\n', '\005', 'v', 'a', +'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\014', 'B', 'v', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', +'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\010', 'A', 'n', 'y', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', ',', 'g', 'o', 'o', 'g', +'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', +'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'a', 'n', 'y', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', +'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', +'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', }; -static void google_protobuf_timestamp_proto_AddDescriptor() { - if (DescriptorPool_HasFile("google/protobuf/timestamp.proto")) return; - DescriptorPool_AddDescriptor("google/protobuf/timestamp.proto", google_protobuf_timestamp_proto_descriptor, - sizeof(google_protobuf_timestamp_proto_descriptor)); +static void google_protobuf_any_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/any.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/any.proto", google_protobuf_any_proto_descriptor, + sizeof(google_protobuf_any_proto_descriptor)); } -static PHP_METHOD(GPBMetadata_Google_Protobuf_Timestamp, initOnce) { - google_protobuf_timestamp_proto_AddDescriptor(); +static PHP_METHOD(GPBMetadata_Google_Protobuf_Any, initOnce) { + google_protobuf_any_proto_AddDescriptor(); } -static zend_function_entry GPBMetadata_Google_Protobuf_Timestamp_methods[] = { - PHP_ME(GPBMetadata_Google_Protobuf_Timestamp, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +static zend_function_entry GPBMetadata_Google_Protobuf_Any_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Any, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) ZEND_FE_END }; -static void GPBMetadata_Google_Protobuf_Timestamp_ModuleInit() { +static void GPBMetadata_Google_Protobuf_Any_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Timestamp", - GPBMetadata_Google_Protobuf_Timestamp_methods); + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Any", + GPBMetadata_Google_Protobuf_Any_methods); - GPBMetadata_Google_Protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); + GPBMetadata_Google_Protobuf_Any_ce = zend_register_internal_class(&tmp_ce); } -/* google_protobuf_Timestamp */ +/* google_protobuf_Any */ -zend_class_entry* google_protobuf_Timestamp_ce; +zend_class_entry* google_protobuf_Any_ce; -static PHP_METHOD(google_protobuf_Timestamp, __construct) { - google_protobuf_timestamp_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_Any, __construct) { + google_protobuf_any_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_Timestamp, getSeconds) { +static PHP_METHOD(google_protobuf_Any, getTypeUrl) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "seconds"); + "type_url"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Timestamp, setSeconds) { +static PHP_METHOD(google_protobuf_Any, setTypeUrl) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "seconds"); + "type_url"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -82,19 +81,19 @@ static PHP_METHOD(google_protobuf_Timestamp, setSeconds) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Timestamp, getNanos) { +static PHP_METHOD(google_protobuf_Any, getValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "nanos"); + "value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Timestamp, setNanos) { +static PHP_METHOD(google_protobuf_Any, setValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "nanos"); + "value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -104,101 +103,116 @@ static PHP_METHOD(google_protobuf_Timestamp, setNanos) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_Timestamp_phpmethods[] = { - PHP_ME(google_protobuf_Timestamp, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, getSeconds, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, setSeconds, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, getNanos, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, setNanos, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, fromDateTime, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Timestamp, toDateTime, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_Any_phpmethods[] = { + PHP_ME(google_protobuf_Any, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, getTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, setTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, setValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, is, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, pack, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Any, unpack, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_Timestamp_ModuleInit() { +static void google_protobuf_Any_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Timestamp", - google_protobuf_Timestamp_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Any", + google_protobuf_Any_phpmethods); - google_protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Timestamp_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Timestamp_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Timestamp_ce, message_ce); + google_protobuf_Any_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Any_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Any_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Any_ce, message_ce); } -/* google/protobuf/wrappers.proto */ +/* google/protobuf/api.proto */ -zend_class_entry* GPBMetadata_Google_Protobuf_Wrappers_ce; +zend_class_entry* GPBMetadata_Google_Protobuf_Api_ce; -const char google_protobuf_wrappers_proto_descriptor [455] = { -'\n', '\036', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'w', 'r', 'a', 'p', 'p', 'e', 'r', -'s', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', -'\034', '\n', '\013', 'D', 'o', 'u', 'b', 'l', 'e', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', -' ', '\001', '(', '\001', '\"', '\033', '\n', '\n', 'F', 'l', 'o', 'a', 't', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', -'u', 'e', '\030', '\001', ' ', '\001', '(', '\002', '\"', '\033', '\n', '\n', 'I', 'n', 't', '6', '4', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', -'\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\003', '\"', '\034', '\n', '\013', 'U', 'I', 'n', 't', '6', '4', 'V', 'a', 'l', -'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\004', '\"', '\033', '\n', '\n', 'I', 'n', 't', '3', -'2', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\005', '\"', '\034', '\n', '\013', -'U', 'I', 'n', 't', '3', '2', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', -'\r', '\"', '\032', '\n', '\t', 'B', 'o', 'o', 'l', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', -' ', '\001', '(', '\010', '\"', '\034', '\n', '\013', 'S', 't', 'r', 'i', 'n', 'g', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', -'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\"', '\033', '\n', '\n', 'B', 'y', 't', 'e', 's', 'V', 'a', 'l', 'u', 'e', '\022', '\r', -'\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\014', 'B', '\203', '\001', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', -'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\r', 'W', 'r', 'a', 'p', 'p', 'e', 'r', 's', 'P', 'r', 'o', -'t', 'o', 'P', '\001', 'Z', '1', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', -'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'w', 'r', 'a', 'p', 'p', -'e', 'r', 's', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', -'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', -'r', 'o', 't', 'o', '3', +const char google_protobuf_api_proto_descriptor [751] = { +'\n', '\031', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'p', 'i', '.', 'p', 'r', 'o', +'t', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\032', '$', 'g', 'o', 'o', 'g', +'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', +'t', '.', 'p', 'r', 'o', 't', 'o', '\032', '\032', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', +'t', 'y', 'p', 'e', '.', 'p', 'r', 'o', 't', 'o', '\"', '\201', '\002', '\n', '\003', 'A', 'p', 'i', '\022', '\014', '\n', '\004', 'n', 'a', 'm', +'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '(', '\n', '\007', 'm', 'e', 't', 'h', 'o', 'd', 's', '\030', '\002', ' ', '\003', '(', '\013', '2', +'\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', 'e', 't', 'h', 'o', 'd', '\022', +'(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', +'.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\017', '\n', '\007', 'v', 'e', 'r', 's', 'i', +'o', 'n', '\030', '\004', ' ', '\001', '(', '\t', '\022', '6', '\n', '\016', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', +'t', '\030', '\005', ' ', '\001', '(', '\013', '2', '\036', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', +'.', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '&', '\n', '\006', 'm', 'i', 'x', 'i', 'n', 's', '\030', +'\006', ' ', '\003', '(', '\013', '2', '\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', +'i', 'x', 'i', 'n', '\022', '\'', '\n', '\006', 's', 'y', 'n', 't', 'a', 'x', '\030', '\007', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', +'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', '\325', '\001', '\n', '\006', +'M', 'e', 't', 'h', 'o', 'd', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\030', '\n', '\020', 'r', +'e', 'q', 'u', 'e', 's', 't', '_', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\002', ' ', '\001', '(', '\t', '\022', '\031', '\n', '\021', +'r', 'e', 'q', 'u', 'e', 's', 't', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\003', ' ', '\001', '(', '\010', '\022', '\031', +'\n', '\021', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e', '_', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\004', ' ', '\001', '(', '\t', +'\022', '\032', '\n', '\022', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\005', ' ', +'\001', '(', '\010', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\006', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', +'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\'', '\n', '\006', 's', +'y', 'n', 't', 'a', 'x', '\030', '\007', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', +'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', '#', '\n', '\005', 'M', 'i', 'x', 'i', 'n', '\022', '\014', '\n', '\004', 'n', +'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\014', '\n', '\004', 'r', 'o', 'o', 't', '\030', '\002', ' ', '\001', '(', '\t', 'B', 'v', +'\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\010', 'A', 'p', +'i', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', ',', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', +'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'a', +'p', 'i', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', +'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', +'3', }; -static void google_protobuf_wrappers_proto_AddDescriptor() { - if (DescriptorPool_HasFile("google/protobuf/wrappers.proto")) return; - DescriptorPool_AddDescriptor("google/protobuf/wrappers.proto", google_protobuf_wrappers_proto_descriptor, - sizeof(google_protobuf_wrappers_proto_descriptor)); +static void google_protobuf_api_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/api.proto")) return; + google_protobuf_source_context_proto_AddDescriptor(); + google_protobuf_type_proto_AddDescriptor(); + DescriptorPool_AddDescriptor("google/protobuf/api.proto", google_protobuf_api_proto_descriptor, + sizeof(google_protobuf_api_proto_descriptor)); } -static PHP_METHOD(GPBMetadata_Google_Protobuf_Wrappers, initOnce) { - google_protobuf_wrappers_proto_AddDescriptor(); +static PHP_METHOD(GPBMetadata_Google_Protobuf_Api, initOnce) { + google_protobuf_api_proto_AddDescriptor(); } -static zend_function_entry GPBMetadata_Google_Protobuf_Wrappers_methods[] = { - PHP_ME(GPBMetadata_Google_Protobuf_Wrappers, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +static zend_function_entry GPBMetadata_Google_Protobuf_Api_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Api, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) ZEND_FE_END }; -static void GPBMetadata_Google_Protobuf_Wrappers_ModuleInit() { +static void GPBMetadata_Google_Protobuf_Api_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Wrappers", - GPBMetadata_Google_Protobuf_Wrappers_methods); + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Api", + GPBMetadata_Google_Protobuf_Api_methods); - GPBMetadata_Google_Protobuf_Wrappers_ce = zend_register_internal_class(&tmp_ce); + GPBMetadata_Google_Protobuf_Api_ce = zend_register_internal_class(&tmp_ce); } -/* google_protobuf_DoubleValue */ +/* google_protobuf_Api */ -zend_class_entry* google_protobuf_DoubleValue_ce; +zend_class_entry* google_protobuf_Api_ce; -static PHP_METHOD(google_protobuf_DoubleValue, __construct) { - google_protobuf_wrappers_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_Api, __construct) { + google_protobuf_api_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_DoubleValue, getValue) { +static PHP_METHOD(google_protobuf_Api, getName) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "name"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_DoubleValue, setValue) { +static PHP_METHOD(google_protobuf_Api, setName) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "name"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -208,47 +222,19 @@ static PHP_METHOD(google_protobuf_DoubleValue, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_DoubleValue_phpmethods[] = { - PHP_ME(google_protobuf_DoubleValue, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_DoubleValue, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_DoubleValue, setValue, NULL, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_DoubleValue_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\DoubleValue", - google_protobuf_DoubleValue_phpmethods); - - google_protobuf_DoubleValue_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_DoubleValue_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_DoubleValue_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_DoubleValue_ce, message_ce); -} - -/* google_protobuf_FloatValue */ - -zend_class_entry* google_protobuf_FloatValue_ce; - -static PHP_METHOD(google_protobuf_FloatValue, __construct) { - google_protobuf_wrappers_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} - -static PHP_METHOD(google_protobuf_FloatValue, getValue) { +static PHP_METHOD(google_protobuf_Api, getMethods) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "methods"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_FloatValue, setValue) { +static PHP_METHOD(google_protobuf_Api, setMethods) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "methods"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -258,47 +244,19 @@ static PHP_METHOD(google_protobuf_FloatValue, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_FloatValue_phpmethods[] = { - PHP_ME(google_protobuf_FloatValue, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_FloatValue, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_FloatValue, setValue, NULL, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_FloatValue_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\FloatValue", - google_protobuf_FloatValue_phpmethods); - - google_protobuf_FloatValue_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_FloatValue_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_FloatValue_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_FloatValue_ce, message_ce); -} - -/* google_protobuf_Int64Value */ - -zend_class_entry* google_protobuf_Int64Value_ce; - -static PHP_METHOD(google_protobuf_Int64Value, __construct) { - google_protobuf_wrappers_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} - -static PHP_METHOD(google_protobuf_Int64Value, getValue) { +static PHP_METHOD(google_protobuf_Api, getOptions) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "options"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Int64Value, setValue) { +static PHP_METHOD(google_protobuf_Api, setOptions) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "options"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -308,47 +266,19 @@ static PHP_METHOD(google_protobuf_Int64Value, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_Int64Value_phpmethods[] = { - PHP_ME(google_protobuf_Int64Value, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Int64Value, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Int64Value, setValue, NULL, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_Int64Value_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Int64Value", - google_protobuf_Int64Value_phpmethods); - - google_protobuf_Int64Value_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Int64Value_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Int64Value_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Int64Value_ce, message_ce); -} - -/* google_protobuf_UInt64Value */ - -zend_class_entry* google_protobuf_UInt64Value_ce; - -static PHP_METHOD(google_protobuf_UInt64Value, __construct) { - google_protobuf_wrappers_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} - -static PHP_METHOD(google_protobuf_UInt64Value, getValue) { +static PHP_METHOD(google_protobuf_Api, getVersion) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "version"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_UInt64Value, setValue) { +static PHP_METHOD(google_protobuf_Api, setVersion) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "version"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -358,47 +288,19 @@ static PHP_METHOD(google_protobuf_UInt64Value, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_UInt64Value_phpmethods[] = { - PHP_ME(google_protobuf_UInt64Value, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_UInt64Value, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_UInt64Value, setValue, NULL, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_UInt64Value_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\UInt64Value", - google_protobuf_UInt64Value_phpmethods); - - google_protobuf_UInt64Value_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_UInt64Value_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_UInt64Value_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_UInt64Value_ce, message_ce); -} - -/* google_protobuf_Int32Value */ - -zend_class_entry* google_protobuf_Int32Value_ce; - -static PHP_METHOD(google_protobuf_Int32Value, __construct) { - google_protobuf_wrappers_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} - -static PHP_METHOD(google_protobuf_Int32Value, getValue) { +static PHP_METHOD(google_protobuf_Api, getSourceContext) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "source_context"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Int32Value, setValue) { +static PHP_METHOD(google_protobuf_Api, setSourceContext) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "source_context"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -408,47 +310,41 @@ static PHP_METHOD(google_protobuf_Int32Value, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_Int32Value_phpmethods[] = { - PHP_ME(google_protobuf_Int32Value, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Int32Value, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Int32Value, setValue, NULL, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_Int32Value_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Int32Value", - google_protobuf_Int32Value_phpmethods); - - google_protobuf_Int32Value_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Int32Value_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Int32Value_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Int32Value_ce, message_ce); +static PHP_METHOD(google_protobuf_Api, getMixins) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "mixins"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); } -/* google_protobuf_UInt32Value */ - -zend_class_entry* google_protobuf_UInt32Value_ce; - -static PHP_METHOD(google_protobuf_UInt32Value, __construct) { - google_protobuf_wrappers_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +static PHP_METHOD(google_protobuf_Api, setMixins) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "mixins"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_UInt32Value, getValue) { +static PHP_METHOD(google_protobuf_Api, getSyntax) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "syntax"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_UInt32Value, setValue) { +static PHP_METHOD(google_protobuf_Api, setSyntax) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "syntax"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -458,47 +354,59 @@ static PHP_METHOD(google_protobuf_UInt32Value, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_UInt32Value_phpmethods[] = { - PHP_ME(google_protobuf_UInt32Value, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_UInt32Value, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_UInt32Value, setValue, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_Api_phpmethods[] = { + PHP_ME(google_protobuf_Api, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getMethods, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setMethods, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getVersion, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setVersion, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setSourceContext, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getMixins, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setMixins, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Api, setSyntax, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_UInt32Value_ModuleInit() { +static void google_protobuf_Api_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\UInt32Value", - google_protobuf_UInt32Value_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Api", + google_protobuf_Api_phpmethods); - google_protobuf_UInt32Value_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_UInt32Value_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_UInt32Value_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_UInt32Value_ce, message_ce); + google_protobuf_Api_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Api_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Api_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Api_ce, message_ce); } -/* google_protobuf_BoolValue */ +/* google_protobuf_Method */ -zend_class_entry* google_protobuf_BoolValue_ce; +zend_class_entry* google_protobuf_Method_ce; -static PHP_METHOD(google_protobuf_BoolValue, __construct) { - google_protobuf_wrappers_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_Method, __construct) { + google_protobuf_api_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_BoolValue, getValue) { +static PHP_METHOD(google_protobuf_Method, getName) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "name"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_BoolValue, setValue) { +static PHP_METHOD(google_protobuf_Method, setName) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "name"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -508,47 +416,41 @@ static PHP_METHOD(google_protobuf_BoolValue, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_BoolValue_phpmethods[] = { - PHP_ME(google_protobuf_BoolValue, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_BoolValue, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_BoolValue, setValue, NULL, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_BoolValue_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\BoolValue", - google_protobuf_BoolValue_phpmethods); - - google_protobuf_BoolValue_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_BoolValue_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_BoolValue_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_BoolValue_ce, message_ce); +static PHP_METHOD(google_protobuf_Method, getRequestTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "request_type_url"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); } -/* google_protobuf_StringValue */ - -zend_class_entry* google_protobuf_StringValue_ce; - -static PHP_METHOD(google_protobuf_StringValue, __construct) { - google_protobuf_wrappers_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +static PHP_METHOD(google_protobuf_Method, setRequestTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "request_type_url"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_StringValue, getValue) { +static PHP_METHOD(google_protobuf_Method, getRequestStreaming) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "request_streaming"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_StringValue, setValue) { +static PHP_METHOD(google_protobuf_Method, setRequestStreaming) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "request_streaming"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -558,47 +460,41 @@ static PHP_METHOD(google_protobuf_StringValue, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_StringValue_phpmethods[] = { - PHP_ME(google_protobuf_StringValue, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_StringValue, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_StringValue, setValue, NULL, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_StringValue_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\StringValue", - google_protobuf_StringValue_phpmethods); - - google_protobuf_StringValue_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_StringValue_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_StringValue_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_StringValue_ce, message_ce); +static PHP_METHOD(google_protobuf_Method, getResponseTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "response_type_url"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); } -/* google_protobuf_BytesValue */ - -zend_class_entry* google_protobuf_BytesValue_ce; - -static PHP_METHOD(google_protobuf_BytesValue, __construct) { - google_protobuf_wrappers_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +static PHP_METHOD(google_protobuf_Method, setResponseTypeUrl) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "response_type_url"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_BytesValue, getValue) { +static PHP_METHOD(google_protobuf_Method, getResponseStreaming) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "response_streaming"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_BytesValue, setValue) { +static PHP_METHOD(google_protobuf_Method, setResponseStreaming) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "response_streaming"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -608,87 +504,103 @@ static PHP_METHOD(google_protobuf_BytesValue, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_BytesValue_phpmethods[] = { - PHP_ME(google_protobuf_BytesValue, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_BytesValue, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_BytesValue, setValue, NULL, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_BytesValue_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\BytesValue", - google_protobuf_BytesValue_phpmethods); - - google_protobuf_BytesValue_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_BytesValue_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_BytesValue_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_BytesValue_ce, message_ce); +static PHP_METHOD(google_protobuf_Method, getOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); } -/* google/protobuf/any.proto */ - -zend_class_entry* GPBMetadata_Google_Protobuf_Any_ce; - -const char google_protobuf_any_proto_descriptor [212] = { -'\n', '\031', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'n', 'y', '.', 'p', 'r', 'o', -'t', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '&', '\n', '\003', 'A', 'n', -'y', '\022', '\020', '\n', '\010', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\r', '\n', '\005', 'v', 'a', -'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\014', 'B', 'v', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', -'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\010', 'A', 'n', 'y', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', ',', 'g', 'o', 'o', 'g', -'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', -'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'a', 'n', 'y', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', -'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', -'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', -}; +static PHP_METHOD(google_protobuf_Method, setOptions) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "options"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); +} -static void google_protobuf_any_proto_AddDescriptor() { - if (DescriptorPool_HasFile("google/protobuf/any.proto")) return; - DescriptorPool_AddDescriptor("google/protobuf/any.proto", google_protobuf_any_proto_descriptor, - sizeof(google_protobuf_any_proto_descriptor)); +static PHP_METHOD(google_protobuf_Method, getSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(GPBMetadata_Google_Protobuf_Any, initOnce) { - google_protobuf_any_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_Method, setSyntax) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "syntax"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry GPBMetadata_Google_Protobuf_Any_methods[] = { - PHP_ME(GPBMetadata_Google_Protobuf_Any, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +static zend_function_entry google_protobuf_Method_phpmethods[] = { + PHP_ME(google_protobuf_Method, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getRequestTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setRequestTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getRequestStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setRequestStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getResponseTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setResponseTypeUrl, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getResponseStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setResponseStreaming, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setOptions, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, getSyntax, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Method, setSyntax, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void GPBMetadata_Google_Protobuf_Any_ModuleInit() { +static void google_protobuf_Method_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Any", - GPBMetadata_Google_Protobuf_Any_methods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Method", + google_protobuf_Method_phpmethods); - GPBMetadata_Google_Protobuf_Any_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Method_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Method_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Method_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Method_ce, message_ce); } -/* google_protobuf_Any */ +/* google_protobuf_Mixin */ -zend_class_entry* google_protobuf_Any_ce; +zend_class_entry* google_protobuf_Mixin_ce; -static PHP_METHOD(google_protobuf_Any, __construct) { - google_protobuf_any_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_Mixin, __construct) { + google_protobuf_api_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_Any, getTypeUrl) { +static PHP_METHOD(google_protobuf_Mixin, getName) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "type_url"); + "name"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Any, setTypeUrl) { +static PHP_METHOD(google_protobuf_Mixin, setName) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "type_url"); + "name"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -698,19 +610,19 @@ static PHP_METHOD(google_protobuf_Any, setTypeUrl) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Any, getValue) { +static PHP_METHOD(google_protobuf_Mixin, getRoot) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "root"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Any, setValue) { +static PHP_METHOD(google_protobuf_Mixin, setRoot) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); + "root"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -720,28 +632,25 @@ static PHP_METHOD(google_protobuf_Any, setValue) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_Any_phpmethods[] = { - PHP_ME(google_protobuf_Any, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Any, getTypeUrl, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Any, setTypeUrl, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Any, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Any, setValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Any, is, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Any, pack, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Any, unpack, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_Mixin_phpmethods[] = { + PHP_ME(google_protobuf_Mixin, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Mixin, getName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Mixin, setName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Mixin, getRoot, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Mixin, setRoot, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_Any_ModuleInit() { +static void google_protobuf_Mixin_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Any", - google_protobuf_Any_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Mixin", + google_protobuf_Mixin_phpmethods); - google_protobuf_Any_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Any_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Any_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Any_ce, message_ce); + google_protobuf_Mixin_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Mixin_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Mixin_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Mixin_ce, message_ce); } /* google/protobuf/duration.proto */ @@ -859,136 +768,133 @@ static void google_protobuf_Duration_ModuleInit() { zend_do_inheritance(google_protobuf_Duration_ce, message_ce); } -/* google/protobuf/api.proto */ +/* google/protobuf/empty.proto */ -zend_class_entry* GPBMetadata_Google_Protobuf_Api_ce; +zend_class_entry* GPBMetadata_Google_Protobuf_GPBEmpty_ce; -const char google_protobuf_api_proto_descriptor [751] = { -'\n', '\031', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'p', 'i', '.', 'p', 'r', 'o', -'t', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\032', '$', 'g', 'o', 'o', 'g', -'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', -'t', '.', 'p', 'r', 'o', 't', 'o', '\032', '\032', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', -'t', 'y', 'p', 'e', '.', 'p', 'r', 'o', 't', 'o', '\"', '\201', '\002', '\n', '\003', 'A', 'p', 'i', '\022', '\014', '\n', '\004', 'n', 'a', 'm', -'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '(', '\n', '\007', 'm', 'e', 't', 'h', 'o', 'd', 's', '\030', '\002', ' ', '\003', '(', '\013', '2', -'\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', 'e', 't', 'h', 'o', 'd', '\022', -'(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', -'.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\017', '\n', '\007', 'v', 'e', 'r', 's', 'i', -'o', 'n', '\030', '\004', ' ', '\001', '(', '\t', '\022', '6', '\n', '\016', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', -'t', '\030', '\005', ' ', '\001', '(', '\013', '2', '\036', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', -'.', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '&', '\n', '\006', 'm', 'i', 'x', 'i', 'n', 's', '\030', -'\006', ' ', '\003', '(', '\013', '2', '\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', -'i', 'x', 'i', 'n', '\022', '\'', '\n', '\006', 's', 'y', 'n', 't', 'a', 'x', '\030', '\007', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', -'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', '\325', '\001', '\n', '\006', -'M', 'e', 't', 'h', 'o', 'd', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\030', '\n', '\020', 'r', -'e', 'q', 'u', 'e', 's', 't', '_', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\002', ' ', '\001', '(', '\t', '\022', '\031', '\n', '\021', -'r', 'e', 'q', 'u', 'e', 's', 't', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\003', ' ', '\001', '(', '\010', '\022', '\031', -'\n', '\021', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e', '_', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\004', ' ', '\001', '(', '\t', -'\022', '\032', '\n', '\022', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\005', ' ', -'\001', '(', '\010', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\006', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', -'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\'', '\n', '\006', 's', -'y', 'n', 't', 'a', 'x', '\030', '\007', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', -'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', '#', '\n', '\005', 'M', 'i', 'x', 'i', 'n', '\022', '\014', '\n', '\004', 'n', -'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\014', '\n', '\004', 'r', 'o', 'o', 't', '\030', '\002', ' ', '\001', '(', '\t', 'B', 'v', -'\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\010', 'A', 'p', -'i', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', ',', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', -'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'a', -'p', 'i', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', -'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', -'3', +const char google_protobuf_empty_proto_descriptor [190] = { +'\n', '\033', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'e', 'm', 'p', 't', 'y', '.', 'p', +'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '\007', '\n', '\005', +'E', 'm', 'p', 't', 'y', 'B', '}', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', +'b', 'u', 'f', 'B', '\n', 'E', 'm', 'p', 't', 'y', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '.', 'g', 'o', 'o', 'g', 'l', 'e', +'.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', +'s', '/', 'k', 'n', 'o', 'w', 'n', '/', 'e', 'm', 'p', 't', 'y', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', +'\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', +'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', }; -static void google_protobuf_api_proto_AddDescriptor() { - if (DescriptorPool_HasFile("google/protobuf/api.proto")) return; - google_protobuf_source_context_proto_AddDescriptor(); - google_protobuf_type_proto_AddDescriptor(); - DescriptorPool_AddDescriptor("google/protobuf/api.proto", google_protobuf_api_proto_descriptor, - sizeof(google_protobuf_api_proto_descriptor)); -} - -static PHP_METHOD(GPBMetadata_Google_Protobuf_Api, initOnce) { - google_protobuf_api_proto_AddDescriptor(); +static void google_protobuf_empty_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/empty.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/empty.proto", google_protobuf_empty_proto_descriptor, + sizeof(google_protobuf_empty_proto_descriptor)); } -static zend_function_entry GPBMetadata_Google_Protobuf_Api_methods[] = { - PHP_ME(GPBMetadata_Google_Protobuf_Api, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +static PHP_METHOD(GPBMetadata_Google_Protobuf_GPBEmpty, initOnce) { + google_protobuf_empty_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_GPBEmpty_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_GPBEmpty, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) ZEND_FE_END }; -static void GPBMetadata_Google_Protobuf_Api_ModuleInit() { +static void GPBMetadata_Google_Protobuf_GPBEmpty_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Api", - GPBMetadata_Google_Protobuf_Api_methods); + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\GPBEmpty", + GPBMetadata_Google_Protobuf_GPBEmpty_methods); - GPBMetadata_Google_Protobuf_Api_ce = zend_register_internal_class(&tmp_ce); + GPBMetadata_Google_Protobuf_GPBEmpty_ce = zend_register_internal_class(&tmp_ce); } -/* google_protobuf_Api */ +/* google_protobuf_Empty */ -zend_class_entry* google_protobuf_Api_ce; +zend_class_entry* google_protobuf_Empty_ce; -static PHP_METHOD(google_protobuf_Api, __construct) { - google_protobuf_api_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_Empty, __construct) { + google_protobuf_empty_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_Api, getName) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "name"); - zval ret; - Message_get(intern, f, &ret); - RETURN_ZVAL(&ret, 1, 0); +static zend_function_entry google_protobuf_Empty_phpmethods[] = { + PHP_ME(google_protobuf_Empty, __construct, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Empty_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\GPBEmpty", + google_protobuf_Empty_phpmethods); + + google_protobuf_Empty_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Empty_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Empty_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Empty_ce, message_ce); } -static PHP_METHOD(google_protobuf_Api, setName) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "name"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_ZVAL(getThis(), 1, 0); +/* google/protobuf/field_mask.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_FieldMask_ce; + +const char google_protobuf_field_mask_proto_descriptor [223] = { +'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'f', 'i', 'e', 'l', 'd', '_', 'm', +'a', 's', 'k', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', +'f', '\"', '\032', '\n', '\t', 'F', 'i', 'e', 'l', 'd', 'M', 'a', 's', 'k', '\022', '\r', '\n', '\005', 'p', 'a', 't', 'h', 's', '\030', '\001', +' ', '\003', '(', '\t', 'B', '\205', '\001', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', +'b', 'u', 'f', 'B', '\016', 'F', 'i', 'e', 'l', 'd', 'M', 'a', 's', 'k', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', +'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', +'t', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'f', 'i', 'e', 'l', 'd', 'm', 'a', 's', 'k', 'p', 'b', '\370', '\001', +'\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', +'.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_field_mask_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/field_mask.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/field_mask.proto", google_protobuf_field_mask_proto_descriptor, + sizeof(google_protobuf_field_mask_proto_descriptor)); } -static PHP_METHOD(google_protobuf_Api, getMethods) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "methods"); - zval ret; - Message_get(intern, f, &ret); - RETURN_ZVAL(&ret, 1, 0); +static PHP_METHOD(GPBMetadata_Google_Protobuf_FieldMask, initOnce) { + google_protobuf_field_mask_proto_AddDescriptor(); } -static PHP_METHOD(google_protobuf_Api, setMethods) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "methods"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_ZVAL(getThis(), 1, 0); +static zend_function_entry GPBMetadata_Google_Protobuf_FieldMask_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_FieldMask, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_FieldMask_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\FieldMask", + GPBMetadata_Google_Protobuf_FieldMask_methods); + + GPBMetadata_Google_Protobuf_FieldMask_ce = zend_register_internal_class(&tmp_ce); } -static PHP_METHOD(google_protobuf_Api, getOptions) { +/* google_protobuf_FieldMask */ + +zend_class_entry* google_protobuf_FieldMask_ce; + +static PHP_METHOD(google_protobuf_FieldMask, __construct) { + google_protobuf_field_mask_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_FieldMask, getPaths) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "options"); + "paths"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Api, setOptions) { +static PHP_METHOD(google_protobuf_FieldMask, setPaths) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "options"); + "paths"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -998,19 +904,88 @@ static PHP_METHOD(google_protobuf_Api, setOptions) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Api, getVersion) { +static zend_function_entry google_protobuf_FieldMask_phpmethods[] = { + PHP_ME(google_protobuf_FieldMask, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_FieldMask, getPaths, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_FieldMask, setPaths, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_FieldMask_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\FieldMask", + google_protobuf_FieldMask_phpmethods); + + google_protobuf_FieldMask_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_FieldMask_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_FieldMask_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_FieldMask_ce, message_ce); +} + +/* google/protobuf/source_context.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_SourceContext_ce; + +const char google_protobuf_source_context_proto_descriptor [240] = { +'\n', '$', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', +'c', 'o', 'n', 't', 'e', 'x', 't', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', +'t', 'o', 'b', 'u', 'f', '\"', '\"', '\n', '\r', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '\021', '\n', +'\t', 'f', 'i', 'l', 'e', '_', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'B', '\212', '\001', '\n', '\023', 'c', 'o', 'm', '.', +'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\022', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', +'n', 't', 'e', 'x', 't', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '6', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', +'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', +'w', 'n', '/', 's', 'o', 'u', 'r', 'c', 'e', 'c', 'o', 'n', 't', 'e', 'x', 't', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', +'\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', +'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_source_context_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/source_context.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/source_context.proto", google_protobuf_source_context_proto_descriptor, + sizeof(google_protobuf_source_context_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_SourceContext, initOnce) { + google_protobuf_source_context_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_SourceContext_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_SourceContext, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_SourceContext_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\SourceContext", + GPBMetadata_Google_Protobuf_SourceContext_methods); + + GPBMetadata_Google_Protobuf_SourceContext_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_SourceContext */ + +zend_class_entry* google_protobuf_SourceContext_ce; + +static PHP_METHOD(google_protobuf_SourceContext, __construct) { + google_protobuf_source_context_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_SourceContext, getFileName) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "version"); + "file_name"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Api, setVersion) { +static PHP_METHOD(google_protobuf_SourceContext, setFileName) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "version"); + "file_name"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1020,19 +995,104 @@ static PHP_METHOD(google_protobuf_Api, setVersion) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Api, getSourceContext) { +static zend_function_entry google_protobuf_SourceContext_phpmethods[] = { + PHP_ME(google_protobuf_SourceContext, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_SourceContext, getFileName, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_SourceContext, setFileName, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_SourceContext_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\SourceContext", + google_protobuf_SourceContext_phpmethods); + + google_protobuf_SourceContext_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_SourceContext_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_SourceContext_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_SourceContext_ce, message_ce); +} + +/* google/protobuf/struct.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Struct_ce; + +const char google_protobuf_struct_proto_descriptor [638] = { +'\n', '\034', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 't', 'r', 'u', 'c', 't', '.', +'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '\204', '\001', +'\n', '\006', 'S', 't', 'r', 'u', 'c', 't', '\022', '3', '\n', '\006', 'f', 'i', 'e', 'l', 'd', 's', '\030', '\001', ' ', '\003', '(', '\013', '2', +'#', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 't', 'r', 'u', 'c', 't', '.', +'F', 'i', 'e', 'l', 'd', 's', 'E', 'n', 't', 'r', 'y', '\032', 'E', '\n', '\013', 'F', 'i', 'e', 'l', 'd', 's', 'E', 'n', 't', 'r', +'y', '\022', '\013', '\n', '\003', 'k', 'e', 'y', '\030', '\001', ' ', '\001', '(', '\t', '\022', '%', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\002', +' ', '\001', '(', '\013', '2', '\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'V', 'a', +'l', 'u', 'e', ':', '\002', '8', '\001', '\"', '\352', '\001', '\n', '\005', 'V', 'a', 'l', 'u', 'e', '\022', '0', '\n', '\n', 'n', 'u', 'l', 'l', +'_', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\016', '2', '\032', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', +'t', 'o', 'b', 'u', 'f', '.', 'N', 'u', 'l', 'l', 'V', 'a', 'l', 'u', 'e', 'H', '\000', '\022', '\026', '\n', '\014', 'n', 'u', 'm', 'b', +'e', 'r', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\001', 'H', '\000', '\022', '\026', '\n', '\014', 's', 't', 'r', 'i', 'n', +'g', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\003', ' ', '\001', '(', '\t', 'H', '\000', '\022', '\024', '\n', '\n', 'b', 'o', 'o', 'l', '_', 'v', +'a', 'l', 'u', 'e', '\030', '\004', ' ', '\001', '(', '\010', 'H', '\000', '\022', '/', '\n', '\014', 's', 't', 'r', 'u', 'c', 't', '_', 'v', 'a', +'l', 'u', 'e', '\030', '\005', ' ', '\001', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', +'u', 'f', '.', 'S', 't', 'r', 'u', 'c', 't', 'H', '\000', '\022', '0', '\n', '\n', 'l', 'i', 's', 't', '_', 'v', 'a', 'l', 'u', 'e', +'\030', '\006', ' ', '\001', '(', '\013', '2', '\032', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', +'L', 'i', 's', 't', 'V', 'a', 'l', 'u', 'e', 'H', '\000', 'B', '\006', '\n', '\004', 'k', 'i', 'n', 'd', '\"', '3', '\n', '\t', 'L', 'i', +'s', 't', 'V', 'a', 'l', 'u', 'e', '\022', '&', '\n', '\006', 'v', 'a', 'l', 'u', 'e', 's', '\030', '\001', ' ', '\003', '(', '\013', '2', '\026', +'.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'V', 'a', 'l', 'u', 'e', '*', '\033', '\n', +'\t', 'N', 'u', 'l', 'l', 'V', 'a', 'l', 'u', 'e', '\022', '\016', '\n', '\n', 'N', 'U', 'L', 'L', '_', 'V', 'A', 'L', 'U', 'E', '\020', +'\000', 'B', '\177', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', +'\013', 'S', 't', 'r', 'u', 'c', 't', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '/', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', +'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', +'n', 'o', 'w', 'n', '/', 's', 't', 'r', 'u', 'c', 't', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', +'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', +'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_struct_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/struct.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/struct.proto", google_protobuf_struct_proto_descriptor, + sizeof(google_protobuf_struct_proto_descriptor)); +} + +static PHP_METHOD(GPBMetadata_Google_Protobuf_Struct, initOnce) { + google_protobuf_struct_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Struct_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Struct, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FE_END +}; + +static void GPBMetadata_Google_Protobuf_Struct_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Struct", + GPBMetadata_Google_Protobuf_Struct_methods); + + GPBMetadata_Google_Protobuf_Struct_ce = zend_register_internal_class(&tmp_ce); +} + +/* google_protobuf_Struct */ + +zend_class_entry* google_protobuf_Struct_ce; + +static PHP_METHOD(google_protobuf_Struct, __construct) { + google_protobuf_struct_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Struct, getFields) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "source_context"); + "fields"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Api, setSourceContext) { +static PHP_METHOD(google_protobuf_Struct, setFields) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "source_context"); + "fields"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1042,19 +1102,47 @@ static PHP_METHOD(google_protobuf_Api, setSourceContext) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Api, getMixins) { +static zend_function_entry google_protobuf_Struct_phpmethods[] = { + PHP_ME(google_protobuf_Struct, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct, getFields, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct, setFields, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Struct_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Struct", + google_protobuf_Struct_phpmethods); + + google_protobuf_Struct_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Struct_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Struct_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Struct_ce, message_ce); +} + +/* google_protobuf_Struct_FieldsEntry */ + +zend_class_entry* google_protobuf_Struct_FieldsEntry_ce; + +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, __construct) { + google_protobuf_struct_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, getKey) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "mixins"); + "key"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Api, setMixins) { +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, setKey) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "mixins"); + "key"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1064,19 +1152,19 @@ static PHP_METHOD(google_protobuf_Api, setMixins) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Api, getSyntax) { +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, getValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "syntax"); + "value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Api, setSyntax) { +static PHP_METHOD(google_protobuf_Struct_FieldsEntry, setValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "syntax"); + "value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1086,81 +1174,49 @@ static PHP_METHOD(google_protobuf_Api, setSyntax) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_Api_phpmethods[] = { - PHP_ME(google_protobuf_Api, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, getName, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, setName, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, getMethods, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, setMethods, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, getOptions, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, setOptions, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, getVersion, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, setVersion, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, getSourceContext, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, setSourceContext, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, getMixins, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, setMixins, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, getSyntax, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Api, setSyntax, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_Struct_FieldsEntry_phpmethods[] = { + PHP_ME(google_protobuf_Struct_FieldsEntry, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct_FieldsEntry, getKey, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct_FieldsEntry, setKey, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct_FieldsEntry, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Struct_FieldsEntry, setValue, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_Api_ModuleInit() { +static void google_protobuf_Struct_FieldsEntry_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Api", - google_protobuf_Api_phpmethods); - - google_protobuf_Api_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Api_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Api_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Api_ce, message_ce); -} - -/* google_protobuf_Method */ - -zend_class_entry* google_protobuf_Method_ce; - -static PHP_METHOD(google_protobuf_Method, __construct) { - google_protobuf_api_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} - -static PHP_METHOD(google_protobuf_Method, getName) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "name"); - zval ret; - Message_get(intern, f, &ret); - RETURN_ZVAL(&ret, 1, 0); -} + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Struct\\FieldsEntry", + google_protobuf_Struct_FieldsEntry_phpmethods); -static PHP_METHOD(google_protobuf_Method, setName) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "name"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_ZVAL(getThis(), 1, 0); + google_protobuf_Struct_FieldsEntry_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Struct_FieldsEntry_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Struct_FieldsEntry_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Struct_FieldsEntry_ce, message_ce); } -static PHP_METHOD(google_protobuf_Method, getRequestTypeUrl) { +/* google_protobuf_Value */ + +zend_class_entry* google_protobuf_Value_ce; + +static PHP_METHOD(google_protobuf_Value, __construct) { + google_protobuf_struct_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} + +static PHP_METHOD(google_protobuf_Value, getNullValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "request_type_url"); + "null_value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Method, setRequestTypeUrl) { +static PHP_METHOD(google_protobuf_Value, setNullValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "request_type_url"); + "null_value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1170,19 +1226,19 @@ static PHP_METHOD(google_protobuf_Method, setRequestTypeUrl) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Method, getRequestStreaming) { +static PHP_METHOD(google_protobuf_Value, getNumberValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "request_streaming"); + "number_value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Method, setRequestStreaming) { +static PHP_METHOD(google_protobuf_Value, setNumberValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "request_streaming"); + "number_value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1192,19 +1248,19 @@ static PHP_METHOD(google_protobuf_Method, setRequestStreaming) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Method, getResponseTypeUrl) { +static PHP_METHOD(google_protobuf_Value, getStringValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "response_type_url"); + "string_value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Method, setResponseTypeUrl) { +static PHP_METHOD(google_protobuf_Value, setStringValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "response_type_url"); + "string_value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1214,19 +1270,19 @@ static PHP_METHOD(google_protobuf_Method, setResponseTypeUrl) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Method, getResponseStreaming) { +static PHP_METHOD(google_protobuf_Value, getBoolValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "response_streaming"); + "bool_value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Method, setResponseStreaming) { +static PHP_METHOD(google_protobuf_Value, setBoolValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "response_streaming"); + "bool_value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1236,19 +1292,19 @@ static PHP_METHOD(google_protobuf_Method, setResponseStreaming) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Method, getOptions) { +static PHP_METHOD(google_protobuf_Value, getStructValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "options"); + "struct_value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Method, setOptions) { +static PHP_METHOD(google_protobuf_Value, setStructValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "options"); + "struct_value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1258,19 +1314,19 @@ static PHP_METHOD(google_protobuf_Method, setOptions) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Method, getSyntax) { +static PHP_METHOD(google_protobuf_Value, getListValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "syntax"); + "list_value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Method, setSyntax) { +static PHP_METHOD(google_protobuf_Value, setListValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "syntax"); + "list_value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1280,81 +1336,65 @@ static PHP_METHOD(google_protobuf_Method, setSyntax) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_Method_phpmethods[] = { - PHP_ME(google_protobuf_Method, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, getName, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, setName, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, getRequestTypeUrl, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, setRequestTypeUrl, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, getRequestStreaming, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, setRequestStreaming, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, getResponseTypeUrl, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, setResponseTypeUrl, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, getResponseStreaming, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, setResponseStreaming, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, getOptions, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, setOptions, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, getSyntax, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Method, setSyntax, NULL, ZEND_ACC_PUBLIC) +static PHP_METHOD(google_protobuf_Value, getKind) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_oneofdef *oneof = upb_msgdef_ntooz(intern->desc->msgdef, + "kind"); + const upb_fielddef *field = upb_msg_whichoneof(intern->msg, oneof); + RETURN_STRING(field ? upb_fielddef_name(field) : ""); +} +static zend_function_entry google_protobuf_Value_phpmethods[] = { + PHP_ME(google_protobuf_Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getNullValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setNullValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getNumberValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setNumberValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getStringValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setStringValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getBoolValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setBoolValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getStructValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setStructValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getListValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, setListValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Value, getKind, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_Method_ModuleInit() { +static void google_protobuf_Value_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Method", - google_protobuf_Method_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Value", + google_protobuf_Value_phpmethods); - google_protobuf_Method_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Method_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Method_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Method_ce, message_ce); + google_protobuf_Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Value_ce, message_ce); } -/* google_protobuf_Mixin */ +/* google_protobuf_ListValue */ -zend_class_entry* google_protobuf_Mixin_ce; +zend_class_entry* google_protobuf_ListValue_ce; -static PHP_METHOD(google_protobuf_Mixin, __construct) { - google_protobuf_api_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_ListValue, __construct) { + google_protobuf_struct_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_Mixin, getName) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "name"); - zval ret; - Message_get(intern, f, &ret); - RETURN_ZVAL(&ret, 1, 0); -} - -static PHP_METHOD(google_protobuf_Mixin, setName) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "name"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_ZVAL(getThis(), 1, 0); -} - -static PHP_METHOD(google_protobuf_Mixin, getRoot) { +static PHP_METHOD(google_protobuf_ListValue, getValues) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "root"); + "values"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Mixin, setRoot) { +static PHP_METHOD(google_protobuf_ListValue, setValues) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "root"); + "values"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -1364,90 +1404,86 @@ static PHP_METHOD(google_protobuf_Mixin, setRoot) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_Mixin_phpmethods[] = { - PHP_ME(google_protobuf_Mixin, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Mixin, getName, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Mixin, setName, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Mixin, getRoot, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Mixin, setRoot, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_ListValue_phpmethods[] = { + PHP_ME(google_protobuf_ListValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_ListValue, getValues, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_ListValue, setValues, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_Mixin_ModuleInit() { +static void google_protobuf_ListValue_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Mixin", - google_protobuf_Mixin_phpmethods); - - google_protobuf_Mixin_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Mixin_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Mixin_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Mixin_ce, message_ce); -} - -/* google/protobuf/empty.proto */ - -zend_class_entry* GPBMetadata_Google_Protobuf_GPBEmpty_ce; - -const char google_protobuf_empty_proto_descriptor [190] = { -'\n', '\033', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'e', 'm', 'p', 't', 'y', '.', 'p', -'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '\007', '\n', '\005', -'E', 'm', 'p', 't', 'y', 'B', '}', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', -'b', 'u', 'f', 'B', '\n', 'E', 'm', 'p', 't', 'y', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '.', 'g', 'o', 'o', 'g', 'l', 'e', -'.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', -'s', '/', 'k', 'n', 'o', 'w', 'n', '/', 'e', 'm', 'p', 't', 'y', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', -'\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', -'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', -}; - -static void google_protobuf_empty_proto_AddDescriptor() { - if (DescriptorPool_HasFile("google/protobuf/empty.proto")) return; - DescriptorPool_AddDescriptor("google/protobuf/empty.proto", google_protobuf_empty_proto_descriptor, - sizeof(google_protobuf_empty_proto_descriptor)); -} + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\ListValue", + google_protobuf_ListValue_phpmethods); -static PHP_METHOD(GPBMetadata_Google_Protobuf_GPBEmpty, initOnce) { - google_protobuf_empty_proto_AddDescriptor(); + google_protobuf_ListValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_ListValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_ListValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_ListValue_ce, message_ce); } -static zend_function_entry GPBMetadata_Google_Protobuf_GPBEmpty_methods[] = { - PHP_ME(GPBMetadata_Google_Protobuf_GPBEmpty, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - ZEND_FE_END -}; - -static void GPBMetadata_Google_Protobuf_GPBEmpty_ModuleInit() { - zend_class_entry tmp_ce; +/* google_protobuf_NullValue */ - INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\GPBEmpty", - GPBMetadata_Google_Protobuf_GPBEmpty_methods); +zend_class_entry* google_protobuf_NullValue_ce; - GPBMetadata_Google_Protobuf_GPBEmpty_ce = zend_register_internal_class(&tmp_ce); +PHP_METHOD(google_protobuf_NullValue, name) { + google_protobuf_struct_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.NullValue"); + const char *name; + zend_long value; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == + FAILURE) { + return; + } + name = upb_enumdef_iton(e, value); + if (!name) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\NullValue has no name " + "defined for value " ZEND_LONG_FMT ".", + value); + return; + } + RETURN_STRING(name); } -/* google_protobuf_Empty */ - -zend_class_entry* google_protobuf_Empty_ce; - -static PHP_METHOD(google_protobuf_Empty, __construct) { - google_protobuf_empty_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +PHP_METHOD(google_protobuf_NullValue, value) { + google_protobuf_struct_proto_AddDescriptor(); + const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); + const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.NullValue"); + char *name = NULL; + size_t name_len; + int32_t num; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, + &name_len) == FAILURE) { + return; + } + if (!upb_enumdef_ntoi(e, name, name_len, &num)) { + zend_throw_exception_ex(NULL, 0, + "Google\\Protobuf\\NullValue has no value " + "defined for name %s.", + name); + return; + } + RETURN_LONG(num); } -static zend_function_entry google_protobuf_Empty_phpmethods[] = { - PHP_ME(google_protobuf_Empty, __construct, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_NullValue_phpmethods[] = { + PHP_ME(google_protobuf_NullValue, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + PHP_ME(google_protobuf_NullValue, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) ZEND_FE_END }; -static void google_protobuf_Empty_ModuleInit() { +static void google_protobuf_NullValue_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\GPBEmpty", - google_protobuf_Empty_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\NullValue", + google_protobuf_NullValue_phpmethods); - google_protobuf_Empty_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Empty_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Empty_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Empty_ce, message_ce); + google_protobuf_NullValue_ce = zend_register_internal_class(&tmp_ce); + zend_declare_class_constant_long(google_protobuf_NullValue_ce, "NULL_VALUE", + strlen("NULL_VALUE"), 0); } /* google/protobuf/type.proto */ @@ -2534,85 +2570,69 @@ static void google_protobuf_Syntax_ModuleInit() { strlen("SYNTAX_PROTO3"), 1); } -/* google/protobuf/struct.proto */ +/* google/protobuf/timestamp.proto */ -zend_class_entry* GPBMetadata_Google_Protobuf_Struct_ce; +zend_class_entry* GPBMetadata_Google_Protobuf_Timestamp_ce; -const char google_protobuf_struct_proto_descriptor [638] = { -'\n', '\034', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 't', 'r', 'u', 'c', 't', '.', -'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '\204', '\001', -'\n', '\006', 'S', 't', 'r', 'u', 'c', 't', '\022', '3', '\n', '\006', 'f', 'i', 'e', 'l', 'd', 's', '\030', '\001', ' ', '\003', '(', '\013', '2', -'#', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 't', 'r', 'u', 'c', 't', '.', -'F', 'i', 'e', 'l', 'd', 's', 'E', 'n', 't', 'r', 'y', '\032', 'E', '\n', '\013', 'F', 'i', 'e', 'l', 'd', 's', 'E', 'n', 't', 'r', -'y', '\022', '\013', '\n', '\003', 'k', 'e', 'y', '\030', '\001', ' ', '\001', '(', '\t', '\022', '%', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\002', -' ', '\001', '(', '\013', '2', '\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'V', 'a', -'l', 'u', 'e', ':', '\002', '8', '\001', '\"', '\352', '\001', '\n', '\005', 'V', 'a', 'l', 'u', 'e', '\022', '0', '\n', '\n', 'n', 'u', 'l', 'l', -'_', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\016', '2', '\032', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', -'t', 'o', 'b', 'u', 'f', '.', 'N', 'u', 'l', 'l', 'V', 'a', 'l', 'u', 'e', 'H', '\000', '\022', '\026', '\n', '\014', 'n', 'u', 'm', 'b', -'e', 'r', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\001', 'H', '\000', '\022', '\026', '\n', '\014', 's', 't', 'r', 'i', 'n', -'g', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\003', ' ', '\001', '(', '\t', 'H', '\000', '\022', '\024', '\n', '\n', 'b', 'o', 'o', 'l', '_', 'v', -'a', 'l', 'u', 'e', '\030', '\004', ' ', '\001', '(', '\010', 'H', '\000', '\022', '/', '\n', '\014', 's', 't', 'r', 'u', 'c', 't', '_', 'v', 'a', -'l', 'u', 'e', '\030', '\005', ' ', '\001', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', -'u', 'f', '.', 'S', 't', 'r', 'u', 'c', 't', 'H', '\000', '\022', '0', '\n', '\n', 'l', 'i', 's', 't', '_', 'v', 'a', 'l', 'u', 'e', -'\030', '\006', ' ', '\001', '(', '\013', '2', '\032', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', -'L', 'i', 's', 't', 'V', 'a', 'l', 'u', 'e', 'H', '\000', 'B', '\006', '\n', '\004', 'k', 'i', 'n', 'd', '\"', '3', '\n', '\t', 'L', 'i', -'s', 't', 'V', 'a', 'l', 'u', 'e', '\022', '&', '\n', '\006', 'v', 'a', 'l', 'u', 'e', 's', '\030', '\001', ' ', '\003', '(', '\013', '2', '\026', -'.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'V', 'a', 'l', 'u', 'e', '*', '\033', '\n', -'\t', 'N', 'u', 'l', 'l', 'V', 'a', 'l', 'u', 'e', '\022', '\016', '\n', '\n', 'N', 'U', 'L', 'L', '_', 'V', 'A', 'L', 'U', 'E', '\020', -'\000', 'B', '\177', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', -'\013', 'S', 't', 'r', 'u', 'c', 't', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '/', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', -'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', -'n', 'o', 'w', 'n', '/', 's', 't', 'r', 'u', 'c', 't', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', -'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', -'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', +const char google_protobuf_timestamp_proto_descriptor [239] = { +'\n', '\037', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'i', 'm', 'e', 's', 't', 'a', +'m', 'p', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', +'\"', '+', '\n', '\t', 'T', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', '\022', '\017', '\n', '\007', 's', 'e', 'c', 'o', 'n', 'd', 's', '\030', +'\001', ' ', '\001', '(', '\003', '\022', '\r', '\n', '\005', 'n', 'a', 'n', 'o', 's', '\030', '\002', ' ', '\001', '(', '\005', 'B', '\205', '\001', '\n', '\023', +'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\016', 'T', 'i', 'm', 'e', +'s', 't', 'a', 'm', 'p', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', +'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', +'w', 'n', '/', 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', +'\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', +'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', }; -static void google_protobuf_struct_proto_AddDescriptor() { - if (DescriptorPool_HasFile("google/protobuf/struct.proto")) return; - DescriptorPool_AddDescriptor("google/protobuf/struct.proto", google_protobuf_struct_proto_descriptor, - sizeof(google_protobuf_struct_proto_descriptor)); +static void google_protobuf_timestamp_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/timestamp.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/timestamp.proto", google_protobuf_timestamp_proto_descriptor, + sizeof(google_protobuf_timestamp_proto_descriptor)); } -static PHP_METHOD(GPBMetadata_Google_Protobuf_Struct, initOnce) { - google_protobuf_struct_proto_AddDescriptor(); +static PHP_METHOD(GPBMetadata_Google_Protobuf_Timestamp, initOnce) { + google_protobuf_timestamp_proto_AddDescriptor(); } -static zend_function_entry GPBMetadata_Google_Protobuf_Struct_methods[] = { - PHP_ME(GPBMetadata_Google_Protobuf_Struct, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +static zend_function_entry GPBMetadata_Google_Protobuf_Timestamp_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Timestamp, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) ZEND_FE_END }; -static void GPBMetadata_Google_Protobuf_Struct_ModuleInit() { +static void GPBMetadata_Google_Protobuf_Timestamp_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Struct", - GPBMetadata_Google_Protobuf_Struct_methods); + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Timestamp", + GPBMetadata_Google_Protobuf_Timestamp_methods); - GPBMetadata_Google_Protobuf_Struct_ce = zend_register_internal_class(&tmp_ce); + GPBMetadata_Google_Protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); } -/* google_protobuf_Struct */ +/* google_protobuf_Timestamp */ -zend_class_entry* google_protobuf_Struct_ce; +zend_class_entry* google_protobuf_Timestamp_ce; -static PHP_METHOD(google_protobuf_Struct, __construct) { - google_protobuf_struct_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_Timestamp, __construct) { + google_protobuf_timestamp_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_Struct, getFields) { +static PHP_METHOD(google_protobuf_Timestamp, getSeconds) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "fields"); + "seconds"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Struct, setFields) { +static PHP_METHOD(google_protobuf_Timestamp, setSeconds) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "fields"); + "seconds"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -2622,47 +2642,19 @@ static PHP_METHOD(google_protobuf_Struct, setFields) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_Struct_phpmethods[] = { - PHP_ME(google_protobuf_Struct, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Struct, getFields, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Struct, setFields, NULL, ZEND_ACC_PUBLIC) - ZEND_FE_END -}; - -static void google_protobuf_Struct_ModuleInit() { - zend_class_entry tmp_ce; - - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Struct", - google_protobuf_Struct_phpmethods); - - google_protobuf_Struct_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Struct_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Struct_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Struct_ce, message_ce); -} - -/* google_protobuf_Struct_FieldsEntry */ - -zend_class_entry* google_protobuf_Struct_FieldsEntry_ce; - -static PHP_METHOD(google_protobuf_Struct_FieldsEntry, __construct) { - google_protobuf_struct_proto_AddDescriptor(); - zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} - -static PHP_METHOD(google_protobuf_Struct_FieldsEntry, getKey) { +static PHP_METHOD(google_protobuf_Timestamp, getNanos) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "key"); + "nanos"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Struct_FieldsEntry, setKey) { +static PHP_METHOD(google_protobuf_Timestamp, setNanos) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "key"); + "nanos"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -2672,93 +2664,101 @@ static PHP_METHOD(google_protobuf_Struct_FieldsEntry, setKey) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Struct_FieldsEntry, getValue) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); - zval ret; - Message_get(intern, f, &ret); - RETURN_ZVAL(&ret, 1, 0); +static zend_function_entry google_protobuf_Timestamp_phpmethods[] = { + PHP_ME(google_protobuf_Timestamp, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, getSeconds, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, setSeconds, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, getNanos, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, setNanos, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, fromDateTime, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Timestamp, toDateTime, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_Timestamp_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Timestamp", + google_protobuf_Timestamp_phpmethods); + + google_protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Timestamp_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Timestamp_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Timestamp_ce, message_ce); } -static PHP_METHOD(google_protobuf_Struct_FieldsEntry, setValue) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "value"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_ZVAL(getThis(), 1, 0); +/* google/protobuf/wrappers.proto */ + +zend_class_entry* GPBMetadata_Google_Protobuf_Wrappers_ce; + +const char google_protobuf_wrappers_proto_descriptor [455] = { +'\n', '\036', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'w', 'r', 'a', 'p', 'p', 'e', 'r', +'s', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', +'\034', '\n', '\013', 'D', 'o', 'u', 'b', 'l', 'e', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', +' ', '\001', '(', '\001', '\"', '\033', '\n', '\n', 'F', 'l', 'o', 'a', 't', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', +'u', 'e', '\030', '\001', ' ', '\001', '(', '\002', '\"', '\033', '\n', '\n', 'I', 'n', 't', '6', '4', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', +'\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\003', '\"', '\034', '\n', '\013', 'U', 'I', 'n', 't', '6', '4', 'V', 'a', 'l', +'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\004', '\"', '\033', '\n', '\n', 'I', 'n', 't', '3', +'2', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\005', '\"', '\034', '\n', '\013', +'U', 'I', 'n', 't', '3', '2', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', +'\r', '\"', '\032', '\n', '\t', 'B', 'o', 'o', 'l', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', +' ', '\001', '(', '\010', '\"', '\034', '\n', '\013', 'S', 't', 'r', 'i', 'n', 'g', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', +'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\"', '\033', '\n', '\n', 'B', 'y', 't', 'e', 's', 'V', 'a', 'l', 'u', 'e', '\022', '\r', +'\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\014', 'B', '\203', '\001', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', +'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\r', 'W', 'r', 'a', 'p', 'p', 'e', 'r', 's', 'P', 'r', 'o', +'t', 'o', 'P', '\001', 'Z', '1', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', +'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'w', 'r', 'a', 'p', 'p', +'e', 'r', 's', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', +'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', +'r', 'o', 't', 'o', '3', +}; + +static void google_protobuf_wrappers_proto_AddDescriptor() { + if (DescriptorPool_HasFile("google/protobuf/wrappers.proto")) return; + DescriptorPool_AddDescriptor("google/protobuf/wrappers.proto", google_protobuf_wrappers_proto_descriptor, + sizeof(google_protobuf_wrappers_proto_descriptor)); } -static zend_function_entry google_protobuf_Struct_FieldsEntry_phpmethods[] = { - PHP_ME(google_protobuf_Struct_FieldsEntry, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Struct_FieldsEntry, getKey, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Struct_FieldsEntry, setKey, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Struct_FieldsEntry, getValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Struct_FieldsEntry, setValue, NULL, ZEND_ACC_PUBLIC) +static PHP_METHOD(GPBMetadata_Google_Protobuf_Wrappers, initOnce) { + google_protobuf_wrappers_proto_AddDescriptor(); +} + +static zend_function_entry GPBMetadata_Google_Protobuf_Wrappers_methods[] = { + PHP_ME(GPBMetadata_Google_Protobuf_Wrappers, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) ZEND_FE_END }; -static void google_protobuf_Struct_FieldsEntry_ModuleInit() { +static void GPBMetadata_Google_Protobuf_Wrappers_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Struct\\FieldsEntry", - google_protobuf_Struct_FieldsEntry_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Wrappers", + GPBMetadata_Google_Protobuf_Wrappers_methods); - google_protobuf_Struct_FieldsEntry_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Struct_FieldsEntry_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Struct_FieldsEntry_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Struct_FieldsEntry_ce, message_ce); + GPBMetadata_Google_Protobuf_Wrappers_ce = zend_register_internal_class(&tmp_ce); } -/* google_protobuf_Value */ +/* google_protobuf_DoubleValue */ -zend_class_entry* google_protobuf_Value_ce; +zend_class_entry* google_protobuf_DoubleValue_ce; -static PHP_METHOD(google_protobuf_Value, __construct) { - google_protobuf_struct_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_DoubleValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_Value, getNullValue) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "null_value"); - zval ret; - Message_get(intern, f, &ret); - RETURN_ZVAL(&ret, 1, 0); -} - -static PHP_METHOD(google_protobuf_Value, setNullValue) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "null_value"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_ZVAL(getThis(), 1, 0); -} - -static PHP_METHOD(google_protobuf_Value, getNumberValue) { +static PHP_METHOD(google_protobuf_DoubleValue, getValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "number_value"); + "value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Value, setNumberValue) { +static PHP_METHOD(google_protobuf_DoubleValue, setValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "number_value"); + "value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -2768,41 +2768,47 @@ static PHP_METHOD(google_protobuf_Value, setNumberValue) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Value, getStringValue) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "string_value"); - zval ret; - Message_get(intern, f, &ret); - RETURN_ZVAL(&ret, 1, 0); +static zend_function_entry google_protobuf_DoubleValue_phpmethods[] = { + PHP_ME(google_protobuf_DoubleValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_DoubleValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_DoubleValue, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_DoubleValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\DoubleValue", + google_protobuf_DoubleValue_phpmethods); + + google_protobuf_DoubleValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_DoubleValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_DoubleValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_DoubleValue_ce, message_ce); } -static PHP_METHOD(google_protobuf_Value, setStringValue) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "string_value"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_ZVAL(getThis(), 1, 0); +/* google_protobuf_FloatValue */ + +zend_class_entry* google_protobuf_FloatValue_ce; + +static PHP_METHOD(google_protobuf_FloatValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_Value, getBoolValue) { +static PHP_METHOD(google_protobuf_FloatValue, getValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "bool_value"); + "value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Value, setBoolValue) { +static PHP_METHOD(google_protobuf_FloatValue, setValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "bool_value"); + "value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -2812,41 +2818,47 @@ static PHP_METHOD(google_protobuf_Value, setBoolValue) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Value, getStructValue) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "struct_value"); - zval ret; - Message_get(intern, f, &ret); - RETURN_ZVAL(&ret, 1, 0); +static zend_function_entry google_protobuf_FloatValue_phpmethods[] = { + PHP_ME(google_protobuf_FloatValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_FloatValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_FloatValue, setValue, NULL, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static void google_protobuf_FloatValue_ModuleInit() { + zend_class_entry tmp_ce; + + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\FloatValue", + google_protobuf_FloatValue_phpmethods); + + google_protobuf_FloatValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_FloatValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_FloatValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_FloatValue_ce, message_ce); } -static PHP_METHOD(google_protobuf_Value, setStructValue) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "struct_value"); - zval *val; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) - == FAILURE) { - return; - } - Message_set(intern, f, val); - RETURN_ZVAL(getThis(), 1, 0); +/* google_protobuf_Int64Value */ + +zend_class_entry* google_protobuf_Int64Value_ce; + +static PHP_METHOD(google_protobuf_Int64Value, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_Value, getListValue) { +static PHP_METHOD(google_protobuf_Int64Value, getValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "list_value"); + "value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_Value, setListValue) { +static PHP_METHOD(google_protobuf_Int64Value, setValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "list_value"); + "value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -2856,65 +2868,47 @@ static PHP_METHOD(google_protobuf_Value, setListValue) { RETURN_ZVAL(getThis(), 1, 0); } -static PHP_METHOD(google_protobuf_Value, getKind) { - Message* intern = (Message*)Z_OBJ_P(getThis()); - const upb_oneofdef *oneof = upb_msgdef_ntooz(intern->desc->msgdef, - "kind"); - const upb_fielddef *field = upb_msg_whichoneof(intern->msg, oneof); - RETURN_STRING(field ? upb_fielddef_name(field) : ""); -} -static zend_function_entry google_protobuf_Value_phpmethods[] = { - PHP_ME(google_protobuf_Value, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, getNullValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, setNullValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, getNumberValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, setNumberValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, getStringValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, setStringValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, getBoolValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, setBoolValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, getStructValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, setStructValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, getListValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, setListValue, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_Value, getKind, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_Int64Value_phpmethods[] = { + PHP_ME(google_protobuf_Int64Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Int64Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Int64Value, setValue, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_Value_ModuleInit() { +static void google_protobuf_Int64Value_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Value", - google_protobuf_Value_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Int64Value", + google_protobuf_Int64Value_phpmethods); - google_protobuf_Value_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_Value_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_Value_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_Value_ce, message_ce); + google_protobuf_Int64Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Int64Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Int64Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Int64Value_ce, message_ce); } -/* google_protobuf_ListValue */ +/* google_protobuf_UInt64Value */ -zend_class_entry* google_protobuf_ListValue_ce; +zend_class_entry* google_protobuf_UInt64Value_ce; -static PHP_METHOD(google_protobuf_ListValue, __construct) { - google_protobuf_struct_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_UInt64Value, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_ListValue, getValues) { +static PHP_METHOD(google_protobuf_UInt64Value, getValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "values"); + "value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_ListValue, setValues) { +static PHP_METHOD(google_protobuf_UInt64Value, setValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "values"); + "value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -2924,151 +2918,147 @@ static PHP_METHOD(google_protobuf_ListValue, setValues) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_ListValue_phpmethods[] = { - PHP_ME(google_protobuf_ListValue, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_ListValue, getValues, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_ListValue, setValues, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_UInt64Value_phpmethods[] = { + PHP_ME(google_protobuf_UInt64Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_UInt64Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_UInt64Value, setValue, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_ListValue_ModuleInit() { +static void google_protobuf_UInt64Value_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\ListValue", - google_protobuf_ListValue_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\UInt64Value", + google_protobuf_UInt64Value_phpmethods); - google_protobuf_ListValue_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_ListValue_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_ListValue_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_ListValue_ce, message_ce); + google_protobuf_UInt64Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_UInt64Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_UInt64Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_UInt64Value_ce, message_ce); } -/* google_protobuf_NullValue */ +/* google_protobuf_Int32Value */ -zend_class_entry* google_protobuf_NullValue_ce; +zend_class_entry* google_protobuf_Int32Value_ce; -PHP_METHOD(google_protobuf_NullValue, name) { - google_protobuf_struct_proto_AddDescriptor(); - const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); - const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.NullValue"); - const char *name; - zend_long value; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == - FAILURE) { - return; - } - name = upb_enumdef_iton(e, value); - if (!name) { - zend_throw_exception_ex(NULL, 0, - "Google\\Protobuf\\NullValue has no name " - "defined for value " ZEND_LONG_FMT ".", - value); - return; - } - RETURN_STRING(name); +static PHP_METHOD(google_protobuf_Int32Value, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -PHP_METHOD(google_protobuf_NullValue, value) { - google_protobuf_struct_proto_AddDescriptor(); - const upb_symtab *symtab = DescriptorPool_GetSymbolTable(); - const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.NullValue"); - char *name = NULL; - size_t name_len; - int32_t num; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, - &name_len) == FAILURE) { - return; - } - if (!upb_enumdef_ntoi(e, name, name_len, &num)) { - zend_throw_exception_ex(NULL, 0, - "Google\\Protobuf\\NullValue has no value " - "defined for name %s.", - name); +static PHP_METHOD(google_protobuf_Int32Value, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); +} + +static PHP_METHOD(google_protobuf_Int32Value, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { return; } - RETURN_LONG(num); + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_NullValue_phpmethods[] = { - PHP_ME(google_protobuf_NullValue, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_ME(google_protobuf_NullValue, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +static zend_function_entry google_protobuf_Int32Value_phpmethods[] = { + PHP_ME(google_protobuf_Int32Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Int32Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_Int32Value, setValue, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_NullValue_ModuleInit() { +static void google_protobuf_Int32Value_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\NullValue", - google_protobuf_NullValue_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Int32Value", + google_protobuf_Int32Value_phpmethods); - google_protobuf_NullValue_ce = zend_register_internal_class(&tmp_ce); - zend_declare_class_constant_long(google_protobuf_NullValue_ce, "NULL_VALUE", - strlen("NULL_VALUE"), 0); + google_protobuf_Int32Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_Int32Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_Int32Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_Int32Value_ce, message_ce); } -/* google/protobuf/source_context.proto */ +/* google_protobuf_UInt32Value */ -zend_class_entry* GPBMetadata_Google_Protobuf_SourceContext_ce; +zend_class_entry* google_protobuf_UInt32Value_ce; -const char google_protobuf_source_context_proto_descriptor [240] = { -'\n', '$', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', -'c', 'o', 'n', 't', 'e', 'x', 't', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', -'t', 'o', 'b', 'u', 'f', '\"', '\"', '\n', '\r', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '\021', '\n', -'\t', 'f', 'i', 'l', 'e', '_', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'B', '\212', '\001', '\n', '\023', 'c', 'o', 'm', '.', -'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\022', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', -'n', 't', 'e', 'x', 't', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '6', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', -'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', -'w', 'n', '/', 's', 'o', 'u', 'r', 'c', 'e', 'c', 'o', 'n', 't', 'e', 'x', 't', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', -'\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', -'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', -}; +static PHP_METHOD(google_protobuf_UInt32Value, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} -static void google_protobuf_source_context_proto_AddDescriptor() { - if (DescriptorPool_HasFile("google/protobuf/source_context.proto")) return; - DescriptorPool_AddDescriptor("google/protobuf/source_context.proto", google_protobuf_source_context_proto_descriptor, - sizeof(google_protobuf_source_context_proto_descriptor)); +static PHP_METHOD(google_protobuf_UInt32Value, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(GPBMetadata_Google_Protobuf_SourceContext, initOnce) { - google_protobuf_source_context_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_UInt32Value, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry GPBMetadata_Google_Protobuf_SourceContext_methods[] = { - PHP_ME(GPBMetadata_Google_Protobuf_SourceContext, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +static zend_function_entry google_protobuf_UInt32Value_phpmethods[] = { + PHP_ME(google_protobuf_UInt32Value, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_UInt32Value, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_UInt32Value, setValue, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void GPBMetadata_Google_Protobuf_SourceContext_ModuleInit() { +static void google_protobuf_UInt32Value_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\SourceContext", - GPBMetadata_Google_Protobuf_SourceContext_methods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\UInt32Value", + google_protobuf_UInt32Value_phpmethods); - GPBMetadata_Google_Protobuf_SourceContext_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_UInt32Value_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_UInt32Value_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_UInt32Value_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_UInt32Value_ce, message_ce); } -/* google_protobuf_SourceContext */ +/* google_protobuf_BoolValue */ -zend_class_entry* google_protobuf_SourceContext_ce; +zend_class_entry* google_protobuf_BoolValue_ce; -static PHP_METHOD(google_protobuf_SourceContext, __construct) { - google_protobuf_source_context_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_BoolValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_SourceContext, getFileName) { +static PHP_METHOD(google_protobuf_BoolValue, getValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "file_name"); + "value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_SourceContext, setFileName) { +static PHP_METHOD(google_protobuf_BoolValue, setValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "file_name"); + "value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -3078,87 +3068,97 @@ static PHP_METHOD(google_protobuf_SourceContext, setFileName) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_SourceContext_phpmethods[] = { - PHP_ME(google_protobuf_SourceContext, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_SourceContext, getFileName, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_SourceContext, setFileName, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_BoolValue_phpmethods[] = { + PHP_ME(google_protobuf_BoolValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_BoolValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_BoolValue, setValue, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_SourceContext_ModuleInit() { +static void google_protobuf_BoolValue_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\SourceContext", - google_protobuf_SourceContext_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\BoolValue", + google_protobuf_BoolValue_phpmethods); - google_protobuf_SourceContext_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_SourceContext_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_SourceContext_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_SourceContext_ce, message_ce); + google_protobuf_BoolValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_BoolValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_BoolValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_BoolValue_ce, message_ce); } -/* google/protobuf/field_mask.proto */ +/* google_protobuf_StringValue */ -zend_class_entry* GPBMetadata_Google_Protobuf_FieldMask_ce; +zend_class_entry* google_protobuf_StringValue_ce; -const char google_protobuf_field_mask_proto_descriptor [223] = { -'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'f', 'i', 'e', 'l', 'd', '_', 'm', -'a', 's', 'k', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', -'f', '\"', '\032', '\n', '\t', 'F', 'i', 'e', 'l', 'd', 'M', 'a', 's', 'k', '\022', '\r', '\n', '\005', 'p', 'a', 't', 'h', 's', '\030', '\001', -' ', '\003', '(', '\t', 'B', '\205', '\001', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', -'b', 'u', 'f', 'B', '\016', 'F', 'i', 'e', 'l', 'd', 'M', 'a', 's', 'k', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', -'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', -'t', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'f', 'i', 'e', 'l', 'd', 'm', 'a', 's', 'k', 'p', 'b', '\370', '\001', -'\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', -'.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', -}; +static PHP_METHOD(google_protobuf_StringValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); + zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); +} -static void google_protobuf_field_mask_proto_AddDescriptor() { - if (DescriptorPool_HasFile("google/protobuf/field_mask.proto")) return; - DescriptorPool_AddDescriptor("google/protobuf/field_mask.proto", google_protobuf_field_mask_proto_descriptor, - sizeof(google_protobuf_field_mask_proto_descriptor)); +static PHP_METHOD(google_protobuf_StringValue, getValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval ret; + Message_get(intern, f, &ret); + RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(GPBMetadata_Google_Protobuf_FieldMask, initOnce) { - google_protobuf_field_mask_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_StringValue, setValue) { + Message* intern = (Message*)Z_OBJ_P(getThis()); + const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, + "value"); + zval *val; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) + == FAILURE) { + return; + } + Message_set(intern, f, val); + RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry GPBMetadata_Google_Protobuf_FieldMask_methods[] = { - PHP_ME(GPBMetadata_Google_Protobuf_FieldMask, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) +static zend_function_entry google_protobuf_StringValue_phpmethods[] = { + PHP_ME(google_protobuf_StringValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_StringValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_StringValue, setValue, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void GPBMetadata_Google_Protobuf_FieldMask_ModuleInit() { +static void google_protobuf_StringValue_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\FieldMask", - GPBMetadata_Google_Protobuf_FieldMask_methods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\StringValue", + google_protobuf_StringValue_phpmethods); - GPBMetadata_Google_Protobuf_FieldMask_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_StringValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_StringValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_StringValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_StringValue_ce, message_ce); } -/* google_protobuf_FieldMask */ +/* google_protobuf_BytesValue */ -zend_class_entry* google_protobuf_FieldMask_ce; +zend_class_entry* google_protobuf_BytesValue_ce; -static PHP_METHOD(google_protobuf_FieldMask, __construct) { - google_protobuf_field_mask_proto_AddDescriptor(); +static PHP_METHOD(google_protobuf_BytesValue, __construct) { + google_protobuf_wrappers_proto_AddDescriptor(); zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU); } -static PHP_METHOD(google_protobuf_FieldMask, getPaths) { +static PHP_METHOD(google_protobuf_BytesValue, getValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "paths"); + "value"); zval ret; Message_get(intern, f, &ret); RETURN_ZVAL(&ret, 1, 0); } -static PHP_METHOD(google_protobuf_FieldMask, setPaths) { +static PHP_METHOD(google_protobuf_BytesValue, setValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, - "paths"); + "value"); zval *val; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) { @@ -3168,48 +3168,46 @@ static PHP_METHOD(google_protobuf_FieldMask, setPaths) { RETURN_ZVAL(getThis(), 1, 0); } -static zend_function_entry google_protobuf_FieldMask_phpmethods[] = { - PHP_ME(google_protobuf_FieldMask, __construct, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_FieldMask, getPaths, NULL, ZEND_ACC_PUBLIC) - PHP_ME(google_protobuf_FieldMask, setPaths, NULL, ZEND_ACC_PUBLIC) +static zend_function_entry google_protobuf_BytesValue_phpmethods[] = { + PHP_ME(google_protobuf_BytesValue, __construct, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_BytesValue, getValue, NULL, ZEND_ACC_PUBLIC) + PHP_ME(google_protobuf_BytesValue, setValue, NULL, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static void google_protobuf_FieldMask_ModuleInit() { +static void google_protobuf_BytesValue_ModuleInit() { zend_class_entry tmp_ce; - INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\FieldMask", - google_protobuf_FieldMask_phpmethods); + INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\BytesValue", + google_protobuf_BytesValue_phpmethods); - google_protobuf_FieldMask_ce = zend_register_internal_class(&tmp_ce); - google_protobuf_FieldMask_ce->ce_flags |= ZEND_ACC_FINAL; - google_protobuf_FieldMask_ce->create_object = Message_create; - zend_do_inheritance(google_protobuf_FieldMask_ce, message_ce); + google_protobuf_BytesValue_ce = zend_register_internal_class(&tmp_ce); + google_protobuf_BytesValue_ce->ce_flags |= ZEND_ACC_FINAL; + google_protobuf_BytesValue_ce->create_object = Message_create; + zend_do_inheritance(google_protobuf_BytesValue_ce, message_ce); } static void WellKnownTypes_ModuleInit() { - GPBMetadata_Google_Protobuf_Timestamp_ModuleInit(); - google_protobuf_Timestamp_ModuleInit(); - GPBMetadata_Google_Protobuf_Wrappers_ModuleInit(); - google_protobuf_DoubleValue_ModuleInit(); - google_protobuf_FloatValue_ModuleInit(); - google_protobuf_Int64Value_ModuleInit(); - google_protobuf_UInt64Value_ModuleInit(); - google_protobuf_Int32Value_ModuleInit(); - google_protobuf_UInt32Value_ModuleInit(); - google_protobuf_BoolValue_ModuleInit(); - google_protobuf_StringValue_ModuleInit(); - google_protobuf_BytesValue_ModuleInit(); GPBMetadata_Google_Protobuf_Any_ModuleInit(); google_protobuf_Any_ModuleInit(); - GPBMetadata_Google_Protobuf_Duration_ModuleInit(); - google_protobuf_Duration_ModuleInit(); GPBMetadata_Google_Protobuf_Api_ModuleInit(); google_protobuf_Api_ModuleInit(); google_protobuf_Method_ModuleInit(); google_protobuf_Mixin_ModuleInit(); + GPBMetadata_Google_Protobuf_Duration_ModuleInit(); + google_protobuf_Duration_ModuleInit(); GPBMetadata_Google_Protobuf_GPBEmpty_ModuleInit(); google_protobuf_Empty_ModuleInit(); + GPBMetadata_Google_Protobuf_FieldMask_ModuleInit(); + google_protobuf_FieldMask_ModuleInit(); + GPBMetadata_Google_Protobuf_SourceContext_ModuleInit(); + google_protobuf_SourceContext_ModuleInit(); + GPBMetadata_Google_Protobuf_Struct_ModuleInit(); + google_protobuf_Struct_ModuleInit(); + google_protobuf_Struct_FieldsEntry_ModuleInit(); + google_protobuf_Value_ModuleInit(); + google_protobuf_ListValue_ModuleInit(); + google_protobuf_NullValue_ModuleInit(); GPBMetadata_Google_Protobuf_Type_ModuleInit(); google_protobuf_Type_ModuleInit(); google_protobuf_Field_ModuleInit(); @@ -3219,14 +3217,16 @@ static void WellKnownTypes_ModuleInit() { google_protobuf_EnumValue_ModuleInit(); google_protobuf_Option_ModuleInit(); google_protobuf_Syntax_ModuleInit(); - GPBMetadata_Google_Protobuf_Struct_ModuleInit(); - google_protobuf_Struct_ModuleInit(); - google_protobuf_Struct_FieldsEntry_ModuleInit(); - google_protobuf_Value_ModuleInit(); - google_protobuf_ListValue_ModuleInit(); - google_protobuf_NullValue_ModuleInit(); - GPBMetadata_Google_Protobuf_SourceContext_ModuleInit(); - google_protobuf_SourceContext_ModuleInit(); - GPBMetadata_Google_Protobuf_FieldMask_ModuleInit(); - google_protobuf_FieldMask_ModuleInit(); + GPBMetadata_Google_Protobuf_Timestamp_ModuleInit(); + google_protobuf_Timestamp_ModuleInit(); + GPBMetadata_Google_Protobuf_Wrappers_ModuleInit(); + google_protobuf_DoubleValue_ModuleInit(); + google_protobuf_FloatValue_ModuleInit(); + google_protobuf_Int64Value_ModuleInit(); + google_protobuf_UInt64Value_ModuleInit(); + google_protobuf_Int32Value_ModuleInit(); + google_protobuf_UInt32Value_ModuleInit(); + google_protobuf_BoolValue_ModuleInit(); + google_protobuf_StringValue_ModuleInit(); + google_protobuf_BytesValue_ModuleInit(); } diff --git a/php/generate_descriptor_protos.sh b/php/generate_descriptor_protos.sh index fc2ed8040df3..9feaa96c8b51 100755 --- a/php/generate_descriptor_protos.sh +++ b/php/generate_descriptor_protos.sh @@ -3,6 +3,8 @@ # Run this script to regenerate descriptor protos after the protocol compiler # changes. +set -e + if test ! -e src/google/protobuf/stubs/common.h; then cat >&2 << __EOF__ Could not find source code. Make sure you are running this script from the @@ -13,7 +15,7 @@ fi pushd src ./protoc --php_out=internal:../php/src google/protobuf/descriptor.proto -./protoc --php_out=internal_generate_c_wkt:src \ +./protoc --php_out=internal_generate_c_wkt:../php/src \ google/protobuf/any.proto \ google/protobuf/api.proto \ google/protobuf/duration.proto \ From 05644f03137ddeaf511beee1364af3a3bfc5940d Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 5 Oct 2020 22:31:50 -0700 Subject: [PATCH 07/12] Revert upb changes to minimize changes as we evaluate performance. --- php/ext/google/protobuf/php-upb.c | 348 ++++++++++++++---------------- php/ext/google/protobuf/php-upb.h | 96 +++------ 2 files changed, 194 insertions(+), 250 deletions(-) diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 2ed7114e7fdd..d1fc36663dfc 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -81,10 +81,6 @@ #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) #define UPB_NOINLINE __attribute__((noinline)) #define UPB_NORETURN __attribute__((__noreturn__)) -#elif defined(_MSC_VER) -#define UPB_NOINLINE -#define UPB_FORCEINLINE -#define UPB_NORETURN __declspec(noreturn) #else /* !defined(__GNUC__) */ #define UPB_FORCEINLINE #define UPB_NOINLINE @@ -147,7 +143,7 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); #elif defined _MSC_VER #define UPB_ASSUME(expr) if (!(expr)) __assume(0) #else -#define UPB_ASSUME(expr) do {} while (false && (expr)) +#define UPB_ASSUME(expr) do {} if (false && (expr)) #endif #else #define UPB_ASSUME(expr) assert(expr) @@ -327,6 +323,8 @@ typedef struct { typedef union { bool bool_val; + int32_t int32_val; + int64_t int64_val; uint32_t uint32_val; uint64_t uint64_val; upb_strview str_val; @@ -426,21 +424,14 @@ static void decode_munge(int type, wireval *val) { break; case UPB_DESCRIPTOR_TYPE_SINT32: { uint32_t n = val->uint32_val; - val->uint32_val = (n >> 1) ^ -(int32_t)(n & 1); + val->int32_val = (n >> 1) ^ -(int32_t)(n & 1); break; } case UPB_DESCRIPTOR_TYPE_SINT64: { uint64_t n = val->uint64_val; - val->uint64_val = (n >> 1) ^ -(int64_t)(n & 1); + val->int64_val = (n >> 1) ^ -(int64_t)(n & 1); break; } - case UPB_DESCRIPTOR_TYPE_INT32: - case UPB_DESCRIPTOR_TYPE_UINT32: - if (!_upb_isle()) { - /* The next stage will memcpy(dst, &val, 4) */ - val->uint32_val = val->uint64_val; - } - break; } } @@ -616,7 +607,7 @@ static void decode_tomap(upb_decstate *d, upb_msg *msg, if (entry->fields[1].descriptortype == UPB_DESCRIPTOR_TYPE_MESSAGE || entry->fields[1].descriptortype == UPB_DESCRIPTOR_TYPE_GROUP) { /* Create proactively to handle the case where it doesn't appear. */ - ent.v.val = upb_value_ptr(_upb_msg_new(entry->submsgs[0], d->arena)); + ent.v.val.val = (uint64_t)_upb_msg_new(entry->submsgs[0], d->arena); } decode_tosubmsg(d, &ent.k, layout, field, val.str_val); @@ -707,16 +698,14 @@ static const char *decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg, break; case UPB_WIRE_TYPE_32BIT: if (d->limit - ptr < 4) decode_err(d); - memcpy(&val.uint32_val, ptr, 4); - val.uint32_val = _upb_be_swap32(val.uint32_val); + memcpy(&val, ptr, 4); ptr += 4; op = OP_SCALAR_LG2(2); if (((1 << field->descriptortype) & fixed32_ok) == 0) goto unknown; break; case UPB_WIRE_TYPE_64BIT: if (d->limit - ptr < 8) decode_err(d); - memcpy(&val.uint64_val, ptr, 8); - val.uint64_val = _upb_be_swap64(val.uint64_val); + memcpy(&val, ptr, 8); ptr += 8; op = OP_SCALAR_LG2(3); if (((1 << field->descriptortype) & fixed64_ok) == 0) goto unknown; @@ -736,7 +725,7 @@ static const char *decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg, break; } case UPB_WIRE_TYPE_START_GROUP: - val.uint32_val = field_number; + val.int32_val = field_number; op = OP_SUBMSG; if (field->descriptortype != UPB_DTYPE_GROUP) goto unknown; break; @@ -805,30 +794,30 @@ bool upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l, /* We encode backwards, to avoid pre-computing lengths (one-pass encode). */ -#include #include #define UPB_PB_VARINT_MAX_LEN 10 +#define CHK(x) do { if (!(x)) { return false; } } while(0) -UPB_NOINLINE -static size_t encode_varint64(uint64_t val, char *buf) { - size_t i = 0; - do { +static size_t upb_encode_varint(uint64_t val, char *buf) { + size_t i; + if (val < 128) { buf[0] = val; return 1; } + i = 0; + while (val) { uint8_t byte = val & 0x7fU; val >>= 7; if (val) byte |= 0x80U; buf[i++] = byte; - } while (val); + } return i; } -static uint32_t encode_zz32(int32_t n) { return ((uint32_t)n << 1) ^ (n >> 31); } -static uint64_t encode_zz64(int64_t n) { return ((uint64_t)n << 1) ^ (n >> 63); } +static uint32_t upb_zzencode_32(int32_t n) { return ((uint32_t)n << 1) ^ (n >> 31); } +static uint64_t upb_zzencode_64(int64_t n) { return ((uint64_t)n << 1) ^ (n >> 63); } typedef struct { - jmp_buf err; upb_alloc *alloc; char *buf, *ptr, *limit; } upb_encstate; @@ -841,15 +830,11 @@ static size_t upb_roundup_pow2(size_t bytes) { return ret; } -UPB_NORETURN static void encode_err(upb_encstate *e) { longjmp(e->err, 1); } - -UPB_NOINLINE -static void encode_growbuffer(upb_encstate *e, size_t bytes) { +static bool upb_encode_growbuffer(upb_encstate *e, size_t bytes) { size_t old_size = e->limit - e->buf; size_t new_size = upb_roundup_pow2(bytes + (e->limit - e->ptr)); char *new_buf = upb_realloc(e->alloc, e->buf, old_size, new_size); - - if (!new_buf) encode_err(e); + CHK(new_buf); /* We want previous data at the end, realloc() put it at the beginning. */ if (old_size > 0) { @@ -859,115 +844,99 @@ static void encode_growbuffer(upb_encstate *e, size_t bytes) { e->ptr = new_buf + new_size - (e->limit - e->ptr); e->limit = new_buf + new_size; e->buf = new_buf; - - e->ptr -= bytes; + return true; } /* Call to ensure that at least "bytes" bytes are available for writing at * e->ptr. Returns false if the bytes could not be allocated. */ -UPB_FORCEINLINE -static void encode_reserve(upb_encstate *e, size_t bytes) { - if ((size_t)(e->ptr - e->buf) < bytes) { - encode_growbuffer(e, bytes); - return; - } +static bool upb_encode_reserve(upb_encstate *e, size_t bytes) { + CHK(UPB_LIKELY((size_t)(e->ptr - e->buf) >= bytes) || + upb_encode_growbuffer(e, bytes)); e->ptr -= bytes; + return true; } /* Writes the given bytes to the buffer, handling reserve/advance. */ -static void encode_bytes(upb_encstate *e, const void *data, size_t len) { - if (len == 0) return; /* memcpy() with zero size is UB */ - encode_reserve(e, len); +static bool upb_put_bytes(upb_encstate *e, const void *data, size_t len) { + if (len == 0) return true; + CHK(upb_encode_reserve(e, len)); memcpy(e->ptr, data, len); + return true; } -static void encode_fixed64(upb_encstate *e, uint64_t val) { - val = _upb_be_swap64(val); - encode_bytes(e, &val, sizeof(uint64_t)); +static bool upb_put_fixed64(upb_encstate *e, uint64_t val) { + /* TODO(haberman): byte-swap for big endian. */ + return upb_put_bytes(e, &val, sizeof(uint64_t)); } -static void encode_fixed32(upb_encstate *e, uint32_t val) { - val = _upb_be_swap32(val); - encode_bytes(e, &val, sizeof(uint32_t)); +static bool upb_put_fixed32(upb_encstate *e, uint32_t val) { + /* TODO(haberman): byte-swap for big endian. */ + return upb_put_bytes(e, &val, sizeof(uint32_t)); } -UPB_NOINLINE -static void encode_longvarint(upb_encstate *e, uint64_t val) { +static bool upb_put_varint(upb_encstate *e, uint64_t val) { size_t len; char *start; - - encode_reserve(e, UPB_PB_VARINT_MAX_LEN); - len = encode_varint64(val, e->ptr); + CHK(upb_encode_reserve(e, UPB_PB_VARINT_MAX_LEN)); + len = upb_encode_varint(val, e->ptr); start = e->ptr + UPB_PB_VARINT_MAX_LEN - len; memmove(start, e->ptr, len); e->ptr = start; + return true; } -UPB_FORCEINLINE -static void encode_varint(upb_encstate *e, uint64_t val) { - if (val < 128 && e->ptr != e->buf) { - --e->ptr; - *e->ptr = val; - } else { - encode_longvarint(e, val); - } -} - -static void encode_double(upb_encstate *e, double d) { +static bool upb_put_double(upb_encstate *e, double d) { uint64_t u64; UPB_ASSERT(sizeof(double) == sizeof(uint64_t)); memcpy(&u64, &d, sizeof(uint64_t)); - encode_fixed64(e, u64); + return upb_put_fixed64(e, u64); } -static void encode_float(upb_encstate *e, float d) { +static bool upb_put_float(upb_encstate *e, float d) { uint32_t u32; UPB_ASSERT(sizeof(float) == sizeof(uint32_t)); memcpy(&u32, &d, sizeof(uint32_t)); - encode_fixed32(e, u32); + return upb_put_fixed32(e, u32); } -static void encode_tag(upb_encstate *e, int field_number, int wire_type) { - encode_varint(e, (field_number << 3) | wire_type); +static bool upb_put_tag(upb_encstate *e, int field_number, int wire_type) { + return upb_put_varint(e, (field_number << 3) | wire_type); } -static void encode_fixedarray(upb_encstate *e, const upb_array *arr, +static bool upb_put_fixedarray(upb_encstate *e, const upb_array *arr, size_t elem_size, uint32_t tag) { size_t bytes = arr->len * elem_size; const char* data = _upb_array_constptr(arr); const char* ptr = data + bytes - elem_size; if (tag) { while (true) { - encode_bytes(e, ptr, elem_size); - encode_varint(e, tag); + CHK(upb_put_bytes(e, ptr, elem_size) && upb_put_varint(e, tag)); if (ptr == data) break; ptr -= elem_size; } + return true; } else { - encode_bytes(e, data, bytes); + return upb_put_bytes(e, data, bytes) && upb_put_varint(e, bytes); } } -static void encode_message(upb_encstate *e, const char *msg, - const upb_msglayout *m, size_t *size); +bool upb_encode_message(upb_encstate *e, const char *msg, + const upb_msglayout *m, size_t *size); -static void encode_scalar(upb_encstate *e, const void *_field_mem, - const upb_msglayout *m, const upb_msglayout_field *f, - bool skip_zero_value) { +static bool upb_encode_scalarfield(upb_encstate *e, const void *_field_mem, + const upb_msglayout *m, + const upb_msglayout_field *f, + bool skip_zero_value) { const char *field_mem = _field_mem; - int wire_type; - -#define CASE(ctype, type, wtype, encodeval) \ - { \ - ctype val = *(ctype *)field_mem; \ - if (skip_zero_value && val == 0) { \ - return; \ - } \ - encode_##type(e, encodeval); \ - wire_type = wtype; \ - break; \ - } +#define CASE(ctype, type, wire_type, encodeval) do { \ + ctype val = *(ctype*)field_mem; \ + if (skip_zero_value && val == 0) { \ + return true; \ + } \ + return upb_put_ ## type(e, encodeval) && \ + upb_put_tag(e, f->number, wire_type); \ +} while(0) switch (f->descriptortype) { case UPB_DESCRIPTOR_TYPE_DOUBLE: @@ -991,91 +960,90 @@ static void encode_scalar(upb_encstate *e, const void *_field_mem, case UPB_DESCRIPTOR_TYPE_BOOL: CASE(bool, varint, UPB_WIRE_TYPE_VARINT, val); case UPB_DESCRIPTOR_TYPE_SINT32: - CASE(int32_t, varint, UPB_WIRE_TYPE_VARINT, encode_zz32(val)); + CASE(int32_t, varint, UPB_WIRE_TYPE_VARINT, upb_zzencode_32(val)); case UPB_DESCRIPTOR_TYPE_SINT64: - CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT, encode_zz64(val)); + CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT, upb_zzencode_64(val)); case UPB_DESCRIPTOR_TYPE_STRING: case UPB_DESCRIPTOR_TYPE_BYTES: { upb_strview view = *(upb_strview*)field_mem; if (skip_zero_value && view.size == 0) { - return; + return true; } - encode_bytes(e, view.data, view.size); - encode_varint(e, view.size); - wire_type = UPB_WIRE_TYPE_DELIMITED; - break; + return upb_put_bytes(e, view.data, view.size) && + upb_put_varint(e, view.size) && + upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); } case UPB_DESCRIPTOR_TYPE_GROUP: { size_t size; void *submsg = *(void **)field_mem; const upb_msglayout *subm = m->submsgs[f->submsg_index]; if (submsg == NULL) { - return; + return true; } - encode_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP); - encode_message(e, submsg, subm, &size); - wire_type = UPB_WIRE_TYPE_START_GROUP; - break; + return upb_put_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP) && + upb_encode_message(e, submsg, subm, &size) && + upb_put_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP); } case UPB_DESCRIPTOR_TYPE_MESSAGE: { size_t size; void *submsg = *(void **)field_mem; const upb_msglayout *subm = m->submsgs[f->submsg_index]; if (submsg == NULL) { - return; + return true; } - encode_message(e, submsg, subm, &size); - encode_varint(e, size); - wire_type = UPB_WIRE_TYPE_DELIMITED; - break; + return upb_encode_message(e, submsg, subm, &size) && + upb_put_varint(e, size) && + upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); } - default: - UPB_UNREACHABLE(); } #undef CASE - - encode_tag(e, f->number, wire_type); + UPB_UNREACHABLE(); } -static void encode_array(upb_encstate *e, const char *field_mem, - const upb_msglayout *m, const upb_msglayout_field *f) { +static bool upb_encode_array(upb_encstate *e, const char *field_mem, + const upb_msglayout *m, + const upb_msglayout_field *f) { const upb_array *arr = *(const upb_array**)field_mem; bool packed = f->label == _UPB_LABEL_PACKED; - size_t pre_len = e->limit - e->ptr; if (arr == NULL || arr->len == 0) { - return; + return true; } #define VARINT_CASE(ctype, encode) \ { \ const ctype *start = _upb_array_constptr(arr); \ const ctype *ptr = start + arr->len; \ + size_t pre_len = e->limit - e->ptr; \ uint32_t tag = packed ? 0 : (f->number << 3) | UPB_WIRE_TYPE_VARINT; \ do { \ ptr--; \ - encode_varint(e, encode); \ - if (tag) encode_varint(e, tag); \ + CHK(upb_put_varint(e, encode)); \ + if (tag) CHK(upb_put_varint(e, tag)); \ } while (ptr != start); \ + if (!tag) CHK(upb_put_varint(e, e->limit - e->ptr - pre_len)); \ } \ - break; + break; \ + do { \ + ; \ + } while (0) #define TAG(wire_type) (packed ? 0 : (f->number << 3 | wire_type)) switch (f->descriptortype) { case UPB_DESCRIPTOR_TYPE_DOUBLE: - encode_fixedarray(e, arr, sizeof(double), TAG(UPB_WIRE_TYPE_64BIT)); + CHK(upb_put_fixedarray(e, arr, sizeof(double), TAG(UPB_WIRE_TYPE_64BIT))); break; case UPB_DESCRIPTOR_TYPE_FLOAT: - encode_fixedarray(e, arr, sizeof(float), TAG(UPB_WIRE_TYPE_32BIT)); + CHK(upb_put_fixedarray(e, arr, sizeof(float), TAG(UPB_WIRE_TYPE_32BIT))); break; case UPB_DESCRIPTOR_TYPE_SFIXED64: case UPB_DESCRIPTOR_TYPE_FIXED64: - encode_fixedarray(e, arr, sizeof(uint64_t), TAG(UPB_WIRE_TYPE_64BIT)); + CHK(upb_put_fixedarray(e, arr, sizeof(uint64_t), TAG(UPB_WIRE_TYPE_64BIT))); break; case UPB_DESCRIPTOR_TYPE_FIXED32: case UPB_DESCRIPTOR_TYPE_SFIXED32: - encode_fixedarray(e, arr, sizeof(uint32_t), TAG(UPB_WIRE_TYPE_32BIT)); + CHK(upb_put_fixedarray(e, arr, sizeof(uint32_t), TAG(UPB_WIRE_TYPE_32BIT))); break; case UPB_DESCRIPTOR_TYPE_INT64: case UPB_DESCRIPTOR_TYPE_UINT64: @@ -1088,20 +1056,20 @@ static void encode_array(upb_encstate *e, const char *field_mem, case UPB_DESCRIPTOR_TYPE_BOOL: VARINT_CASE(bool, *ptr); case UPB_DESCRIPTOR_TYPE_SINT32: - VARINT_CASE(int32_t, encode_zz32(*ptr)); + VARINT_CASE(int32_t, upb_zzencode_32(*ptr)); case UPB_DESCRIPTOR_TYPE_SINT64: - VARINT_CASE(int64_t, encode_zz64(*ptr)); + VARINT_CASE(int64_t, upb_zzencode_64(*ptr)); case UPB_DESCRIPTOR_TYPE_STRING: case UPB_DESCRIPTOR_TYPE_BYTES: { const upb_strview *start = _upb_array_constptr(arr); const upb_strview *ptr = start + arr->len; do { ptr--; - encode_bytes(e, ptr->data, ptr->size); - encode_varint(e, ptr->size); - encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); + CHK(upb_put_bytes(e, ptr->data, ptr->size) && + upb_put_varint(e, ptr->size) && + upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED)); } while (ptr != start); - return; + return true; } case UPB_DESCRIPTOR_TYPE_GROUP: { const void *const*start = _upb_array_constptr(arr); @@ -1110,11 +1078,11 @@ static void encode_array(upb_encstate *e, const char *field_mem, do { size_t size; ptr--; - encode_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP); - encode_message(e, *ptr, subm, &size); - encode_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP); + CHK(upb_put_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP) && + upb_encode_message(e, *ptr, subm, &size) && + upb_put_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP)); } while (ptr != start); - return; + return true; } case UPB_DESCRIPTOR_TYPE_MESSAGE: { const void *const*start = _upb_array_constptr(arr); @@ -1123,30 +1091,31 @@ static void encode_array(upb_encstate *e, const char *field_mem, do { size_t size; ptr--; - encode_message(e, *ptr, subm, &size); - encode_varint(e, size); - encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); + CHK(upb_encode_message(e, *ptr, subm, &size) && + upb_put_varint(e, size) && + upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED)); } while (ptr != start); - return; + return true; } } #undef VARINT_CASE if (packed) { - encode_varint(e, e->limit - e->ptr - pre_len); - encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); + CHK(upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED)); } + return true; } -static void encode_map(upb_encstate *e, const char *field_mem, - const upb_msglayout *m, const upb_msglayout_field *f) { +static bool upb_encode_map(upb_encstate *e, const char *field_mem, + const upb_msglayout *m, + const upb_msglayout_field *f) { const upb_map *map = *(const upb_map**)field_mem; const upb_msglayout *entry = m->submsgs[f->submsg_index]; const upb_msglayout_field *key_field = &entry->fields[0]; const upb_msglayout_field *val_field = &entry->fields[1]; upb_strtable_iter i; if (map == NULL) { - return; + return true; } upb_strtable_begin(&i, &map->table); @@ -1158,57 +1127,59 @@ static void encode_map(upb_encstate *e, const char *field_mem, upb_map_entry ent; _upb_map_fromkey(key, &ent.k, map->key_size); _upb_map_fromvalue(val, &ent.v, map->val_size); - encode_scalar(e, &ent.v, entry, val_field, false); - encode_scalar(e, &ent.k, entry, key_field, false); + CHK(upb_encode_scalarfield(e, &ent.v, entry, val_field, false)); + CHK(upb_encode_scalarfield(e, &ent.k, entry, key_field, false)); size = (e->limit - e->ptr) - pre_len; - encode_varint(e, size); - encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED); + CHK(upb_put_varint(e, size)); + CHK(upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED)); } -} -static void encode_scalarfield(upb_encstate *e, const char *msg, - const upb_msglayout *m, - const upb_msglayout_field *f) { - bool skip_empty = false; - if (f->presence == 0) { - /* Proto3 presence. */ - skip_empty = true; - } else if (f->presence > 0) { - /* Proto2 presence: hasbit. */ - if (!_upb_hasbit_field(msg, f)) return; - } else { - /* Field is in a oneof. */ - if (_upb_getoneofcase_field(msg, f) != f->number) return; - } - encode_scalar(e, msg + f->offset, m, f, skip_empty); + return true; } -static void encode_message(upb_encstate *e, const char *msg, - const upb_msglayout *m, size_t *size) { + +bool upb_encode_message(upb_encstate *e, const char *msg, + const upb_msglayout *m, size_t *size) { + int i; size_t pre_len = e->limit - e->ptr; const char *unknown; size_t unknown_size; - const upb_msglayout_field *f = &m->fields[m->field_count]; - const upb_msglayout_field *first = &m->fields[0]; unknown = upb_msg_getunknown(msg, &unknown_size); if (unknown) { - encode_bytes(e, unknown, unknown_size); + upb_put_bytes(e, unknown, unknown_size); } - while (f != first) { - f--; + for (i = m->field_count - 1; i >= 0; i--) { + const upb_msglayout_field *f = &m->fields[i]; + if (_upb_isrepeated(f)) { - encode_array(e, msg + f->offset, m, f); + CHK(upb_encode_array(e, msg + f->offset, m, f)); } else if (f->label == _UPB_LABEL_MAP) { - encode_map(e, msg + f->offset, m, f); + CHK(upb_encode_map(e, msg + f->offset, m, f)); } else { - encode_scalarfield(e, msg, m, f); + bool skip_empty = false; + if (f->presence == 0) { + /* Proto3 presence. */ + skip_empty = true; + } else if (f->presence > 0) { + /* Proto2 presence: hasbit. */ + if (!_upb_hasbit_field(msg, f)) { + continue; + } + } else { + /* Field is in a oneof. */ + if (_upb_getoneofcase_field(msg, f) != f->number) { + continue; + } + } + CHK(upb_encode_scalarfield(e, msg + f->offset, m, f, skip_empty)); } } *size = (e->limit - e->ptr) - pre_len; + return true; } char *upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, @@ -1219,13 +1190,11 @@ char *upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, e.limit = NULL; e.ptr = NULL; - if (setjmp(e.err)) { + if (!upb_encode_message(&e, msg, m, size)) { *size = 0; return NULL; } - encode_message(&e, msg, m, size); - *size = e.limit - e.ptr; if (*size == 0) { @@ -1237,6 +1206,8 @@ char *upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, } } +#undef CHK + @@ -3092,7 +3063,7 @@ extern const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit; extern const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit; extern const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit; -static const upb_msglayout *google_protobuf_descriptor_proto_layouts[27] = { +static const upb_msglayout *layouts[27] = { &google_protobuf_FileDescriptorSet_msginit, &google_protobuf_FileDescriptorProto_msginit, &google_protobuf_DescriptorProto_msginit, @@ -3122,8 +3093,7 @@ static const upb_msglayout *google_protobuf_descriptor_proto_layouts[27] = { &google_protobuf_GeneratedCodeInfo_Annotation_msginit, }; -static const char google_protobuf_descriptor_proto_descriptor[7619] = { -'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'd', 'e', 's', 'c', 'r', 'i', 'p', +static const char descriptor[7619] = {'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', 'M', '\n', '\021', 'F', 'i', 'l', 'e', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'S', 'e', 't', '\022', '8', '\n', '\004', 'f', 'i', 'l', 'e', '\030', '\001', ' ', '\003', '(', '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', @@ -3430,15 +3400,15 @@ static const char google_protobuf_descriptor_proto_descriptor[7619] = { 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'R', 'e', 'f', 'l', 'e', 'c', 't', 'i', 'o', 'n', }; -static upb_def_init *google_protobuf_descriptor_proto_deps[1] = { +static upb_def_init *deps[1] = { NULL }; -upb_def_init google_protobuf_descriptor_proto_definit = { - google_protobuf_descriptor_proto_deps, - google_protobuf_descriptor_proto_layouts, +upb_def_init google_protobuf_descriptor_proto_upbdefinit = { + deps, + layouts, "google/protobuf/descriptor.proto", - UPB_STRVIEW_INIT(google_protobuf_descriptor_proto_descriptor, 7619) + UPB_STRVIEW_INIT(descriptor, 7619) }; @@ -5696,7 +5666,11 @@ const upb_fielddef *upb_msg_whichoneof(const upb_msg *msg, if (upb_oneof_done(&i)) return false; f = upb_oneof_iter_field(&i); field = upb_fielddef_layout(f); - oneof_case = _upb_getoneofcase_field(msg, field); + if (in_oneof(field)) { + oneof_case = _upb_getoneofcase_field(msg, field); + } else { + return _upb_hasbit_field(msg, field) ? f : NULL; + } return oneof_case ? upb_msgdef_itof(m, oneof_case) : NULL; } diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index 973635214edc..666ec76d05e5 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -80,10 +80,6 @@ #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) #define UPB_NOINLINE __attribute__((noinline)) #define UPB_NORETURN __attribute__((__noreturn__)) -#elif defined(_MSC_VER) -#define UPB_NOINLINE -#define UPB_FORCEINLINE -#define UPB_NORETURN __declspec(noreturn) #else /* !defined(__GNUC__) */ #define UPB_FORCEINLINE #define UPB_NOINLINE @@ -146,7 +142,7 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); #elif defined _MSC_VER #define UPB_ASSUME(expr) if (!(expr)) __assume(0) #else -#define UPB_ASSUME(expr) do {} while (false && (expr)) +#define UPB_ASSUME(expr) do {} if (false && (expr)) #endif #else #define UPB_ASSUME(expr) assert(expr) @@ -217,7 +213,7 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); ** store pointers or integers of at least 32 bits (upb isn't really useful on ** systems where sizeof(void*) < 4). ** -** The table must be homogenous (all values of the same type). In debug +** The table must be homogeneous (all values of the same type). In debug ** mode, we check this on insert and lookup. */ @@ -500,32 +496,6 @@ typedef enum { #define UPB_MAP_BEGIN ((size_t)-1) -UPB_INLINE bool _upb_isle(void) { - int x = 1; - return *(char*)&x == 1; -} - -UPB_INLINE uint32_t _upb_be_swap32(uint32_t val) { - if (_upb_isle()) { - return val; - } else { - return ((val & 0xff) << 24) | ((val & 0xff00) << 8) | - ((val & 0xff0000ULL) >> 8) | ((val & 0xff000000ULL) >> 24); - } -} - -UPB_INLINE uint64_t _upb_be_swap64(uint64_t val) { - if (_upb_isle()) { - return val; - } else { - return ((val & 0xff) << 56) | ((val & 0xff00) << 40) | - ((val & 0xff0000) << 24) | ((val & 0xff000000) << 8) | - ((val & 0xff00000000ULL) >> 8) | ((val & 0xff0000000000ULL) >> 24) | - ((val & 0xff000000000000ULL) >> 40) | - ((val & 0xff00000000000000ULL) >> 56); - } -} - #ifdef __cplusplus } /* extern "C" */ @@ -1281,7 +1251,7 @@ UPB_INLINE upb_value _upb_map_tovalue(const void *val, size_t size, if (size == UPB_MAPTYPE_STRING) { upb_strview *strp = (upb_strview*)upb_arena_malloc(a, sizeof(*strp)); *strp = *(upb_strview*)val; - ret = upb_value_ptr(strp); + memcpy(&ret, &strp, sizeof(strp)); } else { memcpy(&ret, val, size); } @@ -1412,7 +1382,7 @@ UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val, size_t size) /* This is like _upb_map_tovalue() except the entry already exists so we can * reuse the allocated upb_strview for string fields. */ if (size == UPB_MAPTYPE_STRING) { - upb_strview *strp = (upb_strview*)(uintptr_t)ent->val.val; + upb_strview *strp = (upb_strview*)ent->val.val; memcpy(strp, val, sizeof(*strp)); } else { memcpy(&ent->val.val, val, size); @@ -3519,140 +3489,140 @@ extern "C" { -extern upb_def_init google_protobuf_descriptor_proto_definit; +extern upb_def_init google_protobuf_descriptor_proto_upbdefinit; UPB_INLINE const upb_msgdef *google_protobuf_FileDescriptorSet_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorSet"); } UPB_INLINE const upb_msgdef *google_protobuf_FileDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_DescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_DescriptorProto_ExtensionRange_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ExtensionRange"); } UPB_INLINE const upb_msgdef *google_protobuf_DescriptorProto_ReservedRange_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ReservedRange"); } UPB_INLINE const upb_msgdef *google_protobuf_ExtensionRangeOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.ExtensionRangeOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_FieldDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.FieldDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_OneofDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.OneofDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumDescriptorProto_EnumReservedRange_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto.EnumReservedRange"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumValueDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumValueDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_ServiceDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.ServiceDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_MethodDescriptorProto_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.MethodDescriptorProto"); } UPB_INLINE const upb_msgdef *google_protobuf_FileOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.FileOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_MessageOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.MessageOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_FieldOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.FieldOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_OneofOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.OneofOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_EnumValueOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.EnumValueOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_ServiceOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.ServiceOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_MethodOptions_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.MethodOptions"); } UPB_INLINE const upb_msgdef *google_protobuf_UninterpretedOption_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption"); } UPB_INLINE const upb_msgdef *google_protobuf_UninterpretedOption_NamePart_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption.NamePart"); } UPB_INLINE const upb_msgdef *google_protobuf_SourceCodeInfo_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo"); } UPB_INLINE const upb_msgdef *google_protobuf_SourceCodeInfo_Location_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo.Location"); } UPB_INLINE const upb_msgdef *google_protobuf_GeneratedCodeInfo_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.GeneratedCodeInfo"); } UPB_INLINE const upb_msgdef *google_protobuf_GeneratedCodeInfo_Annotation_getmsgdef(upb_symtab *s) { - _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_definit); + _upb_symtab_loaddefinit(s, &google_protobuf_descriptor_proto_upbdefinit); return upb_symtab_lookupmsg(s, "google.protobuf.GeneratedCodeInfo.Annotation"); } @@ -3857,7 +3827,7 @@ extern "C" { #endif enum { - /* When set, emits 0/default values. TOOD(haberman): proto3 only? */ + /* When set, emits 0/default values. TODO(haberman): proto3 only? */ UPB_JSONENC_EMITDEFAULTS = 1, /* When set, use normal (snake_caes) field names instead of JSON (camelCase) From e62cf76b943d99957e03f72a52ded5398a21a99c Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 5 Oct 2020 22:50:15 -0700 Subject: [PATCH 08/12] Added missing base classes. --- php/src/Google/Protobuf/Internal/AnyBase.php | 86 +++++++++++++++++++ .../Protobuf/Internal/TimestampBase.php | 32 +++++++ 2 files changed, 118 insertions(+) create mode 100644 php/src/Google/Protobuf/Internal/AnyBase.php create mode 100644 php/src/Google/Protobuf/Internal/TimestampBase.php diff --git a/php/src/Google/Protobuf/Internal/AnyBase.php b/php/src/Google/Protobuf/Internal/AnyBase.php new file mode 100644 index 000000000000..cba922d47547 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/AnyBase.php @@ -0,0 +1,86 @@ +type_url, 0, $url_prifix_len) != + GPBUtil::TYPE_URL_PREFIX) { + throw new \Exception( + "Type url needs to be type.googleapis.com/fully-qulified"); + } + $fully_qualifed_name = + substr($this->type_url, $url_prifix_len); + + // Create message according to fully qualified name. + $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); + $desc = $pool->getDescriptorByProtoName($fully_qualifed_name); + if (is_null($desc)) { + throw new \Exception("Class ".$fully_qualifed_name + ." hasn't been added to descriptor pool"); + } + $klass = $desc->getClass(); + $msg = new $klass(); + + // Merge data into message. + $msg->mergeFromString($this->value); + return $msg; + } + + /** + * The type_url will be created according to the given message’s type and + * the value is encoded data from the given message.. + * @param message: A proto message. + */ + public function pack($msg) + { + if (!$msg instanceof Message) { + trigger_error("Given parameter is not a message instance.", + E_USER_ERROR); + return; + } + + // Set value using serialized message. + $this->value = $msg->serializeToString(); + + // Set type url. + $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); + $desc = $pool->getDescriptorByClassName(get_class($msg)); + $fully_qualifed_name = $desc->getFullName(); + $this->type_url = GPBUtil::TYPE_URL_PREFIX . $fully_qualifed_name; + } + + /** + * This method returns whether the type_url in any_message is corresponded + * to the given class. + * @param klass: The fully qualified PHP class name of a proto message type. + */ + public function is($klass) + { + $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); + $desc = $pool->getDescriptorByClassName($klass); + $fully_qualifed_name = $desc->getFullName(); + $type_url = GPBUtil::TYPE_URL_PREFIX . $fully_qualifed_name; + return $this->type_url === $type_url; + } +} diff --git a/php/src/Google/Protobuf/Internal/TimestampBase.php b/php/src/Google/Protobuf/Internal/TimestampBase.php new file mode 100644 index 000000000000..653d1e99d71c --- /dev/null +++ b/php/src/Google/Protobuf/Internal/TimestampBase.php @@ -0,0 +1,32 @@ +seconds = $datetime->getTimestamp(); + $this->nanos = 1000 * $datetime->format('u'); + } + + /** + * Converts Timestamp to PHP DateTime. + * + * @return \DateTime $datetime + */ + public function toDateTime() + { + $time = sprintf('%s.%06d', $this->seconds, $this->nanos / 1000); + return \DateTime::createFromFormat('U.u', $time); + } +} From 5a98ff98d756e8b47c846924c8469a4abe608e6e Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 6 Oct 2020 10:57:33 -0700 Subject: [PATCH 09/12] Create a separate InternalDescriptorPool method to see if that fixes preloading. --- php/ext/google/protobuf/def.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index 1ae5c4d67cfb..ac24400d952e 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -1020,8 +1020,21 @@ static zend_function_entry DescriptorPool_methods[] = { zend_class_entry *InternalDescriptorPool_class_entry; +/* + * InternalDescriptorPool::getGeneratedPool() + * + * Returns the generated DescriptorPool. Note that this is identical to + * DescriptorPool::getGeneratedPool(), and in fact returns a DescriptorPool + * instance. + */ +PHP_METHOD(InternalDescriptorPool, getGeneratedPool) { + zval ret; + ZVAL_COPY(&ret, get_generated_pool()); + RETURN_ZVAL(&ret, 0, 1); +} + static zend_function_entry InternalDescriptorPool_methods[] = { - PHP_ME(DescriptorPool, getGeneratedPool, NULL, + PHP_ME(InternalDescriptorPool, getGeneratedPool, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) }; From 8308aa0c311fd148a62b1b3db64b4c5656a3e121 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 6 Oct 2020 14:18:21 -0700 Subject: [PATCH 10/12] Properly terminate method array. --- php/ext/google/protobuf/def.c | 1 + 1 file changed, 1 insertion(+) diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index ac24400d952e..3f7590ca44dc 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -1036,6 +1036,7 @@ PHP_METHOD(InternalDescriptorPool, getGeneratedPool) { static zend_function_entry InternalDescriptorPool_methods[] = { PHP_ME(InternalDescriptorPool, getGeneratedPool, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_FE_END }; // ----------------------------------------------------------------------------- From a29f792bae7bd8571026f3ced00728e5ad849b26 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 29 Oct 2020 10:57:04 -0700 Subject: [PATCH 11/12] Updated Makefile.am for changed files. --- Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index b7b67fdb4f68..a1beb941b903 100644 --- a/Makefile.am +++ b/Makefile.am @@ -772,13 +772,11 @@ php_EXTRA_DIST= \ php/ext/google/protobuf/arena.h \ php/ext/google/protobuf/array.c \ php/ext/google/protobuf/array.h \ - php/ext/google/protobuf/bundled_php.h \ php/ext/google/protobuf/config.m4 \ php/ext/google/protobuf/convert.c \ php/ext/google/protobuf/convert.h \ php/ext/google/protobuf/def.c \ php/ext/google/protobuf/def.h \ - php/ext/google/protobuf/make-preload.php \ php/ext/google/protobuf/map.c \ php/ext/google/protobuf/map.h \ php/ext/google/protobuf/message.c \ @@ -790,6 +788,7 @@ php_EXTRA_DIST= \ php/ext/google/protobuf/php-upb.h \ php/ext/google/protobuf/protobuf.c \ php/ext/google/protobuf/protobuf.h \ + php/ext/google/protobuf/wkt.inc \ php/generate_descriptor_protos.sh \ php/phpunit.xml \ php/release.sh \ From e0151addd363a72dd13dc8fc6b16a38f24c6a1c2 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 29 Oct 2020 11:04:54 -0700 Subject: [PATCH 12/12] Added missing files to Makefile.am. --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index a1beb941b903..5dffeb0fb39b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -826,6 +826,7 @@ php_EXTRA_DIST= \ php/src/Google/Protobuf/GPBEmpty.php \ php/src/Google/Protobuf/Int32Value.php \ php/src/Google/Protobuf/Int64Value.php \ + php/src/Google/Protobuf/Internal/AnyBase.php \ php/src/Google/Protobuf/Internal/CodedInputStream.php \ php/src/Google/Protobuf/Internal/CodedOutputStream.php \ php/src/Google/Protobuf/Internal/Descriptor.php \ @@ -885,6 +886,7 @@ php_EXTRA_DIST= \ php/src/Google/Protobuf/Internal/ServiceOptions.php \ php/src/Google/Protobuf/Internal/SourceCodeInfo.php \ php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php \ + php/src/Google/Protobuf/Internal/TimestampBase.php \ php/src/Google/Protobuf/Internal/UninterpretedOption.php \ php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php \ php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \