public void DoubleVoidPointerParameterPreserved() { var cppParameter = new CppParameter("param") { TypeName = "void", Pointer = "**", Attribute = ParamAttribute.Out }; var typeRegistry = new TypeRegistry(Logger, A.Fake <IDocumentationLinker>()); typeRegistry.BindType("void", TypeRegistry.Void); var marshalledElementFactory = new MarshalledElementFactory(Logger, new GlobalNamespaceProvider(), typeRegistry); var csParameter = marshalledElementFactory.Create(cppParameter, cppParameter.Name); Assert.Equal(TypeRegistry.IntPtr, csParameter.PublicType); Assert.Equal(TypeRegistry.IntPtr, csParameter.MarshalType); Assert.True(csParameter.HasPointer); Assert.False(csParameter.IsArray); Assert.True(csParameter.IsOut); Assert.Equal(0, csParameter.ArrayDimensionValue); }
public void TriplePointerInterfaceParameterMappedAsIntPtr() { var cppParameter = new CppParameter("param") { TypeName = "Interface", Pointer = "***" }; var typeRegistry = new TypeRegistry(Logger, A.Fake <IDocumentationLinker>()); typeRegistry.BindType("Interface", new CsInterface(null, "Interface")); var marshalledElementFactory = new MarshalledElementFactory(Logger, new GlobalNamespaceProvider(), typeRegistry); var csParameter = marshalledElementFactory.Create(cppParameter, cppParameter.Name); Assert.Equal(TypeRegistry.IntPtr, csParameter.PublicType); Assert.Equal(TypeRegistry.IntPtr, csParameter.MarshalType); Assert.True(csParameter.HasPointer); Assert.False(csParameter.IsArray); Assert.Equal(0, csParameter.ArrayDimensionValue); }
public void WCharPointerMappedToStringMarshalledWithIntPtr() { var cppMarshallable = new CppParameter("param") { TypeName = "wchar_t", Pointer = "*" }; var typeRegistry = new TypeRegistry(Logger, A.Fake <IDocumentationLinker>()); var marshalledElementFactory = new MarshalledElementFactory(Logger, new GlobalNamespaceProvider(), typeRegistry); var csMarshallable = marshalledElementFactory.Create(cppMarshallable, cppMarshallable.Name); Assert.Equal(TypeRegistry.String, csMarshallable.PublicType); Assert.Equal(TypeRegistry.IntPtr, csMarshallable.MarshalType); Assert.False(csMarshallable.IsArray); Assert.True(csMarshallable.HasPointer); Assert.True(csMarshallable.IsString); Assert.True(csMarshallable.IsWideChar); Assert.Equal(0, csMarshallable.ArrayDimensionValue); }
public void TriplePointerInterfaceParameterMappedAsIntPtr() { var cppParameter = new CppParameter { TypeName = "Interface", Pointer = "***" }; var typeRegistry = new TypeRegistry(Logger, A.Fake <IDocumentationLinker>()); typeRegistry.BindType("Interface", new CsInterface { Name = "Interface" }); var marshalledElementFactory = new MarshalledElementFactory(Logger, new GlobalNamespaceProvider(), typeRegistry); var csParameter = marshalledElementFactory.Create(cppParameter); Assert.Equal(typeRegistry.ImportType(typeof(IntPtr)), csParameter.PublicType); Assert.Equal(typeRegistry.ImportType(typeof(IntPtr)), csParameter.MarshalType); Assert.True(csParameter.HasPointer); }
public void ParameterWithStructSizeRelationLogsError() { var cppParameter = new CppParameter("param") { TypeName = "int", Rule = { Relation = "struct-size()" } }; var typeRegistry = new TypeRegistry(Logger, A.Fake <IDocumentationLinker>()); typeRegistry.BindType("int", TypeRegistry.Int32); var marshalledElementFactory = new MarshalledElementFactory(Logger, new GlobalNamespaceProvider(), typeRegistry); using (LoggerMessageCountEnvironment(1, LogLevel.Error)) using (LoggerMessageCountEnvironment(0, ~LogLevel.Error)) using (LoggerCodeRequiredEnvironment(LoggingCodes.InvalidRelation)) { marshalledElementFactory.Create(cppParameter, cppParameter.Name); } }
public void ZeroDimensionArrayMappedAsSingleElement() { var cppMarshallable = new CppParameter("param") { TypeName = "int", ArrayDimension = "0", IsArray = true }; var typeRegistry = new TypeRegistry(Logger, A.Fake <IDocumentationLinker>()); typeRegistry.BindType("int", TypeRegistry.Int32); var marshalledElementFactory = new MarshalledElementFactory(Logger, new GlobalNamespaceProvider(), typeRegistry); var csMarshallable = marshalledElementFactory.Create(cppMarshallable, cppMarshallable.Name); Assert.Equal(TypeRegistry.Int32, csMarshallable.PublicType); Assert.Equal(TypeRegistry.Int32, csMarshallable.MarshalType); Assert.False(csMarshallable.IsArray); Assert.False(csMarshallable.HasPointer); Assert.Equal(0, csMarshallable.ArrayDimensionValue); }
public void PointerToTypeWithMarshallingMarshalsAsUnderlyingType() { var cppMarshallable = new CppParameter("param") { TypeName = "bool", Pointer = "*" }; TypeRegistry.BindType("bool", TypeRegistry.Boolean, TypeRegistry.Int32); var csMarshallable = marshalledElementFactory.Create(cppMarshallable, cppMarshallable.Name); Assert.Equal(TypeRegistry.Int32, csMarshallable.MarshalType); Assert.Equal(0, csMarshallable.ArrayDimensionValue); Assert.False(csMarshallable.IsArray); Assert.True(csMarshallable.HasPointer); }