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

Generating code with > 200 local variables #13

Open
jamthief opened this issue Aug 8, 2014 · 3 comments · Fixed by qiqian/protoc-gen-lua#3 · May be fixed by #14
Open

Generating code with > 200 local variables #13

jamthief opened this issue Aug 8, 2014 · 3 comments · Fixed by qiqian/protoc-gen-lua#3 · May be fixed by #14

Comments

@jamthief
Copy link

jamthief commented Aug 8, 2014

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.

jamthief pushed a commit to jamthief/protoc-gen-lua that referenced this issue Aug 8, 2014
- Workaround the internal cap on local variable count enforced in the lua VM
- Fixes sean-lin#13

Change-Id: I67fc84c2de6d978b7f57aed62c04e75a11d079ba
@jamthief jamthief linked a pull request Aug 8, 2014 that will close this issue
@kueiwoodwolf
Copy link

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")

@chiuan
Copy link

chiuan commented Oct 20, 2014

@kueiwoodwolf thanks a lot ,this help me !

@kueiwoodwolf
Copy link

@chiuan my pleasure:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants