%ignore director fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9326 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
38ed98a459
commit
d096cc1613
8 changed files with 262 additions and 176 deletions
|
|
@ -643,6 +643,8 @@ class JAVA : public Language {
|
|||
Hash *new_udata;
|
||||
String *key = NewStringf("%s|%s", imclass_method, decl);
|
||||
|
||||
++curr_class_dmethod;
|
||||
|
||||
/* Do we know about this director class already? */
|
||||
if ((udata = Getattr(dmethods_table, key))) {
|
||||
Delete(key);
|
||||
|
|
@ -3019,7 +3021,7 @@ class JAVA : public Language {
|
|||
String *imcall_args = NewString("");
|
||||
int gencomma = 0;
|
||||
int classmeth_off = curr_class_dmethod - first_class_dmethod;
|
||||
|
||||
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
|
||||
|
||||
// Kludge Alert: functionWrapper sets sym:overload properly, but it
|
||||
// isn't at this point, so we have to manufacture it ourselves. At least
|
||||
|
|
@ -3035,9 +3037,10 @@ class JAVA : public Language {
|
|||
c_classname = classname;
|
||||
|
||||
if (returntype) {
|
||||
if (!is_void) {
|
||||
|
||||
qualified_return = SwigType_rcaststr(returntype, "result");
|
||||
qualified_return = SwigType_rcaststr(returntype, "result");
|
||||
|
||||
if (!is_void && (!ignored_method || pure_virtual)) {
|
||||
if (!SwigType_isclass(returntype)) {
|
||||
if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
|
||||
Wrapper_add_localv(w, "result", SwigType_lstr(returntype, "result"), NIL);
|
||||
|
|
@ -3081,19 +3084,18 @@ class JAVA : public Language {
|
|||
Delete(vt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the intermediate class wrapper */
|
||||
Parm *tp = NewParmFromNode(returntype, empty_str, n);
|
||||
/* Create the intermediate class wrapper */
|
||||
Parm *tp = NewParmFromNode(returntype, empty_str, n);
|
||||
|
||||
tm = Swig_typemap_lookup_new("jtype", tp, "", 0);
|
||||
if (tm) {
|
||||
Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, classname);
|
||||
} else {
|
||||
Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number,
|
||||
"No jtype typemap defined for %s\n", SwigType_str(returntype,0));
|
||||
}
|
||||
} else
|
||||
Printf(callback_def, " public static void %s(%s self", imclass_dmethod, classname);
|
||||
tm = Swig_typemap_lookup_new("jtype", tp, "", 0);
|
||||
if (tm) {
|
||||
Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, classname);
|
||||
} else {
|
||||
Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number,
|
||||
"No jtype typemap defined for %s\n", SwigType_str(returntype,0));
|
||||
}
|
||||
|
||||
/* Get the JNI field descriptor for this return type, add the JNI field descriptor
|
||||
to jniret_desc */
|
||||
|
|
@ -3104,7 +3106,7 @@ class JAVA : public Language {
|
|||
String *jdesc;
|
||||
Parm *tp = NewParmFromNode(c_ret_type, empty_str, n);
|
||||
|
||||
if (!is_void) {
|
||||
if (!is_void && !ignored_method) {
|
||||
String *jretval_decl = NewStringf("%s jresult", c_ret_type);
|
||||
Wrapper_add_localv(w, "jresult", jretval_decl, " = 0", NIL);
|
||||
Delete(jretval_decl);
|
||||
|
|
@ -3177,19 +3179,20 @@ class JAVA : public Language {
|
|||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("javadirectorin", l, 0);
|
||||
|
||||
/* Add Java environment pointer to wrapper */
|
||||
String *jenvstr = NewString("jenv");
|
||||
String *jobjstr = NewString("jobj");
|
||||
if (!ignored_method) {
|
||||
/* Add Java environment pointer to wrapper */
|
||||
String *jenvstr = NewString("jenv");
|
||||
String *jobjstr = NewString("jobj");
|
||||
|
||||
Wrapper_add_localv(w, "jnienv", "JNIEnvWrapper", "jnienv(this)", NIL, NIL);
|
||||
Wrapper_add_localv(w, jenvstr, "JNIEnv *", jenvstr, "= jnienv.getJNIEnv()", NIL);
|
||||
Wrapper_add_localv(w, jobjstr, "jobject ", jobjstr, "= (jobject) NULL", NIL);
|
||||
Delete(jenvstr);
|
||||
Delete(jobjstr);
|
||||
Wrapper_add_localv(w, "jnienv", "JNIEnvWrapper", "jnienv(this)", NIL, NIL);
|
||||
Wrapper_add_localv(w, jenvstr, "JNIEnv *", jenvstr, "= jnienv.getJNIEnv()", NIL);
|
||||
Wrapper_add_localv(w, jobjstr, "jobject ", jobjstr, "= (jobject) NULL", NIL);
|
||||
Delete(jenvstr);
|
||||
Delete(jobjstr);
|
||||
|
||||
/* Preamble code */
|
||||
|
||||
Printf(w->code, "if (!swig_override[%d]) {\n", classmeth_off);
|
||||
/* Preamble code */
|
||||
Printf(w->code, "if (!swig_override[%d]) {\n", classmeth_off);
|
||||
}
|
||||
|
||||
if (!pure_virtual) {
|
||||
if (is_void) {
|
||||
|
|
@ -3201,9 +3204,8 @@ class JAVA : public Language {
|
|||
Delete(super_call);
|
||||
}
|
||||
} else {
|
||||
Printf(w->code, "SWIG_JavaThrowException(jenv, SWIG_JavaDirectorPureVirtual,\n");
|
||||
Printf(w->code, " \"Attempted to invoke pure virtual method %s::%s.\");\n",
|
||||
c_classname, name);
|
||||
Printf(w->code, "SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, ");
|
||||
Printf(w->code, "\"Attempted to invoke pure virtual method %s::%s.\");\n", c_classname, name);
|
||||
|
||||
/* Make sure that we return something in the case of a pure
|
||||
* virtual method call for syntactical reasons. */
|
||||
|
|
@ -3213,9 +3215,11 @@ class JAVA : public Language {
|
|||
Printf(w->code, "return;\n");
|
||||
}
|
||||
|
||||
Printf(w->code, "}\n");
|
||||
Printf(w->code, "jobj = swig_get_self(jenv);\n");
|
||||
Printf(w->code, "if (jobj && jenv->IsSameObject(jobj, NULL) == JNI_FALSE) {\n");
|
||||
if (!ignored_method) {
|
||||
Printf(w->code, "}\n");
|
||||
Printf(w->code, "jobj = swig_get_self(jenv);\n");
|
||||
Printf(w->code, "if (jobj && jenv->IsSameObject(jobj, NULL) == JNI_FALSE) {\n");
|
||||
}
|
||||
|
||||
/* Start the Java field descriptor for the intermediate class's upcall (insert self object) */
|
||||
Parm *tp = NewParmFromNode(c_classname, empty_str, n);
|
||||
|
|
@ -3266,7 +3270,8 @@ class JAVA : public Language {
|
|||
|
||||
/* Add to local variables */
|
||||
Printf(c_decl, "%s %s", c_param_type, arg);
|
||||
Wrapper_add_localv(w, arg, c_decl, (!(SwigType_ispointer(pt) || SwigType_isreference(pt)) ? "" : "= 0"), NIL);
|
||||
if (!ignored_method)
|
||||
Wrapper_add_localv(w, arg, c_decl, (!(SwigType_ispointer(pt) || SwigType_isreference(pt)) ? "" : "= 0"), NIL);
|
||||
|
||||
/* Add input marshalling code and update JNI field descriptor */
|
||||
if ((desc_tm = Swig_typemap_lookup_new("directorin", tp, "", 0))
|
||||
|
|
@ -3282,7 +3287,8 @@ class JAVA : public Language {
|
|||
Replaceall(tm,"$input", arg);
|
||||
|
||||
if (Len(tm))
|
||||
Printf(w->code,"%s\n", tm);
|
||||
if (!ignored_method)
|
||||
Printf(w->code,"%s\n", tm);
|
||||
|
||||
Delete(tm);
|
||||
|
||||
|
|
@ -3437,57 +3443,59 @@ class JAVA : public Language {
|
|||
Printf(callback_code, " }\n");
|
||||
Delete(upcall);
|
||||
|
||||
/* Emit the actual upcall through */
|
||||
String *imclass_desc = NewStringf("(%s)%s", jnidesc, jniret_desc);
|
||||
String *class_desc = NewStringf("(%s)%s", classdesc, classret_desc);
|
||||
UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, imclass_desc, class_desc, decl);
|
||||
String *methid = Getattr(udata, "imclass_methodidx");
|
||||
String *methop = getUpcallJNIMethod(jniret_desc);
|
||||
if (!ignored_method) {
|
||||
/* Emit the actual upcall through */
|
||||
String *imclass_desc = NewStringf("(%s)%s", jnidesc, jniret_desc);
|
||||
String *class_desc = NewStringf("(%s)%s", classdesc, classret_desc);
|
||||
UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, imclass_desc, class_desc, decl);
|
||||
String *methid = Getattr(udata, "imclass_methodidx");
|
||||
String *methop = getUpcallJNIMethod(jniret_desc);
|
||||
|
||||
if (!is_void) Printf(w->code, "jresult = (%s) ", c_ret_type);
|
||||
|
||||
Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n",
|
||||
methop, imclass_name, methid, jupcall_args);
|
||||
if (!is_void) Printf(w->code, "jresult = (%s) ", c_ret_type);
|
||||
|
||||
Printf(w->code, "if (jenv->ExceptionOccurred()) return $null;\n");
|
||||
Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n",
|
||||
methop, imclass_name, methid, jupcall_args);
|
||||
|
||||
if (!is_void) {
|
||||
String *jresult_str = NewString("jresult");
|
||||
String *result_str = NewString("result");
|
||||
Parm *tp = NewParmFromNode(returntype, result_str, n);
|
||||
Printf(w->code, "if (jenv->ExceptionOccurred()) return $null;\n");
|
||||
|
||||
/* Copy jresult into result... */
|
||||
if ((tm = Swig_typemap_lookup_new("directorout", tp, result_str, w))) {
|
||||
addThrows(n, "tmap:directorout", tp);
|
||||
Replaceall(tm,"$source", jresult_str); /* deprecated */
|
||||
Replaceall(tm,"$target", result_str); /* deprecated */
|
||||
Replaceall(tm,"$arg", jresult_str); /* deprecated? */
|
||||
Replaceall(tm,"$input", jresult_str);
|
||||
Printf(w->code, "%s\n", tm);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
|
||||
"Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), classname, name);
|
||||
output_director = false;
|
||||
if (!is_void) {
|
||||
String *jresult_str = NewString("jresult");
|
||||
String *result_str = NewString("result");
|
||||
Parm *tp = NewParmFromNode(returntype, result_str, n);
|
||||
|
||||
/* Copy jresult into result... */
|
||||
if ((tm = Swig_typemap_lookup_new("directorout", tp, result_str, w))) {
|
||||
addThrows(n, "tmap:directorout", tp);
|
||||
Replaceall(tm,"$source", jresult_str); /* deprecated */
|
||||
Replaceall(tm,"$target", result_str); /* deprecated */
|
||||
Replaceall(tm,"$arg", jresult_str); /* deprecated? */
|
||||
Replaceall(tm,"$input", jresult_str);
|
||||
Printf(w->code, "%s\n", tm);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
|
||||
"Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), classname, name);
|
||||
output_director = false;
|
||||
}
|
||||
|
||||
Delete(tp);
|
||||
Delete(jresult_str);
|
||||
Delete(result_str);
|
||||
}
|
||||
|
||||
Delete(tp);
|
||||
Delete(jresult_str);
|
||||
Delete(result_str);
|
||||
Delete(imclass_desc);
|
||||
Delete(class_desc);
|
||||
|
||||
/* Terminate wrapper code */
|
||||
Printf(w->code, "} else {\n");
|
||||
Printf(w->code, "SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, \"null upcall object\");\n");
|
||||
Printf(w->code, "}\n");
|
||||
|
||||
Printf(w->code, "if (jobj) jenv->DeleteLocalRef(jobj);\n");
|
||||
|
||||
if (!is_void)
|
||||
Printf(w->code, "return %s;", qualified_return);
|
||||
}
|
||||
|
||||
Delete(imclass_desc);
|
||||
Delete(class_desc);
|
||||
|
||||
/* Terminate wrapper code */
|
||||
Printf(w->code, "} else {\n");
|
||||
Printf(w->code, "SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, \"null upcall object\");\n");
|
||||
Printf(w->code, "}\n");
|
||||
|
||||
Printf(w->code, "if (jobj) jenv->DeleteLocalRef(jobj);\n");
|
||||
|
||||
if (!is_void)
|
||||
Printf(w->code, "return %s;", qualified_return);
|
||||
|
||||
Printf(w->code, "}");
|
||||
|
||||
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
||||
|
|
@ -3513,7 +3521,8 @@ class JAVA : public Language {
|
|||
} else {
|
||||
Replaceall(w->code,"$null","");
|
||||
}
|
||||
Printv(imclass_directors, callback_def, callback_code, NIL);
|
||||
if (!GetFlag(n, "feature:ignore"))
|
||||
Printv(imclass_directors, callback_def, callback_code, NIL);
|
||||
if (!Getattr(n,"defaultargs")) {
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
|
|
@ -3531,7 +3540,6 @@ class JAVA : public Language {
|
|||
Delete(callback_code);
|
||||
DelWrapper(w);
|
||||
|
||||
++curr_class_dmethod;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue