mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-29 11:22:01 +00:00
fixed bfbs gen to pass extra options (#7949)
This commit is contained in:
@@ -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()
|
||||
|
||||
48
goldens/lua/Galaxy.lua
Normal file
48
goldens/lua/Galaxy.lua
Normal file
@@ -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
|
||||
88
goldens/lua/Universe.lua
Normal file
88
goldens/lua/Universe.lua
Normal file
@@ -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
|
||||
26
goldens/nim/Galaxy.nim
Normal file
26
goldens/nim/Galaxy.nim
Normal file
@@ -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()
|
||||
46
goldens/nim/Universe.nim
Normal file
46
goldens/nim/Universe.nim
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user