mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-26 07:22:39 +00:00
[typescript] Size-prefixed root accessors not taking into account size prefix (#5717)
* [typescript/javascript] Size-prefixed root accessor needs to account for the size prefix. * [typescript] Add parentheses after "new" expression. * Update generated test files
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
6da1cf79d9
commit
9cadf05d89
@@ -37,7 +37,7 @@ __init(i:number, bb:flatbuffers.ByteBuffer):Attacker {
|
||||
* @returns Attacker
|
||||
*/
|
||||
static getRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
|
||||
return (obj || new Attacker).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,8 @@ static getRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
|
||||
* @returns Attacker
|
||||
*/
|
||||
static getSizePrefixedRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
|
||||
return (obj || new Attacker).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -230,7 +231,7 @@ __init(i:number, bb:flatbuffers.ByteBuffer):Movie {
|
||||
* @returns Movie
|
||||
*/
|
||||
static getRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie {
|
||||
return (obj || new Movie).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -239,7 +240,8 @@ static getRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie {
|
||||
* @returns Movie
|
||||
*/
|
||||
static getSizePrefixedRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie {
|
||||
return (obj || new Movie).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user