Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
c9b9fd04
Commit
c9b9fd04
authored
Jul 29, 2016
by
Wouter van Oortmerssen
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'mbp/mutable-js' into ghfix
parents
6897bb99
d268d11c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
487 additions
and
3 deletions
+487
-3
idl_gen_js.cpp
src/idl_gen_js.cpp
+18
-2
JavaScriptTest.js
tests/JavaScriptTest.js
+19
-1
monster_test_generated.js
tests/monster_test_generated.js
+390
-0
namespace_test1_generated.js
tests/namespace_test/namespace_test1_generated.js
+45
-0
namespace_test2_generated.js
tests/namespace_test/namespace_test2_generated.js
+15
-0
No files found.
src/idl_gen_js.cpp
View file @
c9b9fd04
...
...
@@ -79,7 +79,7 @@ class JsGenerator : public BaseGenerator {
for
(
auto
it
=
parser_
.
structs_
.
vec
.
begin
();
it
!=
parser_
.
structs_
.
vec
.
end
();
++
it
)
{
auto
&
struct_def
=
**
it
;
GenStruct
(
struct_def
,
decl_code_ptr
,
exports_code_ptr
);
GenStruct
(
parser_
,
struct_def
,
decl_code_ptr
,
exports_code_ptr
);
}
}
void
GenNamespaces
(
std
::
string
*
code_ptr
,
std
::
string
*
exports_ptr
)
{
...
...
@@ -361,7 +361,7 @@ static void GenStructBody(const StructDef &struct_def,
}
// Generate an accessor struct with constructor for a flatbuffers struct.
void
GenStruct
(
StructDef
&
struct_def
,
std
::
string
*
code_ptr
,
std
::
string
*
exports_ptr
)
{
void
GenStruct
(
const
Parser
&
parser
,
StructDef
&
struct_def
,
std
::
string
*
code_ptr
,
std
::
string
*
exports_ptr
)
{
if
(
struct_def
.
generated
)
return
;
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
exports
=
*
exports_ptr
;
...
...
@@ -550,6 +550,22 @@ void GenStruct(StructDef &struct_def, std::string *code_ptr, std::string *export
}
code
+=
"};
\n\n
"
;
// Adds the mutable scalar value to the output
if
(
IsScalar
(
field
.
value
.
type
.
base_type
)
&&
parser
.
opts
.
mutable_buffer
)
{
std
::
string
annotations
=
"@param {"
+
GenTypeName
(
field
.
value
.
type
,
true
)
+
"} value
\n
"
;
GenDocComment
(
code_ptr
,
annotations
+
"@returns {boolean}"
);
code
+=
object_name
+
".prototype.mutate_"
+
field
.
name
+
" = function(value) {
\n
"
;
code
+=
" var offset = this.bb.__offset(this.bb_pos, "
+
NumToString
(
field
.
value
.
offset
)
+
")
\n\n
"
;
code
+=
" if (offset === 0) {
\n
"
;
code
+=
" return false;
\n
"
;
code
+=
" }
\n\n
"
;
code
+=
" this.bb.write"
+
MakeCamel
(
GenType
(
field
.
value
.
type
))
+
"(this.bb_pos + offset, value);
\n
"
;
code
+=
" return true;
\n
"
;
code
+=
"}
\n\n
"
;
}
// Emit vector helpers
if
(
field
.
value
.
type
.
base_type
==
BASE_TYPE_VECTOR
)
{
// Emit a length helper
...
...
tests/JavaScriptTest.js
View file @
c9b9fd04
...
...
@@ -64,7 +64,10 @@ function main() {
fs
.
writeFileSync
(
'monsterdata_javascript_wire.mon'
,
new
Buffer
(
fbb
.
asUint8Array
()));
// Test it:
// Tests mutation first. This will verify that we did not trample any other
// part of the byte buffer.
testMutation
(
fbb
.
dataBuffer
());
testBuffer
(
fbb
.
dataBuffer
());
test64bit
();
...
...
@@ -74,6 +77,21 @@ function main() {
console
.
log
(
'FlatBuffers test: completed successfully'
);
}
function
testMutation
(
bb
)
{
var
monster
=
MyGame
.
Example
.
Monster
.
getRootAsMonster
(
bb
);
monster
.
mutate_hp
(
120
);
assert
.
strictEqual
(
monster
.
hp
(),
120
);
monster
.
mutate_hp
(
80
);
assert
.
strictEqual
(
monster
.
hp
(),
80
);
var
manaRes
=
monster
.
mutate_mana
(
10
);
assert
.
strictEqual
(
manaRes
,
false
);
// Field was NOT present, because default value.
// TODO: There is not the availability to mutate structs or vectors.
}
function
testBuffer
(
bb
)
{
assert
.
ok
(
MyGame
.
Example
.
Monster
.
bufferHasIdentifier
(
bb
));
...
...
tests/monster_test_generated.js
View file @
c9b9fd04
...
...
@@ -127,6 +127,21 @@ MyGame.Example.Test.prototype.a = function() {
return
this
.
bb
.
readInt16
(
this
.
bb_pos
);
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Test
.
prototype
.
mutate_a
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
0
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt16
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -134,6 +149,21 @@ MyGame.Example.Test.prototype.b = function() {
return
this
.
bb
.
readInt8
(
this
.
bb_pos
+
2
);
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Test
.
prototype
.
mutate_b
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
2
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt8
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {flatbuffers.Builder} builder
* @param {number} a
...
...
@@ -191,6 +221,21 @@ MyGame.Example.TestSimpleTableWithEnum.prototype.color = function() {
return
offset
?
/** @type {MyGame.Example.Color} */
(
this
.
bb
.
readInt8
(
this
.
bb_pos
+
offset
))
:
MyGame
.
Example
.
Color
.
Green
;
};
/**
* @param {MyGame.Example.Color} value
* @returns {boolean}
*/
MyGame
.
Example
.
TestSimpleTableWithEnum
.
prototype
.
mutate_color
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
4
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt8
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {flatbuffers.Builder} builder
*/
...
...
@@ -248,6 +293,21 @@ MyGame.Example.Vec3.prototype.x = function() {
return
this
.
bb
.
readFloat32
(
this
.
bb_pos
);
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Vec3
.
prototype
.
mutate_x
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
0
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeFloat32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -255,6 +315,21 @@ MyGame.Example.Vec3.prototype.y = function() {
return
this
.
bb
.
readFloat32
(
this
.
bb_pos
+
4
);
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Vec3
.
prototype
.
mutate_y
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
4
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeFloat32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -262,6 +337,21 @@ MyGame.Example.Vec3.prototype.z = function() {
return
this
.
bb
.
readFloat32
(
this
.
bb_pos
+
8
);
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Vec3
.
prototype
.
mutate_z
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
8
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeFloat32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -269,6 +359,21 @@ MyGame.Example.Vec3.prototype.test1 = function() {
return
this
.
bb
.
readFloat64
(
this
.
bb_pos
+
16
);
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Vec3
.
prototype
.
mutate_test1
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
16
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeFloat64
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {MyGame.Example.Color}
*/
...
...
@@ -276,6 +381,21 @@ MyGame.Example.Vec3.prototype.test2 = function() {
return
/** @type {MyGame.Example.Color} */
(
this
.
bb
.
readInt8
(
this
.
bb_pos
+
24
));
};
/**
* @param {MyGame.Example.Color} value
* @returns {boolean}
*/
MyGame
.
Example
.
Vec3
.
prototype
.
mutate_test2
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
24
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt8
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {MyGame.Example.Test=} obj
* @returns {MyGame.Example.Test}
...
...
@@ -364,6 +484,21 @@ MyGame.Example.Stat.prototype.val = function() {
return
offset
?
this
.
bb
.
readInt64
(
this
.
bb_pos
+
offset
)
:
this
.
bb
.
createLong
(
0
,
0
);
};
/**
* @param {flatbuffers.Long} value
* @returns {boolean}
*/
MyGame
.
Example
.
Stat
.
prototype
.
mutate_val
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
6
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt64
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -372,6 +507,21 @@ MyGame.Example.Stat.prototype.count = function() {
return
offset
?
this
.
bb
.
readUint16
(
this
.
bb_pos
+
offset
)
:
0
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Stat
.
prototype
.
mutate_count
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
8
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeUint16
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {flatbuffers.Builder} builder
*/
...
...
@@ -474,6 +624,21 @@ MyGame.Example.Monster.prototype.mana = function() {
return
offset
?
this
.
bb
.
readInt16
(
this
.
bb_pos
+
offset
)
:
150
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_mana
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
6
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt16
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -482,6 +647,21 @@ MyGame.Example.Monster.prototype.hp = function() {
return
offset
?
this
.
bb
.
readInt16
(
this
.
bb_pos
+
offset
)
:
100
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_hp
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
8
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt16
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {flatbuffers.Encoding=} optionalEncoding
* @returns {string|Uint8Array}
...
...
@@ -524,6 +704,21 @@ MyGame.Example.Monster.prototype.color = function() {
return
offset
?
/** @type {MyGame.Example.Color} */
(
this
.
bb
.
readInt8
(
this
.
bb_pos
+
offset
))
:
MyGame
.
Example
.
Color
.
Blue
;
};
/**
* @param {MyGame.Example.Color} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_color
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
16
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt8
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {MyGame.Example.Any}
*/
...
...
@@ -532,6 +727,21 @@ MyGame.Example.Monster.prototype.testType = function() {
return
offset
?
/** @type {MyGame.Example.Any} */
(
this
.
bb
.
readUint8
(
this
.
bb_pos
+
offset
))
:
MyGame
.
Example
.
Any
.
NONE
;
};
/**
* @param {MyGame.Example.Any} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_test_type
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
18
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeUint8
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {flatbuffers.Table} obj
* @returns {?flatbuffers.Table}
...
...
@@ -649,6 +859,21 @@ MyGame.Example.Monster.prototype.testbool = function() {
return
offset
?
!!
this
.
bb
.
readInt8
(
this
.
bb_pos
+
offset
)
:
false
;
};
/**
* @param {boolean} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testbool
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
34
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt8
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -657,6 +882,21 @@ MyGame.Example.Monster.prototype.testhashs32Fnv1 = function() {
return
offset
?
this
.
bb
.
readInt32
(
this
.
bb_pos
+
offset
)
:
0
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testhashs32_fnv1
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
36
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -665,6 +905,21 @@ MyGame.Example.Monster.prototype.testhashu32Fnv1 = function() {
return
offset
?
this
.
bb
.
readUint32
(
this
.
bb_pos
+
offset
)
:
0
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testhashu32_fnv1
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
38
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeUint32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {flatbuffers.Long}
*/
...
...
@@ -673,6 +928,21 @@ MyGame.Example.Monster.prototype.testhashs64Fnv1 = function() {
return
offset
?
this
.
bb
.
readInt64
(
this
.
bb_pos
+
offset
)
:
this
.
bb
.
createLong
(
0
,
0
);
};
/**
* @param {flatbuffers.Long} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testhashs64_fnv1
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
40
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt64
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {flatbuffers.Long}
*/
...
...
@@ -681,6 +951,21 @@ MyGame.Example.Monster.prototype.testhashu64Fnv1 = function() {
return
offset
?
this
.
bb
.
readUint64
(
this
.
bb_pos
+
offset
)
:
this
.
bb
.
createLong
(
0
,
0
);
};
/**
* @param {flatbuffers.Long} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testhashu64_fnv1
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
42
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeUint64
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -689,6 +974,21 @@ MyGame.Example.Monster.prototype.testhashs32Fnv1a = function() {
return
offset
?
this
.
bb
.
readInt32
(
this
.
bb_pos
+
offset
)
:
0
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testhashs32_fnv1a
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
44
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -697,6 +997,21 @@ MyGame.Example.Monster.prototype.testhashu32Fnv1a = function() {
return
offset
?
this
.
bb
.
readUint32
(
this
.
bb_pos
+
offset
)
:
0
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testhashu32_fnv1a
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
46
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeUint32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {flatbuffers.Long}
*/
...
...
@@ -705,6 +1020,21 @@ MyGame.Example.Monster.prototype.testhashs64Fnv1a = function() {
return
offset
?
this
.
bb
.
readInt64
(
this
.
bb_pos
+
offset
)
:
this
.
bb
.
createLong
(
0
,
0
);
};
/**
* @param {flatbuffers.Long} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testhashs64_fnv1a
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
48
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt64
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {flatbuffers.Long}
*/
...
...
@@ -713,6 +1043,21 @@ MyGame.Example.Monster.prototype.testhashu64Fnv1a = function() {
return
offset
?
this
.
bb
.
readUint64
(
this
.
bb_pos
+
offset
)
:
this
.
bb
.
createLong
(
0
,
0
);
};
/**
* @param {flatbuffers.Long} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testhashu64_fnv1a
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
50
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeUint64
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {number} index
* @returns {boolean}
...
...
@@ -746,6 +1091,21 @@ MyGame.Example.Monster.prototype.testf = function() {
return
offset
?
this
.
bb
.
readFloat32
(
this
.
bb_pos
+
offset
)
:
3.14159
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testf
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
54
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeFloat32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -754,6 +1114,21 @@ MyGame.Example.Monster.prototype.testf2 = function() {
return
offset
?
this
.
bb
.
readFloat32
(
this
.
bb_pos
+
offset
)
:
3.0
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testf2
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
56
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeFloat32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -762,6 +1137,21 @@ MyGame.Example.Monster.prototype.testf3 = function() {
return
offset
?
this
.
bb
.
readFloat32
(
this
.
bb_pos
+
offset
)
:
0.0
;
};
/**
* @param {number} value
* @returns {boolean}
*/
MyGame
.
Example
.
Monster
.
prototype
.
mutate_testf3
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
58
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeFloat32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {number} index
* @param {flatbuffers.Encoding=} optionalEncoding
...
...
tests/namespace_test/namespace_test1_generated.js
View file @
c9b9fd04
...
...
@@ -64,6 +64,21 @@ NamespaceA.NamespaceB.TableInNestedNS.prototype.foo = function() {
return
offset
?
this
.
bb
.
readInt32
(
this
.
bb_pos
+
offset
)
:
0
;
};
/**
* @param {number} value
* @returns {boolean}
*/
NamespaceA
.
NamespaceB
.
TableInNestedNS
.
prototype
.
mutate_foo
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
4
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {flatbuffers.Builder} builder
*/
...
...
@@ -121,6 +136,21 @@ NamespaceA.NamespaceB.StructInNestedNS.prototype.a = function() {
return
this
.
bb
.
readInt32
(
this
.
bb_pos
);
};
/**
* @param {number} value
* @returns {boolean}
*/
NamespaceA
.
NamespaceB
.
StructInNestedNS
.
prototype
.
mutate_a
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
0
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @returns {number}
*/
...
...
@@ -128,6 +158,21 @@ NamespaceA.NamespaceB.StructInNestedNS.prototype.b = function() {
return
this
.
bb
.
readInt32
(
this
.
bb_pos
+
4
);
};
/**
* @param {number} value
* @returns {boolean}
*/
NamespaceA
.
NamespaceB
.
StructInNestedNS
.
prototype
.
mutate_b
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
4
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt32
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {flatbuffers.Builder} builder
* @param {number} a
...
...
tests/namespace_test/namespace_test2_generated.js
View file @
c9b9fd04
...
...
@@ -70,6 +70,21 @@ NamespaceA.TableInFirstNS.prototype.fooEnum = function() {
return
offset
?
/** @type {NamespaceA.NamespaceB.EnumInNestedNS} */
(
this
.
bb
.
readInt8
(
this
.
bb_pos
+
offset
))
:
NamespaceA
.
NamespaceB
.
EnumInNestedNS
.
A
;
};
/**
* @param {NamespaceA.NamespaceB.EnumInNestedNS} value
* @returns {boolean}
*/
NamespaceA
.
TableInFirstNS
.
prototype
.
mutate_foo_enum
=
function
(
value
)
{
var
offset
=
this
.
bb
.
__offset
(
this
.
bb_pos
,
6
)
if
(
offset
===
0
)
{
return
false
;
}
this
.
bb
.
writeInt8
(
this
.
bb_pos
+
offset
,
value
);
return
true
;
}
/**
* @param {NamespaceA.NamespaceB.StructInNestedNS=} obj
* @returns {NamespaceA.NamespaceB.StructInNestedNS}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment