Created
May 11, 2015 02:45
-
-
Save genuinelucifer/d3a853567246d5c0259a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/AST/Class.cs b/src/AST/Class.cs | |
index 45b535f..07e1d53 100644 | |
--- a/src/AST/Class.cs | |
+++ b/src/AST/Class.cs | |
@@ -10,7 +10,8 @@ public enum AccessSpecifier | |
{ | |
Private, | |
Protected, | |
- Public | |
+ Public, | |
+ Internal //via the CS_INTERNAL macro (to be implemen | |
} | |
// A C++ access specifier declaration. | |
diff --git a/src/Generator.Tests/Passes/TestPasses.cs b/src/Generator.Tests/Pass | |
index 6a6de8c..b66b413 100644 | |
--- a/src/Generator.Tests/Passes/TestPasses.cs | |
+++ b/src/Generator.Tests/Passes/TestPasses.cs | |
@@ -191,5 +191,16 @@ public void TestCheckAmbiguousFunctionsPass() | |
Assert.IsTrue(constMethodWithParam.GenerationKind == GenerationKind | |
Assert.IsTrue(nonConstMethodWithParam.GenerationKind == GenerationK | |
} | |
+ | |
+ [Test] | |
+ public void TestSetMethodAsInternal() | |
+ { | |
+ const string className = "TestMethodAsInternal"; | |
+ passBuilder.AddPass(new CheckMacroPass()); | |
+ passBuilder.RunPasses(pass => pass.VisitLibrary(AstContext)); | |
+ Assert.AreEqual(AccessSpecifier.Internal,AstContext.FindClass( | |
+ className).First().Methods.Find( | |
+ m => m.Signature.Contains("CS_INTERNAL")).Access); | |
+ } | |
} | |
} | |
diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generat | |
index f4f2345..ef0a242 100644 | |
--- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs | |
+++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs | |
@@ -53,6 +53,7 @@ public static string GetAccess(AccessSpecifier accessSpecifier | |
switch (accessSpecifier) | |
{ | |
case AccessSpecifier.Private: | |
+ case AccessSpecifier.Internal: | |
return "internal "; | |
case AccessSpecifier.Protected: | |
return "protected "; | |
diff --git a/src/Generator/Passes/CheckMacrosPass.cs b/src/Generator/Passes/Chec | |
index 26f2caa..62ace33 100644 | |
--- a/src/Generator/Passes/CheckMacrosPass.cs | |
+++ b/src/Generator/Passes/CheckMacrosPass.cs | |
@@ -42,6 +42,10 @@ namespace CppSharp.Passes | |
/// CS_CONSTRAINT(TYPE [, TYPE]*) (templates) | |
/// Used to define constraint of generated generic type or generic | |
/// | |
+ /// CS_INTERNAL (methods) | |
+ /// Used to flag a method as internal to an assembly. So, it is | |
+ /// not accessible outside that assembly. | |
+ /// | |
/// There isn't a standardized header provided by CppSharp so you will | |
/// have to define these on your own. | |
/// </summary> | |
@@ -155,6 +159,9 @@ public override bool VisitMethodDecl(Method method) | |
|| e.Text == Prefix + "_EQUALS")) | |
method.ExplicitlyIgnore(); | |
+ if (expansions.Any(e => e.Text == Prefix + "_INTERNAL")) //Flag a m | |
+ method.Access = AccessSpecifier.Internal; | |
+ | |
return base.VisitMethodDecl(method); | |
} | |
(END) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment