summaryrefslogtreecommitdiff
path: root/goldens
diff options
context:
space:
mode:
authorDerek Bailey <derekbailey@google.com>2023-05-09 22:42:31 -0700
committerGitHub <noreply@github.com>2023-05-09 22:42:31 -0700
commit3e6cd51b6307d680ac8eb6a3f1671fb756228e8b (patch)
tree7bdfafdbd49ff936d90debb037eae874b1e7f8c0 /goldens
parent10b79d87c19bd2d0f4fd061d623f3b08cb55a1a9 (diff)
downloadflatbuffers-3e6cd51b6307d680ac8eb6a3f1671fb756228e8b.tar.gz
flatbuffers-3e6cd51b6307d680ac8eb6a3f1671fb756228e8b.tar.bz2
flatbuffers-3e6cd51b6307d680ac8eb6a3f1671fb756228e8b.zip
fixed bfbs gen to pass extra options (#7949)
Diffstat (limited to 'goldens')
-rwxr-xr-xgoldens/generate_goldens.py5
-rw-r--r--goldens/lua/Galaxy.lua48
-rw-r--r--goldens/lua/Universe.lua88
-rw-r--r--goldens/nim/Galaxy.nim26
-rw-r--r--goldens/nim/Universe.nim46
5 files changed, 210 insertions, 3 deletions
diff --git a/goldens/generate_goldens.py b/goldens/generate_goldens.py
index f04854aa..d521b812 100755
--- a/goldens/generate_goldens.py
+++ b/goldens/generate_goldens.py
@@ -23,9 +23,8 @@ GenerateGo()
GenerateJava()
GenerateKotlin()
GenerateLobster()
-# TODO these doesn't respect the output prefix, fix and reenable
-# GenerateLua()
-# GenerateNim()
+GenerateLua()
+GenerateNim()
GeneratePhp()
GeneratePython()
GenerateRust()
diff --git a/goldens/lua/Galaxy.lua b/goldens/lua/Galaxy.lua
new file mode 100644
index 00000000..071a1c80
--- /dev/null
+++ b/goldens/lua/Galaxy.lua
@@ -0,0 +1,48 @@
+--[[ Galaxy
+
+ Automatically generated by the FlatBuffers compiler, do not modify.
+ Or modify. I'm a message, not a cop.
+
+ flatc version: 23.5.9
+
+ Declared by : //basic.fbs
+ Rooting type : Universe (//basic.fbs)
+
+--]]
+
+local flatbuffers = require('flatbuffers')
+
+local Galaxy = {}
+local mt = {}
+
+function Galaxy.New()
+ local o = {}
+ setmetatable(o, {__index = mt})
+ return o
+end
+
+function mt:Init(buf, pos)
+ self.view = flatbuffers.view.New(buf, pos)
+end
+
+function mt:NumStars()
+ local o = self.view:Offset(4)
+ if o ~= 0 then
+ return self.view:Get(flatbuffers.N.Int64, self.view.pos + o)
+ end
+ return 0
+end
+
+function Galaxy.Start(builder)
+ builder:StartObject(1)
+end
+
+function Galaxy.AddNumStars(builder, numStars)
+ builder:PrependInt64Slot(0, numStars, 0)
+end
+
+function Galaxy.End(builder)
+ return builder:EndObject()
+end
+
+return Galaxy \ No newline at end of file
diff --git a/goldens/lua/Universe.lua b/goldens/lua/Universe.lua
new file mode 100644
index 00000000..d7ef085e
--- /dev/null
+++ b/goldens/lua/Universe.lua
@@ -0,0 +1,88 @@
+--[[ Universe
+
+ Automatically generated by the FlatBuffers compiler, do not modify.
+ Or modify. I'm a message, not a cop.
+
+ flatc version: 23.5.9
+
+ Declared by : //basic.fbs
+ Rooting type : Universe (//basic.fbs)
+
+--]]
+
+local __Galaxy = require('Galaxy')
+local flatbuffers = require('flatbuffers')
+
+local Universe = {}
+local mt = {}
+
+function Universe.New()
+ local o = {}
+ setmetatable(o, {__index = mt})
+ return o
+end
+
+function Universe.GetRootAsUniverse(buf, offset)
+ if type(buf) == "string" then
+ buf = flatbuffers.binaryArray.New(buf)
+ end
+
+ local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
+ local o = Universe.New()
+ o:Init(buf, n + offset)
+ return o
+end
+
+function mt:Init(buf, pos)
+ self.view = flatbuffers.view.New(buf, pos)
+end
+
+function mt:Age()
+ local o = self.view:Offset(4)
+ if o ~= 0 then
+ return self.view:Get(flatbuffers.N.Float64, self.view.pos + o)
+ end
+ return 0.0
+end
+
+function mt:Galaxies(j)
+ local o = self.view:Offset(6)
+ if o ~= 0 then
+ local x = self.view:Vector(o)
+ x = x + ((j-1) * 4)
+ x = self.view:Indirect(x)
+ local obj = __Galaxy.New()
+ obj:Init(self.view.bytes, x)
+ return obj
+ end
+end
+
+function mt:GalaxiesLength()
+ local o = self.view:Offset(6)
+ if o ~= 0 then
+ return self.view:VectorLen(o)
+ end
+ return 0
+end
+
+function Universe.Start(builder)
+ builder:StartObject(2)
+end
+
+function Universe.AddAge(builder, age)
+ builder:PrependFloat64Slot(0, age, 0.0)
+end
+
+function Universe.AddGalaxies(builder, galaxies)
+ builder:PrependUOffsetTRelativeSlot(1, galaxies, 0)
+end
+
+function Universe.StartGalaxiesVector(builder, numElems)
+ return builder:StartVector(4, numElems, 4)
+end
+
+function Universe.End(builder)
+ return builder:EndObject()
+end
+
+return Universe \ No newline at end of file
diff --git a/goldens/nim/Galaxy.nim b/goldens/nim/Galaxy.nim
new file mode 100644
index 00000000..7728c367
--- /dev/null
+++ b/goldens/nim/Galaxy.nim
@@ -0,0 +1,26 @@
+#[ Galaxy
+ Automatically generated by the FlatBuffers compiler, do not modify.
+ Or modify. I'm a message, not a cop.
+
+ flatc version: 23.5.9
+
+ Declared by : //basic.fbs
+ Rooting type : Universe (//basic.fbs)
+]#
+
+import flatbuffers
+
+type Galaxy* = object of FlatObj
+func numStars*(self: Galaxy): int64 =
+ let o = self.tab.Offset(4)
+ if o != 0:
+ return Get[int64](self.tab, self.tab.Pos + o)
+ return 0
+func `numStars=`*(self: var Galaxy, n: int64): bool =
+ return self.tab.MutateSlot(4, n)
+proc GalaxyStart*(builder: var Builder) =
+ builder.StartObject(1)
+proc GalaxyAddnumStars*(builder: var Builder, numStars: int64) =
+ builder.PrependSlot(0, numStars, default(int64))
+proc GalaxyEnd*(builder: var Builder): uoffset =
+ return builder.EndObject()
diff --git a/goldens/nim/Universe.nim b/goldens/nim/Universe.nim
new file mode 100644
index 00000000..3a4e43d2
--- /dev/null
+++ b/goldens/nim/Universe.nim
@@ -0,0 +1,46 @@
+#[ Universe
+ Automatically generated by the FlatBuffers compiler, do not modify.
+ Or modify. I'm a message, not a cop.
+
+ flatc version: 23.5.9
+
+ Declared by : //basic.fbs
+ Rooting type : Universe (//basic.fbs)
+]#
+
+import Galaxy as Galaxy
+import flatbuffers
+import std/options
+
+type Universe* = object of FlatObj
+func age*(self: Universe): float64 =
+ let o = self.tab.Offset(4)
+ if o != 0:
+ return Get[float64](self.tab, self.tab.Pos + o)
+ return 0.0
+func `age=`*(self: var Universe, n: float64): bool =
+ return self.tab.MutateSlot(4, n)
+func galaxiesLength*(self: Universe): int =
+ let o = self.tab.Offset(6)
+ if o != 0:
+ return self.tab.VectorLen(o)
+func galaxies*(self: Universe, j: int): Galaxy.Galaxy =
+ let o = self.tab.Offset(6)
+ if o != 0:
+ var x = self.tab.Vector(o)
+ x += j.uoffset * 4.uoffset
+ return Galaxy.Galaxy(tab: Vtable(Bytes: self.tab.Bytes, Pos: x))
+func galaxies*(self: Universe): seq[Galaxy.Galaxy] =
+ let len = self.galaxiesLength
+ for i in countup(0, len - 1):
+ result.add(self.galaxies(i))
+proc UniverseStart*(builder: var Builder) =
+ builder.StartObject(2)
+proc UniverseAddage*(builder: var Builder, age: float64) =
+ builder.PrependSlot(0, age, default(float64))
+proc UniverseAddgalaxies*(builder: var Builder, galaxies: uoffset) =
+ builder.PrependSlot(1, galaxies, default(uoffset))
+proc UniverseStartgalaxiesVector*(builder: var Builder, numElems: uoffset) =
+ builder.StartVector(4, numElems, 4)
+proc UniverseEnd*(builder: var Builder): uoffset =
+ return builder.EndObject()