Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge3.4 #3739

Merged
merged 31 commits into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
55fdbe5
Make distcheck aware of test proto files.
liujisi Aug 23, 2017
07de70e
Merge pull request #3555 from pherl/fixdist
liujisi Aug 23, 2017
78432ea
Remove pre-installed softwares
matt-kwong Aug 23, 2017
92ea0d2
Merge pull request #3556 from matt-kwong/kokoro_mac_v3
liujisi Aug 23, 2017
d8c6193
Add mising cmake files in dist
liujisi Aug 24, 2017
21b2372
Merge pull request #3565 from pherl/fixdist
liujisi Aug 24, 2017
2807436
change the field number of php_generic_service to fix the conflict wi…
TeBoring Aug 30, 2017
50a6475
Google.Protobuf should target net45
jtattermusch Sep 5, 2017
6a4ffb2
Merge pull request #3596 from jtattermusch/csharp_target_net45
jtattermusch Sep 7, 2017
e5d000c
Add prefix to php reserved keywords.
TeBoring Sep 8, 2017
89069de
Change array to associate array.
TeBoring Sep 11, 2017
ddb9ef9
Change array to map for reserved names in c extension
TeBoring Sep 11, 2017
f46a01d
Exclude valid constant name from reserved name.
TeBoring Sep 12, 2017
2bd55a9
Fix js conformance tests. (#3604)
TeBoring Sep 12, 2017
a425dd9
Rename ClassNamePrefix to ConstantNamePrefix
TeBoring Sep 13, 2017
8741da3
Revert "Fix js conformance tests. (#3604)" (#3633)
TeBoring Sep 13, 2017
c1dd8e8
Move parse frame array to the Map object
tenderlove Aug 24, 2017
a459b22
Storing the frame on the map means we don't need the array
tenderlove Aug 30, 2017
3d78561
Merge pull request #3634 from TeBoring/ruby-bug
TeBoring Sep 13, 2017
dba647a
Bump version for minor release
liujisi Sep 14, 2017
b04e5cb
Merge pull request #3642 from pherl/3.4.x
liujisi Sep 14, 2017
5dd818c
Merge pull request #3612 from TeBoring/php-bug
TeBoring Sep 15, 2017
2eb1bac
Bumping minor version for ruby gems
liujisi Sep 15, 2017
655cc83
Merge pull request #3651 from pherl/3.4.x
liujisi Sep 15, 2017
6d0cf1b
Remove ranged based for in io_win32.cc
liujisi Sep 27, 2017
5a501c6
Fix C++11 string accessors
liujisi Sep 27, 2017
d2738c0
Add spaces
liujisi Sep 27, 2017
a38f876
Merge pull request #3691 from pherl/stringback
liujisi Sep 29, 2017
bd798df
Merge pull request #3690 from pherl/3.4.x
liujisi Oct 2, 2017
de15e73
Merge remote-tracking branch 'origin/3.4.x' into master
liujisi Oct 11, 2017
dd980cc
Fix distcheck
liujisi Oct 11, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,9 @@ php_EXTRA_DIST= \
php/src/Google/Protobuf/Internal/EnumOptions.php \
php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \
php/src/Google/Protobuf/Internal/EnumValueOptions.php \
php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php \
php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \
php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably also need to add new files after running generate_descriptor_proto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The distcheck tests will probably catch other new files if there are any.

php/src/Google/Protobuf/Internal/FieldDescriptor.php \
php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \
php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \
Expand Down Expand Up @@ -732,6 +735,12 @@ php_EXTRA_DIST= \
php/tests/proto/test_no_namespace.proto \
php/tests/proto/test_php_namespace.proto \
php/tests/proto/test_prefix.proto \
php/tests/proto/test_reserved_enum_lower.proto \
php/tests/proto/test_reserved_enum_upper.proto \
php/tests/proto/test_reserved_enum_value_lower.proto \
php/tests/proto/test_reserved_enum_value_upper.proto \
php/tests/proto/test_reserved_message_lower.proto \
php/tests/proto/test_reserved_message_upper.proto \
php/tests/proto/test_service.proto \
php/tests/proto/test_service_namespace.proto \
php/tests/test.sh \
Expand Down Expand Up @@ -1025,8 +1034,10 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
cmake/libprotoc.cmake \
cmake/protobuf-config-version.cmake.in \
cmake/protobuf-config.cmake.in \
cmake/protobuf-lite.pc.cmake \
cmake/protobuf-module.cmake.in \
cmake/protobuf-options.cmake \
cmake/protobuf.pc.cmake \
cmake/protoc.cmake \
cmake/tests.cmake \
editors/README.txt \
Expand Down
2 changes: 1 addition & 1 deletion Protobuf.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
s.version = '3.4.0'
s.version = '3.4.1'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/google/protobuf'
s.license = '3-Clause BSD License'
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# In the SVN trunk, the version should always be the next anticipated release
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
# the size of one file name in the dist tarfile over the 99-char limit.)
AC_INIT([Protocol Buffers],[3.4.0],[protobuf@googlegroups.com],[protobuf])
AC_INIT([Protocol Buffers],[3.4.1],[protobuf@googlegroups.com],[protobuf])

AM_MAINTAINER_MODE([enable])

Expand Down
2 changes: 1 addition & 1 deletion csharp/Google.Protobuf.Tools.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
<version>3.4.0</version>
<version>3.4.1</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>
Expand Down
2 changes: 1 addition & 1 deletion csharp/src/Google.Protobuf/Google.Protobuf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.4.0</VersionPrefix>
<VersionPrefix>3.4.1</VersionPrefix>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.0;net45</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion java/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.4.0</version>
<version>3.4.1</version>
</parent>

<artifactId>protobuf-java</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.4.0</version>
<version>3.4.1</version>
<packaging>pom</packaging>

<name>Protocol Buffers [Parent]</name>
Expand Down
2 changes: 1 addition & 1 deletion java/util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.4.0</version>
<version>3.4.1</version>
</parent>

<artifactId>protobuf-java-util</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "google-protobuf",
"version": "3.4.0",
"version": "3.4.1",
"description": "Protocol Buffers for JavaScript",
"main": "google-protobuf.js",
"files": [
Expand Down
17 changes: 9 additions & 8 deletions php/ext/google/protobuf/def.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@

#include "protobuf.h"

const char* const kReservedNames[] = {"Empty", "ECHO", "ARRAY"};
const int kReservedNamesSize = 3;

// Forward declare.
static void descriptor_init_c_instance(Descriptor* intern TSRMLS_DC);
static void descriptor_free_c(Descriptor* object TSRMLS_DC);
Expand Down Expand Up @@ -747,12 +744,16 @@ static const char *classname_prefix(const char *classname,
return prefix_given;
}

for (i = 0; i < kReservedNamesSize; i++) {
if (strcmp(kReservedNames[i], classname) == 0) {
is_reserved = true;
break;
}
char* lower = ALLOC_N(char, strlen(classname) + 1);
i = 0;
while(classname[i]) {
lower[i] = (char)tolower(classname[i]);
i++;
}
lower[i] = 0;

is_reserved = is_reserved_name(lower);
FREE(lower);

if (is_reserved) {
if (package_name != NULL && strcmp("google.protobuf", package_name) == 0) {
Expand Down
24 changes: 20 additions & 4 deletions php/ext/google/protobuf/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<email>protobuf-opensource@google.com</email>
<active>yes</active>
</lead>
<date>2017-01-13</date>
<time>16:06:07</time>
<date>2017-09-14</date>
<time>11:02:07</time>
<version>
<release>3.4.0</release>
<api>3.4.0</api>
<release>3.4.1</release>
<api>3.4.1</api>
</version>
<stability>
<release>stable</release>
Expand Down Expand Up @@ -149,6 +149,22 @@ GA release.
<time>15:33:07</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>
GA release.
</notes>
</release>
<release>
<version>
<release>3.4.1</release>
<api>3.4.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2017-09-14</date>
<time>11:02:07</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>
GA release.
</notes>
</release>
Expand Down
43 changes: 43 additions & 0 deletions php/ext/google/protobuf/protobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static HashTable* ce_to_php_obj_map;
// Global map from message/enum's proto fully-qualified name to corresponding
// wrapper Descriptor/EnumDescriptor instances.
static HashTable* proto_to_php_obj_map;
static HashTable* reserved_names;

// -----------------------------------------------------------------------------
// Global maps.
Expand Down Expand Up @@ -143,6 +144,36 @@ PHP_PROTO_HASHTABLE_VALUE get_proto_obj(const char* proto) {
proto, strlen(proto));
}

// -----------------------------------------------------------------------------
// Reserved Name.
// -----------------------------------------------------------------------------

// Although we already have kReservedNames, we still add them to hash table to
// speed up look up.
const char *const kReservedNames[] = {
"abstract", "and", "array", "as", "break",
"callable", "case", "catch", "class", "clone",
"const", "continue", "declare", "default", "die",
"do", "echo", "else", "elseif", "empty",
"enddeclare", "endfor", "endforeach", "endif", "endswitch",
"endwhile", "eval", "exit", "extends", "final",
"for", "foreach", "function", "global", "goto",
"if", "implements", "include", "include_once", "instanceof",
"insteadof", "interface", "isset", "list", "namespace",
"new", "or", "print", "private", "protected",
"public", "require", "require_once", "return", "static",
"switch", "throw", "trait", "try", "unset",
"use", "var", "while", "xor", "int",
"float", "bool", "string", "true", "false",
"null", "void", "iterable"};
const int kReservedNamesSize = 73;

bool is_reserved_name(const char* name) {
void** value;
return (php_proto_zend_hash_find(reserved_names, name, strlen(name),
(void**)&value) == SUCCESS);
}

// -----------------------------------------------------------------------------
// Utilities.
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -190,6 +221,8 @@ static void php_proto_hashtable_descriptor_release(zval* value) {
#endif

static PHP_RINIT_FUNCTION(protobuf) {
int i = 0;

ALLOC_HASHTABLE(upb_def_to_php_obj_map);
zend_hash_init(upb_def_to_php_obj_map, 16, NULL, HASHTABLE_VALUE_DTOR, 0);

Expand All @@ -199,6 +232,13 @@ static PHP_RINIT_FUNCTION(protobuf) {
ALLOC_HASHTABLE(proto_to_php_obj_map);
zend_hash_init(proto_to_php_obj_map, 16, NULL, HASHTABLE_VALUE_DTOR, 0);

ALLOC_HASHTABLE(reserved_names);
zend_hash_init(reserved_names, 16, NULL, NULL, 0);
for (i = 0; i < kReservedNamesSize; i++) {
php_proto_zend_hash_update(reserved_names, kReservedNames[i],
strlen(kReservedNames[i]));
}

generated_pool = NULL;
generated_pool_php = NULL;
internal_generated_pool_php = NULL;
Expand All @@ -216,6 +256,9 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) {
zend_hash_destroy(proto_to_php_obj_map);
FREE_HASHTABLE(proto_to_php_obj_map);

zend_hash_destroy(reserved_names);
FREE_HASHTABLE(reserved_names);

#if PHP_MAJOR_VERSION < 7
if (generated_pool_php != NULL) {
zval_dtor(generated_pool_php);
Expand Down
28 changes: 27 additions & 1 deletion php/ext/google/protobuf/protobuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "upb.h"

#define PHP_PROTOBUF_EXTNAME "protobuf"
#define PHP_PROTOBUF_VERSION "3.4.0"
#define PHP_PROTOBUF_VERSION "3.4.1"

#define MAX_LENGTH_OF_INT64 20
#define SIZEOF_INT64 8
Expand Down Expand Up @@ -80,6 +80,9 @@
#define php_proto_zend_hash_update_zval(ht, key, key_len, value) \
zend_hash_update(ht, key, key_len, value, sizeof(void*), NULL)

#define php_proto_zend_hash_update(ht, key, key_len) \
zend_hash_update(ht, key, key_len, 0, 0, NULL)

#define php_proto_zend_hash_index_update_mem(ht, h, pData, nDataSize, pDest) \
zend_hash_index_update(ht, h, pData, nDataSize, pDest)

Expand All @@ -90,6 +93,9 @@
#define php_proto_zend_hash_index_find_zval(ht, h, pDest) \
zend_hash_index_find(ht, h, pDest)

#define php_proto_zend_hash_find(ht, key, key_len, pDest) \
zend_hash_find(ht, key, key_len, pDest)

#define php_proto_zend_hash_index_find_mem(ht, h, pDest) \
zend_hash_index_find(ht, h, pDest)

Expand Down Expand Up @@ -270,6 +276,15 @@ static inline int php_proto_zend_hash_index_update_zval(HashTable* ht, ulong h,
return result != NULL ? SUCCESS : FAILURE;
}

static inline int php_proto_zend_hash_update(HashTable* ht, const char* key,
size_t key_len) {
void* result = NULL;
zval temp;
ZVAL_LONG(&temp, 0);
result = zend_hash_str_update(ht, key, key_len, &temp);
return result != NULL ? SUCCESS : FAILURE;
}

static inline int php_proto_zend_hash_index_update_mem(HashTable* ht, ulong h,
void* pData, uint nDataSize,
void** pDest) {
Expand Down Expand Up @@ -303,6 +318,13 @@ static inline int php_proto_zend_hash_index_find_zval(const HashTable* ht,
return result != NULL ? SUCCESS : FAILURE;
}

static inline int php_proto_zend_hash_find(const HashTable* ht, const char* key,
size_t key_len, void** pDest) {
void* result = NULL;
result = zend_hash_str_find(ht, key, key_len);
return result != NULL ? SUCCESS : FAILURE;
}

static inline int php_proto_zend_hash_index_find_mem(const HashTable* ht,
ulong h, void** pDest) {
void* result = NULL;
Expand Down Expand Up @@ -1413,4 +1435,8 @@ static inline zval* php_proto_message_read_property(
#endif
}

// Reserved name
bool is_reserved_name(const char* name);
bool is_valid_constant_name(const char* name);

#endif // __GOOGLE_PROTOBUF_PHP_PROTOBUF_H__
Loading