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

@ -3449,13 +3449,11 @@ public:
* --------------------------------------------------------------- */
int classDirectorMethod(Node *n, Node *parent, String *super) {
String *empty_str = NewString("");
String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name");
String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
SwigType *type = Getattr(n, "type");
SwigType *returntype = Getattr(n, "returntype");
SwigType *returntype = Getattr(n, "type");
String *overloaded_name = getOverloadedName(n);
String *storage = Getattr(n, "storage");
String *value = Getattr(n, "value");
@ -3544,14 +3542,12 @@ public:
}
/* Create the intermediate class wrapper */
Parm *tp = NewParm(returntype, empty_str, n);
tm = Swig_typemap_lookup("imtype", tp, "", 0);
tm = Swig_typemap_lookup("imtype", n, "", 0);
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)
tm = imtypeout;
const String *im_directoroutattributes = Getattr(tp, "tmap:imtype:directoroutattributes");
const String *im_directoroutattributes = Getattr(n, "tmap:imtype:directoroutattributes");
if (im_directoroutattributes) {
Printf(callback_def, " %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));
}
Parm *retpm = NewParm(returntype, empty_str, n);
if ((c_ret_type = Swig_typemap_lookup("ctype", retpm, "", 0))) {
if ((c_ret_type = Swig_typemap_lookup("ctype", n, "", 0))) {
if (!is_void && !ignored_method) {
String *jretval_decl = NewStringf("%s jresult", c_ret_type);
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));
output_director = false;
}
Delete(retpm);
}
Swig_director_parms_fixup(l);
@ -3731,7 +3722,7 @@ public:
/* header declaration, start wrapper definition */
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);
Printf(w->def, "%s", target);
Delete(qualified_name);
@ -3778,9 +3769,7 @@ public:
String *upcall = NewStringf("%s(%s)", symname, imcall_args);
if (!is_void) {
Parm *tp = NewParm(returntype, empty_str, n);
if ((tm = Swig_typemap_lookup("csdirectorout", tp, "", 0))) {
if ((tm = Swig_typemap_lookup("csdirectorout", n, "", 0))) {
substituteClassname(returntype, tm);
Replaceall(tm, "$cscall", upcall);
@ -3788,7 +3777,6 @@ public:
}
Delete(tm);
Delete(tp);
} else
Printf(callback_code, " %s;\n", upcall);
@ -3804,10 +3792,9 @@ public:
if (!is_void) {
String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result");
Parm *tp = NewParm(returntype, result_str, n);
/* 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, "$result", result_str);
Printf(w->code, "%s\n", tm);
@ -3818,7 +3805,6 @@ public:
output_director = false;
}
Delete(tp);
Delete(jresult_str);
Delete(result_str);
}

View file

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

View file

@ -2853,7 +2853,6 @@ private:
int classDirectorMethod(Node *n, Node *parent, String *super) {
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.
if (GetFlag(n, "explicitcall")) {
@ -2866,18 +2865,8 @@ private:
name = Getattr(n, "name");
}
if (Getattr(class_methods, name)) {
// We need to emit a pure virtual function, even if it is
// 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")) {
bool overloaded = Getattr(n, "sym:overloaded") && !Getattr(n, "explicitcallnode");
if (!overloaded) {
int r = oneClassDirectorMethod(n, parent, super);
if (r != SWIG_OK) {
return r;
@ -2888,47 +2877,54 @@ private:
// class_methods so that we correctly handle cases where a
// function in one class hides a function of the same name in a
// parent class.
for (Node *on = Getattr(n, "sym:overloaded"); on; on = Getattr(on, "sym:nextSibling")) {
int r = oneClassDirectorMethod(on, parent, super);
if (!Getattr(class_methods, name)) {
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) {
return r;
}
// 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"));
String *go_upcall = NewString("Director");
Append(go_upcall, cn);
Append(go_upcall, go_name);
r = makeDispatchFunction(on, 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);
}
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;
}
@ -2980,17 +2976,8 @@ private:
Swig_typemap_attach_parms("gotype", parms, NULL);
int parm_count = emit_num_arguments(parms);
SwigType *result = Getattr(n, "returntype");
if (!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);
}
SwigType *result = Getattr(n, "type");
SwigType *returntype = result;
// Save the type for overload processing.
Setattr(n, "go:type", result);
@ -3177,7 +3164,8 @@ private:
if (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);
Delete(upcall_decl);
@ -3450,7 +3438,7 @@ private:
if (!is_ignored || is_pure_virtual) {
// 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);
Printv(f_c_directors_h, " virtual ", decl, NULL);
Delete(decl);
@ -3474,7 +3462,7 @@ private:
Printv(w->def, " {\n", NULL);
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) {
@ -3530,9 +3518,8 @@ private:
Printv(w->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL);
if (SwigType_type(result) != T_VOID) {
String *rname = NewString("c_result");
Parm *rp = NewParm(Getattr(n, "returntype"), rname, n);
String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL);
String *result_str = NewString("c_result");
String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
if (!tm) {
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
"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, "$result", "c_result");
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);
Delete(retstr);
Delete(tm);
}
Delete(rp);
Delete(rname);
Delete(result_str);
}
// The C wrapper code which calls the Go function.
@ -3605,9 +3591,8 @@ private:
Printv(w->code, callback_wname, "(go_val", args, ");\n", NULL);
if (SwigType_type(result) != T_VOID) {
String *rname = NewString("c_result");
Parm *rp = NewParm(Getattr(n, "returntype"), rname, n);
String *tm = Swig_typemap_lookup("directorout", rp, rname, NULL);
String *result_str = NewString("c_result");
String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
if (!tm) {
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
"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, "$result", "c_result");
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);
Delete(retstr);
Delete(tm);
}
Delete(rp);
Delete(rname);
Delete(result_str);
}
}
@ -3641,7 +3625,7 @@ private:
assert(is_pure_virtual);
Printv(w->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL);
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);
Delete(retstr);
}
@ -3783,7 +3767,8 @@ private:
mismatch = false;
bool any_void = false;
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");
assert(result);
@ -3862,7 +3847,8 @@ private:
for (int i = 0; i < nfunc; ++i) {
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");
// 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.
List *coll = NewList();
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");
if (use_receiver && pk && Getattr(pk, "self")) {
pk = getParm(pk);

View file

@ -3519,7 +3519,6 @@ public:
String *c_classname = Getattr(parent, "name");
String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
SwigType *type = Getattr(n, "type");
SwigType *returntype = Getattr(n, "returntype");
String *overloaded_name = getOverloadedName(n);
String *storage = Getattr(n, "storage");
@ -3616,9 +3615,7 @@ public:
}
/* Create the intermediate class wrapper */
Parm *tp = NewParm(returntype, empty_str, n);
tm = Swig_typemap_lookup("jtype", tp, "", 0);
tm = Swig_typemap_lookup("jtype", n, "", 0);
if (tm) {
Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, qualified_classname);
} else {
@ -3628,7 +3625,8 @@ public:
String *cdesc = NULL;
SwigType *covariant = Getattr(n, "covariant");
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))
&& (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
to jniret_desc */
Parm *retpm = NewParm(returntype, empty_str, n);
if ((c_ret_type = Swig_typemap_lookup("jni", retpm, "", 0))) {
Parm *tp = NewParm(c_ret_type, empty_str, n);
if ((c_ret_type = Swig_typemap_lookup("jni", n, "", 0))) {
Parm *tp = NewParm(c_ret_type, name, n);
if (!is_void && !ignored_method) {
String *jretval_decl = NewStringf("%s jresult", c_ret_type);
@ -3685,7 +3680,6 @@ public:
}
Delete(adjustedreturntypeparm);
Delete(retpm);
Delete(qualified_classname);
}
@ -3755,7 +3749,7 @@ public:
} else {
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",
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;
}
@ -3879,7 +3873,6 @@ public:
output_director = false;
}
Delete(tp);
} 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",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
@ -3894,7 +3887,7 @@ public:
/* header declaration, start wrapper definition */
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);
Printf(w->def, "%s", target);
Delete(qualified_name);
@ -3944,21 +3937,18 @@ public:
addThrows(n, "feature:except", n);
if (!is_void) {
Parm *tp = NewParm(returntype, empty_str, n);
if ((tm = Swig_typemap_lookup("javadirectorout", tp, "", 0))) {
addThrows(n, "tmap:javadirectorout", tp);
if ((tm = Swig_typemap_lookup("javadirectorout", n, "", 0))) {
addThrows(n, "tmap:javadirectorout", n);
substituteClassname(returntype, tm);
Replaceall(tm, "$javacall", upcall);
Printf(callback_code, " return %s;\n", tm);
}
if ((tm = Swig_typemap_lookup("out", tp, "", 0)))
addThrows(n, "tmap:out", tp);
if ((tm = Swig_typemap_lookup("out", n, "", 0)))
addThrows(n, "tmap:out", n);
Delete(tm);
Delete(tp);
} else
Printf(callback_code, " %s;\n", upcall);
@ -3988,11 +3978,10 @@ public:
if (!is_void) {
String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result");
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {
addThrows(n, "tmap:directorout", tp);
if ((tm = Swig_typemap_lookup("directorout", n, result_str, w))) {
addThrows(n, "tmap:directorout", n);
Replaceall(tm, "$input", jresult_str);
Replaceall(tm, "$result", result_str);
Printf(w->code, "%s\n", tm);
@ -4003,7 +3992,6 @@ public:
output_director = false;
}
Delete(tp);
Delete(jresult_str);
Delete(result_str);
}

View file

@ -2041,9 +2041,12 @@ int Language::classDirectorMethods(Node *n) {
if (!Cmp(type, "destructor")) {
classDirectorDestructor(method);
} else {
if (classDirectorMethod(method, n, fqdname) == SWIG_OK) {
Setattr(item, "director", "1");
}
Swig_require("classDirectorMethods", method, "*type", NIL);
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 is_void = 0;
int is_pointer = 0;
String *storage;
String *value;
String *decl;
String *type;
String *name;
String *classname;
String *storage = Getattr(n, "storage");
String *value = Getattr(n, "value");
String *decl = Getattr(n, "decl");
String *return_type = Getattr(n, "type");
String *name = Getattr(n, "name");
String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name");
String *declaration;
ParmList *l;
Wrapper *w;
String *declaration = NewString("");
ParmList *l = Getattr(n, "parms");
Wrapper *w = NewWrapper();
String *tm;
String *wrap_args = NewString("");
String *return_type;
int status = SWIG_OK;
int idx;
bool pure_virtual = 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(value, "0") == 0) {
pure_virtual = true;
}
}
w = NewWrapper();
declaration = NewString("");
Wrapper_add_local(w, "swig_result", "CAMLparam0();\n" "SWIG_CAMLlocal2(swig_result,args)");
/* determine if the method returns a pointer */
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl);
is_void = (!Cmp(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);
}
is_void = (!Cmp(return_type, "void") && !is_pointer);
/* virtual method definition */
l = Getattr(n, "parms");
String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname);
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);
Printf(w->def, "%s {", target);
Delete(qualified_name);
@ -1616,16 +1594,7 @@ public:
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);
Setattr(n, "type", type);
if (tm != 0) {
Replaceall(tm, "$input", "swig_result");
/* TODO check this */
@ -1704,7 +1673,6 @@ public:
/* clean up */
Delete(wrap_args);
Delete(return_type);
Delete(pclassname);
DelWrapper(w);
return status;

View file

@ -1247,18 +1247,17 @@ public:
int classDirectorMethod(Node *n, Node *parent, String *super) {
int is_void = 0;
int is_pointer = 0;
String *decl;
String *type;
String *name;
String *classname;
String *decl = Getattr(n, "decl");
String *return_type = Getattr(n, "type");
String *name = Getattr(n, "name");
String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name");
String *declaration;
ParmList *l;
Wrapper *w;
String *declaration = NewString("");
ParmList *l = Getattr(n, "parms");
Wrapper *w = NewWrapper();
String *tm;
String *wrap_args = NewString("");
String *return_type;
String *value = Getattr(n, "value");
String *storage = Getattr(n, "storage");
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
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl);
is_void = (!Cmp(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);
}
is_void = (!Cmp(return_type, "void") && !is_pointer);
// virtual method definition
l = Getattr(n, "parms");
String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname);
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);
Printf(w->def, "%s", target);
Delete(qualified_name);
@ -1449,9 +1428,7 @@ public:
"method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name);
Printf(w->code, "}\n");
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
Setattr(n, "type", type);
if (tm != 0) {
char temp[24];
sprintf(temp, "out(%d)", idx);
@ -1531,7 +1508,6 @@ public:
}
// clean up
Delete(wrap_args);
Delete(return_type);
Delete(pclassname);
DelWrapper(w);
return status;

