Fix director operator pointer casts
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9536 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
44e0d5eb5f
commit
599d64e188
7 changed files with 83 additions and 111 deletions
|
|
@ -3252,23 +3252,13 @@ public:
|
|||
|
||||
/* header declaration, start wrapper definition */
|
||||
String *target;
|
||||
|
||||
target = Swig_method_decl(decl, qualified_name, l, 0, 0);
|
||||
String *rtype = SwigType_str(type, 0);
|
||||
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(w->def, "%s", target);
|
||||
else
|
||||
Printf(w->def, "%s %s", rtype, target);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s", target);
|
||||
Delete(qualified_name);
|
||||
Delete(target);
|
||||
|
||||
target = Swig_method_decl(decl, name, l, 0, 1);
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(declaration, " virtual %s", target);
|
||||
else
|
||||
Printf(declaration, " virtual %s %s", rtype, target);
|
||||
Delete(rtype);
|
||||
target = Swig_method_decl(rtype, decl, name, l, 0, 1);
|
||||
Printf(declaration, " virtual %s", target);
|
||||
Delete(target);
|
||||
|
||||
// Get any Java exception classes in the throws typemap
|
||||
|
|
@ -3462,7 +3452,7 @@ public:
|
|||
/* constructor */
|
||||
{
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 0);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
String *call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
String *classtype = SwigType_namestr(Getattr(n, "name"));
|
||||
|
||||
|
|
@ -3477,7 +3467,7 @@ public:
|
|||
|
||||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 1);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ String *Swig_method_call(String_or_char *name, ParmList *parms) {
|
|||
*
|
||||
*/
|
||||
|
||||
String *Swig_method_decl(SwigType *s, const String_or_char *id, List *args, int strip, int values) {
|
||||
String *Swig_method_decl(SwigType *returntype, SwigType *decl, const String_or_char *id, List *args, int strip, int values) {
|
||||
String *result;
|
||||
List *elements;
|
||||
String *element = 0, *nextelement;
|
||||
|
|
@ -143,7 +143,7 @@ String *Swig_method_decl(SwigType *s, const String_or_char *id, List *args, int
|
|||
result = NewString("");
|
||||
}
|
||||
|
||||
elements = SwigType_split(s);
|
||||
elements = SwigType_split(decl);
|
||||
nelements = Len(elements);
|
||||
if (nelements > 0) {
|
||||
element = Getitem(elements, 0);
|
||||
|
|
@ -172,31 +172,6 @@ String *Swig_method_decl(SwigType *s, const String_or_char *id, List *args, int
|
|||
}
|
||||
Delete(q);
|
||||
}
|
||||
} else if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
} else if (SwigType_ismemberpointer(element)) {
|
||||
String *q;
|
||||
q = SwigType_parm(element);
|
||||
Insert(result, 0, "::*");
|
||||
Insert(result, 0, q);
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
Delete(q);
|
||||
} else if (SwigType_isreference(element)) {
|
||||
Insert(result, 0, "&");
|
||||
} else if (SwigType_isarray(element)) {
|
||||
DOH *size;
|
||||
Append(result, "[");
|
||||
size = SwigType_parm(element);
|
||||
Append(result, size);
|
||||
Append(result, "]");
|
||||
Delete(size);
|
||||
} else if (SwigType_isfunction(element)) {
|
||||
Parm *parm;
|
||||
String *p;
|
||||
|
|
@ -224,19 +199,48 @@ String *Swig_method_decl(SwigType *s, const String_or_char *id, List *args, int
|
|||
Append(result, ", ");
|
||||
}
|
||||
Append(result, ")");
|
||||
} else {
|
||||
if (Strcmp(element, "v(...)") == 0) {
|
||||
Insert(result, 0, "...");
|
||||
} else if (returntype) { // This check is intended for conversion operators to a pointer/reference which needs the pointer/reference ignoring in the declaration
|
||||
if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
} else if (SwigType_ismemberpointer(element)) {
|
||||
String *q;
|
||||
q = SwigType_parm(element);
|
||||
Insert(result, 0, "::*");
|
||||
Insert(result, 0, q);
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
Delete(q);
|
||||
} else if (SwigType_isreference(element)) {
|
||||
Insert(result, 0, "&");
|
||||
} else if (SwigType_isarray(element)) {
|
||||
DOH *size;
|
||||
Append(result, "[");
|
||||
size = SwigType_parm(element);
|
||||
Append(result, size);
|
||||
Append(result, "]");
|
||||
Delete(size);
|
||||
} else {
|
||||
String *bs = SwigType_namestr(element);
|
||||
Insert(result, 0, " ");
|
||||
Insert(result, 0, bs);
|
||||
Delete(bs);
|
||||
if (Strcmp(element, "v(...)") == 0) {
|
||||
Insert(result, 0, "...");
|
||||
} else {
|
||||
String *bs = SwigType_namestr(element);
|
||||
Insert(result, 0, " ");
|
||||
Insert(result, 0, bs);
|
||||
Delete(bs);
|
||||
}
|
||||
}
|
||||
}
|
||||
element = nextelement;
|
||||
}
|
||||
|
||||
Delete(elements);
|
||||
|
||||
if (is_const) {
|
||||
if (is_func) {
|
||||
Append(result, " ");
|
||||
|
|
@ -245,6 +249,15 @@ String *Swig_method_decl(SwigType *s, const String_or_char *id, List *args, int
|
|||
Insert(result, 0, "const ");
|
||||
}
|
||||
}
|
||||
|
||||
Chop(result);
|
||||
|
||||
if (returntype) {
|
||||
Insert(result, 0, " ");
|
||||
String *rtype = SwigType_str(returntype, 0);
|
||||
Insert(result, 0, rtype);
|
||||
Delete(rtype);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3370,23 +3370,13 @@ public:
|
|||
|
||||
/* header declaration, start wrapper definition */
|
||||
String *target;
|
||||
|
||||
target = Swig_method_decl(decl, qualified_name, l, 0, 0);
|
||||
String *rtype = SwigType_str(type, 0);
|
||||
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(w->def, "%s", target);
|
||||
else
|
||||
Printf(w->def, "%s %s", rtype, target);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s", target);
|
||||
Delete(qualified_name);
|
||||
Delete(target);
|
||||
|
||||
target = Swig_method_decl(decl, name, l, 0, 1);
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(declaration, " virtual %s", target);
|
||||
else
|
||||
Printf(declaration, " virtual %s %s", rtype, target);
|
||||
Delete(rtype);
|
||||
target = Swig_method_decl(rtype, decl, name, l, 0, 1);
|
||||
Printf(declaration, " virtual %s", target);
|
||||
Delete(target);
|
||||
|
||||
// Get any Java exception classes in the throws typemap
|
||||
|
|
@ -3613,7 +3603,7 @@ public:
|
|||
/* constructor */
|
||||
{
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 0);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
String *call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
String *classtype = SwigType_namestr(Getattr(n, "name"));
|
||||
|
||||
|
|
@ -3627,7 +3617,7 @@ public:
|
|||
|
||||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 1);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1440,20 +1440,14 @@ public:
|
|||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
target = Swig_method_decl(decl, qualified_name, l, 0, 0);
|
||||
String *rtype = SwigType_str(type, 0);
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(w->def, "%s {", target);
|
||||
else
|
||||
Printf(w->def, "%s %s {", rtype, target);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s {", target);
|
||||
Delete(qualified_name);
|
||||
Delete(target);
|
||||
/* header declaration */
|
||||
target = Swig_method_decl(decl, name, l, 0, 1);
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(declaration, " virtual %s;", target);
|
||||
else
|
||||
Printf(declaration, " virtual %s %s;\n", rtype, target);
|
||||
target = Swig_method_decl(rtype, decl, name, l, 0, 1);
|
||||
Printf(declaration, " virtual %s;", target);
|
||||
Delete(target);
|
||||
|
||||
/* declare method return value
|
||||
|
|
@ -1715,7 +1709,6 @@ public:
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(rtype);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
|
|
@ -1751,7 +1744,7 @@ public:
|
|||
Wrapper *w = NewWrapper();
|
||||
String *call;
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 0);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self) { }", classname, target, call);
|
||||
Delete(target);
|
||||
|
|
@ -1762,7 +1755,7 @@ public:
|
|||
|
||||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 1);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2362,7 +2362,7 @@ public:
|
|||
Wrapper *w = NewWrapper();
|
||||
String *call;
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 0);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self) { \n", classname, target, call);
|
||||
Printf(w->def, " SWIG_DIRECTOR_RGTR((%s *)this, this); \n", basetype);
|
||||
|
|
@ -2375,7 +2375,7 @@ public:
|
|||
|
||||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 1);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
@ -3305,20 +3305,14 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
target = Swig_method_decl(decl, qualified_name, l, 0, 0);
|
||||
String *rtype = SwigType_str(type, 0);
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(w->def, "%s", target);
|
||||
else
|
||||
Printf(w->def, "%s %s", rtype, target);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s", target);
|
||||
Delete(qualified_name);
|
||||
Delete(target);
|
||||
/* header declaration */
|
||||
target = Swig_method_decl(decl, name, l, 0, 1);
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(declaration, " virtual %s", target);
|
||||
else
|
||||
Printf(declaration, " virtual %s %s", rtype, target);
|
||||
target = Swig_method_decl(rtype, decl, name, l, 0, 1);
|
||||
Printf(declaration, " virtual %s", target);
|
||||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
|
|
@ -3737,7 +3731,6 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(rtype);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
|
|
|
|||
|
|
@ -2073,7 +2073,7 @@ public:
|
|||
Wrapper *w = NewWrapper();
|
||||
String *call;
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 0);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self) { }", classname, target, call);
|
||||
Delete(target);
|
||||
|
|
@ -2084,7 +2084,7 @@ public:
|
|||
|
||||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(decl, classname, parms, 0, 1);
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
@ -2264,20 +2264,14 @@ public:
|
|||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
target = Swig_method_decl(decl, qualified_name, l, 0, 0);
|
||||
String *rtype = SwigType_str(type, 0);
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(w->def, "%s", target);
|
||||
else
|
||||
Printf(w->def, "%s %s", rtype, target);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s", target);
|
||||
Delete(qualified_name);
|
||||
Delete(target);
|
||||
/* header declaration */
|
||||
target = Swig_method_decl(decl, name, l, 0, 1);
|
||||
if (Getattr(n, "conversion_operator"))
|
||||
Printf(declaration, " virtual %s", target);
|
||||
else
|
||||
Printf(declaration, " virtual %s %s", rtype, target);
|
||||
target = Swig_method_decl(rtype, decl, name, l, 0, 1);
|
||||
Printf(declaration, " virtual %s", target);
|
||||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
|
|
@ -2579,7 +2573,6 @@ public:
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(rtype);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ String *Swig_csuperclass_call(String *base, String *method, ParmList *l);
|
|||
String *Swig_class_declaration(Node *n, String *name);
|
||||
String *Swig_class_name(Node *n);
|
||||
String *Swig_method_call(String_or_char *name, ParmList *parms);
|
||||
String *Swig_method_decl(SwigType *s, const String_or_char *id, List *args, int strip, int values);
|
||||
String *Swig_method_decl(SwigType *rtype, SwigType *decl, const String_or_char *id, List *args, int strip, int values);
|
||||
String *Swig_director_declaration(Node *n);
|
||||
/* directors.cxx end */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue