mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 04:33:23 +00:00
[Lua] GetRootAs can accept strings. Made Luatest Benchmarks optional (#6593)
This commit is contained in:
@@ -124,6 +124,10 @@ class LuaGenerator : public BaseGenerator {
|
||||
|
||||
code += "function " + NormalizedName(struct_def) + ".GetRootAs" +
|
||||
NormalizedName(struct_def) + "(buf, offset)\n";
|
||||
code += std::string(Indent) + "if type(buf) == \"string\" then\n";
|
||||
code += std::string(Indent) + Indent +
|
||||
"buf = flatbuffers.binaryArray.New(buf)\n";
|
||||
code += std::string(Indent) + "end\n";
|
||||
code += std::string(Indent) +
|
||||
"local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)\n";
|
||||
code += std::string(Indent) + "local o = " + NormalizedName(struct_def) +
|
||||
|
||||
Reference in New Issue
Block a user