bulk code format fix (#8707)

This commit is contained in:
Derek Bailey
2025-09-23 21:50:27 -07:00
committed by GitHub
parent 0e047869da
commit caf3b494db
559 changed files with 38871 additions and 31276 deletions

View File

@@ -17,4 +17,4 @@ void Offset64ForceAlign();
} // namespace tests
} // namespace flatbuffers
#endif // TESTS_64BIT_OFFSET64_TEST_H
#endif // TESTS_64BIT_OFFSET64_TEST_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,9 @@
//Generated by flatc compiler (version 2.0.0)
//If you make any local changes, they will be lost
//source: monster_test.fbs
// Generated by flatc compiler (version 2.0.0)
// If you make any local changes, they will be lost
// source: monster_test.fbs
package MyGame.Example;
import com.google.flatbuffers.grpc.FlatbuffersUtils;
import java.nio.ByteBuffer;
import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
@@ -22,446 +19,443 @@ import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler",
comments = "Source: monster_test.fbs")
import com.google.flatbuffers.grpc.FlatbuffersUtils;
import java.nio.ByteBuffer;
/** */
@javax.annotation.Generated(value = "by gRPC proto compiler", comments = "Source: monster_test.fbs")
public final class MonsterStorageGrpc {
private MonsterStorageGrpc() {}
public static final String SERVICE_NAME = "MyGame.Example.MonsterStorage";
// Static method descriptors that strictly reflect the proto.
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
@java.lang.Deprecated // Use {@link #getStoreMethod()} instead.
public static final io.grpc.MethodDescriptor<MyGame.Example.Monster,
MyGame.Example.Stat> METHOD_STORE = getStoreMethod();
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Monster,
MyGame.Example.Stat> getStoreMethod;
@java.lang.Deprecated // Use {@link #getStoreMethod()} instead.
public static final io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
METHOD_STORE = getStoreMethod();
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
getStoreMethod;
private static volatile FlatbuffersUtils.FBExtactor<MyGame.Example.Monster> extractorOfMonster;
private static FlatbuffersUtils.FBExtactor<MyGame.Example.Monster> getExtractorOfMonster() {
if (extractorOfMonster != null) return extractorOfMonster;
synchronized (MonsterStorageGrpc.class) {
if (extractorOfMonster != null) return extractorOfMonster;
synchronized (MonsterStorageGrpc.class) {
if (extractorOfMonster != null) return extractorOfMonster;
extractorOfMonster = new FlatbuffersUtils.FBExtactor<MyGame.Example.Monster>() {
public MyGame.Example.Monster extract (ByteBuffer buffer) {
return MyGame.Example.Monster.getRootAsMonster(buffer);
}
extractorOfMonster =
new FlatbuffersUtils.FBExtactor<MyGame.Example.Monster>() {
public MyGame.Example.Monster extract(ByteBuffer buffer) {
return MyGame.Example.Monster.getRootAsMonster(buffer);
}
};
return extractorOfMonster;
}
return extractorOfMonster;
}
}
private static volatile FlatbuffersUtils.FBExtactor<MyGame.Example.Stat> extractorOfStat;
private static FlatbuffersUtils.FBExtactor<MyGame.Example.Stat> getExtractorOfStat() {
if (extractorOfStat != null) return extractorOfStat;
synchronized (MonsterStorageGrpc.class) {
if (extractorOfStat != null) return extractorOfStat;
synchronized (MonsterStorageGrpc.class) {
if (extractorOfStat != null) return extractorOfStat;
extractorOfStat = new FlatbuffersUtils.FBExtactor<MyGame.Example.Stat>() {
public MyGame.Example.Stat extract (ByteBuffer buffer) {
return MyGame.Example.Stat.getRootAsStat(buffer);
}
extractorOfStat =
new FlatbuffersUtils.FBExtactor<MyGame.Example.Stat>() {
public MyGame.Example.Stat extract(ByteBuffer buffer) {
return MyGame.Example.Stat.getRootAsStat(buffer);
}
};
return extractorOfStat;
}
return extractorOfStat;
}
}
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
public static io.grpc.MethodDescriptor<MyGame.Example.Monster,
MyGame.Example.Stat> getStoreMethod() {
public static io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
getStoreMethod() {
io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat> getStoreMethod;
if ((getStoreMethod = MonsterStorageGrpc.getStoreMethod) == null) {
synchronized (MonsterStorageGrpc.class) {
if ((getStoreMethod = MonsterStorageGrpc.getStoreMethod) == null) {
MonsterStorageGrpc.getStoreMethod = getStoreMethod =
io.grpc.MethodDescriptor.<MyGame.Example.Monster, MyGame.Example.Stat>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(
"MyGame.Example.MonsterStorage", "Store"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(FlatbuffersUtils.marshaller(
MyGame.Example.Monster.class, getExtractorOfMonster()))
.setResponseMarshaller(FlatbuffersUtils.marshaller(
MyGame.Example.Stat.class, getExtractorOfStat()))
.setSchemaDescriptor(null)
.build();
}
MonsterStorageGrpc.getStoreMethod =
getStoreMethod =
io.grpc.MethodDescriptor.<MyGame.Example.Monster, MyGame.Example.Stat>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
generateFullMethodName("MyGame.Example.MonsterStorage", "Store"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
FlatbuffersUtils.marshaller(
MyGame.Example.Monster.class, getExtractorOfMonster()))
.setResponseMarshaller(
FlatbuffersUtils.marshaller(
MyGame.Example.Stat.class, getExtractorOfStat()))
.setSchemaDescriptor(null)
.build();
}
}
return getStoreMethod;
}
}
return getStoreMethod;
}
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
@java.lang.Deprecated // Use {@link #getRetrieveMethod()} instead.
public static final io.grpc.MethodDescriptor<MyGame.Example.Stat,
MyGame.Example.Monster> METHOD_RETRIEVE = getRetrieveMethod();
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Stat,
MyGame.Example.Monster> getRetrieveMethod;
@java.lang.Deprecated // Use {@link #getRetrieveMethod()} instead.
public static final io.grpc.MethodDescriptor<MyGame.Example.Stat, MyGame.Example.Monster>
METHOD_RETRIEVE = getRetrieveMethod();
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Stat, MyGame.Example.Monster>
getRetrieveMethod;
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
public static io.grpc.MethodDescriptor<MyGame.Example.Stat,
MyGame.Example.Monster> getRetrieveMethod() {
public static io.grpc.MethodDescriptor<MyGame.Example.Stat, MyGame.Example.Monster>
getRetrieveMethod() {
io.grpc.MethodDescriptor<MyGame.Example.Stat, MyGame.Example.Monster> getRetrieveMethod;
if ((getRetrieveMethod = MonsterStorageGrpc.getRetrieveMethod) == null) {
synchronized (MonsterStorageGrpc.class) {
if ((getRetrieveMethod = MonsterStorageGrpc.getRetrieveMethod) == null) {
MonsterStorageGrpc.getRetrieveMethod = getRetrieveMethod =
io.grpc.MethodDescriptor.<MyGame.Example.Stat, MyGame.Example.Monster>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
.setFullMethodName(generateFullMethodName(
"MyGame.Example.MonsterStorage", "Retrieve"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(FlatbuffersUtils.marshaller(
MyGame.Example.Stat.class, getExtractorOfStat()))
.setResponseMarshaller(FlatbuffersUtils.marshaller(
MyGame.Example.Monster.class, getExtractorOfMonster()))
.setSchemaDescriptor(null)
.build();
}
MonsterStorageGrpc.getRetrieveMethod =
getRetrieveMethod =
io.grpc.MethodDescriptor.<MyGame.Example.Stat, MyGame.Example.Monster>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
.setFullMethodName(
generateFullMethodName("MyGame.Example.MonsterStorage", "Retrieve"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
FlatbuffersUtils.marshaller(
MyGame.Example.Stat.class, getExtractorOfStat()))
.setResponseMarshaller(
FlatbuffersUtils.marshaller(
MyGame.Example.Monster.class, getExtractorOfMonster()))
.setSchemaDescriptor(null)
.build();
}
}
return getRetrieveMethod;
}
}
return getRetrieveMethod;
}
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
@java.lang.Deprecated // Use {@link #getGetMaxHitPointMethod()} instead.
public static final io.grpc.MethodDescriptor<MyGame.Example.Monster,
MyGame.Example.Stat> METHOD_GET_MAX_HIT_POINT = getGetMaxHitPointMethod();
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Monster,
MyGame.Example.Stat> getGetMaxHitPointMethod;
@java.lang.Deprecated // Use {@link #getGetMaxHitPointMethod()} instead.
public static final io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
METHOD_GET_MAX_HIT_POINT = getGetMaxHitPointMethod();
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
getGetMaxHitPointMethod;
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
public static io.grpc.MethodDescriptor<MyGame.Example.Monster,
MyGame.Example.Stat> getGetMaxHitPointMethod() {
public static io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
getGetMaxHitPointMethod() {
io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat> getGetMaxHitPointMethod;
if ((getGetMaxHitPointMethod = MonsterStorageGrpc.getGetMaxHitPointMethod) == null) {
synchronized (MonsterStorageGrpc.class) {
if ((getGetMaxHitPointMethod = MonsterStorageGrpc.getGetMaxHitPointMethod) == null) {
MonsterStorageGrpc.getGetMaxHitPointMethod = getGetMaxHitPointMethod =
io.grpc.MethodDescriptor.<MyGame.Example.Monster, MyGame.Example.Stat>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
.setFullMethodName(generateFullMethodName(
"MyGame.Example.MonsterStorage", "GetMaxHitPoint"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(FlatbuffersUtils.marshaller(
MyGame.Example.Monster.class, getExtractorOfMonster()))
.setResponseMarshaller(FlatbuffersUtils.marshaller(
MyGame.Example.Stat.class, getExtractorOfStat()))
.setSchemaDescriptor(null)
.build();
}
MonsterStorageGrpc.getGetMaxHitPointMethod =
getGetMaxHitPointMethod =
io.grpc.MethodDescriptor.<MyGame.Example.Monster, MyGame.Example.Stat>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
.setFullMethodName(
generateFullMethodName("MyGame.Example.MonsterStorage", "GetMaxHitPoint"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
FlatbuffersUtils.marshaller(
MyGame.Example.Monster.class, getExtractorOfMonster()))
.setResponseMarshaller(
FlatbuffersUtils.marshaller(
MyGame.Example.Stat.class, getExtractorOfStat()))
.setSchemaDescriptor(null)
.build();
}
}
return getGetMaxHitPointMethod;
}
}
return getGetMaxHitPointMethod;
}
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
@java.lang.Deprecated // Use {@link #getGetMinMaxHitPointsMethod()} instead.
public static final io.grpc.MethodDescriptor<MyGame.Example.Monster,
MyGame.Example.Stat> METHOD_GET_MIN_MAX_HIT_POINTS = getGetMinMaxHitPointsMethod();
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Monster,
MyGame.Example.Stat> getGetMinMaxHitPointsMethod;
@java.lang.Deprecated // Use {@link #getGetMinMaxHitPointsMethod()} instead.
public static final io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
METHOD_GET_MIN_MAX_HIT_POINTS = getGetMinMaxHitPointsMethod();
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
getGetMinMaxHitPointsMethod;
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
public static io.grpc.MethodDescriptor<MyGame.Example.Monster,
MyGame.Example.Stat> getGetMinMaxHitPointsMethod() {
io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat> getGetMinMaxHitPointsMethod;
public static io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
getGetMinMaxHitPointsMethod() {
io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat>
getGetMinMaxHitPointsMethod;
if ((getGetMinMaxHitPointsMethod = MonsterStorageGrpc.getGetMinMaxHitPointsMethod) == null) {
synchronized (MonsterStorageGrpc.class) {
if ((getGetMinMaxHitPointsMethod = MonsterStorageGrpc.getGetMinMaxHitPointsMethod) == null) {
MonsterStorageGrpc.getGetMinMaxHitPointsMethod = getGetMinMaxHitPointsMethod =
io.grpc.MethodDescriptor.<MyGame.Example.Monster, MyGame.Example.Stat>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
.setFullMethodName(generateFullMethodName(
"MyGame.Example.MonsterStorage", "GetMinMaxHitPoints"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(FlatbuffersUtils.marshaller(
MyGame.Example.Monster.class, getExtractorOfMonster()))
.setResponseMarshaller(FlatbuffersUtils.marshaller(
MyGame.Example.Stat.class, getExtractorOfStat()))
.setSchemaDescriptor(null)
.build();
}
if ((getGetMinMaxHitPointsMethod = MonsterStorageGrpc.getGetMinMaxHitPointsMethod)
== null) {
MonsterStorageGrpc.getGetMinMaxHitPointsMethod =
getGetMinMaxHitPointsMethod =
io.grpc.MethodDescriptor.<MyGame.Example.Monster, MyGame.Example.Stat>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
.setFullMethodName(
generateFullMethodName(
"MyGame.Example.MonsterStorage", "GetMinMaxHitPoints"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(
FlatbuffersUtils.marshaller(
MyGame.Example.Monster.class, getExtractorOfMonster()))
.setResponseMarshaller(
FlatbuffersUtils.marshaller(
MyGame.Example.Stat.class, getExtractorOfStat()))
.setSchemaDescriptor(null)
.build();
}
}
return getGetMinMaxHitPointsMethod;
}
}
return getGetMinMaxHitPointsMethod;
}
/**
* Creates a new async stub that supports all call types for the service
*/
/** Creates a new async stub that supports all call types for the service */
public static MonsterStorageStub newStub(io.grpc.Channel channel) {
return new MonsterStorageStub(channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static MonsterStorageBlockingStub newBlockingStub(
io.grpc.Channel channel) {
public static MonsterStorageBlockingStub newBlockingStub(io.grpc.Channel channel) {
return new MonsterStorageBlockingStub(channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary calls on the service
*/
public static MonsterStorageFutureStub newFutureStub(
io.grpc.Channel channel) {
/** Creates a new ListenableFuture-style stub that supports unary calls on the service */
public static MonsterStorageFutureStub newFutureStub(io.grpc.Channel channel) {
return new MonsterStorageFutureStub(channel);
}
/**
*/
public static abstract class MonsterStorageImplBase implements io.grpc.BindableService {
/**
*/
public void store(MyGame.Example.Monster request,
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
/** */
public abstract static class MonsterStorageImplBase implements io.grpc.BindableService {
/** */
public void store(
MyGame.Example.Monster request,
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
asyncUnimplementedUnaryCall(getStoreMethod(), responseObserver);
}
/**
*/
public void retrieve(MyGame.Example.Stat request,
io.grpc.stub.StreamObserver<MyGame.Example.Monster> responseObserver) {
/** */
public void retrieve(
MyGame.Example.Stat request,
io.grpc.stub.StreamObserver<MyGame.Example.Monster> responseObserver) {
asyncUnimplementedUnaryCall(getRetrieveMethod(), responseObserver);
}
/**
*/
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMaxHitPoint(
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
/** */
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMaxHitPoint(
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
return asyncUnimplementedStreamingCall(getGetMaxHitPointMethod(), responseObserver);
}
/**
*/
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMinMaxHitPoints(
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
/** */
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMinMaxHitPoints(
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
return asyncUnimplementedStreamingCall(getGetMinMaxHitPointsMethod(), responseObserver);
}
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
@java.lang.Override
public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getStoreMethod(),
asyncUnaryCall(
new MethodHandlers<
MyGame.Example.Monster,
MyGame.Example.Stat>(
this, METHODID_STORE)))
getStoreMethod(),
asyncUnaryCall(
new MethodHandlers<MyGame.Example.Monster, MyGame.Example.Stat>(
this, METHODID_STORE)))
.addMethod(
getRetrieveMethod(),
asyncServerStreamingCall(
new MethodHandlers<
MyGame.Example.Stat,
MyGame.Example.Monster>(
this, METHODID_RETRIEVE)))
getRetrieveMethod(),
asyncServerStreamingCall(
new MethodHandlers<MyGame.Example.Stat, MyGame.Example.Monster>(
this, METHODID_RETRIEVE)))
.addMethod(
getGetMaxHitPointMethod(),
asyncClientStreamingCall(
new MethodHandlers<
MyGame.Example.Monster,
MyGame.Example.Stat>(
this, METHODID_GET_MAX_HIT_POINT)))
getGetMaxHitPointMethod(),
asyncClientStreamingCall(
new MethodHandlers<MyGame.Example.Monster, MyGame.Example.Stat>(
this, METHODID_GET_MAX_HIT_POINT)))
.addMethod(
getGetMinMaxHitPointsMethod(),
asyncBidiStreamingCall(
new MethodHandlers<
MyGame.Example.Monster,
MyGame.Example.Stat>(
this, METHODID_GET_MIN_MAX_HIT_POINTS)))
getGetMinMaxHitPointsMethod(),
asyncBidiStreamingCall(
new MethodHandlers<MyGame.Example.Monster, MyGame.Example.Stat>(
this, METHODID_GET_MIN_MAX_HIT_POINTS)))
.build();
}
}
/**
*/
public static final class MonsterStorageStub extends io.grpc.stub.AbstractStub<MonsterStorageStub> {
/** */
public static final class MonsterStorageStub
extends io.grpc.stub.AbstractStub<MonsterStorageStub> {
private MonsterStorageStub(io.grpc.Channel channel) {
super(channel);
}
private MonsterStorageStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
private MonsterStorageStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected MonsterStorageStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
protected MonsterStorageStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new MonsterStorageStub(channel, callOptions);
}
/**
*/
public void store(MyGame.Example.Monster request,
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
/** */
public void store(
MyGame.Example.Monster request,
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
asyncUnaryCall(
getChannel().newCall(getStoreMethod(), getCallOptions()), request, responseObserver);
}
/**
*/
public void retrieve(MyGame.Example.Stat request,
io.grpc.stub.StreamObserver<MyGame.Example.Monster> responseObserver) {
/** */
public void retrieve(
MyGame.Example.Stat request,
io.grpc.stub.StreamObserver<MyGame.Example.Monster> responseObserver) {
asyncServerStreamingCall(
getChannel().newCall(getRetrieveMethod(), getCallOptions()), request, responseObserver);
}
/**
*/
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMaxHitPoint(
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
/** */
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMaxHitPoint(
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
return asyncClientStreamingCall(
getChannel().newCall(getGetMaxHitPointMethod(), getCallOptions()), responseObserver);
}
/**
*/
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMinMaxHitPoints(
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
/** */
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMinMaxHitPoints(
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
return asyncBidiStreamingCall(
getChannel().newCall(getGetMinMaxHitPointsMethod(), getCallOptions()), responseObserver);
}
}
/**
*/
public static final class MonsterStorageBlockingStub extends io.grpc.stub.AbstractStub<MonsterStorageBlockingStub> {
/** */
public static final class MonsterStorageBlockingStub
extends io.grpc.stub.AbstractStub<MonsterStorageBlockingStub> {
private MonsterStorageBlockingStub(io.grpc.Channel channel) {
super(channel);
}
private MonsterStorageBlockingStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
private MonsterStorageBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected MonsterStorageBlockingStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
protected MonsterStorageBlockingStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new MonsterStorageBlockingStub(channel, callOptions);
}
/**
*/
public MyGame.Example.Stat store(MyGame.Example.Monster request) {
return blockingUnaryCall(
getChannel(), getStoreMethod(), getCallOptions(), request);
/** */
public MyGame.Example.Stat store(MyGame.Example.Monster request) {
return blockingUnaryCall(getChannel(), getStoreMethod(), getCallOptions(), request);
}
/**
*/
public java.util.Iterator<MyGame.Example.Monster> retrieve(
MyGame.Example.Stat request) {
/** */
public java.util.Iterator<MyGame.Example.Monster> retrieve(MyGame.Example.Stat request) {
return blockingServerStreamingCall(
getChannel(), getRetrieveMethod(), getCallOptions(), request);
}
}
/**
*/
public static final class MonsterStorageFutureStub extends io.grpc.stub.AbstractStub<MonsterStorageFutureStub> {
/** */
public static final class MonsterStorageFutureStub
extends io.grpc.stub.AbstractStub<MonsterStorageFutureStub> {
private MonsterStorageFutureStub(io.grpc.Channel channel) {
super(channel);
}
private MonsterStorageFutureStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
private MonsterStorageFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected MonsterStorageFutureStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
protected MonsterStorageFutureStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new MonsterStorageFutureStub(channel, callOptions);
}
/**
*/
public com.google.common.util.concurrent.ListenableFuture<MyGame.Example.Stat> store(
MyGame.Example.Monster request) {
return futureUnaryCall(
getChannel().newCall(getStoreMethod(), getCallOptions()), request);
/** */
public com.google.common.util.concurrent.ListenableFuture<MyGame.Example.Stat> store(
MyGame.Example.Monster request) {
return futureUnaryCall(getChannel().newCall(getStoreMethod(), getCallOptions()), request);
}
}
private static final int METHODID_STORE = 0;
private static final int METHODID_RETRIEVE = 1;
private static final int METHODID_GET_MIN_MAX_HIT_POINTS = 2;
private static final int METHODID_GET_MAX_HIT_POINT = 3;
private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private static final class MethodHandlers<Req, Resp>
implements io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final MonsterStorageImplBase serviceImpl;
private final int methodId;
MethodHandlers(MonsterStorageImplBase serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_STORE:
serviceImpl.store((MyGame.Example.Monster) request,
serviceImpl.store(
(MyGame.Example.Monster) request,
(io.grpc.stub.StreamObserver<MyGame.Example.Stat>) responseObserver);
break;
case METHODID_RETRIEVE:
serviceImpl.retrieve((MyGame.Example.Stat) request,
serviceImpl.retrieve(
(MyGame.Example.Stat) request,
(io.grpc.stub.StreamObserver<MyGame.Example.Monster>) responseObserver);
break;
default:
throw new AssertionError();
}
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_GET_MAX_HIT_POINT:
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.getMaxHitPoint(
(io.grpc.stub.StreamObserver<MyGame.Example.Stat>) responseObserver);
return (io.grpc.stub.StreamObserver<Req>)
serviceImpl.getMaxHitPoint(
(io.grpc.stub.StreamObserver<MyGame.Example.Stat>) responseObserver);
case METHODID_GET_MIN_MAX_HIT_POINTS:
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.getMinMaxHitPoints(
(io.grpc.stub.StreamObserver<MyGame.Example.Stat>) responseObserver);
return (io.grpc.stub.StreamObserver<Req>)
serviceImpl.getMinMaxHitPoints(
(io.grpc.stub.StreamObserver<MyGame.Example.Stat>) responseObserver);
default:
throw new AssertionError();
}
}
}
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
io.grpc.ServiceDescriptor result = serviceDescriptor;
if (result == null) {
synchronized (MonsterStorageGrpc.class) {
result = serviceDescriptor;
if (result == null) {
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(null)
.addMethod(getStoreMethod())
.addMethod(getRetrieveMethod())
.addMethod(getGetMaxHitPointMethod())
.addMethod(getGetMinMaxHitPointsMethod())
.build();
serviceDescriptor =
result =
io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(null)
.addMethod(getStoreMethod())
.addMethod(getRetrieveMethod())
.addMethod(getGetMaxHitPointMethod())
.addMethod(getGetMinMaxHitPointsMethod())
.build();
}
}
}

View File

@@ -4,11 +4,12 @@ package MyGame.Example
@Suppress("unused")
class TestEnum private constructor() {
companion object {
const val A: Byte = 0
const val B: Byte = 1
const val C: Byte = 2
val names : Array<String> = arrayOf("A", "B", "C")
fun name(e: Int) : String = names[e]
}
companion object {
const val A: Byte = 0
const val B: Byte = 1
const val C: Byte = 2
val names: Array<String> = arrayOf("A", "B", "C")
fun name(e: Int): String = names[e]
}
}

View File

@@ -3,52 +3,44 @@ import grpc
class MonsterStorageStub(object):
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.Store = channel.unary_unary(
'/MyGame.Example.MonsterStorage/Store',
)
)
self.Retrieve = channel.unary_stream(
'/MyGame.Example.MonsterStorage/Retrieve',
)
)
self.GetMaxHitPoint = channel.stream_unary(
'/MyGame.Example.MonsterStorage/GetMaxHitPoint',
)
)
self.GetMinMaxHitPoints = channel.unary_unary(
'/MyGame.Example.MonsterStorage/GetMinMaxHitPoints',
)
)
class MonsterStorageServicer(object):
def Store(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def Retrieve(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def GetMaxHitPoint(self, request_iterator, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def GetMinMaxHitPoints(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
@@ -59,28 +51,23 @@ def add_MonsterStorageServicer_to_server(servicer, server):
rpc_method_handlers = {
'Store': grpc.unary_unary_rpc_method_handler(
servicer.Store,
),
'Retrieve': grpc.unary_stream_rpc_method_handler(
servicer.Retrieve,
),
'GetMaxHitPoint': grpc.stream_unary_rpc_method_handler(
servicer.GetMaxHitPoint,
),
'GetMinMaxHitPoints': grpc.unary_unary_rpc_method_handler(
servicer.GetMinMaxHitPoints,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'MyGame.Example.MonsterStorage', rpc_method_handlers)
'MyGame.Example.MonsterStorage', rpc_method_handlers
)
server.add_generic_rpc_handlers((generic_handler,))
try:
# THESE ELEMENTS WILL BE DEPRECATED.
# Please use the generated *_pb2_grpc.py files instead.
@@ -89,153 +76,212 @@ try:
from grpc.beta import interfaces as beta_interfaces
from grpc.framework.common import cardinality
from grpc.framework.interfaces.face import utilities as face_utilities
class MonsterStorageStub(object):
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.Store = channel.unary_unary(
'/MyGame.Example.MonsterStorage/Store',
)
)
self.Retrieve = channel.unary_stream(
'/MyGame.Example.MonsterStorage/Retrieve',
)
)
self.GetMaxHitPoint = channel.stream_unary(
'/MyGame.Example.MonsterStorage/GetMaxHitPoint',
)
)
self.GetMinMaxHitPoints = channel.unary_unary(
'/MyGame.Example.MonsterStorage/GetMinMaxHitPoints',
)
)
class MonsterStorageServicer(object):
def Store(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def Retrieve(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def GetMaxHitPoint(self, request_iterator, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def GetMinMaxHitPoints(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def add_MonsterStorageServicer_to_server(servicer, server):
rpc_method_handlers = {
'Store': grpc.unary_unary_rpc_method_handler(
servicer.Store,
),
'Retrieve': grpc.unary_stream_rpc_method_handler(
servicer.Retrieve,
),
'GetMaxHitPoint': grpc.stream_unary_rpc_method_handler(
servicer.GetMaxHitPoint,
),
'GetMinMaxHitPoints': grpc.unary_unary_rpc_method_handler(
servicer.GetMinMaxHitPoints,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'MyGame.Example.MonsterStorage', rpc_method_handlers)
'MyGame.Example.MonsterStorage', rpc_method_handlers
)
server.add_generic_rpc_handlers((generic_handler,))
class BetaMonsterStorageServicer(object):
"""The Beta API is deprecated for 0.15.0 and later.
It is recommended to use the GA API (classes and functions in this
file not marked beta) for all further purposes. This class was generated
only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0."""
only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.
"""
def Store(self, request, context):
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
def Retrieve(self, request, context):
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
def GetMaxHitPoint(self, request_iterator, context):
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
def GetMinMaxHitPoints(self, request, context):
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
class BetaMonsterStorageStub(object):
"""The Beta API is deprecated for 0.15.0 and later.
It is recommended to use the GA API (classes and functions in this
file not marked beta) for all further purposes. This class was generated
only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0."""
def Store(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.
"""
def Store(
self,
request,
timeout,
metadata=None,
with_call=False,
protocol_options=None,
):
raise NotImplementedError()
Store.future = None
def Retrieve(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
def Retrieve(
self,
request,
timeout,
metadata=None,
with_call=False,
protocol_options=None,
):
raise NotImplementedError()
def GetMaxHitPoint(self, request_iterator, timeout, metadata=None, with_call=False, protocol_options=None):
def GetMaxHitPoint(
self,
request_iterator,
timeout,
metadata=None,
with_call=False,
protocol_options=None,
):
raise NotImplementedError()
GetMaxHitPoint.future = None
def GetMinMaxHitPoints(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
def GetMinMaxHitPoints(
self,
request,
timeout,
metadata=None,
with_call=False,
protocol_options=None,
):
raise NotImplementedError()
GetMinMaxHitPoints.future = None
def beta_create_MonsterStorage_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None):
def beta_create_MonsterStorage_server(
servicer,
pool=None,
pool_size=None,
default_timeout=None,
maximum_timeout=None,
):
"""The Beta API is deprecated for 0.15.0 and later.
It is recommended to use the GA API (classes and functions in this
file not marked beta) for all further purposes. This function was
generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0"""
generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0
"""
method_implementations = {
('MyGame.Example.MonsterStorage', 'GetMaxHitPoint'): face_utilities.stream_unary_inline(servicer.GetMaxHitPoint),
('MyGame.Example.MonsterStorage', 'GetMinMaxHitPoints'): face_utilities.unary_unary_inline(servicer.GetMinMaxHitPoints),
('MyGame.Example.MonsterStorage', 'Retrieve'): face_utilities.unary_stream_inline(servicer.Retrieve),
('MyGame.Example.MonsterStorage', 'Store'): face_utilities.unary_unary_inline(servicer.Store),
(
'MyGame.Example.MonsterStorage',
'GetMaxHitPoint',
): face_utilities.stream_unary_inline(servicer.GetMaxHitPoint),
(
'MyGame.Example.MonsterStorage',
'GetMinMaxHitPoints',
): face_utilities.unary_unary_inline(servicer.GetMinMaxHitPoints),
(
'MyGame.Example.MonsterStorage',
'Retrieve',
): face_utilities.unary_stream_inline(servicer.Retrieve),
(
'MyGame.Example.MonsterStorage',
'Store',
): face_utilities.unary_unary_inline(servicer.Store),
}
server_options = beta_implementations.server_options(thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout)
return beta_implementations.server(method_implementations, options=server_options)
def beta_create_MonsterStorage_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None):
server_options = beta_implementations.server_options(
thread_pool=pool,
thread_pool_size=pool_size,
default_timeout=default_timeout,
maximum_timeout=maximum_timeout,
)
return beta_implementations.server(
method_implementations, options=server_options
)
def beta_create_MonsterStorage_stub(
channel, host=None, metadata_transformer=None, pool=None, pool_size=None
):
"""The Beta API is deprecated for 0.15.0 and later.
It is recommended to use the GA API (classes and functions in this
file not marked beta) for all further purposes. This function was
generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0"""
generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0
"""
cardinalities = {
'GetMaxHitPoint': cardinality.Cardinality.STREAM_UNARY,
'GetMinMaxHitPoints': cardinality.Cardinality.UNARY_UNARY,
'Retrieve': cardinality.Cardinality.UNARY_STREAM,
'Store': cardinality.Cardinality.UNARY_UNARY,
'GetMaxHitPoint': cardinality.Cardinality.STREAM_UNARY,
'GetMinMaxHitPoints': cardinality.Cardinality.UNARY_UNARY,
'Retrieve': cardinality.Cardinality.UNARY_STREAM,
'Store': cardinality.Cardinality.UNARY_UNARY,
}
stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, thread_pool=pool, thread_pool_size=pool_size)
return beta_implementations.dynamic_stub(channel, 'MyGame.Example.MonsterStorage', cardinalities, options=stub_options)
stub_options = beta_implementations.stub_options(
host=host,
metadata_transformer=metadata_transformer,
thread_pool=pool,
thread_pool_size=pool_size,
)
return beta_implementations.dynamic_stub(
channel,
'MyGame.Example.MonsterStorage',
cardinalities,
options=stub_options,
)
except ImportError:
pass
pass

View File

@@ -2,21 +2,22 @@
package MyGame.OtherNameSpace;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
public class TableBT {
private TableAT a;
public TableAT getA() { return a; }
public void setA(TableAT a) { this.a = a; }
public TableAT getA() {
return a;
}
public void setA(TableAT a) {
this.a = a;
}
public TableBT() {
this.a = null;
}
}

View File

@@ -2,21 +2,22 @@
package MyGame.OtherNameSpace;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
public class UnusedT {
private int a;
public int getA() { return a; }
public void setA(int a) { this.a = a; }
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
public UnusedT() {
this.a = 0;
}
}

View File

@@ -11,7 +11,9 @@ type PizzaT struct {
}
func (t *PizzaT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
if t == nil {
return 0
}
PizzaStart(builder)
PizzaAddSize(builder, t.Size)
return PizzaEnd(builder)
@@ -22,7 +24,9 @@ func (rcv *Pizza) UnPackTo(t *PizzaT) {
}
func (rcv *Pizza) UnPack() *PizzaT {
if rcv == nil { return nil }
if rcv == nil {
return nil
}
t := &PizzaT{}
rcv.UnPackTo(t)
return t

View File

@@ -1,20 +1,21 @@
// automatically generated by the FlatBuffers compiler, do not modify
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
public class TableAT {
private MyGame.OtherNameSpace.TableBT b;
public MyGame.OtherNameSpace.TableBT getB() { return b; }
public void setB(MyGame.OtherNameSpace.TableBT b) { this.b = b; }
public MyGame.OtherNameSpace.TableBT getB() {
return b;
}
public void setB(MyGame.OtherNameSpace.TableBT b) {
this.b = b;
}
public TableAT() {
this.b = null;
}
}

View File

@@ -14,9 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pathlib import Path
import platform
import subprocess
from pathlib import Path
# Get the path where this script is located so we can invoke the script from
# any directory and have the paths work correctly.
@@ -33,7 +33,7 @@ flatc_exe = Path(
# Find and assert flatc compiler is present.
if root_path in flatc_exe.parents:
flatc_exe = flatc_exe.relative_to(root_path)
flatc_exe = flatc_exe.relative_to(root_path)
flatc_path = Path(root_path, flatc_exe)
assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
@@ -42,8 +42,8 @@ tests_path = Path(script_path, "tests")
def flatc_annotate(schema, file, cwd=script_path):
cmd = [str(flatc_path), "--annotate", schema, file]
result = subprocess.run(cmd, cwd=str(cwd), check=True)
cmd = [str(flatc_path), "--annotate", schema, file]
result = subprocess.run(cmd, cwd=str(cwd), check=True)
test_files = [
@@ -73,4 +73,4 @@ test_files = [
]
for test_file in test_files:
flatc_annotate("annotated_binary.fbs", test_file)
flatc_annotate("annotated_binary.fbs", test_file)

View File

@@ -1,6 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_OPTIONALSCALARS2_OPTIONAL_SCALARS_H_
#define FLATBUFFERS_GENERATED_OPTIONALSCALARS2_OPTIONAL_SCALARS_H_
@@ -12,7 +11,7 @@ struct ScalarStuff;
struct ScalarStuffBuilder;
struct ScalarStuffT;
inline const flatbuffers::TypeTable *ScalarStuffTypeTable();
inline const flatbuffers::TypeTable* ScalarStuffTypeTable();
enum class OptionalByte : int8_t {
None = 0,
@@ -23,26 +22,19 @@ enum class OptionalByte : int8_t {
};
inline const OptionalByte (&EnumValuesOptionalByte())[3] {
static const OptionalByte values[] = {
OptionalByte::None,
OptionalByte::One,
OptionalByte::Two
};
static const OptionalByte values[] = {OptionalByte::None, OptionalByte::One,
OptionalByte::Two};
return values;
}
inline const char * const *EnumNamesOptionalByte() {
static const char * const names[4] = {
"None",
"One",
"Two",
nullptr
};
inline const char* const* EnumNamesOptionalByte() {
static const char* const names[4] = {"None", "One", "Two", nullptr};
return names;
}
inline const char *EnumNameOptionalByte(OptionalByte e) {
if (flatbuffers::IsOutRange(e, OptionalByte::None, OptionalByte::Two)) return "";
inline const char* EnumNameOptionalByte(OptionalByte e) {
if (flatbuffers::IsOutRange(e, OptionalByte::None, OptionalByte::Two))
return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesOptionalByte()[index];
}
@@ -82,16 +74,19 @@ struct ScalarStuffT : public flatbuffers::NativeTable {
bool just_bool = false;
flatbuffers::Optional<bool> maybe_bool = flatbuffers::nullopt;
bool default_bool = true;
optional_scalars::OptionalByte just_enum = optional_scalars::OptionalByte::None;
flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum = flatbuffers::nullopt;
optional_scalars::OptionalByte default_enum = optional_scalars::OptionalByte::One;
optional_scalars::OptionalByte just_enum =
optional_scalars::OptionalByte::None;
flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum =
flatbuffers::nullopt;
optional_scalars::OptionalByte default_enum =
optional_scalars::OptionalByte::One;
};
struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef ScalarStuffT NativeTableType;
typedef ScalarStuffBuilder Builder;
struct Traits;
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
static const flatbuffers::TypeTable* MiniReflectTypeTable() {
return ScalarStuffTypeTable();
}
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
@@ -132,9 +127,7 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_MAYBE_ENUM = 72,
VT_DEFAULT_ENUM = 74
};
int8_t just_i8() const {
return GetField<int8_t>(VT_JUST_I8, 0);
}
int8_t just_i8() const { return GetField<int8_t>(VT_JUST_I8, 0); }
bool mutate_just_i8(int8_t _just_i8) {
return SetField<int8_t>(VT_JUST_I8, _just_i8, 0);
}
@@ -144,15 +137,11 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_maybe_i8(int8_t _maybe_i8) {
return SetField<int8_t>(VT_MAYBE_I8, _maybe_i8);
}
int8_t default_i8() const {
return GetField<int8_t>(VT_DEFAULT_I8, 42);
}
int8_t default_i8() const { return GetField<int8_t>(VT_DEFAULT_I8, 42); }
bool mutate_default_i8(int8_t _default_i8) {
return SetField<int8_t>(VT_DEFAULT_I8, _default_i8, 42);
}
uint8_t just_u8() const {
return GetField<uint8_t>(VT_JUST_U8, 0);
}
uint8_t just_u8() const { return GetField<uint8_t>(VT_JUST_U8, 0); }
bool mutate_just_u8(uint8_t _just_u8) {
return SetField<uint8_t>(VT_JUST_U8, _just_u8, 0);
}
@@ -162,15 +151,11 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_maybe_u8(uint8_t _maybe_u8) {
return SetField<uint8_t>(VT_MAYBE_U8, _maybe_u8);
}
uint8_t default_u8() const {
return GetField<uint8_t>(VT_DEFAULT_U8, 42);
}
uint8_t default_u8() const { return GetField<uint8_t>(VT_DEFAULT_U8, 42); }
bool mutate_default_u8(uint8_t _default_u8) {
return SetField<uint8_t>(VT_DEFAULT_U8, _default_u8, 42);
}
int16_t just_i16() const {
return GetField<int16_t>(VT_JUST_I16, 0);
}
int16_t just_i16() const { return GetField<int16_t>(VT_JUST_I16, 0); }
bool mutate_just_i16(int16_t _just_i16) {
return SetField<int16_t>(VT_JUST_I16, _just_i16, 0);
}
@@ -180,15 +165,11 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_maybe_i16(int16_t _maybe_i16) {
return SetField<int16_t>(VT_MAYBE_I16, _maybe_i16);
}
int16_t default_i16() const {
return GetField<int16_t>(VT_DEFAULT_I16, 42);
}
int16_t default_i16() const { return GetField<int16_t>(VT_DEFAULT_I16, 42); }
bool mutate_default_i16(int16_t _default_i16) {
return SetField<int16_t>(VT_DEFAULT_I16, _default_i16, 42);
}
uint16_t just_u16() const {
return GetField<uint16_t>(VT_JUST_U16, 0);
}
uint16_t just_u16() const { return GetField<uint16_t>(VT_JUST_U16, 0); }
bool mutate_just_u16(uint16_t _just_u16) {
return SetField<uint16_t>(VT_JUST_U16, _just_u16, 0);
}
@@ -204,9 +185,7 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_default_u16(uint16_t _default_u16) {
return SetField<uint16_t>(VT_DEFAULT_U16, _default_u16, 42);
}
int32_t just_i32() const {
return GetField<int32_t>(VT_JUST_I32, 0);
}
int32_t just_i32() const { return GetField<int32_t>(VT_JUST_I32, 0); }
bool mutate_just_i32(int32_t _just_i32) {
return SetField<int32_t>(VT_JUST_I32, _just_i32, 0);
}
@@ -216,15 +195,11 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_maybe_i32(int32_t _maybe_i32) {
return SetField<int32_t>(VT_MAYBE_I32, _maybe_i32);
}
int32_t default_i32() const {
return GetField<int32_t>(VT_DEFAULT_I32, 42);
}
int32_t default_i32() const { return GetField<int32_t>(VT_DEFAULT_I32, 42); }
bool mutate_default_i32(int32_t _default_i32) {
return SetField<int32_t>(VT_DEFAULT_I32, _default_i32, 42);
}
uint32_t just_u32() const {
return GetField<uint32_t>(VT_JUST_U32, 0);
}
uint32_t just_u32() const { return GetField<uint32_t>(VT_JUST_U32, 0); }
bool mutate_just_u32(uint32_t _just_u32) {
return SetField<uint32_t>(VT_JUST_U32, _just_u32, 0);
}
@@ -240,9 +215,7 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_default_u32(uint32_t _default_u32) {
return SetField<uint32_t>(VT_DEFAULT_U32, _default_u32, 42);
}
int64_t just_i64() const {
return GetField<int64_t>(VT_JUST_I64, 0);
}
int64_t just_i64() const { return GetField<int64_t>(VT_JUST_I64, 0); }
bool mutate_just_i64(int64_t _just_i64) {
return SetField<int64_t>(VT_JUST_I64, _just_i64, 0);
}
@@ -258,9 +231,7 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_default_i64(int64_t _default_i64) {
return SetField<int64_t>(VT_DEFAULT_I64, _default_i64, 42LL);
}
uint64_t just_u64() const {
return GetField<uint64_t>(VT_JUST_U64, 0);
}
uint64_t just_u64() const { return GetField<uint64_t>(VT_JUST_U64, 0); }
bool mutate_just_u64(uint64_t _just_u64) {
return SetField<uint64_t>(VT_JUST_U64, _just_u64, 0);
}
@@ -276,9 +247,7 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_default_u64(uint64_t _default_u64) {
return SetField<uint64_t>(VT_DEFAULT_U64, _default_u64, 42ULL);
}
float just_f32() const {
return GetField<float>(VT_JUST_F32, 0.0f);
}
float just_f32() const { return GetField<float>(VT_JUST_F32, 0.0f); }
bool mutate_just_f32(float _just_f32) {
return SetField<float>(VT_JUST_F32, _just_f32, 0.0f);
}
@@ -288,15 +257,11 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_maybe_f32(float _maybe_f32) {
return SetField<float>(VT_MAYBE_F32, _maybe_f32);
}
float default_f32() const {
return GetField<float>(VT_DEFAULT_F32, 42.0f);
}
float default_f32() const { return GetField<float>(VT_DEFAULT_F32, 42.0f); }
bool mutate_default_f32(float _default_f32) {
return SetField<float>(VT_DEFAULT_F32, _default_f32, 42.0f);
}
double just_f64() const {
return GetField<double>(VT_JUST_F64, 0.0);
}
double just_f64() const { return GetField<double>(VT_JUST_F64, 0.0); }
bool mutate_just_f64(double _just_f64) {
return SetField<double>(VT_JUST_F64, _just_f64, 0.0);
}
@@ -306,15 +271,11 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
bool mutate_maybe_f64(double _maybe_f64) {
return SetField<double>(VT_MAYBE_F64, _maybe_f64);
}
double default_f64() const {
return GetField<double>(VT_DEFAULT_F64, 42.0);
}
double default_f64() const { return GetField<double>(VT_DEFAULT_F64, 42.0); }
bool mutate_default_f64(double _default_f64) {
return SetField<double>(VT_DEFAULT_F64, _default_f64, 42.0);
}
bool just_bool() const {
return GetField<uint8_t>(VT_JUST_BOOL, 0) != 0;
}
bool just_bool() const { return GetField<uint8_t>(VT_JUST_BOOL, 0) != 0; }
bool mutate_just_bool(bool _just_bool) {
return SetField<uint8_t>(VT_JUST_BOOL, static_cast<uint8_t>(_just_bool), 0);
}
@@ -328,10 +289,12 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
return GetField<uint8_t>(VT_DEFAULT_BOOL, 1) != 0;
}
bool mutate_default_bool(bool _default_bool) {
return SetField<uint8_t>(VT_DEFAULT_BOOL, static_cast<uint8_t>(_default_bool), 1);
return SetField<uint8_t>(VT_DEFAULT_BOOL,
static_cast<uint8_t>(_default_bool), 1);
}
optional_scalars::OptionalByte just_enum() const {
return static_cast<optional_scalars::OptionalByte>(GetField<int8_t>(VT_JUST_ENUM, 0));
return static_cast<optional_scalars::OptionalByte>(
GetField<int8_t>(VT_JUST_ENUM, 0));
}
bool mutate_just_enum(optional_scalars::OptionalByte _just_enum) {
return SetField<int8_t>(VT_JUST_ENUM, static_cast<int8_t>(_just_enum), 0);
@@ -343,12 +306,14 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
return SetField<int8_t>(VT_MAYBE_ENUM, static_cast<int8_t>(_maybe_enum));
}
optional_scalars::OptionalByte default_enum() const {
return static_cast<optional_scalars::OptionalByte>(GetField<int8_t>(VT_DEFAULT_ENUM, 1));
return static_cast<optional_scalars::OptionalByte>(
GetField<int8_t>(VT_DEFAULT_ENUM, 1));
}
bool mutate_default_enum(optional_scalars::OptionalByte _default_enum) {
return SetField<int8_t>(VT_DEFAULT_ENUM, static_cast<int8_t>(_default_enum), 1);
return SetField<int8_t>(VT_DEFAULT_ENUM, static_cast<int8_t>(_default_enum),
1);
}
bool Verify(flatbuffers::Verifier &verifier) const {
bool Verify(flatbuffers::Verifier& verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<int8_t>(verifier, VT_JUST_I8) &&
VerifyField<int8_t>(verifier, VT_MAYBE_I8) &&
@@ -388,14 +353,19 @@ struct ScalarStuff FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VerifyField<int8_t>(verifier, VT_DEFAULT_ENUM) &&
verifier.EndTable();
}
ScalarStuffT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
void UnPackTo(ScalarStuffT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
static flatbuffers::Offset<ScalarStuff> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ScalarStuffT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
ScalarStuffT* UnPack(
const flatbuffers::resolver_function_t* _resolver = nullptr) const;
void UnPackTo(
ScalarStuffT* _o,
const flatbuffers::resolver_function_t* _resolver = nullptr) const;
static flatbuffers::Offset<ScalarStuff> Pack(
flatbuffers::FlatBufferBuilder& _fbb, const ScalarStuffT* _o,
const flatbuffers::rehasher_function_t* _rehasher = nullptr);
};
struct ScalarStuffBuilder {
typedef ScalarStuff Table;
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::FlatBufferBuilder& fbb_;
flatbuffers::uoffset_t start_;
void add_just_i8(int8_t just_i8) {
fbb_.AddElement<int8_t>(ScalarStuff::VT_JUST_I8, just_i8, 0);
@@ -488,25 +458,31 @@ struct ScalarStuffBuilder {
fbb_.AddElement<double>(ScalarStuff::VT_DEFAULT_F64, default_f64, 42.0);
}
void add_just_bool(bool just_bool) {
fbb_.AddElement<uint8_t>(ScalarStuff::VT_JUST_BOOL, static_cast<uint8_t>(just_bool), 0);
fbb_.AddElement<uint8_t>(ScalarStuff::VT_JUST_BOOL,
static_cast<uint8_t>(just_bool), 0);
}
void add_maybe_bool(bool maybe_bool) {
fbb_.AddElement<uint8_t>(ScalarStuff::VT_MAYBE_BOOL, static_cast<uint8_t>(maybe_bool));
fbb_.AddElement<uint8_t>(ScalarStuff::VT_MAYBE_BOOL,
static_cast<uint8_t>(maybe_bool));
}
void add_default_bool(bool default_bool) {
fbb_.AddElement<uint8_t>(ScalarStuff::VT_DEFAULT_BOOL, static_cast<uint8_t>(default_bool), 1);
fbb_.AddElement<uint8_t>(ScalarStuff::VT_DEFAULT_BOOL,
static_cast<uint8_t>(default_bool), 1);
}
void add_just_enum(optional_scalars::OptionalByte just_enum) {
fbb_.AddElement<int8_t>(ScalarStuff::VT_JUST_ENUM, static_cast<int8_t>(just_enum), 0);
fbb_.AddElement<int8_t>(ScalarStuff::VT_JUST_ENUM,
static_cast<int8_t>(just_enum), 0);
}
void add_maybe_enum(optional_scalars::OptionalByte maybe_enum) {
fbb_.AddElement<int8_t>(ScalarStuff::VT_MAYBE_ENUM, static_cast<int8_t>(maybe_enum));
fbb_.AddElement<int8_t>(ScalarStuff::VT_MAYBE_ENUM,
static_cast<int8_t>(maybe_enum));
}
void add_default_enum(optional_scalars::OptionalByte default_enum) {
fbb_.AddElement<int8_t>(ScalarStuff::VT_DEFAULT_ENUM, static_cast<int8_t>(default_enum), 1);
fbb_.AddElement<int8_t>(ScalarStuff::VT_DEFAULT_ENUM,
static_cast<int8_t>(default_enum), 1);
}
explicit ScalarStuffBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
explicit ScalarStuffBuilder(flatbuffers::FlatBufferBuilder& _fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
flatbuffers::Offset<ScalarStuff> Finish() {
@@ -517,79 +493,95 @@ struct ScalarStuffBuilder {
};
inline flatbuffers::Offset<ScalarStuff> CreateScalarStuff(
flatbuffers::FlatBufferBuilder &_fbb,
int8_t just_i8 = 0,
flatbuffers::FlatBufferBuilder& _fbb, int8_t just_i8 = 0,
flatbuffers::Optional<int8_t> maybe_i8 = flatbuffers::nullopt,
int8_t default_i8 = 42,
uint8_t just_u8 = 0,
int8_t default_i8 = 42, uint8_t just_u8 = 0,
flatbuffers::Optional<uint8_t> maybe_u8 = flatbuffers::nullopt,
uint8_t default_u8 = 42,
int16_t just_i16 = 0,
uint8_t default_u8 = 42, int16_t just_i16 = 0,
flatbuffers::Optional<int16_t> maybe_i16 = flatbuffers::nullopt,
int16_t default_i16 = 42,
uint16_t just_u16 = 0,
int16_t default_i16 = 42, uint16_t just_u16 = 0,
flatbuffers::Optional<uint16_t> maybe_u16 = flatbuffers::nullopt,
uint16_t default_u16 = 42,
int32_t just_i32 = 0,
uint16_t default_u16 = 42, int32_t just_i32 = 0,
flatbuffers::Optional<int32_t> maybe_i32 = flatbuffers::nullopt,
int32_t default_i32 = 42,
uint32_t just_u32 = 0,
int32_t default_i32 = 42, uint32_t just_u32 = 0,
flatbuffers::Optional<uint32_t> maybe_u32 = flatbuffers::nullopt,
uint32_t default_u32 = 42,
int64_t just_i64 = 0,
uint32_t default_u32 = 42, int64_t just_i64 = 0,
flatbuffers::Optional<int64_t> maybe_i64 = flatbuffers::nullopt,
int64_t default_i64 = 42LL,
uint64_t just_u64 = 0,
int64_t default_i64 = 42LL, uint64_t just_u64 = 0,
flatbuffers::Optional<uint64_t> maybe_u64 = flatbuffers::nullopt,
uint64_t default_u64 = 42ULL,
float just_f32 = 0.0f,
uint64_t default_u64 = 42ULL, float just_f32 = 0.0f,
flatbuffers::Optional<float> maybe_f32 = flatbuffers::nullopt,
float default_f32 = 42.0f,
double just_f64 = 0.0,
float default_f32 = 42.0f, double just_f64 = 0.0,
flatbuffers::Optional<double> maybe_f64 = flatbuffers::nullopt,
double default_f64 = 42.0,
bool just_bool = false,
double default_f64 = 42.0, bool just_bool = false,
flatbuffers::Optional<bool> maybe_bool = flatbuffers::nullopt,
bool default_bool = true,
optional_scalars::OptionalByte just_enum = optional_scalars::OptionalByte::None,
flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum = flatbuffers::nullopt,
optional_scalars::OptionalByte default_enum = optional_scalars::OptionalByte::One) {
optional_scalars::OptionalByte just_enum =
optional_scalars::OptionalByte::None,
flatbuffers::Optional<optional_scalars::OptionalByte> maybe_enum =
flatbuffers::nullopt,
optional_scalars::OptionalByte default_enum =
optional_scalars::OptionalByte::One) {
ScalarStuffBuilder builder_(_fbb);
builder_.add_default_f64(default_f64);
if(maybe_f64) { builder_.add_maybe_f64(*maybe_f64); }
if (maybe_f64) {
builder_.add_maybe_f64(*maybe_f64);
}
builder_.add_just_f64(just_f64);
builder_.add_default_u64(default_u64);
if(maybe_u64) { builder_.add_maybe_u64(*maybe_u64); }
if (maybe_u64) {
builder_.add_maybe_u64(*maybe_u64);
}
builder_.add_just_u64(just_u64);
builder_.add_default_i64(default_i64);
if(maybe_i64) { builder_.add_maybe_i64(*maybe_i64); }
if (maybe_i64) {
builder_.add_maybe_i64(*maybe_i64);
}
builder_.add_just_i64(just_i64);
builder_.add_default_f32(default_f32);
if(maybe_f32) { builder_.add_maybe_f32(*maybe_f32); }
if (maybe_f32) {
builder_.add_maybe_f32(*maybe_f32);
}
builder_.add_just_f32(just_f32);
builder_.add_default_u32(default_u32);
if(maybe_u32) { builder_.add_maybe_u32(*maybe_u32); }
if (maybe_u32) {
builder_.add_maybe_u32(*maybe_u32);
}
builder_.add_just_u32(just_u32);
builder_.add_default_i32(default_i32);
if(maybe_i32) { builder_.add_maybe_i32(*maybe_i32); }
if (maybe_i32) {
builder_.add_maybe_i32(*maybe_i32);
}
builder_.add_just_i32(just_i32);
builder_.add_default_u16(default_u16);
if(maybe_u16) { builder_.add_maybe_u16(*maybe_u16); }
if (maybe_u16) {
builder_.add_maybe_u16(*maybe_u16);
}
builder_.add_just_u16(just_u16);
builder_.add_default_i16(default_i16);
if(maybe_i16) { builder_.add_maybe_i16(*maybe_i16); }
if (maybe_i16) {
builder_.add_maybe_i16(*maybe_i16);
}
builder_.add_just_i16(just_i16);
builder_.add_default_enum(default_enum);
if(maybe_enum) { builder_.add_maybe_enum(*maybe_enum); }
if (maybe_enum) {
builder_.add_maybe_enum(*maybe_enum);
}
builder_.add_just_enum(just_enum);
builder_.add_default_bool(default_bool);
if(maybe_bool) { builder_.add_maybe_bool(*maybe_bool); }
if (maybe_bool) {
builder_.add_maybe_bool(*maybe_bool);
}
builder_.add_just_bool(just_bool);
builder_.add_default_u8(default_u8);
if(maybe_u8) { builder_.add_maybe_u8(*maybe_u8); }
if (maybe_u8) {
builder_.add_maybe_u8(*maybe_u8);
}
builder_.add_just_u8(just_u8);
builder_.add_default_i8(default_i8);
if(maybe_i8) { builder_.add_maybe_i8(*maybe_i8); }
if (maybe_i8) {
builder_.add_maybe_i8(*maybe_i8);
}
builder_.add_just_i8(just_i8);
return builder_.Finish();
}
@@ -599,63 +591,184 @@ struct ScalarStuff::Traits {
static auto constexpr Create = CreateScalarStuff;
};
flatbuffers::Offset<ScalarStuff> CreateScalarStuff(flatbuffers::FlatBufferBuilder &_fbb, const ScalarStuffT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
flatbuffers::Offset<ScalarStuff> CreateScalarStuff(
flatbuffers::FlatBufferBuilder& _fbb, const ScalarStuffT* _o,
const flatbuffers::rehasher_function_t* _rehasher = nullptr);
inline ScalarStuffT *ScalarStuff::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
inline ScalarStuffT* ScalarStuff::UnPack(
const flatbuffers::resolver_function_t* _resolver) const {
auto _o = std::make_unique<ScalarStuffT>();
UnPackTo(_o.get(), _resolver);
return _o.release();
}
inline void ScalarStuff::UnPackTo(ScalarStuffT *_o, const flatbuffers::resolver_function_t *_resolver) const {
inline void ScalarStuff::UnPackTo(
ScalarStuffT* _o, const flatbuffers::resolver_function_t* _resolver) const {
(void)_o;
(void)_resolver;
{ auto _e = just_i8(); _o->just_i8 = _e; }
{ auto _e = maybe_i8(); _o->maybe_i8 = _e; }
{ auto _e = default_i8(); _o->default_i8 = _e; }
{ auto _e = just_u8(); _o->just_u8 = _e; }
{ auto _e = maybe_u8(); _o->maybe_u8 = _e; }
{ auto _e = default_u8(); _o->default_u8 = _e; }
{ auto _e = just_i16(); _o->just_i16 = _e; }
{ auto _e = maybe_i16(); _o->maybe_i16 = _e; }
{ auto _e = default_i16(); _o->default_i16 = _e; }
{ auto _e = just_u16(); _o->just_u16 = _e; }
{ auto _e = maybe_u16(); _o->maybe_u16 = _e; }
{ auto _e = default_u16(); _o->default_u16 = _e; }
{ auto _e = just_i32(); _o->just_i32 = _e; }
{ auto _e = maybe_i32(); _o->maybe_i32 = _e; }
{ auto _e = default_i32(); _o->default_i32 = _e; }
{ auto _e = just_u32(); _o->just_u32 = _e; }
{ auto _e = maybe_u32(); _o->maybe_u32 = _e; }
{ auto _e = default_u32(); _o->default_u32 = _e; }
{ auto _e = just_i64(); _o->just_i64 = _e; }
{ auto _e = maybe_i64(); _o->maybe_i64 = _e; }
{ auto _e = default_i64(); _o->default_i64 = _e; }
{ auto _e = just_u64(); _o->just_u64 = _e; }
{ auto _e = maybe_u64(); _o->maybe_u64 = _e; }
{ auto _e = default_u64(); _o->default_u64 = _e; }
{ auto _e = just_f32(); _o->just_f32 = _e; }
{ auto _e = maybe_f32(); _o->maybe_f32 = _e; }
{ auto _e = default_f32(); _o->default_f32 = _e; }
{ auto _e = just_f64(); _o->just_f64 = _e; }
{ auto _e = maybe_f64(); _o->maybe_f64 = _e; }
{ auto _e = default_f64(); _o->default_f64 = _e; }
{ auto _e = just_bool(); _o->just_bool = _e; }
{ auto _e = maybe_bool(); _o->maybe_bool = _e; }
{ auto _e = default_bool(); _o->default_bool = _e; }
{ auto _e = just_enum(); _o->just_enum = _e; }
{ auto _e = maybe_enum(); _o->maybe_enum = _e; }
{ auto _e = default_enum(); _o->default_enum = _e; }
{
auto _e = just_i8();
_o->just_i8 = _e;
}
{
auto _e = maybe_i8();
_o->maybe_i8 = _e;
}
{
auto _e = default_i8();
_o->default_i8 = _e;
}
{
auto _e = just_u8();
_o->just_u8 = _e;
}
{
auto _e = maybe_u8();
_o->maybe_u8 = _e;
}
{
auto _e = default_u8();
_o->default_u8 = _e;
}
{
auto _e = just_i16();
_o->just_i16 = _e;
}
{
auto _e = maybe_i16();
_o->maybe_i16 = _e;
}
{
auto _e = default_i16();
_o->default_i16 = _e;
}
{
auto _e = just_u16();
_o->just_u16 = _e;
}
{
auto _e = maybe_u16();
_o->maybe_u16 = _e;
}
{
auto _e = default_u16();
_o->default_u16 = _e;
}
{
auto _e = just_i32();
_o->just_i32 = _e;
}
{
auto _e = maybe_i32();
_o->maybe_i32 = _e;
}
{
auto _e = default_i32();
_o->default_i32 = _e;
}
{
auto _e = just_u32();
_o->just_u32 = _e;
}
{
auto _e = maybe_u32();
_o->maybe_u32 = _e;
}
{
auto _e = default_u32();
_o->default_u32 = _e;
}
{
auto _e = just_i64();
_o->just_i64 = _e;
}
{
auto _e = maybe_i64();
_o->maybe_i64 = _e;
}
{
auto _e = default_i64();
_o->default_i64 = _e;
}
{
auto _e = just_u64();
_o->just_u64 = _e;
}
{
auto _e = maybe_u64();
_o->maybe_u64 = _e;
}
{
auto _e = default_u64();
_o->default_u64 = _e;
}
{
auto _e = just_f32();
_o->just_f32 = _e;
}
{
auto _e = maybe_f32();
_o->maybe_f32 = _e;
}
{
auto _e = default_f32();
_o->default_f32 = _e;
}
{
auto _e = just_f64();
_o->just_f64 = _e;
}
{
auto _e = maybe_f64();
_o->maybe_f64 = _e;
}
{
auto _e = default_f64();
_o->default_f64 = _e;
}
{
auto _e = just_bool();
_o->just_bool = _e;
}
{
auto _e = maybe_bool();
_o->maybe_bool = _e;
}
{
auto _e = default_bool();
_o->default_bool = _e;
}
{
auto _e = just_enum();
_o->just_enum = _e;
}
{
auto _e = maybe_enum();
_o->maybe_enum = _e;
}
{
auto _e = default_enum();
_o->default_enum = _e;
}
}
inline flatbuffers::Offset<ScalarStuff> ScalarStuff::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ScalarStuffT* _o, const flatbuffers::rehasher_function_t *_rehasher) {
inline flatbuffers::Offset<ScalarStuff> ScalarStuff::Pack(
flatbuffers::FlatBufferBuilder& _fbb, const ScalarStuffT* _o,
const flatbuffers::rehasher_function_t* _rehasher) {
return CreateScalarStuff(_fbb, _o, _rehasher);
}
inline flatbuffers::Offset<ScalarStuff> CreateScalarStuff(flatbuffers::FlatBufferBuilder &_fbb, const ScalarStuffT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
inline flatbuffers::Offset<ScalarStuff> CreateScalarStuff(
flatbuffers::FlatBufferBuilder& _fbb, const ScalarStuffT* _o,
const flatbuffers::rehasher_function_t* _rehasher) {
(void)_rehasher;
(void)_o;
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ScalarStuffT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
struct _VectorArgs {
flatbuffers::FlatBufferBuilder* __fbb;
const ScalarStuffT* __o;
const flatbuffers::rehasher_function_t* __rehasher;
} _va = {&_fbb, _o, _rehasher};
(void)_va;
auto _just_i8 = _o->just_i8;
auto _maybe_i8 = _o->maybe_i8;
auto _default_i8 = _o->default_i8;
@@ -693,208 +806,125 @@ inline flatbuffers::Offset<ScalarStuff> CreateScalarStuff(flatbuffers::FlatBuffe
auto _maybe_enum = _o->maybe_enum;
auto _default_enum = _o->default_enum;
return optional_scalars::CreateScalarStuff(
_fbb,
_just_i8,
_maybe_i8,
_default_i8,
_just_u8,
_maybe_u8,
_default_u8,
_just_i16,
_maybe_i16,
_default_i16,
_just_u16,
_maybe_u16,
_default_u16,
_just_i32,
_maybe_i32,
_default_i32,
_just_u32,
_maybe_u32,
_default_u32,
_just_i64,
_maybe_i64,
_default_i64,
_just_u64,
_maybe_u64,
_default_u64,
_just_f32,
_maybe_f32,
_default_f32,
_just_f64,
_maybe_f64,
_default_f64,
_just_bool,
_maybe_bool,
_default_bool,
_just_enum,
_maybe_enum,
_fbb, _just_i8, _maybe_i8, _default_i8, _just_u8, _maybe_u8, _default_u8,
_just_i16, _maybe_i16, _default_i16, _just_u16, _maybe_u16, _default_u16,
_just_i32, _maybe_i32, _default_i32, _just_u32, _maybe_u32, _default_u32,
_just_i64, _maybe_i64, _default_i64, _just_u64, _maybe_u64, _default_u64,
_just_f32, _maybe_f32, _default_f32, _just_f64, _maybe_f64, _default_f64,
_just_bool, _maybe_bool, _default_bool, _just_enum, _maybe_enum,
_default_enum);
}
inline const flatbuffers::TypeTable *OptionalByteTypeTable() {
inline const flatbuffers::TypeTable* OptionalByteTypeTable() {
static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_CHAR, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 0 }
};
{flatbuffers::ET_CHAR, 0, 0},
{flatbuffers::ET_CHAR, 0, 0},
{flatbuffers::ET_CHAR, 0, 0}};
static const flatbuffers::TypeFunction type_refs[] = {
optional_scalars::OptionalByteTypeTable
};
static const char * const names[] = {
"None",
"One",
"Two"
};
optional_scalars::OptionalByteTypeTable};
static const char* const names[] = {"None", "One", "Two"};
static const flatbuffers::TypeTable tt = {
flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, nullptr, names
};
flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, nullptr, names};
return &tt;
}
inline const flatbuffers::TypeTable *ScalarStuffTypeTable() {
inline const flatbuffers::TypeTable* ScalarStuffTypeTable() {
static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_CHAR, 0, -1 },
{ flatbuffers::ET_CHAR, 0, -1 },
{ flatbuffers::ET_CHAR, 0, -1 },
{ flatbuffers::ET_UCHAR, 0, -1 },
{ flatbuffers::ET_UCHAR, 0, -1 },
{ flatbuffers::ET_UCHAR, 0, -1 },
{ flatbuffers::ET_SHORT, 0, -1 },
{ flatbuffers::ET_SHORT, 0, -1 },
{ flatbuffers::ET_SHORT, 0, -1 },
{ flatbuffers::ET_USHORT, 0, -1 },
{ flatbuffers::ET_USHORT, 0, -1 },
{ flatbuffers::ET_USHORT, 0, -1 },
{ flatbuffers::ET_INT, 0, -1 },
{ flatbuffers::ET_INT, 0, -1 },
{ flatbuffers::ET_INT, 0, -1 },
{ flatbuffers::ET_UINT, 0, -1 },
{ flatbuffers::ET_UINT, 0, -1 },
{ flatbuffers::ET_UINT, 0, -1 },
{ flatbuffers::ET_LONG, 0, -1 },
{ flatbuffers::ET_LONG, 0, -1 },
{ flatbuffers::ET_LONG, 0, -1 },
{ flatbuffers::ET_ULONG, 0, -1 },
{ flatbuffers::ET_ULONG, 0, -1 },
{ flatbuffers::ET_ULONG, 0, -1 },
{ flatbuffers::ET_FLOAT, 0, -1 },
{ flatbuffers::ET_FLOAT, 0, -1 },
{ flatbuffers::ET_FLOAT, 0, -1 },
{ flatbuffers::ET_DOUBLE, 0, -1 },
{ flatbuffers::ET_DOUBLE, 0, -1 },
{ flatbuffers::ET_DOUBLE, 0, -1 },
{ flatbuffers::ET_BOOL, 0, -1 },
{ flatbuffers::ET_BOOL, 0, -1 },
{ flatbuffers::ET_BOOL, 0, -1 },
{ flatbuffers::ET_CHAR, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 0 }
};
{flatbuffers::ET_CHAR, 0, -1}, {flatbuffers::ET_CHAR, 0, -1},
{flatbuffers::ET_CHAR, 0, -1}, {flatbuffers::ET_UCHAR, 0, -1},
{flatbuffers::ET_UCHAR, 0, -1}, {flatbuffers::ET_UCHAR, 0, -1},
{flatbuffers::ET_SHORT, 0, -1}, {flatbuffers::ET_SHORT, 0, -1},
{flatbuffers::ET_SHORT, 0, -1}, {flatbuffers::ET_USHORT, 0, -1},
{flatbuffers::ET_USHORT, 0, -1}, {flatbuffers::ET_USHORT, 0, -1},
{flatbuffers::ET_INT, 0, -1}, {flatbuffers::ET_INT, 0, -1},
{flatbuffers::ET_INT, 0, -1}, {flatbuffers::ET_UINT, 0, -1},
{flatbuffers::ET_UINT, 0, -1}, {flatbuffers::ET_UINT, 0, -1},
{flatbuffers::ET_LONG, 0, -1}, {flatbuffers::ET_LONG, 0, -1},
{flatbuffers::ET_LONG, 0, -1}, {flatbuffers::ET_ULONG, 0, -1},
{flatbuffers::ET_ULONG, 0, -1}, {flatbuffers::ET_ULONG, 0, -1},
{flatbuffers::ET_FLOAT, 0, -1}, {flatbuffers::ET_FLOAT, 0, -1},
{flatbuffers::ET_FLOAT, 0, -1}, {flatbuffers::ET_DOUBLE, 0, -1},
{flatbuffers::ET_DOUBLE, 0, -1}, {flatbuffers::ET_DOUBLE, 0, -1},
{flatbuffers::ET_BOOL, 0, -1}, {flatbuffers::ET_BOOL, 0, -1},
{flatbuffers::ET_BOOL, 0, -1}, {flatbuffers::ET_CHAR, 0, 0},
{flatbuffers::ET_CHAR, 0, 0}, {flatbuffers::ET_CHAR, 0, 0}};
static const flatbuffers::TypeFunction type_refs[] = {
optional_scalars::OptionalByteTypeTable
};
static const char * const names[] = {
"just_i8",
"maybe_i8",
"default_i8",
"just_u8",
"maybe_u8",
"default_u8",
"just_i16",
"maybe_i16",
"default_i16",
"just_u16",
"maybe_u16",
"default_u16",
"just_i32",
"maybe_i32",
"default_i32",
"just_u32",
"maybe_u32",
"default_u32",
"just_i64",
"maybe_i64",
"default_i64",
"just_u64",
"maybe_u64",
"default_u64",
"just_f32",
"maybe_f32",
"default_f32",
"just_f64",
"maybe_f64",
"default_f64",
"just_bool",
"maybe_bool",
"default_bool",
"just_enum",
"maybe_enum",
"default_enum"
};
static const flatbuffers::TypeTable tt = {
flatbuffers::ST_TABLE, 36, type_codes, type_refs, nullptr, nullptr, names
};
optional_scalars::OptionalByteTypeTable};
static const char* const names[] = {
"just_i8", "maybe_i8", "default_i8", "just_u8",
"maybe_u8", "default_u8", "just_i16", "maybe_i16",
"default_i16", "just_u16", "maybe_u16", "default_u16",
"just_i32", "maybe_i32", "default_i32", "just_u32",
"maybe_u32", "default_u32", "just_i64", "maybe_i64",
"default_i64", "just_u64", "maybe_u64", "default_u64",
"just_f32", "maybe_f32", "default_f32", "just_f64",
"maybe_f64", "default_f64", "just_bool", "maybe_bool",
"default_bool", "just_enum", "maybe_enum", "default_enum"};
static const flatbuffers::TypeTable tt = {flatbuffers::ST_TABLE,
36,
type_codes,
type_refs,
nullptr,
nullptr,
names};
return &tt;
}
inline const optional_scalars::ScalarStuff *GetScalarStuff(const void *buf) {
inline const optional_scalars::ScalarStuff* GetScalarStuff(const void* buf) {
return flatbuffers::GetRoot<optional_scalars::ScalarStuff>(buf);
}
inline const optional_scalars::ScalarStuff *GetSizePrefixedScalarStuff(const void *buf) {
inline const optional_scalars::ScalarStuff* GetSizePrefixedScalarStuff(
const void* buf) {
return flatbuffers::GetSizePrefixedRoot<optional_scalars::ScalarStuff>(buf);
}
inline ScalarStuff *GetMutableScalarStuff(void *buf) {
inline ScalarStuff* GetMutableScalarStuff(void* buf) {
return flatbuffers::GetMutableRoot<ScalarStuff>(buf);
}
inline const char *ScalarStuffIdentifier() {
return "NULL";
inline const char* ScalarStuffIdentifier() { return "NULL"; }
inline bool ScalarStuffBufferHasIdentifier(const void* buf) {
return flatbuffers::BufferHasIdentifier(buf, ScalarStuffIdentifier());
}
inline bool ScalarStuffBufferHasIdentifier(const void *buf) {
return flatbuffers::BufferHasIdentifier(
buf, ScalarStuffIdentifier());
}
inline bool VerifyScalarStuffBuffer(
flatbuffers::Verifier &verifier) {
return verifier.VerifyBuffer<optional_scalars::ScalarStuff>(ScalarStuffIdentifier());
inline bool VerifyScalarStuffBuffer(flatbuffers::Verifier& verifier) {
return verifier.VerifyBuffer<optional_scalars::ScalarStuff>(
ScalarStuffIdentifier());
}
inline bool VerifySizePrefixedScalarStuffBuffer(
flatbuffers::Verifier &verifier) {
return verifier.VerifySizePrefixedBuffer<optional_scalars::ScalarStuff>(ScalarStuffIdentifier());
flatbuffers::Verifier& verifier) {
return verifier.VerifySizePrefixedBuffer<optional_scalars::ScalarStuff>(
ScalarStuffIdentifier());
}
inline const char *ScalarStuffExtension() {
return "mon";
}
inline const char* ScalarStuffExtension() { return "mon"; }
inline void FinishScalarStuffBuffer(
flatbuffers::FlatBufferBuilder &fbb,
flatbuffers::FlatBufferBuilder& fbb,
flatbuffers::Offset<optional_scalars::ScalarStuff> root) {
fbb.Finish(root, ScalarStuffIdentifier());
}
inline void FinishSizePrefixedScalarStuffBuffer(
flatbuffers::FlatBufferBuilder &fbb,
flatbuffers::FlatBufferBuilder& fbb,
flatbuffers::Offset<optional_scalars::ScalarStuff> root) {
fbb.FinishSizePrefixed(root, ScalarStuffIdentifier());
}
inline std::unique_ptr<optional_scalars::ScalarStuffT> UnPackScalarStuff(
const void *buf,
const flatbuffers::resolver_function_t *res = nullptr) {
return std::unique_ptr<optional_scalars::ScalarStuffT>(GetScalarStuff(buf)->UnPack(res));
const void* buf, const flatbuffers::resolver_function_t* res = nullptr) {
return std::unique_ptr<optional_scalars::ScalarStuffT>(
GetScalarStuff(buf)->UnPack(res));
}
inline std::unique_ptr<optional_scalars::ScalarStuffT> UnPackSizePrefixedScalarStuff(
const void *buf,
const flatbuffers::resolver_function_t *res = nullptr) {
return std::unique_ptr<optional_scalars::ScalarStuffT>(GetSizePrefixedScalarStuff(buf)->UnPack(res));
inline std::unique_ptr<optional_scalars::ScalarStuffT>
UnPackSizePrefixedScalarStuff(
const void* buf, const flatbuffers::resolver_function_t* res = nullptr) {
return std::unique_ptr<optional_scalars::ScalarStuffT>(
GetSizePrefixedScalarStuff(buf)->UnPack(res));
}
} // namespace optional_scalars

View File

@@ -32,57 +32,60 @@
namespace cpp17 {
// User calls this; need to forward declare it since it is called recursively.
template<typename T>
template <typename T>
std::optional<std::string> StringifyFlatbufferValue(
T &&val, const std::string &indent = "");
T&& val, const std::string& indent = "");
namespace detail {
/*******************************************************************************
** Metaprogramming helpers for detecting Flatbuffers Tables, Structs, & Vectors.
*******************************************************************************/
template<typename FBS, typename = void>
template <typename FBS, typename = void>
struct is_flatbuffers_table_or_struct : std::false_type {};
// We know it's a table or struct when it has a Traits subclass.
template<typename FBS>
template <typename FBS>
struct is_flatbuffers_table_or_struct<FBS, std::void_t<typename FBS::Traits>>
: std::true_type {};
template<typename FBS>
template <typename FBS>
inline constexpr bool is_flatbuffers_table_or_struct_v =
is_flatbuffers_table_or_struct<FBS>::value;
template<typename T> struct is_flatbuffers_vector : std::false_type {};
template <typename T>
struct is_flatbuffers_vector : std::false_type {};
template<typename T>
template <typename T>
struct is_flatbuffers_vector<flatbuffers::Vector<T>> : std::true_type {};
template<typename T>
template <typename T>
inline constexpr bool is_flatbuffers_vector_v = is_flatbuffers_vector<T>::value;
/*******************************************************************************
** Compile-time Iteration & Recursive Stringification over Flatbuffers types.
*******************************************************************************/
template<size_t Index, typename FBS>
std::string AddStringifiedField(const FBS &fbs, const std::string &indent) {
template <size_t Index, typename FBS>
std::string AddStringifiedField(const FBS& fbs, const std::string& indent) {
auto value_string =
StringifyFlatbufferValue(fbs.template get_field<Index>(), indent);
if (!value_string) { return ""; }
if (!value_string) {
return "";
}
return indent + FBS::Traits::field_names[Index] + " = " + *value_string +
"\n";
}
template<typename FBS, size_t... Indexes>
std::string StringifyTableOrStructImpl(const FBS &fbs,
const std::string &indent,
template <typename FBS, size_t... Indexes>
std::string StringifyTableOrStructImpl(const FBS& fbs,
const std::string& indent,
std::index_sequence<Indexes...>) {
// This line is where the compile-time iteration happens!
return (AddStringifiedField<Indexes>(fbs, indent) + ...);
}
template<typename FBS>
std::string StringifyTableOrStruct(const FBS &fbs, const std::string &indent) {
template <typename FBS>
std::string StringifyTableOrStruct(const FBS& fbs, const std::string& indent) {
(void)fbs;
(void)indent;
static constexpr size_t field_count = FBS::Traits::fields_number;
@@ -96,9 +99,9 @@ std::string StringifyTableOrStruct(const FBS &fbs, const std::string &indent) {
return out;
}
template<typename T>
std::string StringifyVector(const flatbuffers::Vector<T> &vec,
const std::string &indent) {
template <typename T>
std::string StringifyVector(const flatbuffers::Vector<T>& vec,
const std::string& indent) {
const auto prologue = indent + std::string(" ");
const auto epilogue = std::string(",\n");
std::string text;
@@ -115,7 +118,8 @@ std::string StringifyVector(const flatbuffers::Vector<T> &vec,
return text;
}
template<typename T> std::string StringifyArithmeticType(T val) {
template <typename T>
std::string StringifyArithmeticType(T val) {
return flatbuffers::NumToString(val);
}
@@ -124,9 +128,9 @@ template<typename T> std::string StringifyArithmeticType(T val) {
/*******************************************************************************
** Take any flatbuffer type (table, struct, Vector, int...) and stringify it.
*******************************************************************************/
template<typename T>
std::optional<std::string> StringifyFlatbufferValue(T &&val,
const std::string &indent) {
template <typename T>
std::optional<std::string> StringifyFlatbufferValue(T&& val,
const std::string& indent) {
(void)indent;
constexpr bool is_pointer = std::is_pointer_v<std::remove_reference_t<T>>;
if constexpr (is_pointer) {

View File

@@ -6,9 +6,9 @@
namespace flatbuffers {
namespace tests {
void EvolutionTest(const std::string &tests_data_path);
void EvolutionTest(const std::string& tests_data_path);
void ConformTest();
void UnionDeprecationTest(const std::string &tests_data_path);
void UnionDeprecationTest(const std::string& tests_data_path);
} // namespace tests
} // namespace flatbuffers

View File

@@ -16,239 +16,246 @@ from flatc_test import *
class CppTests:
def Flatten(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "foo.fbs"])
# Foo should be generated in place and include bar flatten
assert_file_and_contents("foo_generated.h", '#include "bar_generated.h"')
def Flatten(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "foo.fbs"])
def FlattenAbsolutePath(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", make_absolute("foo.fbs")])
# Foo should be generated in place and include bar flatten
assert_file_and_contents("foo_generated.h", '#include "bar_generated.h"')
# Foo should be generated in place and include bar flatten
assert_file_and_contents("foo_generated.h", '#include "bar_generated.h"')
def FlattenAbsolutePath(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", make_absolute("foo.fbs")])
def FlattenSubDirectory(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "bar/bar.fbs"])
# Foo should be generated in place and include bar flatten
assert_file_and_contents("foo_generated.h", '#include "bar_generated.h"')
# Bar should be generated in place and include baz
assert_file_and_contents("bar_generated.h", '#include "baz_generated.h"')
def FlattenSubDirectory(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "bar/bar.fbs"])
def FlattenOutPath(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "-o", ".tmp", "foo.fbs"])
# Bar should be generated in place and include baz
assert_file_and_contents("bar_generated.h", '#include "baz_generated.h"')
# Foo should be generated in the out path and include bar flatten to the out path.
assert_file_and_contents(".tmp/foo_generated.h", '#include "bar_generated.h"')
def FlattenOutPath(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "-o", ".tmp", "foo.fbs"])
def FlattenOutPathSuperDirectory(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "-o", "../.tmp", "foo.fbs"])
# Foo should be generated in the out path and include bar flatten to the out path.
assert_file_and_contents(
".tmp/foo_generated.h", '#include "bar_generated.h"'
)
# Foo should be generated in the out path and include bar flatten to the out path.
assert_file_and_contents(
"../.tmp/foo_generated.h", '#include "bar_generated.h"'
)
def FlattenOutPathSuperDirectory(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "-o", "../.tmp", "foo.fbs"])
def FlattenOutPathSubDirectory(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "-o", ".tmp", "bar/bar.fbs"])
# Foo should be generated in the out path and include bar flatten to the out path.
assert_file_and_contents(
"../.tmp/foo_generated.h", '#include "bar_generated.h"'
)
# Bar should be generated in the out path and include baz flatten to the out path.
assert_file_and_contents(".tmp/bar_generated.h", '#include "baz_generated.h"')
def FlattenOutPathSubDirectory(self):
# Generate just foo with a "flatten" import of bar.
flatc(["--cpp", "-o", ".tmp", "bar/bar.fbs"])
def KeepPrefix(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "foo.fbs"])
# Bar should be generated in the out path and include baz flatten to the out path.
assert_file_and_contents(
".tmp/bar_generated.h", '#include "baz_generated.h"'
)
assert_file_and_contents("foo_generated.h", '#include "bar/bar_generated.h"')
def KeepPrefix(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "foo.fbs"])
def KeepPrefixAbsolutePath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", make_absolute("foo.fbs")])
assert_file_and_contents(
"foo_generated.h", '#include "bar/bar_generated.h"'
)
assert_file_and_contents("foo_generated.h", '#include "bar/bar_generated.h"')
def KeepPrefixAbsolutePath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", make_absolute("foo.fbs")])
def KeepPrefixSubDirectory(self):
# Generate with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "bar/bar.fbs"])
assert_file_and_contents(
"foo_generated.h", '#include "bar/bar_generated.h"'
)
assert_file_and_contents("bar_generated.h", '#include "baz/baz_generated.h"')
def KeepPrefixSubDirectory(self):
# Generate with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "bar/bar.fbs"])
def KeepPrefixOutPath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "-o", ".tmp", "foo.fbs"])
assert_file_and_contents(
"bar_generated.h", '#include "baz/baz_generated.h"'
)
assert_file_and_contents(
".tmp/foo_generated.h",
'#include "bar/bar_generated.h"',
)
def KeepPrefixOutPath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "-o", ".tmp", "foo.fbs"])
def KeepPrefixOutPathSubDirectory(self):
# Generate with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "-o", ".tmp", "bar/bar.fbs"])
assert_file_and_contents(
".tmp/foo_generated.h",
'#include "bar/bar_generated.h"',
)
assert_file_and_contents(
".tmp/bar_generated.h", '#include "baz/baz_generated.h"'
)
def KeepPrefixOutPathSubDirectory(self):
# Generate with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "-o", ".tmp", "bar/bar.fbs"])
def IncludePrefix(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", "foo.fbs"])
assert_file_and_contents(
".tmp/bar_generated.h", '#include "baz/baz_generated.h"'
)
assert_file_and_contents("foo_generated.h", '#include "test/bar_generated.h"')
def IncludePrefix(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", "foo.fbs"])
def IncludePrefixAbolutePath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", make_absolute("foo.fbs")])
assert_file_and_contents(
"foo_generated.h", '#include "test/bar_generated.h"'
)
assert_file_and_contents("foo_generated.h", '#include "test/bar_generated.h"')
def IncludePrefixAbolutePath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", make_absolute("foo.fbs")])
def IncludePrefixSubDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", "bar/bar.fbs"])
assert_file_and_contents(
"foo_generated.h", '#include "test/bar_generated.h"'
)
assert_file_and_contents("bar_generated.h", '#include "test/baz_generated.h"')
def IncludePrefixSubDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", "bar/bar.fbs"])
def IncludePrefixOutPath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", "-o", ".tmp", "foo.fbs"])
assert_file_and_contents(
"bar_generated.h", '#include "test/baz_generated.h"'
)
assert_file_and_contents(
".tmp/foo_generated.h", '#include "test/bar_generated.h"'
)
def IncludePrefixOutPath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", "-o", ".tmp", "foo.fbs"])
def IncludePrefixOutPathSubDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", "-o", ".tmp", "bar/bar.fbs"])
assert_file_and_contents(
".tmp/foo_generated.h", '#include "test/bar_generated.h"'
)
assert_file_and_contents(
".tmp/bar_generated.h", '#include "test/baz_generated.h"'
)
def IncludePrefixOutPathSubDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--include-prefix", "test", "-o", ".tmp", "bar/bar.fbs"])
def KeepPrefixIncludePrefix(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "--include-prefix", "test", "foo.fbs"])
assert_file_and_contents(
".tmp/bar_generated.h", '#include "test/baz_generated.h"'
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
"foo_generated.h", '#include "test/bar/bar_generated.h"'
)
def KeepPrefixIncludePrefix(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "--include-prefix", "test", "foo.fbs"])
def KeepPrefixIncludePrefixAbsolutePath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(
[
"--cpp",
"--keep-prefix",
"--include-prefix",
"test",
make_absolute("foo.fbs"),
]
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
"foo_generated.h", '#include "test/bar/bar_generated.h"'
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
"foo_generated.h", '#include "test/bar/bar_generated.h"'
)
def KeepPrefixIncludePrefixAbsolutePath(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc([
"--cpp",
"--keep-prefix",
"--include-prefix",
"test",
make_absolute("foo.fbs"),
])
def KeepPrefixIncludePrefixSubDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "--include-prefix", "test", "bar/bar.fbs"])
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
"foo_generated.h", '#include "test/bar/bar_generated.h"'
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
"bar_generated.h", '#include "test/baz/baz_generated.h"'
)
def KeepPrefixIncludePrefixSubDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(["--cpp", "--keep-prefix", "--include-prefix", "test", "bar/bar.fbs"])
def KeepPrefixIncludePrefixOutPathSubDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(
[
"--cpp",
"--keep-prefix",
"--include-prefix",
"test",
"-o",
".tmp",
"bar/bar.fbs",
]
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
"bar_generated.h", '#include "test/baz/baz_generated.h"'
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
".tmp/bar_generated.h", '#include "test/baz/baz_generated.h"'
)
def KeepPrefixIncludePrefixOutPathSubDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc([
"--cpp",
"--keep-prefix",
"--include-prefix",
"test",
"-o",
".tmp",
"bar/bar.fbs",
])
def KeepPrefixIncludePrefixOutPathSuperDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc(
[
"--cpp",
"--keep-prefix",
"--include-prefix",
"test",
"-o",
"../.tmp",
"bar/bar.fbs",
]
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
".tmp/bar_generated.h", '#include "test/baz/baz_generated.h"'
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
"../.tmp/bar_generated.h", '#include "test/baz/baz_generated.h"'
)
def KeepPrefixIncludePrefixOutPathSuperDirectory(self):
# Generate just foo with the import of bar keeping the prefix of where it is located.
flatc([
"--cpp",
"--keep-prefix",
"--include-prefix",
"test",
"-o",
"../.tmp",
"bar/bar.fbs",
])
def KeepPrefixIncludePrefixoutPathAbsoluePaths_SuperDirectoryReference(self):
# Generate bar_with_foo that references a type in a super directory.
flatc(
[
"--cpp",
"--keep-prefix",
"--include-prefix",
"generated",
"-I",
str(script_path.absolute()),
"-o",
str(Path(script_path, ".tmp").absolute()),
str(Path(script_path, "bar/bar_with_foo.fbs").absolute()),
]
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
"../.tmp/bar_generated.h", '#include "test/baz/baz_generated.h"'
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
".tmp/bar_with_foo_generated.h",
[
'#include "generated/baz/baz_generated.h"',
'#include "generated/foo_generated.h"',
],
)
def KeepPrefixIncludePrefixoutPathAbsoluePaths_SuperDirectoryReference(self):
# Generate bar_with_foo that references a type in a super directory.
flatc([
"--cpp",
"--keep-prefix",
"--include-prefix",
"generated",
"-I",
str(script_path.absolute()),
"-o",
str(Path(script_path, ".tmp").absolute()),
str(Path(script_path, "bar/bar_with_foo.fbs").absolute()),
])
def KeepPrefixIncludePrefixoutPath_SuperDirectoryReference(self):
# Generate bar_with_foo that references a type in a super directory.
flatc(
[
"--cpp",
"--keep-prefix",
"--include-prefix",
"generated",
"-I",
"./",
"-o",
".tmp",
"bar/bar_with_foo.fbs",
]
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
".tmp/bar_with_foo_generated.h",
[
'#include "generated/baz/baz_generated.h"',
'#include "generated/foo_generated.h"',
],
)
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
".tmp/bar_with_foo_generated.h",
[
'#include "generated/baz/baz_generated.h"',
'#include "generated/foo_generated.h"',
],
unlink=False,
)
def KeepPrefixIncludePrefixoutPath_SuperDirectoryReference(self):
# Generate bar_with_foo that references a type in a super directory.
flatc([
"--cpp",
"--keep-prefix",
"--include-prefix",
"generated",
"-I",
"./",
"-o",
".tmp",
"bar/bar_with_foo.fbs",
])
# The include prefix should come first, with the kept prefix next.
assert_file_and_contents(
".tmp/bar_with_foo_generated.h",
[
'#include "generated/baz/baz_generated.h"',
'#include "generated/foo_generated.h"',
],
unlink=False,
)

View File

@@ -17,16 +17,20 @@ from flatc_test import *
class KotlinTests:
def EnumValAttributes(self):
flatc(["--kotlin", "enum_val_attributes.fbs"])
def EnumValAttributes(self):
flatc(["--kotlin", "enum_val_attributes.fbs"])
subject = assert_file_exists("ValAttributes.kt")
assert_file_doesnt_contains(subject, 'val names : Array<String> = arrayOf("Val1", "Val2", "Val3")')
assert_file_doesnt_contains(subject, 'fun name(e: Int) : String = names[e]')
subject = assert_file_exists("ValAttributes.kt")
assert_file_doesnt_contains(
subject, 'val names : Array<String> = arrayOf("Val1", "Val2", "Val3")'
)
assert_file_doesnt_contains(subject, "fun name(e: Int) : String = names[e]")
def EnumValAttributes_ReflectNames(self):
flatc(["--kotlin", "--reflect-names", "enum_val_attributes.fbs"])
def EnumValAttributes_ReflectNames(self):
flatc(["--kotlin", "--reflect-names", "enum_val_attributes.fbs"])
subject = assert_file_exists("ValAttributes.kt")
assert_file_contains(subject, 'val names : Array<String> = arrayOf("Val1", "Val2", "Val3")')
assert_file_contains(subject, 'fun name(e: Int) : String = names[e]')
subject = assert_file_exists("ValAttributes.kt")
assert_file_contains(
subject, 'val names : Array<String> = arrayOf("Val1", "Val2", "Val3")'
)
assert_file_contains(subject, "fun name(e: Int) : String = names[e]")

View File

@@ -12,32 +12,62 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from flatc_test import *
import json
from flatc_test import *
class SchemaTests:
def EnumValAttributes(self):
# Generate .bfbs schema first
flatc(["--schema", "--binary", "--bfbs-builtins", "enum_val_attributes.fbs"])
assert_file_exists("enum_val_attributes.bfbs")
# Then turn it into JSON
flatc(["--json", "--strict-json", str(reflection_fbs_path()), "--", "enum_val_attributes.bfbs"])
def EnumValAttributes(self):
# Generate .bfbs schema first
flatc(
["--schema", "--binary", "--bfbs-builtins", "enum_val_attributes.fbs"]
)
assert_file_exists("enum_val_attributes.bfbs")
# The attributes should be present in JSON
schema_json = json.loads(get_file_contents("enum_val_attributes.json"))
# Then turn it into JSON
flatc([
"--json",
"--strict-json",
str(reflection_fbs_path()),
"--",
"enum_val_attributes.bfbs",
])
assert schema_json["enums"][0]["name"] == "ValAttributes"
assert schema_json["enums"][0]["values"][0]["name"] == "Val1"
assert schema_json["enums"][0]["values"][0]["attributes"][0]["key"] == "display_name"
assert schema_json["enums"][0]["values"][0]["attributes"][0]["value"] == "Value 1"
# The attributes should be present in JSON
schema_json = json.loads(get_file_contents("enum_val_attributes.json"))
assert schema_json["enums"][0]["values"][1]["name"] == "Val2"
assert schema_json["enums"][0]["values"][1]["attributes"][0]["key"] == "display_name"
assert schema_json["enums"][0]["values"][1]["attributes"][0]["value"] == "Value 2"
assert schema_json["enums"][0]["name"] == "ValAttributes"
assert schema_json["enums"][0]["values"][0]["name"] == "Val1"
assert (
schema_json["enums"][0]["values"][0]["attributes"][0]["key"]
== "display_name"
)
assert (
schema_json["enums"][0]["values"][0]["attributes"][0]["value"]
== "Value 1"
)
assert schema_json["enums"][0]["values"][2]["name"] == "Val3"
assert schema_json["enums"][0]["values"][2]["attributes"][0]["key"] == "deprecated"
assert schema_json["enums"][0]["values"][2]["attributes"][1]["key"] == "display_name"
assert schema_json["enums"][0]["values"][2]["attributes"][1]["value"] == "Value 3 (deprecated)"
assert schema_json["enums"][0]["values"][1]["name"] == "Val2"
assert (
schema_json["enums"][0]["values"][1]["attributes"][0]["key"]
== "display_name"
)
assert (
schema_json["enums"][0]["values"][1]["attributes"][0]["value"]
== "Value 2"
)
assert schema_json["enums"][0]["values"][2]["name"] == "Val3"
assert (
schema_json["enums"][0]["values"][2]["attributes"][0]["key"]
== "deprecated"
)
assert (
schema_json["enums"][0]["values"][2]["attributes"][1]["key"]
== "display_name"
)
assert (
schema_json["enums"][0]["values"][2]["attributes"][1]["value"]
== "Value 3 (deprecated)"
)

View File

@@ -13,9 +13,9 @@
# limitations under the License.
import argparse
from pathlib import Path
import platform
import subprocess
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -41,99 +41,100 @@ flatc_exe = Path(
# Find and assert flatc compiler is present.
if root_path in flatc_exe.parents:
flatc_exe = flatc_exe.relative_to(root_path)
flatc_exe = flatc_exe.relative_to(root_path)
flatc_path = Path(root_path, flatc_exe)
assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
# Execute the flatc compiler with the specified parameters
def flatc(options, cwd=script_path):
cmd = [str(flatc_path)] + options
subprocess.check_call(cmd, cwd=str(cwd))
cmd = [str(flatc_path)] + options
subprocess.check_call(cmd, cwd=str(cwd))
def reflection_fbs_path():
return Path(root_path).joinpath("reflection", "reflection.fbs")
return Path(root_path).joinpath("reflection", "reflection.fbs")
def make_absolute(filename, path=script_path):
return str(Path(path, filename).absolute())
return str(Path(path, filename).absolute())
def assert_file_exists(filename, path=script_path):
file = Path(path, filename)
assert file.exists(), "could not find file: " + filename
return file
file = Path(path, filename)
assert file.exists(), "could not find file: " + filename
return file
def assert_file_doesnt_exists(filename, path=script_path):
file = Path(path, filename)
assert not file.exists(), "file exists but shouldn't: " + filename
return file
file = Path(path, filename)
assert not file.exists(), "file exists but shouldn't: " + filename
return file
def get_file_contents(filename, path=script_path):
file = Path(path, filename)
contents = ""
with open(file) as file:
contents = file.read()
return contents
file = Path(path, filename)
contents = ""
with open(file) as file:
contents = file.read()
return contents
def assert_file_contains(file, needles):
with open(file) as file:
contents = file.read()
for needle in [needles] if isinstance(needles, str) else needles:
assert needle in contents, (
"coudn't find '" + needle + "' in file: " + str(file)
)
return file
with open(file) as file:
contents = file.read()
for needle in [needles] if isinstance(needles, str) else needles:
assert needle in contents, (
"coudn't find '" + needle + "' in file: " + str(file)
)
return file
def assert_file_doesnt_contains(file, needles):
with open(file) as file:
contents = file.read()
for needle in [needles] if isinstance(needles, str) else needles:
assert needle not in contents, (
"Found unexpected '" + needle + "' in file: " + str(file)
)
return file
with open(file) as file:
contents = file.read()
for needle in [needles] if isinstance(needles, str) else needles:
assert needle not in contents, (
"Found unexpected '" + needle + "' in file: " + str(file)
)
return file
def assert_file_and_contents(
file, needle, doesnt_contain=None, path=script_path, unlink=True
):
assert_file_contains(assert_file_exists(file, path), needle)
if doesnt_contain:
assert_file_doesnt_contains(assert_file_exists(file, path), doesnt_contain)
if unlink:
Path(path, file).unlink()
assert_file_contains(assert_file_exists(file, path), needle)
if doesnt_contain:
assert_file_doesnt_contains(assert_file_exists(file, path), doesnt_contain)
if unlink:
Path(path, file).unlink()
def run_all(*modules):
failing = 0
passing = 0
for module in modules:
methods = [
func
for func in dir(module)
if callable(getattr(module, func)) and not func.startswith("__")
]
module_failing = 0
module_passing = 0
for method in methods:
try:
print("{0}.{1}".format(module.__name__, method))
getattr(module, method)(module)
print(" [PASSED]")
module_passing = module_passing + 1
except Exception as e:
print(" [FAILED]: " + str(e))
module_failing = module_failing + 1
print(
"{0}: {1} of {2} passsed".format(
module.__name__, module_passing, module_passing + module_failing
)
failing = 0
passing = 0
for module in modules:
methods = [
func
for func in dir(module)
if callable(getattr(module, func)) and not func.startswith("__")
]
module_failing = 0
module_passing = 0
for method in methods:
try:
print("{0}.{1}".format(module.__name__, method))
getattr(module, method)(module)
print(" [PASSED]")
module_passing = module_passing + 1
except Exception as e:
print(" [FAILED]: " + str(e))
module_failing = module_failing + 1
print(
"{0}: {1} of {2} passsed".format(
module.__name__, module_passing, module_passing + module_failing
)
passing = passing + module_passing
failing = failing + module_failing
return passing, failing
)
passing = passing + module_passing
failing = failing + module_failing
return passing, failing

View File

@@ -15,228 +15,225 @@
from flatc_test import *
class TsTests():
class TsTests:
def Base(self):
# Generate just foo with no extra arguments
flatc(["--ts", "foo.fbs"])
def Base(self):
# Generate just foo with no extra arguments
flatc(["--ts", "foo.fbs"])
# Should generate the module that exports both foo and its direct
# include, bar.
assert_file_and_contents(
"foo_generated.ts",
[
"export { Bar } from './bar.js';",
"export { Foo } from './foo.js';",
],
)
# Should generate the module that exports both foo and its direct
# include, bar.
assert_file_and_contents(
"foo_generated.ts",
[
"export { Bar } from './bar.js';",
"export { Foo } from './foo.js';",
],
)
# Foo should be generated in place and exports the Foo table.
assert_file_and_contents("foo.ts", "export class Foo {")
# Foo should be generated in place and exports the Foo table.
assert_file_and_contents("foo.ts", "export class Foo {")
# Included files, like bar, should not be generated.
assert_file_doesnt_exists("bar.ts")
# Included files, like bar, should not be generated.
assert_file_doesnt_exists("bar.ts")
def BaseMultipleFiles(self):
# Generate both foo and bar with no extra arguments
flatc(["--ts", "foo.fbs", "bar/bar.fbs"])
def BaseMultipleFiles(self):
# Generate both foo and bar with no extra arguments
flatc(["--ts", "foo.fbs", "bar/bar.fbs"])
# Should generate the module that exports both foo and its direct
# include, bar.
assert_file_and_contents(
"foo_generated.ts",
[
"export { Bar } from './bar.js';",
"export { Foo } from './foo.js';",
],
)
# Should generate the module that exports both foo and its direct
# include, bar.
assert_file_and_contents(
"foo_generated.ts",
[
"export { Bar } from './bar.js';",
"export { Foo } from './foo.js';",
],
)
# Foo should be generated in place and exports the Foo table.
assert_file_and_contents("foo.ts", "export class Foo {")
# Foo should be generated in place and exports the Foo table.
assert_file_and_contents("foo.ts", "export class Foo {")
# Bar should also be generatd in place and exports the Bar table.
assert_file_and_contents("bar.ts", "export class Bar {")
# Bar should also be generatd in place and exports the Bar table.
assert_file_and_contents("bar.ts", "export class Bar {")
def BaseWithNamespace(self):
# Generate foo with namespacing, with no extra arguments
flatc(["--ts", "foo_with_ns.fbs"])
def BaseWithNamespace(self):
# Generate foo with namespacing, with no extra arguments
flatc(["--ts", "foo_with_ns.fbs"])
# Should generate the module that exports both foo in its namespace
# directory and its direct include, bar.
assert_file_and_contents(
"foo_with_ns_generated.ts",
[
"export { Bar } from './bar/bar.js';",
"export { Foo } from './something/foo.js';",
],
)
# Should generate the module that exports both foo in its namespace
# directory and its direct include, bar.
assert_file_and_contents(
"foo_with_ns_generated.ts",
[
"export { Bar } from './bar/bar.js';",
"export { Foo } from './something/foo.js';",
],
)
# Foo should be placed in the namespaced directory. It should export
# Foo, and the import of Bar should be relative to its location.
assert_file_and_contents(
"something/foo.ts",
[
"export class Foo {",
"import { Bar } from '../bar/bar.js';",
],
)
# Foo should be placed in the namespaced directory. It should export
# Foo, and the import of Bar should be relative to its location.
assert_file_and_contents(
"something/foo.ts",
[
"export class Foo {",
"import { Bar } from '../bar/bar.js';",
],
)
# Included files, like bar, should not be generated.
assert_file_doesnt_exists("bar.ts")
# Included files, like bar, should not be generated.
assert_file_doesnt_exists("bar.ts")
def GenAll(self):
# Generate foo with generate all options
flatc(["--ts", "--gen-all", "foo.fbs"])
def GenAll(self):
# Generate foo with generate all options
flatc(["--ts", "--gen-all", "foo.fbs"])
# Should generate a single file that exports all the generated types.
assert_file_and_contents(
"foo_generated.ts",
[
"export { Bar } from './bar.js'",
"export { Baz } from './baz.js'",
"export { Foo } from './foo.js'",
],
)
# Should generate a single file that exports all the generated types.
assert_file_and_contents(
"foo_generated.ts",
[
"export { Bar } from './bar.js'",
"export { Baz } from './baz.js'",
"export { Foo } from './foo.js'",
],
)
# Foo should be generated with an import to Bar and an export of itself.
assert_file_and_contents(
"foo.ts",
[
"import { Bar } from './bar.js';",
"export class Foo {",
],
)
# Foo should be generated with an import to Bar and an export of itself.
assert_file_and_contents(
"foo.ts",
[
"import { Bar } from './bar.js';",
"export class Foo {",
],
)
# Bar should be generated with an import to Baz and an export of itself.
assert_file_and_contents(
"bar.ts",
[
"import { Baz } from './baz.js';",
"export class Bar {",
],
)
# Bar should be generated with an import to Baz and an export of itself.
assert_file_and_contents(
"bar.ts",
[
"import { Baz } from './baz.js';",
"export class Bar {",
],
)
# Baz should be generated with an export of itself.
assert_file_and_contents(
"baz.ts",
[
"export enum Baz {",
],
)
# Baz should be generated with an export of itself.
assert_file_and_contents(
"baz.ts",
[
"export enum Baz {",
],
)
def FlatFiles(self):
# Generate just foo with the flat files option
flatc(["--ts", "--ts-flat-files", "foo.fbs"])
def FlatFiles(self):
# Generate just foo with the flat files option
flatc(["--ts", "--ts-flat-files", "foo.fbs"])
# Should generate a single file that imports bar as a single file, and
# exports the Foo table.
assert_file_and_contents(
"foo_generated.ts",
[
"import {Bar as Bar} from './bar_generated.js';",
"export class Foo {",
],
)
# Should generate a single file that imports bar as a single file, and
# exports the Foo table.
assert_file_and_contents(
"foo_generated.ts",
[
"import {Bar as Bar} from './bar_generated.js';",
"export class Foo {",
],
)
# The root type Foo should not be generated in its own file.
assert_file_doesnt_exists("foo.ts")
# The root type Foo should not be generated in its own file.
assert_file_doesnt_exists("foo.ts")
def FlatFilesWithNamespace(self):
# Generate just foo with the flat files option
flatc(["--ts", "--ts-flat-files", "foo_with_ns.fbs"])
def FlatFilesWithNamespace(self):
# Generate just foo with the flat files option
flatc(["--ts", "--ts-flat-files", "foo_with_ns.fbs"])
# Should generate a single file that imports bar as a single file, and
# exports the Foo table.
assert_file_and_contents(
"foo_with_ns_generated.ts",
[
"import {Bar as Bar} from './bar_with_ns_generated.js';",
"export class Foo {",
],
)
# Should generate a single file that imports bar as a single file, and
# exports the Foo table.
assert_file_and_contents(
"foo_with_ns_generated.ts",
[
"import {Bar as Bar} from './bar_with_ns_generated.js';",
"export class Foo {",
],
)
# The root type Foo should not be generated in its own file.
assert_file_doesnt_exists("foo.ts")
# The root type Foo should not be generated in its own file.
assert_file_doesnt_exists("foo.ts")
def FlatFilesMultipleFiles(self):
# Generate both foo and bar with the flat files option
flatc(["--ts", "--ts-flat-files", "foo.fbs", "bar/bar.fbs"])
def FlatFilesMultipleFiles(self):
# Generate both foo and bar with the flat files option
flatc(["--ts", "--ts-flat-files", "foo.fbs", "bar/bar.fbs"])
# Should generate a single foo file that imports bar as a single file,
# and exports the Foo table.
assert_file_and_contents(
"foo_generated.ts",
[
"import {Bar as Bar} from './bar_generated.js';",
"export class Foo {",
],
)
# Should generate a single foo file that imports bar as a single file,
# and exports the Foo table.
assert_file_and_contents(
"foo_generated.ts",
[
"import {Bar as Bar} from './bar_generated.js';",
"export class Foo {",
],
)
# Should generate a single bar file that imports bar as a single file,
# and exports the Bar table.
assert_file_and_contents(
"bar_generated.ts",
[
"import {Baz as Baz} from './baz_generated.js';",
"export class Bar {",
],
)
# Should generate a single bar file that imports bar as a single file,
# and exports the Bar table.
assert_file_and_contents(
"bar_generated.ts",
[
"import {Baz as Baz} from './baz_generated.js';",
"export class Bar {",
],
)
# The types Foo and Bar should not be generated in their own files
assert_file_doesnt_exists("foo.ts")
assert_file_doesnt_exists("bar.ts")
# The types Foo and Bar should not be generated in their own files
assert_file_doesnt_exists("foo.ts")
assert_file_doesnt_exists("bar.ts")
def FlatFilesGenAll(self):
# Generate foo with all of its dependents with the flat files option
flatc(["--ts", "--ts-flat-files", "--gen-all", "foo.fbs"])
def FlatFilesGenAll(self):
# Generate foo with all of its dependents with the flat files option
flatc(["--ts", "--ts-flat-files", "--gen-all", "foo.fbs"])
# Should generate a single foo file
assert_file_and_contents(
"foo_generated.ts",
# Should export each of the types within the single file
[
"export class Foo {",
"export class Bar {",
"export enum Baz {",
],
# No includes for the dependent types should be present.
doesnt_contain=[
"import {Bar as Bar}",
"import {Baz as Baz}",
],
)
# Should generate a single foo file
assert_file_and_contents(
"foo_generated.ts",
# Should export each of the types within the single file
[
"export class Foo {",
"export class Bar {",
"export enum Baz {",
],
# No includes for the dependent types should be present.
doesnt_contain=[
"import {Bar as Bar}",
"import {Baz as Baz}",
],
)
# The types Foo, Bar and Baz should not be generated in their own files.
assert_file_doesnt_exists("foo.ts")
assert_file_doesnt_exists("bar.ts")
assert_file_doesnt_exists("baz.ts")
# The types Foo, Bar and Baz should not be generated in their own files.
assert_file_doesnt_exists("foo.ts")
assert_file_doesnt_exists("bar.ts")
assert_file_doesnt_exists("baz.ts")
def ZFlatFilesGenAllWithNamespacing(self):
# Generate foo with all of its dependents with the flat files option
flatc(["--ts", "--ts-flat-files", "--gen-all", "foo_with_ns.fbs"])
# Should generate a single foo file
assert_file_and_contents(
"foo_with_ns_generated.ts",
# Should export each of the types within the single file
[
"export class bar_Bar {",
"export class bar_Foo {",
"export enum Baz {",
"export enum baz_Baz {",
"export class something_Foo {",
],
# No includes for the dependent types should be present.
doesnt_contain=[
"import {Bar as Bar}",
"import {Baz as Baz}",
],
)
def ZFlatFilesGenAllWithNamespacing(self):
# Generate foo with all of its dependents with the flat files option
flatc(["--ts", "--ts-flat-files", "--gen-all", "foo_with_ns.fbs"])
# Should generate a single foo file
assert_file_and_contents(
"foo_with_ns_generated.ts",
# Should export each of the types within the single file
[
"export class bar_Bar {",
"export class bar_Foo {",
"export enum Baz {",
"export enum baz_Baz {",
"export class something_Foo {"
],
# No includes for the dependent types should be present.
doesnt_contain=[
"import {Bar as Bar}",
"import {Baz as Baz}",
],
)
# The types Foo, Bar and Baz should not be generated in their own files.
assert_file_doesnt_exists("foo.ts")
assert_file_doesnt_exists("bar.ts")
assert_file_doesnt_exists("baz.ts")
# The types Foo, Bar and Baz should not be generated in their own files.
assert_file_doesnt_exists("foo.ts")
assert_file_doesnt_exists("bar.ts")
assert_file_doesnt_exists("baz.ts")

View File

@@ -16,11 +16,11 @@
import sys
from flatc_test import run_all
from flatc_cpp_tests import CppTests
from flatc_kotlin_tests import KotlinTests
from flatc_ts_tests import TsTests
from flatc_schema_tests import SchemaTests
from flatc_test import run_all
from flatc_ts_tests import TsTests
passing, failing = run_all(CppTests, KotlinTests, TsTests, SchemaTests)
@@ -28,4 +28,4 @@ print("")
print("{0} of {1} tests passed".format(passing, passing + failing))
if failing > 0:
sys.exit(1)
sys.exit(1)

View File

@@ -23,7 +23,7 @@ static const uint64_t kOffsetBasis = 0xcbf29ce484222645ULL;
namespace flatbuffers {
template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
template <typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
uint64_t Hash(T value, uint64_t hash) {
return (hash * kFnvPrime) ^ value;
}
@@ -33,33 +33,51 @@ uint64_t Hash(double value, uint64_t hash) {
return (hash * kFnvPrime) ^ static_cast<uint64_t>(value);
}
uint64_t Hash(const flatbuffers::String *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
for (auto &c : value->str()) { hash = Hash(static_cast<uint8_t>(c), hash); }
uint64_t Hash(const flatbuffers::String* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
for (auto& c : value->str()) {
hash = Hash(static_cast<uint8_t>(c), hash);
}
return hash;
}
uint64_t Hash(const LeafStruct *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
uint64_t Hash(const LeafStruct* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
hash = Hash(value->a(), hash);
hash = Hash(value->b(), hash);
return hash;
}
template<typename T> uint64_t Hash(const Vector<T> *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
for (const T c : *value) { hash = Hash(c, hash); }
template <typename T>
uint64_t Hash(const Vector<T>* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
for (const T c : *value) {
hash = Hash(c, hash);
}
return hash;
}
template<typename T> uint64_t Hash(const Vector64<T> *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
for (const T c : *value) { hash = Hash(c, hash); }
template <typename T>
uint64_t Hash(const Vector64<T>* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
for (const T c : *value) {
hash = Hash(c, hash);
}
return hash;
}
uint64_t Hash(const RootTable *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
uint64_t Hash(const RootTable* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
// Hash all the fields so we can exercise all parts of the code.
hash = Hash(value->far_vector(), hash);
hash = Hash(value->a(), hash);
@@ -72,9 +90,9 @@ uint64_t Hash(const RootTable *value, uint64_t hash) {
return hash;
}
static int AccessBuffer(const uint8_t *data, size_t size,
static int AccessBuffer(const uint8_t* data, size_t size,
bool is_size_prefixed) {
const RootTable *root_table =
const RootTable* root_table =
is_size_prefixed ? GetSizePrefixedRootTable(data) : GetRootTable(data);
TEST_NOTNULL(root_table);
@@ -85,15 +103,17 @@ static int AccessBuffer(const uint8_t *data, size_t size,
return 0;
}
extern "C" int LLVMFuzzerInitialize(int *, char ***argv) {
extern "C" int LLVMFuzzerInitialize(int*, char*** argv) {
Verifier verifier(schema.begin(), schema.size());
TEST_EQ(true, reflection::VerifySchemaBuffer(verifier));
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < FLATBUFFERS_MIN_BUFFER_SIZE) { return 0; }
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (size < FLATBUFFERS_MIN_BUFFER_SIZE) {
return 0;
}
// Take the first bit of data as a flag to control things.
const uint8_t flags = data[0];

View File

@@ -6,7 +6,7 @@
#include "test_init.h"
static std::filesystem::path exe_path_;
static const uint8_t *schema_bfbs_;
static const uint8_t* schema_bfbs_;
static size_t schema_bfbs_length_;
bool TestFileExists(std::filesystem::path file_path) {
@@ -14,7 +14,7 @@ bool TestFileExists(std::filesystem::path file_path) {
return true;
TEST_OUTPUT_LINE("@DEBUG: file '%s' not found", file_path.string().c_str());
for (const auto &entry :
for (const auto& entry :
std::filesystem::directory_iterator(file_path.parent_path())) {
TEST_OUTPUT_LINE("@DEBUG: parent path entry: '%s'",
entry.path().string().c_str());
@@ -22,7 +22,7 @@ bool TestFileExists(std::filesystem::path file_path) {
return false;
}
std::string LoadBinarySchema(const char *file_name) {
std::string LoadBinarySchema(const char* file_name) {
const auto file_path = exe_path_.parent_path() / file_name;
TEST_EQ(true, TestFileExists(file_path));
std::string schemafile;
@@ -30,21 +30,21 @@ std::string LoadBinarySchema(const char *file_name) {
flatbuffers::LoadFile(file_path.string().c_str(), true, &schemafile));
flatbuffers::Verifier verifier(
reinterpret_cast<const uint8_t *>(schemafile.c_str()), schemafile.size());
reinterpret_cast<const uint8_t*>(schemafile.c_str()), schemafile.size());
TEST_EQ(true, reflection::VerifySchemaBuffer(verifier));
return schemafile;
}
extern "C" int LLVMFuzzerInitialize(int *, char ***argv) {
extern "C" int LLVMFuzzerInitialize(int*, char*** argv) {
exe_path_ = (*argv)[0];
static const std::string schema_file =
LoadBinarySchema("annotated_binary.bfbs");
schema_bfbs_ = reinterpret_cast<const uint8_t *>(schema_file.c_str());
schema_bfbs_ = reinterpret_cast<const uint8_t*>(schema_file.c_str());
schema_bfbs_length_ = schema_file.size();
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
flatbuffers::BinaryAnnotator annotator(schema_bfbs_, schema_bfbs_length_,
data, size, false);

View File

@@ -48,14 +48,14 @@ bool TestFileExists(fs::path file_path) {
if (file_path.has_filename() && fs::exists(file_path)) return true;
TEST_OUTPUT_LINE("@DEBUG: file '%s' not found", file_path.string().c_str());
for (const auto &entry : fs::directory_iterator(file_path.parent_path())) {
for (const auto& entry : fs::directory_iterator(file_path.parent_path())) {
TEST_OUTPUT_LINE("@DEBUG: parent path entry: '%s'",
entry.path().string().c_str());
}
return false;
}
std::string LoadBinarySchema(const char *file_name) {
std::string LoadBinarySchema(const char* file_name) {
const auto file_path = exe_path_.parent_path() / file_name;
TEST_EQ(true, TestFileExists(file_path));
std::string schemafile;
@@ -63,12 +63,12 @@ std::string LoadBinarySchema(const char *file_name) {
flatbuffers::LoadFile(file_path.string().c_str(), true, &schemafile));
flatbuffers::Verifier verifier(
reinterpret_cast<const uint8_t *>(schemafile.c_str()), schemafile.size());
reinterpret_cast<const uint8_t*>(schemafile.c_str()), schemafile.size());
TEST_EQ(true, reflection::VerifySchemaBuffer(verifier));
return schemafile;
}
std::string do_test(const flatbuffers::IDLOptions &opts,
std::string do_test(const flatbuffers::IDLOptions& opts,
const std::string input_json, const bool check_parser) {
// (re)define parser options
parser_.opts = opts;
@@ -78,8 +78,7 @@ std::string do_test(const flatbuffers::IDLOptions &opts,
flatbuffers::Verifier verifier(parser_.builder_.GetBufferPointer(),
parser_.builder_.GetSize());
TEST_EQ(true, MyGame::Example::VerifyMonsterBuffer(verifier));
TEST_NULL(
GenText(parser_, parser_.builder_.GetBufferPointer(), &jsongen));
TEST_NULL(GenText(parser_, parser_.builder_.GetBufferPointer(), &jsongen));
} else if (check_parser) {
TEST_OUTPUT_LINE("parser failed with JSON:\n%s", input_json.c_str());
TEST_EQ_STR("", parser_.error_.c_str());
@@ -95,18 +94,18 @@ std::string do_test(const flatbuffers::IDLOptions &opts,
// your fuzz target. If you need to load data files, please use argv[0] to get
// the directory where your fuzz target executable is located.
// You must not modify argv[0].
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
(void)argc;
exe_path_ = (*argv)[0];
static const std::string schemafile = LoadBinarySchema("monster_test.bfbs");
// parse schema first, so we can use it to parse the data after
parser_.Deserialize(reinterpret_cast<const uint8_t *>(schemafile.c_str()),
parser_.Deserialize(reinterpret_cast<const uint8_t*>(schemafile.c_str()),
schemafile.size());
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Reserve one byte for Parser flags and one byte for repetition counter.
if (size < 3) return 0;
const uint8_t flags = data[0];
@@ -114,7 +113,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
data += 2;
size -= 2; // bypass
const std::string original(reinterpret_cast<const char *>(data), size);
const std::string original(reinterpret_cast<const char*>(data), size);
auto input = std::string(original.c_str()); // until '\0'
if (input.size() < kMinInputLength || input.size() > kMaxInputLength)
return 0;

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <stddef.h>
#include <stdint.h>
#include <clocale>
#include <string>
@@ -19,7 +20,7 @@ static constexpr uint8_t flags_allow_non_utf8 = 0x20;
// Utility for test run.
OneTimeTestInit OneTimeTestInit::one_time_init_;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Reserve one byte for Parser flags and one byte for repetition counter.
if (size < 3) return 0;
const uint8_t flags = data[0];
@@ -27,7 +28,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
data += 2;
size -= 2; // bypass
const std::string original(reinterpret_cast<const char *>(data), size);
const std::string original(reinterpret_cast<const char*>(data), size);
auto input = std::string(original.c_str()); // until '\0'
if (input.size() < kMinInputLength || input.size() > kMaxInputLength)
return 0;
@@ -46,7 +47,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// Check Parser.
parser.Parse(parse_input);
// TODO:
// Need to add additional checks for inputs passed Parse(parse_input) successfully:
// Need to add additional checks for inputs passed Parse(parse_input)
// successfully:
// 1. Serialization to bfbs.
// 2. Generation of a default object.
// 3. Verification of the object using reflection.

View File

@@ -38,7 +38,7 @@ static constexpr uint8_t flags_quotes_kind = 0x10; // quote " or '
// Find all 'subj' sub-strings and replace first character of sub-string.
// BreakSequence("testest","tes", 'X') -> "XesXest".
// BreakSequence("xxx","xx", 'Y') -> "YYx".
static void BreakSequence(std::string &s, const char *subj, char repl) {
static void BreakSequence(std::string& s, const char* subj, char repl) {
size_t pos = 0;
while (pos = s.find(subj, pos), pos != std::string::npos) {
s.at(pos) = repl;
@@ -48,8 +48,8 @@ static void BreakSequence(std::string &s, const char *subj, char repl) {
// Remove all leading and trailing symbols matched with pattern set.
// StripString("xy{xy}y", "xy") -> "{xy}"
static std::string StripString(const std::string &s, const char *pattern,
size_t *pos = nullptr) {
static std::string StripString(const std::string& s, const char* pattern,
size_t* pos = nullptr) {
if (pos) *pos = 0;
// leading
auto first = s.find_first_not_of(pattern);
@@ -64,19 +64,19 @@ static std::string StripString(const std::string &s, const char *pattern,
class RegexMatcher {
protected:
virtual bool MatchNumber(const std::string &input) const = 0;
virtual bool MatchNumber(const std::string& input) const = 0;
public:
virtual ~RegexMatcher() = default;
struct MatchResult {
size_t pos{ 0 };
size_t len{ 0 };
bool res{ false };
bool quoted{ false };
size_t pos{0};
size_t len{0};
bool res{false};
bool quoted{false};
};
MatchResult Match(const std::string &input) const {
MatchResult Match(const std::string& input) const {
MatchResult r;
// strip leading and trailing "spaces" accepted by flatbuffer
auto test = StripString(input, "\t\r\n ", &r.pos);
@@ -103,11 +103,11 @@ class RegexMatcher {
return r;
}
bool MatchRegexList(const std::string &input,
const std::vector<std::regex> &re_list) const {
bool MatchRegexList(const std::string& input,
const std::vector<std::regex>& re_list) const {
auto str = StripString(input, " ");
if (str.empty()) return false;
for (auto &re : re_list) {
for (auto& re : re_list) {
std::smatch match;
if (std::regex_match(str, match, re)) return true;
}
@@ -117,13 +117,12 @@ class RegexMatcher {
class IntegerRegex : public RegexMatcher {
protected:
bool MatchNumber(const std::string &input) const override {
bool MatchNumber(const std::string& input) const override {
static const std::vector<std::regex> re_list = {
std::regex{ R"(^[-+]?[0-9]+$)", std::regex_constants::optimize },
std::regex{R"(^[-+]?[0-9]+$)", std::regex_constants::optimize},
std::regex{ R"(^[-+]?0[xX][0-9a-fA-F]+$)",
std::regex_constants::optimize }
};
std::regex{R"(^[-+]?0[xX][0-9a-fA-F]+$)",
std::regex_constants::optimize}};
return MatchRegexList(input, re_list);
}
@@ -134,14 +133,13 @@ class IntegerRegex : public RegexMatcher {
class UIntegerRegex : public RegexMatcher {
protected:
bool MatchNumber(const std::string &input) const override {
bool MatchNumber(const std::string& input) const override {
static const std::vector<std::regex> re_list = {
std::regex{ R"(^[+]?[0-9]+$)", std::regex_constants::optimize },
std::regex{ R"(^[+]?0[xX][0-9a-fA-F]+$)",
std::regex_constants::optimize },
// accept -0 number
std::regex{ R"(^[-](?:0[xX])?0+$)", std::regex_constants::optimize }
};
std::regex{R"(^[+]?[0-9]+$)", std::regex_constants::optimize},
std::regex{R"(^[+]?0[xX][0-9a-fA-F]+$)",
std::regex_constants::optimize},
// accept -0 number
std::regex{R"(^[-](?:0[xX])?0+$)", std::regex_constants::optimize}};
return MatchRegexList(input, re_list);
}
@@ -152,7 +150,7 @@ class UIntegerRegex : public RegexMatcher {
class BooleanRegex : public IntegerRegex {
protected:
bool MatchNumber(const std::string &input) const override {
bool MatchNumber(const std::string& input) const override {
if (input == "true" || input == "false") return true;
return IntegerRegex::MatchNumber(input);
}
@@ -164,20 +162,20 @@ class BooleanRegex : public IntegerRegex {
class FloatRegex : public RegexMatcher {
protected:
bool MatchNumber(const std::string &input) const override {
bool MatchNumber(const std::string& input) const override {
static const std::vector<std::regex> re_list = {
// hex-float
std::regex{
R"(^[-+]?0[xX](?:(?:[.][0-9a-fA-F]+)|(?:[0-9a-fA-F]+[.][0-9a-fA-F]*)|(?:[0-9a-fA-F]+))[pP][-+]?[0-9]+$)",
std::regex_constants::optimize },
// dec-float
std::regex{
R"(^[-+]?(?:(?:[.][0-9]+)|(?:[0-9]+[.][0-9]*)|(?:[0-9]+))(?:[eE][-+]?[0-9]+)?$)",
std::regex_constants::optimize },
// hex-float
std::regex{
R"(^[-+]?0[xX](?:(?:[.][0-9a-fA-F]+)|(?:[0-9a-fA-F]+[.][0-9a-fA-F]*)|(?:[0-9a-fA-F]+))[pP][-+]?[0-9]+$)",
std::regex_constants::optimize},
// dec-float
std::regex{
R"(^[-+]?(?:(?:[.][0-9]+)|(?:[0-9]+[.][0-9]*)|(?:[0-9]+))(?:[eE][-+]?[0-9]+)?$)",
std::regex_constants::optimize},
std::regex{ R"(^[-+]?(?:nan|inf|infinity)$)",
std::regex_constants::optimize | std::regex_constants::icase }
};
std::regex{
R"(^[-+]?(?:nan|inf|infinity)$)",
std::regex_constants::optimize | std::regex_constants::icase}};
return MatchRegexList(input, re_list);
}
@@ -188,34 +186,46 @@ class FloatRegex : public RegexMatcher {
class ScalarReferenceResult {
private:
ScalarReferenceResult(const char *_type, RegexMatcher::MatchResult _matched)
ScalarReferenceResult(const char* _type, RegexMatcher::MatchResult _matched)
: type(_type), matched(_matched) {}
public:
// Decode scalar type and check if the input string satisfies the scalar type.
static ScalarReferenceResult Check(uint8_t code, const std::string &input) {
static ScalarReferenceResult Check(uint8_t code, const std::string& input) {
switch (code) {
case 0x0: return { "double", FloatRegex().Match(input) };
case 0x1: return { "float", FloatRegex().Match(input) };
case 0x2: return { "int8", IntegerRegex().Match(input) };
case 0x3: return { "int16", IntegerRegex().Match(input) };
case 0x4: return { "int32", IntegerRegex().Match(input) };
case 0x5: return { "int64", IntegerRegex().Match(input) };
case 0x6: return { "uint8", UIntegerRegex().Match(input) };
case 0x7: return { "uint16", UIntegerRegex().Match(input) };
case 0x8: return { "uint32", UIntegerRegex().Match(input) };
case 0x9: return { "uint64", UIntegerRegex().Match(input) };
case 0xA: return { "bool", BooleanRegex().Match(input) };
default: return { "float", FloatRegex().Match(input) };
case 0x0:
return {"double", FloatRegex().Match(input)};
case 0x1:
return {"float", FloatRegex().Match(input)};
case 0x2:
return {"int8", IntegerRegex().Match(input)};
case 0x3:
return {"int16", IntegerRegex().Match(input)};
case 0x4:
return {"int32", IntegerRegex().Match(input)};
case 0x5:
return {"int64", IntegerRegex().Match(input)};
case 0x6:
return {"uint8", UIntegerRegex().Match(input)};
case 0x7:
return {"uint16", UIntegerRegex().Match(input)};
case 0x8:
return {"uint32", UIntegerRegex().Match(input)};
case 0x9:
return {"uint64", UIntegerRegex().Match(input)};
case 0xA:
return {"bool", BooleanRegex().Match(input)};
default:
return {"float", FloatRegex().Match(input)};
};
}
const char *type;
const char* type;
const RegexMatcher::MatchResult matched;
};
bool Parse(flatbuffers::Parser &parser, const std::string &json,
std::string *_text) {
bool Parse(flatbuffers::Parser& parser, const std::string& json,
std::string* _text) {
auto done = parser.ParseJson(json.c_str());
if (done) {
TEST_NULL(GenText(parser, parser.builder_.GetBufferPointer(), _text));
@@ -230,7 +240,7 @@ OneTimeTestInit OneTimeTestInit::one_time_init_;
// llvm std::regex have problem with stack overflow, limit maximum length.
// ./scalar_fuzzer -max_len=3000
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Reserve one byte for Parser flags and one byte for repetition counter.
if (size < 3) return 0;
const uint8_t flags = data[0];
@@ -241,7 +251,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
size -= 2; // bypass
// Guarantee 0-termination.
const std::string original(reinterpret_cast<const char *>(data), size);
const std::string original(reinterpret_cast<const char*>(data), size);
auto input = std::string(original.c_str()); // until '\0'
if (input.size() < kMinInputLength || input.size() > kMaxInputLength)
return 0;
@@ -257,7 +267,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// This key:value ignored by the parser. Numbers can not have $.
BreakSequence(input, "$schema", '@'); // "$schema" -> "@schema"
// Break all known scalar functions (todo: add them to regex?):
for (auto f : { "deg", "rad", "sin", "cos", "tan", "asin", "acos", "atan" }) {
for (auto f : {"deg", "rad", "sin", "cos", "tan", "asin", "acos", "atan"}) {
BreakSequence(input, f, '_'); // ident -> ident
}
@@ -265,7 +275,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// the scalar type.
const auto ref_res =
ScalarReferenceResult::Check(flags & flags_scalar_type, input);
auto &recheck = ref_res.matched;
auto& recheck = ref_res.matched;
// Create parser
flatbuffers::IDLOptions opts;
@@ -338,7 +348,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
orig_done);
TEST_EQ_STR(fix_back.c_str(), orig_back.c_str());
}
if (orig_done) { TEST_EQ_STR(fix_back.c_str(), orig_back.c_str()); }
if (orig_done) {
TEST_EQ_STR(fix_back.c_str(), orig_back.c_str());
}
TEST_EQ_FUNC(fix_done, orig_done);
}
@@ -357,8 +369,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// Compare with print.
std::string ref_string, def_string;
FLATBUFFERS_ASSERT(!GenText(
parser, parser.builder_.GetBufferPointer(), &ref_string));
FLATBUFFERS_ASSERT(
!GenText(parser, parser.builder_.GetBufferPointer(), &ref_string));
FLATBUFFERS_ASSERT(!GenText(
def_parser, def_parser.builder_.GetBufferPointer(), &def_string));
if (ref_string != def_string) {
@@ -369,7 +381,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// Restore locale.
if (use_locale) { FLATBUFFERS_ASSERT(setlocale(LC_ALL, "C")); }
if (use_locale) {
FLATBUFFERS_ASSERT(setlocale(LC_ALL, "C"));
}
}
return 0;
}

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <stddef.h>
#include <stdint.h>
#include <string>
#include "cpp17/generated_cpp17/monster_test_generated.h"

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <stddef.h>
#include <stdint.h>
#include <string>
#include "flatbuffers/flexbuffers.h"
@@ -14,6 +15,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// FIXME: we can't really verify this path, because the fuzzer will
// construct buffers that time out.
// Add a simple #define to bound the number of steps just for the fuzzer?
//flexbuffers::VerifyBuffer(data, size, nullptr);
// flexbuffers::VerifyBuffer(data, size, nullptr);
return 0;
}

View File

@@ -4,11 +4,11 @@
#if defined(_MSC_VER)
extern "C" void __debugbreak();
#define __builtin_trap __debugbreak
#else // Clang
#else // Clang
extern "C" void __builtin_trap(void);
#endif
// Declare Debug/Release independed assert macro.
#define fuzzer_assert_impl(x) (!!(x) ? static_cast<void>(0) : __builtin_trap())
#endif // !FUZZER_ASSERT_IMPL_H_
#endif // !FUZZER_ASSERT_IMPL_H_

View File

@@ -9,9 +9,9 @@
struct OneTimeTestInit {
// Declare trap for the Flatbuffers test engine.
// This hook terminate program both in Debug and Release.
static bool TestFailListener(const char *expval, const char *val,
const char *exp, const char *file, int line,
const char *func = nullptr) {
static bool TestFailListener(const char* expval, const char* val,
const char* exp, const char* file, int line,
const char* func = nullptr) {
(void)expval;
(void)val;
(void)exp;
@@ -39,7 +39,7 @@ struct OneTimeTestInit {
}
}
static const char *test_locale() {
static const char* test_locale() {
return one_time_init_.has_locale_ ? nullptr
: one_time_init_.test_locale_.c_str();
}

View File

@@ -10,13 +10,14 @@ namespace tests {
// set to 1. A quiet NaN bit string should be encoded with the first bit d[1]
// of the trailing significand field T being 1 (d[0] is implicit bit).
// It is assumed that endianness of floating-point is same as integer.
template<typename T, typename U, U qnan_base> bool is_quiet_nan_impl(T v) {
template <typename T, typename U, U qnan_base>
bool is_quiet_nan_impl(T v) {
static_assert(sizeof(T) == sizeof(U), "unexpected");
U b = 0;
std::memcpy(&b, &v, sizeof(T));
return ((b & qnan_base) == qnan_base);
}
# if defined(__mips__) || defined(__hppa__)
#if defined(__mips__) || defined(__hppa__)
inline bool is_quiet_nan(float v) {
return is_quiet_nan_impl<float, uint32_t, 0x7FC00000u>(v) ||
is_quiet_nan_impl<float, uint32_t, 0x7FBFFFFFu>(v);
@@ -25,14 +26,14 @@ inline bool is_quiet_nan(double v) {
return is_quiet_nan_impl<double, uint64_t, 0x7FF8000000000000ul>(v) ||
is_quiet_nan_impl<double, uint64_t, 0x7FF7FFFFFFFFFFFFu>(v);
}
# else
#else
inline bool is_quiet_nan(float v) {
return is_quiet_nan_impl<float, uint32_t, 0x7FC00000u>(v);
}
inline bool is_quiet_nan(double v) {
return is_quiet_nan_impl<double, uint64_t, 0x7FF8000000000000ul>(v);
}
# endif
#endif
#endif
} // namespace tests

View File

@@ -9,7 +9,6 @@ void StructKeyInStructTest();
void NestedStructKeyInStructTest();
void FixedSizedStructArrayKeyInStructTest();
} // namespace tests
} // namespace flatbuffers

View File

@@ -1,6 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_ENUMS_H_
#define FLATBUFFERS_GENERATED_ENUMS_H_
@@ -9,18 +8,10 @@
// Ensure the included flatbuffers.h is the same version as when this file was
// generated, otherwise it may not be compatible.
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
FLATBUFFERS_VERSION_MINOR == 2 &&
FLATBUFFERS_VERSION_REVISION == 10,
"Non-compatible flatbuffers version included");
FLATBUFFERS_VERSION_MINOR == 2 &&
FLATBUFFERS_VERSION_REVISION == 10,
"Non-compatible flatbuffers version included");
enum Color : int32_t {
Color_Red = 1,
Color_Blue = 2,
Color_Orange = 3
};
enum Size : int32_t {
Size_Small = 10,
Size_Large = 100,
Size_Medium = 1000
};
enum Color : int32_t { Color_Red = 1, Color_Blue = 2, Color_Orange = 3 };
enum Size : int32_t { Size_Small = 10, Size_Large = 100, Size_Medium = 1000 };
#endif // FLATBUFFERS_GENERATED_ENUMS_H_

View File

@@ -9,16 +9,16 @@
namespace flatbuffers {
namespace tests {
flatbuffers::DetachedBuffer CreateFlatBufferTest(std::string &buffer);
flatbuffers::DetachedBuffer CreateFlatBufferTest(std::string& buffer);
void AccessFlatBufferTest(const uint8_t *flatbuf, size_t length,
bool pooled = true);
void AccessFlatBufferTest(const uint8_t* flatbuf, size_t length,
bool pooled = true);
void MutateFlatBuffersTest(uint8_t *flatbuf, std::size_t length);
void MutateFlatBuffersTest(uint8_t* flatbuf, std::size_t length);
void ObjectFlatBuffersTest(uint8_t *flatbuf);
void ObjectFlatBuffersTest(uint8_t* flatbuf);
void CheckMonsterObject(MyGame::Example::MonsterT *monster2);
void CheckMonsterObject(MyGame::Example::MonsterT* monster2);
void SizePrefixedTest();
@@ -30,7 +30,7 @@ void TypeAliasesTest();
void ParseAndGenerateTextTest(const std::string& tests_data_path, bool binary);
void UnPackTo(const uint8_t *flatbuf);
void UnPackTo(const uint8_t* flatbuf);
} // namespace tests
} // namespace flatbuffers

View File

@@ -1,9 +1,8 @@
// Generated by the gRPC C++ plugin.
// FlatBuffers modified generator: native gRPC callback client API enabled when --grpc-callback-api.
// source: monster_test
// FlatBuffers modified generator: native gRPC callback client API enabled when
// --grpc-callback-api. source: monster_test
#include "monster_test_generated.h"
#include "monster_test.grpc.fb.h"
#include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h>
@@ -13,119 +12,227 @@
#include <grpcpp/impl/codegen/rpc_service_method.h>
#include <grpcpp/impl/codegen/service_type.h>
#include <grpcpp/impl/codegen/sync_stream.h>
#include "monster_test.grpc.fb.h"
namespace MyGame {
namespace Example {
static const char* MonsterStorage_method_names[] = {
"/MyGame.Example.MonsterStorage/Store",
"/MyGame.Example.MonsterStorage/Retrieve",
"/MyGame.Example.MonsterStorage/GetMaxHitPoint",
"/MyGame.Example.MonsterStorage/GetMinMaxHitPoints",
"/MyGame.Example.MonsterStorage/Store",
"/MyGame.Example.MonsterStorage/Retrieve",
"/MyGame.Example.MonsterStorage/GetMaxHitPoint",
"/MyGame.Example.MonsterStorage/GetMinMaxHitPoints",
};
std::unique_ptr< MonsterStorage::Stub> MonsterStorage::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& /*options*/) {
std::unique_ptr< MonsterStorage::Stub> stub(new MonsterStorage::Stub(channel));
std::unique_ptr<MonsterStorage::Stub> MonsterStorage::NewStub(
const std::shared_ptr<::grpc::ChannelInterface>& channel,
const ::grpc::StubOptions& /*options*/) {
std::unique_ptr<MonsterStorage::Stub> stub(new MonsterStorage::Stub(channel));
return stub;
}
MonsterStorage::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
: channel_(channel) , rpcmethod_Store_(MonsterStorage_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_Retrieve_(MonsterStorage_method_names[1], ::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
, rpcmethod_GetMaxHitPoint_(MonsterStorage_method_names[2], ::grpc::internal::RpcMethod::CLIENT_STREAMING, channel)
, rpcmethod_GetMinMaxHitPoints_(MonsterStorage_method_names[3], ::grpc::internal::RpcMethod::BIDI_STREAMING, channel)
{}
::grpc::Status MonsterStorage::Stub::Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) {
return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_Store_, context, request, response);
MonsterStorage::Stub::Stub(
const std::shared_ptr<::grpc::ChannelInterface>& channel)
: channel_(channel),
rpcmethod_Store_(MonsterStorage_method_names[0],
::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_Retrieve_(MonsterStorage_method_names[1],
::grpc::internal::RpcMethod::SERVER_STREAMING,
channel),
rpcmethod_GetMaxHitPoint_(MonsterStorage_method_names[2],
::grpc::internal::RpcMethod::CLIENT_STREAMING,
channel),
rpcmethod_GetMinMaxHitPoints_(MonsterStorage_method_names[3],
::grpc::internal::RpcMethod::BIDI_STREAMING,
channel) {}
::grpc::Status MonsterStorage::Stub::Store(
::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
flatbuffers::grpc::Message<Stat>* response) {
return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_Store_,
context, request, response);
}
::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory< flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_Store_, context, request, true);
::grpc::ClientAsyncResponseReader<flatbuffers::grpc::Message<Stat>>*
MonsterStorage::Stub::AsyncStoreRaw(
::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory<
flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq,
rpcmethod_Store_, context,
request, true);
}
::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory< flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_Store_, context, request, false);
::grpc::ClientAsyncResponseReader<flatbuffers::grpc::Message<Stat>>*
MonsterStorage::Stub::PrepareAsyncStoreRaw(
::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderFactory<
flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq,
rpcmethod_Store_, context,
request, false);
}
::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
return ::grpc::internal::ClientReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), rpcmethod_Retrieve_, context, request);
::grpc::ClientReader<flatbuffers::grpc::Message<Monster>>*
MonsterStorage::Stub::RetrieveRaw(
::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request) {
return ::grpc::internal::ClientReaderFactory<
flatbuffers::grpc::Message<Monster>>::Create(channel_.get(),
rpcmethod_Retrieve_, context,
request);
}
::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
return ::grpc::internal::ClientAsyncReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_Retrieve_, context, request, true, tag);
::grpc::ClientAsyncReader<flatbuffers::grpc::Message<Monster>>*
MonsterStorage::Stub::AsyncRetrieveRaw(
::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq, void* tag) {
return ::grpc::internal::ClientAsyncReaderFactory<
flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq,
rpcmethod_Retrieve_, context,
request, true, tag);
}
::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncReaderFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_Retrieve_, context, request, false, nullptr);
::grpc::ClientAsyncReader<flatbuffers::grpc::Message<Monster>>*
MonsterStorage::Stub::PrepareAsyncRetrieveRaw(
::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncReaderFactory<
flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq,
rpcmethod_Retrieve_, context,
request, false, nullptr);
}
::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
return ::grpc::internal::ClientWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), rpcmethod_GetMaxHitPoint_, context, response);
::grpc::ClientWriter<flatbuffers::grpc::Message<Monster>>*
MonsterStorage::Stub::GetMaxHitPointRaw(
::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response) {
return ::grpc::internal::ClientWriterFactory<
flatbuffers::grpc::Message<Monster>>::Create(channel_.get(),
rpcmethod_GetMaxHitPoint_,
context, response);
}
::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
return ::grpc::internal::ClientAsyncWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_GetMaxHitPoint_, context, response, true, tag);
::grpc::ClientAsyncWriter<flatbuffers::grpc::Message<Monster>>*
MonsterStorage::Stub::AsyncGetMaxHitPointRaw(
::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq, void* tag) {
return ::grpc::internal::ClientAsyncWriterFactory<
flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq,
rpcmethod_GetMaxHitPoint_,
context, response, true,
tag);
}
::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* MonsterStorage::Stub::PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncWriterFactory< flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq, rpcmethod_GetMaxHitPoint_, context, response, false, nullptr);
::grpc::ClientAsyncWriter<flatbuffers::grpc::Message<Monster>>*
MonsterStorage::Stub::PrepareAsyncGetMaxHitPointRaw(
::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncWriterFactory<
flatbuffers::grpc::Message<Monster>>::Create(channel_.get(), cq,
rpcmethod_GetMaxHitPoint_,
context, response, false,
nullptr);
}
::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::GetMinMaxHitPointsRaw(::grpc::ClientContext* context) {
return ::grpc::internal::ClientReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), rpcmethod_GetMinMaxHitPoints_, context);
::grpc::ClientReaderWriter<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>*
MonsterStorage::Stub::GetMinMaxHitPointsRaw(::grpc::ClientContext* context) {
return ::grpc::internal::ClientReaderWriterFactory<
flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>::Create(channel_.get(),
rpcmethod_GetMinMaxHitPoints_,
context);
}
::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
return ::grpc::internal::ClientAsyncReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_GetMinMaxHitPoints_, context, true, tag);
::grpc::ClientAsyncReaderWriter<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>*
MonsterStorage::Stub::AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context,
::grpc::CompletionQueue* cq,
void* tag) {
return ::grpc::internal::ClientAsyncReaderWriterFactory<
flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq,
rpcmethod_GetMinMaxHitPoints_,
context, true, tag);
}
::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* MonsterStorage::Stub::PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncReaderWriterFactory< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq, rpcmethod_GetMinMaxHitPoints_, context, false, nullptr);
::grpc::ClientAsyncReaderWriter<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>*
MonsterStorage::Stub::PrepareAsyncGetMinMaxHitPointsRaw(
::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncReaderWriterFactory<
flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>::Create(channel_.get(), cq,
rpcmethod_GetMinMaxHitPoints_,
context, false, nullptr);
}
MonsterStorage::Service::Service() {
AddMethod(new ::grpc::internal::RpcServiceMethod(
MonsterStorage_method_names[0],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
MonsterStorage_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<
MonsterStorage::Service, flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>(
std::mem_fn(&MonsterStorage::Service::Store), this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
MonsterStorage_method_names[1],
::grpc::internal::RpcMethod::SERVER_STREAMING,
new ::grpc::internal::ServerStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>(
new ::grpc::internal::ServerStreamingHandler<
MonsterStorage::Service, flatbuffers::grpc::Message<Stat>,
flatbuffers::grpc::Message<Monster>>(
std::mem_fn(&MonsterStorage::Service::Retrieve), this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
MonsterStorage_method_names[2],
::grpc::internal::RpcMethod::CLIENT_STREAMING,
new ::grpc::internal::ClientStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
new ::grpc::internal::ClientStreamingHandler<
MonsterStorage::Service, flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>(
std::mem_fn(&MonsterStorage::Service::GetMaxHitPoint), this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
MonsterStorage_method_names[3],
::grpc::internal::RpcMethod::BIDI_STREAMING,
new ::grpc::internal::BidiStreamingHandler< MonsterStorage::Service, flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(
new ::grpc::internal::BidiStreamingHandler<
MonsterStorage::Service, flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>(
std::mem_fn(&MonsterStorage::Service::GetMinMaxHitPoints), this)));
}
MonsterStorage::Service::~Service() {
}
MonsterStorage::Service::~Service() {}
::grpc::Status MonsterStorage::Service::Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) {
::grpc::Status MonsterStorage::Service::Store(
::grpc::ServerContext* /*context*/,
const flatbuffers::grpc::Message<Monster>* /*request*/,
flatbuffers::grpc::Message<Stat>* /*response*/) {
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status MonsterStorage::Service::Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) {
::grpc::Status MonsterStorage::Service::Retrieve(
::grpc::ServerContext* /*context*/,
const flatbuffers::grpc::Message<Stat>* /*request*/,
::grpc::ServerWriter<flatbuffers::grpc::Message<Monster>>* /*writer*/) {
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status MonsterStorage::Service::GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) {
::grpc::Status MonsterStorage::Service::GetMaxHitPoint(
::grpc::ServerContext* /*context*/,
::grpc::ServerReader<flatbuffers::grpc::Message<Monster>>* /*reader*/,
flatbuffers::grpc::Message<Stat>* /*response*/) {
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status MonsterStorage::Service::GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) {
::grpc::Status MonsterStorage::Service::GetMinMaxHitPoints(
::grpc::ServerContext* /*context*/,
::grpc::ServerReaderWriter<
flatbuffers::grpc::Message<Stat>,
flatbuffers::grpc::Message<Monster>>* /*stream*/) {
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
} // namespace MyGame
} // namespace Example
} // namespace MyGame

View File

@@ -4,9 +4,6 @@
#ifndef GRPC_monster_5ftest__INCLUDED
#define GRPC_monster_5ftest__INCLUDED
#include "monster_test_generated.h"
#include "flatbuffers/grpc.h"
#include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h>
#include <grpcpp/impl/codegen/method_handler.h>
@@ -17,6 +14,9 @@
#include <grpcpp/impl/codegen/stub_options.h>
#include <grpcpp/impl/codegen/sync_stream.h>
#include "flatbuffers/grpc.h"
#include "monster_test_generated.h"
namespace grpc {
class CompletionQueue;
class Channel;
@@ -35,184 +35,421 @@ class MonsterStorage final {
class StubInterface {
public:
virtual ~StubInterface() {}
virtual ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) = 0;
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>>(AsyncStoreRaw(context, request, cq));
virtual ::grpc::Status Store(
::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
flatbuffers::grpc::Message<Stat>* response) = 0;
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<
flatbuffers::grpc::Message<Stat>>>
AsyncStore(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<
flatbuffers::grpc::Message<Stat>>>(
AsyncStoreRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>> PrepareAsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>>(PrepareAsyncStoreRaw(context, request, cq));
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<
flatbuffers::grpc::Message<Stat>>>
PrepareAsyncStore(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<
flatbuffers::grpc::Message<Stat>>>(
PrepareAsyncStoreRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
return std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>>(RetrieveRaw(context, request));
std::unique_ptr<
::grpc::ClientReaderInterface<flatbuffers::grpc::Message<Monster>>>
Retrieve(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request) {
return std::unique_ptr<
::grpc::ClientReaderInterface<flatbuffers::grpc::Message<Monster>>>(
RetrieveRaw(context, request));
}
std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag));
std::unique_ptr<
::grpc::ClientAsyncReaderInterface<flatbuffers::grpc::Message<Monster>>>
AsyncRetrieve(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr<::grpc::ClientAsyncReaderInterface<
flatbuffers::grpc::Message<Monster>>>(
AsyncRetrieveRaw(context, request, cq, tag));
}
std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>> PrepareAsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncRetrieveRaw(context, request, cq));
std::unique_ptr<
::grpc::ClientAsyncReaderInterface<flatbuffers::grpc::Message<Monster>>>
PrepareAsyncRetrieve(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<::grpc::ClientAsyncReaderInterface<
flatbuffers::grpc::Message<Monster>>>(
PrepareAsyncRetrieveRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>> GetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
return std::unique_ptr< ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>>(GetMaxHitPointRaw(context, response));
std::unique_ptr<
::grpc::ClientWriterInterface<flatbuffers::grpc::Message<Monster>>>
GetMaxHitPoint(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response) {
return std::unique_ptr<
::grpc::ClientWriterInterface<flatbuffers::grpc::Message<Monster>>>(
GetMaxHitPointRaw(context, response));
}
std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>> AsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>>(AsyncGetMaxHitPointRaw(context, response, cq, tag));
std::unique_ptr<
::grpc::ClientAsyncWriterInterface<flatbuffers::grpc::Message<Monster>>>
AsyncGetMaxHitPoint(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr<::grpc::ClientAsyncWriterInterface<
flatbuffers::grpc::Message<Monster>>>(
AsyncGetMaxHitPointRaw(context, response, cq, tag));
}
std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>> PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncGetMaxHitPointRaw(context, response, cq));
std::unique_ptr<
::grpc::ClientAsyncWriterInterface<flatbuffers::grpc::Message<Monster>>>
PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<::grpc::ClientAsyncWriterInterface<
flatbuffers::grpc::Message<Monster>>>(
PrepareAsyncGetMaxHitPointRaw(context, response, cq));
}
std::unique_ptr< ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> GetMinMaxHitPoints(::grpc::ClientContext* context) {
return std::unique_ptr< ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(GetMinMaxHitPointsRaw(context));
std::unique_ptr<::grpc::ClientReaderWriterInterface<
flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>
GetMinMaxHitPoints(::grpc::ClientContext* context) {
return std::unique_ptr<::grpc::ClientReaderWriterInterface<
flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>>(GetMinMaxHitPointsRaw(context));
}
std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> AsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(AsyncGetMinMaxHitPointsRaw(context, cq, tag));
std::unique_ptr<::grpc::ClientAsyncReaderWriterInterface<
flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>
AsyncGetMinMaxHitPoints(::grpc::ClientContext* context,
::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr<::grpc::ClientAsyncReaderWriterInterface<
flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>>(
AsyncGetMinMaxHitPointsRaw(context, cq, tag));
}
std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
std::unique_ptr<::grpc::ClientAsyncReaderWriterInterface<
flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>
PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<::grpc::ClientAsyncReaderWriterInterface<
flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>>(
PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
}
private:
virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::grpc::Message<Stat>>* PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientReaderInterface< flatbuffers::grpc::Message<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) = 0;
virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) = 0;
virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::grpc::Message<Monster>>* PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientWriterInterface< flatbuffers::grpc::Message<Monster>>* GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) = 0;
virtual ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>* AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) = 0;
virtual ::grpc::ClientAsyncWriterInterface< flatbuffers::grpc::Message<Monster>>* PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* GetMinMaxHitPointsRaw(::grpc::ClientContext* context) = 0;
virtual ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) = 0;
virtual ::grpc::ClientAsyncReaderWriterInterface< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) = 0;
private:
virtual ::grpc::ClientAsyncResponseReaderInterface<
flatbuffers::grpc::Message<Stat>>*
AsyncStoreRaw(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<
flatbuffers::grpc::Message<Stat>>*
PrepareAsyncStoreRaw(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientReaderInterface<flatbuffers::grpc::Message<Monster>>*
RetrieveRaw(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request) = 0;
virtual ::grpc::ClientAsyncReaderInterface<
flatbuffers::grpc::Message<Monster>>*
AsyncRetrieveRaw(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq, void* tag) = 0;
virtual ::grpc::ClientAsyncReaderInterface<
flatbuffers::grpc::Message<Monster>>*
PrepareAsyncRetrieveRaw(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientWriterInterface<flatbuffers::grpc::Message<Monster>>*
GetMaxHitPointRaw(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response) = 0;
virtual ::grpc::ClientAsyncWriterInterface<
flatbuffers::grpc::Message<Monster>>*
AsyncGetMaxHitPointRaw(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq, void* tag) = 0;
virtual ::grpc::ClientAsyncWriterInterface<
flatbuffers::grpc::Message<Monster>>*
PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientReaderWriterInterface<
flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>*
GetMinMaxHitPointsRaw(::grpc::ClientContext* context) = 0;
virtual ::grpc::ClientAsyncReaderWriterInterface<
flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>*
AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context,
::grpc::CompletionQueue* cq, void* tag) = 0;
virtual ::grpc::ClientAsyncReaderWriterInterface<
flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>*
PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context,
::grpc::CompletionQueue* cq) = 0;
};
class Stub final : public StubInterface {
public:
Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, flatbuffers::grpc::Message<Stat>* response) override;
std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>>(AsyncStoreRaw(context, request, cq));
Stub(const std::shared_ptr<::grpc::ChannelInterface>& channel);
::grpc::Status Store(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
flatbuffers::grpc::Message<Stat>* response) override;
std::unique_ptr<
::grpc::ClientAsyncResponseReader<flatbuffers::grpc::Message<Stat>>>
AsyncStore(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<
::grpc::ClientAsyncResponseReader<flatbuffers::grpc::Message<Stat>>>(
AsyncStoreRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>> PrepareAsyncStore(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>>(PrepareAsyncStoreRaw(context, request, cq));
std::unique_ptr<
::grpc::ClientAsyncResponseReader<flatbuffers::grpc::Message<Stat>>>
PrepareAsyncStore(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<
::grpc::ClientAsyncResponseReader<flatbuffers::grpc::Message<Stat>>>(
PrepareAsyncStoreRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) {
return std::unique_ptr< ::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>>(RetrieveRaw(context, request));
std::unique_ptr<::grpc::ClientReader<flatbuffers::grpc::Message<Monster>>>
Retrieve(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request) {
return std::unique_ptr<
::grpc::ClientReader<flatbuffers::grpc::Message<Monster>>>(
RetrieveRaw(context, request));
}
std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag));
std::unique_ptr<
::grpc::ClientAsyncReader<flatbuffers::grpc::Message<Monster>>>
AsyncRetrieve(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr<
::grpc::ClientAsyncReader<flatbuffers::grpc::Message<Monster>>>(
AsyncRetrieveRaw(context, request, cq, tag));
}
std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>> PrepareAsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncRetrieveRaw(context, request, cq));
std::unique_ptr<
::grpc::ClientAsyncReader<flatbuffers::grpc::Message<Monster>>>
PrepareAsyncRetrieve(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<
::grpc::ClientAsyncReader<flatbuffers::grpc::Message<Monster>>>(
PrepareAsyncRetrieveRaw(context, request, cq));
}
std::unique_ptr< ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>> GetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) {
return std::unique_ptr< ::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>>(GetMaxHitPointRaw(context, response));
std::unique_ptr<::grpc::ClientWriter<flatbuffers::grpc::Message<Monster>>>
GetMaxHitPoint(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response) {
return std::unique_ptr<
::grpc::ClientWriter<flatbuffers::grpc::Message<Monster>>>(
GetMaxHitPointRaw(context, response));
}
std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>> AsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>>(AsyncGetMaxHitPointRaw(context, response, cq, tag));
std::unique_ptr<
::grpc::ClientAsyncWriter<flatbuffers::grpc::Message<Monster>>>
AsyncGetMaxHitPoint(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr<
::grpc::ClientAsyncWriter<flatbuffers::grpc::Message<Monster>>>(
AsyncGetMaxHitPointRaw(context, response, cq, tag));
}
std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>> PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>>(PrepareAsyncGetMaxHitPointRaw(context, response, cq));
std::unique_ptr<
::grpc::ClientAsyncWriter<flatbuffers::grpc::Message<Monster>>>
PrepareAsyncGetMaxHitPoint(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<
::grpc::ClientAsyncWriter<flatbuffers::grpc::Message<Monster>>>(
PrepareAsyncGetMaxHitPointRaw(context, response, cq));
}
std::unique_ptr< ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> GetMinMaxHitPoints(::grpc::ClientContext* context) {
return std::unique_ptr< ::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(GetMinMaxHitPointsRaw(context));
std::unique_ptr<::grpc::ClientReaderWriter<
flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>
GetMinMaxHitPoints(::grpc::ClientContext* context) {
return std::unique_ptr<
::grpc::ClientReaderWriter<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>>(
GetMinMaxHitPointsRaw(context));
}
std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> AsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(AsyncGetMinMaxHitPointsRaw(context, cq, tag));
std::unique_ptr<::grpc::ClientAsyncReaderWriter<
flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>
AsyncGetMinMaxHitPoints(::grpc::ClientContext* context,
::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr<
::grpc::ClientAsyncReaderWriter<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>>(
AsyncGetMinMaxHitPointsRaw(context, cq, tag));
}
std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>> PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>(PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
std::unique_ptr<::grpc::ClientAsyncReaderWriter<
flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>>
PrepareAsyncGetMinMaxHitPoints(::grpc::ClientContext* context,
::grpc::CompletionQueue* cq) {
return std::unique_ptr<
::grpc::ClientAsyncReaderWriter<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>>(
PrepareAsyncGetMinMaxHitPointsRaw(context, cq));
}
private:
std::shared_ptr< ::grpc::ChannelInterface> channel_;
::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< flatbuffers::grpc::Message<Stat>>* PrepareAsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Monster>& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientReader< flatbuffers::grpc::Message<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request) override;
::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) override;
::grpc::ClientAsyncReader< flatbuffers::grpc::Message<Monster>>* PrepareAsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::grpc::Message<Stat>& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientWriter< flatbuffers::grpc::Message<Monster>>* GetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response) override;
::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* AsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq, void* tag) override;
::grpc::ClientAsyncWriter< flatbuffers::grpc::Message<Monster>>* PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context, flatbuffers::grpc::Message<Stat>* response, ::grpc::CompletionQueue* cq) override;
::grpc::ClientReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* GetMinMaxHitPointsRaw(::grpc::ClientContext* context) override;
::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) override;
::grpc::ClientAsyncReaderWriter< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>* PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) override;
std::shared_ptr<::grpc::ChannelInterface> channel_;
::grpc::ClientAsyncResponseReader<flatbuffers::grpc::Message<Stat>>*
AsyncStoreRaw(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<flatbuffers::grpc::Message<Stat>>*
PrepareAsyncStoreRaw(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Monster>& request,
::grpc::CompletionQueue* cq) override;
::grpc::ClientReader<flatbuffers::grpc::Message<Monster>>* RetrieveRaw(
::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request) override;
::grpc::ClientAsyncReader<flatbuffers::grpc::Message<Monster>>*
AsyncRetrieveRaw(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq, void* tag) override;
::grpc::ClientAsyncReader<flatbuffers::grpc::Message<Monster>>*
PrepareAsyncRetrieveRaw(::grpc::ClientContext* context,
const flatbuffers::grpc::Message<Stat>& request,
::grpc::CompletionQueue* cq) override;
::grpc::ClientWriter<flatbuffers::grpc::Message<Monster>>*
GetMaxHitPointRaw(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response) override;
::grpc::ClientAsyncWriter<flatbuffers::grpc::Message<Monster>>*
AsyncGetMaxHitPointRaw(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq, void* tag) override;
::grpc::ClientAsyncWriter<flatbuffers::grpc::Message<Monster>>*
PrepareAsyncGetMaxHitPointRaw(::grpc::ClientContext* context,
flatbuffers::grpc::Message<Stat>* response,
::grpc::CompletionQueue* cq) override;
::grpc::ClientReaderWriter<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>*
GetMinMaxHitPointsRaw(::grpc::ClientContext* context) override;
::grpc::ClientAsyncReaderWriter<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>*
AsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context,
::grpc::CompletionQueue* cq, void* tag) override;
::grpc::ClientAsyncReaderWriter<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>*
PrepareAsyncGetMinMaxHitPointsRaw(::grpc::ClientContext* context,
::grpc::CompletionQueue* cq) override;
const ::grpc::internal::RpcMethod rpcmethod_Store_;
const ::grpc::internal::RpcMethod rpcmethod_Retrieve_;
const ::grpc::internal::RpcMethod rpcmethod_GetMaxHitPoint_;
const ::grpc::internal::RpcMethod rpcmethod_GetMinMaxHitPoints_;
};
static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
static std::unique_ptr<Stub> NewStub(
const std::shared_ptr<::grpc::ChannelInterface>& channel,
const ::grpc::StubOptions& options = ::grpc::StubOptions());
class Service : public ::grpc::Service {
public:
Service();
virtual ~Service();
virtual ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::grpc::Message<Monster>* request, flatbuffers::grpc::Message<Stat>* response);
virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::grpc::Message<Stat>* request, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* writer);
virtual ::grpc::Status GetMaxHitPoint(::grpc::ServerContext* context, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* reader, flatbuffers::grpc::Message<Stat>* response);
virtual ::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* stream);
virtual ::grpc::Status Store(
::grpc::ServerContext* context,
const flatbuffers::grpc::Message<Monster>* request,
flatbuffers::grpc::Message<Stat>* response);
virtual ::grpc::Status Retrieve(
::grpc::ServerContext* context,
const flatbuffers::grpc::Message<Stat>* request,
::grpc::ServerWriter<flatbuffers::grpc::Message<Monster>>* writer);
virtual ::grpc::Status GetMaxHitPoint(
::grpc::ServerContext* context,
::grpc::ServerReader<flatbuffers::grpc::Message<Monster>>* reader,
flatbuffers::grpc::Message<Stat>* response);
virtual ::grpc::Status GetMinMaxHitPoints(
::grpc::ServerContext* context,
::grpc::ServerReaderWriter<flatbuffers::grpc::Message<Stat>,
flatbuffers::grpc::Message<Monster>>*
stream);
};
template <class BaseClass>
class WithAsyncMethod_Store : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithAsyncMethod_Store() {
::grpc::Service::MarkMethodAsync(0);
}
WithAsyncMethod_Store() { ::grpc::Service::MarkMethodAsync(0); }
~WithAsyncMethod_Store() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
::grpc::Status Store(
::grpc::ServerContext* /*context*/,
const flatbuffers::grpc::Message<Monster>* /*request*/,
flatbuffers::grpc::Message<Stat>* /*response*/) final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestStore(::grpc::ServerContext* context, flatbuffers::grpc::Message<Monster>* request, ::grpc::ServerAsyncResponseWriter< flatbuffers::grpc::Message<Stat>>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
void RequestStore(
::grpc::ServerContext* context,
flatbuffers::grpc::Message<Monster>* request,
::grpc::ServerAsyncResponseWriter<flatbuffers::grpc::Message<Stat>>*
response,
::grpc::CompletionQueue* new_call_cq,
::grpc::ServerCompletionQueue* notification_cq, void* tag) {
::grpc::Service::RequestAsyncUnary(0, context, request, response,
new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithAsyncMethod_Retrieve : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithAsyncMethod_Retrieve() {
::grpc::Service::MarkMethodAsync(1);
}
WithAsyncMethod_Retrieve() { ::grpc::Service::MarkMethodAsync(1); }
~WithAsyncMethod_Retrieve() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
::grpc::Status Retrieve(
::grpc::ServerContext* /*context*/,
const flatbuffers::grpc::Message<Stat>* /*request*/,
::grpc::ServerWriter<flatbuffers::grpc::Message<Monster>>* /*writer*/)
final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestRetrieve(::grpc::ServerContext* context, flatbuffers::grpc::Message<Stat>* request, ::grpc::ServerAsyncWriter< flatbuffers::grpc::Message<Monster>>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncServerStreaming(1, context, request, writer, new_call_cq, notification_cq, tag);
void RequestRetrieve(
::grpc::ServerContext* context,
flatbuffers::grpc::Message<Stat>* request,
::grpc::ServerAsyncWriter<flatbuffers::grpc::Message<Monster>>* writer,
::grpc::CompletionQueue* new_call_cq,
::grpc::ServerCompletionQueue* notification_cq, void* tag) {
::grpc::Service::RequestAsyncServerStreaming(
1, context, request, writer, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithAsyncMethod_GetMaxHitPoint : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithAsyncMethod_GetMaxHitPoint() {
::grpc::Service::MarkMethodAsync(2);
}
WithAsyncMethod_GetMaxHitPoint() { ::grpc::Service::MarkMethodAsync(2); }
~WithAsyncMethod_GetMaxHitPoint() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
::grpc::Status GetMaxHitPoint(
::grpc::ServerContext* /*context*/,
::grpc::ServerReader<flatbuffers::grpc::Message<Monster>>* /*reader*/,
flatbuffers::grpc::Message<Stat>* /*response*/) final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestGetMaxHitPoint(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncClientStreaming(2, context, reader, new_call_cq, notification_cq, tag);
void RequestGetMaxHitPoint(
::grpc::ServerContext* context,
::grpc::ServerAsyncReader<flatbuffers::grpc::Message<Stat>,
flatbuffers::grpc::Message<Monster>>* reader,
::grpc::CompletionQueue* new_call_cq,
::grpc::ServerCompletionQueue* notification_cq, void* tag) {
::grpc::Service::RequestAsyncClientStreaming(
2, context, reader, new_call_cq, notification_cq, tag);
}
};
template <class BaseClass>
class WithAsyncMethod_GetMinMaxHitPoints : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithAsyncMethod_GetMinMaxHitPoints() {
::grpc::Service::MarkMethodAsync(3);
@@ -221,28 +458,44 @@ class MonsterStorage final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
::grpc::Status GetMinMaxHitPoints(
::grpc::ServerContext* /*context*/,
::grpc::ServerReaderWriter<
flatbuffers::grpc::Message<Stat>,
flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestGetMinMaxHitPoints(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
::grpc::Service::RequestAsyncBidiStreaming(3, context, stream, new_call_cq, notification_cq, tag);
void RequestGetMinMaxHitPoints(
::grpc::ServerContext* context,
::grpc::ServerAsyncReaderWriter<flatbuffers::grpc::Message<Stat>,
flatbuffers::grpc::Message<Monster>>*
stream,
::grpc::CompletionQueue* new_call_cq,
::grpc::ServerCompletionQueue* notification_cq, void* tag) {
::grpc::Service::RequestAsyncBidiStreaming(
3, context, stream, new_call_cq, notification_cq, tag);
}
};
typedef WithAsyncMethod_Store< WithAsyncMethod_Retrieve< WithAsyncMethod_GetMaxHitPoint< WithAsyncMethod_GetMinMaxHitPoints< Service > > > > AsyncService;
typedef WithAsyncMethod_Store<
WithAsyncMethod_Retrieve<WithAsyncMethod_GetMaxHitPoint<
WithAsyncMethod_GetMinMaxHitPoints<Service>>>>
AsyncService;
template <class BaseClass>
class WithGenericMethod_Store : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithGenericMethod_Store() {
::grpc::Service::MarkMethodGeneric(0);
}
WithGenericMethod_Store() { ::grpc::Service::MarkMethodGeneric(0); }
~WithGenericMethod_Store() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
::grpc::Status Store(
::grpc::ServerContext* /*context*/,
const flatbuffers::grpc::Message<Monster>* /*request*/,
flatbuffers::grpc::Message<Stat>* /*response*/) final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -250,16 +503,19 @@ class MonsterStorage final {
template <class BaseClass>
class WithGenericMethod_Retrieve : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithGenericMethod_Retrieve() {
::grpc::Service::MarkMethodGeneric(1);
}
WithGenericMethod_Retrieve() { ::grpc::Service::MarkMethodGeneric(1); }
~WithGenericMethod_Retrieve() override {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
::grpc::Status Retrieve(
::grpc::ServerContext* /*context*/,
const flatbuffers::grpc::Message<Stat>* /*request*/,
::grpc::ServerWriter<flatbuffers::grpc::Message<Monster>>* /*writer*/)
final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -267,7 +523,8 @@ class MonsterStorage final {
template <class BaseClass>
class WithGenericMethod_GetMaxHitPoint : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithGenericMethod_GetMaxHitPoint() {
::grpc::Service::MarkMethodGeneric(2);
@@ -276,7 +533,10 @@ class MonsterStorage final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status GetMaxHitPoint(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< flatbuffers::grpc::Message<Monster>>* /*reader*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
::grpc::Status GetMaxHitPoint(
::grpc::ServerContext* /*context*/,
::grpc::ServerReader<flatbuffers::grpc::Message<Monster>>* /*reader*/,
flatbuffers::grpc::Message<Stat>* /*response*/) final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -284,7 +544,8 @@ class MonsterStorage final {
template <class BaseClass>
class WithGenericMethod_GetMinMaxHitPoints : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithGenericMethod_GetMinMaxHitPoints() {
::grpc::Service::MarkMethodGeneric(3);
@@ -293,7 +554,11 @@ class MonsterStorage final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status GetMinMaxHitPoints(::grpc::ServerContext* /*context*/, ::grpc::ServerReaderWriter< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
::grpc::Status GetMinMaxHitPoints(
::grpc::ServerContext* /*context*/,
::grpc::ServerReaderWriter<
flatbuffers::grpc::Message<Stat>,
flatbuffers::grpc::Message<Monster>>* /*stream*/) final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -301,50 +566,77 @@ class MonsterStorage final {
template <class BaseClass>
class WithStreamedUnaryMethod_Store : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) {}
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithStreamedUnaryMethod_Store() {
::grpc::Service::MarkMethodStreamed(0,
new ::grpc::internal::StreamedUnaryHandler< flatbuffers::grpc::Message<Monster>, flatbuffers::grpc::Message<Stat>>(std::bind(&WithStreamedUnaryMethod_Store<BaseClass>::StreamedStore, this, std::placeholders::_1, std::placeholders::_2)));
::grpc::Service::MarkMethodStreamed(
0, new ::grpc::internal::StreamedUnaryHandler<
flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>(std::bind(
&WithStreamedUnaryMethod_Store<BaseClass>::StreamedStore, this,
std::placeholders::_1, std::placeholders::_2)));
}
~WithStreamedUnaryMethod_Store() override {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
::grpc::Status Store(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Monster>* /*request*/, flatbuffers::grpc::Message<Stat>* /*response*/) final override {
::grpc::Status Store(
::grpc::ServerContext* /*context*/,
const flatbuffers::grpc::Message<Monster>* /*request*/,
flatbuffers::grpc::Message<Stat>* /*response*/) final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
// replace default version of method with streamed unary
virtual ::grpc::Status StreamedStore(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< flatbuffers::grpc::Message<Monster>,flatbuffers::grpc::Message<Stat>>* server_unary_streamer) = 0;
virtual ::grpc::Status StreamedStore(
::grpc::ServerContext* context,
::grpc::ServerUnaryStreamer<flatbuffers::grpc::Message<Monster>,
flatbuffers::grpc::Message<Stat>>*
server_unary_streamer) = 0;
};
typedef WithStreamedUnaryMethod_Store< Service > StreamedUnaryService;
typedef WithStreamedUnaryMethod_Store<Service> StreamedUnaryService;
template <class BaseClass>
class WithSplitStreamingMethod_Retrieve : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service */*service*/) { }
void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
public:
WithSplitStreamingMethod_Retrieve() {
::grpc::Service::MarkMethodStreamed(1,
new ::grpc::internal::SplitServerStreamingHandler< flatbuffers::grpc::Message<Stat>, flatbuffers::grpc::Message<Monster>>(std::bind(&WithSplitStreamingMethod_Retrieve<BaseClass>::StreamedRetrieve, this, std::placeholders::_1, std::placeholders::_2)));
::grpc::Service::MarkMethodStreamed(
1,
new ::grpc::internal::SplitServerStreamingHandler<
flatbuffers::grpc::Message<Stat>,
flatbuffers::grpc::Message<Monster>>(std::bind(
&WithSplitStreamingMethod_Retrieve<BaseClass>::StreamedRetrieve,
this, std::placeholders::_1, std::placeholders::_2)));
}
~WithSplitStreamingMethod_Retrieve() override {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
::grpc::Status Retrieve(::grpc::ServerContext* /*context*/, const flatbuffers::grpc::Message<Stat>* /*request*/, ::grpc::ServerWriter< flatbuffers::grpc::Message<Monster>>* /*writer*/) final override {
::grpc::Status Retrieve(
::grpc::ServerContext* /*context*/,
const flatbuffers::grpc::Message<Stat>* /*request*/,
::grpc::ServerWriter<flatbuffers::grpc::Message<Monster>>* /*writer*/)
final override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
// replace default version of method with split streamed
virtual ::grpc::Status StreamedRetrieve(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< flatbuffers::grpc::Message<Stat>,flatbuffers::grpc::Message<Monster>>* server_split_streamer) = 0;
virtual ::grpc::Status StreamedRetrieve(
::grpc::ServerContext* context,
::grpc::ServerSplitStreamer<flatbuffers::grpc::Message<Stat>,
flatbuffers::grpc::Message<Monster>>*
server_split_streamer) = 0;
};
typedef WithSplitStreamingMethod_Retrieve< Service > SplitStreamedService;
typedef WithStreamedUnaryMethod_Store< WithSplitStreamingMethod_Retrieve< Service > > StreamedService;
typedef WithSplitStreamingMethod_Retrieve<Service> SplitStreamedService;
typedef WithStreamedUnaryMethod_Store<
WithSplitStreamingMethod_Retrieve<Service>>
StreamedService;
};
} // namespace Example
} // namespace MyGame
#endif // GRPC_monster_5ftest__INCLUDED

View File

@@ -1,19 +1,42 @@
// automatically generated by the FlatBuffers compiler, do not modify
export { Monster as MyGame_Example2_Monster, MonsterT as MyGame_Example2_MonsterT } from './my-game/example2/monster';
export { Ability, AbilityT } from './my-game/example/ability';
export { Any, unionToAny, unionListToAny } from './my-game/example/any';
export { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from './my-game/example/any-ambiguous-aliases';
export { AnyUniqueAliases, unionToAnyUniqueAliases, unionListToAnyUniqueAliases } from './my-game/example/any-unique-aliases';
export { Color } from './my-game/example/color';
export { Monster, MonsterT } from './my-game/example/monster';
export { Race } from './my-game/example/race';
export { Referrable, ReferrableT } from './my-game/example/referrable';
export { Stat, StatT } from './my-game/example/stat';
export { StructOfStructs, StructOfStructsT } from './my-game/example/struct-of-structs';
export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './my-game/example/struct-of-structs-of-structs';
export { Test, TestT } from './my-game/example/test';
export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './my-game/example/test-simple-table-with-enum';
export { TypeAliases, TypeAliasesT } from './my-game/example/type-aliases';
export { Vec3, Vec3T } from './my-game/example/vec3';
export { InParentNamespace, InParentNamespaceT } from './my-game/in-parent-namespace';
export {Ability, AbilityT} from './my-game/example/ability';
export {Any, unionListToAny, unionToAny} from './my-game/example/any';
export {
AnyAmbiguousAliases,
unionListToAnyAmbiguousAliases,
unionToAnyAmbiguousAliases,
} from './my-game/example/any-ambiguous-aliases';
export {
AnyUniqueAliases,
unionListToAnyUniqueAliases,
unionToAnyUniqueAliases,
} from './my-game/example/any-unique-aliases';
export {Color} from './my-game/example/color';
export {Monster, MonsterT} from './my-game/example/monster';
export {Race} from './my-game/example/race';
export {Referrable, ReferrableT} from './my-game/example/referrable';
export {Stat, StatT} from './my-game/example/stat';
export {
StructOfStructs,
StructOfStructsT,
} from './my-game/example/struct-of-structs';
export {
StructOfStructsOfStructs,
StructOfStructsOfStructsT,
} from './my-game/example/struct-of-structs-of-structs';
export {Test, TestT} from './my-game/example/test';
export {
TestSimpleTableWithEnum,
TestSimpleTableWithEnumT,
} from './my-game/example/test-simple-table-with-enum';
export {TypeAliases, TypeAliasesT} from './my-game/example/type-aliases';
export {Vec3, Vec3T} from './my-game/example/vec3';
export {
Monster as MyGame_Example2_Monster,
MonsterT as MyGame_Example2_MonsterT,
} from './my-game/example2/monster';
export {
InParentNamespace,
InParentNamespaceT,
} from './my-game/in-parent-namespace';

View File

@@ -4,13 +4,17 @@ package NamespaceA.NamespaceB;
@SuppressWarnings("unused")
public final class EnumInNestedNS {
private EnumInNestedNS() { }
private EnumInNestedNS() {}
public static final byte A = 0;
public static final byte B = 1;
public static final byte C = 2;
public static final String[] names = { "A", "B", "C", };
public static final String[] names = {
"A", "B", "C",
};
public static String name(int e) { return names[e]; }
public static String name(int e) {
return names[e];
}
}

View File

@@ -5,11 +5,12 @@ package NamespaceA.NamespaceB
@Suppress("unused")
@ExperimentalUnsignedTypes
class EnumInNestedNS private constructor() {
companion object {
const val A: Byte = 0
const val B: Byte = 1
const val C: Byte = 2
val names : Array<String> = arrayOf("A", "B", "C")
fun name(e: Int) : String = names[e]
}
companion object {
const val A: Byte = 0
const val B: Byte = 1
const val C: Byte = 2
val names: Array<String> = arrayOf("A", "B", "C")
fun name(e: Int): String = names[e]
}
}

View File

@@ -2,7 +2,8 @@
# namespace: NamespaceB
class EnumInNestedNS(object):
A = 0
B = 1
C = 2
A = 0
B = 1
C = 2

View File

@@ -12,7 +12,9 @@ type StructInNestedNST struct {
}
func (t *StructInNestedNST) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
if t == nil {
return 0
}
return CreateStructInNestedNS(builder, t.A, t.B)
}
func (rcv *StructInNestedNS) UnPackTo(t *StructInNestedNST) {
@@ -21,7 +23,9 @@ func (rcv *StructInNestedNS) UnPackTo(t *StructInNestedNST) {
}
func (rcv *StructInNestedNS) UnPack() *StructInNestedNST {
if rcv == nil { return nil }
if rcv == nil {
return nil
}
t := &StructInNestedNST{}
rcv.UnPackTo(t)
return t

View File

@@ -2,20 +2,36 @@
package NamespaceA.NamespaceB;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
@SuppressWarnings("unused")
public final class StructInNestedNS extends Struct {
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public StructInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public void __init(int _i, ByteBuffer _bb) {
__reset(_i, _bb);
}
public int a() { return bb.getInt(bb_pos + 0); }
public void mutateA(int a) { bb.putInt(bb_pos + 0, a); }
public int b() { return bb.getInt(bb_pos + 4); }
public void mutateB(int b) { bb.putInt(bb_pos + 4, b); }
public StructInNestedNS __assign(int _i, ByteBuffer _bb) {
__init(_i, _bb);
return this;
}
public int a() {
return bb.getInt(bb_pos + 0);
}
public void mutateA(int a) {
bb.putInt(bb_pos + 0, a);
}
public int b() {
return bb.getInt(bb_pos + 4);
}
public void mutateB(int b) {
bb.putInt(bb_pos + 4, b);
}
public static int createStructInNestedNS(FlatBufferBuilder builder, int a, int b) {
builder.prep(4, 8);
@@ -25,28 +41,35 @@ public final class StructInNestedNS extends Struct {
}
public static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) {
__reset(_vector, _element_size, _bb);
return this;
}
public StructInNestedNS get(int j) { return get(new StructInNestedNS(), j); }
public StructInNestedNS get(StructInNestedNS obj, int j) { return obj.__assign(__element(j), bb); }
public StructInNestedNS get(int j) {
return get(new StructInNestedNS(), j);
}
public StructInNestedNS get(StructInNestedNS obj, int j) {
return obj.__assign(__element(j), bb);
}
}
public StructInNestedNST unpack() {
StructInNestedNST _o = new StructInNestedNST();
unpackTo(_o);
return _o;
}
public void unpackTo(StructInNestedNST _o) {
int _oA = a();
_o.setA(_oA);
int _oB = b();
_o.setB(_oB);
}
public static int pack(FlatBufferBuilder builder, StructInNestedNST _o) {
if (_o == null) return 0;
return createStructInNestedNS(
builder,
_o.getA(),
_o.getB());
return createStructInNestedNS(builder, _o.getA(), _o.getB());
}
}

View File

@@ -2,43 +2,39 @@
package NamespaceA.NamespaceB
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
@Suppress("unused")
@ExperimentalUnsignedTypes
class StructInNestedNS : Struct() {
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
}
fun __assign(_i: Int, _bb: ByteBuffer) : StructInNestedNS {
__init(_i, _bb)
return this
}
val a : Int get() = bb.getInt(bb_pos + 0)
fun mutateA(a: Int) : ByteBuffer = bb.putInt(bb_pos + 0, a)
val b : Int get() = bb.getInt(bb_pos + 4)
fun mutateB(b: Int) : ByteBuffer = bb.putInt(bb_pos + 4, b)
companion object {
fun createStructInNestedNS(builder: FlatBufferBuilder, a: Int, b: Int) : Int {
builder.prep(4, 8)
builder.putInt(b)
builder.putInt(a)
return builder.offset()
}
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
}
fun __assign(_i: Int, _bb: ByteBuffer): StructInNestedNS {
__init(_i, _bb)
return this
}
val a: Int
get() = bb.getInt(bb_pos + 0)
fun mutateA(a: Int): ByteBuffer = bb.putInt(bb_pos + 0, a)
val b: Int
get() = bb.getInt(bb_pos + 4)
fun mutateB(b: Int): ByteBuffer = bb.putInt(bb_pos + 4, b)
companion object {
fun createStructInNestedNS(builder: FlatBufferBuilder, a: Int, b: Int): Int {
builder.prep(4, 8)
builder.putInt(b)
builder.putInt(a)
return builder.offset()
}
}
}

View File

@@ -4,57 +4,69 @@
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class StructInNestedNS(object):
__slots__ = ['_tab']
__slots__ = ['_tab']
@classmethod
def SizeOf(cls):
return 8
@classmethod
def SizeOf(cls):
return 8
# StructInNestedNS
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# StructInNestedNS
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# StructInNestedNS
def A(self):
return self._tab.Get(
flatbuffers.number_types.Int32Flags,
self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0),
)
# StructInNestedNS
def B(self):
return self._tab.Get(
flatbuffers.number_types.Int32Flags,
self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4),
)
# StructInNestedNS
def A(self): return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0))
# StructInNestedNS
def B(self): return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4))
def CreateStructInNestedNS(builder, a, b):
builder.Prep(4, 8)
builder.PrependInt32(b)
builder.PrependInt32(a)
return builder.Offset()
builder.Prep(4, 8)
builder.PrependInt32(b)
builder.PrependInt32(a)
return builder.Offset()
class StructInNestedNST(object):
# StructInNestedNST
def __init__(self):
self.a = 0 # type: int
self.b = 0 # type: int
# StructInNestedNST
def __init__(self):
self.a = 0 # type: int
self.b = 0 # type: int
@classmethod
def InitFromBuf(cls, buf, pos):
structInNestedNS = StructInNestedNS()
structInNestedNS.Init(buf, pos)
return cls.InitFromObj(structInNestedNS)
@classmethod
def InitFromBuf(cls, buf, pos):
structInNestedNS = StructInNestedNS()
structInNestedNS.Init(buf, pos)
return cls.InitFromObj(structInNestedNS)
@classmethod
def InitFromObj(cls, structInNestedNS):
x = StructInNestedNST()
x._UnPack(structInNestedNS)
return x
@classmethod
def InitFromObj(cls, structInNestedNS):
x = StructInNestedNST()
x._UnPack(structInNestedNS)
return x
# StructInNestedNST
def _UnPack(self, structInNestedNS):
if structInNestedNS is None:
return
self.a = structInNestedNS.A()
self.b = structInNestedNS.B()
# StructInNestedNST
def _UnPack(self, structInNestedNS):
if structInNestedNS is None:
return
self.a = structInNestedNS.A()
self.b = structInNestedNS.B()
# StructInNestedNST
def Pack(self, builder):
return CreateStructInNestedNS(builder, self.a, self.b)
# StructInNestedNST
def Pack(self, builder):
return CreateStructInNestedNS(builder, self.a, self.b)

View File

@@ -2,27 +2,32 @@
package NamespaceA.NamespaceB;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
public class StructInNestedNST {
private int a;
private int b;
public int getA() { return a; }
public int getA() {
return a;
}
public void setA(int a) { this.a = a; }
public void setA(int a) {
this.a = a;
}
public int getB() { return b; }
public void setB(int b) { this.b = b; }
public int getB() {
return b;
}
public void setB(int b) {
this.b = b;
}
public StructInNestedNST() {
this.a = 0;
this.b = 0;
}
}

View File

@@ -11,7 +11,9 @@ type TableInNestedNST struct {
}
func (t *TableInNestedNST) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
if t == nil {
return 0
}
TableInNestedNSStart(builder)
TableInNestedNSAddFoo(builder, t.Foo)
return TableInNestedNSEnd(builder)
@@ -22,7 +24,9 @@ func (rcv *TableInNestedNS) UnPackTo(t *TableInNestedNST) {
}
func (rcv *TableInNestedNS) UnPack() *TableInNestedNST {
if rcv == nil { return nil }
if rcv == nil {
return nil
}
t := &TableInNestedNST{}
rcv.UnPackTo(t)
return t

View File

@@ -2,56 +2,96 @@
package NamespaceA.NamespaceB;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
@SuppressWarnings("unused")
public final class TableInNestedNS extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_25_2_10(); }
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb) { return getRootAsTableInNestedNS(_bb, new TableInNestedNS()); }
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public TableInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public static void ValidateVersion() {
Constants.FLATBUFFERS_25_2_10();
}
public int foo() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
public boolean mutateFoo(int foo) { int o = __offset(4); if (o != 0) { bb.putInt(o + bb_pos, foo); return true; } else { return false; } }
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb) {
return getRootAsTableInNestedNS(_bb, new TableInNestedNS());
}
public static int createTableInNestedNS(FlatBufferBuilder builder,
int foo) {
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) {
_bb.order(ByteOrder.LITTLE_ENDIAN);
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb));
}
public void __init(int _i, ByteBuffer _bb) {
__reset(_i, _bb);
}
public TableInNestedNS __assign(int _i, ByteBuffer _bb) {
__init(_i, _bb);
return this;
}
public int foo() {
int o = __offset(4);
return o != 0 ? bb.getInt(o + bb_pos) : 0;
}
public boolean mutateFoo(int foo) {
int o = __offset(4);
if (o != 0) {
bb.putInt(o + bb_pos, foo);
return true;
} else {
return false;
}
}
public static int createTableInNestedNS(FlatBufferBuilder builder, int foo) {
builder.startTable(1);
TableInNestedNS.addFoo(builder, foo);
return TableInNestedNS.endTableInNestedNS(builder);
}
public static void startTableInNestedNS(FlatBufferBuilder builder) { builder.startTable(1); }
public static void addFoo(FlatBufferBuilder builder, int foo) { builder.addInt(0, foo, 0); }
public static void startTableInNestedNS(FlatBufferBuilder builder) {
builder.startTable(1);
}
public static void addFoo(FlatBufferBuilder builder, int foo) {
builder.addInt(0, foo, 0);
}
public static int endTableInNestedNS(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
}
public static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) {
__reset(_vector, _element_size, _bb);
return this;
}
public TableInNestedNS get(int j) { return get(new TableInNestedNS(), j); }
public TableInNestedNS get(TableInNestedNS obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
public TableInNestedNS get(int j) {
return get(new TableInNestedNS(), j);
}
public TableInNestedNS get(TableInNestedNS obj, int j) {
return obj.__assign(__indirect(__element(j), bb), bb);
}
}
public TableInNestedNST unpack() {
TableInNestedNST _o = new TableInNestedNST();
unpackTo(_o);
return _o;
}
public void unpackTo(TableInNestedNST _o) {
int _oFoo = foo();
_o.setFoo(_oFoo);
}
public static int pack(FlatBufferBuilder builder, TableInNestedNST _o) {
if (_o == null) return 0;
return createTableInNestedNS(
builder,
_o.getFoo());
return createTableInNestedNS(builder, _o.getFoo());
}
}

View File

@@ -2,64 +2,65 @@
package NamespaceA.NamespaceB
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
@Suppress("unused")
@ExperimentalUnsignedTypes
class TableInNestedNS : Table() {
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
}
fun __assign(_i: Int, _bb: ByteBuffer): TableInNestedNS {
__init(_i, _bb)
return this
}
val foo: Int
get() {
val o = __offset(4)
return if (o != 0) bb.getInt(o + bb_pos) else 0
}
fun __assign(_i: Int, _bb: ByteBuffer) : TableInNestedNS {
__init(_i, _bb)
return this
fun mutateFoo(foo: Int): Boolean {
val o = __offset(4)
return if (o != 0) {
bb.putInt(o + bb_pos, foo)
true
} else {
false
}
val foo : Int
get() {
val o = __offset(4)
return if(o != 0) bb.getInt(o + bb_pos) else 0
}
fun mutateFoo(foo: Int) : Boolean {
val o = __offset(4)
return if (o != 0) {
bb.putInt(o + bb_pos, foo)
true
} else {
false
}
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_25_2_10()
fun getRootAsTableInNestedNS(_bb: ByteBuffer): TableInNestedNS =
getRootAsTableInNestedNS(_bb, TableInNestedNS())
fun getRootAsTableInNestedNS(_bb: ByteBuffer, obj: TableInNestedNS): TableInNestedNS {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_25_2_10()
fun getRootAsTableInNestedNS(_bb: ByteBuffer): TableInNestedNS = getRootAsTableInNestedNS(_bb, TableInNestedNS())
fun getRootAsTableInNestedNS(_bb: ByteBuffer, obj: TableInNestedNS): TableInNestedNS {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
fun createTableInNestedNS(builder: FlatBufferBuilder, foo: Int) : Int {
builder.startTable(1)
addFoo(builder, foo)
return endTableInNestedNS(builder)
}
fun startTableInNestedNS(builder: FlatBufferBuilder) = builder.startTable(1)
fun addFoo(builder: FlatBufferBuilder, foo: Int) = builder.addInt(0, foo, 0)
fun endTableInNestedNS(builder: FlatBufferBuilder) : Int {
val o = builder.endTable()
return o
}
fun createTableInNestedNS(builder: FlatBufferBuilder, foo: Int): Int {
builder.startTable(1)
addFoo(builder, foo)
return endTableInNestedNS(builder)
}
fun startTableInNestedNS(builder: FlatBufferBuilder) = builder.startTable(1)
fun addFoo(builder: FlatBufferBuilder, foo: Int) = builder.addInt(0, foo, 0)
fun endTableInNestedNS(builder: FlatBufferBuilder): Int {
val o = builder.endTable()
return o
}
}
}

View File

@@ -4,70 +4,90 @@
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class TableInNestedNS(object):
__slots__ = ['_tab']
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = TableInNestedNS()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = TableInNestedNS()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsTableInNestedNS(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# TableInNestedNS
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
@classmethod
def GetRootAsTableInNestedNS(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# TableInNestedNS
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# TableInNestedNS
def Foo(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
return self._tab.Get(
flatbuffers.number_types.Int32Flags, o + self._tab.Pos
)
return 0
def TableInNestedNSStart(builder):
builder.StartObject(1)
# TableInNestedNS
def Foo(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
return 0
def TableInNestedNSStart(builder): builder.StartObject(1)
def Start(builder):
return TableInNestedNSStart(builder)
def TableInNestedNSAddFoo(builder, foo): builder.PrependInt32Slot(0, foo, 0)
return TableInNestedNSStart(builder)
def TableInNestedNSAddFoo(builder, foo):
builder.PrependInt32Slot(0, foo, 0)
def AddFoo(builder, foo):
return TableInNestedNSAddFoo(builder, foo)
def TableInNestedNSEnd(builder): return builder.EndObject()
return TableInNestedNSAddFoo(builder, foo)
def TableInNestedNSEnd(builder):
return builder.EndObject()
def End(builder):
return TableInNestedNSEnd(builder)
return TableInNestedNSEnd(builder)
class TableInNestedNST(object):
# TableInNestedNST
def __init__(self):
self.foo = 0 # type: int
# TableInNestedNST
def __init__(self):
self.foo = 0 # type: int
@classmethod
def InitFromBuf(cls, buf, pos):
tableInNestedNS = TableInNestedNS()
tableInNestedNS.Init(buf, pos)
return cls.InitFromObj(tableInNestedNS)
@classmethod
def InitFromBuf(cls, buf, pos):
tableInNestedNS = TableInNestedNS()
tableInNestedNS.Init(buf, pos)
return cls.InitFromObj(tableInNestedNS)
@classmethod
def InitFromObj(cls, tableInNestedNS):
x = TableInNestedNST()
x._UnPack(tableInNestedNS)
return x
@classmethod
def InitFromObj(cls, tableInNestedNS):
x = TableInNestedNST()
x._UnPack(tableInNestedNS)
return x
# TableInNestedNST
def _UnPack(self, tableInNestedNS):
if tableInNestedNS is None:
return
self.foo = tableInNestedNS.Foo()
# TableInNestedNST
def _UnPack(self, tableInNestedNS):
if tableInNestedNS is None:
return
self.foo = tableInNestedNS.Foo()
# TableInNestedNST
def Pack(self, builder):
TableInNestedNSStart(builder)
TableInNestedNSAddFoo(builder, self.foo)
tableInNestedNS = TableInNestedNSEnd(builder)
return tableInNestedNS
# TableInNestedNST
def Pack(self, builder):
TableInNestedNSStart(builder)
TableInNestedNSAddFoo(builder, self.foo)
tableInNestedNS = TableInNestedNSEnd(builder)
return tableInNestedNS

View File

@@ -2,21 +2,22 @@
package NamespaceA.NamespaceB;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
public class TableInNestedNST {
private int foo;
public int getFoo() { return foo; }
public void setFoo(int foo) { this.foo = foo; }
public int getFoo() {
return foo;
}
public void setFoo(int foo) {
this.foo = foo;
}
public TableInNestedNST() {
this.foo = 0;
}
}

View File

@@ -11,7 +11,7 @@ import (
)
type UnionInNestedNST struct {
Type UnionInNestedNS
Type UnionInNestedNS
Value interface{}
}
@@ -30,7 +30,7 @@ func (rcv UnionInNestedNS) UnPack(table flatbuffers.Table) *UnionInNestedNST {
switch rcv {
case UnionInNestedNSTableInNestedNS:
x := TableInNestedNS{_tab: table}
return &NamespaceA__NamespaceB.UnionInNestedNST{ Type: UnionInNestedNSTableInNestedNS, Value: x.UnPack() }
return &NamespaceA__NamespaceB.UnionInNestedNST{Type: UnionInNestedNSTableInNestedNS, Value: x.UnPack()}
}
return nil
}

View File

@@ -4,12 +4,16 @@ package NamespaceA.NamespaceB;
@SuppressWarnings("unused")
public final class UnionInNestedNS {
private UnionInNestedNS() { }
private UnionInNestedNS() {}
public static final byte NONE = 0;
public static final byte TableInNestedNS = 1;
public static final String[] names = { "NONE", "TableInNestedNS", };
public static final String[] names = {
"NONE", "TableInNestedNS",
};
public static String name(int e) { return names[e]; }
public static String name(int e) {
return names[e];
}
}

View File

@@ -5,10 +5,11 @@ package NamespaceA.NamespaceB
@Suppress("unused")
@ExperimentalUnsignedTypes
class UnionInNestedNS private constructor() {
companion object {
const val NONE: UByte = 0u
const val TableInNestedNS: UByte = 1u
val names : Array<String> = arrayOf("NONE", "TableInNestedNS")
fun name(e: Int) : String = names[e]
}
companion object {
const val NONE: UByte = 0u
const val TableInNestedNS: UByte = 1u
val names: Array<String> = arrayOf("NONE", "TableInNestedNS")
fun name(e: Int): String = names[e]
}
}

View File

@@ -2,14 +2,17 @@
# namespace: NamespaceB
class UnionInNestedNS(object):
NONE = 0
TableInNestedNS = 1
NONE = 0
TableInNestedNS = 1
def UnionInNestedNSCreator(unionType, table):
from flatbuffers.table import Table
if not isinstance(table, Table):
return None
if unionType == UnionInNestedNS().TableInNestedNS:
return TableInNestedNST.InitFromBuf(table.Bytes, table.Pos)
from flatbuffers.table import Table
if not isinstance(table, Table):
return None
if unionType == UnionInNestedNS().TableInNestedNS:
return TableInNestedNST.InitFromBuf(table.Bytes, table.Pos)
return None

View File

@@ -8,26 +8,37 @@ public class UnionInNestedNSUnion {
private byte type;
private Object value;
public byte getType() { return type; }
public byte getType() {
return type;
}
public void setType(byte type) { this.type = type; }
public void setType(byte type) {
this.type = type;
}
public Object getValue() { return value; }
public Object getValue() {
return value;
}
public void setValue(Object value) { this.value = value; }
public void setValue(Object value) {
this.value = value;
}
public UnionInNestedNSUnion() {
this.type = UnionInNestedNS.NONE;
this.value = null;
}
public NamespaceA.NamespaceB.TableInNestedNST asTableInNestedNS() { return (NamespaceA.NamespaceB.TableInNestedNST) value; }
public NamespaceA.NamespaceB.TableInNestedNST asTableInNestedNS() {
return (NamespaceA.NamespaceB.TableInNestedNST) value;
}
public static int pack(FlatBufferBuilder builder, UnionInNestedNSUnion _o) {
switch (_o.type) {
case UnionInNestedNS.TableInNestedNS: return NamespaceA.NamespaceB.TableInNestedNS.pack(builder, _o.asTableInNestedNS());
default: return 0;
case UnionInNestedNS.TableInNestedNS:
return NamespaceA.NamespaceB.TableInNestedNS.pack(builder, _o.asTableInNestedNS());
default:
return 0;
}
}
}

View File

@@ -13,7 +13,9 @@ type SecondTableInAT struct {
}
func (t *SecondTableInAT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
if t == nil {
return 0
}
referToCOffset := t.ReferToC.Pack(builder)
SecondTableInAStart(builder)
SecondTableInAAddReferToC(builder, referToCOffset)
@@ -25,7 +27,9 @@ func (rcv *SecondTableInA) UnPackTo(t *SecondTableInAT) {
}
func (rcv *SecondTableInA) UnPack() *SecondTableInAT {
if rcv == nil { return nil }
if rcv == nil {
return nil
}
t := &SecondTableInAT{}
rcv.UnPackTo(t)
return t

View File

@@ -2,57 +2,92 @@
package NamespaceA;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
@SuppressWarnings("unused")
public final class SecondTableInA extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_25_2_10(); }
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb) { return getRootAsSecondTableInA(_bb, new SecondTableInA()); }
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public SecondTableInA __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public static void ValidateVersion() {
Constants.FLATBUFFERS_25_2_10();
}
public NamespaceC.TableInC referToC() { return referToC(new NamespaceC.TableInC()); }
public NamespaceC.TableInC referToC(NamespaceC.TableInC obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb) {
return getRootAsSecondTableInA(_bb, new SecondTableInA());
}
public static int createSecondTableInA(FlatBufferBuilder builder,
int referToCOffset) {
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) {
_bb.order(ByteOrder.LITTLE_ENDIAN);
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb));
}
public void __init(int _i, ByteBuffer _bb) {
__reset(_i, _bb);
}
public SecondTableInA __assign(int _i, ByteBuffer _bb) {
__init(_i, _bb);
return this;
}
public NamespaceC.TableInC referToC() {
return referToC(new NamespaceC.TableInC());
}
public NamespaceC.TableInC referToC(NamespaceC.TableInC obj) {
int o = __offset(4);
return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null;
}
public static int createSecondTableInA(FlatBufferBuilder builder, int referToCOffset) {
builder.startTable(1);
SecondTableInA.addReferToC(builder, referToCOffset);
return SecondTableInA.endSecondTableInA(builder);
}
public static void startSecondTableInA(FlatBufferBuilder builder) { builder.startTable(1); }
public static void addReferToC(FlatBufferBuilder builder, int referToCOffset) { builder.addOffset(0, referToCOffset, 0); }
public static void startSecondTableInA(FlatBufferBuilder builder) {
builder.startTable(1);
}
public static void addReferToC(FlatBufferBuilder builder, int referToCOffset) {
builder.addOffset(0, referToCOffset, 0);
}
public static int endSecondTableInA(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
}
public static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) {
__reset(_vector, _element_size, _bb);
return this;
}
public SecondTableInA get(int j) { return get(new SecondTableInA(), j); }
public SecondTableInA get(SecondTableInA obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
public SecondTableInA get(int j) {
return get(new SecondTableInA(), j);
}
public SecondTableInA get(SecondTableInA obj, int j) {
return obj.__assign(__indirect(__element(j), bb), bb);
}
}
public SecondTableInAT unpack() {
SecondTableInAT _o = new SecondTableInAT();
unpackTo(_o);
return _o;
}
public void unpackTo(SecondTableInAT _o) {
if (referToC() != null) _o.setReferToC(referToC().unpack());
else _o.setReferToC(null);
}
public static int pack(FlatBufferBuilder builder, SecondTableInAT _o) {
if (_o == null) return 0;
int _refer_to_c = _o.getReferToC() == null ? 0 : NamespaceC.TableInC.pack(builder, _o.getReferToC());
return createSecondTableInA(
builder,
_refer_to_c);
int _refer_to_c =
_o.getReferToC() == null ? 0 : NamespaceC.TableInC.pack(builder, _o.getReferToC());
return createSecondTableInA(builder, _refer_to_c);
}
}

View File

@@ -2,59 +2,61 @@
package NamespaceA
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
@Suppress("unused")
@ExperimentalUnsignedTypes
class SecondTableInA : Table() {
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
}
fun __assign(_i: Int, _bb: ByteBuffer): SecondTableInA {
__init(_i, _bb)
return this
}
val referToC: NamespaceC.TableInC?
get() = referToC(NamespaceC.TableInC())
fun referToC(obj: NamespaceC.TableInC): NamespaceC.TableInC? {
val o = __offset(4)
return if (o != 0) {
obj.__assign(__indirect(o + bb_pos), bb)
} else {
null
}
fun __assign(_i: Int, _bb: ByteBuffer) : SecondTableInA {
__init(_i, _bb)
return this
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_25_2_10()
fun getRootAsSecondTableInA(_bb: ByteBuffer): SecondTableInA =
getRootAsSecondTableInA(_bb, SecondTableInA())
fun getRootAsSecondTableInA(_bb: ByteBuffer, obj: SecondTableInA): SecondTableInA {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
val referToC : NamespaceC.TableInC? get() = referToC(NamespaceC.TableInC())
fun referToC(obj: NamespaceC.TableInC) : NamespaceC.TableInC? {
val o = __offset(4)
return if (o != 0) {
obj.__assign(__indirect(o + bb_pos), bb)
} else {
null
}
fun createSecondTableInA(builder: FlatBufferBuilder, referToCOffset: Int): Int {
builder.startTable(1)
addReferToC(builder, referToCOffset)
return endSecondTableInA(builder)
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_25_2_10()
fun getRootAsSecondTableInA(_bb: ByteBuffer): SecondTableInA = getRootAsSecondTableInA(_bb, SecondTableInA())
fun getRootAsSecondTableInA(_bb: ByteBuffer, obj: SecondTableInA): SecondTableInA {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
fun createSecondTableInA(builder: FlatBufferBuilder, referToCOffset: Int) : Int {
builder.startTable(1)
addReferToC(builder, referToCOffset)
return endSecondTableInA(builder)
}
fun startSecondTableInA(builder: FlatBufferBuilder) = builder.startTable(1)
fun addReferToC(builder: FlatBufferBuilder, referToC: Int) = builder.addOffset(0, referToC, 0)
fun endSecondTableInA(builder: FlatBufferBuilder) : Int {
val o = builder.endTable()
return o
}
fun startSecondTableInA(builder: FlatBufferBuilder) = builder.startTable(1)
fun addReferToC(builder: FlatBufferBuilder, referToC: Int) = builder.addOffset(0, referToC, 0)
fun endSecondTableInA(builder: FlatBufferBuilder): Int {
val o = builder.endTable()
return o
}
}
}

View File

@@ -4,81 +4,103 @@
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class SecondTableInA(object):
__slots__ = ['_tab']
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = SecondTableInA()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = SecondTableInA()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsSecondTableInA(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# SecondTableInA
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
@classmethod
def GetRootAsSecondTableInA(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# SecondTableInA
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# SecondTableInA
def ReferToC(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
obj = TableInC()
obj.Init(self._tab.Bytes, x)
return obj
return None
def SecondTableInAStart(builder):
builder.StartObject(1)
# SecondTableInA
def ReferToC(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
obj = TableInC()
obj.Init(self._tab.Bytes, x)
return obj
return None
def SecondTableInAStart(builder): builder.StartObject(1)
def Start(builder):
return SecondTableInAStart(builder)
def SecondTableInAAddReferToC(builder, referToC): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(referToC), 0)
return SecondTableInAStart(builder)
def SecondTableInAAddReferToC(builder, referToC):
builder.PrependUOffsetTRelativeSlot(
0, flatbuffers.number_types.UOffsetTFlags.py_type(referToC), 0
)
def AddReferToC(builder, referToC):
return SecondTableInAAddReferToC(builder, referToC)
def SecondTableInAEnd(builder): return builder.EndObject()
return SecondTableInAAddReferToC(builder, referToC)
def SecondTableInAEnd(builder):
return builder.EndObject()
def End(builder):
return SecondTableInAEnd(builder)
return SecondTableInAEnd(builder)
try:
from typing import Optional
from typing import Optional
except:
pass
pass
class SecondTableInAT(object):
# SecondTableInAT
def __init__(self):
self.referToC = None # type: Optional[TableInCT]
# SecondTableInAT
def __init__(self):
self.referToC = None # type: Optional[TableInCT]
@classmethod
def InitFromBuf(cls, buf, pos):
secondTableInA = SecondTableInA()
secondTableInA.Init(buf, pos)
return cls.InitFromObj(secondTableInA)
@classmethod
def InitFromBuf(cls, buf, pos):
secondTableInA = SecondTableInA()
secondTableInA.Init(buf, pos)
return cls.InitFromObj(secondTableInA)
@classmethod
def InitFromObj(cls, secondTableInA):
x = SecondTableInAT()
x._UnPack(secondTableInA)
return x
@classmethod
def InitFromObj(cls, secondTableInA):
x = SecondTableInAT()
x._UnPack(secondTableInA)
return x
# SecondTableInAT
def _UnPack(self, secondTableInA):
if secondTableInA is None:
return
if secondTableInA.ReferToC() is not None:
self.referToC = TableInCT.InitFromObj(secondTableInA.ReferToC())
# SecondTableInAT
def _UnPack(self, secondTableInA):
if secondTableInA is None:
return
if secondTableInA.ReferToC() is not None:
self.referToC = TableInCT.InitFromObj(secondTableInA.ReferToC())
# SecondTableInAT
def Pack(self, builder):
if self.referToC is not None:
referToC = self.referToC.Pack(builder)
SecondTableInAStart(builder)
if self.referToC is not None:
SecondTableInAAddReferToC(builder, referToC)
secondTableInA = SecondTableInAEnd(builder)
return secondTableInA
# SecondTableInAT
def Pack(self, builder):
if self.referToC is not None:
referToC = self.referToC.Pack(builder)
SecondTableInAStart(builder)
if self.referToC is not None:
SecondTableInAAddReferToC(builder, referToC)
secondTableInA = SecondTableInAEnd(builder)
return secondTableInA

View File

@@ -2,21 +2,22 @@
package NamespaceA;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
public class SecondTableInAT {
private NamespaceC.TableInCT referToC;
public NamespaceC.TableInCT getReferToC() { return referToC; }
public void setReferToC(NamespaceC.TableInCT referToC) { this.referToC = referToC; }
public NamespaceC.TableInCT getReferToC() {
return referToC;
}
public void setReferToC(NamespaceC.TableInCT referToC) {
this.referToC = referToC;
}
public SecondTableInAT() {
this.referToC = null;
}
}

View File

@@ -5,6 +5,7 @@ package NamespaceA
import (
flatbuffers "github.com/google/flatbuffers/go"
)
type TableInC struct {
_tab flatbuffers.Table
}
@@ -41,6 +42,10 @@ func (rcv *TableInC) ReferToA2(obj *SecondTableInA) *SecondTableInA {
}
func TableInCStart(builder *flatbuffers.Builder) { builder.StartObject(2) }
func TableInCAddReferToA1(builder *flatbuffers.Builder, referToA1 flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(referToA1), 0) }
func TableInCAddReferToA2(builder *flatbuffers.Builder, referToA2 flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(referToA2), 0) }
func TableInCAddReferToA1(builder *flatbuffers.Builder, referToA1 flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(referToA1), 0)
}
func TableInCAddReferToA2(builder *flatbuffers.Builder, referToA2 flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(referToA2), 0)
}
func TableInCEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }

View File

@@ -4,36 +4,54 @@
import flatbuffers
class TableInC(object):
__slots__ = ['_tab']
__slots__ = ['_tab']
# TableInC
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# TableInC
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# TableInC
def ReferToA1(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .TableInFirstNS import TableInFirstNS
obj = TableInFirstNS()
obj.Init(self._tab.Bytes, x)
return obj
return None
# TableInC
def ReferToA1(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .TableInFirstNS import TableInFirstNS
# TableInC
def ReferToA2(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .SecondTableInA import SecondTableInA
obj = SecondTableInA()
obj.Init(self._tab.Bytes, x)
return obj
return None
obj = TableInFirstNS()
obj.Init(self._tab.Bytes, x)
return obj
return None
def TableInCStart(builder): builder.StartObject(2)
def TableInCAddReferToA1(builder, referToA1): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(referToA1), 0)
def TableInCAddReferToA2(builder, referToA2): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(referToA2), 0)
def TableInCEnd(builder): return builder.EndObject()
# TableInC
def ReferToA2(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from .SecondTableInA import SecondTableInA
obj = SecondTableInA()
obj.Init(self._tab.Bytes, x)
return obj
return None
def TableInCStart(builder):
builder.StartObject(2)
def TableInCAddReferToA1(builder, referToA1):
builder.PrependUOffsetTRelativeSlot(
0, flatbuffers.number_types.UOffsetTFlags.py_type(referToA1), 0
)
def TableInCAddReferToA2(builder, referToA2):
builder.PrependUOffsetTRelativeSlot(
1, flatbuffers.number_types.UOffsetTFlags.py_type(referToA2), 0
)
def TableInCEnd(builder):
return builder.EndObject()

View File

@@ -9,17 +9,19 @@ import (
)
type TableInFirstNST struct {
FooTable *NamespaceA__NamespaceB.TableInNestedNST
FooEnum NamespaceA__NamespaceB.EnumInNestedNS
FooUnion *NamespaceA__NamespaceB.UnionInNestedNST
FooTable *NamespaceA__NamespaceB.TableInNestedNST
FooEnum NamespaceA__NamespaceB.EnumInNestedNS
FooUnion *NamespaceA__NamespaceB.UnionInNestedNST
FooStruct *NamespaceA__NamespaceB.StructInNestedNST
}
func (t *TableInFirstNST) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
if t == nil {
return 0
}
fooTableOffset := t.FooTable.Pack(builder)
fooUnionOffset := t.FooUnion.Pack(builder)
TableInFirstNSStart(builder)
TableInFirstNSAddFooTable(builder, fooTableOffset)
TableInFirstNSAddFooEnum(builder, t.FooEnum)
@@ -43,7 +45,9 @@ func (rcv *TableInFirstNS) UnPackTo(t *TableInFirstNST) {
}
func (rcv *TableInFirstNS) UnPack() *TableInFirstNST {
if rcv == nil { return nil }
if rcv == nil {
return nil
}
t := &TableInFirstNST{}
rcv.UnPackTo(t)
return t

View File

@@ -2,75 +2,168 @@
package NamespaceA;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
@SuppressWarnings("unused")
public final class TableInFirstNS extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_25_2_10(); }
public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb) { return getRootAsTableInFirstNS(_bb, new TableInFirstNS()); }
public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb, TableInFirstNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public TableInFirstNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public static void ValidateVersion() {
Constants.FLATBUFFERS_25_2_10();
}
public NamespaceA.NamespaceB.TableInNestedNS fooTable() { return fooTable(new NamespaceA.NamespaceB.TableInNestedNS()); }
public NamespaceA.NamespaceB.TableInNestedNS fooTable(NamespaceA.NamespaceB.TableInNestedNS obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public byte fooEnum() { int o = __offset(6); return o != 0 ? bb.get(o + bb_pos) : 0; }
public boolean mutateFooEnum(byte foo_enum) { int o = __offset(6); if (o != 0) { bb.put(o + bb_pos, foo_enum); return true; } else { return false; } }
public byte fooUnionType() { int o = __offset(8); return o != 0 ? bb.get(o + bb_pos) : 0; }
public Table fooUnion(Table obj) { int o = __offset(10); return o != 0 ? __union(obj, o + bb_pos) : null; }
public NamespaceA.NamespaceB.StructInNestedNS fooStruct() { return fooStruct(new NamespaceA.NamespaceB.StructInNestedNS()); }
public NamespaceA.NamespaceB.StructInNestedNS fooStruct(NamespaceA.NamespaceB.StructInNestedNS obj) { int o = __offset(12); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; }
public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb) {
return getRootAsTableInFirstNS(_bb, new TableInFirstNS());
}
public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb, TableInFirstNS obj) {
_bb.order(ByteOrder.LITTLE_ENDIAN);
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb));
}
public void __init(int _i, ByteBuffer _bb) {
__reset(_i, _bb);
}
public TableInFirstNS __assign(int _i, ByteBuffer _bb) {
__init(_i, _bb);
return this;
}
public NamespaceA.NamespaceB.TableInNestedNS fooTable() {
return fooTable(new NamespaceA.NamespaceB.TableInNestedNS());
}
public NamespaceA.NamespaceB.TableInNestedNS fooTable(NamespaceA.NamespaceB.TableInNestedNS obj) {
int o = __offset(4);
return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null;
}
public byte fooEnum() {
int o = __offset(6);
return o != 0 ? bb.get(o + bb_pos) : 0;
}
public boolean mutateFooEnum(byte foo_enum) {
int o = __offset(6);
if (o != 0) {
bb.put(o + bb_pos, foo_enum);
return true;
} else {
return false;
}
}
public byte fooUnionType() {
int o = __offset(8);
return o != 0 ? bb.get(o + bb_pos) : 0;
}
public Table fooUnion(Table obj) {
int o = __offset(10);
return o != 0 ? __union(obj, o + bb_pos) : null;
}
public NamespaceA.NamespaceB.StructInNestedNS fooStruct() {
return fooStruct(new NamespaceA.NamespaceB.StructInNestedNS());
}
public NamespaceA.NamespaceB.StructInNestedNS fooStruct(
NamespaceA.NamespaceB.StructInNestedNS obj) {
int o = __offset(12);
return o != 0 ? obj.__assign(o + bb_pos, bb) : null;
}
public static void startTableInFirstNS(FlatBufferBuilder builder) {
builder.startTable(5);
}
public static void addFooTable(FlatBufferBuilder builder, int fooTableOffset) {
builder.addOffset(0, fooTableOffset, 0);
}
public static void addFooEnum(FlatBufferBuilder builder, byte fooEnum) {
builder.addByte(1, fooEnum, 0);
}
public static void addFooUnionType(FlatBufferBuilder builder, byte fooUnionType) {
builder.addByte(2, fooUnionType, 0);
}
public static void addFooUnion(FlatBufferBuilder builder, int fooUnionOffset) {
builder.addOffset(3, fooUnionOffset, 0);
}
public static void addFooStruct(FlatBufferBuilder builder, int fooStructOffset) {
builder.addStruct(4, fooStructOffset, 0);
}
public static void startTableInFirstNS(FlatBufferBuilder builder) { builder.startTable(5); }
public static void addFooTable(FlatBufferBuilder builder, int fooTableOffset) { builder.addOffset(0, fooTableOffset, 0); }
public static void addFooEnum(FlatBufferBuilder builder, byte fooEnum) { builder.addByte(1, fooEnum, 0); }
public static void addFooUnionType(FlatBufferBuilder builder, byte fooUnionType) { builder.addByte(2, fooUnionType, 0); }
public static void addFooUnion(FlatBufferBuilder builder, int fooUnionOffset) { builder.addOffset(3, fooUnionOffset, 0); }
public static void addFooStruct(FlatBufferBuilder builder, int fooStructOffset) { builder.addStruct(4, fooStructOffset, 0); }
public static int endTableInFirstNS(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
}
public static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) {
__reset(_vector, _element_size, _bb);
return this;
}
public TableInFirstNS get(int j) { return get(new TableInFirstNS(), j); }
public TableInFirstNS get(TableInFirstNS obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
public TableInFirstNS get(int j) {
return get(new TableInFirstNS(), j);
}
public TableInFirstNS get(TableInFirstNS obj, int j) {
return obj.__assign(__indirect(__element(j), bb), bb);
}
}
public TableInFirstNST unpack() {
TableInFirstNST _o = new TableInFirstNST();
unpackTo(_o);
return _o;
}
public void unpackTo(TableInFirstNST _o) {
if (fooTable() != null) _o.setFooTable(fooTable().unpack());
else _o.setFooTable(null);
byte _oFooEnum = fooEnum();
_o.setFooEnum(_oFooEnum);
NamespaceA.NamespaceB.UnionInNestedNSUnion _oFooUnion = new NamespaceA.NamespaceB.UnionInNestedNSUnion();
NamespaceA.NamespaceB.UnionInNestedNSUnion _oFooUnion =
new NamespaceA.NamespaceB.UnionInNestedNSUnion();
byte _oFooUnionType = fooUnionType();
_oFooUnion.setType(_oFooUnionType);
Table _oFooUnionValue;
switch (_oFooUnionType) {
case NamespaceA.NamespaceB.UnionInNestedNS.TableInNestedNS:
_oFooUnionValue = fooUnion(new NamespaceA.NamespaceB.TableInNestedNS());
_oFooUnion.setValue(_oFooUnionValue != null ? ((NamespaceA.NamespaceB.TableInNestedNS) _oFooUnionValue).unpack() : null);
_oFooUnion.setValue(
_oFooUnionValue != null
? ((NamespaceA.NamespaceB.TableInNestedNS) _oFooUnionValue).unpack()
: null);
break;
default:
break;
default: break;
}
_o.setFooUnion(_oFooUnion);
if (fooStruct() != null) fooStruct().unpackTo(_o.getFooStruct());
else _o.setFooStruct(null);
}
public static int pack(FlatBufferBuilder builder, TableInFirstNST _o) {
if (_o == null) return 0;
int _foo_table = _o.getFooTable() == null ? 0 : NamespaceA.NamespaceB.TableInNestedNS.pack(builder, _o.getFooTable());
byte _fooUnionType = _o.getFooUnion() == null ? NamespaceA.NamespaceB.UnionInNestedNS.NONE : _o.getFooUnion().getType();
int _fooUnion = _o.getFooUnion() == null ? 0 : NamespaceA.NamespaceB.UnionInNestedNSUnion.pack(builder, _o.getFooUnion());
int _foo_table =
_o.getFooTable() == null
? 0
: NamespaceA.NamespaceB.TableInNestedNS.pack(builder, _o.getFooTable());
byte _fooUnionType =
_o.getFooUnion() == null
? NamespaceA.NamespaceB.UnionInNestedNS.NONE
: _o.getFooUnion().getType();
int _fooUnion =
_o.getFooUnion() == null
? 0
: NamespaceA.NamespaceB.UnionInNestedNSUnion.pack(builder, _o.getFooUnion());
startTableInFirstNS(builder);
addFooTable(builder, _foo_table);
addFooEnum(builder, _o.getFooEnum());
@@ -80,4 +173,3 @@ public final class TableInFirstNS extends Table {
return endTableInFirstNS(builder);
}
}

View File

@@ -2,98 +2,116 @@
package NamespaceA
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
@Suppress("unused")
@ExperimentalUnsignedTypes
class TableInFirstNS : Table() {
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
}
fun __assign(_i: Int, _bb: ByteBuffer): TableInFirstNS {
__init(_i, _bb)
return this
}
val fooTable: NamespaceA.NamespaceB.TableInNestedNS?
get() = fooTable(NamespaceA.NamespaceB.TableInNestedNS())
fun fooTable(obj: NamespaceA.NamespaceB.TableInNestedNS): NamespaceA.NamespaceB.TableInNestedNS? {
val o = __offset(4)
return if (o != 0) {
obj.__assign(__indirect(o + bb_pos), bb)
} else {
null
}
fun __assign(_i: Int, _bb: ByteBuffer) : TableInFirstNS {
__init(_i, _bb)
return this
}
val fooEnum: Byte
get() {
val o = __offset(6)
return if (o != 0) bb.get(o + bb_pos) else 0
}
val fooTable : NamespaceA.NamespaceB.TableInNestedNS? get() = fooTable(NamespaceA.NamespaceB.TableInNestedNS())
fun fooTable(obj: NamespaceA.NamespaceB.TableInNestedNS) : NamespaceA.NamespaceB.TableInNestedNS? {
val o = __offset(4)
return if (o != 0) {
obj.__assign(__indirect(o + bb_pos), bb)
} else {
null
}
fun mutateFooEnum(fooEnum: Byte): Boolean {
val o = __offset(6)
return if (o != 0) {
bb.put(o + bb_pos, fooEnum)
true
} else {
false
}
val fooEnum : Byte
get() {
val o = __offset(6)
return if(o != 0) bb.get(o + bb_pos) else 0
}
fun mutateFooEnum(fooEnum: Byte) : Boolean {
val o = __offset(6)
return if (o != 0) {
bb.put(o + bb_pos, fooEnum)
true
} else {
false
}
}
val fooUnionType: UByte
get() {
val o = __offset(8)
return if (o != 0) bb.get(o + bb_pos).toUByte() else 0u
}
val fooUnionType : UByte
get() {
val o = __offset(8)
return if(o != 0) bb.get(o + bb_pos).toUByte() else 0u
}
fun mutateFooUnionType(fooUnionType: UByte) : Boolean {
val o = __offset(8)
return if (o != 0) {
bb.put(o + bb_pos, fooUnionType.toByte())
true
} else {
false
}
fun mutateFooUnionType(fooUnionType: UByte): Boolean {
val o = __offset(8)
return if (o != 0) {
bb.put(o + bb_pos, fooUnionType.toByte())
true
} else {
false
}
fun fooUnion(obj: Table) : Table? {
val o = __offset(10); return if (o != 0) __union(obj, o + bb_pos) else null
}
fun fooUnion(obj: Table): Table? {
val o = __offset(10)
return if (o != 0) __union(obj, o + bb_pos) else null
}
val fooStruct: NamespaceA.NamespaceB.StructInNestedNS?
get() = fooStruct(NamespaceA.NamespaceB.StructInNestedNS())
fun fooStruct(
obj: NamespaceA.NamespaceB.StructInNestedNS
): NamespaceA.NamespaceB.StructInNestedNS? {
val o = __offset(12)
return if (o != 0) {
obj.__assign(o + bb_pos, bb)
} else {
null
}
val fooStruct : NamespaceA.NamespaceB.StructInNestedNS? get() = fooStruct(NamespaceA.NamespaceB.StructInNestedNS())
fun fooStruct(obj: NamespaceA.NamespaceB.StructInNestedNS) : NamespaceA.NamespaceB.StructInNestedNS? {
val o = __offset(12)
return if (o != 0) {
obj.__assign(o + bb_pos, bb)
} else {
null
}
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_25_2_10()
fun getRootAsTableInFirstNS(_bb: ByteBuffer): TableInFirstNS =
getRootAsTableInFirstNS(_bb, TableInFirstNS())
fun getRootAsTableInFirstNS(_bb: ByteBuffer, obj: TableInFirstNS): TableInFirstNS {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_25_2_10()
fun getRootAsTableInFirstNS(_bb: ByteBuffer): TableInFirstNS = getRootAsTableInFirstNS(_bb, TableInFirstNS())
fun getRootAsTableInFirstNS(_bb: ByteBuffer, obj: TableInFirstNS): TableInFirstNS {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
fun startTableInFirstNS(builder: FlatBufferBuilder) = builder.startTable(5)
fun addFooTable(builder: FlatBufferBuilder, fooTable: Int) = builder.addOffset(0, fooTable, 0)
fun addFooEnum(builder: FlatBufferBuilder, fooEnum: Byte) = builder.addByte(1, fooEnum, 0)
fun addFooUnionType(builder: FlatBufferBuilder, fooUnionType: UByte) = builder.addByte(2, fooUnionType.toByte(), 0)
fun addFooUnion(builder: FlatBufferBuilder, fooUnion: Int) = builder.addOffset(3, fooUnion, 0)
fun addFooStruct(builder: FlatBufferBuilder, fooStruct: Int) = builder.addStruct(4, fooStruct, 0)
fun endTableInFirstNS(builder: FlatBufferBuilder) : Int {
val o = builder.endTable()
return o
}
fun startTableInFirstNS(builder: FlatBufferBuilder) = builder.startTable(5)
fun addFooTable(builder: FlatBufferBuilder, fooTable: Int) = builder.addOffset(0, fooTable, 0)
fun addFooEnum(builder: FlatBufferBuilder, fooEnum: Byte) = builder.addByte(1, fooEnum, 0)
fun addFooUnionType(builder: FlatBufferBuilder, fooUnionType: UByte) =
builder.addByte(2, fooUnionType.toByte(), 0)
fun addFooUnion(builder: FlatBufferBuilder, fooUnion: Int) = builder.addOffset(3, fooUnion, 0)
fun addFooStruct(builder: FlatBufferBuilder, fooStruct: Int) =
builder.addStruct(4, fooStruct, 0)
fun endTableInFirstNS(builder: FlatBufferBuilder): Int {
val o = builder.endTable()
return o
}
}
}

View File

@@ -4,145 +4,198 @@
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class TableInFirstNS(object):
__slots__ = ['_tab']
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = TableInFirstNS()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = TableInFirstNS()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsTableInFirstNS(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# TableInFirstNS
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
@classmethod
def GetRootAsTableInFirstNS(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# TableInFirstNS
def FooTable(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
obj = TableInNestedNS()
obj.Init(self._tab.Bytes, x)
return obj
return None
# TableInFirstNS
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# TableInFirstNS
def FooEnum(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
return 0
# TableInFirstNS
def FooTable(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
obj = TableInNestedNS()
obj.Init(self._tab.Bytes, x)
return obj
return None
# TableInFirstNS
def FooUnionType(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
if o != 0:
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
return 0
# TableInFirstNS
def FooEnum(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
return self._tab.Get(
flatbuffers.number_types.Int8Flags, o + self._tab.Pos
)
return 0
# TableInFirstNS
def FooUnion(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
if o != 0:
from flatbuffers.table import Table
obj = Table(bytearray(), 0)
self._tab.Union(obj, o)
return obj
return None
# TableInFirstNS
def FooUnionType(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
if o != 0:
return self._tab.Get(
flatbuffers.number_types.Uint8Flags, o + self._tab.Pos
)
return 0
# TableInFirstNS
def FooUnion(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
if o != 0:
from flatbuffers.table import Table
obj = Table(bytearray(), 0)
self._tab.Union(obj, o)
return obj
return None
# TableInFirstNS
def FooStruct(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
if o != 0:
x = o + self._tab.Pos
obj = StructInNestedNS()
obj.Init(self._tab.Bytes, x)
return obj
return None
def TableInFirstNSStart(builder):
builder.StartObject(5)
# TableInFirstNS
def FooStruct(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
if o != 0:
x = o + self._tab.Pos
obj = StructInNestedNS()
obj.Init(self._tab.Bytes, x)
return obj
return None
def TableInFirstNSStart(builder): builder.StartObject(5)
def Start(builder):
return TableInFirstNSStart(builder)
def TableInFirstNSAddFooTable(builder, fooTable): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(fooTable), 0)
return TableInFirstNSStart(builder)
def TableInFirstNSAddFooTable(builder, fooTable):
builder.PrependUOffsetTRelativeSlot(
0, flatbuffers.number_types.UOffsetTFlags.py_type(fooTable), 0
)
def AddFooTable(builder, fooTable):
return TableInFirstNSAddFooTable(builder, fooTable)
def TableInFirstNSAddFooEnum(builder, fooEnum): builder.PrependInt8Slot(1, fooEnum, 0)
return TableInFirstNSAddFooTable(builder, fooTable)
def TableInFirstNSAddFooEnum(builder, fooEnum):
builder.PrependInt8Slot(1, fooEnum, 0)
def AddFooEnum(builder, fooEnum):
return TableInFirstNSAddFooEnum(builder, fooEnum)
def TableInFirstNSAddFooUnionType(builder, fooUnionType): builder.PrependUint8Slot(2, fooUnionType, 0)
return TableInFirstNSAddFooEnum(builder, fooEnum)
def TableInFirstNSAddFooUnionType(builder, fooUnionType):
builder.PrependUint8Slot(2, fooUnionType, 0)
def AddFooUnionType(builder, fooUnionType):
return TableInFirstNSAddFooUnionType(builder, fooUnionType)
def TableInFirstNSAddFooUnion(builder, fooUnion): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(fooUnion), 0)
return TableInFirstNSAddFooUnionType(builder, fooUnionType)
def TableInFirstNSAddFooUnion(builder, fooUnion):
builder.PrependUOffsetTRelativeSlot(
3, flatbuffers.number_types.UOffsetTFlags.py_type(fooUnion), 0
)
def AddFooUnion(builder, fooUnion):
return TableInFirstNSAddFooUnion(builder, fooUnion)
def TableInFirstNSAddFooStruct(builder, fooStruct): builder.PrependStructSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(fooStruct), 0)
return TableInFirstNSAddFooUnion(builder, fooUnion)
def TableInFirstNSAddFooStruct(builder, fooStruct):
builder.PrependStructSlot(
4, flatbuffers.number_types.UOffsetTFlags.py_type(fooStruct), 0
)
def AddFooStruct(builder, fooStruct):
return TableInFirstNSAddFooStruct(builder, fooStruct)
def TableInFirstNSEnd(builder): return builder.EndObject()
return TableInFirstNSAddFooStruct(builder, fooStruct)
def TableInFirstNSEnd(builder):
return builder.EndObject()
def End(builder):
return TableInFirstNSEnd(builder)
return TableInFirstNSEnd(builder)
try:
from typing import Optional, Union
from typing import Optional, Union
except:
pass
pass
class TableInFirstNST(object):
# TableInFirstNST
def __init__(self):
self.fooTable = None # type: Optional[TableInNestedNST]
self.fooEnum = 0 # type: int
self.fooUnionType = 0 # type: int
self.fooUnion = None # type: Union[None, TableInNestedNST]
self.fooStruct = None # type: Optional[StructInNestedNST]
# TableInFirstNST
def __init__(self):
self.fooTable = None # type: Optional[TableInNestedNST]
self.fooEnum = 0 # type: int
self.fooUnionType = 0 # type: int
self.fooUnion = None # type: Union[None, TableInNestedNST]
self.fooStruct = None # type: Optional[StructInNestedNST]
@classmethod
def InitFromBuf(cls, buf, pos):
tableInFirstNS = TableInFirstNS()
tableInFirstNS.Init(buf, pos)
return cls.InitFromObj(tableInFirstNS)
@classmethod
def InitFromBuf(cls, buf, pos):
tableInFirstNS = TableInFirstNS()
tableInFirstNS.Init(buf, pos)
return cls.InitFromObj(tableInFirstNS)
@classmethod
def InitFromObj(cls, tableInFirstNS):
x = TableInFirstNST()
x._UnPack(tableInFirstNS)
return x
@classmethod
def InitFromObj(cls, tableInFirstNS):
x = TableInFirstNST()
x._UnPack(tableInFirstNS)
return x
# TableInFirstNST
def _UnPack(self, tableInFirstNS):
if tableInFirstNS is None:
return
if tableInFirstNS.FooTable() is not None:
self.fooTable = TableInNestedNST.InitFromObj(tableInFirstNS.FooTable())
self.fooEnum = tableInFirstNS.FooEnum()
self.fooUnionType = tableInFirstNS.FooUnionType()
self.fooUnion = UnionInNestedNSCreator(self.fooUnionType, tableInFirstNS.FooUnion())
if tableInFirstNS.FooStruct() is not None:
self.fooStruct = StructInNestedNST.InitFromObj(tableInFirstNS.FooStruct())
# TableInFirstNST
def _UnPack(self, tableInFirstNS):
if tableInFirstNS is None:
return
if tableInFirstNS.FooTable() is not None:
self.fooTable = TableInNestedNST.InitFromObj(tableInFirstNS.FooTable())
self.fooEnum = tableInFirstNS.FooEnum()
self.fooUnionType = tableInFirstNS.FooUnionType()
self.fooUnion = UnionInNestedNSCreator(
self.fooUnionType, tableInFirstNS.FooUnion()
)
if tableInFirstNS.FooStruct() is not None:
self.fooStruct = StructInNestedNST.InitFromObj(tableInFirstNS.FooStruct())
# TableInFirstNST
def Pack(self, builder):
if self.fooTable is not None:
fooTable = self.fooTable.Pack(builder)
if self.fooUnion is not None:
fooUnion = self.fooUnion.Pack(builder)
TableInFirstNSStart(builder)
if self.fooTable is not None:
TableInFirstNSAddFooTable(builder, fooTable)
TableInFirstNSAddFooEnum(builder, self.fooEnum)
TableInFirstNSAddFooUnionType(builder, self.fooUnionType)
if self.fooUnion is not None:
TableInFirstNSAddFooUnion(builder, fooUnion)
if self.fooStruct is not None:
fooStruct = self.fooStruct.Pack(builder)
TableInFirstNSAddFooStruct(builder, fooStruct)
tableInFirstNS = TableInFirstNSEnd(builder)
return tableInFirstNS
# TableInFirstNST
def Pack(self, builder):
if self.fooTable is not None:
fooTable = self.fooTable.Pack(builder)
if self.fooUnion is not None:
fooUnion = self.fooUnion.Pack(builder)
TableInFirstNSStart(builder)
if self.fooTable is not None:
TableInFirstNSAddFooTable(builder, fooTable)
TableInFirstNSAddFooEnum(builder, self.fooEnum)
TableInFirstNSAddFooUnionType(builder, self.fooUnionType)
if self.fooUnion is not None:
TableInFirstNSAddFooUnion(builder, fooUnion)
if self.fooStruct is not None:
fooStruct = self.fooStruct.Pack(builder)
TableInFirstNSAddFooStruct(builder, fooStruct)
tableInFirstNS = TableInFirstNSEnd(builder)
return tableInFirstNS

View File

@@ -2,10 +2,9 @@
package NamespaceA;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
public class TableInFirstNST {
private NamespaceA.NamespaceB.TableInNestedNST fooTable;
@@ -13,22 +12,37 @@ public class TableInFirstNST {
private NamespaceA.NamespaceB.UnionInNestedNSUnion fooUnion;
private NamespaceA.NamespaceB.StructInNestedNST fooStruct;
public NamespaceA.NamespaceB.TableInNestedNST getFooTable() { return fooTable; }
public NamespaceA.NamespaceB.TableInNestedNST getFooTable() {
return fooTable;
}
public void setFooTable(NamespaceA.NamespaceB.TableInNestedNST fooTable) { this.fooTable = fooTable; }
public void setFooTable(NamespaceA.NamespaceB.TableInNestedNST fooTable) {
this.fooTable = fooTable;
}
public byte getFooEnum() { return fooEnum; }
public byte getFooEnum() {
return fooEnum;
}
public void setFooEnum(byte fooEnum) { this.fooEnum = fooEnum; }
public void setFooEnum(byte fooEnum) {
this.fooEnum = fooEnum;
}
public NamespaceA.NamespaceB.UnionInNestedNSUnion getFooUnion() { return fooUnion; }
public NamespaceA.NamespaceB.UnionInNestedNSUnion getFooUnion() {
return fooUnion;
}
public void setFooUnion(NamespaceA.NamespaceB.UnionInNestedNSUnion fooUnion) { this.fooUnion = fooUnion; }
public void setFooUnion(NamespaceA.NamespaceB.UnionInNestedNSUnion fooUnion) {
this.fooUnion = fooUnion;
}
public NamespaceA.NamespaceB.StructInNestedNST getFooStruct() { return fooStruct; }
public void setFooStruct(NamespaceA.NamespaceB.StructInNestedNST fooStruct) { this.fooStruct = fooStruct; }
public NamespaceA.NamespaceB.StructInNestedNST getFooStruct() {
return fooStruct;
}
public void setFooStruct(NamespaceA.NamespaceB.StructInNestedNST fooStruct) {
this.fooStruct = fooStruct;
}
public TableInFirstNST() {
this.fooTable = null;
@@ -37,4 +51,3 @@ public class TableInFirstNST {
this.fooStruct = new NamespaceA.NamespaceB.StructInNestedNST();
}
}

View File

@@ -14,7 +14,9 @@ type TableInCT struct {
}
func (t *TableInCT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
if t == nil {
return 0
}
referToA1Offset := t.ReferToA1.Pack(builder)
referToA2Offset := t.ReferToA2.Pack(builder)
TableInCStart(builder)
@@ -29,7 +31,9 @@ func (rcv *TableInC) UnPackTo(t *TableInCT) {
}
func (rcv *TableInC) UnPack() *TableInCT {
if rcv == nil { return nil }
if rcv == nil {
return nil
}
t := &TableInCT{}
rcv.UnPackTo(t)
return t

View File

@@ -2,66 +2,111 @@
package NamespaceC;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
@SuppressWarnings("unused")
public final class TableInC extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_25_2_10(); }
public static TableInC getRootAsTableInC(ByteBuffer _bb) { return getRootAsTableInC(_bb, new TableInC()); }
public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public TableInC __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public static void ValidateVersion() {
Constants.FLATBUFFERS_25_2_10();
}
public NamespaceA.TableInFirstNS referToA1() { return referToA1(new NamespaceA.TableInFirstNS()); }
public NamespaceA.TableInFirstNS referToA1(NamespaceA.TableInFirstNS obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public NamespaceA.SecondTableInA referToA2() { return referToA2(new NamespaceA.SecondTableInA()); }
public NamespaceA.SecondTableInA referToA2(NamespaceA.SecondTableInA obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public static TableInC getRootAsTableInC(ByteBuffer _bb) {
return getRootAsTableInC(_bb, new TableInC());
}
public static int createTableInC(FlatBufferBuilder builder,
int referToA1Offset,
int referToA2Offset) {
public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) {
_bb.order(ByteOrder.LITTLE_ENDIAN);
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb));
}
public void __init(int _i, ByteBuffer _bb) {
__reset(_i, _bb);
}
public TableInC __assign(int _i, ByteBuffer _bb) {
__init(_i, _bb);
return this;
}
public NamespaceA.TableInFirstNS referToA1() {
return referToA1(new NamespaceA.TableInFirstNS());
}
public NamespaceA.TableInFirstNS referToA1(NamespaceA.TableInFirstNS obj) {
int o = __offset(4);
return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null;
}
public NamespaceA.SecondTableInA referToA2() {
return referToA2(new NamespaceA.SecondTableInA());
}
public NamespaceA.SecondTableInA referToA2(NamespaceA.SecondTableInA obj) {
int o = __offset(6);
return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null;
}
public static int createTableInC(
FlatBufferBuilder builder, int referToA1Offset, int referToA2Offset) {
builder.startTable(2);
TableInC.addReferToA2(builder, referToA2Offset);
TableInC.addReferToA1(builder, referToA1Offset);
return TableInC.endTableInC(builder);
}
public static void startTableInC(FlatBufferBuilder builder) { builder.startTable(2); }
public static void addReferToA1(FlatBufferBuilder builder, int referToA1Offset) { builder.addOffset(0, referToA1Offset, 0); }
public static void addReferToA2(FlatBufferBuilder builder, int referToA2Offset) { builder.addOffset(1, referToA2Offset, 0); }
public static void startTableInC(FlatBufferBuilder builder) {
builder.startTable(2);
}
public static void addReferToA1(FlatBufferBuilder builder, int referToA1Offset) {
builder.addOffset(0, referToA1Offset, 0);
}
public static void addReferToA2(FlatBufferBuilder builder, int referToA2Offset) {
builder.addOffset(1, referToA2Offset, 0);
}
public static int endTableInC(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
}
public static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) {
__reset(_vector, _element_size, _bb);
return this;
}
public TableInC get(int j) { return get(new TableInC(), j); }
public TableInC get(TableInC obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
public TableInC get(int j) {
return get(new TableInC(), j);
}
public TableInC get(TableInC obj, int j) {
return obj.__assign(__indirect(__element(j), bb), bb);
}
}
public TableInCT unpack() {
TableInCT _o = new TableInCT();
unpackTo(_o);
return _o;
}
public void unpackTo(TableInCT _o) {
if (referToA1() != null) _o.setReferToA1(referToA1().unpack());
else _o.setReferToA1(null);
if (referToA2() != null) _o.setReferToA2(referToA2().unpack());
else _o.setReferToA2(null);
}
public static int pack(FlatBufferBuilder builder, TableInCT _o) {
if (_o == null) return 0;
int _refer_to_a1 = _o.getReferToA1() == null ? 0 : NamespaceA.TableInFirstNS.pack(builder, _o.getReferToA1());
int _refer_to_a2 = _o.getReferToA2() == null ? 0 : NamespaceA.SecondTableInA.pack(builder, _o.getReferToA2());
return createTableInC(
builder,
_refer_to_a1,
_refer_to_a2);
int _refer_to_a1 =
_o.getReferToA1() == null ? 0 : NamespaceA.TableInFirstNS.pack(builder, _o.getReferToA1());
int _refer_to_a2 =
_o.getReferToA2() == null ? 0 : NamespaceA.SecondTableInA.pack(builder, _o.getReferToA2());
return createTableInC(builder, _refer_to_a1, _refer_to_a2);
}
}

View File

@@ -2,70 +2,81 @@
package NamespaceC
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
@Suppress("unused")
@ExperimentalUnsignedTypes
class TableInC : Table() {
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
}
fun __assign(_i: Int, _bb: ByteBuffer): TableInC {
__init(_i, _bb)
return this
}
val referToA1: NamespaceA.TableInFirstNS?
get() = referToA1(NamespaceA.TableInFirstNS())
fun referToA1(obj: NamespaceA.TableInFirstNS): NamespaceA.TableInFirstNS? {
val o = __offset(4)
return if (o != 0) {
obj.__assign(__indirect(o + bb_pos), bb)
} else {
null
}
fun __assign(_i: Int, _bb: ByteBuffer) : TableInC {
__init(_i, _bb)
return this
}
val referToA2: NamespaceA.SecondTableInA?
get() = referToA2(NamespaceA.SecondTableInA())
fun referToA2(obj: NamespaceA.SecondTableInA): NamespaceA.SecondTableInA? {
val o = __offset(6)
return if (o != 0) {
obj.__assign(__indirect(o + bb_pos), bb)
} else {
null
}
val referToA1 : NamespaceA.TableInFirstNS? get() = referToA1(NamespaceA.TableInFirstNS())
fun referToA1(obj: NamespaceA.TableInFirstNS) : NamespaceA.TableInFirstNS? {
val o = __offset(4)
return if (o != 0) {
obj.__assign(__indirect(o + bb_pos), bb)
} else {
null
}
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_25_2_10()
fun getRootAsTableInC(_bb: ByteBuffer): TableInC = getRootAsTableInC(_bb, TableInC())
fun getRootAsTableInC(_bb: ByteBuffer, obj: TableInC): TableInC {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
val referToA2 : NamespaceA.SecondTableInA? get() = referToA2(NamespaceA.SecondTableInA())
fun referToA2(obj: NamespaceA.SecondTableInA) : NamespaceA.SecondTableInA? {
val o = __offset(6)
return if (o != 0) {
obj.__assign(__indirect(o + bb_pos), bb)
} else {
null
}
fun createTableInC(
builder: FlatBufferBuilder,
referToA1Offset: Int,
referToA2Offset: Int,
): Int {
builder.startTable(2)
addReferToA2(builder, referToA2Offset)
addReferToA1(builder, referToA1Offset)
return endTableInC(builder)
}
companion object {
fun validateVersion() = Constants.FLATBUFFERS_25_2_10()
fun getRootAsTableInC(_bb: ByteBuffer): TableInC = getRootAsTableInC(_bb, TableInC())
fun getRootAsTableInC(_bb: ByteBuffer, obj: TableInC): TableInC {
_bb.order(ByteOrder.LITTLE_ENDIAN)
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
}
fun createTableInC(builder: FlatBufferBuilder, referToA1Offset: Int, referToA2Offset: Int) : Int {
builder.startTable(2)
addReferToA2(builder, referToA2Offset)
addReferToA1(builder, referToA1Offset)
return endTableInC(builder)
}
fun startTableInC(builder: FlatBufferBuilder) = builder.startTable(2)
fun addReferToA1(builder: FlatBufferBuilder, referToA1: Int) = builder.addOffset(0, referToA1, 0)
fun addReferToA2(builder: FlatBufferBuilder, referToA2: Int) = builder.addOffset(1, referToA2, 0)
fun endTableInC(builder: FlatBufferBuilder) : Int {
val o = builder.endTable()
return o
}
fun startTableInC(builder: FlatBufferBuilder) = builder.startTable(2)
fun addReferToA1(builder: FlatBufferBuilder, referToA1: Int) =
builder.addOffset(0, referToA1, 0)
fun addReferToA2(builder: FlatBufferBuilder, referToA2: Int) =
builder.addOffset(1, referToA2, 0)
fun endTableInC(builder: FlatBufferBuilder): Int {
val o = builder.endTable()
return o
}
}
}

View File

@@ -4,101 +4,130 @@
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class TableInC(object):
__slots__ = ['_tab']
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = TableInC()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = TableInC()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsTableInC(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# TableInC
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
@classmethod
def GetRootAsTableInC(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# TableInC
def ReferToA1(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
obj = TableInFirstNS()
obj.Init(self._tab.Bytes, x)
return obj
return None
# TableInC
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# TableInC
def ReferToA1(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
obj = TableInFirstNS()
obj.Init(self._tab.Bytes, x)
return obj
return None
# TableInC
def ReferToA2(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
obj = SecondTableInA()
obj.Init(self._tab.Bytes, x)
return obj
return None
def TableInCStart(builder):
builder.StartObject(2)
# TableInC
def ReferToA2(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
obj = SecondTableInA()
obj.Init(self._tab.Bytes, x)
return obj
return None
def TableInCStart(builder): builder.StartObject(2)
def Start(builder):
return TableInCStart(builder)
def TableInCAddReferToA1(builder, referToA1): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(referToA1), 0)
return TableInCStart(builder)
def TableInCAddReferToA1(builder, referToA1):
builder.PrependUOffsetTRelativeSlot(
0, flatbuffers.number_types.UOffsetTFlags.py_type(referToA1), 0
)
def AddReferToA1(builder, referToA1):
return TableInCAddReferToA1(builder, referToA1)
def TableInCAddReferToA2(builder, referToA2): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(referToA2), 0)
return TableInCAddReferToA1(builder, referToA1)
def TableInCAddReferToA2(builder, referToA2):
builder.PrependUOffsetTRelativeSlot(
1, flatbuffers.number_types.UOffsetTFlags.py_type(referToA2), 0
)
def AddReferToA2(builder, referToA2):
return TableInCAddReferToA2(builder, referToA2)
def TableInCEnd(builder): return builder.EndObject()
return TableInCAddReferToA2(builder, referToA2)
def TableInCEnd(builder):
return builder.EndObject()
def End(builder):
return TableInCEnd(builder)
return TableInCEnd(builder)
try:
from typing import Optional
from typing import Optional
except:
pass
pass
class TableInCT(object):
# TableInCT
def __init__(self):
self.referToA1 = None # type: Optional[TableInFirstNST]
self.referToA2 = None # type: Optional[SecondTableInAT]
# TableInCT
def __init__(self):
self.referToA1 = None # type: Optional[TableInFirstNST]
self.referToA2 = None # type: Optional[SecondTableInAT]
@classmethod
def InitFromBuf(cls, buf, pos):
tableInC = TableInC()
tableInC.Init(buf, pos)
return cls.InitFromObj(tableInC)
@classmethod
def InitFromBuf(cls, buf, pos):
tableInC = TableInC()
tableInC.Init(buf, pos)
return cls.InitFromObj(tableInC)
@classmethod
def InitFromObj(cls, tableInC):
x = TableInCT()
x._UnPack(tableInC)
return x
@classmethod
def InitFromObj(cls, tableInC):
x = TableInCT()
x._UnPack(tableInC)
return x
# TableInCT
def _UnPack(self, tableInC):
if tableInC is None:
return
if tableInC.ReferToA1() is not None:
self.referToA1 = TableInFirstNST.InitFromObj(tableInC.ReferToA1())
if tableInC.ReferToA2() is not None:
self.referToA2 = SecondTableInAT.InitFromObj(tableInC.ReferToA2())
# TableInCT
def _UnPack(self, tableInC):
if tableInC is None:
return
if tableInC.ReferToA1() is not None:
self.referToA1 = TableInFirstNST.InitFromObj(tableInC.ReferToA1())
if tableInC.ReferToA2() is not None:
self.referToA2 = SecondTableInAT.InitFromObj(tableInC.ReferToA2())
# TableInCT
def Pack(self, builder):
if self.referToA1 is not None:
referToA1 = self.referToA1.Pack(builder)
if self.referToA2 is not None:
referToA2 = self.referToA2.Pack(builder)
TableInCStart(builder)
if self.referToA1 is not None:
TableInCAddReferToA1(builder, referToA1)
if self.referToA2 is not None:
TableInCAddReferToA2(builder, referToA2)
tableInC = TableInCEnd(builder)
return tableInC
# TableInCT
def Pack(self, builder):
if self.referToA1 is not None:
referToA1 = self.referToA1.Pack(builder)
if self.referToA2 is not None:
referToA2 = self.referToA2.Pack(builder)
TableInCStart(builder)
if self.referToA1 is not None:
TableInCAddReferToA1(builder, referToA1)
if self.referToA2 is not None:
TableInCAddReferToA2(builder, referToA2)
tableInC = TableInCEnd(builder)
return tableInC

View File

@@ -2,27 +2,32 @@
package NamespaceC;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
import java.nio.*;
import java.util.*;
public class TableInCT {
private NamespaceA.TableInFirstNST referToA1;
private NamespaceA.SecondTableInAT referToA2;
public NamespaceA.TableInFirstNST getReferToA1() { return referToA1; }
public NamespaceA.TableInFirstNST getReferToA1() {
return referToA1;
}
public void setReferToA1(NamespaceA.TableInFirstNST referToA1) { this.referToA1 = referToA1; }
public void setReferToA1(NamespaceA.TableInFirstNST referToA1) {
this.referToA1 = referToA1;
}
public NamespaceA.SecondTableInAT getReferToA2() { return referToA2; }
public void setReferToA2(NamespaceA.SecondTableInAT referToA2) { this.referToA2 = referToA2; }
public NamespaceA.SecondTableInAT getReferToA2() {
return referToA2;
}
public void setReferToA2(NamespaceA.SecondTableInAT referToA2) {
this.referToA2 = referToA2;
}
public TableInCT() {
this.referToA1 = null;
this.referToA2 = null;
}
}

View File

@@ -4,8 +4,8 @@
library namespace_a.namespace_b;
import 'dart:typed_data' show Uint8List;
import 'package:flat_buffers/flat_buffers.dart' as fb;
import 'package:flat_buffers/flat_buffers.dart' as fb;
class UnionInNestedNSTypeId {
final int value;
@@ -14,12 +14,14 @@ class UnionInNestedNSTypeId {
factory UnionInNestedNSTypeId.fromValue(int value) {
final result = values[value];
if (result == null) {
throw StateError('Invalid value $value for bit flag enum UnionInNestedNSTypeId');
throw StateError(
'Invalid value $value for bit flag enum UnionInNestedNSTypeId',
);
}
return result;
}
static UnionInNestedNSTypeId? _createOrNull(int? value) =>
static UnionInNestedNSTypeId? _createOrNull(int? value) =>
value == null ? null : UnionInNestedNSTypeId.fromValue(value);
static const int minValue = 0;
@@ -27,12 +29,16 @@ class UnionInNestedNSTypeId {
static bool containsValue(int value) => values.containsKey(value);
static const UnionInNestedNSTypeId NONE = UnionInNestedNSTypeId._(0);
static const UnionInNestedNSTypeId TableInNestedNS = UnionInNestedNSTypeId._(1);
static const UnionInNestedNSTypeId TableInNestedNS = UnionInNestedNSTypeId._(
1,
);
static const Map<int, UnionInNestedNSTypeId> values = {
0: NONE,
1: TableInNestedNS};
1: TableInNestedNS,
};
static const fb.Reader<UnionInNestedNSTypeId> reader = _UnionInNestedNSTypeIdReader();
static const fb.Reader<UnionInNestedNSTypeId> reader =
_UnionInNestedNSTypeIdReader();
@override
String toString() {
@@ -63,7 +69,7 @@ class EnumInNestedNS {
return result;
}
static EnumInNestedNS? _createOrNull(int? value) =>
static EnumInNestedNS? _createOrNull(int? value) =>
value == null ? null : EnumInNestedNS.fromValue(value);
static const int minValue = 0;
@@ -73,10 +79,7 @@ class EnumInNestedNS {
static const EnumInNestedNS A = EnumInNestedNS._(0);
static const EnumInNestedNS B = EnumInNestedNS._(1);
static const EnumInNestedNS C = EnumInNestedNS._(2);
static const Map<int, EnumInNestedNS> values = {
0: A,
1: B,
2: C};
static const Map<int, EnumInNestedNS> values = {0: A, 1: B, 2: C};
static const fb.Reader<EnumInNestedNS> reader = _EnumInNestedNSReader();
@@ -116,8 +119,7 @@ class TableInNestedNS {
return 'TableInNestedNS{foo: $foo}';
}
TableInNestedNST unpack() => TableInNestedNST(
foo: foo);
TableInNestedNST unpack() => TableInNestedNST(foo: foo);
static int pack(fb.Builder fbBuilder, TableInNestedNST? object) {
if (object == null) return 0;
@@ -128,8 +130,7 @@ class TableInNestedNS {
class TableInNestedNST implements fb.Packable {
int foo;
TableInNestedNST({
this.foo = 0});
TableInNestedNST({this.foo = 0});
@override
int pack(fb.Builder fbBuilder) {
@@ -148,8 +149,8 @@ class _TableInNestedNSReader extends fb.TableReader<TableInNestedNS> {
const _TableInNestedNSReader();
@override
TableInNestedNS createObject(fb.BufferContext bc, int offset) =>
TableInNestedNS._(bc, offset);
TableInNestedNS createObject(fb.BufferContext bc, int offset) =>
TableInNestedNS._(bc, offset);
}
class TableInNestedNSBuilder {
@@ -174,10 +175,7 @@ class TableInNestedNSBuilder {
class TableInNestedNSObjectBuilder extends fb.ObjectBuilder {
final int? _foo;
TableInNestedNSObjectBuilder({
int? foo,
})
: _foo = foo;
TableInNestedNSObjectBuilder({int? foo}) : _foo = foo;
/// Finish building, and store into the [fbBuilder].
@override
@@ -195,6 +193,7 @@ class TableInNestedNSObjectBuilder extends fb.ObjectBuilder {
return fbBuilder.buffer;
}
}
class StructInNestedNS {
StructInNestedNS._(this._bc, this._bcOffset);
@@ -211,9 +210,7 @@ class StructInNestedNS {
return 'StructInNestedNS{a: $a, b: $b}';
}
StructInNestedNST unpack() => StructInNestedNST(
a: a,
b: b);
StructInNestedNST unpack() => StructInNestedNST(a: a, b: b);
static int pack(fb.Builder fbBuilder, StructInNestedNST? object) {
if (object == null) return 0;
@@ -225,9 +222,7 @@ class StructInNestedNST implements fb.Packable {
int a;
int b;
StructInNestedNST({
required this.a,
required this.b});
StructInNestedNST({required this.a, required this.b});
@override
int pack(fb.Builder fbBuilder) {
@@ -249,8 +244,8 @@ class _StructInNestedNSReader extends fb.StructReader<StructInNestedNS> {
int get size => 8;
@override
StructInNestedNS createObject(fb.BufferContext bc, int offset) =>
StructInNestedNS._(bc, offset);
StructInNestedNS createObject(fb.BufferContext bc, int offset) =>
StructInNestedNS._(bc, offset);
}
class StructInNestedNSBuilder {
@@ -263,19 +258,15 @@ class StructInNestedNSBuilder {
fbBuilder.putInt32(a);
return fbBuilder.offset;
}
}
class StructInNestedNSObjectBuilder extends fb.ObjectBuilder {
final int _a;
final int _b;
StructInNestedNSObjectBuilder({
required int a,
required int b,
})
: _a = a,
_b = b;
StructInNestedNSObjectBuilder({required int a, required int b})
: _a = a,
_b = b;
/// Finish building, and store into the [fbBuilder].
@override

View File

@@ -4,6 +4,7 @@
library namespace_a;
import 'dart:typed_data' show Uint8List;
import 'package:flat_buffers/flat_buffers.dart' as fb;
import './namespace_test2_namespace_c_generated.dart' as namespace_c;
@@ -20,16 +21,34 @@ class TableInFirstNS {
final fb.BufferContext _bc;
final int _bcOffset;
namespace_a_namespace_b.TableInNestedNS? get fooTable => namespace_a_namespace_b.TableInNestedNS.reader.vTableGetNullable(_bc, _bcOffset, 4);
EnumInNestedNS get fooEnum => EnumInNestedNS.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 6, 0));
UnionInNestedNSTypeId? get fooUnionType => UnionInNestedNSTypeId._createOrNull(const fb.Uint8Reader().vTableGetNullable(_bc, _bcOffset, 8));
namespace_a_namespace_b.TableInNestedNS? get fooTable =>
namespace_a_namespace_b.TableInNestedNS.reader.vTableGetNullable(
_bc,
_bcOffset,
4,
);
EnumInNestedNS get fooEnum => EnumInNestedNS.fromValue(
const fb.Int8Reader().vTableGet(_bc, _bcOffset, 6, 0),
);
UnionInNestedNSTypeId? get fooUnionType =>
UnionInNestedNSTypeId._createOrNull(
const fb.Uint8Reader().vTableGetNullable(_bc, _bcOffset, 8),
);
dynamic get fooUnion {
switch (fooUnionType?.value) {
case 1: return TableInNestedNS.reader.vTableGetNullable(_bc, _bcOffset, 10);
default: return null;
case 1:
return TableInNestedNS.reader.vTableGetNullable(_bc, _bcOffset, 10);
default:
return null;
}
}
namespace_a_namespace_b.StructInNestedNS? get fooStruct => namespace_a_namespace_b.StructInNestedNS.reader.vTableGetNullable(_bc, _bcOffset, 12);
namespace_a_namespace_b.StructInNestedNS? get fooStruct =>
namespace_a_namespace_b.StructInNestedNS.reader.vTableGetNullable(
_bc,
_bcOffset,
12,
);
@override
String toString() {
@@ -37,11 +56,12 @@ class TableInFirstNS {
}
TableInFirstNST unpack() => TableInFirstNST(
fooTable: fooTable?.unpack(),
fooEnum: fooEnum,
fooUnionType: fooUnionType,
fooUnion: fooUnion,
fooStruct: fooStruct?.unpack());
fooTable: fooTable?.unpack(),
fooEnum: fooEnum,
fooUnionType: fooUnionType,
fooUnion: fooUnion,
fooStruct: fooStruct?.unpack(),
);
static int pack(fb.Builder fbBuilder, TableInFirstNST? object) {
if (object == null) return 0;
@@ -57,11 +77,12 @@ class TableInFirstNST implements fb.Packable {
namespace_a_namespace_b.StructInNestedNST? fooStruct;
TableInFirstNST({
this.fooTable,
this.fooEnum = EnumInNestedNS.A,
this.fooUnionType,
this.fooUnion,
this.fooStruct});
this.fooTable,
this.fooEnum = EnumInNestedNS.A,
this.fooUnionType,
this.fooUnion,
this.fooStruct,
});
@override
int pack(fb.Builder fbBuilder) {
@@ -88,8 +109,8 @@ class _TableInFirstNSReader extends fb.TableReader<TableInFirstNS> {
const _TableInFirstNSReader();
@override
TableInFirstNS createObject(fb.BufferContext bc, int offset) =>
TableInFirstNS._(bc, offset);
TableInFirstNS createObject(fb.BufferContext bc, int offset) =>
TableInFirstNS._(bc, offset);
}
class TableInFirstNSBuilder {
@@ -105,18 +126,22 @@ class TableInFirstNSBuilder {
fbBuilder.addOffset(0, offset);
return fbBuilder.offset;
}
int addFooEnum(EnumInNestedNS? fooEnum) {
fbBuilder.addInt8(1, fooEnum?.value);
return fbBuilder.offset;
}
int addFooUnionType(UnionInNestedNSTypeId? fooUnionType) {
fbBuilder.addUint8(2, fooUnionType?.value);
return fbBuilder.offset;
}
int addFooUnionOffset(int? offset) {
fbBuilder.addOffset(3, offset);
return fbBuilder.offset;
}
int addFooStruct(int offset) {
fbBuilder.addStruct(4, offset);
return fbBuilder.offset;
@@ -140,12 +165,11 @@ class TableInFirstNSObjectBuilder extends fb.ObjectBuilder {
UnionInNestedNSTypeId? fooUnionType,
dynamic fooUnion,
namespace_a_namespace_b.StructInNestedNSObjectBuilder? fooStruct,
})
: _fooTable = fooTable,
_fooEnum = fooEnum,
_fooUnionType = fooUnionType,
_fooUnion = fooUnion,
_fooStruct = fooStruct;
}) : _fooTable = fooTable,
_fooEnum = fooEnum,
_fooUnionType = fooUnionType,
_fooUnion = fooUnion,
_fooStruct = fooStruct;
/// Finish building, and store into the [fbBuilder].
@override
@@ -171,6 +195,7 @@ class TableInFirstNSObjectBuilder extends fb.ObjectBuilder {
return fbBuilder.buffer;
}
}
class SecondTableInA {
SecondTableInA._(this._bc, this._bcOffset);
factory SecondTableInA(List<int> bytes) {
@@ -183,15 +208,15 @@ class SecondTableInA {
final fb.BufferContext _bc;
final int _bcOffset;
namespace_c.TableInC? get referToC => namespace_c.TableInC.reader.vTableGetNullable(_bc, _bcOffset, 4);
namespace_c.TableInC? get referToC =>
namespace_c.TableInC.reader.vTableGetNullable(_bc, _bcOffset, 4);
@override
String toString() {
return 'SecondTableInA{referToC: $referToC}';
}
SecondTableInAT unpack() => SecondTableInAT(
referToC: referToC?.unpack());
SecondTableInAT unpack() => SecondTableInAT(referToC: referToC?.unpack());
static int pack(fb.Builder fbBuilder, SecondTableInAT? object) {
if (object == null) return 0;
@@ -202,8 +227,7 @@ class SecondTableInA {
class SecondTableInAT implements fb.Packable {
namespace_c.TableInCT? referToC;
SecondTableInAT({
this.referToC});
SecondTableInAT({this.referToC});
@override
int pack(fb.Builder fbBuilder) {
@@ -223,8 +247,8 @@ class _SecondTableInAReader extends fb.TableReader<SecondTableInA> {
const _SecondTableInAReader();
@override
SecondTableInA createObject(fb.BufferContext bc, int offset) =>
SecondTableInA._(bc, offset);
SecondTableInA createObject(fb.BufferContext bc, int offset) =>
SecondTableInA._(bc, offset);
}
class SecondTableInABuilder {
@@ -249,10 +273,8 @@ class SecondTableInABuilder {
class SecondTableInAObjectBuilder extends fb.ObjectBuilder {
final namespace_c.TableInCObjectBuilder? _referToC;
SecondTableInAObjectBuilder({
namespace_c.TableInCObjectBuilder? referToC,
})
: _referToC = referToC;
SecondTableInAObjectBuilder({namespace_c.TableInCObjectBuilder? referToC})
: _referToC = referToC;
/// Finish building, and store into the [fbBuilder].
@override

View File

@@ -4,6 +4,7 @@
library namespace_c;
import 'dart:typed_data' show Uint8List;
import 'package:flat_buffers/flat_buffers.dart' as fb;
import './namespace_test2_namespace_a_generated.dart' as namespace_a;
@@ -20,17 +21,18 @@ class TableInC {
final fb.BufferContext _bc;
final int _bcOffset;
namespace_a.TableInFirstNS? get referToA1 => namespace_a.TableInFirstNS.reader.vTableGetNullable(_bc, _bcOffset, 4);
namespace_a.SecondTableInA? get referToA2 => namespace_a.SecondTableInA.reader.vTableGetNullable(_bc, _bcOffset, 6);
namespace_a.TableInFirstNS? get referToA1 =>
namespace_a.TableInFirstNS.reader.vTableGetNullable(_bc, _bcOffset, 4);
namespace_a.SecondTableInA? get referToA2 =>
namespace_a.SecondTableInA.reader.vTableGetNullable(_bc, _bcOffset, 6);
@override
String toString() {
return 'TableInC{referToA1: $referToA1, referToA2: $referToA2}';
}
TableInCT unpack() => TableInCT(
referToA1: referToA1?.unpack(),
referToA2: referToA2?.unpack());
TableInCT unpack() =>
TableInCT(referToA1: referToA1?.unpack(), referToA2: referToA2?.unpack());
static int pack(fb.Builder fbBuilder, TableInCT? object) {
if (object == null) return 0;
@@ -42,9 +44,7 @@ class TableInCT implements fb.Packable {
namespace_a.TableInFirstNST? referToA1;
namespace_a.SecondTableInAT? referToA2;
TableInCT({
this.referToA1,
this.referToA2});
TableInCT({this.referToA1, this.referToA2});
@override
int pack(fb.Builder fbBuilder) {
@@ -66,8 +66,8 @@ class _TableInCReader extends fb.TableReader<TableInC> {
const _TableInCReader();
@override
TableInC createObject(fb.BufferContext bc, int offset) =>
TableInC._(bc, offset);
TableInC createObject(fb.BufferContext bc, int offset) =>
TableInC._(bc, offset);
}
class TableInCBuilder {
@@ -83,6 +83,7 @@ class TableInCBuilder {
fbBuilder.addOffset(0, offset);
return fbBuilder.offset;
}
int addReferToA2Offset(int? offset) {
fbBuilder.addOffset(1, offset);
return fbBuilder.offset;
@@ -100,9 +101,8 @@ class TableInCObjectBuilder extends fb.ObjectBuilder {
TableInCObjectBuilder({
namespace_a.TableInFirstNSObjectBuilder? referToA1,
namespace_a.SecondTableInAObjectBuilder? referToA2,
})
: _referToA1 = referToA1,
_referToA2 = referToA2;
}) : _referToA1 = referToA1,
_referToA2 = referToA2;
/// Finish building, and store into the [fbBuilder].
@override

View File

@@ -26,10 +26,10 @@ struct Vector3DAlt;
} // namespace Geometry
namespace flatbuffers {
Geometry::Vector3D Pack(const Native::Vector3D &obj);
const Native::Vector3D UnPack(const Geometry::Vector3D &obj);
Geometry::Vector3DAlt PackVector3DAlt(const Native::Vector3D &obj);
const Native::Vector3D UnPackVector3DAlt(const Geometry::Vector3DAlt &obj);
Geometry::Vector3D Pack(const Native::Vector3D& obj);
const Native::Vector3D UnPack(const Geometry::Vector3D& obj);
Geometry::Vector3DAlt PackVector3DAlt(const Native::Vector3D& obj);
const Native::Vector3D UnPackVector3DAlt(const Geometry::Vector3DAlt& obj);
} // namespace flatbuffers
#endif // VECTOR3D_PACK_H

View File

@@ -1,22 +1,22 @@
import glob
import os
from pathlib import Path
import shutil
import subprocess
from pathlib import Path
test_nim_dir = Path(__file__).absolute().parent
test_dir = test_nim_dir.parent
def main():
try:
subprocess.check_call("testament --megatest:off all".split())
finally:
shutil.rmtree(test_nim_dir / "nimcache")
shutil.rmtree(test_nim_dir / "testresults")
for f in glob.glob(str(test_nim_dir / "tests" / "*" / "test")):
os.remove(f)
try:
subprocess.check_call("testament --megatest:off all".split())
finally:
shutil.rmtree(test_nim_dir / "nimcache")
shutil.rmtree(test_nim_dir / "testresults")
for f in glob.glob(str(test_nim_dir / "tests" / "*" / "test")):
os.remove(f)
if __name__ == "__main__":
main()
main()

View File

@@ -7,46 +7,48 @@ import (
)
type ScalarStuffT struct {
JustI8 int8 `json:"just_i8"`
MaybeI8 *int8 `json:"maybe_i8"`
DefaultI8 int8 `json:"default_i8"`
JustU8 byte `json:"just_u8"`
MaybeU8 *byte `json:"maybe_u8"`
DefaultU8 byte `json:"default_u8"`
JustI16 int16 `json:"just_i16"`
MaybeI16 *int16 `json:"maybe_i16"`
DefaultI16 int16 `json:"default_i16"`
JustU16 uint16 `json:"just_u16"`
MaybeU16 *uint16 `json:"maybe_u16"`
DefaultU16 uint16 `json:"default_u16"`
JustI32 int32 `json:"just_i32"`
MaybeI32 *int32 `json:"maybe_i32"`
DefaultI32 int32 `json:"default_i32"`
JustU32 uint32 `json:"just_u32"`
MaybeU32 *uint32 `json:"maybe_u32"`
DefaultU32 uint32 `json:"default_u32"`
JustI64 int64 `json:"just_i64"`
MaybeI64 *int64 `json:"maybe_i64"`
DefaultI64 int64 `json:"default_i64"`
JustU64 uint64 `json:"just_u64"`
MaybeU64 *uint64 `json:"maybe_u64"`
DefaultU64 uint64 `json:"default_u64"`
JustF32 float32 `json:"just_f32"`
MaybeF32 *float32 `json:"maybe_f32"`
DefaultF32 float32 `json:"default_f32"`
JustF64 float64 `json:"just_f64"`
MaybeF64 *float64 `json:"maybe_f64"`
DefaultF64 float64 `json:"default_f64"`
JustBool bool `json:"just_bool"`
MaybeBool *bool `json:"maybe_bool"`
DefaultBool bool `json:"default_bool"`
JustEnum OptionalByte `json:"just_enum"`
MaybeEnum *OptionalByte `json:"maybe_enum"`
DefaultEnum OptionalByte `json:"default_enum"`
JustI8 int8 `json:"just_i8"`
MaybeI8 *int8 `json:"maybe_i8"`
DefaultI8 int8 `json:"default_i8"`
JustU8 byte `json:"just_u8"`
MaybeU8 *byte `json:"maybe_u8"`
DefaultU8 byte `json:"default_u8"`
JustI16 int16 `json:"just_i16"`
MaybeI16 *int16 `json:"maybe_i16"`
DefaultI16 int16 `json:"default_i16"`
JustU16 uint16 `json:"just_u16"`
MaybeU16 *uint16 `json:"maybe_u16"`
DefaultU16 uint16 `json:"default_u16"`
JustI32 int32 `json:"just_i32"`
MaybeI32 *int32 `json:"maybe_i32"`
DefaultI32 int32 `json:"default_i32"`
JustU32 uint32 `json:"just_u32"`
MaybeU32 *uint32 `json:"maybe_u32"`
DefaultU32 uint32 `json:"default_u32"`
JustI64 int64 `json:"just_i64"`
MaybeI64 *int64 `json:"maybe_i64"`
DefaultI64 int64 `json:"default_i64"`
JustU64 uint64 `json:"just_u64"`
MaybeU64 *uint64 `json:"maybe_u64"`
DefaultU64 uint64 `json:"default_u64"`
JustF32 float32 `json:"just_f32"`
MaybeF32 *float32 `json:"maybe_f32"`
DefaultF32 float32 `json:"default_f32"`
JustF64 float64 `json:"just_f64"`
MaybeF64 *float64 `json:"maybe_f64"`
DefaultF64 float64 `json:"default_f64"`
JustBool bool `json:"just_bool"`
MaybeBool *bool `json:"maybe_bool"`
DefaultBool bool `json:"default_bool"`
JustEnum OptionalByte `json:"just_enum"`
MaybeEnum *OptionalByte `json:"maybe_enum"`
DefaultEnum OptionalByte `json:"default_enum"`
}
func (t *ScalarStuffT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
if t == nil {
return 0
}
ScalarStuffStart(builder)
ScalarStuffAddJustI8(builder, t.JustI8)
if t.MaybeI8 != nil {
@@ -151,7 +153,9 @@ func (rcv *ScalarStuff) UnPackTo(t *ScalarStuffT) {
}
func (rcv *ScalarStuff) UnPack() *ScalarStuffT {
if rcv == nil { return nil }
if rcv == nil {
return nil
}
t := &ScalarStuffT{}
rcv.UnPackTo(t)
return t

View File

@@ -1,4 +1,4 @@
// automatically generated by the FlatBuffers compiler, do not modify
export { OptionalByte } from './optional-scalars/optional-byte';
export { ScalarStuff } from './optional-scalars/scalar-stuff';
export {OptionalByte} from './optional-scalars/optional-byte';
export {ScalarStuff} from './optional-scalars/scalar-stuff';

View File

@@ -1,7 +1,6 @@
#ifndef TESTS_OPTIONAL_SCALARS_TEST_H
#define TESTS_OPTIONAL_SCALARS_TEST_H
namespace flatbuffers {
namespace tests {

View File

@@ -9,12 +9,14 @@ import (
)
type FoodT struct {
Pizza *Pizza.PizzaT `json:"pizza"`
Pizza *Pizza.PizzaT `json:"pizza"`
PizzaTest *Pizza.PizzaT `json:"pizza_test"`
}
func (t *FoodT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil { return 0 }
if t == nil {
return 0
}
pizzaOffset := t.Pizza.Pack(builder)
pizzaTestOffset := t.PizzaTest.Pack(builder)
FoodStart(builder)
@@ -29,7 +31,9 @@ func (rcv *Food) UnPackTo(t *FoodT) {
}
func (rcv *Food) UnPack() *FoodT {
if rcv == nil { return nil }
if rcv == nil {
return nil
}
t := &FoodT{}
rcv.UnPackTo(t)
return t

View File

@@ -1,28 +1,42 @@
#ifndef TESTS_PROTO_TEST_H
#define TESTS_PROTO_TEST_H
#include "flatbuffers/idl.h"
#include <string>
#include "flatbuffers/idl.h"
namespace flatbuffers {
namespace tests {
void RunTest(const flatbuffers::IDLOptions &opts, const std::string &proto_path, const std::string &proto_file,
const std::string &golden_file, const std::string import_proto_file = {});
void proto_test(const std::string &proto_path, const std::string &proto_file);
void proto_test_union(const std::string &proto_path, const std::string &proto_file);
void proto_test_union_suffix(const std::string &proto_path, const std::string &proto_file);
void proto_test_include(const std::string &proto_path, const std::string &proto_file, const std::string &import_proto_file);
void proto_test_include_union(const std::string &proto_path, const std::string &proto_file, const std::string &import_proto_file);
void RunTest(const flatbuffers::IDLOptions& opts, const std::string& proto_path,
const std::string& proto_file, const std::string& golden_file,
const std::string import_proto_file = {});
void proto_test(const std::string& proto_path, const std::string& proto_file);
void proto_test_union(const std::string& proto_path,
const std::string& proto_file);
void proto_test_union_suffix(const std::string& proto_path,
const std::string& proto_file);
void proto_test_include(const std::string& proto_path,
const std::string& proto_file,
const std::string& import_proto_file);
void proto_test_include_union(const std::string& proto_path,
const std::string& proto_file,
const std::string& import_proto_file);
void proto_test_id(const std::string &proto_path, const std::string &proto_file);
void proto_test_union_id(const std::string &proto_path, const std::string &proto_file);
void proto_test_union_suffix_id(const std::string &proto_path, const std::string &proto_file);
void proto_test_include_id(const std::string &proto_path, const std::string &proto_file, const std::string &import_proto_file);
void proto_test_include_union_id(const std::string &proto_path, const std::string &proto_file, const std::string &import_proto_file);
void proto_test_id(const std::string& proto_path,
const std::string& proto_file);
void proto_test_union_id(const std::string& proto_path,
const std::string& proto_file);
void proto_test_union_suffix_id(const std::string& proto_path,
const std::string& proto_file);
void proto_test_include_id(const std::string& proto_path,
const std::string& proto_file,
const std::string& import_proto_file);
void proto_test_include_union_id(const std::string& proto_path,
const std::string& proto_file,
const std::string& import_proto_file);
void ParseCorruptedProto(const std::string &proto_path);
void ParseCorruptedProto(const std::string& proto_path);
void ParseProtoTest(const std::string& tests_data_path);
void ParseProtoBufAsciiTest();

View File

@@ -32,7 +32,7 @@ GOLD_FLEXBUFFER_OBJ = {
'bools': [True, False, True, False],
'foo': 100.0,
'mymap': {'foo': 'Fred'},
'vec': [-100, 'Fred', 4.0, b'M', False, 4.0]
'vec': [-100, 'Fred', 4.0, b'M', False, 4.0],
}
GOLD_FLEXBUFFER_FILE = 'gold_flexbuffer_example.bin'
@@ -74,11 +74,15 @@ def int_sizes(value):
def int_bytes(value, byte_width):
return struct.pack('<%s' % {1: 'b', 2: 'h', 4: 'i', 8: 'q'}[byte_width], value)
return struct.pack(
'<%s' % {1: 'b', 2: 'h', 4: 'i', 8: 'q'}[byte_width], value
)
def uint_bytes(value, byte_width):
return struct.pack('<%s' % {1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[byte_width], value)
return struct.pack(
'<%s' % {1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[byte_width], value
)
def float_bytes(value, byte_width):
@@ -126,13 +130,24 @@ def encode_type(type_, value, byte_width=None):
return fbb.Finish()
INT_MIN_MAX_VALUES = (min_value(Type.INT, 1), max_value(Type.INT, 1),
min_value(Type.INT, 2), max_value(Type.INT, 2),
min_value(Type.INT, 4), max_value(Type.INT, 4),
min_value(Type.INT, 8), max_value(Type.INT, 8))
INT_MIN_MAX_VALUES = (
min_value(Type.INT, 1),
max_value(Type.INT, 1),
min_value(Type.INT, 2),
max_value(Type.INT, 2),
min_value(Type.INT, 4),
max_value(Type.INT, 4),
min_value(Type.INT, 8),
max_value(Type.INT, 8),
)
UINT_MIN_MAX_VALUES = (0, max_value(Type.UINT, 1), max_value(Type.UINT, 2),
max_value(Type.UINT, 4), max_value(Type.UINT, 8))
UINT_MIN_MAX_VALUES = (
0,
max_value(Type.UINT, 1),
max_value(Type.UINT, 2),
max_value(Type.UINT, 4),
max_value(Type.UINT, 8),
)
class UtilTest(unittest.TestCase):
@@ -149,17 +164,26 @@ class UtilTest(unittest.TestCase):
def test_inline_types(self):
self._test_type_predicate(
Type.IsInline, (Type.NULL, Type.INT, Type.UINT, Type.FLOAT, Type.BOOL))
Type.IsInline, (Type.NULL, Type.INT, Type.UINT, Type.FLOAT, Type.BOOL)
)
def test_typed_vector(self):
self._test_type_predicate(
Type.IsTypedVector,
(Type.VECTOR_INT, Type.VECTOR_UINT, Type.VECTOR_FLOAT, Type.VECTOR_KEY,
Type.VECTOR_STRING_DEPRECATED, Type.VECTOR_BOOL))
(
Type.VECTOR_INT,
Type.VECTOR_UINT,
Type.VECTOR_FLOAT,
Type.VECTOR_KEY,
Type.VECTOR_STRING_DEPRECATED,
Type.VECTOR_BOOL,
),
)
self._test_type_predicate(
Type.IsTypedVectorElementType,
(Type.INT, Type.UINT, Type.FLOAT, Type.KEY, Type.STRING, Type.BOOL))
(Type.INT, Type.UINT, Type.FLOAT, Type.KEY, Type.STRING, Type.BOOL),
)
with self.assertRaises(ValueError):
Type.ToTypedVectorElementType(Type.VECTOR)
@@ -169,7 +193,8 @@ class UtilTest(unittest.TestCase):
self.assertIs(Type.ToTypedVectorElementType(Type.VECTOR_KEY), Type.KEY)
self.assertIs(
Type.ToTypedVectorElementType(Type.VECTOR_STRING_DEPRECATED),
Type.STRING)
Type.STRING,
)
self.assertIs(Type.ToTypedVectorElementType(Type.VECTOR_BOOL), Type.BOOL)
with self.assertRaises(ValueError):
@@ -179,37 +204,57 @@ class UtilTest(unittest.TestCase):
self.assertIs(Type.ToTypedVector(Type.FLOAT), Type.VECTOR_FLOAT)
self.assertIs(Type.ToTypedVector(Type.KEY), Type.VECTOR_KEY)
self.assertIs(
Type.ToTypedVector(Type.STRING), Type.VECTOR_STRING_DEPRECATED)
Type.ToTypedVector(Type.STRING), Type.VECTOR_STRING_DEPRECATED
)
self.assertIs(Type.ToTypedVector(Type.BOOL), Type.VECTOR_BOOL)
def test_fixed_typed_vector(self):
self._test_type_predicate(
Type.IsFixedTypedVector,
(Type.VECTOR_INT2, Type.VECTOR_UINT2, Type.VECTOR_FLOAT2,
Type.VECTOR_INT3, Type.VECTOR_UINT3, Type.VECTOR_FLOAT3,
Type.VECTOR_INT4, Type.VECTOR_UINT4, Type.VECTOR_FLOAT4))
(
Type.VECTOR_INT2,
Type.VECTOR_UINT2,
Type.VECTOR_FLOAT2,
Type.VECTOR_INT3,
Type.VECTOR_UINT3,
Type.VECTOR_FLOAT3,
Type.VECTOR_INT4,
Type.VECTOR_UINT4,
Type.VECTOR_FLOAT4,
),
)
self._test_type_predicate(Type.IsFixedTypedVectorElementType,
(Type.INT, Type.UINT, Type.FLOAT))
self._test_type_predicate(
Type.IsFixedTypedVectorElementType, (Type.INT, Type.UINT, Type.FLOAT)
)
self.assertEqual(
Type.ToFixedTypedVectorElementType(Type.VECTOR_INT2), (Type.INT, 2))
Type.ToFixedTypedVectorElementType(Type.VECTOR_INT2), (Type.INT, 2)
)
self.assertEqual(
Type.ToFixedTypedVectorElementType(Type.VECTOR_UINT2), (Type.UINT, 2))
Type.ToFixedTypedVectorElementType(Type.VECTOR_UINT2), (Type.UINT, 2)
)
self.assertEqual(
Type.ToFixedTypedVectorElementType(Type.VECTOR_FLOAT2), (Type.FLOAT, 2))
Type.ToFixedTypedVectorElementType(Type.VECTOR_FLOAT2), (Type.FLOAT, 2)
)
self.assertEqual(
Type.ToFixedTypedVectorElementType(Type.VECTOR_INT3), (Type.INT, 3))
Type.ToFixedTypedVectorElementType(Type.VECTOR_INT3), (Type.INT, 3)
)
self.assertEqual(
Type.ToFixedTypedVectorElementType(Type.VECTOR_UINT3), (Type.UINT, 3))
Type.ToFixedTypedVectorElementType(Type.VECTOR_UINT3), (Type.UINT, 3)
)
self.assertEqual(
Type.ToFixedTypedVectorElementType(Type.VECTOR_FLOAT3), (Type.FLOAT, 3))
Type.ToFixedTypedVectorElementType(Type.VECTOR_FLOAT3), (Type.FLOAT, 3)
)
self.assertEqual(
Type.ToFixedTypedVectorElementType(Type.VECTOR_INT4), (Type.INT, 4))
Type.ToFixedTypedVectorElementType(Type.VECTOR_INT4), (Type.INT, 4)
)
self.assertEqual(
Type.ToFixedTypedVectorElementType(Type.VECTOR_UINT4), (Type.UINT, 4))
Type.ToFixedTypedVectorElementType(Type.VECTOR_UINT4), (Type.UINT, 4)
)
self.assertEqual(
Type.ToFixedTypedVectorElementType(Type.VECTOR_FLOAT4), (Type.FLOAT, 4))
Type.ToFixedTypedVectorElementType(Type.VECTOR_FLOAT4), (Type.FLOAT, 4)
)
# Invalid size
for type_ in Type.INT, Type.UINT, Type.FLOAT:
@@ -283,9 +328,15 @@ class DecoderTest(unittest.TestCase):
self.assertEqual(root.AsInt, 0)
self.assertEqual(root.AsFloat, 0.0)
for prop in (type(root).AsKey, type(root).AsString, type(root).AsBlob,
type(root).AsVector, type(root).AsTypedVector,
type(root).AsFixedTypedVector, type(root).AsMap):
for prop in (
type(root).AsKey,
type(root).AsString,
type(root).AsBlob,
type(root).AsVector,
type(root).AsTypedVector,
type(root).AsFixedTypedVector,
type(root).AsMap,
):
with self.assertRaises(TypeError):
prop.fget(root)
@@ -310,10 +361,15 @@ class DecoderTest(unittest.TestCase):
self.assertEqual(root.AsInt, int(value))
self.assertEqual(root.AsFloat, float(value))
for prop in (type(root).AsKey, type(root).AsString,
type(root).AsBlob,
type(root).AsVector, type(root).AsTypedVector,
type(root).AsFixedTypedVector, type(root).AsMap):
for prop in (
type(root).AsKey,
type(root).AsString,
type(root).AsBlob,
type(root).AsVector,
type(root).AsTypedVector,
type(root).AsFixedTypedVector,
type(root).AsMap,
):
with self.assertRaises(TypeError):
prop.fget(root)
@@ -341,9 +397,15 @@ class DecoderTest(unittest.TestCase):
self.assertEqual(root.AsBool, bool(value))
self.assertEqual(root.AsFloat, float(value))
for prop in (type(root).AsKey, type(root).AsString, type(root).AsBlob,
type(root).AsVector, type(root).AsTypedVector,
type(root).AsFixedTypedVector, type(root).AsMap):
for prop in (
type(root).AsKey,
type(root).AsString,
type(root).AsBlob,
type(root).AsVector,
type(root).AsTypedVector,
type(root).AsFixedTypedVector,
type(root).AsMap,
):
with self.assertRaises(TypeError):
prop.fget(root)
@@ -460,9 +522,15 @@ class DecoderTest(unittest.TestCase):
self.assertTrue(root.IsFloat)
self.assertAlmostEqual(root.AsFloat, value)
for prop in (type(root).AsKey, type(root).AsString, type(root).AsBlob,
type(root).AsVector, type(root).AsTypedVector,
type(root).AsFixedTypedVector, type(root).AsMap):
for prop in (
type(root).AsKey,
type(root).AsString,
type(root).AsBlob,
type(root).AsVector,
type(root).AsTypedVector,
type(root).AsFixedTypedVector,
type(root).AsMap,
):
with self.assertRaises(TypeError):
prop.fget(root)
@@ -640,9 +708,11 @@ class DecoderTest(unittest.TestCase):
self.assertEqual(root.AsInt, len(vector))
def test_fixed_typed_vector_float(self):
for type_, vector in ((Type.VECTOR_FLOAT2, [-75.0, 34.89]),
(Type.VECTOR_FLOAT3, [-75.0, 34.89, 12.0]),
(Type.VECTOR_FLOAT4, [-75.0, 34.89, -1.0, 1.0])):
for type_, vector in (
(Type.VECTOR_FLOAT2, [-75.0, 34.89]),
(Type.VECTOR_FLOAT3, [-75.0, 34.89, 12.0]),
(Type.VECTOR_FLOAT4, [-75.0, 34.89, -1.0, 1.0]),
):
for bw in 1, 2, 4, 8:
for ebw in 4, 8:
with self.subTest(type=type_, vector=vector, bw=bw, ebw=ebw):
@@ -659,9 +729,11 @@ class DecoderTest(unittest.TestCase):
self.assertAlmostEqual(a, b, places=2)
def test_fixed_typed_vector_int(self):
for type_, vector in ((Type.VECTOR_INT2, [0, -13]), (Type.VECTOR_INT3,
[127, 0, -13]),
(Type.VECTOR_INT4, [127, 0, -13, 0])):
for type_, vector in (
(Type.VECTOR_INT2, [0, -13]),
(Type.VECTOR_INT3, [127, 0, -13]),
(Type.VECTOR_INT4, [127, 0, -13, 0]),
):
for bw in 1, 2, 4, 8:
for ebw in 1, 2, 4, 8:
with self.subTest(type=type_, vector=vector, bw=bw, ebw=ebw):
@@ -677,9 +749,11 @@ class DecoderTest(unittest.TestCase):
self._check_fixed_typed_vector(data, vector, Type.INT)
def test_fixed_typed_vector_uint(self):
for type_, vector in ((Type.VECTOR_UINT2, [0, 13]),
(Type.VECTOR_UINT3, [127, 0, 13]), (Type.VECTOR_UINT4,
[127, 0, 13, 0])):
for type_, vector in (
(Type.VECTOR_UINT2, [0, 13]),
(Type.VECTOR_UINT3, [127, 0, 13]),
(Type.VECTOR_UINT4, [127, 0, 13, 0]),
):
for bw in 1, 2, 4, 8:
for ebw in 1, 2, 4, 8:
with self.subTest(type=type_, vector=vector, bw=bw, ebw=ebw):
@@ -709,9 +783,14 @@ class DecoderTest(unittest.TestCase):
self.assertEqual(root.AsInt, len(vector))
def test_empty_typed_vector(self):
for type_ in (Type.VECTOR_BOOL, Type.VECTOR_INT, Type.VECTOR_UINT,
Type.VECTOR_FLOAT, Type.VECTOR_KEY,
Type.VECTOR_STRING_DEPRECATED):
for type_ in (
Type.VECTOR_BOOL,
Type.VECTOR_INT,
Type.VECTOR_UINT,
Type.VECTOR_FLOAT,
Type.VECTOR_KEY,
Type.VECTOR_STRING_DEPRECATED,
):
for bw in 1, 2, 4, 8:
for ebw in 1, 2, 4, 8:
with self.subTest(type=type_, bw=bw, ebw=ebw):
@@ -721,7 +800,7 @@ class DecoderTest(unittest.TestCase):
# Root
*uint_bytes(0, bw),
packed_type(type_, ebw),
bw
bw,
])
element_type = Type.ToTypedVectorElementType(type_)
@@ -1018,8 +1097,9 @@ class DecoderTest(unittest.TestCase):
packed_type(Type.INT, vbw),
packed_type(Type.INT, vbw),
# Root
*uint_bytes(vbw * len(value) + len(value),
bw), # offset to values
*uint_bytes(
vbw * len(value) + len(value), bw
), # offset to values
packed_type(Type.MAP, vbw),
bw,
])
@@ -1196,7 +1276,8 @@ class EncoderTest(unittest.TestCase):
data = fbb.Finish()
self.assertEqual(
flexbuffers.Loads(data), ['begin', 42, [0, 1, 2, 3, 4], 'end'])
flexbuffers.Loads(data), ['begin', 42, [0, 1, 2, 3, 4], 'end']
)
def test_big_vector(self):
n = 10 * 1000
@@ -1282,8 +1363,14 @@ class EncoderTest(unittest.TestCase):
fbb.FixedTypedVectorFromElements(elements, element_type)
return fbb.Finish()
for elements in ((-2, 2), (1, 2, 3), (100, -100, 200, -200), (4.0, 7.0),
(0.0, 1.0, 8.0), (9.0, 7.0, 1.0, 5.5)):
for elements in (
(-2, 2),
(1, 2, 3),
(100, -100, 200, -200),
(4.0, 7.0),
(0.0, 1.0, 8.0),
(9.0, 7.0, 1.0, 5.5),
):
with self.subTest(elements=elements):
data = encode_fixed_typed_vector(elements)
self.assertSequenceEqual(flexbuffers.Loads(data), elements)
@@ -1340,11 +1427,8 @@ class EncoderTest(unittest.TestCase):
data = fbb.Finish()
self.assertEqual(
flexbuffers.Loads(data), {
'v': [45],
'tv': [-7],
'ftv': [-2.0, 1.0]
})
flexbuffers.Loads(data), {'v': [45], 'tv': [-7], 'ftv': [-2.0, 1.0]}
)
keys = get_keys(data)
self.assertEqual(sorted(keys), keys)
@@ -1368,7 +1452,8 @@ class EncoderTest(unittest.TestCase):
data = fbb.Finish()
self.assertEqual(
flexbuffers.Loads(data), {
flexbuffers.Loads(data),
{
'n': None,
'b': False,
'i': -27,
@@ -1381,8 +1466,9 @@ class EncoderTest(unittest.TestCase):
'if': 0.0,
'v': [2, 1, 0.0],
'tv': [2, 1, 0],
'ftv': [2.0, -6.0]
})
'ftv': [2.0, -6.0],
},
)
keys = get_keys(data)
self.assertEqual(sorted(keys), keys)
@@ -1390,19 +1476,9 @@ class EncoderTest(unittest.TestCase):
def test_map_python(self):
maps = [
{},
{
'key': 'value'
},
{
'x': None,
'y': 3400,
'z': -7040
},
{
'zzz': 100,
'aaa': 5.0,
'ccc': ['Test', 32, False, None, True]
},
{'key': 'value'},
{'x': None, 'y': 3400, 'z': -7040},
{'zzz': 100, 'aaa': 5.0, 'ccc': ['Test', 32, False, None, True]},
{
'name': ['John', 'Smith'],
'valid': True,

File diff suppressed because it is too large Load Diff

View File

@@ -2,14 +2,16 @@
#define TESTS_REFLECTION_TEST_H
#include <stdint.h>
#include <string>
namespace flatbuffers {
namespace tests {
void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length);
void ReflectionTest(const std::string& tests_data_path, uint8_t* flatbuf,
size_t length);
void MiniReflectFixedLengthArrayTest();
void MiniReflectFlatBuffersTest(uint8_t *flatbuf);
void MiniReflectFlatBuffersTest(uint8_t* flatbuf);
} // namespace tests
} // namespace flatbuffers

View File

@@ -109,10 +109,7 @@ fn test_schema_correct_file() {
#[test]
fn test_schema_correct_table_field() {
let schema_buffer = load_file_as_buffer("../monster_test.bfbs");
let root_table = root_as_schema(schema_buffer.as_slice())
.unwrap()
.root_table()
.unwrap();
let root_table = root_as_schema(schema_buffer.as_slice()).unwrap().root_table().unwrap();
let fields = root_table.fields();
@@ -132,18 +129,14 @@ fn test_schema_correct_table_field() {
.unwrap()
.attributes()
.unwrap()
.lookup_by_key("priority", |key_value, key| key_value
.key_compare_with_value(key))
.lookup_by_key("priority", |key_value, key| key_value.key_compare_with_value(key))
.is_some());
}
#[test]
fn test_schema_correct_table_field_nullability() {
let schema_buffer = load_file_as_buffer("../monster_test.bfbs");
let root_table = root_as_schema(schema_buffer.as_slice())
.unwrap()
.root_table()
.unwrap();
let root_table = root_as_schema(schema_buffer.as_slice()).unwrap().root_table().unwrap();
let fields = root_table.fields();
@@ -375,9 +368,7 @@ fn test_buffer_table_same_type_succeeds() {
.get(table_field.type_().index() as usize)
.fields();
let nested_table_field = nested_table_fields
.lookup_by_key("id", |field: &Field<'_>, key| {
field.key_compare_with_value(key)
})
.lookup_by_key("id", |field: &Field<'_>, key| field.key_compare_with_value(key))
.unwrap();
let nested_table_id = unsafe { get_field_string(&nested_table, &nested_table_field) };
assert!(nested_table_id.is_ok());
@@ -406,11 +397,7 @@ fn test_buffer_nested_struct_same_type_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -434,11 +421,7 @@ fn test_buffer_nested_struct_diff_type_fails() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -591,11 +574,7 @@ fn test_buffer_i16_as_string_succeeds() {
let i16_field = get_schema_field(&schema, "hp");
let value = unsafe {
get_any_field_string(
&root_table,
&i16_field,
&root_as_schema(schema.as_slice()).unwrap(),
)
get_any_field_string(&root_table, &i16_field, &root_as_schema(schema.as_slice()).unwrap())
};
assert_eq!(value, String::from("32767"));
@@ -609,11 +588,7 @@ fn test_buffer_f32_as_string_succeeds() {
let f32_field = get_schema_field(&schema, "testf");
let mut value = unsafe {
get_any_field_string(
&root_table,
&f32_field,
&root_as_schema(schema.as_slice()).unwrap(),
)
get_any_field_string(&root_table, &f32_field, &root_as_schema(schema.as_slice()).unwrap())
};
value.truncate(4);
@@ -644,11 +619,7 @@ fn test_buffer_i16_in_struct_as_integer_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -680,11 +651,7 @@ fn test_buffer_f32_in_struct_as_integer_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -706,11 +673,7 @@ fn test_buffer_enum_in_struct_as_integer_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -732,11 +695,7 @@ fn test_buffer_struct_in_struct_as_integer_fails() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -761,11 +720,7 @@ fn test_buffer_i16_in_struct_as_float_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -797,11 +752,7 @@ fn test_buffer_f32_in_struct_as_float_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -823,11 +774,7 @@ fn test_buffer_enum_in_struct_as_float_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -849,11 +796,7 @@ fn test_buffer_struct_in_struct_as_float_fails() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -878,11 +821,7 @@ fn test_buffer_i16_in_struct_as_string_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -919,11 +858,7 @@ fn test_buffer_f32_in_struct_as_string_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -950,11 +885,7 @@ fn test_buffer_enum_in_struct_as_string_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -981,11 +912,7 @@ fn test_buffer_struct_in_struct_as_string_succeeds() {
let root_table = unsafe { get_any_root(&buffer) };
let schema = load_file_as_buffer("../monster_test.bfbs");
let struct_field = get_schema_field(&schema, "pos");
let struct_value = unsafe {
get_field_struct(&root_table, &struct_field)
.unwrap()
.unwrap()
};
let struct_value = unsafe { get_field_struct(&root_table, &struct_field).unwrap().unwrap() };
let struct_schema = root_as_schema(schema.as_slice())
.unwrap()
.objects()
@@ -1371,10 +1298,7 @@ fn test_buffer_set_string_bigger_size_succeeds() {
let updated_table = unsafe { get_any_root(&buffer) };
let updated_value = unsafe { get_field_string(&updated_table, &string_field) };
assert!(updated_value.is_ok());
assert_eq!(
updated_value.unwrap(),
Some("AStringWithSlightlyBiggerSize")
);
assert_eq!(updated_value.unwrap(), Some("AStringWithSlightlyBiggerSize"));
}
#[test]
@@ -1441,10 +1365,7 @@ fn test_create_safe_buffer_limit_max_depth_fails() {
let buffer = create_test_buffer();
let schema_buffer = load_file_as_buffer("../monster_test.bfbs");
let schema = root_as_schema(schema_buffer.as_slice()).unwrap();
let verify_options = VerifierOptions {
max_depth: 1,
..Default::default()
};
let verify_options = VerifierOptions { max_depth: 1, ..Default::default() };
let safe_buffer = SafeBuffer::new_with_options(&buffer, &schema, &verify_options);
@@ -1457,10 +1378,7 @@ fn test_create_safe_buffer_limit_max_table_fails() {
let buffer = create_test_buffer();
let schema_buffer = load_file_as_buffer("../monster_test.bfbs");
let schema = root_as_schema(schema_buffer.as_slice()).unwrap();
let verify_options = VerifierOptions {
max_tables: 1,
..Default::default()
};
let verify_options = VerifierOptions { max_tables: 1, ..Default::default() };
let safe_buffer = SafeBuffer::new_with_options(&buffer, &schema, &verify_options);
@@ -1473,10 +1391,7 @@ fn test_create_safe_buffer_limit_max_size_fails() {
let buffer = create_test_buffer();
let schema_buffer = load_file_as_buffer("../monster_test.bfbs");
let schema = root_as_schema(schema_buffer.as_slice()).unwrap();
let verify_options = VerifierOptions {
max_apparent_size: 1 << 6,
..Default::default()
};
let verify_options = VerifierOptions { max_apparent_size: 1 << 6, ..Default::default() };
let safe_buffer = SafeBuffer::new_with_options(&buffer, &schema, &verify_options);
@@ -2073,9 +1988,7 @@ fn get_schema_field<'a>(schema_buffer: &'a Vec<u8>, field_name: &'a str) -> Fiel
let schema = root_as_schema(schema_buffer.as_slice()).unwrap();
let root_table = schema.root_table().unwrap();
let fields = root_table.fields();
fields
.lookup_by_key(field_name, |field, key| field.key_compare_with_value(key))
.unwrap()
fields.lookup_by_key(field_name, |field, key| field.key_compare_with_value(key)).unwrap()
}
fn create_test_buffer() -> Vec<u8> {
@@ -2105,18 +2018,12 @@ fn create_test_buffer() -> Vec<u8> {
test_type: my_game::example::Any::Monster,
testempty: Some(my_game::example::Stat::create(
&mut builder,
&my_game::example::StatArgs {
id: Some(fred_name),
..Default::default()
},
&my_game::example::StatArgs { id: Some(fred_name), ..Default::default() },
)),
test: Some(
my_game::example::Monster::create(
&mut builder,
&my_game::example::MonsterArgs {
name: Some(fred_name),
..Default::default()
},
&my_game::example::MonsterArgs { name: Some(fred_name), ..Default::default() },
)
.as_union_value(),
),

View File

@@ -29,10 +29,7 @@ fn create_serialized_example_with_generated_code(builder: &mut flatbuffers::Flat
test: Some(
my_game::example::Monster::create(
builder,
&my_game::example::MonsterArgs {
name: Some(fred_name),
..Default::default()
},
&my_game::example::MonsterArgs { name: Some(fred_name), ..Default::default() },
)
.as_union_value(),
),

View File

@@ -27,7 +27,4 @@ mod flexbuffers_benchmarks;
mod monster_test_generated;
pub use monster_test_generated::my_game;
benchmark_main!(
flatbuffers_benchmarks::benches,
flexbuffers_benchmarks::benches
);
benchmark_main!(flatbuffers_benchmarks::benches, flexbuffers_benchmarks::benches);

View File

@@ -63,25 +63,15 @@ fn create_serialized_example_with_generated_code(
let t2_name = builder.create_string("Wilma");
let t0 = my_game::example::Monster::create(
builder,
&my_game::example::MonsterArgs {
hp: 1000,
name: Some(t0_name),
..Default::default()
},
&my_game::example::MonsterArgs { hp: 1000, name: Some(t0_name), ..Default::default() },
);
let t1 = my_game::example::Monster::create(
builder,
&my_game::example::MonsterArgs {
name: Some(t1_name),
..Default::default()
},
&my_game::example::MonsterArgs { name: Some(t1_name), ..Default::default() },
);
let t2 = my_game::example::Monster::create(
builder,
&my_game::example::MonsterArgs {
name: Some(t2_name),
..Default::default()
},
&my_game::example::MonsterArgs { name: Some(t2_name), ..Default::default() },
);
let mon = {
let name = builder.create_string("MyMonster");
@@ -108,10 +98,7 @@ fn create_serialized_example_with_generated_code(
test: Some(
my_game::example::Monster::create(
builder,
&my_game::example::MonsterArgs {
name: Some(fred_name),
..Default::default()
},
&my_game::example::MonsterArgs { name: Some(fred_name), ..Default::default() },
)
.as_union_value(),
),

View File

@@ -3,7 +3,6 @@
// global variable).
use std::alloc::{GlobalAlloc, Layout, System};
static mut N_ALLOCS: usize = 0;
struct TrackingAllocator;
@@ -55,7 +54,7 @@ fn create_serialized_example_with_generated_code(builder: &mut flatbuffers::Flat
builder.create_string("check"),
builder.create_string("the"),
builder.create_string("create_vector_of_strings"),
builder.create_string("function")
builder.create_string("function"),
];
let _ = builder.create_vector(&strings);
@@ -83,12 +82,9 @@ fn create_serialized_example_with_generated_code(builder: &mut flatbuffers::Flat
test: Some(
my_game::example::Monster::create(
builder,
&my_game::example::MonsterArgs {
name: Some(fred_name),
..Default::default()
},
&my_game::example::MonsterArgs { name: Some(fred_name), ..Default::default() },
)
.as_union_value(),
.as_union_value(),
),
inventory: Some(builder.create_vector(&[0u8, 1, 2, 3, 4])),
test4: Some(builder.create_vector(&[
@@ -103,7 +99,7 @@ fn create_serialized_example_with_generated_code(builder: &mut flatbuffers::Flat
my_game::example::finish_monster_buffer(builder, mon);
}
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
fn main() {
// test the allocation tracking:
{

View File

@@ -107,7 +107,7 @@ fn validate_monster(flexbuffer: &[u8]) {
// This is in a separate binary than tests because taking over the global allocator is not
// hermetic and not thread safe.
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
fn main() {
let start_up = current_allocs();
@@ -138,7 +138,7 @@ fn main() {
}
#[test]
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
fn no_extra_allocations() {
main()
}

View File

@@ -1,7 +1,6 @@
#![allow(clippy::derivable_impls, clippy::all)]
extern crate flatbuffers;
#[allow(dead_code, unused_imports)]
#[path = "../../include_test1/mod.rs"]
pub mod include_test1_generated;

View File

@@ -7,15 +7,7 @@ use generated::my_game::sample::{Monster, MonsterArgs};
fn main() {
let mut fbb = flatbuffers::FlatBufferBuilder::new();
let name = Some(fbb.create_string("bob"));
let m = Monster::create(
&mut fbb,
&MonsterArgs {
hp: 1,
mana: 2,
name,
..Default::default()
},
);
let m = Monster::create(&mut fbb, &MonsterArgs { hp: 1, mana: 2, name, ..Default::default() });
fbb.finish(m, None);
let mon = flatbuffers::root::<Monster>(fbb.finished_data()).unwrap();
assert_eq!(mon.hp(), 1);

View File

@@ -44,12 +44,7 @@ fn create_serialized_example_with_generated_code(builder: &mut flatbuffers::Flat
&[-0x8000000000000000, 0x7FFFFFFFFFFFFFFF],
);
// Test five makes sense when specified.
let ss = ArrayTable::create(
builder,
&ArrayTableArgs {
a: Some(&array_struct),
},
);
let ss = ArrayTable::create(builder, &ArrayTableArgs { a: Some(&array_struct) });
finish_array_table_buffer(builder, ss);
}
@@ -102,10 +97,7 @@ fn serialized_example_is_accessible_and_correct(
assert_eq!(nested_struct2.c().get(1), TestEnum::A);
assert_eq!(nested_struct2.d().len(), 2);
let arr: [i64; 2] = nested_struct2.d().into();
assert_eq!(
arr,
[-0x1122334455667788, 0x1122334455667788]
);
assert_eq!(arr, [-0x1122334455667788, 0x1122334455667788]);
assert_eq!(array_struct.e(), 1);
assert_eq!(array_struct.f().len(), 2);
@@ -254,9 +246,11 @@ impl<T: Arbitrary + Debug + PartialEq, const N: usize> Arbitrary for FakeArray<T
let x: [T; N] = array_init(|_| {
loop {
let generated_scalar = T::arbitrary(g);
// Verify that generated scalar is not Nan, which is not equals to itself,
// Verify that generated scalar is not Nan, which is not equals to itself,
// therefore we can't use it to validate input == output
if generated_scalar == generated_scalar { return generated_scalar; }
if generated_scalar == generated_scalar {
return generated_scalar;
}
}
});
FakeArray { 0: x }
@@ -265,9 +259,9 @@ impl<T: Arbitrary + Debug + PartialEq, const N: usize> Arbitrary for FakeArray<T
#[cfg(test)]
mod array_fuzz {
#[cfg(not(miri))] // slow.
extern crate quickcheck;
extern crate flatbuffers;
#[cfg(not(miri))] // slow.
extern crate quickcheck;
use self::flatbuffers::{Follow, Push};
use super::*;
@@ -278,10 +272,10 @@ mod array_fuzz {
// This uses a macro because lifetimes for the trait-bounded function get too
// complicated.
macro_rules! impl_prop {
($test_name:ident, $fn_name:ident, $ty:ident) => (
($test_name:ident, $fn_name:ident, $ty:ident) => {
fn $fn_name(xs: FakeArray<$ty, ARRAY_SIZE>) {
let mut test_buf = [0 as u8; 1024];
let arr: flatbuffers::Array<$ty, ARRAY_SIZE> = unsafe {
let arr: flatbuffers::Array<$ty, ARRAY_SIZE> = unsafe {
flatbuffers::emplace_scalar_array(&mut test_buf, 0, &xs.0);
flatbuffers::Array::follow(&test_buf, 0)
};
@@ -289,10 +283,12 @@ mod array_fuzz {
assert_eq!(got, xs.0);
}
#[test]
fn $test_name() {
quickcheck::QuickCheck::new().max_tests(MAX_TESTS).quickcheck($fn_name as fn(FakeArray<$ty, ARRAY_SIZE>));
fn $test_name() {
quickcheck::QuickCheck::new()
.max_tests(MAX_TESTS)
.quickcheck($fn_name as fn(FakeArray<$ty, ARRAY_SIZE>));
}
)
};
}
impl_prop!(test_bool, prop_bool, bool);
@@ -322,19 +318,25 @@ mod array_fuzz {
fn prop_struct(xs: FakeArray<NestedStructWrapper, ARRAY_SIZE>) {
let mut test_buf = [0 as u8; 1024];
let native_struct_array: [&NestedStruct; ARRAY_SIZE] = array_init::from_iter(xs.0.iter().map(|x| &x.0)).unwrap();
let native_struct_array: [&NestedStruct; ARRAY_SIZE] =
array_init::from_iter(xs.0.iter().map(|x| &x.0)).unwrap();
for i in 0..ARRAY_SIZE {
let offset = i * NESTED_STRUCT_SIZE;
unsafe { native_struct_array[i].push(&mut test_buf[offset..offset + NESTED_STRUCT_SIZE], 0) };
unsafe {
native_struct_array[i].push(&mut test_buf[offset..offset + NESTED_STRUCT_SIZE], 0)
};
}
let arr: flatbuffers::Array<NestedStruct, ARRAY_SIZE> = unsafe { flatbuffers::Array::follow(&test_buf, 0) };
let arr: flatbuffers::Array<NestedStruct, ARRAY_SIZE> =
unsafe { flatbuffers::Array::follow(&test_buf, 0) };
let got: [&NestedStruct; ARRAY_SIZE] = arr.into();
assert_eq!(got, native_struct_array);
}
#[test]
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
fn test_struct() {
quickcheck::QuickCheck::new().max_tests(MAX_TESTS).quickcheck(prop_struct as fn(FakeArray<NestedStructWrapper, ARRAY_SIZE>));
quickcheck::QuickCheck::new()
.max_tests(MAX_TESTS)
.quickcheck(prop_struct as fn(FakeArray<NestedStructWrapper, ARRAY_SIZE>));
}
}

View File

@@ -108,7 +108,7 @@ fn store_vec_uint_16() {
);
}
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
quickcheck! {
fn qc_f32(x: f32) -> bool {
let fxb = singleton(x);

View File

@@ -16,6 +16,6 @@ mod binary_format;
#[cfg(not(feature = "no_std"))] // uses file I/O
mod interop;
mod other_api;
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
mod qc_serious;
mod rwyw;

View File

@@ -15,11 +15,11 @@
use alloc::vec::Vec;
use flexbuffers::*;
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
use quickcheck::QuickCheck;
#[test]
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
fn qc_reader_no_crash() {
fn no_crash(xs: Vec<u8>) -> bool {
let r = Reader::get_root(xs.as_ref());
@@ -165,12 +165,7 @@ fn get_root_deref_oob() {
}
#[test]
fn get_root_deref_u64() {
let s = &[
0,
0,
(FlexBufferType::IndirectUInt as u8) << 2 | BitWidth::W64 as u8,
1,
];
let s = &[0, 0, (FlexBufferType::IndirectUInt as u8) << 2 | BitWidth::W64 as u8, 1];
// The risk of crashing is reading 8 bytes from index 0.
assert_eq!(Reader::get_root(s.as_ref()).unwrap().as_u64(), 0);
}

View File

@@ -25,11 +25,7 @@ enum Enum {
String(String),
Strings(String, String),
Everything(u8, u16, u32, u64, i8, i16, i32, i64, f32, f64, String),
Arrays {
a: Array3<u16>,
b: Array4<i32>,
c: Array2<f64>,
},
Arrays { a: Array3<u16>, b: Array4<i32>, c: Array2<f64> },
Blobs(#[serde(with = "serde_bytes")] Vec<u8>),
}
@@ -126,12 +122,7 @@ impl<A: Arbitrary> Arbitrary for Array3<A> {
}
impl<A: Arbitrary> Arbitrary for Array4<A> {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
Array4([
A::arbitrary(g),
A::arbitrary(g),
A::arbitrary(g),
A::arbitrary(g),
])
Array4([A::arbitrary(g), A::arbitrary(g), A::arbitrary(g), A::arbitrary(g)])
}
}

View File

@@ -17,7 +17,7 @@ use alloc::vec::Vec;
// Read what you wrote.
use flexbuffers::*;
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
use quickcheck;
use serde::{Deserialize, Serialize};
@@ -28,16 +28,12 @@ impl quickcheck::Arbitrary for NonNullString {
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
let size = core::cmp::min(1, usize::arbitrary(g));
NonNullString(
(0..)
.map(|_| <char>::arbitrary(g))
.filter(|&b| b != '\0')
.take(size)
.collect(),
(0..).map(|_| <char>::arbitrary(g)).filter(|&b| b != '\0').take(size).collect(),
)
}
}
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
quickcheck! {
fn qc_vec_bool(xs: Vec<bool>) -> bool {
let mut builder = Builder::default();
@@ -371,7 +367,7 @@ struct Foo {
d: String,
}
#[cfg(not(miri))] // slow.
#[cfg(not(miri))] // slow.
quickcheck! {
fn serde_foo(a: i8,
b: f64,
@@ -415,22 +411,13 @@ fn serde_serious() {
let data = MyTupleStruct(
MyNewType,
MyUnitStruct(vec!["Hello".to_string(), "World".to_string()]),
MyStruct {
a: 2,
b: 4,
c: 8,
d: 16,
},
MyStruct { a: 2, b: 4, c: 8, d: 16 },
vec![
MyEnum::Unit,
MyEnum::NewType([-1, 0, 1]),
MyEnum::Unit,
MyEnum::Tuple(3.14, 2.71),
MyEnum::Struct {
a: 32,
b: 64,
c: 128,
},
MyEnum::Struct { a: 32, b: 64, c: 128 },
],
);

View File

@@ -59,41 +59,17 @@ make_test!(optional_i32, just_i32, default_i32, maybe_i32, 5, 0, 42);
make_test!(optional_u32, just_u32, default_u32, maybe_u32, 5, 0, 42);
make_test!(optional_i64, just_i64, default_i64, maybe_i64, 5, 0, 42);
make_test!(optional_u64, just_u64, default_u64, maybe_u64, 5, 0, 42);
make_test!(optional_f32, just_f32, default_f32, maybe_f32, 5.0, 0.0, 42.0);
make_test!(optional_f64, just_f64, default_f64, maybe_f64, 5.0, 0.0, 42.0);
make_test!(optional_bool, just_bool, default_bool, maybe_bool, true, false, true);
make_test!(
optional_f32,
just_f32,
default_f32,
maybe_f32,
5.0,
0.0,
42.0
);
make_test!(
optional_f64,
just_f64,
default_f64,
maybe_f64,
5.0,
0.0,
42.0
);
make_test!(
optional_bool,
just_bool,
default_bool,
maybe_bool,
true,
false,
true
);
make_test!(
optional_enum,
just_enum,
default_enum,
maybe_enum,
OptionalByte::Two,
OptionalByte::None,
OptionalByte::One
optional_enum,
just_enum,
default_enum,
maybe_enum,
OptionalByte::Two,
OptionalByte::None,
OptionalByte::One
);
#[test]
@@ -143,7 +119,6 @@ fn object_api_defaults() {
just_enum: OptionalByte::None,
maybe_enum: None,
default_enum: OptionalByte::One,
}
);
}

View File

@@ -2,57 +2,61 @@
# namespace: example
import flatbuffers
from typing import Any
import flatbuffers
class HelloRequest(object):
__slots__ = ['_tab']
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset: int = 0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = HelloRequest()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAs(cls, buf, offset: int = 0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = HelloRequest()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsHelloRequest(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# HelloRequest
def Init(self, buf: bytes, pos: int):
self._tab = flatbuffers.table.Table(buf, pos)
@classmethod
def GetRootAsHelloRequest(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# HelloRequest
def Init(self, buf: bytes, pos: int):
self._tab = flatbuffers.table.Table(buf, pos)
def HelloRequestStart(builder: flatbuffers.Builder):
builder.StartObject(0)
builder.StartObject(0)
def HelloRequestEnd(builder: flatbuffers.Builder) -> int:
return builder.EndObject()
return builder.EndObject()
class HelloResponse(object):
__slots__ = ['_tab']
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset: int = 0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = HelloResponse()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAs(cls, buf, offset: int = 0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = HelloResponse()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsHelloResponse(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# HelloResponse
def Init(self, buf: bytes, pos: int):
self._tab = flatbuffers.table.Table(buf, pos)
@classmethod
def GetRootAsHelloResponse(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
# HelloResponse
def Init(self, buf: bytes, pos: int):
self._tab = flatbuffers.table.Table(buf, pos)
def HelloResponseStart(builder: flatbuffers.Builder):
builder.StartObject(0)
builder.StartObject(0)
def HelloResponseEnd(builder: flatbuffers.Builder) -> int:
return builder.EndObject()
return builder.EndObject()

View File

@@ -2,7 +2,6 @@
import flatbuffers
import grpc
from service_test_generated import HelloRequest, HelloResponse
@@ -15,38 +14,42 @@ def _serialize_to_bytes(table):
class HelloServiceStub(object):
'''Interface exported by the server.'''
"""Interface exported by the server."""
def __init__(self, channel):
'''Constructor.
"""Constructor.
Args:
channel: A grpc.Channel.
'''
"""
self.Hello = channel.unary_unary(
method='/example.HelloService/Hello',
request_serializer=_serialize_to_bytes,
response_deserializer=HelloResponse.GetRootAs)
method='/example.HelloService/Hello',
request_serializer=_serialize_to_bytes,
response_deserializer=HelloResponse.GetRootAs,
)
self.StreamClient = channel.stream_unary(
method='/example.HelloService/StreamClient',
request_serializer=_serialize_to_bytes,
response_deserializer=HelloResponse.GetRootAs)
method='/example.HelloService/StreamClient',
request_serializer=_serialize_to_bytes,
response_deserializer=HelloResponse.GetRootAs,
)
self.StreamServer = channel.unary_stream(
method='/example.HelloService/StreamServer',
request_serializer=_serialize_to_bytes,
response_deserializer=HelloResponse.GetRootAs)
method='/example.HelloService/StreamServer',
request_serializer=_serialize_to_bytes,
response_deserializer=HelloResponse.GetRootAs,
)
self.Stream = channel.stream_stream(
method='/example.HelloService/Stream',
request_serializer=_serialize_to_bytes,
response_deserializer=HelloResponse.GetRootAs)
method='/example.HelloService/Stream',
request_serializer=_serialize_to_bytes,
response_deserializer=HelloResponse.GetRootAs,
)
class HelloServiceServicer(object):
'''Interface exported by the server.'''
"""Interface exported by the server."""
def Hello(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -71,27 +74,30 @@ class HelloServiceServicer(object):
def add_HelloServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'Hello': grpc.unary_unary_rpc_method_handler(
servicer.Hello,
request_deserializer=HelloRequest.GetRootAs,
response_serializer=_serialize_to_bytes),
'StreamClient': grpc.stream_unary_rpc_method_handler(
servicer.StreamClient,
request_deserializer=HelloRequest.GetRootAs,
response_serializer=_serialize_to_bytes),
'StreamServer': grpc.unary_stream_rpc_method_handler(
servicer.StreamServer,
request_deserializer=HelloRequest.GetRootAs,
response_serializer=_serialize_to_bytes),
'Stream': grpc.stream_stream_rpc_method_handler(
servicer.Stream,
request_deserializer=HelloRequest.GetRootAs,
response_serializer=_serialize_to_bytes),
'Hello': grpc.unary_unary_rpc_method_handler(
servicer.Hello,
request_deserializer=HelloRequest.GetRootAs,
response_serializer=_serialize_to_bytes,
),
'StreamClient': grpc.stream_unary_rpc_method_handler(
servicer.StreamClient,
request_deserializer=HelloRequest.GetRootAs,
response_serializer=_serialize_to_bytes,
),
'StreamServer': grpc.unary_stream_rpc_method_handler(
servicer.StreamServer,
request_deserializer=HelloRequest.GetRootAs,
response_serializer=_serialize_to_bytes,
),
'Stream': grpc.stream_stream_rpc_method_handler(
servicer.Stream,
request_deserializer=HelloRequest.GetRootAs,
response_serializer=_serialize_to_bytes,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'example.HelloService', rpc_method_handlers)
'example.HelloService', rpc_method_handlers
)
server.add_generic_rpc_handlers((generic_handler,))

Some files were not shown because too many files have changed in this diff Show More