Browse Source

Added CS_INTERNAL macro definition and test.

pull/448/head
Abhinav Tripathi 10 years ago
parent
commit
c7c74e306b
  1. 3
      src/AST/Class.cs
  2. 11
      src/Generator.Tests/Passes/TestPasses.cs
  3. 1
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  4. 7
      src/Generator/Passes/CheckMacrosPass.cs
  5. 6
      tests/Native/Passes.h

3
src/AST/Class.cs

@ -10,7 +10,8 @@ namespace CppSharp.AST @@ -10,7 +10,8 @@ namespace CppSharp.AST
{
Private,
Protected,
Public
Public,
Internal
}
// A C++ access specifier declaration.

11
src/Generator.Tests/Passes/TestPasses.cs

@ -191,5 +191,16 @@ namespace CppSharp.Generator.Tests.Passes @@ -191,5 +191,16 @@ namespace CppSharp.Generator.Tests.Passes
Assert.IsTrue(constMethodWithParam.GenerationKind == GenerationKind.None);
Assert.IsTrue(nonConstMethodWithParam.GenerationKind == GenerationKind.Generate);
}
[Test]
public void TestSetMethodAsInternal()
{
var c = AstContext.Class("TestMethodAsInternal");
var method = c.Method("beInternal");
Assert.AreEqual(method.Access , AccessSpecifier.Public);
passBuilder.AddPass(new CheckMacroPass());
passBuilder.RunPasses(pass => pass.VisitLibrary(AstContext));
Assert.AreEqual(method.Access , AccessSpecifier.Internal);
}
}
}

1
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -53,6 +53,7 @@ namespace CppSharp.Generators.CSharp @@ -53,6 +53,7 @@ namespace CppSharp.Generators.CSharp
switch (accessSpecifier)
{
case AccessSpecifier.Private:
case AccessSpecifier.Internal:
return "internal ";
case AccessSpecifier.Protected:
return "protected ";

7
src/Generator/Passes/CheckMacrosPass.cs

@ -42,6 +42,10 @@ namespace CppSharp.Passes @@ -42,6 +42,10 @@ namespace CppSharp.Passes
/// CS_CONSTRAINT(TYPE [, TYPE]*) (templates)
/// Used to define constraint of generated generic type or generic method.
///
/// 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 @@ namespace CppSharp.Passes @@ -155,6 +159,9 @@ namespace CppSharp.Passes
|| e.Text == Prefix + "_EQUALS"))
method.ExplicitlyIgnore();
if (expansions.Any(e => e.Text == Prefix + "_INTERNAL"))
method.Access = AccessSpecifier.Internal;
return base.VisitMethodDecl(method);
}

6
tests/Native/Passes.h

@ -61,3 +61,9 @@ struct TestCheckAmbiguousFunctionsPass @@ -61,3 +61,9 @@ struct TestCheckAmbiguousFunctionsPass
int Method(int x);
int Method(int x) const;
};
#define CS_INTERNAL
struct TestMethodAsInternal
{
int CS_INTERNAL beInternal();
};

Loading…
Cancel
Save