From 01cc0b2bd8e1f3a8de422c42bbd5fdd771d1b067 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 31 Oct 2006 21:59:33 +0000 Subject: [PATCH] Fix %csmethodmodifiers for smart pointers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9494 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 981275448..be3c4faf3 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1917,9 +1917,20 @@ class CSHARP : public Language { Printf(function_code, " %s\n", csattributes); const String *methodmods = Getattr(n,"feature:cs:methodmodifiers"); if (methodmods) { - Printf(function_code, " %s ", methodmods); + if (is_smart_pointer()) { + // Smart pointer classes do not mirror the inheritance hierarchy of the underlying pointer type, so no virtual/override/new required. + String *mmods = Copy(methodmods); + Replaceall(mmods, "override", ""); + Replaceall(mmods, "virtual", ""); + Replaceall(mmods, "new", ""); + Chop(mmods); // remove trailing whitespace + Printf(function_code, " %s ", mmods); + Delete(mmods); + } else { + Printf(function_code, " %s ", methodmods); + } } else { - methodmods = (!is_public(n) ? protected_string : public_string); + methodmods = (is_public(n) ? public_string : protected_string); Printf(function_code, " %s ", methodmods); if (!is_smart_pointer()) { // Smart pointer classes do not mirror the inheritance hierarchy of the underlying pointer type, so no virtual/override/new required. @@ -2062,12 +2073,11 @@ class CSHARP : public Language { Printf(proxy_class_code, " %s\n", csattributes); const String *methodmods = Getattr(n,"feature:cs:methodmodifiers"); if (!methodmods) - methodmods = (!is_public(n) ? protected_string : public_string); + methodmods = (is_public(n) ? public_string : protected_string); Printf(proxy_class_code, " %s %s%s %s {", methodmods, static_flag ? "static " : "", variable_type, variable_name); } generate_property_declaration_flag = false; - if(setter_flag) { // Setter method Swig_typemap_attach_parms("csvarin", l, NULL); @@ -2137,7 +2147,7 @@ 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); + methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); Printf(function_code, " %s %s(", methodmods, proxy_class_name); Printv(imcall, imclass_name, ".", mangled_overname, "(", NIL); @@ -2394,7 +2404,7 @@ 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); + methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); Printf(function_code, " %s static %s %s(", methodmods, return_type, func_name); Printv(imcall, imclass_name, ".", overloaded_name, "(", NIL); @@ -2490,7 +2500,7 @@ class CSHARP : public Language { Printf(module_class_code, " %s\n", csattributes); const String *methodmods = Getattr(n,"feature:cs:methodmodifiers"); if (!methodmods) - methodmods = (!is_public(n) ? protected_string : public_string); + methodmods = (is_public(n) ? public_string : protected_string); Printf(module_class_code, " %s static %s %s {", methodmods, variable_type, variable_name); } generate_property_declaration_flag = false;