Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
52ab3b07
Commit
52ab3b07
authored
Oct 04, 2016
by
Stanley Cheung
Committed by
Paul Yang
Oct 04, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHP: fix ZTS tsrm_ls errors (#2189)
* PHP: fix ZTS tsrm_ls errors * Fix a few more macros
parent
71e5994b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
29 deletions
+35
-29
array.c
php/ext/google/protobuf/array.c
+3
-2
encode_decode.c
php/ext/google/protobuf/encode_decode.c
+0
-0
map.c
php/ext/google/protobuf/map.c
+10
-9
message.c
php/ext/google/protobuf/message.c
+3
-2
protobuf.h
php/ext/google/protobuf/protobuf.h
+8
-7
storage.c
php/ext/google/protobuf/storage.c
+11
-9
No files found.
php/ext/google/protobuf/array.c
View file @
52ab3b07
...
...
@@ -160,7 +160,8 @@ static void repeated_field_write_dimension(zval *object, zval *offset,
unsigned
char
memory
[
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
;
}
...
...
@@ -192,7 +193,7 @@ static HashTable *repeated_field_get_gc(zval *object, zval ***table,
// 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
);
void
*
value
;
...
...
php/ext/google/protobuf/encode_decode.c
View file @
52ab3b07
This diff is collapsed.
Click to expand it.
php/ext/google/protobuf/map.c
View file @
52ab3b07
...
...
@@ -88,7 +88,7 @@ void* upb_value_memory(upb_value* v) {
static
bool
table_key
(
Map
*
self
,
zval
*
key
,
char
*
buf
,
const
char
**
out_key
,
size_t
*
out_length
)
{
size_t
*
out_length
TSRMLS_DC
)
{
switch
(
self
->
key_type
)
{
case
UPB_TYPE_STRING
:
if
(
!
protobuf_convert_to_string
(
key
))
{
...
...
@@ -108,7 +108,7 @@ static bool table_key(Map* self, zval* key,
if (!protobuf_convert_to_##type(key, &type##_value)) { \
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_length = native_slot_size(self->key_type); \
break; \
...
...
@@ -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
);
intern
->
key_type
=
upb_fielddef_type
(
key_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
)
{
...
...
@@ -270,7 +270,7 @@ static bool *map_field_read_dimension(zval *object, zval *key, int type,
#ifndef NDEBUG
v
.
ctype
=
UPB_CTYPE_UINT64
;
#endif
if
(
!
table_key
(
intern
,
key
,
keybuf
,
&
keyval
,
&
length
))
{
if
(
!
table_key
(
intern
,
key
,
keybuf
,
&
keyval
,
&
length
TSRMLS_CC
))
{
return
false
;
}
...
...
@@ -303,13 +303,14 @@ static bool map_field_write_dimension(zval *object, zval *key,
size_t
length
=
0
;
upb_value
v
;
void
*
mem
;
if
(
!
table_key
(
intern
,
key
,
keybuf
,
&
keyval
,
&
length
))
{
if
(
!
table_key
(
intern
,
key
,
keybuf
,
&
keyval
,
&
length
TSRMLS_CC
))
{
return
false
;
}
mem
=
upb_value_memory
(
&
v
);
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
;
}
#ifndef NDEBUG
...
...
@@ -333,7 +334,7 @@ static bool map_field_unset_dimension(zval *object, zval *key TSRMLS_DC) {
const
char
*
keyval
=
NULL
;
size_t
length
=
0
;
upb_value
v
;
if
(
!
table_key
(
intern
,
key
,
keybuf
,
&
keyval
,
&
length
))
{
if
(
!
table_key
(
intern
,
key
,
keybuf
,
&
keyval
,
&
length
TSRMLS_CC
))
{
return
false
;
}
#ifndef NDEBUG
...
...
@@ -396,7 +397,7 @@ PHP_METHOD(MapField, offsetExists) {
#ifndef NDEBUG
v
.
ctype
=
UPB_CTYPE_UINT64
;
#endif
if
(
!
table_key
(
intern
,
key
,
keybuf
,
&
keyval
,
&
length
))
{
if
(
!
table_key
(
intern
,
key
,
keybuf
,
&
keyval
,
&
length
TSRMLS_CC
))
{
return
false
;
}
...
...
@@ -446,7 +447,7 @@ PHP_METHOD(MapField, count) {
// 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_begin_internal
(
self
,
iter
);
}
...
...
php/ext/google/protobuf/message.c
View file @
52ab3b07
...
...
@@ -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
));
}
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
,
...
...
@@ -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
);
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
(
msg
,
(
zend_objects_store_dtor_t
)
zend_objects_destroy_object
,
message_free
,
...
...
php/ext/google/protobuf/protobuf.h
View file @
52ab3b07
...
...
@@ -233,11 +233,12 @@ struct MessageHeader {
};
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
,
const
upb_fielddef
*
field
,
zval
**
cache
TSRMLS_DC
);
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
);
PHP_METHOD
(
Message
,
readOneof
);
...
...
@@ -293,7 +294,7 @@ PHP_METHOD(Util, checkRepeatedField);
size_t
native_slot_size
(
upb_fieldtype_t
type
);
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
);
// For each property, in order to avoid conversion between the zval object and
// the actual data type during parsing/serialization, the containing message
...
...
@@ -325,7 +326,7 @@ typedef struct {
upb_strtable_iter
it
;
}
MapIter
;
void
map_begin
(
zval
*
self
,
MapIter
*
iter
);
void
map_begin
(
zval
*
self
,
MapIter
*
iter
TSRMLS_DC
);
void
map_next
(
MapIter
*
iter
);
bool
map_done
(
MapIter
*
iter
);
const
char
*
map_iter_key
(
MapIter
*
iter
,
int
*
len
);
...
...
@@ -377,10 +378,10 @@ void repeated_field_create_with_type(zend_class_entry* ce,
zval
**
repeated_field
TSRMLS_DC
);
// Return the element at the index position from the repeated field. There is
// 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
// 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
,
append
);
...
...
@@ -411,7 +412,7 @@ typedef struct {
// -----------------------------------------------------------------------------
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.
...
...
php/ext/google/protobuf/storage.c
View file @
52ab3b07
...
...
@@ -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
,
void
*
memory
,
zval
*
value
)
{
void
*
memory
,
zval
*
value
TSRMLS_DC
)
{
switch
(
type
)
{
case
UPB_TYPE_STRING
:
case
UPB_TYPE_BYTES
:
{
...
...
@@ -295,7 +295,7 @@ const upb_fielddef* map_entry_value(const upb_msgdef* msgdef) {
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
)
{
zval
*
desc_php
=
get_def_obj
(
upb_fielddef_subdef
(
field
));
Descriptor
*
desc
=
zend_object_store_get_object
(
desc_php
TSRMLS_CC
);
...
...
@@ -435,7 +435,8 @@ void free_layout(MessageLayout* 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
;
upb_msg_field_iter
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)
*
oneof_case
=
ONEOF_CASE_NONE
;
}
else
if
(
is_map_field
(
field
))
{
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
;
}
else
if
(
upb_fielddef_label
(
field
)
==
UPB_LABEL_REPEATED
)
{
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
;
}
else
{
native_slot_init
(
upb_fielddef_type
(
field
),
memory
,
property_ptr
);
...
...
@@ -501,8 +503,8 @@ zval* layout_get(MessageLayout* layout, const void* storage,
}
}
void
layout_set
(
MessageLayout
*
layout
,
MessageHeader
*
header
,
const
upb_fielddef
*
field
,
zval
*
val
)
{
void
layout_set
(
MessageLayout
*
layout
,
MessageHeader
*
header
,
const
upb_fielddef
*
field
,
zval
*
val
TSRMLS_DC
)
{
void
*
storage
=
message_data
(
header
);
void
*
memory
=
slot_memory
(
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
break
;
}
native_slot_set
(
type
,
ce
,
memory
,
val
);
native_slot_set
(
type
,
ce
,
memory
,
val
TSRMLS_CC
);
*
oneof_case
=
upb_fielddef_number
(
field
);
}
else
if
(
upb_fielddef_label
(
field
)
==
UPB_LABEL_REPEATED
)
{
// Works for both repeated and map fields
...
...
@@ -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
);
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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment