forked from google/flatbuffers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bfbs gen to pass extra options (google#7949)
- Loading branch information
1 parent
65ef80e
commit 40e5b75
Showing
26 changed files
with
568 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.