From b29514ffcfaf1c871a3630366b4e5f81123f14fd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 26 May 2005 20:49:03 +0000 Subject: [PATCH] %csmethodmodifiers can be applied to variables as well as methods now. %csmethodmodifiers will replace the virtual/new/override modifiers that SWIG thinks is appropriate in addition to the default 'public'. This is necessary for some obscure cases where SWIG might get the modifiers incorrect, for example with private inheritance. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7227 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 8d455928f..907319357 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1569,16 +1569,20 @@ class CSHARP : public Language { if (csattributes) Printf(function_code, " %s\n", csattributes); const String *methodmods = Getattr(n,"feature:cs:methodmodifiers"); - methodmods = methodmods ? methodmods : (!is_public(n) ? protected_string : public_string); - Printf(function_code, " %s ", methodmods); + if (methodmods) { + Printf(function_code, " %s ", methodmods); + } else { + methodmods = (!is_public(n) ? protected_string : public_string); + Printf(function_code, " %s ", methodmods); + if (Getattr(n,"override")) + Printf(function_code, "override "); + else if (checkAttribute(n, "storage", "virtual")) + Printf(function_code, "virtual "); + if (Getattr(n, "hides")) + Printf(function_code, "new "); + } if (static_flag) Printf(function_code, "static "); - if (Getattr(n,"override")) - Printf(function_code, "override "); - else if (checkAttribute(n, "storage", "virtual")) - Printf(function_code, "virtual "); - if (Getattr(n, "hides")) - Printf(function_code, "new "); Printf(function_code, "%s %s(", return_type, proxy_function_name); @@ -1685,7 +1689,10 @@ class CSHARP : public Language { const String *csattributes = Getattr(n,"feature:cs:attributes"); if (csattributes) Printf(proxy_class_code, " %s\n", csattributes); - Printf(proxy_class_code, " public %s%s %s {", static_flag ? "static " : "", variable_type, variable_name); + const String *methodmods = Getattr(n,"feature:cs:methodmodifiers"); + if (!methodmods) + methodmods = (!is_public(n) ? protected_string : public_string); + Printf(proxy_class_code, " %s %s%s %s {", methodmods, static_flag ? "static " : "", variable_type, variable_name); } generate_property_declaration_flag = false; @@ -2089,7 +2096,10 @@ class CSHARP : public Language { const String *csattributes = Getattr(n,"feature:cs:attributes"); if (csattributes) Printf(module_class_code, " %s\n", csattributes); - Printf(module_class_code, " public static %s %s {", variable_type, variable_name); + const String *methodmods = Getattr(n,"feature:cs:methodmodifiers"); + if (!methodmods) + methodmods = (!is_public(n) ? protected_string : public_string); + Printf(module_class_code, " %s static %s %s {", methodmods, variable_type, variable_name); } generate_property_declaration_flag = false;