Qualify generated SwigDirector class names with namespaces
This commit is contained in:
parent
3e70da14c9
commit
f6ce5f089f
5 changed files with 55 additions and 38 deletions
|
|
@ -78,9 +78,10 @@ String *Swig_class_name(Node *n) {
|
|||
|
||||
String *Swig_director_declaration(Node *n) {
|
||||
String *classname = Swig_class_name(n);
|
||||
String *directorname = NewStringf("SwigDirector_%s", classname);
|
||||
String *directorname = Language::instance()->directorClassName(n);
|
||||
String *base = Getattr(n, "classtype");
|
||||
String *declaration = Swig_class_declaration(n, directorname);
|
||||
|
||||
Printf(declaration, " : public %s, public Swig::Director {\n", base);
|
||||
Delete(classname);
|
||||
Delete(directorname);
|
||||
|
|
@ -281,8 +282,10 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) {
|
|||
&& !Equal(nodeType(n), "constructor"))) {
|
||||
Node *parent = Getattr(n, "parentNode");
|
||||
String *symname = Getattr(parent, "sym:name");
|
||||
String *dirname = NewStringf("SwigDirector_%s", symname);
|
||||
String *dirdecl = NewStringf("%s *darg = 0", dirname);
|
||||
String *dirname;
|
||||
String *dirdecl;
|
||||
dirname = Language::instance()->directorClassName(parent);
|
||||
dirdecl = NewStringf("%s *darg = 0", dirname);
|
||||
Wrapper_add_local(f, "darg", dirdecl);
|
||||
Printf(f->code, "darg = dynamic_cast<%s *>(arg1);\n", dirname);
|
||||
Delete(dirname);
|
||||
|
|
|
|||
|
|
@ -204,24 +204,6 @@ public:
|
|||
return valid_jni_name;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* directorClassName()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *directorClassName(Node *n) {
|
||||
String *dirclassname;
|
||||
const char *attrib = "director:classname";
|
||||
|
||||
if (!(dirclassname = Getattr(n, attrib))) {
|
||||
String *classname = Getattr(n, "sym:name");
|
||||
|
||||
dirclassname = NewStringf("SwigDirector_%s", classname);
|
||||
Setattr(n, attrib, dirclassname);
|
||||
}
|
||||
|
||||
return dirclassname;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* main()
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
@ -2008,7 +1990,7 @@ public:
|
|||
Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n");
|
||||
Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name);
|
||||
Printf(dcast_wrap->code, " if (obj) director = dynamic_cast<Swig::Director *>(obj);\n");
|
||||
Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n");
|
||||
Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self);\n");
|
||||
Printf(dcast_wrap->code, " return jresult;\n");
|
||||
Printf(dcast_wrap->code, "}\n");
|
||||
|
||||
|
|
@ -3380,8 +3362,8 @@ public:
|
|||
String *norm_name = SwigType_namestr(Getattr(n, "name"));
|
||||
String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect");
|
||||
String *swig_director_connect_jni = makeValidJniName(swig_director_connect);
|
||||
String *sym_name = Getattr(n, "sym:name");
|
||||
String *smartptr_feature = Getattr(n, "feature:smartptr");
|
||||
String *dirClassName = directorClassName(n);
|
||||
Wrapper *code_wrap;
|
||||
|
||||
Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean mem_own, boolean weak_global);\n",
|
||||
|
|
@ -3401,12 +3383,12 @@ public:
|
|||
Printf(code_wrap->code, " // raw pointer alive. This is done instead of using the smart pointer's dynamic cast\n");
|
||||
Printf(code_wrap->code, " // feature since different smart pointer implementations have differently named dynamic\n");
|
||||
Printf(code_wrap->code, " // cast mechanisms.\n");
|
||||
Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast< SwigDirector_%s *>(obj->operator->());\n", sym_name, sym_name);
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast< %s *>(obj->operator->());\n", dirClassName, dirClassName);
|
||||
}
|
||||
else {
|
||||
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name);
|
||||
Printf(code_wrap->code, " (void)jcls;\n");
|
||||
Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast<SwigDirector_%s *>(obj);\n", sym_name, sym_name);
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
}
|
||||
|
||||
Printf(code_wrap->code, " if (director) {\n");
|
||||
|
|
@ -3432,7 +3414,7 @@ public:
|
|||
"SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jtake_or_release) {\n",
|
||||
jnipackage, jni_imclass_name, changeown_jnimethod_name);
|
||||
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name);
|
||||
Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast<SwigDirector_%s *>(obj);\n", sym_name, sym_name);
|
||||
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName);
|
||||
Printf(code_wrap->code, " (void)jcls;\n");
|
||||
Printf(code_wrap->code, " if (director) {\n");
|
||||
Printf(code_wrap->code, " director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);\n");
|
||||
|
|
@ -3445,6 +3427,7 @@ public:
|
|||
Delete(changeown_method_name);
|
||||
Delete(changeown_jnimethod_name);
|
||||
Delete(norm_name);
|
||||
Delete(dirClassName);
|
||||
Delete(jni_imclass_name);
|
||||
}
|
||||
|
||||
|
|
@ -3583,7 +3566,7 @@ public:
|
|||
// we're consistent with the sym:overload name in functionWrapper. (?? when
|
||||
// does the overloaded method name get set?)
|
||||
|
||||
imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), classname, overloaded_name));
|
||||
imclass_dmethod = NewStringf("%s", Swig_name_member(getNSpace(), dirclassname, overloaded_name));
|
||||
|
||||
qualified_return = SwigType_rcaststr(returntype, "c_result");
|
||||
|
||||
|
|
@ -4182,16 +4165,18 @@ public:
|
|||
int classDirectorDefaultConstructor(Node *n) {
|
||||
String *classname = Swig_class_name(n);
|
||||
String *classtype = SwigType_namestr(Getattr(n, "name"));
|
||||
String *dirClassName = directorClassName(n);
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
Printf(w->def, "SwigDirector_%s::SwigDirector_%s(JNIEnv *jenv) : %s {", classname, classname, Getattr(n, "director:ctor"));
|
||||
Printf(w->def, "%s::%s(JNIEnv *jenv) : %s {", dirClassName, dirClassName, Getattr(n, "director:ctor"));
|
||||
Printf(w->code, "}\n");
|
||||
Wrapper_print(w, f_directors);
|
||||
|
||||
Printf(f_directors_h, " SwigDirector_%s(JNIEnv *jenv);\n", classname);
|
||||
Printf(f_directors_h, " %s(JNIEnv *jenv);\n", dirClassName);
|
||||
DelWrapper(w);
|
||||
Delete(classtype);
|
||||
Delete(classname);
|
||||
Delete(dirClassName);
|
||||
directorPrefixArgs(n);
|
||||
return Language::classDirectorDefaultConstructor(n);
|
||||
}
|
||||
|
|
@ -4228,14 +4213,15 @@ public:
|
|||
Node *current_class = getCurrentClass();
|
||||
String *full_classname = Getattr(current_class, "name");
|
||||
String *classname = Swig_class_name(current_class);
|
||||
String *dirClassName = directorClassName(current_class);
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
if (Getattr(n, "throw")) {
|
||||
Printf(f_directors_h, " virtual ~SwigDirector_%s() throw ();\n", classname);
|
||||
Printf(w->def, "SwigDirector_%s::~SwigDirector_%s() throw () {\n", classname, classname);
|
||||
Printf(f_directors_h, " virtual ~%s() throw ();\n", dirClassName);
|
||||
Printf(w->def, "%s::~%s() throw () {\n", dirClassName, dirClassName);
|
||||
} else {
|
||||
Printf(f_directors_h, " virtual ~SwigDirector_%s();\n", classname);
|
||||
Printf(w->def, "SwigDirector_%s::~SwigDirector_%s() {\n", classname, classname);
|
||||
Printf(f_directors_h, " virtual ~%s();\n", dirClassName);
|
||||
Printf(w->def, "%s::~%s() {\n", dirClassName, dirClassName);
|
||||
}
|
||||
|
||||
/* Ensure that correct directordisconnect typemap's method name is called
|
||||
|
|
@ -4254,6 +4240,7 @@ public:
|
|||
DelWrapper(w);
|
||||
Delete(disconn_attr);
|
||||
Delete(classname);
|
||||
Delete(dirClassName);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -4395,8 +4382,7 @@ public:
|
|||
String *base = Getattr(n, "classtype");
|
||||
String *class_ctor = NewString("Swig::Director(jenv)");
|
||||
|
||||
String *classname = Swig_class_name(n);
|
||||
String *directorname = NewStringf("SwigDirector_%s", classname);
|
||||
String *directorname = directorClassName(n);
|
||||
String *declaration = Swig_class_declaration(n, directorname);
|
||||
|
||||
Printf(declaration, " : public %s, public Swig::Director", base);
|
||||
|
|
|
|||
|
|
@ -347,6 +347,24 @@ Language::~Language() {
|
|||
this_ = 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* directorClassName()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Language::directorClassName(Node *n) {
|
||||
String *dirclassname;
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
const char *attrib = "director:classname";
|
||||
String *classname = Getattr(n, "sym:name");
|
||||
|
||||
Replace(nspace, ".", "_", DOH_REPLACE_ANY);
|
||||
dirclassname = NewStringf("SwigDirector_%s_%s", nspace, classname);
|
||||
Setattr(n, attrib, dirclassname);
|
||||
|
||||
Delete(nspace);
|
||||
return dirclassname;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
emit_one()
|
||||
---------------------------------------------------------------------- */
|
||||
|
|
@ -2405,7 +2423,7 @@ int Language::classDeclaration(Node *n) {
|
|||
}
|
||||
|
||||
if (dir) {
|
||||
DirectorClassName = NewStringf("SwigDirector_%s", symname);
|
||||
DirectorClassName = directorClassName(n);
|
||||
classDirector(n);
|
||||
}
|
||||
/* check for abstract after resolving directors */
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ public:
|
|||
virtual ~Language();
|
||||
virtual int emit_one(Node *n);
|
||||
|
||||
String *directorClassName(Node *n);
|
||||
|
||||
/* Parse command line options */
|
||||
|
||||
virtual void main(int argc, char *argv[]);
|
||||
|
|
|
|||
|
|
@ -855,6 +855,9 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
String *self = 0;
|
||||
int is_smart_pointer_overload = 0;
|
||||
String *qualifier = Getattr(n, "qualifier");
|
||||
String *directorScope = NewString(nspace);
|
||||
|
||||
Replace(directorScope, ".", "_", DOH_REPLACE_ANY);
|
||||
|
||||
/* If smart pointer without const overload or mutable method, change self dereferencing */
|
||||
if (flags & CWRAP_SMART_POINTER) {
|
||||
|
|
@ -937,7 +940,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
/* If protected access (can only be if a director method) then call the extra public accessor method (language module must provide this) */
|
||||
String *explicit_qualifier_tmp = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname"));
|
||||
explicitcall_name = NewStringf("%sSwigPublic", name);
|
||||
explicit_qualifier = NewStringf("SwigDirector_%s", explicit_qualifier_tmp);
|
||||
explicit_qualifier = NewStringf("SwigDirector_%s_%s", directorScope, explicit_qualifier_tmp);
|
||||
Delete(explicit_qualifier_tmp);
|
||||
} else {
|
||||
explicit_qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname"));
|
||||
|
|
@ -1057,6 +1060,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
Delete(p);
|
||||
Delete(self);
|
||||
Delete(parms);
|
||||
Delete(directorScope);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1107,6 +1111,9 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
ParmList *directorparms;
|
||||
SwigType *type;
|
||||
int use_director;
|
||||
String *directorScope = NewString(nspace);
|
||||
|
||||
Replace(directorScope, ".", "_", DOH_REPLACE_ANY);
|
||||
|
||||
use_director = Swig_directorclass(n);
|
||||
|
||||
|
|
@ -1167,7 +1174,7 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
Node *parent = Swig_methodclass(n);
|
||||
int abstract = Getattr(parent, "abstracts") != 0;
|
||||
String *name = Getattr(parent, "sym:name");
|
||||
String *directorname = NewStringf("SwigDirector_%s", name);
|
||||
String *directorname = NewStringf("SwigDirector_%s_%s", directorScope, name);
|
||||
String *action = NewStringEmpty();
|
||||
String *tmp_none_comparison = Copy(none_comparison);
|
||||
String *director_call;
|
||||
|
|
@ -1233,6 +1240,7 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
if (directorparms != parms)
|
||||
Delete(directorparms);
|
||||
Delete(parms);
|
||||
Delete(directorScope);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue