- explicitcall feature removed.
- Instead of using the swig_up flag in each director method (Python, Ruby, Ocaml) to indicate whether the explicit C++ call to the appropriate base class method or a normal polymorphic C++ call should be made, the new approach makes one of these calls directly from the wrapper method. - Java/C# recursive director method calls fixed (no need for explicitcall feature to solve this now) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9275 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c51284fdbf
commit
38a17f30fe
12 changed files with 355 additions and 303 deletions
|
|
@ -1870,6 +1870,9 @@ class JAVA : public Language {
|
|||
// Wrappers not wanted for some methods where the parameters cannot be overloaded in Java
|
||||
if (Getattr(n, "overload:ignore")) return;
|
||||
|
||||
// Don't generate proxy method for additional explicitcall method used in directors
|
||||
if (GetFlag(n, "explicitcall")) return;
|
||||
|
||||
if (l) {
|
||||
if (SwigType_type(Getattr(l,"type")) == T_VOID) {
|
||||
l = nextSibling(l);
|
||||
|
|
@ -1985,6 +1988,29 @@ class JAVA : public Language {
|
|||
else
|
||||
Replaceall(tm,"$owner","false");
|
||||
substituteClassname(t, tm);
|
||||
|
||||
// For director methods: generate code to selectively make a normal polymorphic call or
|
||||
// an explicit method call - needed to prevent infinite recursion calls in director methods.
|
||||
Node *explicit_n = Getattr(n,"explicitcallnode");
|
||||
if (explicit_n) {
|
||||
String *ex_overloaded_name = getOverloadedName(explicit_n);
|
||||
String *ex_intermediary_function_name = Swig_name_member(proxy_class_name, ex_overloaded_name);
|
||||
|
||||
String *ex_imcall = Copy(imcall);
|
||||
Replaceall(ex_imcall, intermediary_function_name, ex_intermediary_function_name);
|
||||
|
||||
String *excode = NewString("");
|
||||
if (!Cmp(return_type, "void"))
|
||||
Printf(excode, "if (getClass() == %s.class) %s; else %s", proxy_class_name, imcall, ex_imcall);
|
||||
else
|
||||
Printf(excode, "(getClass() == %s.class) ? %s : %s", proxy_class_name, imcall, ex_imcall);
|
||||
|
||||
Clear(imcall);
|
||||
Printv(imcall, excode, NIL);
|
||||
Delete(ex_overloaded_name);
|
||||
Delete(excode);
|
||||
}
|
||||
|
||||
Replaceall(tm, "$jnicall", imcall);
|
||||
} else {
|
||||
Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number,
|
||||
|
|
@ -3464,6 +3490,22 @@ class JAVA : public Language {
|
|||
|
||||
Printf(w->code, "}");
|
||||
|
||||
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
||||
String *inline_extra_method = NewString("");
|
||||
if (dirprot_mode() && !is_public(n) && !pure_virtual)
|
||||
{
|
||||
Printv(inline_extra_method, declaration, NIL);
|
||||
String *extra_method_name = NewStringf("%sSwigPublic", name);
|
||||
Replaceall(inline_extra_method, name, extra_method_name);
|
||||
Replaceall(inline_extra_method, ";\n", " {\n ");
|
||||
if (!is_void)
|
||||
Printf(inline_extra_method, "return ");
|
||||
String *methodcall = Swig_method_call(super, l);
|
||||
Printv(inline_extra_method, methodcall, ";\n }\n", NIL);
|
||||
Delete(methodcall);
|
||||
Delete(extra_method_name);
|
||||
}
|
||||
|
||||
/* emit code */
|
||||
if (status == SWIG_OK && output_director) {
|
||||
if(!is_void) {
|
||||
|
|
@ -3475,9 +3517,11 @@ class JAVA : public Language {
|
|||
if (!Getattr(n,"defaultargs")) {
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(inline_extra_method);
|
||||
Delete(qualified_return);
|
||||
Delete(jnidesc);
|
||||
Delete(c_ret_type);
|
||||
|
|
@ -3767,6 +3811,14 @@ class JAVA : public Language {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* extraDirectorProtectedCPPMethodsRequired()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
bool extraDirectorProtectedCPPMethodsRequired() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* Java_director_declaration()
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue