Commit 52ab3b07 authored by Stanley Cheung's avatar Stanley Cheung Committed by Paul Yang

PHP: fix ZTS tsrm_ls errors (#2189)

* PHP: fix ZTS tsrm_ls errors

* Fix a few more macros
parent 71e5994b
...@@ -160,7 +160,8 @@ static void repeated_field_write_dimension(zval *object, zval *offset, ...@@ -160,7 +160,8 @@ static void repeated_field_write_dimension(zval *object, zval *offset,
unsigned char memory[NATIVE_SLOT_MAX_SIZE]; unsigned char memory[NATIVE_SLOT_MAX_SIZE];
memset(memory, 0, NATIVE_SLOT_MAX_SIZE); memset(memory, 0, NATIVE_SLOT_MAX_SIZE);
if (!native_slot_set(intern->type, intern->msg_ce, memory, value)) { if (!native_slot_set(intern->type, intern->msg_ce, memory, value
TSRMLS_CC)) {
return; return;
} }
...@@ -192,7 +193,7 @@ static HashTable *repeated_field_get_gc(zval *object, zval ***table, ...@@ -192,7 +193,7 @@ static HashTable *repeated_field_get_gc(zval *object, zval ***table,
// C RepeatedField Utilities // C RepeatedField Utilities
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void *repeated_field_index_native(RepeatedField *intern, int index) { void *repeated_field_index_native(RepeatedField *intern, int index TSRMLS_DC) {
HashTable *ht = HASH_OF(intern->array); HashTable *ht = HASH_OF(intern->array);
void *value; void *value;
......
...@@ -199,11 +199,11 @@ static void *startseq_handler(void* closure, const void* hd) { ...@@ -199,11 +199,11 @@ static void *startseq_handler(void* closure, const void* hd) {
// Handlers that append primitive values to a repeated field. // Handlers that append primitive values to a repeated field.
#define DEFINE_APPEND_HANDLER(type, ctype) \ #define DEFINE_APPEND_HANDLER(type, ctype) \
static bool append##type##_handler(void* closure, const void* hd, \ static bool append##type##_handler(void* closure, const void* hd, \
ctype val) { \ ctype val TSRMLS_DC) { \
zval* array = (zval*)closure; \ zval* array = (zval*)closure; \
RepeatedField* intern = \ RepeatedField* intern = \
(RepeatedField*)zend_object_store_get_object(array TSRMLS_CC); \ (RepeatedField*)zend_object_store_get_object(array TSRMLS_CC); \
repeated_field_push_native(intern, &val); \ repeated_field_push_native(intern, &val TSRMLS_CC); \
return true; \ return true; \
} }
...@@ -218,7 +218,7 @@ DEFINE_APPEND_HANDLER(double, double) ...@@ -218,7 +218,7 @@ DEFINE_APPEND_HANDLER(double, double)
// Appends a string to a repeated field. // Appends a string to a repeated field.
static void* appendstr_handler(void *closure, static void* appendstr_handler(void *closure,
const void *hd, const void *hd,
size_t size_hint) { size_t size_hint TSRMLS_DC) {
zval* array = (zval*)closure; zval* array = (zval*)closure;
RepeatedField* intern = RepeatedField* intern =
(RepeatedField*)zend_object_store_get_object(array TSRMLS_CC); (RepeatedField*)zend_object_store_get_object(array TSRMLS_CC);
...@@ -234,7 +234,7 @@ static void* appendstr_handler(void *closure, ...@@ -234,7 +234,7 @@ static void* appendstr_handler(void *closure,
// Appends a 'bytes' string to a repeated field. // Appends a 'bytes' string to a repeated field.
static void* appendbytes_handler(void *closure, static void* appendbytes_handler(void *closure,
const void *hd, const void *hd,
size_t size_hint) { size_t size_hint TSRMLS_DC) {
zval* array = (zval*)closure; zval* array = (zval*)closure;
RepeatedField* intern = RepeatedField* intern =
(RepeatedField*)zend_object_store_get_object(array TSRMLS_CC); (RepeatedField*)zend_object_store_get_object(array TSRMLS_CC);
...@@ -296,7 +296,7 @@ static size_t stringdata_handler(void* closure, const void* hd, ...@@ -296,7 +296,7 @@ static size_t stringdata_handler(void* closure, const void* hd,
} }
// Appends a submessage to a repeated field. // Appends a submessage to a repeated field.
static void *appendsubmsg_handler(void *closure, const void *hd) { static void *appendsubmsg_handler(void *closure, const void *hd TSRMLS_DC) {
zval* array = (zval*)closure; zval* array = (zval*)closure;
RepeatedField* intern = RepeatedField* intern =
(RepeatedField*)zend_object_store_get_object(array TSRMLS_CC); (RepeatedField*)zend_object_store_get_object(array TSRMLS_CC);
...@@ -319,7 +319,7 @@ static void *appendsubmsg_handler(void *closure, const void *hd) { ...@@ -319,7 +319,7 @@ static void *appendsubmsg_handler(void *closure, const void *hd) {
} }
// Sets a non-repeated submessage field in a message. // Sets a non-repeated submessage field in a message.
static void *submsg_handler(void *closure, const void *hd) { static void *submsg_handler(void *closure, const void *hd TSRMLS_DC) {
MessageHeader* msg = closure; MessageHeader* msg = closure;
const submsg_handlerdata_t* submsgdata = hd; const submsg_handlerdata_t* submsgdata = hd;
zval* subdesc_php = get_def_obj((void*)submsgdata->md); zval* subdesc_php = get_def_obj((void*)submsgdata->md);
...@@ -423,7 +423,8 @@ static void map_slot_key(upb_fieldtype_t type, const void* from, char** keyval, ...@@ -423,7 +423,8 @@ static void map_slot_key(upb_fieldtype_t type, const void* from, char** keyval,
} }
} }
static void map_slot_value(upb_fieldtype_t type, const void* from, upb_value* v) { static void map_slot_value(upb_fieldtype_t type, const void* from,
upb_value* v) {
size_t len; size_t len;
void* to = upb_value_memory(v); void* to = upb_value_memory(v);
#ifndef NDEBUG #ifndef NDEBUG
...@@ -464,7 +465,8 @@ static void *startmapentry_handler(void *closure, const void *hd) { ...@@ -464,7 +465,8 @@ static void *startmapentry_handler(void *closure, const void *hd) {
// Handler to end a map entry: inserts the value defined during the message into // Handler to end a map entry: inserts the value defined during the message into
// the map. This is the 'endmsg' handler on the map entry msgdef. // the map. This is the 'endmsg' handler on the map entry msgdef.
static bool endmap_handler(void *closure, const void *hd, upb_status* s) { static bool endmap_handler(void *closure, const void *hd, upb_status* s
TSRMLS_DC) {
map_parse_frame_t* frame = closure; map_parse_frame_t* frame = closure;
const map_handlerdata_t* mapdata = hd; const map_handlerdata_t* mapdata = hd;
...@@ -574,7 +576,7 @@ static void *oneofbytes_handler(void *closure, ...@@ -574,7 +576,7 @@ static void *oneofbytes_handler(void *closure,
// Handler for a submessage field in a oneof. // Handler for a submessage field in a oneof.
static void *oneofsubmsg_handler(void *closure, static void *oneofsubmsg_handler(void *closure,
const void *hd) { const void *hd TSRMLS_DC) {
MessageHeader* msg = closure; MessageHeader* msg = closure;
const oneof_handlerdata_t *oneofdata = hd; const oneof_handlerdata_t *oneofdata = hd;
uint32_t oldcase = DEREF(msg, oneofdata->case_ofs, uint32_t); uint32_t oldcase = DEREF(msg, oneofdata->case_ofs, uint32_t);
...@@ -771,7 +773,8 @@ static void add_handlers_for_oneof_field(upb_handlers *h, ...@@ -771,7 +773,8 @@ static void add_handlers_for_oneof_field(upb_handlers *h,
upb_handlerattr_uninit(&attr); upb_handlerattr_uninit(&attr);
} }
static void add_handlers_for_message(const void *closure, upb_handlers *h) { static void add_handlers_for_message(const void *closure, upb_handlers *h
TSRMLS_DC) {
const upb_msgdef* msgdef = upb_handlers_msgdef(h); const upb_msgdef* msgdef = upb_handlers_msgdef(h);
Descriptor* desc = (Descriptor*)zend_object_store_get_object( Descriptor* desc = (Descriptor*)zend_object_store_get_object(
get_def_obj((void*)msgdef) TSRMLS_CC); get_def_obj((void*)msgdef) TSRMLS_CC);
...@@ -860,7 +863,7 @@ static const upb_pbdecodermethod *msgdef_decodermethod(Descriptor* desc) { ...@@ -860,7 +863,7 @@ static const upb_pbdecodermethod *msgdef_decodermethod(Descriptor* desc) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
static void putmsg(zval* msg, const Descriptor* desc, upb_sink* sink, static void putmsg(zval* msg, const Descriptor* desc, upb_sink* sink,
int depth); int depth TSRMLS_DC);
static void putstr(zval* str, const upb_fielddef* f, upb_sink* sink); static void putstr(zval* str, const upb_fielddef* f, upb_sink* sink);
...@@ -868,11 +871,12 @@ static void putrawstr(const char* str, int len, const upb_fielddef* f, ...@@ -868,11 +871,12 @@ static void putrawstr(const char* str, int len, const upb_fielddef* f,
upb_sink* sink); upb_sink* sink);
static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink, static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink,
int depth); int depth TSRMLS_DC);
static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink, static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink,
int depth); int depth TSRMLS_DC);
static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink, int depth); static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink, int depth
TSRMLS_DC);
static upb_selector_t getsel(const upb_fielddef* f, upb_handlertype_t type) { static upb_selector_t getsel(const upb_fielddef* f, upb_handlertype_t type) {
upb_selector_t ret; upb_selector_t ret;
...@@ -882,7 +886,7 @@ static upb_selector_t getsel(const upb_fielddef* f, upb_handlertype_t type) { ...@@ -882,7 +886,7 @@ static upb_selector_t getsel(const upb_fielddef* f, upb_handlertype_t type) {
} }
static void put_optional_value(void* memory, int len, const upb_fielddef* f, static void put_optional_value(void* memory, int len, const upb_fielddef* f,
int depth, upb_sink* sink) { int depth, upb_sink* sink TSRMLS_DC) {
assert(upb_fielddef_label(f) == UPB_LABEL_OPTIONAL); assert(upb_fielddef_label(f) == UPB_LABEL_OPTIONAL);
switch (upb_fielddef_type(f)) { switch (upb_fielddef_type(f)) {
...@@ -911,7 +915,7 @@ static void put_optional_value(void* memory, int len, const upb_fielddef* f, ...@@ -911,7 +915,7 @@ static void put_optional_value(void* memory, int len, const upb_fielddef* f,
break; break;
case UPB_TYPE_MESSAGE: { case UPB_TYPE_MESSAGE: {
zval* submsg = *(zval**)memory; zval* submsg = *(zval**)memory;
putsubmsg(submsg, f, sink, depth); putsubmsg(submsg, f, sink, depth TSRMLS_CC);
break; break;
} }
default: default:
...@@ -943,7 +947,7 @@ static int raw_value_len(void* memory, int len, const upb_fielddef* f) { ...@@ -943,7 +947,7 @@ static int raw_value_len(void* memory, int len, const upb_fielddef* f) {
} }
static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink, static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
int depth) { int depth TSRMLS_DC) {
Map* self; Map* self;
upb_sink subsink; upb_sink subsink;
const upb_fielddef* key_field; const upb_fielddef* key_field;
...@@ -960,7 +964,7 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink, ...@@ -960,7 +964,7 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
key_field = map_field_key(f); key_field = map_field_key(f);
value_field = map_field_value(f); value_field = map_field_value(f);
for (map_begin(map, &it); !map_done(&it); map_next(&it)) { for (map_begin(map, &it TSRMLS_CC); !map_done(&it); map_next(&it)) {
upb_status status; upb_status status;
upb_sink entry_sink; upb_sink entry_sink;
...@@ -970,13 +974,13 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink, ...@@ -970,13 +974,13 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
// Serialize key. // Serialize key.
const char *key = map_iter_key(&it, &len); const char *key = map_iter_key(&it, &len);
put_optional_value(key, len, key_field, depth + 1, &entry_sink); put_optional_value(key, len, key_field, depth + 1, &entry_sink TSRMLS_CC);
// Serialize value. // Serialize value.
upb_value value = map_iter_value(&it, &len); upb_value value = map_iter_value(&it, &len);
put_optional_value(raw_value(upb_value_memory(&value), value_field), put_optional_value(raw_value(upb_value_memory(&value), value_field),
raw_value_len(upb_value_memory(&value), len, value_field), raw_value_len(upb_value_memory(&value), len, value_field),
value_field, depth + 1, &entry_sink); value_field, depth + 1, &entry_sink TSRMLS_CC);
upb_sink_endmsg(&entry_sink, &status); upb_sink_endmsg(&entry_sink, &status);
upb_sink_endsubmsg(&subsink, getsel(f, UPB_HANDLER_ENDSUBMSG)); upb_sink_endsubmsg(&subsink, getsel(f, UPB_HANDLER_ENDSUBMSG));
...@@ -986,7 +990,7 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink, ...@@ -986,7 +990,7 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
} }
static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink* sink, static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink* sink,
int depth) { int depth TSRMLS_DC) {
upb_msg_field_iter i; upb_msg_field_iter i;
upb_status status; upb_status status;
...@@ -1023,12 +1027,12 @@ static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink* sink, ...@@ -1023,12 +1027,12 @@ static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink* sink,
if (is_map_field(f)) { if (is_map_field(f)) {
zval* map = *DEREF(msg, offset, zval**); zval* map = *DEREF(msg, offset, zval**);
if (map != NULL) { if (map != NULL) {
putmap(map, f, sink, depth); putmap(map, f, sink, depth TSRMLS_CC);
} }
} else if (upb_fielddef_isseq(f)) { } else if (upb_fielddef_isseq(f)) {
zval* array = *DEREF(msg, offset, zval**); zval* array = *DEREF(msg, offset, zval**);
if (array != NULL) { if (array != NULL) {
putarray(array, f, sink, depth); putarray(array, f, sink, depth TSRMLS_CC);
} }
} else if (upb_fielddef_isstring(f)) { } else if (upb_fielddef_isstring(f)) {
zval* str = *DEREF(msg, offset, zval**); zval* str = *DEREF(msg, offset, zval**);
...@@ -1036,7 +1040,7 @@ static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink* sink, ...@@ -1036,7 +1040,7 @@ static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink* sink,
putstr(str, f, sink); putstr(str, f, sink);
} }
} else if (upb_fielddef_issubmsg(f)) { } else if (upb_fielddef_issubmsg(f)) {
putsubmsg(*DEREF(msg, offset, zval**), f, sink, depth); putsubmsg(*DEREF(msg, offset, zval**), f, sink, depth TSRMLS_CC);
} else { } else {
upb_selector_t sel = getsel(f, upb_handlers_getprimitivehandlertype(f)); upb_selector_t sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
...@@ -1113,7 +1117,7 @@ static void putrawstr(const char* str, int len, const upb_fielddef* f, ...@@ -1113,7 +1117,7 @@ static void putrawstr(const char* str, int len, const upb_fielddef* f,
} }
static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink, static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink,
int depth) { int depth TSRMLS_DC) {
upb_sink subsink; upb_sink subsink;
if (Z_TYPE_P(submsg) == IS_NULL) return; if (Z_TYPE_P(submsg) == IS_NULL) return;
...@@ -1123,12 +1127,12 @@ static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink, ...@@ -1123,12 +1127,12 @@ static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink,
(Descriptor*)zend_object_store_get_object(php_descriptor TSRMLS_CC); (Descriptor*)zend_object_store_get_object(php_descriptor TSRMLS_CC);
upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink); upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink);
putmsg(submsg, subdesc, &subsink, depth + 1); putmsg(submsg, subdesc, &subsink, depth + 1 TSRMLS_CC);
upb_sink_endsubmsg(sink, getsel(f, UPB_HANDLER_ENDSUBMSG)); upb_sink_endsubmsg(sink, getsel(f, UPB_HANDLER_ENDSUBMSG));
} }
static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink, static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink,
int depth) { int depth TSRMLS_DC) {
upb_sink subsink; upb_sink subsink;
upb_fieldtype_t type = upb_fielddef_type(f); upb_fieldtype_t type = upb_fielddef_type(f);
upb_selector_t sel = 0; upb_selector_t sel = 0;
...@@ -1147,7 +1151,7 @@ static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink, ...@@ -1147,7 +1151,7 @@ static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink,
} }
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
void* memory = repeated_field_index_native(intern, i); void* memory = repeated_field_index_native(intern, i TSRMLS_CC);
switch (type) { switch (type) {
#define T(upbtypeconst, upbtype, ctype) \ #define T(upbtypeconst, upbtype, ctype) \
case upbtypeconst: \ case upbtypeconst: \
...@@ -1168,7 +1172,7 @@ static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink, ...@@ -1168,7 +1172,7 @@ static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink,
putstr(*((zval**)memory), f, &subsink); putstr(*((zval**)memory), f, &subsink);
break; break;
case UPB_TYPE_MESSAGE: case UPB_TYPE_MESSAGE:
putsubmsg(*((zval**)memory), f, &subsink, depth); putsubmsg(*((zval**)memory), f, &subsink, depth TSRMLS_CC);
break; break;
#undef T #undef T
...@@ -1206,7 +1210,7 @@ PHP_METHOD(Message, encode) { ...@@ -1206,7 +1210,7 @@ PHP_METHOD(Message, encode) {
stackenv_init(&se, "Error occurred during encoding: %s"); stackenv_init(&se, "Error occurred during encoding: %s");
encoder = upb_pb_encoder_create(&se.env, serialize_handlers, &sink.sink); encoder = upb_pb_encoder_create(&se.env, serialize_handlers, &sink.sink);
putmsg(getThis(), desc, upb_pb_encoder_input(encoder), 0); putmsg(getThis(), desc, upb_pb_encoder_input(encoder), 0 TSRMLS_CC);
RETVAL_STRINGL(sink.ptr, sink.len, 1); RETVAL_STRINGL(sink.ptr, sink.len, 1);
......
...@@ -88,7 +88,7 @@ void* upb_value_memory(upb_value* v) { ...@@ -88,7 +88,7 @@ void* upb_value_memory(upb_value* v) {
static bool table_key(Map* self, zval* key, static bool table_key(Map* self, zval* key,
char* buf, char* buf,
const char** out_key, const char** out_key,
size_t* out_length) { size_t* out_length TSRMLS_DC) {
switch (self->key_type) { switch (self->key_type) {
case UPB_TYPE_STRING: case UPB_TYPE_STRING:
if (!protobuf_convert_to_string(key)) { if (!protobuf_convert_to_string(key)) {
...@@ -108,7 +108,7 @@ static bool table_key(Map* self, zval* key, ...@@ -108,7 +108,7 @@ static bool table_key(Map* self, zval* key,
if (!protobuf_convert_to_##type(key, &type##_value)) { \ if (!protobuf_convert_to_##type(key, &type##_value)) { \
return false; \ return false; \
} \ } \
native_slot_set(self->key_type, NULL, buf, key); \ native_slot_set(self->key_type, NULL, buf, key TSRMLS_CC); \
*out_key = buf; \ *out_key = buf; \
*out_length = native_slot_size(self->key_type); \ *out_length = native_slot_size(self->key_type); \
break; \ break; \
...@@ -248,7 +248,7 @@ void map_field_create_with_type(zend_class_entry *ce, const upb_fielddef *field, ...@@ -248,7 +248,7 @@ void map_field_create_with_type(zend_class_entry *ce, const upb_fielddef *field,
const upb_fielddef *value_field = map_field_value(field); const upb_fielddef *value_field = map_field_value(field);
intern->key_type = upb_fielddef_type(key_field); intern->key_type = upb_fielddef_type(key_field);
intern->value_type = upb_fielddef_type(value_field); intern->value_type = upb_fielddef_type(value_field);
intern->msg_ce = field_type_class(value_field); intern->msg_ce = field_type_class(value_field TSRMLS_CC);
} }
static void map_field_free_element(void *object) { static void map_field_free_element(void *object) {
...@@ -270,7 +270,7 @@ static bool *map_field_read_dimension(zval *object, zval *key, int type, ...@@ -270,7 +270,7 @@ static bool *map_field_read_dimension(zval *object, zval *key, int type,
#ifndef NDEBUG #ifndef NDEBUG
v.ctype = UPB_CTYPE_UINT64; v.ctype = UPB_CTYPE_UINT64;
#endif #endif
if (!table_key(intern, key, keybuf, &keyval, &length)) { if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
return false; return false;
} }
...@@ -303,13 +303,14 @@ static bool map_field_write_dimension(zval *object, zval *key, ...@@ -303,13 +303,14 @@ static bool map_field_write_dimension(zval *object, zval *key,
size_t length = 0; size_t length = 0;
upb_value v; upb_value v;
void* mem; void* mem;
if (!table_key(intern, key, keybuf, &keyval, &length)) { if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
return false; return false;
} }
mem = upb_value_memory(&v); mem = upb_value_memory(&v);
memset(mem, 0, native_slot_size(intern->value_type)); memset(mem, 0, native_slot_size(intern->value_type));
if(!native_slot_set(intern->value_type, intern->msg_ce, mem, value)) { if (!native_slot_set(intern->value_type, intern->msg_ce, mem, value
TSRMLS_CC)) {
return false; return false;
} }
#ifndef NDEBUG #ifndef NDEBUG
...@@ -333,7 +334,7 @@ static bool map_field_unset_dimension(zval *object, zval *key TSRMLS_DC) { ...@@ -333,7 +334,7 @@ static bool map_field_unset_dimension(zval *object, zval *key TSRMLS_DC) {
const char* keyval = NULL; const char* keyval = NULL;
size_t length = 0; size_t length = 0;
upb_value v; upb_value v;
if (!table_key(intern, key, keybuf, &keyval, &length)) { if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
return false; return false;
} }
#ifndef NDEBUG #ifndef NDEBUG
...@@ -396,7 +397,7 @@ PHP_METHOD(MapField, offsetExists) { ...@@ -396,7 +397,7 @@ PHP_METHOD(MapField, offsetExists) {
#ifndef NDEBUG #ifndef NDEBUG
v.ctype = UPB_CTYPE_UINT64; v.ctype = UPB_CTYPE_UINT64;
#endif #endif
if (!table_key(intern, key, keybuf, &keyval, &length)) { if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
return false; return false;
} }
...@@ -446,7 +447,7 @@ PHP_METHOD(MapField, count) { ...@@ -446,7 +447,7 @@ PHP_METHOD(MapField, count) {
// Map Iterator // Map Iterator
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void map_begin(zval *map_php, MapIter *iter) { void map_begin(zval *map_php, MapIter *iter TSRMLS_DC) {
Map *self = UNBOX(Map, map_php); Map *self = UNBOX(Map, map_php);
map_begin_internal(self, iter); map_begin_internal(self, iter);
} }
......
...@@ -96,7 +96,7 @@ static void message_set_property(zval* object, zval* member, zval* value, ...@@ -96,7 +96,7 @@ static void message_set_property(zval* object, zval* member, zval* value,
zend_error(E_USER_ERROR, "Unknown field: %s", Z_STRVAL_P(member)); zend_error(E_USER_ERROR, "Unknown field: %s", Z_STRVAL_P(member));
} }
layout_set(self->descriptor->layout, self, field, value); layout_set(self->descriptor->layout, self, field, value TSRMLS_CC);
} }
static zval* message_get_property(zval* object, zval* member, int type, static zval* message_get_property(zval* object, zval* member, int type,
...@@ -177,7 +177,8 @@ static zend_object_value message_create(zend_class_entry* ce TSRMLS_DC) { ...@@ -177,7 +177,8 @@ static zend_object_value message_create(zend_class_entry* ce TSRMLS_DC) {
zend_object_std_init(&msg->std, ce TSRMLS_CC); zend_object_std_init(&msg->std, ce TSRMLS_CC);
object_properties_init(&msg->std, ce); object_properties_init(&msg->std, ce);
layout_init(desc->layout, message_data(msg), msg->std.properties_table); layout_init(desc->layout, message_data(msg), msg->std.properties_table
TSRMLS_CC);
return_value.handle = zend_objects_store_put( return_value.handle = zend_objects_store_put(
msg, (zend_objects_store_dtor_t)zend_objects_destroy_object, message_free, msg, (zend_objects_store_dtor_t)zend_objects_destroy_object, message_free,
......
...@@ -233,11 +233,12 @@ struct MessageHeader { ...@@ -233,11 +233,12 @@ struct MessageHeader {
}; };
MessageLayout* create_layout(const upb_msgdef* msgdef); MessageLayout* create_layout(const upb_msgdef* msgdef);
void layout_init(MessageLayout* layout, void* storage, zval** properties_table); void layout_init(MessageLayout* layout, void* storage, zval** properties_table
TSRMLS_DC);
zval* layout_get(MessageLayout* layout, const void* storage, zval* layout_get(MessageLayout* layout, const void* storage,
const upb_fielddef* field, zval** cache TSRMLS_DC); const upb_fielddef* field, zval** cache TSRMLS_DC);
void layout_set(MessageLayout* layout, MessageHeader* header, void layout_set(MessageLayout* layout, MessageHeader* header,
const upb_fielddef* field, zval* val); const upb_fielddef* field, zval* val TSRMLS_DC);
void free_layout(MessageLayout* layout); void free_layout(MessageLayout* layout);
PHP_METHOD(Message, readOneof); PHP_METHOD(Message, readOneof);
...@@ -293,7 +294,7 @@ PHP_METHOD(Util, checkRepeatedField); ...@@ -293,7 +294,7 @@ PHP_METHOD(Util, checkRepeatedField);
size_t native_slot_size(upb_fieldtype_t type); size_t native_slot_size(upb_fieldtype_t type);
bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass, bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass,
void* memory, zval* value); void* memory, zval* value TSRMLS_DC);
void native_slot_init(upb_fieldtype_t type, void* memory, zval** cache); void native_slot_init(upb_fieldtype_t type, void* memory, zval** cache);
// For each property, in order to avoid conversion between the zval object and // For each property, in order to avoid conversion between the zval object and
// the actual data type during parsing/serialization, the containing message // the actual data type during parsing/serialization, the containing message
...@@ -325,7 +326,7 @@ typedef struct { ...@@ -325,7 +326,7 @@ typedef struct {
upb_strtable_iter it; upb_strtable_iter it;
} MapIter; } MapIter;
void map_begin(zval* self, MapIter* iter); void map_begin(zval* self, MapIter* iter TSRMLS_DC);
void map_next(MapIter* iter); void map_next(MapIter* iter);
bool map_done(MapIter* iter); bool map_done(MapIter* iter);
const char* map_iter_key(MapIter* iter, int* len); const char* map_iter_key(MapIter* iter, int* len);
...@@ -377,10 +378,10 @@ void repeated_field_create_with_type(zend_class_entry* ce, ...@@ -377,10 +378,10 @@ void repeated_field_create_with_type(zend_class_entry* ce,
zval** repeated_field TSRMLS_DC); zval** repeated_field TSRMLS_DC);
// Return the element at the index position from the repeated field. There is // Return the element at the index position from the repeated field. There is
// not restriction on the type of stored elements. // not restriction on the type of stored elements.
void *repeated_field_index_native(RepeatedField *intern, int index); void *repeated_field_index_native(RepeatedField *intern, int index TSRMLS_DC);
// Add the element to the end of the repeated field. There is not restriction on // Add the element to the end of the repeated field. There is not restriction on
// the type of stored elements. // the type of stored elements.
void repeated_field_push_native(RepeatedField *intern, void *value); void repeated_field_push_native(RepeatedField *intern, void *value TSRMLS_DC);
PHP_METHOD(RepeatedField, __construct); PHP_METHOD(RepeatedField, __construct);
PHP_METHOD(RepeatedField, append); PHP_METHOD(RepeatedField, append);
...@@ -411,7 +412,7 @@ typedef struct { ...@@ -411,7 +412,7 @@ typedef struct {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
upb_fieldtype_t to_fieldtype(upb_descriptortype_t type); upb_fieldtype_t to_fieldtype(upb_descriptortype_t type);
const zend_class_entry *field_type_class(const upb_fielddef *field); const zend_class_entry *field_type_class(const upb_fielddef *field TSRMLS_DC);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Utilities. // Utilities.
......
...@@ -56,7 +56,7 @@ size_t native_slot_size(upb_fieldtype_t type) { ...@@ -56,7 +56,7 @@ size_t native_slot_size(upb_fieldtype_t type) {
} }
bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass, bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass,
void* memory, zval* value) { void* memory, zval* value TSRMLS_DC) {
switch (type) { switch (type) {
case UPB_TYPE_STRING: case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: { case UPB_TYPE_BYTES: {
...@@ -295,7 +295,7 @@ const upb_fielddef* map_entry_value(const upb_msgdef* msgdef) { ...@@ -295,7 +295,7 @@ const upb_fielddef* map_entry_value(const upb_msgdef* msgdef) {
return value_field; return value_field;
} }
const zend_class_entry* field_type_class(const upb_fielddef* field) { const zend_class_entry* field_type_class(const upb_fielddef* field TSRMLS_DC) {
if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) { if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) {
zval* desc_php = get_def_obj(upb_fielddef_subdef(field)); zval* desc_php = get_def_obj(upb_fielddef_subdef(field));
Descriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC); Descriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC);
...@@ -435,7 +435,8 @@ void free_layout(MessageLayout* layout) { ...@@ -435,7 +435,8 @@ void free_layout(MessageLayout* layout) {
FREE(layout); FREE(layout);
} }
void layout_init(MessageLayout* layout, void* storage, zval** properties_table) { void layout_init(MessageLayout* layout, void* storage, zval** properties_table
TSRMLS_DC) {
int i; int i;
upb_msg_field_iter it; upb_msg_field_iter it;
for (upb_msg_field_begin(&it, layout->msgdef), i = 0; !upb_msg_field_done(&it); for (upb_msg_field_begin(&it, layout->msgdef), i = 0; !upb_msg_field_done(&it);
...@@ -451,11 +452,12 @@ void layout_init(MessageLayout* layout, void* storage, zval** properties_table) ...@@ -451,11 +452,12 @@ void layout_init(MessageLayout* layout, void* storage, zval** properties_table)
*oneof_case = ONEOF_CASE_NONE; *oneof_case = ONEOF_CASE_NONE;
} else if (is_map_field(field)) { } else if (is_map_field(field)) {
zval_ptr_dtor(property_ptr); zval_ptr_dtor(property_ptr);
map_field_create_with_type(map_field_type, field, property_ptr); map_field_create_with_type(map_field_type, field, property_ptr TSRMLS_CC);
DEREF(memory, zval**) = property_ptr; DEREF(memory, zval**) = property_ptr;
} else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) { } else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) {
zval_ptr_dtor(property_ptr); zval_ptr_dtor(property_ptr);
repeated_field_create_with_type(repeated_field_type, field, property_ptr); repeated_field_create_with_type(repeated_field_type, field, property_ptr
TSRMLS_CC);
DEREF(memory, zval**) = property_ptr; DEREF(memory, zval**) = property_ptr;
} else { } else {
native_slot_init(upb_fielddef_type(field), memory, property_ptr); native_slot_init(upb_fielddef_type(field), memory, property_ptr);
...@@ -501,8 +503,8 @@ zval* layout_get(MessageLayout* layout, const void* storage, ...@@ -501,8 +503,8 @@ zval* layout_get(MessageLayout* layout, const void* storage,
} }
} }
void layout_set(MessageLayout* layout, MessageHeader* header, const upb_fielddef* field, void layout_set(MessageLayout* layout, MessageHeader* header,
zval* val) { const upb_fielddef* field, zval* val TSRMLS_DC) {
void* storage = message_data(header); void* storage = message_data(header);
void* memory = slot_memory(layout, storage, field); void* memory = slot_memory(layout, storage, field);
uint32_t* oneof_case = slot_oneof_case(layout, storage, field); uint32_t* oneof_case = slot_oneof_case(layout, storage, field);
...@@ -535,7 +537,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, const upb_fielddef ...@@ -535,7 +537,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, const upb_fielddef
break; break;
} }
native_slot_set(type, ce, memory, val); native_slot_set(type, ce, memory, val TSRMLS_CC);
*oneof_case = upb_fielddef_number(field); *oneof_case = upb_fielddef_number(field);
} else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) { } else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) {
// Works for both repeated and map fields // Works for both repeated and map fields
...@@ -554,6 +556,6 @@ void layout_set(MessageLayout* layout, MessageHeader* header, const upb_fielddef ...@@ -554,6 +556,6 @@ void layout_set(MessageLayout* layout, MessageHeader* header, const upb_fielddef
Descriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC); Descriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC);
ce = desc->klass; ce = desc->klass;
} }
native_slot_set(type, ce, value_memory(field, memory), val); native_slot_set(type, ce, value_memory(field, memory), val TSRMLS_CC);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment