|
@@ -75,8 +75,13 @@ static zval** message_get_property_ptr_ptr(zval* object, zval* member, int type,
|
|
|
php_proto_zend_literal key TSRMLS_DC);
|
|
|
static HashTable* message_get_gc(zval* object, zval*** table, int* n TSRMLS_DC);
|
|
|
#else
|
|
|
+#if PHP_VERSION_ID < 70400
|
|
|
static void message_set_property(zval* object, zval* member, zval* value,
|
|
|
void** cache_slot);
|
|
|
+#else
|
|
|
+static zval* message_set_property(zval* object, zval* member, zval* value,
|
|
|
+ void** cache_slot);
|
|
|
+#endif
|
|
|
static zval* message_get_property(zval* object, zval* member, int type,
|
|
|
void** cache_slot, zval* rv);
|
|
|
static zval* message_get_property_ptr_ptr(zval* object, zval* member, int type,
|
|
@@ -100,7 +105,7 @@ PHP_PROTO_OBJECT_FREE_START(MessageHeader, message)
|
|
|
}
|
|
|
PHP_PROTO_OBJECT_FREE_END
|
|
|
|
|
|
-PHP_PROTO_OBJECT_DTOR_START(MessageHeader, message)
|
|
|
+PHP_PROTO_OBJECT_EMPTY_DTOR_START(MessageHeader, message)
|
|
|
PHP_PROTO_OBJECT_DTOR_END
|
|
|
|
|
|
// Define object create method.
|
|
@@ -140,13 +145,20 @@ static void message_set_property_internal(zval* object, zval* member,
|
|
|
#if PHP_MAJOR_VERSION < 7
|
|
|
static void message_set_property(zval* object, zval* member, zval* value,
|
|
|
php_proto_zend_literal key TSRMLS_DC) {
|
|
|
-#else
|
|
|
+#elif PHP_VERSION_ID < 70400
|
|
|
static void message_set_property(zval* object, zval* member, zval* value,
|
|
|
void** cache_slot) {
|
|
|
+#else
|
|
|
+static zval* message_set_property(zval* object, zval* member, zval* value,
|
|
|
+ void** cache_slot) {
|
|
|
#endif
|
|
|
if (Z_TYPE_P(member) != IS_STRING) {
|
|
|
zend_error(E_USER_ERROR, "Unexpected type for field name");
|
|
|
+#if PHP_VERSION_ID < 70400
|
|
|
return;
|
|
|
+#else
|
|
|
+ return value;
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
#if PHP_MAJOR_VERSION < 7 || (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION == 0)
|
|
@@ -156,10 +168,17 @@ static void message_set_property(zval* object, zval* member, zval* value,
|
|
|
#endif
|
|
|
// User cannot set property directly (e.g., $m->a = 1)
|
|
|
zend_error(E_USER_ERROR, "Cannot access private property.");
|
|
|
+#if PHP_VERSION_ID < 70400
|
|
|
return;
|
|
|
+#else
|
|
|
+ return value;
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
message_set_property_internal(object, member, value TSRMLS_CC);
|
|
|
+#if PHP_VERSION_ID >= 70400
|
|
|
+ return value;
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
static zval* message_get_property_internal(zval* object,
|
|
@@ -380,7 +399,6 @@ void Message_construct(zval* msg, zval* array_wrapper) {
|
|
|
|
|
|
if (upb_fielddef_issubmsg(value_field)) {
|
|
|
const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(value_field);
|
|
|
- upb_wellknowntype_t type = upb_msgdef_wellknowntype(submsgdef);
|
|
|
is_wrapper = is_wrapper_msg(submsgdef);
|
|
|
|
|
|
if (is_wrapper) {
|
|
@@ -420,7 +438,6 @@ void Message_construct(zval* msg, zval* array_wrapper) {
|
|
|
|
|
|
if (upb_fielddef_issubmsg(field)) {
|
|
|
const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(field);
|
|
|
- upb_wellknowntype_t type = upb_msgdef_wellknowntype(submsgdef);
|
|
|
is_wrapper = is_wrapper_msg(submsgdef);
|
|
|
|
|
|
if (is_wrapper) {
|
|
@@ -646,6 +663,9 @@ PHP_METHOD(Message, writeWrapperValue) {
|
|
|
CASE_TYPE(BOOL, bool, int8_t)
|
|
|
|
|
|
#undef CASE_TYPE
|
|
|
+ case UPB_TYPE_MESSAGE:
|
|
|
+ zend_error(E_ERROR, "No wrapper for message.");
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -666,7 +686,6 @@ PHP_METHOD(Message, writeWrapperValue) {
|
|
|
const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(field);
|
|
|
const upb_fielddef* value_field = upb_msgdef_itof(submsgdef, 1);
|
|
|
MessageHeader* submsg = UNBOX(MessageHeader, cached_zval);
|
|
|
- CACHED_VALUE* cached_value = find_zval_property(submsg, value_field);
|
|
|
layout_set(submsg->descriptor->layout, submsg,
|
|
|
value_field, value TSRMLS_CC);
|
|
|
} else {
|
|
@@ -1156,7 +1175,11 @@ PHP_METHOD(Field_Cardinality, name) {
|
|
|
zend_throw_exception_ex(
|
|
|
NULL, 0 TSRMLS_CC,
|
|
|
"Enum Google\\Protobuf\\Field_Cardinality has no name "
|
|
|
+#if PHP_MAJOR_VERSION < 7
|
|
|
"defined for value %d.",
|
|
|
+#else
|
|
|
+ "defined for value " ZEND_LONG_FMT ".",
|
|
|
+#endif
|
|
|
value);
|
|
|
}
|
|
|
}
|
|
@@ -1291,7 +1314,11 @@ PHP_METHOD(Field_Kind, name) {
|
|
|
default:
|
|
|
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
|
|
|
"Enum Google\\Protobuf\\Field_Kind has no name "
|
|
|
+#if PHP_MAJOR_VERSION < 7
|
|
|
"defined for value %d.",
|
|
|
+#else
|
|
|
+ "defined for value " ZEND_LONG_FMT ".",
|
|
|
+#endif
|
|
|
value);
|
|
|
}
|
|
|
}
|
|
@@ -1362,7 +1389,11 @@ PHP_METHOD(NullValue, name) {
|
|
|
default:
|
|
|
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
|
|
|
"Enum Google\\Protobuf\\NullValue has no name "
|
|
|
+#if PHP_MAJOR_VERSION < 7
|
|
|
"defined for value %d.",
|
|
|
+#else
|
|
|
+ "defined for value " ZEND_LONG_FMT ".",
|
|
|
+#endif
|
|
|
value);
|
|
|
}
|
|
|
}
|
|
@@ -1419,7 +1450,11 @@ PHP_METHOD(Syntax, name) {
|
|
|
default:
|
|
|
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
|
|
|
"Enum Google\\Protobuf\\Syntax has no name "
|
|
|
+#if PHP_MAJOR_VERSION < 7
|
|
|
"defined for value %d.",
|
|
|
+#else
|
|
|
+ "defined for value " ZEND_LONG_FMT ".",
|
|
|
+#endif
|
|
|
value);
|
|
|
}
|
|
|
}
|
|
@@ -1495,7 +1530,6 @@ static void hex_to_binary(const char* hex, char** binary, int* binary_len) {
|
|
|
|
|
|
PHP_METHOD(Any, __construct) {
|
|
|
init_file_any(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -1660,7 +1694,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Duration, __construct) {
|
|
|
init_file_duration(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -1695,7 +1728,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Timestamp, __construct) {
|
|
|
init_file_timestamp(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -1704,7 +1736,6 @@ PHP_PROTO_FIELD_ACCESSORS(Timestamp, timestamp, Nanos, "nanos")
|
|
|
|
|
|
PHP_METHOD(Timestamp, fromDateTime) {
|
|
|
zval* datetime;
|
|
|
- zval member;
|
|
|
|
|
|
PHP_PROTO_CE_DECLARE date_interface_ce;
|
|
|
if (php_proto_zend_lookup_class("\\DatetimeInterface", 18,
|
|
@@ -1897,7 +1928,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Api, __construct) {
|
|
|
init_file_api(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -1931,7 +1961,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(BoolValue, __construct) {
|
|
|
init_file_wrappers(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -1959,7 +1988,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(BytesValue, __construct) {
|
|
|
init_file_wrappers(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -1987,7 +2015,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(DoubleValue, __construct) {
|
|
|
init_file_wrappers(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2031,7 +2058,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Enum, __construct) {
|
|
|
init_file_type(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2071,7 +2097,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(EnumValue, __construct) {
|
|
|
init_file_type(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2101,7 +2126,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(FieldMask, __construct) {
|
|
|
init_file_field_mask(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2166,7 +2190,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Field, __construct) {
|
|
|
init_file_type(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2203,7 +2226,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(FloatValue, __construct) {
|
|
|
init_file_wrappers(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2227,7 +2249,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(GPBEmpty, __construct) {
|
|
|
init_file_empty(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2254,7 +2275,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Int32Value, __construct) {
|
|
|
init_file_wrappers(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2282,7 +2302,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Int64Value, __construct) {
|
|
|
init_file_wrappers(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2310,7 +2329,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(ListValue, __construct) {
|
|
|
init_file_struct(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2366,7 +2384,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Method, __construct) {
|
|
|
init_file_api(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2404,7 +2421,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Mixin, __construct) {
|
|
|
init_file_api(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2437,7 +2453,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Option, __construct) {
|
|
|
init_file_type(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2467,7 +2482,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(SourceContext, __construct) {
|
|
|
init_file_source_context(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2495,7 +2509,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(StringValue, __construct) {
|
|
|
init_file_wrappers(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2523,7 +2536,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Struct, __construct) {
|
|
|
init_file_struct(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2571,7 +2583,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Type, __construct) {
|
|
|
init_file_type(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2604,7 +2615,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(UInt32Value, __construct) {
|
|
|
init_file_wrappers(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2632,7 +2642,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(UInt64Value, __construct) {
|
|
|
init_file_wrappers(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|
|
@@ -2671,7 +2680,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END
|
|
|
|
|
|
PHP_METHOD(Value, __construct) {
|
|
|
init_file_struct(TSRMLS_C);
|
|
|
- MessageHeader* intern = UNBOX(MessageHeader, getThis());
|
|
|
INIT_MESSAGE_WITH_ARRAY;
|
|
|
}
|
|
|
|