Unverified Commit f5e8ee41 authored by Joshua Haberman's avatar Joshua Haberman Committed by GitHub

PHP updates for new upb APIs (#5604)

parent 37581380
......@@ -591,6 +591,7 @@ php_EXTRA_DIST= \
php/README.md \
php/composer.json \
php/ext/google/protobuf/array.c \
php/ext/google/protobuf/builtin_descriptors.inc \
php/ext/google/protobuf/config.m4 \
php/ext/google/protobuf/def.c \
php/ext/google/protobuf/encode_decode.c \
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -494,7 +494,7 @@ void Message_construct(zval* msg, zval* array_wrapper) {
ZVAL_OBJ(submsg, desc->klass->create_object(desc->klass TSRMLS_CC));
Message_construct(submsg, NULL);
MessageHeader* to = UNBOX(MessageHeader, submsg);
const upb_filedef *file = upb_def_file(upb_msgdef_upcast(submsgdef));
const upb_filedef *file = upb_msgdef_file(submsgdef);
if (!strcmp(upb_filedef_name(file), "google/protobuf/wrappers.proto") &&
Z_TYPE_P(CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)value)) != IS_OBJECT) {
const upb_fielddef *value_field = upb_msgdef_itof(submsgdef, 1);
......
......@@ -763,7 +763,12 @@ PHP_METHOD(DescriptorPool, getEnumDescriptorByClassName);
PHP_PROTO_WRAP_OBJECT_START(InternalDescriptorPool)
upb_symtab* symtab;
HashTable* pending_list;
upb_handlercache* fill_handler_cache;
upb_handlercache* pb_serialize_handler_cache;
upb_handlercache* json_serialize_handler_cache;
upb_handlercache* json_serialize_handler_preserve_cache;
upb_pbcodecache* fill_method_cache;
upb_json_codecache* json_fill_method_cache;
PHP_PROTO_WRAP_OBJECT_END
PHP_METHOD(InternalDescriptorPool, getGeneratedPool);
......@@ -773,6 +778,7 @@ void internal_add_generated_file(const char* data, PHP_PROTO_SIZE data_len,
InternalDescriptorPool* pool,
bool use_nested_submsg TSRMLS_DC);
void init_generated_pool_once(TSRMLS_D);
void add_handlers_for_message(const void* closure, upb_handlers* h);
// wrapper of generated pool
#if PHP_MAJOR_VERSION < 7
......@@ -789,15 +795,10 @@ void internal_descriptor_pool_free(zend_object* object);
extern InternalDescriptorPool* generated_pool; // The actual generated pool
PHP_PROTO_WRAP_OBJECT_START(Descriptor)
InternalDescriptorPool* pool;
const upb_msgdef* msgdef;
MessageLayout* layout;
zend_class_entry* klass; // begins as NULL
const upb_handlers* fill_handlers;
const upb_pbdecodermethod* fill_method;
const upb_json_parsermethod* json_fill_method;
const upb_handlers* pb_serialize_handlers;
const upb_handlers* json_serialize_handlers;
const upb_handlers* json_serialize_handlers_preserve;
PHP_PROTO_WRAP_OBJECT_END
PHP_METHOD(Descriptor, getClass);
......@@ -1168,7 +1169,7 @@ PHP_METHOD(RepeatedFieldIter, valid);
// -----------------------------------------------------------------------------
PHP_PROTO_WRAP_OBJECT_START(Oneof)
upb_oneofdef* oneofdef;
const upb_oneofdef* oneofdef;
int index; // Index of field in oneof. -1 if not set.
char value[NATIVE_SLOT_MAX_SIZE];
PHP_PROTO_WRAP_OBJECT_END
......
......@@ -553,11 +553,11 @@ const zend_class_entry* field_type_class(
const upb_fielddef* field PHP_PROTO_TSRMLS_DC) {
if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) {
Descriptor* desc = UNBOX_HASHTABLE_VALUE(
Descriptor, get_def_obj(upb_fielddef_subdef(field)));
Descriptor, get_def_obj(upb_fielddef_msgsubdef(field)));
return desc->klass;
} else if (upb_fielddef_type(field) == UPB_TYPE_ENUM) {
EnumDescriptor* desc = UNBOX_HASHTABLE_VALUE(
EnumDescriptor, get_def_obj(upb_fielddef_subdef(field)));
EnumDescriptor, get_def_obj(upb_fielddef_enumsubdef(field)));
return desc->klass;
}
return NULL;
......@@ -742,16 +742,13 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) {
}
layout->size = off;
layout->msgdef = msgdef;
upb_msgdef_ref(layout->msgdef, &layout->msgdef);
return layout;
}
void free_layout(MessageLayout* layout) {
FREE(layout->fields);
upb_msgdef_unref(layout->msgdef, &layout->msgdef);
FREE(layout);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -18,12 +18,12 @@ internal_build_cpp() {
./autogen.sh
./configure CXXFLAGS="-fPIC -std=c++11" # -fPIC is needed for python cpp test.
# See python/setup.py for more details
make -j4
make -j$(nproc)
}
build_cpp() {
internal_build_cpp
make check -j4 || (cat src/test-suite.log; false)
make check -j$(nproc) || (cat src/test-suite.log; false)
cd conformance && make test_cpp && cd ..
# The benchmark code depends on cmake, so test if it is installed before
......@@ -77,7 +77,7 @@ build_cpp_distcheck() {
fi
# Do the regular dist-check for C++.
make distcheck -j4
make distcheck -j$(nproc)
}
build_csharp() {
......
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