From baa06d2509513698f828c7fa57a4254781448f33 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Dec 2003 00:13:10 +0000 Subject: [PATCH] %javamethodmodifiers (java) and %csmethodmodifiers (C#) operate slightly differently. Previously this had to be present to set the method modifiers. Now this feature is only used if it exists for the method being wrapped. The default is "public" as previous however, when wrapping protected director methods it is "protected". git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5553 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Modules/csharp.cxx | 17 ++++++++++++++--- SWIG/Source/Modules/java.cxx | 16 +++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/SWIG/Source/Modules/csharp.cxx b/SWIG/Source/Modules/csharp.cxx index 922da3de7..6360b51d7 100644 --- a/SWIG/Source/Modules/csharp.cxx +++ b/SWIG/Source/Modules/csharp.cxx @@ -22,6 +22,8 @@ char cvsroot_csharp_cxx[] = "$Header$"; class CSHARP : public Language { static const char *usage; const String *empty_string; + const String *public_string; + const String *protected_string; Hash *swig_types_hash; File *f_runtime; @@ -71,6 +73,8 @@ class CSHARP : public Language { CSHARP() : empty_string(NewString("")), + public_string(NewString("public")), + protected_string(NewString("protected")), swig_types_hash(NULL), f_runtime(NULL), @@ -1262,7 +1266,9 @@ class CSHARP : public Language { } /* Start generating the proxy function */ - Printf(function_code, " %s ", Getattr(n,"feature:cs:methodmodifiers")); + const String *methodmods = Getattr(n,"feature:cs:methodmodifiers"); + methodmods = methodmods ? methodmods : (is_protected(n) ? protected_string : public_string); + Printf(function_code, " %s ", methodmods); if (static_flag) Printf(function_code, "static "); if (Getattr(n,"virtual:derived")) @@ -1416,7 +1422,10 @@ class CSHARP : public Language { String *overloaded_name = getOverloadedName(n); String *imcall = NewString(""); - Printf(proxy_class_code, " %s %s(", Getattr(n,"feature:cs:methodmodifiers"), proxy_class_name); + const String *methodmods = Getattr(n,"feature:cs:methodmodifiers"); + methodmods = methodmods ? methodmods : (is_protected(n) ? protected_string : public_string); + methodmods = methodmods ? methodmods : public_string; + Printf(proxy_class_code, " %s %s(", methodmods, proxy_class_name); Printv(imcall, " : this(", imclass_name, ".", Swig_name_construct(overloaded_name), "(", NIL); /* Attach the non-standard typemaps to the parameter list */ @@ -1664,7 +1673,9 @@ class CSHARP : public Language { } /* Start generating the function */ - Printf(function_code, " %s static %s %s(", Getattr(n,"feature:cs:methodmodifiers"), return_type, func_name); + const String *methodmods = Getattr(n,"feature:cs:methodmodifiers"); + methodmods = methodmods ? methodmods : (is_protected(n) ? protected_string : public_string); + Printf(function_code, " %s static %s %s(", methodmods, return_type, func_name); Printv(imcall, imclass_name, ".", overloaded_name, "(", NIL); /* Get number of required and total arguments */ diff --git a/SWIG/Source/Modules/java.cxx b/SWIG/Source/Modules/java.cxx index d150164ea..48df4c933 100644 --- a/SWIG/Source/Modules/java.cxx +++ b/SWIG/Source/Modules/java.cxx @@ -26,6 +26,8 @@ typedef DOH UpcallData; class JAVA : public Language { static const char *usage; const String *empty_string; + const String *public_string; + const String *protected_string; Hash *swig_types_hash; File *f_runtime; @@ -92,6 +94,8 @@ class JAVA : public Language { JAVA() : empty_string(NewString("")), + public_string(NewString("public")), + protected_string(NewString("protected")), swig_types_hash(NULL), f_runtime(NULL), @@ -1617,7 +1621,9 @@ class JAVA : public Language { } /* Start generating the proxy function */ - Printf(function_code, " %s ", Getattr(n,"feature:java:methodmodifiers")); + const String *methodmods = Getattr(n,"feature:java:methodmodifiers"); + methodmods = methodmods ? methodmods : (is_protected(n) ? protected_string : public_string); + Printf(function_code, " %s ", methodmods); if (static_flag) Printf(function_code, "static "); Printf(function_code, "%s %s(", return_type, proxy_function_name); @@ -1735,7 +1741,9 @@ class JAVA : public Language { String *mangled_overname = Swig_name_construct(overloaded_name); String *imcall = NewString(""); - Printf(proxy_class_code, " %s %s(", Getattr(n,"feature:java:methodmodifiers"), proxy_class_name); + const String *methodmods = Getattr(n,"feature:java:methodmodifiers"); + methodmods = methodmods ? methodmods : (is_protected(n) ? protected_string : public_string); + Printf(proxy_class_code, " %s %s(", methodmods, proxy_class_name); Printv(imcall, "this(", imclass_name, ".", mangled_overname, "(", NIL); /* Attach the non-standard typemaps to the parameter list */ @@ -1988,7 +1996,9 @@ class JAVA : public Language { } /* Start generating the function */ - Printf(function_code, " %s static %s %s(", Getattr(n,"feature:java:methodmodifiers"), return_type, func_name); + const String *methodmods = Getattr(n,"feature:java:methodmodifiers"); + methodmods = methodmods ? methodmods : (is_protected(n) ? protected_string : public_string); + Printf(function_code, " %s static %s %s(", methodmods, return_type, func_name); Printv(imcall, imclass_name, ".", overloaded_name, "(", NIL); /* Get number of required and total arguments */