director protected support cleanup
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5505 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7ffb2f2a8b
commit
7b69dddba0
2 changed files with 15 additions and 11 deletions
|
|
@ -374,15 +374,11 @@ void emit_action(Node *n, Wrapper *f) {
|
||||||
String* symname = Getattr(parent, "sym:name");
|
String* symname = Getattr(parent, "sym:name");
|
||||||
String* classtype = Getattr(parent,"classtype");
|
String* classtype = Getattr(parent,"classtype");
|
||||||
String* dirname = NewStringf("SwigDirector_%s", symname);
|
String* dirname = NewStringf("SwigDirector_%s", symname);
|
||||||
String* dirdecl = NewStringf("%s *darg1 = 0", dirname);
|
String* dirdecl = NewStringf("%s *darg = 0", dirname);
|
||||||
Wrapper_add_local(f, "darg1", dirdecl);
|
Wrapper_add_local(f, "darg", dirdecl);
|
||||||
Printf(f->code, "darg1 = dynamic_cast<%s *>(arg1);\n",dirname);
|
Printf(f->code, "darg = dynamic_cast<%s *>(arg1);\n",dirname);
|
||||||
/* Maybe here a more detailed diagnostic can de added,
|
Printf(f->code, "if (!darg) SWIG_exception(SWIG_RuntimeError,\"accesing protected member %s\");\n",Getattr(n,"name"));
|
||||||
such as trying to access a protected member, but it seems
|
Replace(action, "arg1", "darg", DOH_REPLACE_FIRST);
|
||||||
it is not easy to do it for all the languages at once*/
|
|
||||||
Printf(f->code, "if (!darg1) return NULL;\n");
|
|
||||||
Replaceall(action,"arg1","darg1");
|
|
||||||
Replaceall(action,classtype,dirname);
|
|
||||||
Delete(dirname);
|
Delete(dirname);
|
||||||
Delete(dirdecl);
|
Delete(dirdecl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1735,9 +1735,17 @@ int Language::classHandler(Node *n) {
|
||||||
&& (n != parentnode)
|
&& (n != parentnode)
|
||||||
&& is_protected(method)) {
|
&& is_protected(method)) {
|
||||||
Node* m = Copy(method);
|
Node* m = Copy(method);
|
||||||
|
String* mdecl = Getattr(m,"decl");
|
||||||
Setattr(m,"parentNode", n);
|
Setattr(m,"parentNode", n);
|
||||||
/* ugly trick, to avoid an uglier one later on emit.*/
|
/* ugly trick, to avoid an uglier one later on emit. We take
|
||||||
Replace(Getattr(m,"decl"),"q(const).","",1);
|
the 'const' out from calling method to avoid the ugly const
|
||||||
|
casting latter. The casting from 'non-const' to 'const' is not
|
||||||
|
needed here, but it prevents the simple replacement of
|
||||||
|
arg1 by darg on emit.cxx.
|
||||||
|
*/
|
||||||
|
if (Strncmp(mdecl, "q(const).", 9)== 0)
|
||||||
|
Replace(mdecl,"q(const).","", DOH_REPLACE_FIRST);
|
||||||
|
|
||||||
cDeclaration(m);
|
cDeclaration(m);
|
||||||
Delete(m);
|
Delete(m);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue