Formatting fixes in generated code for interface feature

This commit is contained in:
William S Fulton 2016-02-05 20:12:58 +00:00
commit a7370b7bc0
4 changed files with 25 additions and 29 deletions

View file

@ -1,18 +1,14 @@
%define DECLARE_INTERFACE_(CTYPE, INTERFACE, IMPL)
%feature("interface", name = "INTERFACE", cptr = "GetCPtr") CTYPE;
%typemap(cstype) CTYPE*, const CTYPE& "INTERFACE"
%typemap(csdirectorout) CTYPE*, const CTYPE& "$cscall.GetCPtr()"
%typemap(csdirectorin) CTYPE*, const CTYPE&
%{
(INTERFACE)new IMPL($iminput,false)
%}
%typemap(csin) CTYPE*, const CTYPE& "$csinput.GetCPtr()"
%typemap(csout, excode=SWIGEXCODE) CTYPE*, const CTYPE&
{
IMPL ret = new IMPL($imcall,true);
$excode
return (INTERFACE)ret;
}
%typemap(cstype) CTYPE *, CTYPE & "INTERFACE"
%typemap(csdirectorout) CTYPE *, CTYPE & "$cscall.GetCPtr()"
%typemap(csdirectorin) CTYPE *, CTYPE & "(INTERFACE)new IMPL($iminput, false)"
%typemap(csin) CTYPE * "$csinput == null ? new HandleRef(null, IntPtr.Zero) : $csinput.GetCPtr()"
%typemap(csin) CTYPE & "$csinput.GetCPtr()"
%typemap(csout, excode=SWIGEXCODE) CTYPE *, CTYPE & {
IMPL ret = new IMPL($imcall, true);$excode
return (INTERFACE)ret;
}
%enddef
%define DECLARE_INTERFACE_RENAME(CTYPE, INTERFACE, IMPL)

View file

@ -1,19 +1,15 @@
%define DECLARE_INTERFACE_(CTYPE, INTERFACE, IMPL)
%feature("interface", name = "INTERFACE", cptr = #INTERFACE ## "_getCPtr") CTYPE;
%typemap(jstype) CTYPE*, const CTYPE& "INTERFACE"
%typemap(jtype, nopgcpp="1") CTYPE*, const CTYPE& "long"
%typemap(javadirectorout) CTYPE*, const CTYPE& "$javacall." ## #INTERFACE ## "_getCPtr()"
%typemap(javadirectorin) CTYPE*, const CTYPE&
%{
($jniinput == 0) ? null : (INTERFACE)new IMPL($jniinput,false)
%}
%typemap(jstype) CTYPE *, const CTYPE & "INTERFACE"
%typemap(jtype, nopgcpp="1") CTYPE *, const CTYPE & "long"
%typemap(javadirectorout) CTYPE *, const CTYPE & "$javacall." ## #INTERFACE ## "_getCPtr()"
%typemap(javadirectorin) CTYPE *, const CTYPE & "($jniinput == 0) ? null : (INTERFACE)new IMPL($jniinput, false)"
%typemap(javain) CTYPE * "($javainput == null) ? 0 : $javainput." ## #INTERFACE ## "_getCPtr()"
%typemap(javain) const CTYPE & "$javainput." ## #INTERFACE ## "_getCPtr()"
%typemap(javaout) CTYPE*, const CTYPE&
{
long cPtr = $jnicall;
return (cPtr == 0) ? null : (INTERFACE)new IMPL(cPtr,true);
}
%typemap(javaout) CTYPE *, const CTYPE & {
long cPtr = $jnicall;
return (cPtr == 0) ? null : (INTERFACE)new IMPL(cPtr, true);
}
SWIG_JAVABODY_PROXY(public, protected, CTYPE)
%enddef

View file

@ -1609,17 +1609,19 @@ public:
Append(interface_list, ", ");
Append(interface_list, iname);
Printf(interface_upcasts, "\n");
Printf(interface_upcasts, " [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n");
String* upcast_name = 0;
if (String* cptr_func = Getattr(base, "feature:interface:cptr"))
upcast_name = NewStringf("%s.%s", iname, cptr_func);
else
upcast_name = NewStringf("%s.GetCPtr", iname);
Printf(interface_upcasts, " HandleRef %s()", upcast_name);
Printf(interface_upcasts, " HandleRef %s() {\n", upcast_name);
Replaceall(upcast_name, ".", "_");
String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name);
String *wname = Swig_name_wrapper(upcast_method);
Printf(interface_upcasts, "{ return new HandleRef((%s)this, %s.%s(swigCPtr.Handle)); }\n", iname, imclass_name, upcast_method );
Printf(interface_upcasts, " return new HandleRef((%s)this, %s.%s(swigCPtr.Handle));\n", iname, imclass_name, upcast_method);
Printf(interface_upcasts, " }\n");
Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
Printf(imclass_cppcasts_code, " public static extern IntPtr %s(IntPtr jarg1);\n", upcast_method);
Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);

View file

@ -1740,12 +1740,14 @@ public:
upcast_name = NewStringf("%s", cptr_func);
else
upcast_name = NewStringf("%s_getCPtr", iname);
Printf(interface_upcasts, " public long %s()", upcast_name);
Printf(interface_upcasts, "\n");
Printf(interface_upcasts, " public long %s() {\n", upcast_name);
Replaceall(upcast_name, ".", "_");
String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name);
String *jniname = makeValidJniName(upcast_method);
String *wname = Swig_name_wrapper(jniname);
Printf(interface_upcasts, "{ return %s.%s(swigCPtr); }\n", imclass_name, upcast_method );
Printf(interface_upcasts, " return %s.%s(swigCPtr);\n", imclass_name, upcast_method);
Printf(interface_upcasts, " }\n");
Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method);
Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);
Printv(upcasts_code,