Skip to content
Open
Changes from all commits
Commits
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
17 changes: 11 additions & 6 deletions plugin/protoc-gen-lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import google.protobuf.descriptor_pb2 as descriptor_pb2
_packages = {}
_files = {}
_message = {}

_prefix = "pb_table."
_prefixNoDot = "pb_table"
FDP = plugin_pb2.descriptor_pb2.FieldDescriptorProto

if sys.platform == "win32":
Expand Down Expand Up @@ -249,8 +250,9 @@ DEFAULT_VALUE = {
def code_gen_enum_item(index, enum_value, env):
full_name = env.get_local_name() + '.' + enum_value.name
obj_name = full_name.upper().replace('.', '_') + '_ENUM'
obj_name = _prefix + obj_name
env.descriptor.append(
"local %s = protobuf.EnumValueDescriptor();\n"% obj_name
"%s = protobuf.EnumValueDescriptor();\n"% obj_name
)

context = Writer(obj_name)
Expand All @@ -265,8 +267,9 @@ def code_gen_enum(enum_desc, env):
env.enter(enum_desc.name)
full_name = env.get_local_name()
obj_name = full_name.upper().replace('.', '_')
obj_name = _prefix + obj_name
env.descriptor.append(
"local %s = protobuf.EnumDescriptor();\n"% obj_name
"%s = protobuf.EnumDescriptor();\n"% obj_name
)

context = Writer(obj_name)
Expand All @@ -285,8 +288,9 @@ def code_gen_enum(enum_desc, env):
def code_gen_field(index, field_desc, env):
full_name = env.get_local_name() + '.' + field_desc.name
obj_name = full_name.upper().replace('.', '_') + '_FIELD'
obj_name = _prefix + obj_name
env.descriptor.append(
"local %s = protobuf.FieldDescriptor();\n"% obj_name
"%s = protobuf.FieldDescriptor();\n"% obj_name
)

context = Writer(obj_name)
Expand Down Expand Up @@ -337,8 +341,9 @@ def code_gen_message(message_descriptor, env, containing_type = None):
env.enter(message_descriptor.name)
full_name = env.get_local_name()
obj_name = full_name.upper().replace('.', '_')
obj_name = _prefix + obj_name
env.descriptor.append(
"local %s = protobuf.Descriptor();\n"% obj_name
"%s = protobuf.Descriptor();\n"% obj_name
)

context = Writer(obj_name)
Expand Down Expand Up @@ -413,7 +418,7 @@ def code_gen_file(proto_file, env, is_gen):
for i in includes:
lua('local %s_pb = require("%s_pb")\n' % (i, i))
lua("module('%s_pb')\n" % env.filename)

lua("local %s = {}" % (_prefixNoDot))
lua('\n\n')
map(lua, env.descriptor)
lua('\n')
Expand Down