mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-01 12:41:36 +00:00
[Swift] RFC: Switch Swift namespace from public enum to ordinary concat with _ (#6045)
This PR attempts to switch namespace from public enum back to ordinary concat with _ in Swift. This kept style similar with protobuf, but different from other popular style guide in Swift. This is needed because previously, when we do `public enum`, we don't really know when to declare and when to extend (extension). With namespace implementation in this PR, there is no such ambiguity.
This commit is contained in:
@@ -125,18 +125,24 @@ public class BookReaderT: NativeTable {
|
||||
}
|
||||
|
||||
}
|
||||
public func createRapunzel(hairLength: Int32 = 0) -> UnsafeMutableRawPointer {
|
||||
let memory = UnsafeMutableRawPointer.allocate(byteCount: Rapunzel.size, alignment: Rapunzel.alignment)
|
||||
memory.initializeMemory(as: UInt8.self, repeating: 0, count: Rapunzel.size)
|
||||
memory.storeBytes(of: hairLength, toByteOffset: 0, as: Int32.self)
|
||||
return memory
|
||||
extension Rapunzel {
|
||||
public static func createRapunzel(hairLength: Int32 = 0) -> UnsafeMutableRawPointer {
|
||||
let memory = UnsafeMutableRawPointer.allocate(byteCount: Rapunzel.size, alignment: Rapunzel.alignment)
|
||||
memory.initializeMemory(as: UInt8.self, repeating: 0, count: Rapunzel.size)
|
||||
memory.storeBytes(of: hairLength, toByteOffset: 0, as: Int32.self)
|
||||
return memory
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public func createBookReader(booksRead: Int32 = 0) -> UnsafeMutableRawPointer {
|
||||
let memory = UnsafeMutableRawPointer.allocate(byteCount: BookReader.size, alignment: BookReader.alignment)
|
||||
memory.initializeMemory(as: UInt8.self, repeating: 0, count: BookReader.size)
|
||||
memory.storeBytes(of: booksRead, toByteOffset: 0, as: Int32.self)
|
||||
return memory
|
||||
extension BookReader {
|
||||
public static func createBookReader(booksRead: Int32 = 0) -> UnsafeMutableRawPointer {
|
||||
let memory = UnsafeMutableRawPointer.allocate(byteCount: BookReader.size, alignment: BookReader.alignment)
|
||||
memory.initializeMemory(as: UInt8.self, repeating: 0, count: BookReader.size)
|
||||
memory.storeBytes(of: booksRead, toByteOffset: 0, as: Int32.self)
|
||||
return memory
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct Attacker: FlatBufferObject {
|
||||
|
||||
Reference in New Issue
Block a user