Browse Source

Revert "Included ignored fields in the wrappers for better marshalling."

This reverts commit 65cac93259.

Conflicts:
	src/Generator/Generators/CSharp/CSharpTextTemplate.cs
	tests/Basic/Basic.h

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/496/merge
Dimitar Dobrev 10 years ago
parent
commit
27d3f21a75
  1. 6
      src/AST/Declaration.cs
  2. 2
      src/Generator/AST/Utils.cs
  3. 9
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  4. 2
      src/Generator/Library.cs
  5. 12
      src/Generator/Passes/CheckIgnoredDecls.cs
  6. 1
      tests/Basic/Basic.cs
  7. 12
      tests/Basic/Basic.h
  8. 6
      tests/CSharpTemp/CSharpTemp.Tests.cs
  9. 5
      tests/CSharpTemp/CSharpTemp.cs

6
src/AST/Declaration.cs

@ -31,7 +31,7 @@ namespace CppSharp.AST @@ -31,7 +31,7 @@ namespace CppSharp.AST
public enum GenerationKind
{
/// <summary>
/// Declaration is not generated.
// Declaration is not generated.
/// </summary>
None,
/// <summary>
@ -200,8 +200,7 @@ namespace CppSharp.AST @@ -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 @@ -353,6 +352,7 @@ namespace CppSharp.AST
}
public abstract T Visit<T>(IDeclVisitor<T> visitor);
}
/// <summary>

2
src/Generator/AST/Utils.cs

@ -65,7 +65,7 @@ namespace CppSharp.AST @@ -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)

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

@ -353,7 +353,7 @@ namespace CppSharp.Generators.CSharp @@ -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 @@ -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 @@ -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);

2
src/Generator/Library.cs

@ -184,7 +184,7 @@ namespace CppSharp @@ -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)

12
src/Generator/Passes/CheckIgnoredDecls.cs

@ -40,13 +40,13 @@ namespace CppSharp.Passes @@ -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 @@ -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;

1
tests/Basic/Basic.cs

@ -34,7 +34,6 @@ namespace CppSharp.Tests @@ -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)

12
tests/Basic/Basic.h

@ -6,17 +6,6 @@ @@ -6,17 +6,6 @@
#endif
#include <string>
class DLL_API IgnoredType
{
class IgnoredNested
{
private:
int i;
};
private:
int i;
};
class DLL_API Foo
{
private:
@ -31,7 +20,6 @@ public: @@ -31,7 +20,6 @@ public:
Foo(Private p);
int A;
float B;
IgnoredType ignoredType;
int fixedArray[3];
void* ptr;
static const int unsafe = 10;

6
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -209,12 +209,6 @@ public class CSharpTempTests : GeneratorTestFixture @@ -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()
{

5
tests/CSharpTemp/CSharpTemp.cs

@ -59,7 +59,8 @@ namespace CppSharp.Tests @@ -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 @@ -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)

Loading…
Cancel
Save