Fix director typemap searching so that a typemap specified with a name will be correctly matched. Previously the name was ignored during the typemap search. Implemented by ensuring the 'type' attribute in the Node is set up correctly and using the usual Swig_typemap_lookup on the Node.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13873 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-10-27 17:37:34 +00:00
commit f6229d4b73
12 changed files with 201 additions and 348 deletions

View file

@ -4,6 +4,11 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.9 (in progress) Version 2.0.9 (in progress)
=========================== ===========================
2012-10-26: wsfulton
Fix director typemap searching so that a typemap specified with a name will be correctly matched. Previously
the name was ignored during the typemap search. Applies to the following list of typemaps:
directorout, csdirectorout, cstype, imtype, ctype, ddirectorout, dtype, gotype, jtype, jni, javadirectorout.
2012-10-11: wsfulton 2012-10-11: wsfulton
Most of the special variables available for use in %exception are now also available for expansion in Most of the special variables available for use in %exception are now also available for expansion in
%extend blocks. These are: $name $symname $overname $decl $fulldecl $parentname $parentsymname, see docs %extend blocks. These are: $name $symname $overname $decl $fulldecl $parentname $parentsymname, see docs

View file

@ -0,0 +1,48 @@
// Test named output typemaps used in directors are found during the typematch search
%module(directors="1") typemap_directorout
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Class1;
%feature("director");
%typemap(out) MyType & %{ WILL_NOT_COMPILE %}
%typemap(out) MyType &USEME = SWIGTYPE &;
%typemap(out) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(out, MyType &USEME) /* special end */ %}
%typemap(directorout) MyType & %{ WILL_NOT_COMPILE %}
// Can't use the %typemap(directorout) MyType & = SWIGTYPE & approach as non-director languages don't define any directorout typemaps
%typemap(directorout) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $input = 0; /* special end */ %}
#ifdef SWIGCSHARP
%typemap(csdirectorout) MyType & %{ WILL_NOT_COMPILE %}
%typemap(csdirectorout) MyType &USEME = SWIGTYPE &;
%typemap(csdirectorout) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(csdirectorout, MyType &USEME) /* special end */ %}
#endif
#ifdef SWIGD
%typemap(ddirectorout) MyType & %{ WILL_NOT_COMPILE %}
%typemap(ddirectorout) MyType &USEME = SWIGTYPE &;
%typemap(ddirectorout) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(ddirectorout, MyType &USEME) /* special end */ %}
#endif
#ifdef SWIGJAVA
%typemap(javadirectorout) MyType & %{ WILL_NOT_COMPILE %}
%typemap(javadirectorout) MyType &USEME = SWIGTYPE &;
%typemap(javadirectorout) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(javadirectorout, MyType &USEME) /* special end */ %}
#endif
%inline %{
typedef int MyType;
class Class1
{
MyType mt;
public:
Class1() : mt() {}
virtual MyType & foo1() { return mt; }
virtual MyType & foo2(int parm1) { return mt; }
virtual MyType & foo2() { return mt; }
virtual ~Class1() {}
};
%}

View file

@ -3449,13 +3449,11 @@ public:
* --------------------------------------------------------------- */ * --------------------------------------------------------------- */
int classDirectorMethod(Node *n, Node *parent, String *super) { int classDirectorMethod(Node *n, Node *parent, String *super) {
String *empty_str = NewString("");
String *classname = Getattr(parent, "sym:name"); String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name"); String *c_classname = Getattr(parent, "name");
String *name = Getattr(n, "name"); String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
SwigType *type = Getattr(n, "type"); SwigType *returntype = Getattr(n, "type");
SwigType *returntype = Getattr(n, "returntype");
String *overloaded_name = getOverloadedName(n); String *overloaded_name = getOverloadedName(n);
String *storage = Getattr(n, "storage"); String *storage = Getattr(n, "storage");
String *value = Getattr(n, "value"); String *value = Getattr(n, "value");
@ -3544,14 +3542,12 @@ public:
} }
/* Create the intermediate class wrapper */ /* Create the intermediate class wrapper */
Parm *tp = NewParm(returntype, empty_str, n); tm = Swig_typemap_lookup("imtype", n, "", 0);
tm = Swig_typemap_lookup("imtype", tp, "", 0);
if (tm) { if (tm) {
String *imtypeout = Getattr(tp, "tmap:imtype:out"); // the type in the imtype typemap's out attribute overrides the type in the typemap String *imtypeout = Getattr(n, "tmap:imtype:out"); // the type in the imtype typemap's out attribute overrides the type in the typemap
if (imtypeout) if (imtypeout)
tm = imtypeout; tm = imtypeout;
const String *im_directoroutattributes = Getattr(tp, "tmap:imtype:directoroutattributes"); const String *im_directoroutattributes = Getattr(n, "tmap:imtype:directoroutattributes");
if (im_directoroutattributes) { if (im_directoroutattributes) {
Printf(callback_def, " %s\n", im_directoroutattributes); Printf(callback_def, " %s\n", im_directoroutattributes);
Printf(director_delegate_definitions, " %s\n", im_directoroutattributes); Printf(director_delegate_definitions, " %s\n", im_directoroutattributes);
@ -3564,10 +3560,7 @@ public:
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0)); Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
} }
Parm *retpm = NewParm(returntype, empty_str, n); if ((c_ret_type = Swig_typemap_lookup("ctype", n, "", 0))) {
if ((c_ret_type = Swig_typemap_lookup("ctype", retpm, "", 0))) {
if (!is_void && !ignored_method) { if (!is_void && !ignored_method) {
String *jretval_decl = NewStringf("%s jresult", c_ret_type); String *jretval_decl = NewStringf("%s jresult", c_ret_type);
Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL); Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL);
@ -3578,8 +3571,6 @@ public:
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false; output_director = false;
} }
Delete(retpm);
} }
Swig_director_parms_fixup(l); Swig_director_parms_fixup(l);
@ -3731,7 +3722,7 @@ public:
/* header declaration, start wrapper definition */ /* header declaration, start wrapper definition */
String *target; String *target;
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
Printf(w->def, "%s", target); Printf(w->def, "%s", target);
Delete(qualified_name); Delete(qualified_name);
@ -3778,9 +3769,7 @@ public:
String *upcall = NewStringf("%s(%s)", symname, imcall_args); String *upcall = NewStringf("%s(%s)", symname, imcall_args);
if (!is_void) { if (!is_void) {
Parm *tp = NewParm(returntype, empty_str, n); if ((tm = Swig_typemap_lookup("csdirectorout", n, "", 0))) {
if ((tm = Swig_typemap_lookup("csdirectorout", tp, "", 0))) {
substituteClassname(returntype, tm); substituteClassname(returntype, tm);
Replaceall(tm, "$cscall", upcall); Replaceall(tm, "$cscall", upcall);
@ -3788,7 +3777,6 @@ public:
} }
Delete(tm); Delete(tm);
Delete(tp);
} else } else
Printf(callback_code, " %s;\n", upcall); Printf(callback_code, " %s;\n", upcall);
@ -3804,10 +3792,9 @@ public:
if (!is_void) { if (!is_void) {
String *jresult_str = NewString("jresult"); String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result"); String *result_str = NewString("c_result");
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */ /* Copy jresult into c_result... */
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) { if ((tm = Swig_typemap_lookup("directorout", n, result_str, w))) {
Replaceall(tm, "$input", jresult_str); Replaceall(tm, "$input", jresult_str);
Replaceall(tm, "$result", result_str); Replaceall(tm, "$result", result_str);
Printf(w->code, "%s\n", tm); Printf(w->code, "%s\n", tm);
@ -3818,7 +3805,6 @@ public:
output_director = false; output_director = false;
} }
Delete(tp);
Delete(jresult_str); Delete(jresult_str);
Delete(result_str); Delete(result_str);
} }

