Covariant return type fixes...
Fixed error where the base class was being used to wrap the derived class C++ pointer. Also fixed runtime error when using directors - the wrong canonical description was not using the base class type. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5589 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
98e493b6fa
commit
0af36656c1
1 changed files with 10 additions and 3 deletions
|
|
@ -1587,7 +1587,7 @@ class JAVA : public Language {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void proxyClassFunctionHandler(Node *n) {
|
||||
SwigType *t = Getattr(n,"virtual:type") ? Getattr(n,"virtual:type") : Getattr(n,"type");
|
||||
SwigType *t = Getattr(n,"type");
|
||||
ParmList *l = Getattr(n,"parms");
|
||||
String *intermediary_function_name = Getattr(n,"imfuncname");
|
||||
String *proxy_function_name = Getattr(n,"proxyfuncname");
|
||||
|
|
@ -1613,8 +1613,13 @@ class JAVA : public Language {
|
|||
|
||||
/* Get return types */
|
||||
if ((tm = Swig_typemap_lookup_new("jstype",n,"",0))) {
|
||||
substituteClassname(t, tm);
|
||||
// Note that in the case of polymorphic (covariant) return types, the method's return type is changed to be the base of the C++ return type
|
||||
SwigType *virtualtype = Getattr(n,"virtual:type");
|
||||
substituteClassname(virtualtype ? virtualtype : t, tm);
|
||||
Printf(return_type, "%s", tm);
|
||||
if (virtualtype)
|
||||
Swig_warning(WARN_JAVA_COVARIANT_RET, input_file, line_number,
|
||||
"Covariant return types not supported in Java. Proxy method will return %s.\n", SwigType_str(virtualtype,0));
|
||||
} else {
|
||||
Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number,
|
||||
"No jstype typemap defined for %s\n", SwigType_str(t,0));
|
||||
|
|
@ -2636,7 +2641,9 @@ class JAVA : public Language {
|
|||
&& (jdesc = Getattr(retpm, "tmap:directorin:descriptor")) != NULL) {
|
||||
String *jnidesc_canon;
|
||||
|
||||
jnidesc_canon = canonicalJNIFDesc(jdesc, n, return_type);
|
||||
// Note that in the case of polymorphic (covariant) return types, the method's return type is changed to be the base of the C++ return type
|
||||
SwigType *virtualtype = Getattr(n,"virtual:type");
|
||||
jnidesc_canon = canonicalJNIFDesc(jdesc, n, virtualtype ? virtualtype : return_type);
|
||||
Append(classret_desc, jnidesc_canon);
|
||||
Delete(jnidesc_canon);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue