Unverified Commit a66423f0 authored by Paul Yang's avatar Paul Yang Committed by GitHub

Make c extension portable for php 7.4 (#6968)

* Make c extension portable for php 7.4

* Fix conformance tests

* Fix comments

* Fix 32-bit

* Update conformance failure list

* Fix compiler warnings

* Cleanup configure created by phpize
The file created in php 7.4 is not recognizable by previous versions

* Fix conformance tests for 64-bit php

* Fix conformance test

* Fix compile warning

* Fix compile warnings
parent 0425fa93
......@@ -353,8 +353,8 @@ test_php: protoc_middleman conformance-test-runner conformance-php $(other_langu
test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
test_php_zts_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
test_php_c_32: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c_32.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
# These depend on library paths being properly set up. The easiest way to
# run them is to just use "tox" from the python dir.
......
......@@ -64,7 +64,6 @@ Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOu
Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.FloatFieldTooLarge
Required.Proto3.JsonInput.FloatFieldTooSmall
Required.Proto3.JsonInput.Int32FieldLeadingSpace
Required.Proto3.JsonInput.Int32FieldNotInteger
Required.Proto3.JsonInput.Int64FieldNotInteger
Required.Proto3.JsonInput.OneofFieldDuplicate
......
......@@ -18,33 +18,63 @@ Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator
Recommended.Proto3.ProtobufInput.OneofZeroBytes.JsonOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[3].ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[4].ProtobufOutput
Required.DurationProtoInputTooLarge.JsonOutput
......@@ -67,6 +97,7 @@ Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
Required.Proto3.ProtobufInput.ValidDataOneof.BYTES.DefaultValue.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput
......@@ -76,34 +107,3 @@ Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[2].JsonOutput
Required.TimestampProtoInputTooLarge.JsonOutput
Required.TimestampProtoInputTooSmall.JsonOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataOneof.BYTES.DefaultValue.JsonOutput
This diff is collapsed.
This diff is collapsed.
......@@ -73,7 +73,6 @@ static int repeated_field_array_init(zval *array, upb_fieldtype_t type,
uint size ZEND_FILE_LINE_DC);
static void repeated_field_write_dimension(zval *object, zval *offset,
zval *value TSRMLS_DC);
static int repeated_field_has_dimension(zval *object, zval *offset TSRMLS_DC);
static HashTable *repeated_field_get_gc(zval *object, CACHED_VALUE **table,
int *n TSRMLS_DC);
#if PHP_MAJOR_VERSION < 7
......@@ -102,7 +101,7 @@ php_proto_zval_ptr_dtor(&intern->array);
#endif
PHP_PROTO_OBJECT_FREE_END
PHP_PROTO_OBJECT_DTOR_START(RepeatedField, repeated_field)
PHP_PROTO_OBJECT_EMPTY_DTOR_START(RepeatedField, repeated_field)
PHP_PROTO_OBJECT_DTOR_END
// Define object create method.
......@@ -488,10 +487,10 @@ PHP_METHOD(RepeatedField, getIterator) {
// -----------------------------------------------------------------------------
// Define object free method.
PHP_PROTO_OBJECT_FREE_START(RepeatedFieldIter, repeated_field_iter)
PHP_PROTO_OBJECT_EMPTY_FREE_START(RepeatedFieldIter, repeated_field_iter)
PHP_PROTO_OBJECT_FREE_END
PHP_PROTO_OBJECT_DTOR_START(RepeatedFieldIter, repeated_field_iter)
PHP_PROTO_OBJECT_EMPTY_DTOR_START(RepeatedFieldIter, repeated_field_iter)
PHP_PROTO_OBJECT_DTOR_END
// Define object create method.
......@@ -519,7 +518,7 @@ PHP_METHOD(RepeatedFieldIter, current) {
RepeatedFieldIter *intern = UNBOX(RepeatedFieldIter, getThis());
RepeatedField *repeated_field = intern->repeated_field;
long index;
long index = 0;
void *memory;
HashTable *table = PHP_PROTO_HASH_OF(repeated_field->array);
......@@ -527,13 +526,13 @@ PHP_METHOD(RepeatedFieldIter, current) {
if (repeated_field->type == UPB_TYPE_MESSAGE) {
if (php_proto_zend_hash_index_find_zval(table, intern->position,
(void **)&memory) == FAILURE) {
zend_error(E_USER_ERROR, "Element at %d doesn't exist.\n", index);
zend_error(E_USER_ERROR, "Element at %ld doesn't exist.\n", index);
return;
}
} else {
if (php_proto_zend_hash_index_find_mem(table, intern->position,
(void **)&memory) == FAILURE) {
zend_error(E_USER_ERROR, "Element at %d doesn't exist.\n", index);
zend_error(E_USER_ERROR, "Element at %ld doesn't exist.\n", index);
return;
}
}
......
......@@ -69,31 +69,6 @@ static void check_upb_status(const upb_status* status, const char* msg) {
}
}
// Camel-case the field name and append "Entry" for generated map entry name.
// e.g. map<KeyType, ValueType> foo_map => FooMapEntry
static void append_map_entry_name(char *result, const char *field_name,
int pos) {
bool cap_next = true;
int i;
for (i = 0; i < strlen(field_name); ++i) {
if (field_name[i] == '_') {
cap_next = true;
} else if (cap_next) {
// Note: Do not use ctype.h due to locales.
if ('a' <= field_name[i] && field_name[i] <= 'z') {
result[pos++] = field_name[i] - 'a' + 'A';
} else {
result[pos++] = field_name[i];
}
cap_next = false;
} else {
result[pos++] = field_name[i];
}
}
strcat(result, "Entry");
}
// -----------------------------------------------------------------------------
// GPBType
// -----------------------------------------------------------------------------
......@@ -682,29 +657,6 @@ static void descriptor_pool_init_c_instance(DescriptorPool *pool TSRMLS_DC) {
static void descriptor_pool_free_c(DescriptorPool *pool TSRMLS_DC) {
}
static void validate_enumdef(const upb_enumdef *enumdef) {
// Verify that an entry exists with integer value 0. (This is the default
// value.)
const char *lookup = upb_enumdef_iton(enumdef, 0);
if (lookup == NULL) {
zend_error(E_USER_ERROR,
"Enum definition does not contain a value for '0'.");
}
}
static void validate_msgdef(const upb_msgdef* msgdef) {
// Verify that no required fields exist. proto3 does not support these.
upb_msg_field_iter it;
for (upb_msg_field_begin(&it, msgdef);
!upb_msg_field_done(&it);
upb_msg_field_next(&it)) {
const upb_fielddef* field = upb_msg_iter_field(&it);
if (upb_fielddef_label(field) == UPB_LABEL_REQUIRED) {
zend_error(E_ERROR, "Required fields are unsupported in proto3.");
}
}
}
PHP_METHOD(DescriptorPool, getGeneratedPool) {
init_generated_pool_once(TSRMLS_C);
#if PHP_MAJOR_VERSION < 7
......@@ -725,58 +677,6 @@ PHP_METHOD(InternalDescriptorPool, getGeneratedPool) {
#endif
}
static size_t classname_len_max(const char *fullname,
const char *package,
const char *php_namespace,
const char *prefix) {
size_t fullname_len = strlen(fullname);
size_t package_len = 0;
size_t prefix_len = 0;
size_t namespace_len = 0;
size_t length = fullname_len;
int i, segment, classname_start = 0;
if (package != NULL) {
package_len = strlen(package);
}
if (prefix != NULL) {
prefix_len = strlen(prefix);
}
if (php_namespace != NULL) {
namespace_len = strlen(php_namespace);
}
// Process package
if (package_len > 0) {
segment = 1;
for (i = 0; i < package_len; i++) {
if (package[i] == '.') {
segment++;
}
}
// In case of reserved name in package.
length += 3 * segment;
classname_start = package_len + 1;
}
// Process class name
segment = 1;
for (i = classname_start; i < fullname_len; i++) {
if (fullname[i] == '.') {
segment++;
}
}
if (prefix_len == 0) {
length += 3 * segment;
} else {
length += prefix_len * segment;
}
// The additional 2, one is for preceding '.' and the other is for trailing 0.
return length + namespace_len + 2;
}
static bool is_reserved(const char *segment, int length) {
bool result;
char* lower = ALLOC_N(char, length + 1);
......@@ -797,8 +697,6 @@ static void fill_prefix(const char *segment, int length,
const char *prefix_given,
const char *package_name,
stringsink *classname) {
size_t i;
if (prefix_given != NULL && strcmp(prefix_given, "") != 0) {
stringsink_string(classname, NULL, prefix_given,
strlen(prefix_given), NULL);
......@@ -834,7 +732,7 @@ static void fill_namespace(const char *package, const char *php_namespace,
stringsink_string(classname, NULL, "\\", 1, NULL);
}
} else if (package != NULL) {
int i = 0, j, offset = 0;
int i = 0, j = 0;
size_t package_len = strlen(package);
while (i < package_len) {
j = i;
......@@ -868,7 +766,7 @@ static void fill_classname(const char *fullname,
while (j < fullname_len && fullname[j] != '.') {
j++;
}
if (use_nested_submsg || is_first_segment && j == fullname_len) {
if (use_nested_submsg || (is_first_segment && j == fullname_len)) {
fill_prefix(fullname + i, j - i, prefix, package, classname);
}
is_first_segment = false;
......@@ -907,9 +805,6 @@ static void fill_classname_for_desc(void *desc, bool is_enum) {
const char *package = upb_filedef_package(file);
const char *php_namespace = upb_filedef_phpnamespace(file);
const char *prefix = upb_filedef_phpprefix(file);
size_t classname_len =
classname_len_max(fullname, package, php_namespace, prefix);
char* after_package;
stringsink namesink;
stringsink_init(&namesink);
......@@ -958,7 +853,7 @@ void register_class(void *desc, bool is_enum TSRMLS_DC) {
zend_error(
E_ERROR,
"Generated message class %s hasn't been defined (%s)",
classname);
classname, fullname);
return;
}
ret = PHP_PROTO_CE_UNREF(pce);
......@@ -1107,9 +1002,7 @@ void internal_add_generated_file(const char *data, PHP_PROTO_SIZE data_len,
PHP_METHOD(InternalDescriptorPool, internalAddGeneratedFile) {
char *data = NULL;
PHP_PROTO_SIZE data_len;
upb_filedef **files;
zend_bool use_nested_submsg = false;
size_t i;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b",
&data, &data_len, &use_nested_submsg) ==
......
......@@ -333,25 +333,6 @@ DEFINE_SINGULAR_HANDLER(double, double)
#undef DEFINE_SINGULAR_HANDLER
#if PHP_MAJOR_VERSION < 7
static void *empty_php_string(zval** value_ptr) {
SEPARATE_ZVAL_IF_NOT_REF(value_ptr);
if (Z_TYPE_PP(value_ptr) == IS_STRING &&
!IS_INTERNED(Z_STRVAL_PP(value_ptr))) {
FREE(Z_STRVAL_PP(value_ptr));
}
ZVAL_EMPTY_STRING(*value_ptr);
return (void*)(*value_ptr);
}
#else
static void *empty_php_string(zval* value_ptr) {
if (Z_TYPE_P(value_ptr) == IS_STRING) {
zend_string_release(Z_STR_P(value_ptr));
}
ZVAL_EMPTY_STRING(value_ptr);
return value_ptr;
}
#endif
#if PHP_MAJOR_VERSION < 7
static void new_php_string(zval** value_ptr, const char* str, size_t len) {
SEPARATE_ZVAL_IF_NOT_REF(value_ptr);
......@@ -830,7 +811,6 @@ static map_handlerdata_t* new_map_handlerdata(
static bool oneof##type##_handler(void* closure, const void* hd, \
ctype val) { \
const oneof_handlerdata_t* oneofdata = hd; \
MessageHeader* msg = (MessageHeader*)closure; \
DEREF(message_data(closure), oneofdata->case_ofs, uint32_t) = \
oneofdata->oneof_case_num; \
DEREF(message_data(closure), oneofdata->ofs, ctype) = val; \
......@@ -886,22 +866,6 @@ static void oneof_cleanup(MessageHeader* msg,
}
// Handlers for string/bytes in a oneof.
static void *oneofbytes_handler(void *closure,
const void *hd,
size_t size_hint) {
MessageHeader* msg = closure;
const oneof_handlerdata_t *oneofdata = hd;
oneof_cleanup(msg, oneofdata);
DEREF(message_data(msg), oneofdata->case_ofs, uint32_t) =
oneofdata->oneof_case_num;
DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) =
OBJ_PROP(&msg->std, oneofdata->property_ofs);
return empty_php_string(DEREF(
message_data(msg), oneofdata->ofs, CACHED_VALUE*));
}
static bool oneofstr_end_handler(void *closure, const void *hd) {
stringfields_parseframe_t* frame = closure;
MessageHeader* msg = (MessageHeader*)frame->closure;
......@@ -984,7 +948,6 @@ static void* wrapper_submsg_handler(void* closure, const void* hd) {
TSRMLS_FETCH();
DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md);
register_class(subdesc, false TSRMLS_CC);
zend_class_entry* subklass = subdesc->klass;
zval* submsg_php;
MessageHeader* submsg;
wrapperfields_parseframe_t* frame =
......@@ -1022,7 +985,6 @@ static void* wrapper_oneofsubmsg_handler(void* closure, const void* hd) {
TSRMLS_FETCH();
DescriptorInternal* subdesc = get_msgdef_desc(oneofdata->md);
register_class(subdesc, false TSRMLS_CC);
zend_class_entry* subklass = subdesc->klass;
wrapperfields_parseframe_t* frame =
(wrapperfields_parseframe_t*)malloc(sizeof(wrapperfields_parseframe_t));
CACHED_VALUE* cached = OBJ_PROP(&msg->std, oneofdata->property_ofs);
......@@ -1688,11 +1650,10 @@ static void putjsonlistvalue(
upb_status status;
upb_sink subsink;
const upb_fielddef* f = upb_msgdef_itof(desc->msgdef, 1);
uint32_t offset = desc->layout->fields[upb_fielddef_index(f)].offset;
zval* array;
RepeatedField* intern;
HashTable *ht;
int size, i;
int size;
upb_sink_startmsg(sink);
......@@ -1722,7 +1683,6 @@ static void putjsonstruct(
upb_status status;
upb_sink subsink;
const upb_fielddef* f = upb_msgdef_itof(desc->msgdef, 1);
uint32_t offset = desc->layout->fields[upb_fielddef_index(f)].offset;
zval* map;
Map* intern;
int size;
......@@ -2247,8 +2207,6 @@ static void discard_unknown_fields(MessageHeader* msg) {
!upb_msg_field_done(&it);
upb_msg_field_next(&it)) {
upb_fielddef* f = upb_msg_iter_field(&it);
uint32_t offset = desc->layout->fields[upb_fielddef_index(f)].offset;
bool containing_oneof = false;
if (upb_fielddef_containingoneof(f)) {
uint32_t oneof_case_offset =
......@@ -2261,12 +2219,11 @@ static void discard_unknown_fields(MessageHeader* msg) {
}
// Otherwise, fall through to the appropriate singular-field handler
// below.
containing_oneof = true;
}
if (is_map_field(f)) {
MapIter map_it;
int len, size;
int len;
const upb_fielddef* value_field;
value_field = map_field_value(f);
......@@ -2275,7 +2232,6 @@ static void discard_unknown_fields(MessageHeader* msg) {
zval* map_php = CACHED_PTR_TO_ZVAL_PTR(find_zval_property(msg, f));
if (ZVAL_IS_NULL(map_php)) continue;
Map* intern = UNBOX(Map, map_php);
for (map_begin(map_php, &map_it TSRMLS_CC);
!map_done(&map_it); map_next(&map_it)) {
upb_value value = map_iter_value(&map_it, &len);
......
......@@ -222,7 +222,7 @@ for (map_begin_internal(intern, &it); !map_done(&it); map_next(&it)) {
upb_strtable_uninit(&intern->table);
PHP_PROTO_OBJECT_FREE_END
PHP_PROTO_OBJECT_DTOR_START(Map, map_field)
PHP_PROTO_OBJECT_EMPTY_DTOR_START(Map, map_field)
PHP_PROTO_OBJECT_DTOR_END
// Define object create method.
......@@ -383,7 +383,6 @@ static bool map_field_unset_dimension(zval *object, zval *key TSRMLS_DC) {
char keybuf[TABLE_KEY_BUF_LENGTH];
const char* keyval = NULL;
size_t length = 0;
upb_value v;
if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
return false;
}
......@@ -454,7 +453,7 @@ PHP_METHOD(MapField, offsetExists) {
}
PHP_METHOD(MapField, offsetGet) {
zval *index, *value;
zval *index;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) ==
FAILURE) {
return;
......@@ -495,7 +494,6 @@ PHP_METHOD(MapField, getIterator) {
CREATE_OBJ_ON_ALLOCATED_ZVAL_PTR(return_value,
map_field_iter_type);
Map *intern = UNBOX(Map, getThis());
MapIter *iter = UNBOX(MapIter, return_value);
map_begin(getThis(), iter TSRMLS_CC);
}
......@@ -544,10 +542,10 @@ static zend_function_entry map_field_iter_methods[] = {
// -----------------------------------------------------------------------------
// Define object free method.
PHP_PROTO_OBJECT_FREE_START(MapIter, map_field_iter)
PHP_PROTO_OBJECT_EMPTY_FREE_START(MapIter, map_field_iter)
PHP_PROTO_OBJECT_FREE_END
PHP_PROTO_OBJECT_DTOR_START(MapIter, map_field_iter)
PHP_PROTO_OBJECT_EMPTY_DTOR_START(MapIter, map_field_iter)
PHP_PROTO_OBJECT_DTOR_END
// Define object create method.
......
This diff is collapsed.
......@@ -63,8 +63,6 @@ upb_strtable reserved_names;
// -----------------------------------------------------------------------------
static void add_to_table(HashTable* t, const void* def, void* value) {
uint nIndex = (ulong)def & t->nTableMask;
zval* pDest = NULL;
php_proto_zend_hash_index_update_mem(t, (zend_ulong)def, &value,
sizeof(zval*), (void**)&pDest);
......@@ -79,28 +77,6 @@ static void* get_from_table(const HashTable* t, const void* def) {
return *value;
}
static bool exist_in_table(const HashTable* t, const void* def) {
void** value;
return (php_proto_zend_hash_index_find_mem(t, (zend_ulong)def,
(void**)&value) == SUCCESS);
}
static void add_to_strtable(HashTable* t, const char* key, int key_size,
void* value) {
zval* pDest = NULL;
php_proto_zend_hash_update_mem(t, key, key_size, &value, sizeof(void*),
(void**)&pDest);
}
static void* get_from_strtable(const HashTable* t, const char* key, int key_size) {
void** value;
if (php_proto_zend_hash_find_mem(t, key, key_size, (void**)&value) ==
FAILURE) {
return NULL;
}
return *value;
}
void add_def_obj(const void* def, PHP_PROTO_HASHTABLE_VALUE value) {
#if PHP_MAJOR_VERSION < 7
Z_ADDREF_P(value);
......@@ -349,13 +325,9 @@ static void php_proto_hashtable_descriptor_release(zval* value) {
}
efree(ptr);
}
static void test_release(void* value) {
void* ptr = value;
}
#endif
static initialize_persistent_descriptor_pool(TSRMLS_D) {
static void initialize_persistent_descriptor_pool(TSRMLS_D) {
upb_inttable_init(&upb_def_to_desc_map_persistent, UPB_CTYPE_PTR);
upb_inttable_init(&upb_def_to_enumdesc_map_persistent, UPB_CTYPE_PTR);
upb_inttable_init(&ce_to_desc_map_persistent, UPB_CTYPE_PTR);
......@@ -427,7 +399,7 @@ static void cleanup_enumdesc_table(upb_inttable* t) {
}
}
static cleanup_persistent_descriptor_pool(TSRMLS_D) {
static void cleanup_persistent_descriptor_pool(TSRMLS_D) {
// Clean up
// Only needs to clean one map out of three (def=>desc, ce=>desc, proto=>desc)
......@@ -482,10 +454,7 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) {
static void reserved_names_init() {
size_t i;
upb_value v;
#ifndef NDEBUG
v.ctype = UPB_CTYPE_UINT64;
#endif
upb_value v = upb_value_bool(false);
for (i = 0; i < kReservedNamesSize; i++) {
upb_strtable_insert2(&reserved_names, kReservedNames[i],
strlen(kReservedNames[i]), v);
......
......@@ -143,7 +143,6 @@
#define PHP_PROTO_INIT_SUBMSGCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
void LOWWERNAME##_init(TSRMLS_D) { \
zend_class_entry class_type; \
const char* class_name = CLASSNAME; \
INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
LOWWERNAME##_methods); \
LOWWERNAME##_type = zend_register_internal_class_ex( \
......@@ -156,7 +155,6 @@
#define PHP_PROTO_INIT_ENUMCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
void LOWWERNAME##_init(TSRMLS_D) { \
zend_class_entry class_type; \
const char* class_name = CLASSNAME; \
INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
LOWWERNAME##_methods); \
LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC);
......@@ -166,7 +164,6 @@
#define PHP_PROTO_INIT_CLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
void LOWWERNAME##_init(TSRMLS_D) { \
zend_class_entry class_type; \
const char* class_name = CLASSNAME; \
INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
LOWWERNAME##_methods); \
LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \
......@@ -187,6 +184,9 @@
PHP_PROTO_FREE_CLASS_OBJECT(NAME, LOWWERNAME##_free, LOWWERNAME##_handlers); \
}
#define PHP_PROTO_OBJECT_EMPTY_FREE_START(classname, lowername) \
void lowername##_free(void* object TSRMLS_DC) { \
classname* intern = object;
#define PHP_PROTO_OBJECT_FREE_START(classname, lowername) \
void lowername##_free(void* object TSRMLS_DC) { \
classname* intern = object;
......@@ -195,6 +195,7 @@
efree(intern); \
}
#define PHP_PROTO_OBJECT_EMPTY_DTOR_START(classname, lowername)
#define PHP_PROTO_OBJECT_DTOR_START(classname, lowername)
#define PHP_PROTO_OBJECT_DTOR_END
......@@ -410,32 +411,28 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht,
zend_object std; \
};
#define PHP_PROTO_INIT_SUBMSGCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
void LOWWERNAME##_init(TSRMLS_D) { \
zend_class_entry class_type; \
const char* class_name = CLASSNAME; \
INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
LOWWERNAME##_methods); \
LOWWERNAME##_type = zend_register_internal_class_ex( \
&class_type, message_type TSRMLS_CC); \
zend_do_inheritance(LOWWERNAME##_type, message_type TSRMLS_CC);
#define PHP_PROTO_INIT_SUBMSGCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
void LOWWERNAME##_init(TSRMLS_D) { \
zend_class_entry class_type; \
INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
LOWWERNAME##_methods); \
LOWWERNAME##_type = zend_register_internal_class(&class_type); \
zend_do_inheritance(LOWWERNAME##_type, message_type);
#define PHP_PROTO_INIT_SUBMSGCLASS_END \
}
#define PHP_PROTO_INIT_ENUMCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
void LOWWERNAME##_init(TSRMLS_D) { \
zend_class_entry class_type; \
const char* class_name = CLASSNAME; \
INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
LOWWERNAME##_methods); \
LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC);
LOWWERNAME##_type = zend_register_internal_class(&class_type);
#define PHP_PROTO_INIT_ENUMCLASS_END \
}
#define PHP_PROTO_INIT_CLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
void LOWWERNAME##_init(TSRMLS_D) { \
zend_class_entry class_type; \
const char* class_name = CLASSNAME; \
INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
LOWWERNAME##_methods); \
LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \
......@@ -449,6 +446,8 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht,
#define PHP_PROTO_INIT_CLASS_END \
}
#define PHP_PROTO_OBJECT_EMPTY_FREE_START(classname, lowername) \
void lowername##_free(zend_object* object) {
#define PHP_PROTO_OBJECT_FREE_START(classname, lowername) \
void lowername##_free(zend_object* object) { \
classname* intern = \
......@@ -456,6 +455,8 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht,
#define PHP_PROTO_OBJECT_FREE_END \
}
#define PHP_PROTO_OBJECT_EMPTY_DTOR_START(classname, lowername) \
void lowername##_dtor(zend_object* object) {
#define PHP_PROTO_OBJECT_DTOR_START(classname, lowername) \
void lowername##_dtor(zend_object* object) { \
classname* intern = \
......@@ -569,8 +570,8 @@ static inline int php_proto_zend_lookup_class(
LOWERNAME##_free_c(intern TSRMLS_CC); \
PHP_PROTO_OBJECT_FREE_END
#define DEFINE_PROTOBUF_DTOR(CAMELNAME, LOWERNAME) \
PHP_PROTO_OBJECT_DTOR_START(CAMELNAME, LOWERNAME) \
#define DEFINE_PROTOBUF_DTOR(CAMELNAME, LOWERNAME) \
PHP_PROTO_OBJECT_EMPTY_DTOR_START(CAMELNAME, LOWERNAME) \
PHP_PROTO_OBJECT_DTOR_END
#define DEFINE_CLASS(NAME, LOWERNAME, string_name) \
......
......@@ -100,8 +100,10 @@ bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass,
if (EXPECTED(cached_zval != NULL)) {
#if PHP_MAJOR_VERSION < 7
REPLACE_ZVAL_VALUE((zval**)memory, value, 1);
#else
#elif PHP_VERSION_ID < 70400
zend_assign_to_variable(cached_zval, value, IS_CV);
#else
zend_assign_to_variable(cached_zval, value, IS_CV, 0);
#endif
}
break;
......@@ -272,7 +274,6 @@ bool native_slot_set_by_map(upb_fieldtype_t type, const zend_class_entry* klass,
}
void native_slot_init(upb_fieldtype_t type, void* memory, CACHED_VALUE* cache) {
zval* tmp = NULL;
switch (type) {
case UPB_TYPE_FLOAT:
DEREF(memory, float) = 0.0;
......@@ -577,11 +578,6 @@ uint32_t* slot_oneof_case(MessageLayout* layout, const void* storage,
layout->fields[upb_fielddef_index(field)].case_offset);
}
static int slot_property_cache(MessageLayout* layout, const void* storage,
const upb_fielddef* field) {
return layout->fields[upb_fielddef_index(field)].cache_index;
}
void* slot_memory(MessageLayout* layout, const void* storage,
const upb_fielddef* field) {
return ((uint8_t*)storage) + layout->fields[upb_fielddef_index(field)].offset;
......@@ -998,7 +994,6 @@ static void native_slot_merge_by_array(const upb_fielddef* field, const void* fr
break;
}
case UPB_TYPE_MESSAGE: {
const upb_msgdef* msg = upb_fielddef_msgsubdef(field);
DescriptorInternal* desc = get_msgdef_desc(upb_fielddef_msgsubdef(field));
register_class(desc, false TSRMLS_CC);
zend_class_entry* ce = desc->klass;
......@@ -1168,7 +1163,7 @@ void layout_merge(MessageLayout* layout, MessageHeader* from,
const char* layout_get_oneof_case(MessageLayout* layout, const void* storage,
const upb_oneofdef* oneof TSRMLS_DC) {
upb_oneof_iter i;
const upb_fielddef* first_field;
const upb_fielddef* first_field = NULL;
// Oneof is guaranteed to have at least one field. Get the first field.
for(upb_oneof_begin(&i, oneof); !upb_oneof_done(&i); upb_oneof_next(&i)) {
......
......@@ -407,8 +407,6 @@ bool protobuf_convert_to_bool(zval* from, int8_t* to) {
*to = (int8_t)(Z_LVAL_P(from) != 0);
break;
case IS_STRING: {
char* strval = Z_STRVAL_P(from);
if (Z_STRLEN_P(from) == 0 ||
(Z_STRLEN_P(from) == 1 && Z_STRVAL_P(from)[0] == '0')) {
*to = 0;
......@@ -496,7 +494,11 @@ PHP_METHOD(Util, checkMessage) {
if (!instanceof_function(Z_OBJCE_P(val), klass TSRMLS_CC)) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Given value is not an instance of %s.",
#if PHP_MAJOR_VERSION < 7
klass->name);
#else
ZSTR_VAL(klass->name));
#endif
return;
}
RETURN_ZVAL(val, 1, 0);
......@@ -541,7 +543,11 @@ void check_repeated_field(const zend_class_entry* klass, PHP_PROTO_LONG type,
if (!instanceof_function(Z_OBJCE_P(val), repeated_field_type TSRMLS_CC)) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Given value is not an instance of %s.",
#if PHP_MAJOR_VERSION < 7
repeated_field_type->name);
#else
ZSTR_VAL(repeated_field_type->name));
#endif
return;
}
RepeatedField* intern = UNBOX(RepeatedField, val);
......@@ -553,7 +559,12 @@ void check_repeated_field(const zend_class_entry* klass, PHP_PROTO_LONG type,
if (klass != NULL && intern->msg_ce != klass) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Expect a repeated field of %s, but %s is given.",
#if PHP_MAJOR_VERSION < 7
klass->name, intern->msg_ce->name);
#else
ZSTR_VAL(klass->name),
ZSTR_VAL(intern->msg_ce->name));
#endif
return;
}
RETURN_ZVAL(val, 1, 0);
......@@ -617,7 +628,11 @@ void check_map_field(const zend_class_entry* klass, PHP_PROTO_LONG key_type,
if (!instanceof_function(Z_OBJCE_P(val), map_field_type TSRMLS_CC)) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Given value is not an instance of %s.",
#if PHP_MAJOR_VERSION < 7
map_field_type->name);
#else
ZSTR_VAL(map_field_type->name));
#endif
return;
}
Map* intern = UNBOX(Map, val);
......@@ -636,7 +651,12 @@ void check_map_field(const zend_class_entry* klass, PHP_PROTO_LONG key_type,
if (klass != NULL && intern->msg_ce != klass) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Expect a map field of %s, but %s is given.",
#if PHP_MAJOR_VERSION < 7
klass->name, intern->msg_ce->name);
#else
ZSTR_VAL(klass->name),
ZSTR_VAL(intern->msg_ce->name));
#endif
return;
}
RETURN_ZVAL(val, 1, 0);
......
......@@ -933,6 +933,10 @@ class Message
throw new GPBDecodeException(
"Invalid data type for int32 field");
}
if (is_string($value) && trim($value) !== $value) {
throw new GPBDecodeException(
"Invalid data type for int32 field");
}
if (bccomp($value, "2147483647") > 0) {
throw new GPBDecodeException(
"Int32 too large");
......@@ -951,6 +955,10 @@ class Message
throw new GPBDecodeException(
"Invalid data type for uint32 field");
}
if (is_string($value) && trim($value) !== $value) {
throw new GPBDecodeException(
"Invalid data type for int32 field");
}
if (bccomp($value, 4294967295) > 0) {
throw new GPBDecodeException(
"Uint32 too large");
......@@ -966,6 +974,10 @@ class Message
throw new GPBDecodeException(
"Invalid data type for int64 field");
}
if (is_string($value) && trim($value) !== $value) {
throw new GPBDecodeException(
"Invalid data type for int64 field");
}
if (bccomp($value, "9223372036854775807") > 0) {
throw new GPBDecodeException(
"Int64 too large");
......@@ -984,6 +996,10 @@ class Message
throw new GPBDecodeException(
"Invalid data type for int64 field");
}
if (is_string($value) && trim($value) !== $value) {
throw new GPBDecodeException(
"Invalid data type for int64 field");
}
if (bccomp($value, "18446744073709551615") > 0) {
throw new GPBDecodeException(
"Uint64 too large");
......
......@@ -6,5 +6,5 @@ pushd $EXTENSION_PATH
make clean || true
set -e
# Add following in configure for debug: --enable-debug CFLAGS='-g -O0'
phpize && ./configure CFLAGS='-g -O0' && make
phpize && ./configure CFLAGS='-g -O0 -Wall' && make
popd
......@@ -514,14 +514,19 @@ build_php5.5() {
}
build_php5.5_c() {
IS_64BIT=$1
use_php 5.5
pushd php/tests
/bin/bash ./test.sh 5.5
popd
# TODO(teboring): Add it back
# pushd conformance
# make test_php_c
# popd
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
make test_php_c
else
make test_php_c_32
fi
popd
}
build_php5.5_mixed() {
......@@ -535,12 +540,17 @@ build_php5.5_mixed() {
}
build_php5.5_zts_c() {
IS_64BIT=$1
use_php_zts 5.5
cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../..
# TODO(teboring): Add it back
# pushd conformance
# make test_php_zts_c
# popd
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
make test_php_c
else
make test_php_c_32
fi
popd
}
build_php5.6() {
......@@ -556,12 +566,17 @@ build_php5.6() {
}
build_php5.6_c() {
IS_64BIT=$1
use_php 5.6
cd php/tests && /bin/bash ./test.sh 5.6 && cd ../..
# TODO(teboring): Add it back
# pushd conformance
# make test_php_c
# popd
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
make test_php_c
else
make test_php_c_32
fi
popd
}
build_php5.6_mixed() {
......@@ -575,12 +590,17 @@ build_php5.6_mixed() {
}
build_php5.6_zts_c() {
IS_64BIT=$1
use_php_zts 5.6
cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../..
# TODO(teboring): Add it back
# pushd conformance
# make test_php_zts_c
# popd
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
make test_php_c
else
make test_php_c_32
fi
popd
}
build_php5.6_mac() {
......@@ -602,10 +622,9 @@ build_php5.6_mac() {
# Test
cd php/tests && /bin/bash ./test.sh && cd ../..
# TODO(teboring): Add it back
# pushd conformance
# make test_php_c
# popd
pushd conformance
make test_php_c
popd
}
build_php7.0() {
......@@ -621,12 +640,17 @@ build_php7.0() {
}
build_php7.0_c() {
IS_64BIT=$1
use_php 7.0
cd php/tests && /bin/bash ./test.sh 7.0 && cd ../..
# TODO(teboring): Add it back
# pushd conformance
# make test_php_c
# popd
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
make test_php_c
else
make test_php_c_32
fi
popd
}
build_php7.0_mixed() {
......@@ -640,12 +664,17 @@ build_php7.0_mixed() {
}
build_php7.0_zts_c() {
IS_64BIT=$1
use_php_zts 7.0
cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../..
# TODO(teboring): Add it back.
# pushd conformance
# make test_php_zts_c
# popd
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
make test_php_c
else
make test_php_c_32
fi
popd
}
build_php7.0_mac() {
......@@ -667,10 +696,9 @@ build_php7.0_mac() {
# Test
cd php/tests && /bin/bash ./test.sh && cd ../..
# TODO(teboring): Add it back
# pushd conformance
# make test_php_c
# popd
pushd conformance
make test_php_c
popd
}
build_php_compatibility() {
......@@ -691,15 +719,17 @@ build_php7.1() {
}
build_php7.1_c() {
ENABLE_CONFORMANCE_TEST=$1
IS_64BIT=$1
use_php 7.1
cd php/tests && /bin/bash ./test.sh 7.1 && cd ../..
if [ "$ENABLE_CONFORMANCE_TEST" = "true" ]
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
pushd conformance
make test_php_c
popd
else
make test_php_c_32
fi
popd
}
build_php7.1_mixed() {
......@@ -713,10 +743,75 @@ build_php7.1_mixed() {
}
build_php7.1_zts_c() {
IS_64BIT=$1
use_php_zts 7.1
cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../..
pushd conformance
# make test_php_c
if [ "$IS_64BIT" = "true" ]
then
make test_php_c
else
make test_php_c_32
fi
popd
}
build_php7.4() {
use_php 7.4
pushd php
rm -rf vendor
composer update
./vendor/bin/phpunit
popd
pushd conformance
make test_php
popd
}
build_php7.4_c() {
IS_64BIT=$1
use_php 7.4
cd php/tests && /bin/bash ./test.sh 7.4 && cd ../..
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
make test_php_c
else
make test_php_c_32
fi
popd
pushd php/ext/google/protobuf
phpize --clean
popd
}
build_php7.4_mixed() {
use_php 7.4
pushd php
rm -rf vendor
composer update
/bin/bash ./tests/compile_extension.sh ./ext/google/protobuf
php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
popd
pushd php/ext/google/protobuf
phpize --clean
popd
}
build_php7.4_zts_c() {
IS_64BIT=$1
use_php_zts 7.4
cd php/tests && /bin/bash ./test.sh 7.4-zts && cd ../..
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
make test_php_c
else
make test_php_c_32
fi
popd
pushd php/ext/google/protobuf
phpize --clean
popd
}
......@@ -725,18 +820,22 @@ build_php_all_32() {
build_php5.6
build_php7.0
build_php7.1
build_php5.5_c
build_php5.6_c
build_php7.0_c
build_php7.4
build_php5.5_c $1
build_php5.6_c $1
build_php7.0_c $1
build_php7.1_c $1
build_php7.4_c $1
build_php5.5_mixed
build_php5.6_mixed
build_php7.0_mixed
build_php7.1_mixed
build_php5.5_zts_c
build_php5.6_zts_c
build_php7.0_zts_c
build_php7.1_zts_c
build_php7.4_mixed
build_php5.5_zts_c $1
build_php5.6_zts_c $1
build_php7.0_zts_c $1
build_php7.1_zts_c $1
build_php7.4_zts_c $1
}
build_php_all() {
......
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