mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-16 01:07:29 +00:00
removed parser from the method signatures
This commit is contained in:
@@ -48,7 +48,7 @@ class JsGenerator : public BaseGenerator {
|
|||||||
code = code + "// " + FlatBuffersGeneratedWarning();
|
code = code + "// " + FlatBuffersGeneratedWarning();
|
||||||
|
|
||||||
// Generate code for all the namespace declarations.
|
// Generate code for all the namespace declarations.
|
||||||
GenNamespaces(parser_, &code, &exports_code);
|
GenNamespaces(&code, &exports_code);
|
||||||
|
|
||||||
// Output the main declaration code from above.
|
// Output the main declaration code from above.
|
||||||
code += enum_code;
|
code += enum_code;
|
||||||
@@ -79,15 +79,14 @@ class JsGenerator : public BaseGenerator {
|
|||||||
for (auto it = parser_.structs_.vec.begin();
|
for (auto it = parser_.structs_.vec.begin();
|
||||||
it != parser_.structs_.vec.end(); ++it) {
|
it != parser_.structs_.vec.end(); ++it) {
|
||||||
auto &struct_def = **it;
|
auto &struct_def = **it;
|
||||||
GenStruct(parser_, struct_def, decl_code_ptr, exports_code_ptr);
|
GenStruct(struct_def, decl_code_ptr, exports_code_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void GenNamespaces(const Parser &parser, std::string *code_ptr,
|
void GenNamespaces(std::string *code_ptr, std::string *exports_ptr) {
|
||||||
std::string *exports_ptr) {
|
|
||||||
std::set<std::string> namespaces;
|
std::set<std::string> namespaces;
|
||||||
|
|
||||||
for (auto it = parser.namespaces_.begin();
|
for (auto it = parser_.namespaces_.begin();
|
||||||
it != parser.namespaces_.end(); ++it) {
|
it != parser_.namespaces_.end(); ++it) {
|
||||||
std::string namespace_so_far;
|
std::string namespace_so_far;
|
||||||
|
|
||||||
// Gather all parent namespaces for this namespace
|
// Gather all parent namespaces for this namespace
|
||||||
@@ -378,8 +377,7 @@ static void GenStructBody(const StructDef &struct_def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate an accessor struct with constructor for a flatbuffers struct.
|
// Generate an accessor struct with constructor for a flatbuffers struct.
|
||||||
static void GenStruct(const Parser &parser, StructDef &struct_def,
|
void GenStruct(StructDef &struct_def, std::string *code_ptr, std::string *exports_ptr) {
|
||||||
std::string *code_ptr, std::string *exports_ptr) {
|
|
||||||
if (struct_def.generated) return;
|
if (struct_def.generated) return;
|
||||||
std::string &code = *code_ptr;
|
std::string &code = *code_ptr;
|
||||||
std::string &exports = *exports_ptr;
|
std::string &exports = *exports_ptr;
|
||||||
@@ -433,13 +431,13 @@ static void GenStruct(const Parser &parser, StructDef &struct_def,
|
|||||||
code += "};\n\n";
|
code += "};\n\n";
|
||||||
|
|
||||||
// Generate the identifier check method
|
// Generate the identifier check method
|
||||||
if (parser.root_struct_def_ == &struct_def &&
|
if (parser_.root_struct_def_ == &struct_def &&
|
||||||
!parser.file_identifier_.empty()) {
|
!parser_.file_identifier_.empty()) {
|
||||||
GenDocComment(code_ptr,
|
GenDocComment(code_ptr,
|
||||||
"@param {flatbuffers.ByteBuffer} bb\n"
|
"@param {flatbuffers.ByteBuffer} bb\n"
|
||||||
"@returns {boolean}");
|
"@returns {boolean}");
|
||||||
code += object_name + ".bufferHasIdentifier = function(bb) {\n";
|
code += object_name + ".bufferHasIdentifier = function(bb) {\n";
|
||||||
code += " return bb.__has_identifier('" + parser.file_identifier_;
|
code += " return bb.__has_identifier('" + parser_.file_identifier_;
|
||||||
code += "');\n};\n\n";
|
code += "');\n};\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -702,15 +700,15 @@ static void GenStruct(const Parser &parser, StructDef &struct_def,
|
|||||||
code += "};\n\n";
|
code += "};\n\n";
|
||||||
|
|
||||||
// Generate the method to complete buffer construction
|
// Generate the method to complete buffer construction
|
||||||
if (parser.root_struct_def_ == &struct_def) {
|
if (parser_.root_struct_def_ == &struct_def) {
|
||||||
GenDocComment(code_ptr,
|
GenDocComment(code_ptr,
|
||||||
"@param {flatbuffers.Builder} builder\n"
|
"@param {flatbuffers.Builder} builder\n"
|
||||||
"@param {flatbuffers.Offset} offset");
|
"@param {flatbuffers.Offset} offset");
|
||||||
code += object_name + ".finish" + struct_def.name + "Buffer";
|
code += object_name + ".finish" + struct_def.name + "Buffer";
|
||||||
code += " = function(builder, offset) {\n";
|
code += " = function(builder, offset) {\n";
|
||||||
code += " builder.finish(offset";
|
code += " builder.finish(offset";
|
||||||
if (!parser.file_identifier_.empty()) {
|
if (!parser_.file_identifier_.empty()) {
|
||||||
code += ", '" + parser.file_identifier_ + "'";
|
code += ", '" + parser_.file_identifier_ + "'";
|
||||||
}
|
}
|
||||||
code += ");\n";
|
code += ");\n";
|
||||||
code += "};\n\n";
|
code += "};\n\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user