Generating code with > 200 local variables
Lua has a built in limit of 200 local variables in any one instance on the VM.
Currently, protoc-gen-lua will exceed this limit for very large protocol buffer specifications. This causes an error when one tries to use the generated code.
I propose to use global variables when creating *_pb.lua files. Although they are slower, they are only used the first time this file is parsed. This would make the effect negligible in situations where the file is require'd once and the resultant API objects are used repeatedly within the same VM context, for example in NGINX across multiple requests.
here is my solution for this problem, put this variables into a table named 'pb', modify protoc-gen-lua to below: line 251: obj_name = 'pb.' + full_name.upper().replace('.', '') + 'ENUM' line 253: "%s = protobuf.EnumValueDescriptor();\n"% obj_name line 267: obj_name = 'pb.' + full_name.upper().replace('.', '') line 269: "%s = protobuf.EnumDescriptor();\n"% obj_name line 287: obj_name = 'pb.' + full_name.upper().replace('.', '') + 'FIELD' line 289: "%s = protobuf.FieldDescriptor();\n"% obj_name line 319: type_name = 'pb.' + env.get_ref_name(field_desc.type_name).upper().replace('.', '') line 326: type_name = 'pb.' + env.get_ref_name(field_desc.extendee) line 339: obj_name = 'pb.' + full_name.upper().replace('.', '_') line 341: "%s = protobuf.Descriptor();\n"% obj_name insert before line 418: lua("local pb = {}\n")
@kueiwoodwolf thanks a lot ,this help me !
@chiuan my pleasure:)