View file

@ -1927,13 +1927,11 @@ public:
* underlying D object. * underlying D object.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
virtual int classDirectorMethod(Node *n, Node *parent, String *super) { virtual int classDirectorMethod(Node *n, Node *parent, String *super) {
String *empty_str = NewString("");
String *classname = Getattr(parent, "sym:name"); String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name"); String *c_classname = Getattr(parent, "name");
String *name = Getattr(n, "name"); String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
SwigType *type = Getattr(n, "type"); SwigType *returntype = Getattr(n, "type");
SwigType *returntype = Getattr(n, "returntype");
String *overloaded_name = getOverloadedName(n); String *overloaded_name = getOverloadedName(n);
String *storage = Getattr(n, "storage"); String *storage = Getattr(n, "storage");
String *value = Getattr(n, "value"); String *value = Getattr(n, "value");
@ -2022,11 +2020,9 @@ public:
} }
/* Create the intermediate class wrapper */ /* Create the intermediate class wrapper */
Parm *tp = NewParm(returntype, empty_str, n); tm = lookupDTypemap(n, "imtype");
tm = lookupDTypemap(tp, "imtype");
if (tm) { if (tm) {
String *imtypeout = Getattr(tp, "tmap:imtype:out"); String *imtypeout = Getattr(n, "tmap:imtype:out");
if (imtypeout) { if (imtypeout) {
// The type in the imtype typemap's out attribute overrides the type // The type in the imtype typemap's out attribute overrides the type
// in the typemap. // in the typemap.
@ -2039,9 +2035,7 @@ public:
"No imtype typemap defined for %s\n", SwigType_str(returntype, 0)); "No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
} }
Parm *retpm = NewParm(returntype, empty_str, n); if ((c_ret_type = Swig_typemap_lookup("ctype", n, "", 0))) {
if ((c_ret_type = Swig_typemap_lookup("ctype", retpm, "", 0))) {
if (!is_void && !ignored_method) { if (!is_void && !ignored_method) {
String *jretval_decl = NewStringf("%s jresult", c_ret_type); String *jretval_decl = NewStringf("%s jresult", c_ret_type);
Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL); Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL);
@ -2053,8 +2047,6 @@ public:
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false; output_director = false;
} }
Delete(retpm);
} }
Swig_director_parms_fixup(l); Swig_director_parms_fixup(l);
@ -2213,7 +2205,7 @@ public:
/* header declaration, start wrapper definition */ /* header declaration, start wrapper definition */
String *target; String *target;
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
Printf(w->def, "%s", target); Printf(w->def, "%s", target);
Delete(qualified_name); Delete(qualified_name);
@ -2259,16 +2251,10 @@ public:
String *upcall = NewStringf("(cast(%s)dObject).%s(%s)", classname, symname, imcall_args); String *upcall = NewStringf("(cast(%s)dObject).%s(%s)", classname, symname, imcall_args);
if (!is_void) { if (!is_void) {
Parm *tp = NewParm(returntype, empty_str, n); if ((tm = lookupDTypemap(n, "ddirectorout"))) {
// RESEARCH: What happens if there is no ddirectorout typemap?
if ((tm = lookupDTypemap(tp, "ddirectorout"))) {
Replaceall(tm, "$dcall", upcall); Replaceall(tm, "$dcall", upcall);
Printf(callback_code, " return %s;\n", tm); Printf(callback_code, " return %s;\n", tm);
} }
Delete(tp);
} else { } else {
Printf(callback_code, " %s;\n", upcall); Printf(callback_code, " %s;\n", upcall);
} }
@ -2285,11 +2271,9 @@ public:
if (!is_void) { if (!is_void) {
String *jresult_str = NewString("jresult"); String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result"); String *result_str = NewString("c_result");
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */ /* Copy jresult into c_result... */
// FIXME: lookupDTypemap? if ((tm = Swig_typemap_lookup("directorout", n, result_str, w))) {
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {
Replaceall(tm, "$input", jresult_str); Replaceall(tm, "$input", jresult_str);
Replaceall(tm, "$result", result_str); Replaceall(tm, "$result", result_str);
Printf(w->code, "%s\n", tm); Printf(w->code, "%s\n", tm);
@ -2300,7 +2284,6 @@ public:
output_director = false; output_director = false;
} }
Delete(tp);
Delete(jresult_str); Delete(jresult_str);
Delete(result_str); Delete(result_str);
} }
@ -2365,8 +2348,7 @@ public:
// We cannot directly use n here because its »type« attribute does not // We cannot directly use n here because its »type« attribute does not
// the full return type any longer after Language::functionHandler has // the full return type any longer after Language::functionHandler has
// returned. // returned.
Parm *tp = NewParm(returntype, empty_str, n); String *dp_return_type = lookupDTypemap(n, "dtype");
String *dp_return_type = lookupDTypemap(tp, "dtype");
if (dp_return_type) { if (dp_return_type) {
String *dtypeout = Getattr(n, "tmap:dtype:out"); String *dtypeout = Getattr(n, "tmap:dtype:out");
if (dtypeout) { if (dtypeout) {
@ -2377,7 +2359,7 @@ public:
} }
} else { } else {
Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number, Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
"No dtype typemap defined for %s\n", SwigType_str(type, 0)); "No dtype typemap defined for %s\n", SwigType_str(returntype, 0));
dp_return_type = NewString(""); dp_return_type = NewString("");
} }

