Merge remote-tracking branch 'upstream/main' into remove-public-modifier-kotlin

pull/9642/head
Minsoo Cheong 3 years ago
commit 464d626d1a
  1. 43
      .github/workflows/php-ext.yml
  2. 10
      objectivec/DevTools/full_mac_build.sh
  3. 11
      objectivec/DevTools/pddm.py
  4. 166
      objectivec/DevTools/pddm_tests.py
  5. 1
      php/ext/google/protobuf/config.m4
  6. 6
      src/google/protobuf/compiler/python/generator.cc
  7. 2
      src/google/protobuf/port_def.inc
  8. 1
      src/google/protobuf/port_undef.inc

@ -0,0 +1,43 @@
name: PHP extension
on:
- push
- pull_request
jobs:
build-php:
name: Build PHP extension
runs-on: ubuntu-latest
container: ${{ matrix.php-image }}
strategy:
matrix:
php-image:
- php:7.4-cli
- php:8.1-cli
steps:
- name: Install git
run: |
apt-get update -q
apt-get install -qy --no-install-recommends git
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Prepare source code
run: |
rm -rf "$GITHUB_WORKSPACE/php/ext/google/protobuf/third_party"
cp -r "$GITHUB_WORKSPACE/third_party" "$GITHUB_WORKSPACE/php/ext/google/protobuf"
cp "$GITHUB_WORKSPACE/LICENSE" "$GITHUB_WORKSPACE/php/ext/google/protobuf"
- name: Create package
run: |
cd /tmp
rm -rf protobuf-*.tgz
pecl package "$GITHUB_WORKSPACE/php/ext/google/protobuf/package.xml"
- name: Compile extension
run: |
cd /tmp
MAKE="make -j$(nproc)" pecl install protobuf-*.tgz
- name: Enable extension
run: docker-php-ext-enable protobuf
- name: Inspect extension
run: php --ri protobuf

