2020-11-16 16:52:38 +00:00
|
|
|
/*
|
2023-01-07 00:40:40 +00:00
|
|
|
* Copyright 2023 Google Inc. All rights reserved.
|
2020-11-16 16:52:38 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-05-29 18:56:33 +00:00
|
|
|
#if !os(WASI)
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
import Foundation
|
2022-05-29 18:56:33 +00:00
|
|
|
#else
|
|
|
|
import SwiftOverlayShims
|
|
|
|
#endif
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// `Table` is a Flatbuffers object that can read,
|
|
|
|
/// mutate scalar fields within a valid flatbuffers buffer
|
2021-05-06 04:55:03 +00:00
|
|
|
@frozen
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
public struct Table {
|
2021-05-14 17:59:28 +00:00
|
|
|
|
|
|
|
/// Hosting Bytebuffer
|
2020-11-16 16:52:38 +00:00
|
|
|
public private(set) var bb: ByteBuffer
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Current position of the table within the buffer
|
2020-11-16 16:52:38 +00:00
|
|
|
public private(set) var postion: Int32
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Initializer for the table interface to allow generated code to read
|
|
|
|
/// data from memory
|
|
|
|
/// - Parameters:
|
|
|
|
/// - bb: ByteBuffer that stores data
|
|
|
|
/// - position: Current table position
|
|
|
|
/// - Note: This will `CRASH` if read on a big endian machine
|
2020-11-16 16:52:38 +00:00
|
|
|
public init(bb: ByteBuffer, position: Int32 = 0) {
|
|
|
|
guard isLitteEndian else {
|
2021-09-27 18:59:19 +00:00
|
|
|
fatalError(
|
|
|
|
"Reading/Writing a buffer in big endian machine is not supported on swift")
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
}
|
2020-11-16 16:52:38 +00:00
|
|
|
self.bb = bb
|
|
|
|
postion = position
|
|
|
|
}
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Gets the offset of the current field within the buffer by reading
|
|
|
|
/// the vtable
|
|
|
|
/// - Parameter o: current offset
|
|
|
|
/// - Returns: offset of field within buffer
|
2020-11-16 16:52:38 +00:00
|
|
|
public func offset(_ o: Int32) -> Int32 {
|
|
|
|
let vtable = postion - bb.read(def: Int32.self, position: Int(postion))
|
2021-09-27 18:59:19 +00:00
|
|
|
return o < bb
|
|
|
|
.read(def: VOffset.self, position: Int(vtable)) ? Int32(bb.read(
|
|
|
|
def: Int16.self,
|
|
|
|
position: Int(vtable + o))) : 0
|
2020-11-16 16:52:38 +00:00
|
|
|
}
|
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Gets the indirect offset of the current stored object
|
|
|
|
/// (applicable only for object arrays)
|
|
|
|
/// - Parameter o: current offset
|
|
|
|
/// - Returns: offset of field within buffer
|
|
|
|
public func indirect(_ o: Int32) -> Int32 {
|
|
|
|
o + bb.read(def: Int32.self, position: Int(o))
|
|
|
|
}
|
2020-11-16 16:52:38 +00:00
|
|
|
|
|
|
|
/// String reads from the buffer with respect to position of the current table.
|
|
|
|
/// - Parameter offset: Offset of the string
|
|
|
|
public func string(at offset: Int32) -> String? {
|
|
|
|
directString(at: offset + postion)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Direct string reads from the buffer disregarding the position of the table.
|
2021-05-14 17:59:28 +00:00
|
|
|
/// It would be preferable to use string unless the current position of the table
|
|
|
|
/// is not needed
|
2020-11-16 16:52:38 +00:00
|
|
|
/// - Parameter offset: Offset of the string
|
|
|
|
public func directString(at offset: Int32) -> String? {
|
|
|
|
var offset = offset
|
|
|
|
offset += bb.read(def: Int32.self, position: Int(offset))
|
|
|
|
let count = bb.read(def: Int32.self, position: Int(offset))
|
2021-05-14 17:59:28 +00:00
|
|
|
let position = Int(offset) + MemoryLayout<Int32>.size
|
|
|
|
return bb.readString(at: position, count: Int(count))
|
2020-11-16 16:52:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Reads from the buffer with respect to the position in the table.
|
|
|
|
/// - Parameters:
|
2020-12-17 22:55:32 +00:00
|
|
|
/// - type: Type of Element that needs to be read from the buffer
|
2020-11-16 16:52:38 +00:00
|
|
|
/// - o: Offset of the Element
|
2020-12-17 22:55:32 +00:00
|
|
|
public func readBuffer<T>(of type: T.Type, at o: Int32) -> T {
|
2020-11-16 16:52:38 +00:00
|
|
|
directRead(of: T.self, offset: o + postion)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Reads from the buffer disregarding the position of the table.
|
|
|
|
/// It would be used when reading from an
|
|
|
|
/// ```
|
|
|
|
/// let offset = __t.offset(10)
|
|
|
|
/// //Only used when the we already know what is the
|
|
|
|
/// // position in the table since __t.vector(at:)
|
|
|
|
/// // returns the index with respect to the position
|
|
|
|
/// __t.directRead(of: Byte.self,
|
|
|
|
/// offset: __t.vector(at: offset) + index * 1)
|
|
|
|
/// ```
|
|
|
|
/// - Parameters:
|
2020-12-17 22:55:32 +00:00
|
|
|
/// - type: Type of Element that needs to be read from the buffer
|
2020-11-16 16:52:38 +00:00
|
|
|
/// - o: Offset of the Element
|
2020-12-17 22:55:32 +00:00
|
|
|
public func directRead<T>(of type: T.Type, offset o: Int32) -> T {
|
2020-11-16 16:52:38 +00:00
|
|
|
let r = bb.read(def: T.self, position: Int(o))
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Returns that current `Union` object at a specific offset
|
|
|
|
/// by adding offset to the current position of table
|
|
|
|
/// - Parameter o: offset
|
|
|
|
/// - Returns: A flatbuffers object
|
2021-04-24 11:47:24 +00:00
|
|
|
public func union<T: FlatbuffersInitializable>(_ o: Int32) -> T {
|
2020-11-16 16:52:38 +00:00
|
|
|
let o = o + postion
|
|
|
|
return directUnion(o)
|
|
|
|
}
|
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Returns a direct `Union` object at a specific offset
|
|
|
|
/// - Parameter o: offset
|
|
|
|
/// - Returns: A flatbuffers object
|
2021-04-24 11:47:24 +00:00
|
|
|
public func directUnion<T: FlatbuffersInitializable>(_ o: Int32) -> T {
|
2020-11-16 16:52:38 +00:00
|
|
|
T.init(bb, o: o + bb.read(def: Int32.self, position: Int(o)))
|
|
|
|
}
|
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Returns a vector of type T at a specific offset
|
|
|
|
/// This should only be used by `Scalars`
|
|
|
|
/// - Parameter off: Readable offset
|
|
|
|
/// - Returns: Returns a vector of type [T]
|
2020-11-16 16:52:38 +00:00
|
|
|
public func getVector<T>(at off: Int32) -> [T]? {
|
|
|
|
let o = offset(off)
|
|
|
|
guard o != 0 else { return nil }
|
2021-05-14 17:59:28 +00:00
|
|
|
return bb.readSlice(index: Int(vector(at: o)), count: Int(vector(count: o)))
|
2020-11-16 16:52:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Vector count gets the count of Elements within the array
|
|
|
|
/// - Parameter o: start offset of the vector
|
|
|
|
/// - returns: Count of elements
|
|
|
|
public func vector(count o: Int32) -> Int32 {
|
|
|
|
var o = o
|
|
|
|
o += postion
|
|
|
|
o += bb.read(def: Int32.self, position: Int(o))
|
|
|
|
return bb.read(def: Int32.self, position: Int(o))
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Vector start index in the buffer
|
|
|
|
/// - Parameter o:start offset of the vector
|
|
|
|
/// - returns: the start index of the vector
|
|
|
|
public func vector(at o: Int32) -> Int32 {
|
|
|
|
var o = o
|
|
|
|
o += postion
|
|
|
|
return o + bb.read(def: Int32.self, position: Int(o)) + 4
|
|
|
|
}
|
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Reading an indirect offset of a table.
|
|
|
|
/// - Parameters:
|
|
|
|
/// - o: position within the buffer
|
|
|
|
/// - fbb: ByteBuffer
|
|
|
|
/// - Returns: table offset
|
|
|
|
static public func indirect(_ o: Int32, _ fbb: ByteBuffer) -> Int32 {
|
|
|
|
o + fbb.read(def: Int32.self, position: Int(o))
|
|
|
|
}
|
2020-11-16 16:52:38 +00:00
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Gets a vtable value according to an table Offset and a field offset
|
|
|
|
/// - Parameters:
|
|
|
|
/// - o: offset relative to entire buffer
|
|
|
|
/// - vOffset: Field offset within a vtable
|
|
|
|
/// - fbb: ByteBuffer
|
|
|
|
/// - Returns: an position of a field
|
2021-09-27 18:59:19 +00:00
|
|
|
static public func offset(
|
|
|
|
_ o: Int32,
|
|
|
|
vOffset: Int32,
|
|
|
|
fbb: ByteBuffer) -> Int32
|
|
|
|
{
|
2020-11-16 16:52:38 +00:00
|
|
|
let vTable = Int32(fbb.capacity) - o
|
|
|
|
return vTable + Int32(fbb.read(
|
|
|
|
def: Int16.self,
|
2021-05-14 17:59:28 +00:00
|
|
|
position: Int(vTable + vOffset - fbb.read(
|
|
|
|
def: Int32.self,
|
|
|
|
position: Int(vTable)))))
|
2020-11-16 16:52:38 +00:00
|
|
|
}
|
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Compares two objects at offset A and offset B within a ByteBuffer
|
|
|
|
/// - Parameters:
|
|
|
|
/// - off1: first offset to compare
|
|
|
|
/// - off2: second offset to compare
|
|
|
|
/// - fbb: Bytebuffer
|
|
|
|
/// - Returns: returns the difference between
|
2021-09-27 18:59:19 +00:00
|
|
|
static public func compare(
|
|
|
|
_ off1: Int32,
|
|
|
|
_ off2: Int32,
|
|
|
|
fbb: ByteBuffer) -> Int32
|
|
|
|
{
|
2020-11-16 16:52:38 +00:00
|
|
|
let memorySize = Int32(MemoryLayout<Int32>.size)
|
|
|
|
let _off1 = off1 + fbb.read(def: Int32.self, position: Int(off1))
|
|
|
|
let _off2 = off2 + fbb.read(def: Int32.self, position: Int(off2))
|
|
|
|
let len1 = fbb.read(def: Int32.self, position: Int(_off1))
|
|
|
|
let len2 = fbb.read(def: Int32.self, position: Int(_off2))
|
|
|
|
let startPos1 = _off1 + memorySize
|
|
|
|
let startPos2 = _off2 + memorySize
|
|
|
|
let minValue = min(len1, len2)
|
|
|
|
for i in 0...minValue {
|
|
|
|
let b1 = fbb.read(def: Int8.self, position: Int(i + startPos1))
|
|
|
|
let b2 = fbb.read(def: Int8.self, position: Int(i + startPos2))
|
|
|
|
if b1 != b2 {
|
|
|
|
return Int32(b2 - b1)
|
|
|
|
}
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
}
|
2020-11-16 16:52:38 +00:00
|
|
|
return len1 - len2
|
|
|
|
}
|
|
|
|
|
2021-05-14 17:59:28 +00:00
|
|
|
/// Compares two objects at offset A and array of `Bytes` within a ByteBuffer
|
|
|
|
/// - Parameters:
|
|
|
|
/// - off1: Offset to compare to
|
|
|
|
/// - key: bytes array to compare to
|
|
|
|
/// - fbb: Bytebuffer
|
|
|
|
/// - Returns: returns the difference between
|
2021-09-27 18:59:19 +00:00
|
|
|
static public func compare(
|
|
|
|
_ off1: Int32,
|
|
|
|
_ key: [Byte],
|
|
|
|
fbb: ByteBuffer) -> Int32
|
|
|
|
{
|
2020-11-16 16:52:38 +00:00
|
|
|
let memorySize = Int32(MemoryLayout<Int32>.size)
|
|
|
|
let _off1 = off1 + fbb.read(def: Int32.self, position: Int(off1))
|
|
|
|
let len1 = fbb.read(def: Int32.self, position: Int(_off1))
|
|
|
|
let len2 = Int32(key.count)
|
|
|
|
let startPos1 = _off1 + memorySize
|
|
|
|
let minValue = min(len1, len2)
|
|
|
|
for i in 0..<minValue {
|
|
|
|
let b = fbb.read(def: Int8.self, position: Int(i + startPos1))
|
|
|
|
let byte = key[Int(i)]
|
|
|
|
if b != byte {
|
|
|
|
return Int32(b - Int8(byte))
|
|
|
|
}
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
}
|
2020-11-16 16:52:38 +00:00
|
|
|
return len1 - len2
|
|
|
|
}
|
[Swift] Swift implementation 🎉🎉 (#5603)
* Implemented the swift version of Flatbuffers
Implemented serailzing, reading, and mutating data from object monster
Fixes mis-aligned pointer issue
Fixes issue when shared strings are removed from table
Adds swift enum, structs code gen
Fixed namespace issues + started implementing the table gen
Added Mutate function to the code generator
Generated linux test cases
Fixed an issue with bools, and structs readers in table writer
Swift docker image added
Updated the test cases, and removed a method parameters in swift
Fixed createVector api when called with scalars
Fixed issues with scalar arrays, and fixed the code gen namespaces, added sample_binary.swift
Cleaned up project
Added enum vectors, and their readers
Refactored code
Added swift into the support document
Added documentation in docs, and fixed a small issue with Data() not being returned correctly
Fixes Lowercase issue, and prevents generating lookups for deprecated keys
* Made all the required funcs to have const + removed unneeded code + fix lowercase func
* Removed transform from lowercased and moved it to function
* Fixes an issue with iOS allocation from read
* Refactored cpp code to be more readable
* casts position into int for position
* Fix enums issue, moves scalar writer code to use memcpy
* Removed c_str from struct function
* Fixed script to generate new objects when ran on travis ci: fix
* Handles deallocating space allocated for structs
* Updated the test cases to adhere to the fileprivate lookup, no mutation for unions, and updated the names of the vector functions
2020-01-09 20:12:10 +00:00
|
|
|
}
|