[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:
Anass Al
2020-09-28 08:54:50 -07:00
committed by GitHub
parent 641309a5bf
commit 689bfafa7e
14 changed files with 133 additions and 0 deletions

View File

@@ -185,6 +185,13 @@ Rapunzel.getFullyQualifiedName = function() {
return 'Rapunzel';
}
/**
* @returns {number}
*/
Rapunzel.sizeOf = function() {
return 4;
}
/**
* @param {flatbuffers.Builder} builder
* @param {number} hair_length
@@ -245,6 +252,13 @@ BookReader.getFullyQualifiedName = function() {
return 'BookReader';
}
/**
* @returns {number}
*/
BookReader.sizeOf = function() {
return 4;
}
/**
* @param {flatbuffers.Builder} builder
* @param {number} books_read