diff --git a/src/AST/Declaration.cs b/src/AST/Declaration.cs
index f785367e..26163743 100644
--- a/src/AST/Declaration.cs
+++ b/src/AST/Declaration.cs
@@ -31,7 +31,7 @@ namespace CppSharp.AST
public enum GenerationKind
{
///
- /// Declaration is not generated.
+ // Declaration is not generated.
///
None,
///
@@ -200,8 +200,7 @@ namespace CppSharp.AST
return generationKind.Value;
if (Namespace != null)
- // fields in nested classes have to always be generated
- return !Namespace.IsGenerated && this is Field ? GenerationKind.Internal : Namespace.GenerationKind;
+ return Namespace.GenerationKind;
return GenerationKind.Generate;
}
@@ -353,6 +352,7 @@ namespace CppSharp.AST
}
public abstract T Visit(IDeclVisitor visitor);
+
}
///
diff --git a/src/Generator/AST/Utils.cs b/src/Generator/AST/Utils.cs
index 8c83a0e9..6c3f2446 100644
--- a/src/Generator/AST/Utils.cs
+++ b/src/Generator/AST/Utils.cs
@@ -65,7 +65,7 @@ namespace CppSharp.AST
public static bool CheckIgnoreField(Field field, bool useInternals = false)
{
- if (field.Access == AccessSpecifier.Private && !useInternals)
+ if (field.Access == AccessSpecifier.Private)
return true;
if (field.Class.IsValueType && field.IsDeclared)
diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs
index 5ccc01bc..47ce0d15 100644
--- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs
+++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs
@@ -353,7 +353,7 @@ namespace CppSharp.Generators.CSharp
public void GenerateClass(Class @class)
{
- if (@class.IsIncomplete)
+ if (!@class.IsGenerated || @class.IsIncomplete)
return;
PushBlock(CSharpBlockKind.Class);
@@ -370,7 +370,7 @@ namespace CppSharp.Generators.CSharp
GenerateClassInternals(@class);
GenerateDeclContext(@class);
- if (@class.IsDependent || !@class.IsGenerated)
+ if (@class.IsDependent)
goto exit;
if (ShouldGenerateClassNativeField(@class))
@@ -720,15 +720,14 @@ namespace CppSharp.Generators.CSharp
if (!string.IsNullOrWhiteSpace(fieldTypePrinted.NameSuffix))
safeIdentifier += fieldTypePrinted.NameSuffix;
- var access = @class != null && !@class.IsGenerated ? "internal" : "public";
if (field.Expression != null)
{
var fieldValuePrinted = field.Expression.CSharpValue(ExpressionPrinter);
- Write("{0} {1} {2} = {3};", access, fieldTypePrinted.Type, safeIdentifier, fieldValuePrinted);
+ Write("public {0} {1} = {2};", fieldTypePrinted.Type, safeIdentifier, fieldValuePrinted);
}
else
{
- Write("{0} {1} {2};", access, fieldTypePrinted.Type, safeIdentifier);
+ Write("public {0} {1};", fieldTypePrinted.Type, safeIdentifier);
}
PopBlock(NewLineKind.BeforeNextBlock);
diff --git a/src/Generator/Library.cs b/src/Generator/Library.cs
index 026e8d06..bd32595e 100644
--- a/src/Generator/Library.cs
+++ b/src/Generator/Library.cs
@@ -184,7 +184,7 @@ namespace CppSharp
public static void IgnoreClassWithName(this ASTContext context, string name)
{
foreach (var @class in context.FindClass(name))
- @class.GenerationKind = GenerationKind.Internal;
+ @class.ExplicitlyIgnore();
}
public static void SetClassAsOpaque(this ASTContext context, string name)
diff --git a/src/Generator/Passes/CheckIgnoredDecls.cs b/src/Generator/Passes/CheckIgnoredDecls.cs
index ccbfc717..df425b90 100644
--- a/src/Generator/Passes/CheckIgnoredDecls.cs
+++ b/src/Generator/Passes/CheckIgnoredDecls.cs
@@ -40,13 +40,13 @@ namespace CppSharp.Passes
{
Log.Debug("Decl '{0}' was ignored due to invalid access",
decl.Name);
- decl.GenerationKind = decl is Field ? GenerationKind.Internal : GenerationKind.None;
+ decl.ExplicitlyIgnore();
return true;
}
if (decl.IsDependent)
{
- decl.GenerationKind = decl is Field ? GenerationKind.Internal : GenerationKind.None;
+ decl.ExplicitlyIgnore();
Log.Debug("Decl '{0}' was ignored due to dependent context",
decl.Name);
return true;
@@ -62,13 +62,11 @@ namespace CppSharp.Passes
var type = field.Type;
- Declaration decl;
- type.TryGetDeclaration(out decl);
- string msg = "internal";
- if (decl == null || (decl.GenerationKind != GenerationKind.Internal && !HasInvalidType(type, out msg)))
+ string msg;
+ if (!HasInvalidType(type, out msg))
return false;
- field.GenerationKind = GenerationKind.Internal;
+ field.ExplicitlyIgnore();
var @class = (Class)field.Namespace;
diff --git a/tests/Basic/Basic.cs b/tests/Basic/Basic.cs
index 269386a7..42a75b2b 100644
--- a/tests/Basic/Basic.cs
+++ b/tests/Basic/Basic.cs
@@ -34,7 +34,6 @@ namespace CppSharp.Tests
driver.AddTranslationUnitPass(new CheckMacroPass());
ctx.SetClassAsValueType("Bar");
ctx.SetClassAsValueType("Bar2");
- ctx.IgnoreClassWithName("IgnoredType");
}
public static void Main(string[] args)
diff --git a/tests/Basic/Basic.h b/tests/Basic/Basic.h
index 0738d774..f3f3a8c8 100644
--- a/tests/Basic/Basic.h
+++ b/tests/Basic/Basic.h
@@ -6,17 +6,6 @@
#endif
#include
-class DLL_API IgnoredType
-{
- class IgnoredNested
- {
- private:
- int i;
- };
-private:
- int i;
-};
-
class DLL_API Foo
{
private:
@@ -31,7 +20,6 @@ public:
Foo(Private p);
int A;
float B;
- IgnoredType ignoredType;
int fixedArray[3];
void* ptr;
static const int unsafe = 10;
diff --git a/tests/CSharpTemp/CSharpTemp.Tests.cs b/tests/CSharpTemp/CSharpTemp.Tests.cs
index dbe0a858..3e09c37e 100644
--- a/tests/CSharpTemp/CSharpTemp.Tests.cs
+++ b/tests/CSharpTemp/CSharpTemp.Tests.cs
@@ -209,12 +209,6 @@ public class CSharpTempTests : GeneratorTestFixture
Assert.That(res, Is.EqualTo(50));
}
- [Test]
- public void TestInnerClasses()
- {
- QMap.Iterator test_iter;
- }
-
[Test]
public void TestNativeToManagedMapWithForeignObjects()
{
diff --git a/tests/CSharpTemp/CSharpTemp.cs b/tests/CSharpTemp/CSharpTemp.cs
index 586e6502..035999af 100644
--- a/tests/CSharpTemp/CSharpTemp.cs
+++ b/tests/CSharpTemp/CSharpTemp.cs
@@ -59,7 +59,8 @@ namespace CppSharp.Tests
public override string CSharpSignature(CSharpTypePrinterContext ctx)
{
if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
- return Type.IsAddress() ? "QList.Internal*" : "QList.Internal";
+ // pointless, put just so that the generated code compiles
+ return "global::System.IntPtr";
return string.Format("System.Collections.Generic.{0}<{1}>",
ctx.CSharpKind == CSharpTypePrinterContextKind.DefaultExpression ? "List" : "IList",
@@ -69,7 +70,7 @@ namespace CppSharp.Tests
public override void CSharpMarshalToNative(MarshalContext ctx)
{
// pointless, put just so that the generated code compiles
- ctx.Return.Write("new QList.Internal()");
+ ctx.Return.Write("new global::System.IntPtr()");
}
public override void CSharpMarshalToManaged(MarshalContext ctx)