diff options
author | Derek Bailey <derek.bailey@thermofisher.com> | 2018-07-05 15:55:57 -0700 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2018-07-05 15:55:57 -0700 |
commit | ba5eb3b5cfb6eea74727e67cad599409f9d0af99 (patch) | |
tree | 45ef72d9acc8934b6dc62f070078dc4b1fe8485f /tests/MyGame/Example/Test.lua | |
parent | 8ea293b9881e707e1735dea503878b9ad6d9ef14 (diff) | |
download | flatbuffers-ba5eb3b5cfb6eea74727e67cad599409f9d0af99.tar.gz flatbuffers-ba5eb3b5cfb6eea74727e67cad599409f9d0af99.tar.bz2 flatbuffers-ba5eb3b5cfb6eea74727e67cad599409f9d0af99.zip |
Lua (5.3) Language addition (#4804)
* starting Lua port of python implmention. Syncing commit
* Bulk of Lua module port from Python done. Not tested, only static analysis. Need to work on binary strings. Started work on flatc lua code generation
* Fixed all the basic errors to produced a binary output from the builder, don't know if it is generated correctly, but it contains data, so that must be good
* fixed binary set command that was extending the array improperly
* continued improvement
* Moved lua submodules down a directory so their names don't clash with potential other modules. Added compat module to provide Lua versioning logic
* Successful sample port from Python
* working on testing Lua code with formal tests
* continued to work on tests and fixes to code to make tests pass
* Added reading buffer test
* Changed binaryarray implmentation to use a temporary table for storing data, and then serialize it to a string when requested. This double the rate of building flatbuffers compared to the string approach.
* Didn't need encode module as it just added another layer of indirection that isn't need
* profiled reading buffers, optimizations to increase read performance of monster data to ~7 monster / millisecond
* Writing profiler improvments. Get about
~2 monsters/millisecond building rate
* removed Numpy generation from Lua (came from the Python port)
* math.pow is deprecated in Lua 5.3, so changed to ^ notation. Also added .bat script for starting Lua tests
* adding results of generate_code.bat
* simple edits for code review in PR.
* There was a buffer overflow in inserting the keywords into the unorder set for both the Lua and Python code gens. Changed insertion to use iterators.
* fixed spacing issue
* basic documenation/tutorial updates. Updated sample_binary.lua to reflect the tutorial better
* removed windows-specific build step in Lua tests
Diffstat (limited to 'tests/MyGame/Example/Test.lua')
-rw-r--r-- | tests/MyGame/Example/Test.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/MyGame/Example/Test.lua b/tests/MyGame/Example/Test.lua new file mode 100644 index 00000000..154067bf --- /dev/null +++ b/tests/MyGame/Example/Test.lua @@ -0,0 +1,32 @@ +-- automatically generated by the FlatBuffers compiler, do not modify + +-- namespace: Example + +local flatbuffers = require('flatbuffers') + +local Test = {} -- the module +local Test_mt = {} -- the class metatable + +function Test.New() + local o = {} + setmetatable(o, {__index = Test_mt}) + return o +end +function Test_mt:Init(buf, pos) + self.view = flatbuffers.view.New(buf, pos) +end +function Test_mt:A() + return self.view:Get(flatbuffers.N.Int16, self.view.pos + 0) +end +function Test_mt:B() + return self.view:Get(flatbuffers.N.Int8, self.view.pos + 2) +end +function Test.CreateTest(builder, a, b) + builder:Prep(2, 4) + builder:Pad(1) + builder:PrependInt8(b) + builder:PrependInt16(a) + return builder:Offset() +end + +return Test -- return the module
\ No newline at end of file |