mirror of
https://github.com/kwsch/pkNX.git
synced 2026-05-03 11:25:25 -05:00
* Manually translated/attributed fbs files. * Include fields in obj-as-table dump * Emit fields for json too. FlatSharp generates structs with fields rather than properties at fixed offsets (maybe I'm missing a setting) * Update .editorconfig to ignore generated code files (unsure if this actually works).
162 lines
5.0 KiB
Plaintext
162 lines
5.0 KiB
Plaintext
// The original file can be found at https://github.com/google/flatbuffers/blob/0a80646371179f8a7a5c1f42c31ee1d44dcf6709/reflection/reflection.fbs.
|
|
// The file was then adapted by FlatSharpDelta with revisions below:
|
|
// - In the table EnumVal, the field named "object" has been renamed to "_object". Without this change, FlatSharp won't generate valid C# code because "object" is a C# keyword.
|
|
// - Added the "fs_serializer" attribute to the "Schema" table. This is required in order for FlatSharp to generate a serializer.
|
|
// - Added the "fs_sortedVector" attribute to the "objects" and "enums" fields in the "Schema" table. This is to sort the objects/enums by name, which is what the FlatSharp compiler expects.
|
|
|
|
// 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 pkNX.Structures.FlatBuffers.Reflection;
|
|
|
|
attribute "fs_serializer";
|
|
attribute "fs_sortedVector";
|
|
|
|
// 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.
|
|
// If base_type == Vector && element == Union or UnionType.
|
|
fixed_length:uint16 = 0; // Only if base_type == Array.
|
|
/// The size (octets) of the `base_type` field.
|
|
base_size:uint = 4; // 4 Is a common size due to offsets being that size.
|
|
/// The size (octets) of the `element` field, if present.
|
|
element_size:uint = 0;
|
|
}
|
|
|
|
table KeyValue {
|
|
key:string (required, key);
|
|
value:string;
|
|
}
|
|
|
|
table EnumVal {
|
|
name:string (required);
|
|
value:long (key);
|
|
_object:Object (deprecated);
|
|
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];
|
|
/// File that this Enum is declared in.
|
|
declaration_file: 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;
|
|
/// Number of padding octets to always add after this field. Structs only.
|
|
padding:uint16 = 0;
|
|
}
|
|
|
|
table Object { // Used for both tables and structs.
|
|
name:string (required, key);
|
|
fields:[Field] (required, fs_sortedVector); // Sorted.
|
|
is_struct:bool = false;
|
|
minalign:int;
|
|
bytesize:int; // For structs.
|
|
attributes:[KeyValue];
|
|
documentation:[string];
|
|
/// File that this Object is declared in.
|
|
declaration_file: 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];
|
|
/// File that this Service is declared in.
|
|
declaration_file: string;
|
|
}
|
|
|
|
/// New schema language features that are not supported by old code generators.
|
|
enum AdvancedFeatures : ulong (bit_flags) {
|
|
AdvancedArrayFeatures,
|
|
AdvancedUnionFeatures,
|
|
OptionalScalars,
|
|
DefaultVectorsAndStrings,
|
|
}
|
|
|
|
/// File specific information.
|
|
/// Symbols declared within a file may be recovered by iterating over all
|
|
/// symbols and examining the `declaration_file` field.
|
|
table SchemaFile {
|
|
/// Filename, relative to project root.
|
|
filename:string (required, key);
|
|
/// Names of included files, relative to project root.
|
|
included_filenames:[string];
|
|
}
|
|
|
|
table Schema (fs_serializer) {
|
|
objects:[Object] (required, fs_sortedVector); // Sorted.
|
|
enums:[Enum] (required, fs_sortedVector); // Sorted.
|
|
file_ident:string;
|
|
file_ext:string;
|
|
root_table:Object;
|
|
services:[Service]; // Sorted.
|
|
advanced_features:AdvancedFeatures;
|
|
/// All the files used in this compilation. Files are relative to where
|
|
/// flatc was invoked.
|
|
fbs_files:[SchemaFile]; // Sorted.
|
|
}
|
|
|
|
root_type Schema;
|
|
|
|
file_identifier "BFBS";
|
|
file_extension "bfbs";
|