mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-17 17:56:31 +00:00
[Python/JS/TS] Codegen SizeOf method for structs (#6136)
* [Python] Codegen SizeOf classmethod for structs This codegens a `SizeOf()` classmethod for all structs since we can't determine the size of a FlatBuffer generated struct from Python otherwise. * [JS/TS] Codegen sizeOf static method for structs This codegens a `sizeOf()` static method for all structs since we can't determine the size of a FlatBuffer generated struct from JavaScript or TypeScript otherwise.
This commit is contained in:
@@ -376,6 +376,13 @@ mutate_b(value:number):boolean {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns number
|
||||
*/
|
||||
static sizeOf():number {
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flatbuffers.Builder builder
|
||||
* @param number a
|
||||
@@ -668,6 +675,13 @@ test3(obj?:MyGame.Example.Test):MyGame.Example.Test|null {
|
||||
return (obj || new MyGame.Example.Test()).__init(this.bb_pos + 26, this.bb!);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns number
|
||||
*/
|
||||
static sizeOf():number {
|
||||
return 32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flatbuffers.Builder builder
|
||||
* @param number x
|
||||
@@ -811,6 +825,13 @@ mutate_distance(value:number):boolean {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns number
|
||||
*/
|
||||
static sizeOf():number {
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flatbuffers.Builder builder
|
||||
* @param number id
|
||||
|
||||
Reference in New Issue
Block a user