summaryrefslogtreecommitdiff
path: root/Source/Modules/javascript.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Modules/javascript.cxx')
-rw-r--r--Source/Modules/javascript.cxx65
1 files changed, 47 insertions, 18 deletions
diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx
index 20af76f9f..0c3f02a75 100644
--- a/Source/Modules/javascript.cxx
+++ b/Source/Modules/javascript.cxx
@@ -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()
*
@@ -716,19 +724,19 @@ int JSEmitter::emitWrapperFunction(Node *n) {
// detected via the 'view' attribute.
|| (Equal(kind, "variable") && Equal(Getattr(n, "view"), "globalfunctionHandler"))
) {
- bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend");
- bool is_static = GetFlag(state.function(), IS_STATIC);
+ bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0;
+ bool is_static = GetFlag(state.function(), IS_STATIC) != 0;
ret = emitFunction(n, is_member, is_static);
} else if (Cmp(kind, "variable") == 0) {
- bool is_static = GetFlag(state.variable(), IS_STATIC);
+ bool is_static = GetFlag(state.variable(), IS_STATIC) != 0;
// HACK: smartpointeraccessed static variables are not treated as statics
if (GetFlag(n, "allocate:smartpointeraccess")) {
is_static = false;
}
- bool is_member = GetFlag(n, "ismember");
- bool is_setter = GetFlag(n, "memberset") || GetFlag(n, "varset");
- bool is_getter = GetFlag(n, "memberget") || GetFlag(n, "varget");
+ bool is_member = GetFlag(n, "ismember") != 0;
+ bool is_setter = GetFlag(n, "memberset") != 0 || GetFlag(n, "varset") != 0;
+ bool is_getter = GetFlag(n, "memberget") != 0 || GetFlag(n, "varget") != 0;
if (is_setter) {
ret = emitSetter(n, is_member, is_static);
} else if (is_getter) {
@@ -832,7 +840,7 @@ int JSEmitter::emitCtor(Node *n) {
Wrapper *wrapper = NewWrapper();
- bool is_overloaded = GetFlag(n, "sym:overloaded");
+ bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
Template t_ctor(getTemplate("js_ctor"));
@@ -1152,7 +1160,7 @@ int JSEmitter::emitFunction(Node *n, bool is_member, bool is_static) {
Wrapper *wrapper = NewWrapper();
Template t_function(getTemplate("js_function"));
- bool is_overloaded = GetFlag(n, "sym:overloaded");
+ bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
// prepare the function wrapper name
String *iname = Getattr(n, "sym:name");
@@ -1223,18 +1231,27 @@ int JSEmitter::emitFunctionDispatcher(Node *n, bool /*is_member */ ) {
// substract the extension "sym:overname",
String *wrap_name = NewString(Getattr(n, "wrap:name"));
String *overname = Getattr(n, "sym:overname");
+
+ Node *methodclass = Swig_methodclass(n);
+ String *class_name = Getattr(methodclass, "sym:name");
+
int l1 = Len(wrap_name);
int l2 = Len(overname);
Delslice(wrap_name, l1 - l2, l1);
- Setattr(n, "wrap:name", wrap_name);
- state.function(WRAPPER_NAME, wrap_name);
+ String *new_string = NewStringf("%s_%s", class_name, wrap_name);
+ String *final_wrap_name = Swig_name_wrapper(new_string);
+
+ Setattr(n, "wrap:name", final_wrap_name);
+ state.function(WRAPPER_NAME, final_wrap_name);
+
+
t_function.replace("$jslocals", wrapper->locals)
.replace("$jscode", wrapper->code);
// call this here, to replace all variables
- t_function.replace("$jswrapper", wrap_name)
+ t_function.replace("$jswrapper", final_wrap_name)
.replace("$jsname", state.function(NAME))
.pretty_print(f_wrappers);
@@ -1280,7 +1297,7 @@ void JSEmitter::marshalOutput(Node *n, ParmList *params, Wrapper *wrapper, Strin
cresult = defaultResultName;
tm = Swig_typemap_lookup_out("out", n, cresult, wrapper, actioncode);
- bool should_own = GetFlag(n, "feature:new");
+ bool should_own = GetFlag(n, "feature:new") != 0;
if (tm) {
Replaceall(tm, "$objecttype", Swig_scopename_last(SwigType_str(SwigType_strip_qualifiers(type), 0)));
@@ -1346,14 +1363,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 '::')
@@ -1608,8 +1637,8 @@ int JSCEmitter::enterFunction(Node *n) {
int JSCEmitter::exitFunction(Node *n) {
Template t_function = getTemplate("jsc_function_declaration");
- bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend");
- bool is_overloaded = GetFlag(n, "sym:overloaded");
+ bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0;
+ bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
// handle overloaded functions
if (is_overloaded) {
@@ -2057,10 +2086,10 @@ int V8Emitter::exitVariable(Node *n) {
}
int V8Emitter::exitFunction(Node *n) {
- bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend");
+ bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0;
// create a dispatcher for overloaded functions
- bool is_overloaded = GetFlag(n, "sym:overloaded");
+ bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
if (is_overloaded) {
if (!Getattr(n, "sym:nextSibling")) {
//state.function(WRAPPER_NAME, Swig_name_wrapper(Getattr(n, "name")));