View file

@ -2853,7 +2853,6 @@ private:
int classDirectorMethod(Node *n, Node *parent, String *super) { int classDirectorMethod(Node *n, Node *parent, String *super) {
bool is_ignored = GetFlag(n, "feature:ignore") ? true : false; bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0);
// We don't need explicit calls. // We don't need explicit calls.
if (GetFlag(n, "explicitcall")) { if (GetFlag(n, "explicitcall")) {
@ -2866,18 +2865,8 @@ private:
name = Getattr(n, "name"); name = Getattr(n, "name");
} }
if (Getattr(class_methods, name)) { bool overloaded = Getattr(n, "sym:overloaded") && !Getattr(n, "explicitcallnode");
// We need to emit a pure virtual function, even if it is if (!overloaded) {
// overloaded. Otherwise we won't be able to create an instance
// of the director class. The function doesn't need to actually
// do anything.
if (!is_pure_virtual || Getattr(n, "sym:overloaded")) {
return SWIG_OK;
}
}
Setattr(class_methods, name, NewString(""));
if (!Getattr(n, "sym:overloaded")) {
int r = oneClassDirectorMethod(n, parent, super); int r = oneClassDirectorMethod(n, parent, super);
if (r != SWIG_OK) { if (r != SWIG_OK) {
return r; return r;
@ -2888,47 +2877,54 @@ private:
// class_methods so that we correctly handle cases where a // class_methods so that we correctly handle cases where a
// function in one class hides a function of the same name in a // function in one class hides a function of the same name in a
// parent class. // parent class.
for (Node *on = Getattr(n, "sym:overloaded"); on; on = Getattr(on, "sym:nextSibling")) { if (!Getattr(class_methods, name)) {
int r = oneClassDirectorMethod(on, parent, super); for (Node *on = Getattr(n, "sym:overloaded"); on; on = Getattr(on, "sym:nextSibling")) {
// Swig_overload_rank expects wrap:name and wrap:parms to be
// set.
String *wn = Swig_name_wrapper(Getattr(on, "sym:name"));
Append(wn, Getattr(on, "sym:overname"));
Setattr(on, "wrap:name", wn);
Delete(wn);
Setattr(on, "wrap:parms", Getattr(on, "parms"));
}
}
int r = oneClassDirectorMethod(n, parent, super);
if (r != SWIG_OK) {
return r;
}
if (!Getattr(n, "sym:nextSibling"))
{
// Last overloaded function
Node *on = Getattr(n, "sym:overloaded");
bool is_static = isStatic(on);
String *cn = exportedName(Getattr(parent, "sym:name"));
String *go_name = buildGoName(name, is_static, false);
String *director_struct_name = NewString("_swig_Director");
Append(director_struct_name, cn);
int r = makeDispatchFunction(on, go_name, director_struct_name, is_static, director_struct_name, false);
if (r != SWIG_OK) { if (r != SWIG_OK) {
return r; return r;
} }
// Swig_overload_rank expects wrap:name and wrap:parms to be String *go_upcall = NewString("Director");
// set. Append(go_upcall, cn);
String *wn = Swig_name_wrapper(Getattr(on, "sym:name")); Append(go_upcall, go_name);
Append(wn, Getattr(on, "sym:overname")); r = makeDispatchFunction(on, go_upcall, director_struct_name, is_static, director_struct_name, true);
Setattr(on, "wrap:name", wn); if (r != SWIG_OK) {
Delete(wn); return r;
Setattr(on, "wrap:parms", Getattr(on, "parms")); }
Delete(cn);
Delete(go_name);
Delete(director_struct_name);
Delete(go_upcall);
} }
bool is_static = isStatic(n);
String *cn = exportedName(Getattr(parent, "sym:name"));
String *go_name = buildGoName(name, is_static, false);
String *director_struct_name = NewString("_swig_Director");
Append(director_struct_name, cn);
int r = makeDispatchFunction(n, go_name, director_struct_name, is_static, director_struct_name, false);
if (r != SWIG_OK) {
return r;
}
String *go_upcall = NewString("Director");
Append(go_upcall, cn);
Append(go_upcall, go_name);
r = makeDispatchFunction(n, go_upcall, director_struct_name, is_static, director_struct_name, true);
if (r != SWIG_OK) {
return r;
}
Delete(cn);
Delete(go_name);
Delete(director_struct_name);
Delete(go_upcall);
} }
Setattr(class_methods, name, NewString(""));
return SWIG_OK; return SWIG_OK;
} }
@ -2980,17 +2976,8 @@ private:
Swig_typemap_attach_parms("gotype", parms, NULL); Swig_typemap_attach_parms("gotype", parms, NULL);
int parm_count = emit_num_arguments(parms); int parm_count = emit_num_arguments(parms);
SwigType *result = Getattr(n, "returntype"); SwigType *result = Getattr(n, "type");
if (!result) { SwigType *returntype = result;
// This can happen when following overloads.
result = NewString(Getattr(n, "type"));
SwigType_push(result, Getattr(n, "decl"));
if (SwigType_isqualifier(result)) {
Delete(SwigType_pop(result));
}
Delete(SwigType_pop_function(result));
Setattr(n, "returntype", result);
}
// Save the type for overload processing. // Save the type for overload processing.
Setattr(n, "go:type", result); Setattr(n, "go:type", result);
@ -3177,7 +3164,8 @@ private:
if (overname) { if (overname) {
Append(upcall_method_name, overname); Append(upcall_method_name, overname);
} }
String *upcall_decl = Swig_method_decl(Getattr(n, "type"), Getattr(n, "decl"), upcall_method_name, parms, 0, 0); SwigType *rtype = Getattr(n, "classDirectorMethods:type");
String *upcall_decl = Swig_method_decl(rtype, Getattr(n, "decl"), upcall_method_name, parms, 0, 0);
Printv(f_c_directors_h, " ", upcall_decl, " {\n", NULL); Printv(f_c_directors_h, " ", upcall_decl, " {\n", NULL);
Delete(upcall_decl); Delete(upcall_decl);
@ -3450,7 +3438,7 @@ private:
if (!is_ignored || is_pure_virtual) { if (!is_ignored || is_pure_virtual) {
// Declare the method for the director class. // Declare the method for the director class.
SwigType *rtype = (Getattr(n, "conversion_operator") ? NULL : Getattr(n, "type")); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
String *decl = Swig_method_decl(rtype, Getattr(n, "decl"), Getattr(n, "name"), parms, 0, 0); String *decl = Swig_method_decl(rtype, Getattr(n, "decl"), Getattr(n, "name"), parms, 0, 0);
Printv(f_c_directors_h, " virtual ", decl, NULL); Printv(f_c_directors_h, " virtual ", decl, NULL);
Delete(decl); Delete(decl);
@ -3474,7 +3462,7 @@ private:
Printv(w->def, " {\n", NULL); Printv(w->def, " {\n", NULL);
if (SwigType_type(result) != T_VOID) { if (SwigType_type(result) != T_VOID) {
Wrapper_add_local(w, "c_result", SwigType_lstr(Getattr(n, "returntype"), "c_result")); Wrapper_add_local(w, "c_result", SwigType_lstr(returntype, "c_result"));
} }
if (!is_ignored) { if (!is_ignored) {
@ -3530,9 +3518,8 @@ private:
Printv(w->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL); Printv(w->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL);
if (SwigType_type(result) != T_VOID) { if (SwigType_type(result) != T_VOID) {
String *rname = NewString("c_result"); String *result_str = NewString("c_result");
Parm *rp = NewParm(Getattr(n, "returntype"), rname, n); String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL);
if (!tm) { if (!tm) {
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
"Unable to use type %s as director method result\n", SwigType_str(result, 0)); "Unable to use type %s as director method result\n", SwigType_str(result, 0));
@ -3541,13 +3528,12 @@ private:
Replaceall(tm, "$input", swig_a_result); Replaceall(tm, "$input", swig_a_result);
Replaceall(tm, "$result", "c_result"); Replaceall(tm, "$result", "c_result");
Printv(w->code, " ", tm, "\n", NULL); Printv(w->code, " ", tm, "\n", NULL);
String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); String *retstr = SwigType_rcaststr(returntype, "c_result");
Printv(w->code, " return ", retstr, ";\n", NULL); Printv(w->code, " return ", retstr, ";\n", NULL);
Delete(retstr); Delete(retstr);
Delete(tm); Delete(tm);
} }
Delete(rp); Delete(result_str);
Delete(rname);
} }
// The C wrapper code which calls the Go function. // The C wrapper code which calls the Go function.
@ -3605,9 +3591,8 @@ private:
Printv(w->code, callback_wname, "(go_val", args, ");\n", NULL); Printv(w->code, callback_wname, "(go_val", args, ");\n", NULL);
if (SwigType_type(result) != T_VOID) { if (SwigType_type(result) != T_VOID) {
String *rname = NewString("c_result"); String *result_str = NewString("c_result");
Parm *rp = NewParm(Getattr(n, "returntype"), rname, n); String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL);
if (!tm) { if (!tm) {
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
"Unable to use type %s as director method result\n", SwigType_str(result, 0)); "Unable to use type %s as director method result\n", SwigType_str(result, 0));
@ -3615,13 +3600,12 @@ private:
Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$input", Swig_cresult_name());
Replaceall(tm, "$result", "c_result"); Replaceall(tm, "$result", "c_result");
Printv(w->code, " ", tm, "\n", NULL); Printv(w->code, " ", tm, "\n", NULL);
String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); String *retstr = SwigType_rcaststr(returntype, "c_result");
Printv(w->code, " return ", retstr, ";\n", NULL); Printv(w->code, " return ", retstr, ";\n", NULL);
Delete(retstr); Delete(retstr);
Delete(tm); Delete(tm);
} }
Delete(rp); Delete(result_str);
Delete(rname);
} }
} }
@ -3641,7 +3625,7 @@ private:
assert(is_pure_virtual); assert(is_pure_virtual);
Printv(w->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL); Printv(w->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL);
if (SwigType_type(result) != T_VOID) { if (SwigType_type(result) != T_VOID) {
String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); String *retstr = SwigType_rcaststr(returntype, "c_result");
Printv(w->code, " return ", retstr, ";\n", NULL); Printv(w->code, " return ", retstr, ";\n", NULL);
Delete(retstr); Delete(retstr);
} }
@ -3783,7 +3767,8 @@ private:
mismatch = false; mismatch = false;
bool any_void = false; bool any_void = false;
for (int i = 0; i < nfunc; ++i) { for (int i = 0; i < nfunc; ++i) {
Node *ni = Getitem(dispatch, i); Node *nn = Getitem(dispatch, i);
Node *ni = Getattr(nn, "directorNode") ? Getattr(nn, "directorNode") : nn;
SwigType *result = Getattr(ni, "go:type"); SwigType *result = Getattr(ni, "go:type");
assert(result); assert(result);
@ -3862,7 +3847,8 @@ private:
for (int i = 0; i < nfunc; ++i) { for (int i = 0; i < nfunc; ++i) {
int fn = 0; int fn = 0;
Node *ni = Getitem(dispatch, i); Node *nn = Getitem(dispatch, i);
Node *ni = Getattr(nn, "directorNode") ? Getattr(nn, "directorNode") : nn;
Parm *pi = Getattr(ni, "wrap:parms"); Parm *pi = Getattr(ni, "wrap:parms");
// If we are using a receiver, we want to ignore a leading self // If we are using a receiver, we want to ignore a leading self
@ -3892,7 +3878,8 @@ private:
// Build list of collisions with the same number of arguments. // Build list of collisions with the same number of arguments.
List *coll = NewList(); List *coll = NewList();
for (int k = i + 1; k < nfunc; ++k) { for (int k = i + 1; k < nfunc; ++k) {
Node *nk = Getitem(dispatch, k); Node *nnk = Getitem(dispatch, k);
Node *nk = Getattr(nnk, "directorNode") ? Getattr(nnk, "directorNode") : nnk;
Parm *pk = Getattr(nk, "wrap:parms"); Parm *pk = Getattr(nk, "wrap:parms");
if (use_receiver && pk && Getattr(pk, "self")) { if (use_receiver && pk && Getattr(pk, "self")) {
pk = getParm(pk); pk = getParm(pk);

View file

@ -3519,7 +3519,6 @@ public:
String *c_classname = Getattr(parent, "name"); String *c_classname = Getattr(parent, "name");
String *name = Getattr(n, "name"); String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
SwigType *type = Getattr(n, "type");
SwigType *returntype = Getattr(n, "returntype"); SwigType *returntype = Getattr(n, "returntype");
String *overloaded_name = getOverloadedName(n); String *overloaded_name = getOverloadedName(n);
String *storage = Getattr(n, "storage"); String *storage = Getattr(n, "storage");
@ -3616,9 +3615,7 @@ public:
} }
/* Create the intermediate class wrapper */ /* Create the intermediate class wrapper */
Parm *tp = NewParm(returntype, empty_str, n); tm = Swig_typemap_lookup("jtype", n, "", 0);
tm = Swig_typemap_lookup("jtype", tp, "", 0);
if (tm) { if (tm) {
Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, qualified_classname); Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, qualified_classname);
} else { } else {
@ -3628,7 +3625,8 @@ public:
String *cdesc = NULL; String *cdesc = NULL;
SwigType *covariant = Getattr(n, "covariant"); SwigType *covariant = Getattr(n, "covariant");
SwigType *adjustedreturntype = covariant ? covariant : returntype; SwigType *adjustedreturntype = covariant ? covariant : returntype;
Parm *adjustedreturntypeparm = NewParm(adjustedreturntype, empty_str, n); Parm *adjustedreturntypeparm = NewParm(adjustedreturntype, name, n);
// Setattr(adjustedreturntypeparm, "sym:symtab", Getattr(n, "sym:symtab"));
if ((tm = Swig_typemap_lookup("directorin", adjustedreturntypeparm, "", 0)) if ((tm = Swig_typemap_lookup("directorin", adjustedreturntypeparm, "", 0))
&& (cdesc = Getattr(adjustedreturntypeparm, "tmap:directorin:descriptor"))) { && (cdesc = Getattr(adjustedreturntypeparm, "tmap:directorin:descriptor"))) {
@ -3647,11 +3645,8 @@ public:
/* Get the JNI field descriptor for this return type, add the JNI field descriptor /* Get the JNI field descriptor for this return type, add the JNI field descriptor
to jniret_desc */ to jniret_desc */
if ((c_ret_type = Swig_typemap_lookup("jni", n, "", 0))) {
Parm *retpm = NewParm(returntype, empty_str, n); Parm *tp = NewParm(c_ret_type, name, n);
if ((c_ret_type = Swig_typemap_lookup("jni", retpm, "", 0))) {
Parm *tp = NewParm(c_ret_type, empty_str, n);
if (!is_void && !ignored_method) { if (!is_void && !ignored_method) {
String *jretval_decl = NewStringf("%s jresult", c_ret_type); String *jretval_decl = NewStringf("%s jresult", c_ret_type);
@ -3685,7 +3680,6 @@ public:
} }
Delete(adjustedreturntypeparm); Delete(adjustedreturntypeparm);
Delete(retpm);
Delete(qualified_classname); Delete(qualified_classname);
} }
@ -3755,7 +3749,7 @@ public:
} else { } else {
Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number,
"No or improper directorin typemap for type %s for use in %s::%s (skipping director method)\n", "No or improper directorin typemap for type %s for use in %s::%s (skipping director method)\n",
SwigType_str(type, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
output_director = false; output_director = false;
} }
@ -3879,7 +3873,6 @@ public:
output_director = false; output_director = false;
} }
Delete(tp);
} else { } else {
Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s for use in %s::%s (skipping director method)\n", Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
@ -3894,7 +3887,7 @@ public:
/* header declaration, start wrapper definition */ /* header declaration, start wrapper definition */
String *target; String *target;
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
Printf(w->def, "%s", target); Printf(w->def, "%s", target);
Delete(qualified_name); Delete(qualified_name);
@ -3944,21 +3937,18 @@ public:
addThrows(n, "feature:except", n); addThrows(n, "feature:except", n);
if (!is_void) { if (!is_void) {
Parm *tp = NewParm(returntype, empty_str, n); if ((tm = Swig_typemap_lookup("javadirectorout", n, "", 0))) {
addThrows(n, "tmap:javadirectorout", n);
if ((tm = Swig_typemap_lookup("javadirectorout", tp, "", 0))) {
addThrows(n, "tmap:javadirectorout", tp);
substituteClassname(returntype, tm); substituteClassname(returntype, tm);
Replaceall(tm, "$javacall", upcall); Replaceall(tm, "$javacall", upcall);
Printf(callback_code, " return %s;\n", tm); Printf(callback_code, " return %s;\n", tm);
} }
if ((tm = Swig_typemap_lookup("out", tp, "", 0))) if ((tm = Swig_typemap_lookup("out", n, "", 0)))
addThrows(n, "tmap:out", tp); addThrows(n, "tmap:out", n);
Delete(tm); Delete(tm);
Delete(tp);
} else } else
Printf(callback_code, " %s;\n", upcall); Printf(callback_code, " %s;\n", upcall);
@ -3988,11 +3978,10 @@ public:
if (!is_void) { if (!is_void) {
String *jresult_str = NewString("jresult"); String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result"); String *result_str = NewString("c_result");
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */ /* Copy jresult into c_result... */
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) { if ((tm = Swig_typemap_lookup("directorout", n, result_str, w))) {
addThrows(n, "tmap:directorout", tp); addThrows(n, "tmap:directorout", n);
Replaceall(tm, "$input", jresult_str); Replaceall(tm, "$input", jresult_str);
Replaceall(tm, "$result", result_str); Replaceall(tm, "$result", result_str);
Printf(w->code, "%s\n", tm); Printf(w->code, "%s\n", tm);
@ -4003,7 +3992,6 @@ public:
output_director = false; output_director = false;
} }
Delete(tp);
Delete(jresult_str); Delete(jresult_str);
Delete(result_str); Delete(result_str);
} }

View file

@ -2041,9 +2041,12 @@ int Language::classDirectorMethods(Node *n) {
if (!Cmp(type, "destructor")) { if (!Cmp(type, "destructor")) {
classDirectorDestructor(method); classDirectorDestructor(method);
} else { } else {
if (classDirectorMethod(method, n, fqdname) == SWIG_OK) { Swig_require("classDirectorMethods", method, "*type", NIL);
Setattr(item, "director", "1"); assert(Getattr(method, "returntype"));
} Setattr(method, "type", Getattr(method, "returntype"));
if (classDirectorMethod(method, n, fqdname) == SWIG_OK)
SetFlag(item, "director");
Swig_restore(method);
} }
} }

View file

@ -1380,63 +1380,41 @@ public:
int classDirectorMethod(Node *n, Node *parent, String *super) { int classDirectorMethod(Node *n, Node *parent, String *super) {
int is_void = 0; int is_void = 0;
int is_pointer = 0; int is_pointer = 0;
String *storage; String *storage = Getattr(n, "storage");
String *value; String *value = Getattr(n, "value");
String *decl; String *decl = Getattr(n, "decl");
String *type; String *return_type = Getattr(n, "type");
String *name; String *name = Getattr(n, "name");
String *classname; String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name"); String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
String *declaration; String *declaration = NewString("");
ParmList *l; ParmList *l = Getattr(n, "parms");
Wrapper *w; Wrapper *w = NewWrapper();
String *tm; String *tm;
String *wrap_args = NewString(""); String *wrap_args = NewString("");
String *return_type;
int status = SWIG_OK; int status = SWIG_OK;
int idx; int idx;
bool pure_virtual = false; bool pure_virtual = false;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
storage = Getattr(n, "storage");
value = Getattr(n, "value");
classname = Getattr(parent, "sym:name");
type = Getattr(n, "type");
name = Getattr(n, "name");
if (Cmp(storage, "virtual") == 0) { if (Cmp(storage, "virtual") == 0) {
if (Cmp(value, "0") == 0) { if (Cmp(value, "0") == 0) {
pure_virtual = true; pure_virtual = true;
} }
} }
w = NewWrapper();
declaration = NewString("");
Wrapper_add_local(w, "swig_result", "CAMLparam0();\n" "SWIG_CAMLlocal2(swig_result,args)"); Wrapper_add_local(w, "swig_result", "CAMLparam0();\n" "SWIG_CAMLlocal2(swig_result,args)");
/* determine if the method returns a pointer */ /* determine if the method returns a pointer */
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl); is_pointer = SwigType_ispointer_return(decl);
is_void = (!Cmp(type, "void") && !is_pointer); is_void = (!Cmp(return_type, "void") && !is_pointer);
/* form complete return type */
return_type = Copy(type);
{
SwigType *t = Copy(decl);
SwigType *f = 0;
f = SwigType_pop_function(t);
SwigType_push(return_type, t);
Delete(f);
Delete(t);
}
/* virtual method definition */ /* virtual method definition */
l = Getattr(n, "parms");
String *target; String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname); String *pclassname = NewStringf("SwigDirector_%s", classname);
String *qualified_name = NewStringf("%s::%s", pclassname, name); String *qualified_name = NewStringf("%s::%s", pclassname, name);
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
Printf(w->def, "%s {", target); Printf(w->def, "%s {", target);
Delete(qualified_name); Delete(qualified_name);
@ -1616,16 +1594,7 @@ public:
idx = 0; idx = 0;
/* this seems really silly. the node's type excludes
* qualifier/pointer/reference markers, which have to be retrieved
* from the decl field to construct return_type. but the typemap
* lookup routine uses the node's type, so we have to swap in and
* out the correct type. it's not just me, similar silliness also
* occurs in Language::cDeclaration().
*/
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "c_result", w); tm = Swig_typemap_lookup("directorout", n, "c_result", w);
Setattr(n, "type", type);
if (tm != 0) { if (tm != 0) {
Replaceall(tm, "$input", "swig_result"); Replaceall(tm, "$input", "swig_result");
/* TODO check this */ /* TODO check this */
@ -1704,7 +1673,6 @@ public:
/* clean up */ /* clean up */
Delete(wrap_args); Delete(wrap_args);
Delete(return_type);
Delete(pclassname); Delete(pclassname);
DelWrapper(w); DelWrapper(w);
return status; return status;

View file

@ -1247,18 +1247,17 @@ public:
int classDirectorMethod(Node *n, Node *parent, String *super) { int classDirectorMethod(Node *n, Node *parent, String *super) {
int is_void = 0; int is_void = 0;
int is_pointer = 0; int is_pointer = 0;
String *decl; String *decl = Getattr(n, "decl");
String *type; String *return_type = Getattr(n, "type");
String *name; String *name = Getattr(n, "name");
String *classname; String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name"); String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
String *declaration; String *declaration = NewString("");
ParmList *l; ParmList *l = Getattr(n, "parms");
Wrapper *w; Wrapper *w = NewWrapper();
String *tm; String *tm;
String *wrap_args = NewString(""); String *wrap_args = NewString("");
String *return_type;
String *value = Getattr(n, "value"); String *value = Getattr(n, "value");
String *storage = Getattr(n, "storage"); String *storage = Getattr(n, "storage");
bool pure_virtual = false; bool pure_virtual = false;
@ -1272,35 +1271,15 @@ public:
} }
} }
classname = Getattr(parent, "sym:name");
type = Getattr(n, "type");
name = Getattr(n, "name");
w = NewWrapper();
declaration = NewString("");
// determine if the method returns a pointer // determine if the method returns a pointer
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl); is_pointer = SwigType_ispointer_return(decl);
is_void = (!Cmp(type, "void") && !is_pointer); is_void = (!Cmp(return_type, "void") && !is_pointer);
// form complete return type
return_type = Copy(type);
{
SwigType *t = Copy(decl);
SwigType *f = 0;
f = SwigType_pop_function(t);
SwigType_push(return_type, t);
Delete(f);
Delete(t);
}
// virtual method definition // virtual method definition
l = Getattr(n, "parms");
String *target; String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname); String *pclassname = NewStringf("SwigDirector_%s", classname);
String *qualified_name = NewStringf("%s::%s", pclassname, name); String *qualified_name = NewStringf("%s::%s", pclassname, name);
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
Printf(w->def, "%s", target); Printf(w->def, "%s", target);
Delete(qualified_name); Delete(qualified_name);
@ -1449,9 +1428,7 @@ public:
"method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name); "method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name);
Printf(w->code, "}\n"); Printf(w->code, "}\n");
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
Setattr(n, "type", type);
if (tm != 0) { if (tm != 0) {
char temp[24]; char temp[24];
sprintf(temp, "out(%d)", idx); sprintf(temp, "out(%d)", idx);
@ -1531,7 +1508,6 @@ public:
} }
// clean up // clean up
Delete(wrap_args); Delete(wrap_args);
Delete(return_type);
Delete(pclassname); Delete(pclassname);
DelWrapper(w); DelWrapper(w);
return status; return status;