View file

@ -2415,18 +2415,17 @@ done:
int classDirectorMethod(Node *n, Node *parent, String *super) {
int is_void = 0;
int is_pointer = 0;
String *decl;
String *type;
String *name;
String *classname;
String *decl = Getattr(n, "decl");
String *return_type = Getattr(n, "type");
String *name = Getattr(n, "name");
String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name");
String *declaration;
ParmList *l;
Wrapper *w;
String *declaration = NewStringEmpty();
ParmList *l = Getattr(n, "parms");
Wrapper *w = NewWrapper();
String *tm;
String *wrap_args = NewStringEmpty();
String *return_type;
String *value = Getattr(n, "value");
String *storage = Getattr(n, "storage");
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 */
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl);
is_void = (Cmp(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);
}
is_void = (Cmp(return_type, "void") == 0 && !is_pointer);
/* virtual method definition */
l = Getattr(n, "parms");
String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname);
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);
Printf(w->def, "%s", target);
Delete(qualified_name);
@ -2651,16 +2631,7 @@ done:
/* marshal return value */
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);
Setattr(n, "type", type);
if (tm != 0) {
static const String *amp_result = NewStringf("&%s", Swig_cresult_name());
Replaceall(tm, "$input", amp_result);
@ -2749,7 +2720,6 @@ done:
/* clean up */
Delete(wrap_args);
Delete(return_type);
Delete(pclassname);
DelWrapper(w);
return status;

View file

@ -4528,18 +4528,17 @@ int PYTHON::classDirectorMethods(Node *n) {
int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
int is_void = 0;
int is_pointer = 0;
String *decl;
String *type;
String *name;
String *classname;
String *decl = Getattr(n, "decl");
String *name = Getattr(n, "name");
String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name");
String *declaration;
ParmList *l;
Wrapper *w;
String *declaration = NewString("");
ParmList *l = Getattr(n, "parms");
Wrapper *w = NewWrapper();
String *tm;
String *wrap_args = NewString("");
String *return_type;
String *return_type = Getattr(n, "type");
String *value = Getattr(n, "value");
String *storage = Getattr(n, "storage");
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 */
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl);
is_void = (!Cmp(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);
}
is_void = (!Cmp(return_type, "void") && !is_pointer);
/* virtual method definition */
l = Getattr(n, "parms");
String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname);
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);
Printf(w->def, "%s", target);
Delete(qualified_name);
@ -4898,16 +4877,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
/* marshal return value */
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);
Setattr(n, "type", type);
if (tm != 0) {
if (outputs > 1) {
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 */
Delete(wrap_args);
Delete(return_type);
Delete(pclassname);
DelWrapper(w);
return status;

View file

@ -3017,18 +3017,17 @@ public:
virtual int classDirectorMethod(Node *n, Node *parent, String *super) {
int is_void = 0;
int is_pointer = 0;
String *decl;
String *type;
String *name;
String *classname;
String *decl = Getattr(n, "decl");
String *name = Getattr(n, "name");
String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name");
String *symname = Getattr(n, "sym:name");
String *declaration;
ParmList *l;
Wrapper *w;
String *declaration = NewString("");
ParmList *l = Getattr(n, "parms");
Wrapper *w = NewWrapper();
String *tm;
String *wrap_args = NewString("");
String *return_type;
String *return_type = Getattr(n, "type");
Parm *p;
String *value = Getattr(n, "value");
String *storage = Getattr(n, "storage");
@ -3049,35 +3048,15 @@ public:
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 */
decl = Getattr(n, "decl");
is_pointer = SwigType_ispointer_return(decl);
is_void = (!Cmp(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);
}
is_void = (!Cmp(return_type, "void") && !is_pointer);
/* virtual method definition */
l = Getattr(n, "parms");
String *target;
String *pclassname = NewStringf("SwigDirector_%s", classname);
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);
Printf(w->def, "%s", target);
Delete(qualified_name);
@ -3295,14 +3274,7 @@ public:
/* Marshal return value */
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);
Setattr(n, "type", type);
if (tm != 0) {
if (outputs > 1 && !asvoid ) {
Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++);
@ -3390,7 +3362,6 @@ public:
/* clean up */
Delete(wrap_args);
Delete(return_type);
Delete(pclassname);
DelWrapper(w);
return status;