Scott Michel patch which removes supefluous ricochet director checking code except for pure virtual methods.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5288 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2003-11-10 22:26:36 +00:00
commit 4536730c5a

View file

@ -751,7 +751,6 @@ class JAVA : public Language {
bool pure_virtual = false; bool pure_virtual = false;
bool director_method = false; bool director_method = false;
bool feature_director = false; bool feature_director = false;
bool recursive_upcall = false;
bool feature_extend = !Cmp(Getattr(n, "feature:extend"), "1"); bool feature_extend = !Cmp(Getattr(n, "feature:extend"), "1");
String *director_class = NULL; String *director_class = NULL;
String *director_uargs = NewString("director->swig_get_self()"); String *director_uargs = NewString("director->swig_get_self()");
@ -771,9 +770,6 @@ class JAVA : public Language {
udata = getUpcallMethodData(dirimclass_meth, Getattr(n, "decl")); udata = getUpcallMethodData(dirimclass_meth, Getattr(n, "decl"));
imclass_methodidx = Getattr(udata, "imclass_methodidx"); imclass_methodidx = Getattr(udata, "imclass_methodidx");
class_methodidx = Getattr(udata, "class_methodidx"); class_methodidx = Getattr(udata, "class_methodidx");
recursive_upcall = !(Cmp(Getattr(n, "feature:director:recursive"), "1")
&& Cmp(Getattr(parent, "feature:director:recursive"), "1"));
} }
if (!Cmp(Getattr(n, "value"), "0")) if (!Cmp(Getattr(n, "value"), "0"))
@ -1093,7 +1089,7 @@ class JAVA : public Language {
upcall_method = getUpcallJNIMethod(jdescrip); upcall_method = getUpcallJNIMethod(jdescrip);
if (upcall_method != NULL) { if (upcall_method != NULL) {
if (!recursive_upcall) { if (pure_virtual) {
Printf(f->code, " if (!director->swig_get_ricochet(%s)) {\n", class_methodidx); Printf(f->code, " if (!director->swig_get_ricochet(%s)) {\n", class_methodidx);
Printf(f->code, " director->swig_set_ricochet(%s);\n", class_methodidx); Printf(f->code, " director->swig_set_ricochet(%s);\n", class_methodidx);
} }
@ -1105,22 +1101,12 @@ class JAVA : public Language {
Printf(f->code, " jenv->%s(jcls, Swig::director_methids[%s], %s);\n", Printf(f->code, " jenv->%s(jcls, Swig::director_methids[%s], %s);\n",
upcall_method, imclass_methodidx, director_uargs); upcall_method, imclass_methodidx, director_uargs);
if (!recursive_upcall) if (pure_virtual) {
Printf(f->code, " director->swig_clear_ricochet(%s);\n", class_methodidx); Printf(f->code, " director->swig_clear_ricochet(%s);\n", class_methodidx);
if (!recursive_upcall) {
Printf(f->code, " } else {\n"); Printf(f->code, " } else {\n");
Printf(f->code, " SWIG_JavaThrowException(jenv, SWIG_JavaDirectorPureVirtual,\n");
if (!pure_virtual) { Printf(f->code, " \"Pure virtual director method %s::%s invoked.\");\n",
Printf(f->code, " SWIG_JavaThrowException(jenv, SWIG_JavaDirectorRicochet,\n"); proxy_class_name, Getattr(n, "name"));
Printf(f->code, " \"Recursive loop into director method %s::%s detected.\");\n",
proxy_class_name, Getattr(n, "name"));
} else {
Printf(f->code, " SWIG_JavaThrowException(jenv, SWIG_JavaDirectorPureVirtual,\n");
Printf(f->code, " \"Pure virtual director method %s::%s invoked.\");\n",
proxy_class_name, Getattr(n, "name"));
}
Printf(f->code, "}"); Printf(f->code, "}");
} }
@ -1664,9 +1650,10 @@ class JAVA : public Language {
f_proxy = NULL; f_proxy = NULL;
/* Output the downcast method, if necessary. Note: There's no other really /* Output the downcast method, if necessary. Note: There's no other really
good place to put this code, since ABCs can and should have downcasts, good place to put this code, since Abstract Base Classes (ABCs) can and should have
making the constructorHandler() a bad place. */ downcasts, making the constructorHandler() a bad place (because ABCs don't get to
if (Getattr(n, "feature:director:downcast")) { have constructors emitted.) */
if (Getattr(n, "feature:javadowncast")) {
String *jni_imclass_name = makeValidJniName(imclass_name); String *jni_imclass_name = makeValidJniName(imclass_name);
String *jni_class_name = makeValidJniName(proxy_class_name); String *jni_class_name = makeValidJniName(proxy_class_name);
String *norm_name = SwigType_namestr(Getattr(n, "name")); String *norm_name = SwigType_namestr(Getattr(n, "name"));
@ -2677,11 +2664,9 @@ class JAVA : public Language {
ParmList *l = Getattr(n, "parms"); ParmList *l = Getattr(n, "parms");
bool is_void = !(Cmp(type, "void")); bool is_void = !(Cmp(type, "void"));
bool pure_virtual = (!(Cmp(storage, "virtual")) && !(Cmp(value, "0"))); bool pure_virtual = (!(Cmp(storage, "virtual")) && !(Cmp(value, "0")));
bool is_const = SwigType_isconst(decl) ? true : false;
int status = SWIG_OK; int status = SWIG_OK;
bool output_director = true; bool output_director = true;
bool recursive_upcall = false;
String *dirclassname = directorClassName(parent); String *dirclassname = directorClassName(parent);
String *qualified_name = NewStringf("%s::%s", dirclassname, name); String *qualified_name = NewStringf("%s::%s", dirclassname, name);
String *jnidesc = NewString(""); String *jnidesc = NewString("");
@ -2714,10 +2699,6 @@ class JAVA : public Language {
if (!(Cmp(type, "class"))) if (!(Cmp(type, "class")))
c_classname = classname; c_classname = classname;
/* Check if the user wants upcall recursion */
recursive_upcall = !(Cmp(Getattr(n, "feature:director:recursive"), "1")
&& Cmp(Getattr(parent, "feature:director:recursive"), "1"));
/* Handle and form complete return type, including the modification /* Handle and form complete return type, including the modification
to a pointer, if return type is a reference. */ to a pointer, if return type is a reference. */
@ -2898,14 +2879,6 @@ class JAVA : public Language {
Delete(tp); Delete(tp);
} }
if (!recursive_upcall) {
if (!is_const)
Printf(w->code, "if (!swig_get_ricochet(%d)) {\n", classmeth_off);
else
Printf(w->code, "if (!const_cast<%s *>(this)->swig_get_ricochet(%d)) {\n",
dirclassname, classmeth_off);
}
/* Get number of required and total arguments */ /* Get number of required and total arguments */
num_arguments = emit_num_arguments(l); num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l); num_required = emit_num_required(l);
@ -3113,14 +3086,6 @@ class JAVA : public Language {
String *methid = Getattr(udata, "imclass_methodidx"); String *methid = Getattr(udata, "imclass_methodidx");
String *methop = getUpcallJNIMethod(jniret_desc); String *methop = getUpcallJNIMethod(jniret_desc);
if (!recursive_upcall) {
if (!is_const)
Printf(w->code, " swig_set_ricochet(%d);\n", classmeth_off);
else
Printf(w->code, " const_cast<%s *>(this)->swig_set_ricochet(%d);\n",
dirclassname, classmeth_off);
}
if (!is_void) { if (!is_void) {
Printf(w->code, "jresult = (%s) jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n", Printf(w->code, "jresult = (%s) jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n",
jniret_type, methop, imclass_name, methid, jupcall_args); jniret_type, methop, imclass_name, methid, jupcall_args);
@ -3129,14 +3094,6 @@ class JAVA : public Language {
methop, imclass_name, methid, jupcall_args); methop, imclass_name, methid, jupcall_args);
} }
if (!recursive_upcall) {
if (!is_const)
Printf(w->code, "swig_clear_ricochet(%d);\n", classmeth_off);
else
Printf(w->code, " const_cast<%s *>(this)->swig_clear_ricochet(%d);\n",
dirclassname, classmeth_off);
}
Printf(w->code, "if (jenv->ExceptionOccurred()) return $null;\n"); Printf(w->code, "if (jenv->ExceptionOccurred()) return $null;\n");
if (!is_void) { if (!is_void) {
@ -3163,14 +3120,6 @@ class JAVA : public Language {
Delete(result_str); Delete(result_str);
} }
if (!recursive_upcall) {
Printf(w->code, "} else {\n");
Printf(w->code, " SWIG_JavaThrowException(jenv, SWIG_JavaDirectorRicochet,\n");
Printf(w->code, " \"Recursive loop into director method %s::%s detected.\");\n",
c_classname, name);
Printf(w->code, "}\n");
}
Delete(imclass_desc); Delete(imclass_desc);
Delete(class_desc); Delete(class_desc);