Merge pull request #3935 from kazimuth/jsns

Add @namespace annotation to namespaces in javascript
This commit is contained in:
Wouter van Oortmerssen 2016-07-25 10:47:46 -07:00 committed by GitHub
commit f61f0449c7
6 changed files with 23 additions and 10 deletions

View File

@ -2,6 +2,10 @@
/// @addtogroup flatbuffers_javascript_api /// @addtogroup flatbuffers_javascript_api
/// @{ /// @{
/// @cond FLATBUFFERS_INTERNAL /// @cond FLATBUFFERS_INTERNAL
/**
* @const
* @namespace
*/
var flatbuffers = {}; var flatbuffers = {};
/** /**

View File

@ -110,7 +110,7 @@ class JsGenerator : public BaseGenerator {
std::string &exports = *exports_ptr; std::string &exports = *exports_ptr;
for (auto it = sorted_namespaces.begin(); for (auto it = sorted_namespaces.begin();
it != sorted_namespaces.end(); it++) { it != sorted_namespaces.end(); it++) {
code += "/**\n * @const\n*/\n"; code += "/**\n * @const\n * @namespace\n */\n";
if (it->find('.') == std::string::npos) { if (it->find('.') == std::string::npos) {
code += "var "; code += "var ";
exports += "this." + *it + " = " + *it + ";\n"; exports += "this." + *it + " = " + *it + ";\n";

Binary file not shown.

View File

@ -2,22 +2,26 @@
/** /**
* @const * @const
*/ * @namespace
*/
var MyGame = MyGame || {}; var MyGame = MyGame || {};
/** /**
* @const * @const
*/ * @namespace
*/
MyGame.Example = MyGame.Example || {}; MyGame.Example = MyGame.Example || {};
/** /**
* @const * @const
*/ * @namespace
*/
MyGame.Example2 = MyGame.Example2 || {}; MyGame.Example2 = MyGame.Example2 || {};
/** /**
* @const * @const
*/ * @namespace
*/
MyGame.OtherNameSpace = MyGame.OtherNameSpace || {}; MyGame.OtherNameSpace = MyGame.OtherNameSpace || {};
/** /**

View File

@ -2,12 +2,14 @@
/** /**
* @const * @const
*/ * @namespace
*/
var NamespaceA = NamespaceA || {}; var NamespaceA = NamespaceA || {};
/** /**
* @const * @const
*/ * @namespace
*/
NamespaceA.NamespaceB = NamespaceA.NamespaceB || {}; NamespaceA.NamespaceB = NamespaceA.NamespaceB || {};
/** /**

View File

@ -2,17 +2,20 @@
/** /**
* @const * @const
*/ * @namespace
*/
var NamespaceA = NamespaceA || {}; var NamespaceA = NamespaceA || {};
/** /**
* @const * @const
*/ * @namespace
*/
NamespaceA.NamespaceB = NamespaceA.NamespaceB || {}; NamespaceA.NamespaceB = NamespaceA.NamespaceB || {};
/** /**
* @const * @const
*/ * @namespace
*/
var NamespaceC = NamespaceC || {}; var NamespaceC = NamespaceC || {};
/** /**