GenComment(struct_def.doc_comment);
code_.SetValue("STRUCTNAME", NameWrappedInNameSpace(struct_def));
code_ += "{{ACCESS_TYPE}} struct {{STRUCTNAME}}: NativeStruct\\";
- if (parser_.opts.generate_object_based_api) code_ += ", UnionObject\\";
+ if (parser_.opts.generate_object_based_api) code_ += ", NativeObject\\";
code_ += " {";
code_ += "";
Indent();
code_ +=
"{{ACCESS_TYPE}} struct {{STRUCTNAME}}{{MUTABLE}}: FlatBufferObject\\";
if (!struct_def.fixed && parser_.opts.generate_object_based_api)
- code_ += ", ObjectAPI\\";
+ code_ += ", ObjectAPIPacker\\";
code_ += " {\n";
Indent();
code_ += ValidateFunc();
code_ += "{{ACCESS_TYPE}} struct {{ENUM_NAME}}Union {";
Indent();
code_ += "{{ACCESS_TYPE}} var type: {{ENUM_NAME}}";
- code_ += "{{ACCESS_TYPE}} var value: UnionObject?";
- code_ += "{{ACCESS_TYPE}} init(_ v: UnionObject?, type: {{ENUM_NAME}}) {";
+ code_ += "{{ACCESS_TYPE}} var value: NativeObject?";
+ code_ +=
+ "{{ACCESS_TYPE}} init(_ v: NativeObject?, type: {{ENUM_NAME}}) {";
Indent();
code_ += "self.type = type";
code_ += "self.value = v";
void GenObjectAPI(const StructDef &struct_def) {
code_ += "{{ACCESS_TYPE}} class " + ObjectAPIName("{{STRUCTNAME}}") +
- ": UnionObject {\n";
+ ": NativeObject {\n";
std::vector<std::string> buffer_constructor;
std::vector<std::string> base_constructor;
Indent();
import Foundation
-public protocol UnionObject {}
+public protocol NativeObject {}
-extension UnionObject {
+extension NativeObject {
/// Serialize is a helper function that serailizes the data from the Object API to a bytebuffer directly th
/// - Parameter type: Type of the Flatbuffer object
/// - Returns: returns the encoded sized ByteBuffer
- public func serialize<T: ObjectAPI>(type: T.Type) -> ByteBuffer where T.T == Self {
+ public func serialize<T: ObjectAPIPacker>(type: T.Type) -> ByteBuffer where T.T == Self {
var builder = FlatBufferBuilder(initialSize: 1024)
return serialize(builder: &builder, type: type.self)
}
/// - Returns: returns the encoded sized ByteBuffer
/// - Note: The `serialize(builder:type)` can be considered as a function that allows you to create smaller builder instead of the default `1024`.
/// It can be considered less expensive in terms of memory allocation
- public func serialize<T: ObjectAPI>(builder: inout FlatBufferBuilder, type: T.Type) -> ByteBuffer where T.T == Self {
+ public func serialize<T: ObjectAPIPacker>(builder: inout FlatBufferBuilder, type: T.Type) -> ByteBuffer where T.T == Self {
var s = self
let root = type.pack(&builder, obj: &s)
builder.finish(offset: root)
public struct MyGame_Example_Any_Union {
public var type: MyGame_Example_Any_
- public var value: UnionObject?
- public init(_ v: UnionObject?, type: MyGame_Example_Any_) {
+ public var value: NativeObject?
+ public init(_ v: NativeObject?, type: MyGame_Example_Any_) {
self.type = type
self.value = v
}
public struct MyGame_Example_AnyUniqueAliasesUnion {
public var type: MyGame_Example_AnyUniqueAliases
- public var value: UnionObject?
- public init(_ v: UnionObject?, type: MyGame_Example_AnyUniqueAliases) {
+ public var value: NativeObject?
+ public init(_ v: NativeObject?, type: MyGame_Example_AnyUniqueAliases) {
self.type = type
self.value = v
}
public struct MyGame_Example_AnyAmbiguousAliasesUnion {
public var type: MyGame_Example_AnyAmbiguousAliases
- public var value: UnionObject?
- public init(_ v: UnionObject?, type: MyGame_Example_AnyAmbiguousAliases) {
+ public var value: NativeObject?
+ public init(_ v: NativeObject?, type: MyGame_Example_AnyAmbiguousAliases) {
self.type = type
self.value = v
}
}
}
}
-public struct MyGame_Example_Test: NativeStruct, UnionObject {
+public struct MyGame_Example_Test: NativeStruct, NativeObject {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
}
}
-public struct MyGame_Example_Vec3: NativeStruct, UnionObject {
+public struct MyGame_Example_Vec3: NativeStruct, NativeObject {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
}
}
-public struct MyGame_Example_Ability: NativeStruct, UnionObject {
+public struct MyGame_Example_Ability: NativeStruct, NativeObject {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
}
}
-public struct MyGame_InParentNamespace: FlatBufferObject, ObjectAPI {
+public struct MyGame_InParentNamespace: FlatBufferObject, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
public var __buffer: ByteBuffer! { return _accessor.bb }
}
}
-public class MyGame_InParentNamespaceT: UnionObject {
+public class MyGame_InParentNamespaceT: NativeObject {
public init(_ _t: inout MyGame_InParentNamespace) {
public func serialize() -> ByteBuffer { return serialize(type: MyGame_InParentNamespace.self) }
}
-public struct MyGame_Example2_Monster: FlatBufferObject, ObjectAPI {
+public struct MyGame_Example2_Monster: FlatBufferObject, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
public var __buffer: ByteBuffer! { return _accessor.bb }
}
}
-public class MyGame_Example2_MonsterT: UnionObject {
+public class MyGame_Example2_MonsterT: NativeObject {
public init(_ _t: inout MyGame_Example2_Monster) {
public func serialize() -> ByteBuffer { return serialize(type: MyGame_Example2_Monster.self) }
}
-internal struct MyGame_Example_TestSimpleTableWithEnum: FlatBufferObject, ObjectAPI {
+internal struct MyGame_Example_TestSimpleTableWithEnum: FlatBufferObject, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
internal var __buffer: ByteBuffer! { return _accessor.bb }
}
}
-internal class MyGame_Example_TestSimpleTableWithEnumT: UnionObject {
+internal class MyGame_Example_TestSimpleTableWithEnumT: NativeObject {
internal var color: MyGame_Example_Color
internal func serialize() -> ByteBuffer { return serialize(type: MyGame_Example_TestSimpleTableWithEnum.self) }
}
-public struct MyGame_Example_Stat: FlatBufferObject, ObjectAPI {
+public struct MyGame_Example_Stat: FlatBufferObject, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
public var __buffer: ByteBuffer! { return _accessor.bb }
}
}
-public class MyGame_Example_StatT: UnionObject {
+public class MyGame_Example_StatT: NativeObject {
public var id: String?
public var val: Int64
public func serialize() -> ByteBuffer { return serialize(type: MyGame_Example_Stat.self) }
}
-public struct MyGame_Example_Referrable: FlatBufferObject, ObjectAPI {
+public struct MyGame_Example_Referrable: FlatBufferObject, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
public var __buffer: ByteBuffer! { return _accessor.bb }
}
}
-public class MyGame_Example_ReferrableT: UnionObject {
+public class MyGame_Example_ReferrableT: NativeObject {
public var id: UInt64
}
/// an example documentation comment: "monster object"
-public struct MyGame_Example_Monster: FlatBufferObject, ObjectAPI {
+public struct MyGame_Example_Monster: FlatBufferObject, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
public var __buffer: ByteBuffer! { return _accessor.bb }
}
}
-public class MyGame_Example_MonsterT: UnionObject {
+public class MyGame_Example_MonsterT: NativeObject {
public var pos: MyGame_Example_Vec3?
public var mana: Int16
public func serialize() -> ByteBuffer { return serialize(type: MyGame_Example_Monster.self) }
}
-public struct MyGame_Example_TypeAliases: FlatBufferObject, ObjectAPI {
+public struct MyGame_Example_TypeAliases: FlatBufferObject, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
public var __buffer: ByteBuffer! { return _accessor.bb }
}
}
-public class MyGame_Example_TypeAliasesT: UnionObject {
+public class MyGame_Example_TypeAliasesT: NativeObject {
public var i8: Int8
public var u8: UInt8
public struct CharacterUnion {
public var type: Character
- public var value: UnionObject?
- public init(_ v: UnionObject?, type: Character) {
+ public var value: NativeObject?
+ public init(_ v: NativeObject?, type: Character) {
self.type = type
self.value = v
}
}
}
}
-public struct Rapunzel: NativeStruct, UnionObject {
+public struct Rapunzel: NativeStruct, NativeObject {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
}
}
-public struct BookReader: NativeStruct, UnionObject {
+public struct BookReader: NativeStruct, NativeObject {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
}
}
-public struct Attacker: FlatBufferObject, ObjectAPI {
+public struct Attacker: FlatBufferObject, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
public var __buffer: ByteBuffer! { return _accessor.bb }
}
}
-public class AttackerT: UnionObject {
+public class AttackerT: NativeObject {
public var swordAttackDamage: Int32
public func serialize() -> ByteBuffer { return serialize(type: Attacker.self) }
}
-public struct Movie: FlatBufferObject, ObjectAPI {
+public struct Movie: FlatBufferObject, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_1_12_0() }
public var __buffer: ByteBuffer! { return _accessor.bb }
}
}
-public class MovieT: UnionObject {
+public class MovieT: NativeObject {
public var mainCharacter: CharacterUnion?
public var characters: [CharacterUnion?]