@ -234,8 +234,14 @@ fi
objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}" objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}"
header "Checking on the ObjC Runtime Code" header "Checking on the ObjC Runtime Code"
objectivec/DevTools/pddm_tests.py # Some of the kokoro machines don't have python3 yet, so fall back to python if need be.
if ! objectivec/DevTools/pddm.py --dry-run objectivec/*.[hm] objectivec/Tests/*.[hm] ; then if hash python3 >/dev/null 2>&1 ; then
LOCAL_PYTHON=python3
else
LOCAL_PYTHON=python
fi
"${LOCAL_PYTHON}" objectivec/DevTools/pddm_tests.py
if ! "${LOCAL_PYTHON}" objectivec/DevTools/pddm.py --dry-run objectivec/*.[hm] objectivec/Tests/*.[hm] ; then
echo "" echo ""
echo "Update by running:" echo "Update by running:"
echo " objectivec/DevTools/pddm.py objectivec/*.[hm] objectivec/Tests/*.[hm]" echo " objectivec/DevTools/pddm.py objectivec/*.[hm] objectivec/Tests/*.[hm]"

@ -1,4 +1,4 @@
#! /usr/bin/python #! /usr/bin/env python3
# #
# Protocol Buffers - Google's data interchange format # Protocol Buffers - Google's data interchange format
# Copyright 2015 Google Inc. All rights reserved. # Copyright 2015 Google Inc. All rights reserved.
@ -134,7 +134,10 @@ def _MacroArgRefRe(macro_arg_names):
class PDDMError(Exception): class PDDMError(Exception):
"""Error thrown by pddm.""" """Error thrown by pddm."""
pass
def __init__(self, message="Error"):
self.message = message
super().__init__(self.message)
class MacroCollection(object): class MacroCollection(object):
@ -318,7 +321,7 @@ class MacroCollection(object):
# Nothing to do # Nothing to do
return macro.body return macro.body
assert len(arg_values) == len(macro.args) assert len(arg_values) == len(macro.args)
args = dict(zip(macro.args, arg_values)) args = dict(list(zip(macro.args, arg_values)))
def _lookupArg(match): def _lookupArg(match):
val = args[match.group('name')] val = args[match.group('name')]
@ -351,7 +354,7 @@ class MacroCollection(object):
return macro_arg_ref_re.sub(_lookupArg, macro.body) return macro_arg_ref_re.sub(_lookupArg, macro.body)
def _EvalMacrosRefs(self, text, macro_stack): def _EvalMacrosRefs(self, text, macro_stack):
macro_ref_re = _MacroRefRe(self._macros.keys()) macro_ref_re = _MacroRefRe(list(self._macros.keys()))
def _resolveMacro(match): def _resolveMacro(match):
return self._Expand(match, macro_stack) return self._Expand(match, macro_stack)

@ -1,4 +1,4 @@
#! /usr/bin/python #! /usr/bin/env python3
# #
# Protocol Buffers - Google's data interchange format # Protocol Buffers - Google's data interchange format
# Copyright 2015 Google Inc. All rights reserved. # Copyright 2015 Google Inc. All rights reserved.
@ -41,24 +41,24 @@ import pddm
class TestParsingMacros(unittest.TestCase): class TestParsingMacros(unittest.TestCase):
def testParseEmpty(self): def testParseEmpty(self):
f = io.StringIO(u'') f = io.StringIO('')
result = pddm.MacroCollection(f) result = pddm.MacroCollection(f)
self.assertEqual(len(result._macros), 0) self.assertEqual(len(result._macros), 0)
def testParseOne(self): def testParseOne(self):
f = io.StringIO(u"""PDDM-DEFINE foo( ) f = io.StringIO("""PDDM-DEFINE foo( )
body""") body""")
result = pddm.MacroCollection(f) result = pddm.MacroCollection(f)
self.assertEqual(len(result._macros), 1) self.assertEqual(len(result._macros), 1)
macro = result._macros.get('foo') macro = result._macros.get('foo')
self.assertIsNotNone(macro) self.assertIsNotNone(macro)
self.assertEquals(macro.name, 'foo') self.assertEqual(macro.name, 'foo')
self.assertEquals(macro.args, tuple()) self.assertEqual(macro.args, tuple())
self.assertEquals(macro.body, 'body') self.assertEqual(macro.body, 'body')
def testParseGeneral(self): def testParseGeneral(self):
# Tests multiple defines, spaces in all places, etc. # Tests multiple defines, spaces in all places, etc.
f = io.StringIO(u""" f = io.StringIO("""
PDDM-DEFINE noArgs( ) PDDM-DEFINE noArgs( )
body1 body1
body2 body2
@ -74,21 +74,21 @@ body5""")
self.assertEqual(len(result._macros), 3) self.assertEqual(len(result._macros), 3)
macro = result._macros.get('noArgs') macro = result._macros.get('noArgs')
self.assertIsNotNone(macro) self.assertIsNotNone(macro)
self.assertEquals(macro.name, 'noArgs') self.assertEqual(macro.name, 'noArgs')
self.assertEquals(macro.args, tuple()) self.assertEqual(macro.args, tuple())
self.assertEquals(macro.body, 'body1\nbody2\n') self.assertEqual(macro.body, 'body1\nbody2\n')
macro = result._macros.get('oneArg') macro = result._macros.get('oneArg')
self.assertIsNotNone(macro) self.assertIsNotNone(macro)
self.assertEquals(macro.name, 'oneArg') self.assertEqual(macro.name, 'oneArg')
self.assertEquals(macro.args, ('foo',)) self.assertEqual(macro.args, ('foo',))
self.assertEquals(macro.body, 'body3') self.assertEqual(macro.body, 'body3')
macro = result._macros.get('twoArgs') macro = result._macros.get('twoArgs')
self.assertIsNotNone(macro) self.assertIsNotNone(macro)
self.assertEquals(macro.name, 'twoArgs') self.assertEqual(macro.name, 'twoArgs')
self.assertEquals(macro.args, ('bar_', 'baz')) self.assertEqual(macro.args, ('bar_', 'baz'))
self.assertEquals(macro.body, 'body4\nbody5') self.assertEqual(macro.body, 'body4\nbody5')
# Add into existing collection # Add into existing collection
f = io.StringIO(u""" f = io.StringIO("""
PDDM-DEFINE another(a,b,c) PDDM-DEFINE another(a,b,c)
body1 body1
body2""") body2""")
@ -96,23 +96,23 @@ body2""")
self.assertEqual(len(result._macros), 4) self.assertEqual(len(result._macros), 4)
macro = result._macros.get('another') macro = result._macros.get('another')
self.assertIsNotNone(macro) self.assertIsNotNone(macro)
self.assertEquals(macro.name, 'another') self.assertEqual(macro.name, 'another')
self.assertEquals(macro.args, ('a', 'b', 'c')) self.assertEqual(macro.args, ('a', 'b', 'c'))
self.assertEquals(macro.body, 'body1\nbody2') self.assertEqual(macro.body, 'body1\nbody2')
def testParseDirectiveIssues(self): def testParseDirectiveIssues(self):
test_list = [ test_list = [
# Unknown directive # Unknown directive
(u'PDDM-DEFINE foo()\nbody\nPDDM-DEFINED foo\nbaz', ('PDDM-DEFINE foo()\nbody\nPDDM-DEFINED foo\nbaz',
'Hit a line with an unknown directive: '), 'Hit a line with an unknown directive: '),
# End without begin # End without begin
(u'PDDM-DEFINE foo()\nbody\nPDDM-DEFINE-END\nPDDM-DEFINE-END\n', ('PDDM-DEFINE foo()\nbody\nPDDM-DEFINE-END\nPDDM-DEFINE-END\n',
'Got DEFINE-END directive without an active macro: '), 'Got DEFINE-END directive without an active macro: '),
# Line not in macro block # Line not in macro block
(u'PDDM-DEFINE foo()\nbody\nPDDM-DEFINE-END\nmumble\n', ('PDDM-DEFINE foo()\nbody\nPDDM-DEFINE-END\nmumble\n',
'Hit a line that wasn\'t a directive and no open macro definition: '), 'Hit a line that wasn\'t a directive and no open macro definition: '),
# Redefine macro # Redefine macro
(u'PDDM-DEFINE foo()\nbody\nPDDM-DEFINE foo(a)\nmumble\n', ('PDDM-DEFINE foo()\nbody\nPDDM-DEFINE foo(a)\nmumble\n',
'Attempt to redefine macro: '), 'Attempt to redefine macro: '),
] ]
for idx, (input_str, expected_prefix) in enumerate(test_list, 1): for idx, (input_str, expected_prefix) in enumerate(test_list, 1):
@ -127,47 +127,47 @@ body2""")
def testParseBeginIssues(self): def testParseBeginIssues(self):
test_list = [ test_list = [
# 1. No name # 1. No name
(u'PDDM-DEFINE\nmumble', ('PDDM-DEFINE\nmumble',
'Failed to parse macro definition: '), 'Failed to parse macro definition: '),
# 2. No name (with spaces) # 2. No name (with spaces)
(u'PDDM-DEFINE \nmumble', ('PDDM-DEFINE \nmumble',
'Failed to parse macro definition: '), 'Failed to parse macro definition: '),
# 3. No open paren # 3. No open paren
(u'PDDM-DEFINE foo\nmumble', ('PDDM-DEFINE foo\nmumble',
'Failed to parse macro definition: '), 'Failed to parse macro definition: '),
# 4. No close paren # 4. No close paren
(u'PDDM-DEFINE foo(\nmumble', ('PDDM-DEFINE foo(\nmumble',
'Failed to parse macro definition: '), 'Failed to parse macro definition: '),
# 5. No close paren (with args) # 5. No close paren (with args)
(u'PDDM-DEFINE foo(a, b\nmumble', ('PDDM-DEFINE foo(a, b\nmumble',
'Failed to parse macro definition: '), 'Failed to parse macro definition: '),
# 6. No name before args # 6. No name before args
(u'PDDM-DEFINE (a, b)\nmumble', ('PDDM-DEFINE (a, b)\nmumble',
'Failed to parse macro definition: '), 'Failed to parse macro definition: '),
# 7. No name before args # 7. No name before args
(u'PDDM-DEFINE foo bar(a, b)\nmumble', ('PDDM-DEFINE foo bar(a, b)\nmumble',
'Failed to parse macro definition: '), 'Failed to parse macro definition: '),
# 8. Empty arg name # 8. Empty arg name
(u'PDDM-DEFINE foo(a, ,b)\nmumble', ('PDDM-DEFINE foo(a, ,b)\nmumble',
'Empty arg name in macro definition: '), 'Empty arg name in macro definition: '),
(u'PDDM-DEFINE foo(a,,b)\nmumble', ('PDDM-DEFINE foo(a,,b)\nmumble',
'Empty arg name in macro definition: '), 'Empty arg name in macro definition: '),
# 10. Duplicate name # 10. Duplicate name
(u'PDDM-DEFINE foo(a,b,a,c)\nmumble', ('PDDM-DEFINE foo(a,b,a,c)\nmumble',
'Arg name "a" used more than once in macro definition: '), 'Arg name "a" used more than once in macro definition: '),
# 11. Invalid arg name # 11. Invalid arg name
(u'PDDM-DEFINE foo(a b,c)\nmumble', ('PDDM-DEFINE foo(a b,c)\nmumble',
'Invalid arg name "a b" in macro definition: '), 'Invalid arg name "a b" in macro definition: '),
(u'PDDM-DEFINE foo(a.b,c)\nmumble', ('PDDM-DEFINE foo(a.b,c)\nmumble',
'Invalid arg name "a.b" in macro definition: '), 'Invalid arg name "a.b" in macro definition: '),
(u'PDDM-DEFINE foo(a-b,c)\nmumble', ('PDDM-DEFINE foo(a-b,c)\nmumble',
'Invalid arg name "a-b" in macro definition: '), 'Invalid arg name "a-b" in macro definition: '),
(u'PDDM-DEFINE foo(a,b,c.)\nmumble', ('PDDM-DEFINE foo(a,b,c.)\nmumble',
'Invalid arg name "c." in macro definition: '), 'Invalid arg name "c." in macro definition: '),
# 15. Extra stuff after the name # 15. Extra stuff after the name
(u'PDDM-DEFINE foo(a,c) foo\nmumble', ('PDDM-DEFINE foo(a,c) foo\nmumble',
'Failed to parse macro definition: '), 'Failed to parse macro definition: '),
(u'PDDM-DEFINE foo(a,c) foo)\nmumble', ('PDDM-DEFINE foo(a,c) foo)\nmumble',
'Failed to parse macro definition: '), 'Failed to parse macro definition: '),
] ]
for idx, (input_str, expected_prefix) in enumerate(test_list, 1): for idx, (input_str, expected_prefix) in enumerate(test_list, 1):
@ -183,7 +183,7 @@ body2""")
class TestExpandingMacros(unittest.TestCase): class TestExpandingMacros(unittest.TestCase):
def testExpandBasics(self): def testExpandBasics(self):
f = io.StringIO(u""" f = io.StringIO("""
PDDM-DEFINE noArgs( ) PDDM-DEFINE noArgs( )
body1 body1
body2 body2
@ -203,21 +203,21 @@ PDDM-DEFINE-END
""") """)
mc = pddm.MacroCollection(f) mc = pddm.MacroCollection(f)
test_list = [ test_list = [
(u'noArgs()', ('noArgs()',
'body1\nbody2\n'), 'body1\nbody2\n'),
(u'oneArg(wee)', ('oneArg(wee)',
'body3 wee\n'), 'body3 wee\n'),
(u'twoArgs(having some, fun)', ('twoArgs(having some, fun)',
'body4 having some fun\nbody5'), 'body4 having some fun\nbody5'),
# One arg, pass empty. # One arg, pass empty.
(u'oneArg()', ('oneArg()',
'body3 \n'), 'body3 \n'),
# Two args, gets empty in each slot. # Two args, gets empty in each slot.
(u'twoArgs(, empty)', ('twoArgs(, empty)',
'body4 empty\nbody5'), 'body4 empty\nbody5'),
(u'twoArgs(empty, )', ('twoArgs(empty, )',
'body4 empty \nbody5'), 'body4 empty \nbody5'),
(u'twoArgs(, )', ('twoArgs(, )',
'body4 \nbody5'), 'body4 \nbody5'),
] ]
for idx, (input_str, expected) in enumerate(test_list, 1): for idx, (input_str, expected) in enumerate(test_list, 1):
@ -227,7 +227,7 @@ PDDM-DEFINE-END
(idx, result, expected)) (idx, result, expected))
def testExpandArgOptions(self): def testExpandArgOptions(self):
f = io.StringIO(u""" f = io.StringIO("""
PDDM-DEFINE bar(a) PDDM-DEFINE bar(a)
a-a$S-a$l-a$L-a$u-a$U a-a$S-a$l-a$L-a$u-a$U
PDDM-DEFINE-END PDDM-DEFINE-END
@ -240,7 +240,7 @@ PDDM-DEFINE-END
self.assertEqual(mc.Expand('bar()'), '-----') self.assertEqual(mc.Expand('bar()'), '-----')
def testExpandSimpleMacroErrors(self): def testExpandSimpleMacroErrors(self):
f = io.StringIO(u""" f = io.StringIO("""
PDDM-DEFINE foo(a, b) PDDM-DEFINE foo(a, b)
<a-z> <a-z>
PDDM-DEFINE baz(a) PDDM-DEFINE baz(a)
@ -249,19 +249,19 @@ a - a$z
mc = pddm.MacroCollection(f) mc = pddm.MacroCollection(f)
test_list = [ test_list = [
# 1. Unknown macro # 1. Unknown macro
(u'bar()', ('bar()',
'No macro named "bar".'), 'No macro named "bar".'),
(u'bar(a)', ('bar(a)',
'No macro named "bar".'), 'No macro named "bar".'),
# 3. Arg mismatch # 3. Arg mismatch
(u'foo()', ('foo()',
'Expected 2 args, got: "foo()".'), 'Expected 2 args, got: "foo()".'),
(u'foo(a b)', ('foo(a b)',
'Expected 2 args, got: "foo(a b)".'), 'Expected 2 args, got: "foo(a b)".'),
(u'foo(a,b,c)', ('foo(a,b,c)',
'Expected 2 args, got: "foo(a,b,c)".'), 'Expected 2 args, got: "foo(a,b,c)".'),
# 6. Unknown option in expansion # 6. Unknown option in expansion
(u'baz(mumble)', ('baz(mumble)',
'Unknown arg option "a$z" while expanding "baz(mumble)".'), 'Unknown arg option "a$z" while expanding "baz(mumble)".'),
] ]
for idx, (input_str, expected_err) in enumerate(test_list, 1): for idx, (input_str, expected_err) in enumerate(test_list, 1):
@ -273,7 +273,7 @@ a - a$z
'Entry %d failed: %r' % (idx, e)) 'Entry %d failed: %r' % (idx, e))
def testExpandReferences(self): def testExpandReferences(self):
f = io.StringIO(u""" f = io.StringIO("""
PDDM-DEFINE StartIt() PDDM-DEFINE StartIt()
foo(abc, def) foo(abc, def)
foo(ghi, jkl) foo(ghi, jkl)
@ -301,7 +301,7 @@ PDDM-DEFINE bar(n, t)
self.assertEqual(mc.Expand('StartIt()'), expected) self.assertEqual(mc.Expand('StartIt()'), expected)
def testCatchRecursion(self): def testCatchRecursion(self):
f = io.StringIO(u""" f = io.StringIO("""
PDDM-DEFINE foo(a, b) PDDM-DEFINE foo(a, b)
bar(1, a) bar(1, a)
bar(2, b) bar(2, b)
@ -322,29 +322,29 @@ class TestParsingSource(unittest.TestCase):
def testBasicParse(self): def testBasicParse(self):
test_list = [ test_list = [
# 1. no directives # 1. no directives
(u'a\nb\nc', ('a\nb\nc',
(3,) ), (3,) ),
# 2. One define # 2. One define
(u'a\n//%PDDM-DEFINE foo()\n//%body\nc', ('a\n//%PDDM-DEFINE foo()\n//%body\nc',
(1, 2, 1) ), (1, 2, 1) ),
# 3. Two defines # 3. Two defines
(u'a\n//%PDDM-DEFINE foo()\n//%body\n//%PDDM-DEFINE bar()\n//%body2\nc', ('a\n//%PDDM-DEFINE foo()\n//%body\n//%PDDM-DEFINE bar()\n//%body2\nc',
(1, 4, 1) ), (1, 4, 1) ),
# 4. Two defines with ends # 4. Two defines with ends
(u'a\n//%PDDM-DEFINE foo()\n//%body\n//%PDDM-DEFINE-END\n' ('a\n//%PDDM-DEFINE foo()\n//%body\n//%PDDM-DEFINE-END\n'
u'//%PDDM-DEFINE bar()\n//%body2\n//%PDDM-DEFINE-END\nc', '//%PDDM-DEFINE bar()\n//%body2\n//%PDDM-DEFINE-END\nc',
(1, 6, 1) ), (1, 6, 1) ),
# 5. One expand, one define (that runs to end of file) # 5. One expand, one define (that runs to end of file)
(u'a\n//%PDDM-EXPAND foo()\nbody\n//%PDDM-EXPAND-END\n' ('a\n//%PDDM-EXPAND foo()\nbody\n//%PDDM-EXPAND-END\n'
u'//%PDDM-DEFINE bar()\n//%body2\n', '//%PDDM-DEFINE bar()\n//%body2\n',
(1, 1, 2) ), (1, 1, 2) ),
# 6. One define ended with an expand. # 6. One define ended with an expand.
(u'a\nb\n//%PDDM-DEFINE bar()\n//%body2\n' ('a\nb\n//%PDDM-DEFINE bar()\n//%body2\n'
u'//%PDDM-EXPAND bar()\nbody2\n//%PDDM-EXPAND-END\n', '//%PDDM-EXPAND bar()\nbody2\n//%PDDM-EXPAND-END\n',
(2, 2, 1) ), (2, 2, 1) ),
# 7. Two expands (one end), one define. # 7. Two expands (one end), one define.
(u'a\n//%PDDM-EXPAND foo(1)\nbody\n//%PDDM-EXPAND foo(2)\nbody2\n//%PDDM-EXPAND-END\n' ('a\n//%PDDM-EXPAND foo(1)\nbody\n//%PDDM-EXPAND foo(2)\nbody2\n//%PDDM-EXPAND-END\n'
u'//%PDDM-DEFINE foo()\n//%body2\n', '//%PDDM-DEFINE foo()\n//%body2\n',
(1, 2, 2) ), (1, 2, 2) ),
] ]
for idx, (input_str, line_counts) in enumerate(test_list, 1): for idx, (input_str, line_counts) in enumerate(test_list, 1):
@ -362,24 +362,24 @@ class TestParsingSource(unittest.TestCase):
def testErrors(self): def testErrors(self):
test_list = [ test_list = [
# 1. Directive within expansion # 1. Directive within expansion
(u'//%PDDM-EXPAND a()\n//%PDDM-BOGUS', ('//%PDDM-EXPAND a()\n//%PDDM-BOGUS',
'Ran into directive ("//%PDDM-BOGUS", line 2) while in "//%PDDM-EXPAND a()".'), 'Ran into directive ("//%PDDM-BOGUS", line 2) while in "//%PDDM-EXPAND a()".'),
(u'//%PDDM-EXPAND a()\n//%PDDM-DEFINE a()\n//%body\n', ('//%PDDM-EXPAND a()\n//%PDDM-DEFINE a()\n//%body\n',
'Ran into directive ("//%PDDM-DEFINE", line 2) while in "//%PDDM-EXPAND a()".'), 'Ran into directive ("//%PDDM-DEFINE", line 2) while in "//%PDDM-EXPAND a()".'),
# 3. Expansion ran off end of file # 3. Expansion ran off end of file
(u'//%PDDM-EXPAND a()\na\nb\n', ('//%PDDM-EXPAND a()\na\nb\n',
'Hit the end of the file while in "//%PDDM-EXPAND a()".'), 'Hit the end of the file while in "//%PDDM-EXPAND a()".'),
# 4. Directive within define # 4. Directive within define
(u'//%PDDM-DEFINE a()\n//%body\n//%PDDM-BOGUS', ('//%PDDM-DEFINE a()\n//%body\n//%PDDM-BOGUS',
'Ran into directive ("//%PDDM-BOGUS", line 3) while in "//%PDDM-DEFINE a()".'), 'Ran into directive ("//%PDDM-BOGUS", line 3) while in "//%PDDM-DEFINE a()".'),
(u'//%PDDM-DEFINE a()\n//%body\n//%PDDM-EXPAND-END a()', ('//%PDDM-DEFINE a()\n//%body\n//%PDDM-EXPAND-END a()',
'Ran into directive ("//%PDDM-EXPAND-END", line 3) while in "//%PDDM-DEFINE a()".'), 'Ran into directive ("//%PDDM-EXPAND-END", line 3) while in "//%PDDM-DEFINE a()".'),
# 6. Directives that shouldn't start sections # 6. Directives that shouldn't start sections
(u'a\n//%PDDM-DEFINE-END a()\n//a\n', ('a\n//%PDDM-DEFINE-END a()\n//a\n',
'Unexpected line 2: "//%PDDM-DEFINE-END a()".'), 'Unexpected line 2: "//%PDDM-DEFINE-END a()".'),
(u'a\n//%PDDM-EXPAND-END a()\n//a\n', ('a\n//%PDDM-EXPAND-END a()\n//a\n',
'Unexpected line 2: "//%PDDM-EXPAND-END a()".'), 'Unexpected line 2: "//%PDDM-EXPAND-END a()".'),
(u'//%PDDM-BOGUS\n//a\n', ('//%PDDM-BOGUS\n//a\n',
'Unexpected line 1: "//%PDDM-BOGUS".'), 'Unexpected line 1: "//%PDDM-BOGUS".'),
] ]
for idx, (input_str, expected_err) in enumerate(test_list, 1): for idx, (input_str, expected_err) in enumerate(test_list, 1):
@ -395,7 +395,7 @@ class TestProcessingSource(unittest.TestCase):
def testBasics(self): def testBasics(self):
self.maxDiff = None self.maxDiff = None
input_str = u""" input_str = """
//%PDDM-IMPORT-DEFINES ImportFile //%PDDM-IMPORT-DEFINES ImportFile
foo foo
//%PDDM-EXPAND mumble(abc) //%PDDM-EXPAND mumble(abc)
@ -408,12 +408,12 @@ baz
//%PDDM-DEFINE mumble(a_) //%PDDM-DEFINE mumble(a_)
//%a_: getName(a_) //%a_: getName(a_)
""" """
input_str2 = u""" input_str2 = """
//%PDDM-DEFINE getName(x_) //%PDDM-DEFINE getName(x_)
//%do##x_$u##(int x_); //%do##x_$u##(int x_);
""" """
expected = u""" expected = """
//%PDDM-IMPORT-DEFINES ImportFile //%PDDM-IMPORT-DEFINES ImportFile
foo foo
//%PDDM-EXPAND mumble(abc) //%PDDM-EXPAND mumble(abc)
@ -441,7 +441,7 @@ baz
//%PDDM-DEFINE mumble(a_) //%PDDM-DEFINE mumble(a_)
//%a_: getName(a_) //%a_: getName(a_)
""" """
expected_stripped = u""" expected_stripped = """
//%PDDM-IMPORT-DEFINES ImportFile //%PDDM-IMPORT-DEFINES ImportFile
foo foo
//%PDDM-EXPAND mumble(abc) //%PDDM-EXPAND mumble(abc)
@ -478,7 +478,7 @@ baz
self.assertEqual(sf2.processed_content, expected_stripped) self.assertEqual(sf2.processed_content, expected_stripped)
def testProcessFileWithMacroParseError(self): def testProcessFileWithMacroParseError(self):
input_str = u""" input_str = """
foo foo
//%PDDM-DEFINE mumble(a_) //%PDDM-DEFINE mumble(a_)
//%body //%body
@ -498,7 +498,7 @@ foo
' Line 3: //%PDDM-DEFINE mumble(a_)') ' Line 3: //%PDDM-DEFINE mumble(a_)')
def testProcessFileWithExpandError(self): def testProcessFileWithExpandError(self):
input_str = u""" input_str = """
foo foo
//%PDDM-DEFINE mumble(a_) //%PDDM-DEFINE mumble(a_)
//%body //%body

@ -6,5 +6,6 @@ if test "$PHP_PROTOBUF" != "no"; then
protobuf, protobuf,
arena.c array.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c third_party/utf8_range/naive.c third_party/utf8_range/range2-neon.c third_party/utf8_range/range2-sse.c, arena.c array.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c third_party/utf8_range/naive.c third_party/utf8_range/range2-neon.c third_party/utf8_range/range2-sse.c,
$ext_shared, , -std=gnu99) $ext_shared, , -std=gnu99)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/utf8_range)
fi fi

@ -90,12 +90,6 @@ std::string ModuleAlias(const std::string& filename) {
// in proto2/public/reflection.py. // in proto2/public/reflection.py.
const char kDescriptorKey[] = "DESCRIPTOR"; const char kDescriptorKey[] = "DESCRIPTOR";
// Does the file have top-level enums?
inline bool HasTopLevelEnums(const FileDescriptor* file) {
return file->enum_type_count() > 0;
}
// file output by this generator. // file output by this generator.
void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file, void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file,
bool descriptor_proto) { bool descriptor_proto) {

@ -779,6 +779,8 @@
#undef GetClassName #undef GetClassName
#pragma push_macro("GetMessage") #pragma push_macro("GetMessage")
#undef GetMessage #undef GetMessage
#pragma push_macro("GetObject")
#undef GetObject
#pragma push_macro("IGNORE") #pragma push_macro("IGNORE")
#undef IGNORE #undef IGNORE
#pragma push_macro("IN") #pragma push_macro("IN")

@ -114,6 +114,7 @@
#pragma pop_macro("ERROR_NOT_FOUND") #pragma pop_macro("ERROR_NOT_FOUND")
#pragma pop_macro("GetClassName") #pragma pop_macro("GetClassName")
#pragma pop_macro("GetMessage") #pragma pop_macro("GetMessage")
#pragma pop_macro("GetObject")
#pragma pop_macro("IGNORE") #pragma pop_macro("IGNORE")
#pragma pop_macro("IN") #pragma pop_macro("IN")
#pragma pop_macro("INPUT_KEYBOARD") #pragma pop_macro("INPUT_KEYBOARD")

Loading…
Cancel
Save