Javascript: preparations for using Language::getNSpace().

This commit is contained in:
Oliver Buchtala 2014-05-19 00:20:19 +02:00
parent 7824322b14
commit 0c42158723
1 changed files with 22 additions and 2 deletions

View File

@ -318,6 +318,10 @@ public:
**/
virtual int fragmentDirective(Node *n);
public:
virtual String *getNSpace() const;
private:
JSEmitter *emitter;
@ -467,6 +471,10 @@ int JAVASCRIPT::fragmentDirective(Node *n) {
return SWIG_OK;
}
String *JAVASCRIPT::getNSpace() const {
return Language::getNSpace();
}
/* ---------------------------------------------------------------------
* top()
*
@ -1346,14 +1354,26 @@ int JSEmitter::switchNamespace(Node *n) {
return SWIG_OK;
}
String *nspace = Getattr(n, "sym:nspace");
// if nspace is deactivated, everything goes into the global scope
if (!GetFlag(n, "feature:nspace")) {
current_namespace = Getattr(namespaces, "::");
return SWIG_OK;
}
// EXPERIMENTAL: we want to use Language::getNSpace() here
// However, it is not working yet.
// For namespace functions Language::getNSpace() does not give a valid result
#if 0
JAVASCRIPT *lang = static_cast<JAVASCRIPT*>(Language::instance());
String *_nspace = lang->getNSpace();
if (!Equal(nspace, _nspace)) {
Printf(stdout, "##### Custom vs Language::getNSpace(): %s | %s\n", nspace, _nspace);
Swig_print_node(n);
}
#endif
String *nspace = Getattr(n, "sym:nspace");
if (nspace == NULL) {
// It seems that only classes have 'sym:nspace' set.
// We try to get the namespace from the qualified name (i.e., everything before the last '::')