aboutsummaryrefslogtreecommitdiff
path: root/flatcc/reflection
diff options
context:
space:
mode:
Diffstat (limited to 'flatcc/reflection')
-rw-r--r--flatcc/reflection/README.in19
-rwxr-xr-xflatcc/reflection/generate_code.sh13
-rw-r--r--flatcc/reflection/reflection.fbs117
3 files changed, 149 insertions, 0 deletions
diff --git a/flatcc/reflection/README.in b/flatcc/reflection/README.in
new file mode 100644
index 0000000..3c7207a
--- /dev/null
+++ b/flatcc/reflection/README.in
@@ -0,0 +1,19 @@
+Generated by flatcc
+
+Keep checked in - needed by flatcc to generate binary schema.
+
+NOTE TO CONTRIBUTORS: DO NOT EDIT THESE FILES BY HAND
+
+If you need to change anything here, it is done in the code generator,
+possibly followed by running `reflection/generate_code.sh` from the
+project root. But please only do this for testing do not include the
+generated files in a pull request unless agreed otherwise, and if so,
+do it in a separate commit.
+
+Normally new reflection code is generated during a release which also
+updates the version number in comments and there is no reason to update
+reflection on every commit unless it breaks something fundamentally.
+
+There is a build option `FLATCC_REFLECTION` to disable reflection which
+is helpful while making changes that affect the content of these files
+in a way that would prevent the flatcc compiler from building.
diff --git a/flatcc/reflection/generate_code.sh b/flatcc/reflection/generate_code.sh
new file mode 100755
index 0000000..ce88aaf
--- /dev/null
+++ b/flatcc/reflection/generate_code.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+# Regnerate reflection API
+#
+# The output should be checked in with the project since it is
+# a bootstrapping process.
+
+cd `dirname $0`
+../scripts/build.sh
+RPATH=../include/flatcc/reflection
+mkdir -p ${RPATH}
+../bin/flatcc -a -o ../include/flatcc/reflection reflection.fbs
+cp README.in ${RPATH}/README
diff --git a/flatcc/reflection/reflection.fbs b/flatcc/reflection/reflection.fbs
new file mode 100644
index 0000000..d9e2dc4
--- /dev/null
+++ b/flatcc/reflection/reflection.fbs
@@ -0,0 +1,117 @@
+// This schema defines objects that represent a parsed schema, like
+// the binary version of a .fbs file.
+// This could be used to operate on unknown FlatBuffers at runtime.
+// It can even ... represent itself (!)
+
+namespace reflection;
+
+// These must correspond to the enum in idl.h.
+enum BaseType : byte {
+ None,
+ UType,
+ Bool,
+ Byte,
+ UByte,
+ Short,
+ UShort,
+ Int,
+ UInt,
+ Long,
+ ULong,
+ Float,
+ Double,
+ String,
+ Vector,
+ Obj, // Used for tables & structs.
+ Union,
+ Array,
+
+ // Add any new type above this value.
+ MaxBaseType
+}
+
+table Type {
+ base_type:BaseType;
+ element:BaseType = None; // Only if base_type == Vector
+ // or base_type == Array.
+ index:int = -1; // If base_type == Object, index into "objects" below.
+ // If base_type == Union, UnionType, or integral derived
+ // from an enum, index into "enums" below.
+ fixed_length:uint16 = 0; // Only if base_type == Array.
+}
+
+table KeyValue {
+ key:string (required, key);
+ value:string;
+}
+
+table EnumVal {
+ name:string (required);
+ value:long (key);
+ object:Object; // Will be deprecated in favor of union_type in the future.
+ union_type:Type;
+ documentation:[string];
+}
+
+table Enum {
+ name:string (required, key);
+ values:[EnumVal] (required); // In order of their values.
+ is_union:bool = false;
+ underlying_type:Type (required);
+ attributes:[KeyValue];
+ documentation:[string];
+}
+
+table Field {
+ name:string (required, key);
+ type:Type (required);
+ id:ushort;
+ offset:ushort; // Offset into the vtable for tables, or into the struct.
+ default_integer:long = 0;
+ default_real:double = 0.0;
+ deprecated:bool = false;
+ required:bool = false;
+ key:bool = false;
+ attributes:[KeyValue];
+ documentation:[string];
+ optional:bool = false;
+}
+
+table Object { // Used for both tables and structs.
+ name:string (required, key);
+ fields:[Field] (required); // Sorted.
+ is_struct:bool = false;
+ minalign:int;
+ bytesize:int; // For structs.
+ attributes:[KeyValue];
+ documentation:[string];
+}
+
+table RPCCall {
+ name:string (required, key);
+ request:Object (required); // must be a table (not a struct)
+ response:Object (required); // must be a table (not a struct)
+ attributes:[KeyValue];
+ documentation:[string];
+}
+
+table Service {
+ name:string (required, key);
+ calls:[RPCCall];
+ attributes:[KeyValue];
+ documentation:[string];
+}
+
+table Schema {
+ objects:[Object] (required); // Sorted.
+ enums:[Enum] (required); // Sorted.
+ file_ident:string;
+ file_ext:string;
+ root_table:Object;
+ services:[Service]; // Sorted.
+}
+
+root_type Schema;
+
+file_identifier "BFBS";
+file_extension "bfbs";