View file

@ -2415,18 +2415,17 @@ done:
int classDirectorMethod(Node *n, Node *parent, String *super) { int classDirectorMethod(Node *n, Node *parent, String *super) {
int is_void = 0; int is_void = 0;
int is_pointer = 0; int is_pointer = 0;
String *decl; String *decl = Getattr(n, "decl");
String *type; String *return_type = Getattr(n, "type");
String *name; String *name = Getattr(n, "name");
String *classname; String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name"); String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
String *declaration; String *declaration = NewStringEmpty();
ParmList *l; ParmList *l = Getattr(n, "parms");
Wrapper *w; Wrapper *w = NewWrapper();
String *tm; String *tm;
String *wrap_args = NewStringEmpty(); String *wrap_args = NewStringEmpty();
String *return_type;
String *value = Getattr(n, "value"); String *value = Getattr(n, "value");
String *storage = Getattr(n, "storage"); String *storage = Getattr(n, "storage");
bool pure_virtual = false; bool pure_virtual = false;
@ -2440,34 +2439,15 @@ done:
} }
} }
classname = Getattr(parent, "sym:name");
type = Getattr(n, "type");
name = Getattr(n, "name");
w = NewWrapper();
declaration = NewStringEmpty();
/* determine if the method returns a pointer */ /* determine if the method returns a pointer */
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl); is_pointer = SwigType_ispointer_return(decl);
is_void = (Cmp(type, "void") == 0 && !is_pointer); is_void = (Cmp(return_type, "void") == 0 && !is_pointer);
/* form complete return type */
return_type = Copy(type);
{
SwigType *t = Copy(decl);
SwigType *f = SwigType_pop_function(t);
SwigType_push(return_type, t);
Delete(f);
Delete(t);
}
/* virtual method definition */ /* virtual method definition */
l = Getattr(n, "parms");
String *target; String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname); String *pclassname = NewStringf("SwigDirector_%s", classname);
String *qualified_name = NewStringf("%s::%s", pclassname, name); String *qualified_name = NewStringf("%s::%s", pclassname, name);
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
Printf(w->def, "%s", target); Printf(w->def, "%s", target);
Delete(qualified_name); Delete(qualified_name);
@ -2651,16 +2631,7 @@ done:
/* marshal return value */ /* marshal return value */
if (!is_void) { if (!is_void) {
/* this seems really silly. the node's type excludes
* qualifier/pointer/reference markers, which have to be retrieved
* from the decl field to construct return_type. but the typemap
* lookup routine uses the node's type, so we have to swap in and
* out the correct type. it's not just me, similar silliness also
* occurs in Language::cDeclaration().
*/
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
Setattr(n, "type", type);
if (tm != 0) { if (tm != 0) {
static const String *amp_result = NewStringf("&%s", Swig_cresult_name()); static const String *amp_result = NewStringf("&%s", Swig_cresult_name());
Replaceall(tm, "$input", amp_result); Replaceall(tm, "$input", amp_result);
@ -2749,7 +2720,6 @@ done:
/* clean up */ /* clean up */
Delete(wrap_args); Delete(wrap_args);
Delete(return_type);
Delete(pclassname); Delete(pclassname);
DelWrapper(w); DelWrapper(w);
return status; return status;

View file

@ -4528,18 +4528,17 @@ int PYTHON::classDirectorMethods(Node *n) {
int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
int is_void = 0; int is_void = 0;
int is_pointer = 0; int is_pointer = 0;
String *decl; String *decl = Getattr(n, "decl");
String *type; String *name = Getattr(n, "name");
String *name; String *classname = Getattr(parent, "sym:name");
String *classname;
String *c_classname = Getattr(parent, "name"); String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
String *declaration; String *declaration = NewString("");
ParmList *l; ParmList *l = Getattr(n, "parms");
Wrapper *w; Wrapper *w = NewWrapper();
String *tm; String *tm;
String *wrap_args = NewString(""); String *wrap_args = NewString("");
String *return_type; String *return_type = Getattr(n, "type");
String *value = Getattr(n, "value"); String *value = Getattr(n, "value");
String *storage = Getattr(n, "storage"); String *storage = Getattr(n, "storage");
bool pure_virtual = false; bool pure_virtual = false;
@ -4553,35 +4552,15 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
} }
} }
classname = Getattr(parent, "sym:name");
type = Getattr(n, "type");
name = Getattr(n, "name");
w = NewWrapper();
declaration = NewString("");
/* determine if the method returns a pointer */ /* determine if the method returns a pointer */
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl); is_pointer = SwigType_ispointer_return(decl);
is_void = (!Cmp(type, "void") && !is_pointer); is_void = (!Cmp(return_type, "void") && !is_pointer);
/* form complete return type */
return_type = Copy(type);
{
SwigType *t = Copy(decl);
SwigType *f = 0;
f = SwigType_pop_function(t);
SwigType_push(return_type, t);
Delete(f);
Delete(t);
}
/* virtual method definition */ /* virtual method definition */
l = Getattr(n, "parms");
String *target; String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname); String *pclassname = NewStringf("SwigDirector_%s", classname);
String *qualified_name = NewStringf("%s::%s", pclassname, name); String *qualified_name = NewStringf("%s::%s", pclassname, name);
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
Printf(w->def, "%s", target); Printf(w->def, "%s", target);
Delete(qualified_name); Delete(qualified_name);
@ -4898,16 +4877,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
/* marshal return value */ /* marshal return value */
if (!is_void) { if (!is_void) {
/* this seems really silly. the node's type excludes
* qualifier/pointer/reference markers, which have to be retrieved
* from the decl field to construct return_type. but the typemap
* lookup routine uses the node's type, so we have to swap in and
* out the correct type. it's not just me, similar silliness also
* occurs in Language::cDeclaration().
*/
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
Setattr(n, "type", type);
if (tm != 0) { if (tm != 0) {
if (outputs > 1) { if (outputs > 1) {
Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++); Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++);
@ -5009,7 +4979,6 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
/* clean up */ /* clean up */
Delete(wrap_args); Delete(wrap_args);
Delete(return_type);
Delete(pclassname); Delete(pclassname);
DelWrapper(w); DelWrapper(w);
return status; return status;

View file

@ -3017,18 +3017,17 @@ public:
virtual int classDirectorMethod(Node *n, Node *parent, String *super) { virtual int classDirectorMethod(Node *n, Node *parent, String *super) {
int is_void = 0; int is_void = 0;
int is_pointer = 0; int is_pointer = 0;
String *decl; String *decl = Getattr(n, "decl");
String *type; String *name = Getattr(n, "name");
String *name; String *classname = Getattr(parent, "sym:name");
String *classname;
String *c_classname = Getattr(parent, "name"); String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
String *declaration; String *declaration = NewString("");
ParmList *l; ParmList *l = Getattr(n, "parms");
Wrapper *w; Wrapper *w = NewWrapper();
String *tm; String *tm;
String *wrap_args = NewString(""); String *wrap_args = NewString("");
String *return_type; String *return_type = Getattr(n, "type");
Parm *p; Parm *p;
String *value = Getattr(n, "value"); String *value = Getattr(n, "value");
String *storage = Getattr(n, "storage"); String *storage = Getattr(n, "storage");
@ -3049,35 +3048,15 @@ public:
Printf(overnametmp, "::%s", Getattr(n, "sym:overname")); Printf(overnametmp, "::%s", Getattr(n, "sym:overname"));
} }
classname = Getattr(parent, "sym:name");
type = Getattr(n, "type");
name = Getattr(n, "name");
w = NewWrapper();
declaration = NewString("");
/* determine if the method returns a pointer */ /* determine if the method returns a pointer */
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl); is_pointer = SwigType_ispointer_return(decl);
is_void = (!Cmp(type, "void") && !is_pointer); is_void = (!Cmp(return_type, "void") && !is_pointer);
/* form complete return type */
return_type = Copy(type);
{
SwigType *t = Copy(decl);
SwigType *f = 0;
f = SwigType_pop_function(t);
SwigType_push(return_type, t);
Delete(f);
Delete(t);
}
/* virtual method definition */ /* virtual method definition */
l = Getattr(n, "parms");
String *target; String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname); String *pclassname = NewStringf("SwigDirector_%s", classname);
String *qualified_name = NewStringf("%s::%s", pclassname, name); String *qualified_name = NewStringf("%s::%s", pclassname, name);
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
Printf(w->def, "%s", target); Printf(w->def, "%s", target);
Delete(qualified_name); Delete(qualified_name);
@ -3295,14 +3274,7 @@ public:
/* Marshal return value */ /* Marshal return value */
if (!is_void) { if (!is_void) {
/* This seems really silly. The node's type excludes qualifier/pointer/reference markers,
* which have to be retrieved from the decl field to construct return_type. But the typemap
* lookup routine uses the node's type, so we have to swap in and out the correct type.
* It's not just me, similar silliness also occurs in Language::cDeclaration().
*/
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
Setattr(n, "type", type);
if (tm != 0) { if (tm != 0) {
if (outputs > 1 && !asvoid ) { if (outputs > 1 && !asvoid ) {
Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++); Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++);
@ -3390,7 +3362,6 @@ public:
/* clean up */ /* clean up */
Delete(wrap_args); Delete(wrap_args);
Delete(return_type);
Delete(pclassname); Delete(pclassname);
DelWrapper(w); DelWrapper(w);
return status; return status;