TypeScript support (#4232)

* Eclipse ignore

* TypeScript support

* Prefixing enums

* Test results

* Merged JS and TS generators

* Fixed AppVeyor build problems

* Fixed more AppVeyor build problems

* Fixed more AppVeyor build problems

* Changed TS flag to options struct

* Storing options by value

* Removed unneeded const

* Re-export support for unions

* Uint support

* Casting bools to numbers for mutation

* TS shell tests

* Reverted generates js test file to original version

* Backing up js tests and properly generating test data
This commit is contained in:
Kamil Rojewski
2017-04-10 19:01:13 +02:00
committed by Wouter van Oortmerssen
parent adc50051e0
commit 28e7dbd3d3
13 changed files with 2672 additions and 104 deletions

View File

@@ -114,6 +114,8 @@ class BaseGenerator {
std::string WrapInNameSpace(const Definition &def) const;
std::string GetNameSpace(const Definition &def) const;
const Parser &parser_;
const std::string &path_;
const std::string &file_name_;

View File

@@ -358,7 +358,9 @@ struct IDLOptions {
bool allow_non_utf8;
std::string include_prefix;
bool binary_schema_comments;
bool skip_flatbuffers_import;
std::string go_namespace;
bool reexport_ts_modules;
// Possible options for the more general generator below.
enum Language {
@@ -371,6 +373,7 @@ struct IDLOptions {
kPhp = 1 << 6,
kJson = 1 << 7,
kBinary = 1 << 8,
kTs = 1 << 9,
kMAX
};
@@ -400,6 +403,8 @@ struct IDLOptions {
union_value_namespacing(true),
allow_non_utf8(false),
binary_schema_comments(false),
skip_flatbuffers_import(false),
reexport_ts_modules(true),
lang(IDLOptions::kJava),
lang_to_generate(0) {}
};
@@ -650,7 +655,7 @@ extern bool GenerateCPP(const Parser &parser,
const std::string &path,
const std::string &file_name);
// Generate JavaScript code from the definitions in the Parser object.
// Generate JavaScript or TypeScript code from the definitions in the Parser object.
// See idl_gen_js.
extern std::string GenerateJS(const Parser &parser);
extern bool GenerateJS(const Parser &parser,
@@ -701,7 +706,7 @@ extern bool GenerateFBS(const Parser &parser,
const std::string &path,
const std::string &file_name);
// Generate a make rule for the generated JavaScript code.
// Generate a make rule for the generated JavaScript or TypeScript code.
// See idl_gen_js.cpp.
extern std::string JSMakeRule(const Parser &parser,
const std::string &path,