mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-14 08:26:59 +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:
@@ -342,6 +342,13 @@ MyGame.Example.Test.prototype.mutate_b = function(value) {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
MyGame.Example.Test.sizeOf = function() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} a
|
||||
@@ -573,6 +580,13 @@ MyGame.Example.Vec3.prototype.test3 = function(obj) {
|
||||
return (obj || new MyGame.Example.Test).__init(this.bb_pos + 26, this.bb);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
MyGame.Example.Vec3.sizeOf = function() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} x
|
||||
@@ -659,6 +673,13 @@ MyGame.Example.Ability.prototype.mutate_distance = function(value) {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
MyGame.Example.Ability.sizeOf = function() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} id
|
||||
|
||||
Reference in New Issue
Block a user