Adds JSON encoding to swift (#6874)

Updates generated code & removes unneeded protocol

Updates cpp to only generate code when flag is passed

Updates code gen script
This commit is contained in:
mustiikhalil
2021-10-07 23:22:22 +02:00
committed by GitHub
parent 38295a1873
commit 4c7a9c10d3
17 changed files with 1324 additions and 20 deletions

View File

@@ -58,7 +58,7 @@ cd ${current_dir}
cd swift
cd Greeter/Sources/Model
fbc --bfbs-filenames ../../../.. --swift ${generator}
fbc --bfbs-filenames ../../../.. --swift --gen-json-emit ${generator}
cd ${current_dir}

View File

@@ -42,6 +42,17 @@ public struct models_HelloReply: FlatBufferObject, Verifiable {
}
}
extension models_HelloReply: Encodable {
enum CodingKeys: String, CodingKey {
case message = "message"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(message, forKey: .message)
}
}
public struct models_HelloRequest: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_2_0_0() }
@@ -80,3 +91,14 @@ public struct models_HelloRequest: FlatBufferObject, Verifiable {
}
}
extension models_HelloRequest: Encodable {
enum CodingKeys: String, CodingKey {
case name = "name"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(name, forKey: .name)
}
}

View File

@@ -0,0 +1,2 @@
export { HelloReply } from './models/hello-reply';
export { HelloRequest } from './models/hello-request';