mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-21 00:07:32 +00:00
[JS] Add getFullyQualifiedName() (#6119)
This optionally generates a static `getFullyQualifiedName()` function to get the fully-qualified name of a type in JavaScript and TypeScript in a similar fashion to the C++ codegen.
This commit is contained in:
@@ -66,6 +66,9 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructInNestedNS FLATBUFFERS_FINAL_CLASS
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return StructInNestedNSTypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.NamespaceB.StructInNestedNS";
|
||||
}
|
||||
StructInNestedNS()
|
||||
: a_(0),
|
||||
b_(0) {
|
||||
@@ -102,6 +105,9 @@ inline bool operator!=(const StructInNestedNS &lhs, const StructInNestedNS &rhs)
|
||||
|
||||
struct TableInNestedNST : public flatbuffers::NativeTable {
|
||||
typedef TableInNestedNS TableType;
|
||||
static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.NamespaceB.TableInNestedNST";
|
||||
}
|
||||
int32_t foo;
|
||||
TableInNestedNST()
|
||||
: foo(0) {
|
||||
@@ -124,6 +130,9 @@ struct TableInNestedNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInNestedNSTypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.NamespaceB.TableInNestedNS";
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_FOO = 4
|
||||
};
|
||||
|
||||
@@ -98,6 +98,13 @@ NamespaceA.NamespaceB.TableInNestedNS.prototype.mutate_foo = function(value) {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
NamespaceA.NamespaceB.TableInNestedNS.getFullyQualifiedName = function() {
|
||||
return 'NamespaceA.NamespaceB.TableInNestedNS';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
@@ -191,6 +198,13 @@ NamespaceA.NamespaceB.StructInNestedNS.prototype.mutate_b = function(value) {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
NamespaceA.NamespaceB.StructInNestedNS.getFullyQualifiedName = function() {
|
||||
return 'NamespaceA.NamespaceB.StructInNestedNS';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} a
|
||||
|
||||
@@ -141,6 +141,10 @@ impl StructInNestedNS {
|
||||
|
||||
}
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.NamespaceB.StructInNestedNS"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> i32 {
|
||||
self.a_.from_little_endian()
|
||||
}
|
||||
@@ -165,6 +169,10 @@ impl<'a> flatbuffers::Follow<'a> for TableInNestedNS<'a> {
|
||||
}
|
||||
|
||||
impl<'a> TableInNestedNS<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.NamespaceB.TableInNestedNS"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableInNestedNS {
|
||||
|
||||
@@ -72,6 +72,13 @@ mutate_foo(value:number):boolean {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns string
|
||||
*/
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.NamespaceB.TableInNestedNS';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flatbuffers.Builder builder
|
||||
*/
|
||||
@@ -190,6 +197,13 @@ mutate_b(value:number):boolean {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns string
|
||||
*/
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.NamespaceB.StructInNestedNS';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flatbuffers.Builder builder
|
||||
* @param number a
|
||||
|
||||
@@ -59,6 +59,9 @@ inline const flatbuffers::TypeTable *SecondTableInATypeTable();
|
||||
|
||||
struct TableInFirstNST : public flatbuffers::NativeTable {
|
||||
typedef TableInFirstNS TableType;
|
||||
static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.TableInFirstNST";
|
||||
}
|
||||
flatbuffers::unique_ptr<NamespaceA::NamespaceB::TableInNestedNST> foo_table;
|
||||
NamespaceA::NamespaceB::EnumInNestedNS foo_enum;
|
||||
flatbuffers::unique_ptr<NamespaceA::NamespaceB::StructInNestedNS> foo_struct;
|
||||
@@ -85,6 +88,9 @@ struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInFirstNSTypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.TableInFirstNS";
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_FOO_TABLE = 4,
|
||||
VT_FOO_ENUM = 6,
|
||||
@@ -165,6 +171,9 @@ namespace NamespaceC {
|
||||
|
||||
struct TableInCT : public flatbuffers::NativeTable {
|
||||
typedef TableInC TableType;
|
||||
static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
|
||||
return "NamespaceC.TableInCT";
|
||||
}
|
||||
flatbuffers::unique_ptr<NamespaceA::TableInFirstNST> refer_to_a1;
|
||||
flatbuffers::unique_ptr<NamespaceA::SecondTableInAT> refer_to_a2;
|
||||
TableInCT() {
|
||||
@@ -188,6 +197,9 @@ struct TableInC FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return TableInCTypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
|
||||
return "NamespaceC.TableInC";
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_REFER_TO_A1 = 4,
|
||||
VT_REFER_TO_A2 = 6
|
||||
@@ -256,6 +268,9 @@ namespace NamespaceA {
|
||||
|
||||
struct SecondTableInAT : public flatbuffers::NativeTable {
|
||||
typedef SecondTableInA TableType;
|
||||
static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.SecondTableInAT";
|
||||
}
|
||||
flatbuffers::unique_ptr<NamespaceC::TableInCT> refer_to_c;
|
||||
SecondTableInAT() {
|
||||
}
|
||||
@@ -277,6 +292,9 @@ struct SecondTableInA FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return SecondTableInATypeTable();
|
||||
}
|
||||
static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
|
||||
return "NamespaceA.SecondTableInA";
|
||||
}
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_REFER_TO_C = 4
|
||||
};
|
||||
|
||||
@@ -104,6 +104,13 @@ NamespaceA.TableInFirstNS.prototype.fooStruct = function(obj) {
|
||||
return offset ? (obj || new NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
NamespaceA.TableInFirstNS.getFullyQualifiedName = function() {
|
||||
return 'NamespaceA.TableInFirstNS';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
@@ -207,6 +214,13 @@ NamespaceC.TableInC.prototype.referToA2 = function(obj) {
|
||||
return offset ? (obj || new NamespaceA.SecondTableInA).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
NamespaceC.TableInC.getFullyQualifiedName = function() {
|
||||
return 'NamespaceC.TableInC';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
@@ -293,6 +307,13 @@ NamespaceA.SecondTableInA.prototype.referToC = function(obj) {
|
||||
return offset ? (obj || new NamespaceC.TableInC).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
NamespaceA.SecondTableInA.getFullyQualifiedName = function() {
|
||||
return 'NamespaceA.SecondTableInA';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,10 @@ impl<'a> flatbuffers::Follow<'a> for TableInFirstNS<'a> {
|
||||
}
|
||||
|
||||
impl<'a> TableInFirstNS<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.TableInFirstNS"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableInFirstNS {
|
||||
@@ -133,6 +137,10 @@ impl<'a> flatbuffers::Follow<'a> for SecondTableInA<'a> {
|
||||
}
|
||||
|
||||
impl<'a> SecondTableInA<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.SecondTableInA"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
SecondTableInA {
|
||||
@@ -219,6 +227,10 @@ impl<'a> flatbuffers::Follow<'a> for TableInC<'a> {
|
||||
}
|
||||
|
||||
impl<'a> TableInC<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceC.TableInC"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableInC {
|
||||
|
||||
@@ -80,6 +80,13 @@ fooStruct(obj?:NS8755221360535654258.NamespaceA.NamespaceB.StructInNestedNS):NS8
|
||||
return offset ? (obj || new NS8755221360535654258.NamespaceA.NamespaceB.StructInNestedNS()).__init(this.bb_pos + offset, this.bb!) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns string
|
||||
*/
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.TableInFirstNS';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flatbuffers.Builder builder
|
||||
*/
|
||||
@@ -225,6 +232,13 @@ referToA2(obj?:NamespaceA.SecondTableInA):NamespaceA.SecondTableInA|null {
|
||||
return offset ? (obj || new NamespaceA.SecondTableInA()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns string
|
||||
*/
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceC.TableInC';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flatbuffers.Builder builder
|
||||
*/
|
||||
@@ -348,6 +362,13 @@ referToC(obj?:NamespaceC.TableInC):NamespaceC.TableInC|null {
|
||||
return offset ? (obj || new NamespaceC.TableInC()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns string
|
||||
*/
|
||||
static getFullyQualifiedName():string {
|
||||
return 'NamespaceA.SecondTableInA';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flatbuffers.Builder builder
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user