Bill Hoffman patch to stop crashing when typewrapper class cannot be created. Overloading fixes for when methods cannot be disambiguated.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5712 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cff68da57b
commit
aed0e94056
2 changed files with 56 additions and 26 deletions
|
|
@ -495,11 +495,6 @@ class CSHARP : public Language {
|
||||||
if (!is_void_return)
|
if (!is_void_return)
|
||||||
Wrapper_add_localv(f,"jresult", c_return_type, "jresult = 0",NIL);
|
Wrapper_add_localv(f,"jresult", c_return_type, "jresult = 0",NIL);
|
||||||
|
|
||||||
Printv(imclass_class_code,
|
|
||||||
"\n [DllImport(\"",module_class_name,"\", EntryPoint=\"CSharp_",overloaded_name,"\")]\n", NIL);
|
|
||||||
|
|
||||||
Printf(imclass_class_code, " public static extern %s %s(", im_return_type, overloaded_name);
|
|
||||||
|
|
||||||
Printv(f->def, " DllExport ", c_return_type, " SWIGSTDCALL ", wname, "(", NIL);
|
Printv(f->def, " DllExport ", c_return_type, " SWIGSTDCALL ", wname, "(", NIL);
|
||||||
|
|
||||||
// Emit all of the local variables for holding arguments.
|
// Emit all of the local variables for holding arguments.
|
||||||
|
|
@ -507,7 +502,24 @@ class CSHARP : public Language {
|
||||||
|
|
||||||
/* Attach the standard typemaps */
|
/* Attach the standard typemaps */
|
||||||
emit_attach_parmmaps(l,f);
|
emit_attach_parmmaps(l,f);
|
||||||
|
|
||||||
|
// Parameter overloading
|
||||||
Setattr(n,"wrap:parms",l);
|
Setattr(n,"wrap:parms",l);
|
||||||
|
Setattr(n,"wrap:name", wname);
|
||||||
|
|
||||||
|
// Wrappers not wanted for some methods where the parameters cannot be overloaded in C#
|
||||||
|
if (Getattr(n,"sym:overloaded")) {
|
||||||
|
// Emit warnings for the few cases that can't be overloaded in C# and give up on generating wrapper
|
||||||
|
Swig_overload_check(n);
|
||||||
|
if (Getattr(n, "overload:ignore"))
|
||||||
|
return SWIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
Printv(imclass_class_code,
|
||||||
|
"\n [DllImport(\"",module_class_name,"\", EntryPoint=\"CSharp_",overloaded_name,"\")]\n", NIL);
|
||||||
|
|
||||||
|
Printf(imclass_class_code, " public static extern %s %s(", im_return_type, overloaded_name);
|
||||||
|
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
@ -709,14 +721,6 @@ class CSHARP : public Language {
|
||||||
if(!native_function_flag)
|
if(!native_function_flag)
|
||||||
Wrapper_print(f,f_wrappers);
|
Wrapper_print(f,f_wrappers);
|
||||||
|
|
||||||
Setattr(n,"wrap:name", wname);
|
|
||||||
|
|
||||||
/* Emit warnings for the few cases that can't be overloaded in C# */
|
|
||||||
if (Getattr(n,"sym:overloaded")) {
|
|
||||||
if (!Getattr(n,"sym:nextSibling"))
|
|
||||||
Swig_overload_rank(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!(proxy_flag && is_wrapping_class()) && !enum_constant_flag) {
|
if(!(proxy_flag && is_wrapping_class()) && !enum_constant_flag) {
|
||||||
moduleClassFunctionHandler(n);
|
moduleClassFunctionHandler(n);
|
||||||
}
|
}
|
||||||
|
|
@ -1237,6 +1241,9 @@ class CSHARP : public Language {
|
||||||
|
|
||||||
if(!proxy_flag) return;
|
if(!proxy_flag) return;
|
||||||
|
|
||||||
|
// Wrappers not wanted for some methods where the parameters cannot be overloaded in C#
|
||||||
|
if (Getattr(n, "overload:ignore")) return;
|
||||||
|
|
||||||
if (l) {
|
if (l) {
|
||||||
if (SwigType_type(Getattr(l,"type")) == T_VOID) {
|
if (SwigType_type(Getattr(l,"type")) == T_VOID) {
|
||||||
l = nextSibling(l);
|
l = nextSibling(l);
|
||||||
|
|
@ -1420,6 +1427,10 @@ class CSHARP : public Language {
|
||||||
|
|
||||||
Language::constructorHandler(n);
|
Language::constructorHandler(n);
|
||||||
|
|
||||||
|
// Wrappers not wanted for some methods where the parameters cannot be overloaded in C#
|
||||||
|
if (Getattr(n, "overload:ignore"))
|
||||||
|
return SWIG_OK;
|
||||||
|
|
||||||
if(proxy_flag) {
|
if(proxy_flag) {
|
||||||
String *overloaded_name = getOverloadedName(n);
|
String *overloaded_name = getOverloadedName(n);
|
||||||
String *imcall = NewString("");
|
String *imcall = NewString("");
|
||||||
|
|
@ -1874,9 +1885,14 @@ class CSHARP : public Language {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void emitTypeWrapperClass(String *classname, SwigType *type) {
|
void emitTypeWrapperClass(String *classname, SwigType *type) {
|
||||||
|
String *swigtype = NewString("");
|
||||||
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname);
|
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname);
|
||||||
File *f_swigtype = NewFile(filen,"w");
|
File *f_swigtype = NewFile(filen,"w");
|
||||||
String *swigtype = NewString("");
|
if(!f_swigtype) {
|
||||||
|
Printf(stderr,"Unable to open %s\n", filen);
|
||||||
|
SWIG_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
Delete(filen); filen = NULL;
|
||||||
|
|
||||||
// Emit banner and package name
|
// Emit banner and package name
|
||||||
emitBanner(f_swigtype);
|
emitBanner(f_swigtype);
|
||||||
|
|
@ -1923,7 +1939,6 @@ class CSHARP : public Language {
|
||||||
Printv(f_swigtype, swigtype, NIL);
|
Printv(f_swigtype, swigtype, NIL);
|
||||||
|
|
||||||
Close(f_swigtype);
|
Close(f_swigtype);
|
||||||
Delete(filen);
|
|
||||||
Delete(swigtype);
|
Delete(swigtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -768,7 +768,6 @@ class JAVA : public Language {
|
||||||
if (!is_void_return)
|
if (!is_void_return)
|
||||||
Wrapper_add_localv(f,"jresult", c_return_type, "jresult = 0",NIL);
|
Wrapper_add_localv(f,"jresult", c_return_type, "jresult = 0",NIL);
|
||||||
|
|
||||||
Printf(imclass_class_code, " public final static native %s %s(", im_return_type, overloaded_name);
|
|
||||||
Printv(f->def, "JNIEXPORT ", c_return_type, " JNICALL ", wname, "(JNIEnv *jenv, jclass jcls", NIL);
|
Printv(f->def, "JNIEXPORT ", c_return_type, " JNICALL ", wname, "(JNIEnv *jenv, jclass jcls", NIL);
|
||||||
|
|
||||||
// Usually these function parameters are unused - The code below ensures
|
// Usually these function parameters are unused - The code below ensures
|
||||||
|
|
@ -782,7 +781,20 @@ class JAVA : public Language {
|
||||||
|
|
||||||
/* Attach the standard typemaps */
|
/* Attach the standard typemaps */
|
||||||
emit_attach_parmmaps(l,f);
|
emit_attach_parmmaps(l,f);
|
||||||
|
|
||||||
|
// Parameter overloading
|
||||||
Setattr(n,"wrap:parms",l);
|
Setattr(n,"wrap:parms",l);
|
||||||
|
Setattr(n,"wrap:name", wname);
|
||||||
|
|
||||||
|
// Wrappers not wanted for some methods where the parameters cannot be overloaded in Java
|
||||||
|
if (Getattr(n,"sym:overloaded")) {
|
||||||
|
// Emit warnings for the few cases that can't be overloaded in Java and give up on generating wrapper
|
||||||
|
Swig_overload_check(n);
|
||||||
|
if (Getattr(n, "overload:ignore"))
|
||||||
|
return SWIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
Printf(imclass_class_code, " public final static native %s %s(", im_return_type, overloaded_name);
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
@ -990,14 +1002,6 @@ class JAVA : public Language {
|
||||||
if(!native_function_flag)
|
if(!native_function_flag)
|
||||||
Wrapper_print(f,f_wrappers);
|
Wrapper_print(f,f_wrappers);
|
||||||
|
|
||||||
Setattr(n,"wrap:name", wname);
|
|
||||||
|
|
||||||
/* Emit warnings for the few cases that can't be overloaded in Java */
|
|
||||||
if (Getattr(n,"sym:overloaded")) {
|
|
||||||
if (!Getattr(n,"sym:nextSibling"))
|
|
||||||
Swig_overload_rank(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!(proxy_flag && is_wrapping_class()) && !enum_constant_flag) {
|
if(!(proxy_flag && is_wrapping_class()) && !enum_constant_flag) {
|
||||||
moduleClassFunctionHandler(n);
|
moduleClassFunctionHandler(n);
|
||||||
}
|
}
|
||||||
|
|
@ -1597,6 +1601,9 @@ class JAVA : public Language {
|
||||||
|
|
||||||
if(!proxy_flag) return;
|
if(!proxy_flag) return;
|
||||||
|
|
||||||
|
// Wrappers not wanted for some methods where the parameters cannot be overloaded in Java
|
||||||
|
if (Getattr(n, "overload:ignore")) return;
|
||||||
|
|
||||||
if (l) {
|
if (l) {
|
||||||
if (SwigType_type(Getattr(l,"type")) == T_VOID) {
|
if (SwigType_type(Getattr(l,"type")) == T_VOID) {
|
||||||
l = nextSibling(l);
|
l = nextSibling(l);
|
||||||
|
|
@ -1738,6 +1745,10 @@ class JAVA : public Language {
|
||||||
|
|
||||||
Language::constructorHandler(n);
|
Language::constructorHandler(n);
|
||||||
|
|
||||||
|
// Wrappers not wanted for some methods where the parameters cannot be overloaded in Java
|
||||||
|
if (Getattr(n, "overload:ignore"))
|
||||||
|
return SWIG_OK;
|
||||||
|
|
||||||
if(proxy_flag) {
|
if(proxy_flag) {
|
||||||
String *overloaded_name = getOverloadedName(n);
|
String *overloaded_name = getOverloadedName(n);
|
||||||
String *mangled_overname = Swig_name_construct(overloaded_name);
|
String *mangled_overname = Swig_name_construct(overloaded_name);
|
||||||
|
|
@ -2163,9 +2174,14 @@ class JAVA : public Language {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void emitTypeWrapperClass(String *classname, SwigType *type) {
|
void emitTypeWrapperClass(String *classname, SwigType *type) {
|
||||||
|
String *swigtype = NewString("");
|
||||||
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname);
|
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname);
|
||||||
File *f_swigtype = NewFile(filen,"w");
|
File *f_swigtype = NewFile(filen,"w");
|
||||||
String *swigtype = NewString("");
|
if(!f_swigtype) {
|
||||||
|
Printf(stderr,"Unable to open %s\n", filen);
|
||||||
|
SWIG_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
Delete(filen); filen = NULL;
|
||||||
|
|
||||||
// Emit banner and package name
|
// Emit banner and package name
|
||||||
emitBanner(f_swigtype);
|
emitBanner(f_swigtype);
|
||||||
|
|
@ -2212,7 +2228,6 @@ class JAVA : public Language {
|
||||||
Printv(f_swigtype, swigtype, NIL);
|
Printv(f_swigtype, swigtype, NIL);
|
||||||
|
|
||||||
Close(f_swigtype);
|
Close(f_swigtype);
|
||||||
Delete(filen);
|
|
||||||
Delete(swigtype);
|
Delete(swigtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue