mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 18:58:57 +00:00
Enable --gen-onefile in Python (#6953)
* Enable --gen-onefile in Python Made it possible to generate all python code in one file. Modified py_test.py so that it can switch between the multi-file code and the one-file code. Updated PythonTest.sh and py_test.py so that the multi-file code and the one-file code can be tested based on the same test code. * Sync with google/flatbuffers * Add --gen-onefile to generate_code.py
This commit is contained in:
@@ -8,7 +8,6 @@ class Any(object):
|
||||
TestSimpleTableWithEnum = 2
|
||||
MyGame_Example2_Monster = 3
|
||||
|
||||
|
||||
def AnyCreator(unionType, table):
|
||||
from flatbuffers.table import Table
|
||||
if not isinstance(table, Table):
|
||||
|
||||
@@ -8,7 +8,6 @@ class AnyAmbiguousAliases(object):
|
||||
M2 = 2
|
||||
M3 = 3
|
||||
|
||||
|
||||
def AnyAmbiguousAliasesCreator(unionType, table):
|
||||
from flatbuffers.table import Table
|
||||
if not isinstance(table, Table):
|
||||
|
||||
@@ -8,7 +8,6 @@ class AnyUniqueAliases(object):
|
||||
TS = 2
|
||||
M2 = 3
|
||||
|
||||
|
||||
def AnyUniqueAliasesCreator(unionType, table):
|
||||
from flatbuffers.table import Table
|
||||
if not isinstance(table, Table):
|
||||
|
||||
@@ -10,4 +10,3 @@ class Color(object):
|
||||
Green = 2
|
||||
# \brief color Blue (1u << 3)
|
||||
Blue = 8
|
||||
|
||||
|
||||
@@ -7,4 +7,3 @@ class Race(object):
|
||||
Human = 0
|
||||
Dwarf = 1
|
||||
Elf = 2
|
||||
|
||||
|
||||
@@ -6,4 +6,3 @@ class TestEnum(object):
|
||||
A = 0
|
||||
B = 1
|
||||
C = 2
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ runtime_library_dir=${test_dir}/../python
|
||||
|
||||
# Emit Python code for the example schema in the test dir:
|
||||
${test_dir}/../flatc -p -o ${gen_code_path} -I include_test monster_test.fbs --gen-object-api
|
||||
${test_dir}/../flatc -p -o ${gen_code_path} -I include_test monster_test.fbs --gen-object-api --gen-onefile
|
||||
${test_dir}/../flatc -p -o ${gen_code_path} -I include_test monster_extra.fbs --gen-object-api
|
||||
|
||||
# Syntax: run_tests <interpreter> <benchmark vtable dedupes>
|
||||
@@ -35,7 +36,7 @@ function run_tests() {
|
||||
JYTHONPATH=${runtime_library_dir}:${gen_code_path} \
|
||||
COMPARE_GENERATED_TO_GO=0 \
|
||||
COMPARE_GENERATED_TO_JAVA=0 \
|
||||
$1 py_test.py $2 $3 $4
|
||||
$1 py_test.py $2 $3 $4 $5
|
||||
if [ $1 = python3 ]; then
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONPATH=${runtime_library_dir}:${gen_code_path} \
|
||||
@@ -47,10 +48,12 @@ function run_tests() {
|
||||
}
|
||||
|
||||
# Run test suite with these interpreters. The arguments are benchmark counts.
|
||||
run_tests python2.6 100 100 100
|
||||
run_tests python2.7 100 100 100
|
||||
run_tests python3 100 100 100
|
||||
run_tests pypy 100 100 100
|
||||
run_tests python2.6 100 100 100 false
|
||||
run_tests python2.7 100 100 100 false
|
||||
run_tests python2.7 100 100 100 true
|
||||
run_tests python3 100 100 100 false
|
||||
run_tests python3 100 100 100 true
|
||||
run_tests pypy 100 100 100 false
|
||||
|
||||
# NOTE: We'd like to support python2.5 in the future.
|
||||
|
||||
|
||||
2319
tests/monster_test_generated.py
Normal file
2319
tests/monster_test_generated.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,4 +6,3 @@ class EnumInNestedNS(object):
|
||||
A = 0
|
||||
B = 1
|
||||
C = 2
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ class UnionInNestedNS(object):
|
||||
NONE = 0
|
||||
TableInNestedNS = 1
|
||||
|
||||
|
||||
def UnionInNestedNSCreator(unionType, table):
|
||||
from flatbuffers.table import Table
|
||||
if not isinstance(table, Table):
|
||||
|
||||
4378
tests/py_test.py
4378
tests/py_test.py
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user