public void PointerSizeReturnValueNotLarge() { var config = new ConfigFile { Id = nameof(PointerSizeReturnValueNotLarge), Namespace = nameof(PointerSizeReturnValueNotLarge), Includes = { new IncludeRule { File = "pointerSize.h", Attach = true, Namespace = nameof(PointerSizeReturnValueNotLarge) } }, Extension = { new DefineExtensionRule { Struct = "SharpGen.Runtime.PointerSize", SizeOf = 8, IsNativePrimitive = true, } }, Bindings = { new BindRule("int", "SharpGen.Runtime.PointerSize") } }; var iface = new CppInterface("Interface"); iface.Add(new CppMethod("method") { ReturnValue = new CppReturnValue { TypeName = "int" } }); var include = new CppInclude("pointerSize"); include.Add(iface); var module = new CppModule("SharpGenTestModule"); module.Add(include); var(solution, _) = MapModel(module, config); Assert.Single(solution.EnumerateDescendants <CsInterface>()); var csIface = solution.EnumerateDescendants <CsInterface>().First(); Assert.Single(csIface.Methods); var method = csIface.Methods.First(); Assert.False(method.IsReturnStructLarge); }
public void Simple() { var config = new ConfigFile { Id = nameof(Simple), Namespace = nameof(Simple), Includes = { new IncludeRule { File = "interface.h", Attach = true, Namespace = nameof(Simple) } }, Bindings = { new BindRule("int", "System.Int32") } }; var iface = new CppInterface("Interface") { TotalMethodCount = 1 }; iface.Add(new CppMethod("method") { ReturnValue = new CppReturnValue { TypeName = "int" } }); var include = new CppInclude("interface"); include.Add(iface); var module = new CppModule("SharpGenTestModule"); module.Add(include); var(solution, _) = MapModel(module, config); Assert.Single(solution.EnumerateDescendants().OfType <CsInterface>()); var csIface = solution.EnumerateDescendants().OfType <CsInterface>().First(); Assert.Single(csIface.Methods); var method = csIface.Methods.First(); Assert.Equal(0, method.Offset); Assert.IsType <CsFundamentalType>(method.ReturnValue.PublicType); Assert.Equal(TypeRegistry.Int32, method.ReturnValue.PublicType); }
IEnumerator UpdateNumber() { while (true) { lbl_fps[0].text = number.ToString(); number = CppInterface.Add(number, 1); yield return(new WaitForSeconds(0.1f)); } }
public void DualCallbackFlowsNativeImplementation() { var config = new ConfigFile { Id = nameof(Simple), Namespace = nameof(Simple), Includes = { new IncludeRule { File = "interface.h", Attach = true, Namespace = nameof(Simple) } }, Bindings = { new BindRule("int", "System.Int32") }, Mappings = { new MappingRule { Interface = "Interface", IsCallbackInterface = true, IsDualCallbackInterface = true } } }; var iface = new CppInterface("Interface") { TotalMethodCount = 1 }; iface.Add(new CppMethod("method") { ReturnValue = new CppReturnValue { TypeName = "int" } }); var include = new CppInclude("interface"); include.Add(iface); var module = new CppModule("SharpGenTestModule"); module.Add(include); var(_, defines) = GetConsumerBindings(module, config); var interfaceDefine = defines.First(define => define.Interface == "Simple.Interface"); Assert.Equal("Simple.InterfaceNative", interfaceDefine.NativeImplementation); }
public void NativePrimitiveTypeNotLarge() { var config = new ConfigFile { Id = nameof(NativePrimitiveTypeNotLarge), Namespace = nameof(NativePrimitiveTypeNotLarge), Includes = { new IncludeRule { File = "pointerSize.h", Attach = true, Namespace = nameof(NativePrimitiveTypeNotLarge) } }, Extension = { new DefineExtensionRule { Struct = "NativePrimitiveType", SizeOf = 16, IsNativePrimitive = true, } }, Bindings = { new BindRule("NativePrimitive", "NativePrimitiveType") } }; var iface = new CppInterface { Name = "Interface", TotalMethodCount = 1 }; iface.Add(new CppMethod { Name = "method", ReturnValue = new CppReturnValue { TypeName = "NativePrimitive" } }); var include = new CppInclude { Name = "pointerSize" }; include.Add(iface); var module = new CppModule(); module.Add(include); var(solution, _) = MapModel(module, config); Assert.Single(solution.EnumerateDescendants().OfType <CsInterface>()); var csIface = solution.EnumerateDescendants().OfType <CsInterface>().First(); Assert.Single(csIface.Methods); var method = csIface.Methods.First(); Assert.False(method.IsReturnStructLarge); Assert.False(Logger.HasErrors); }
public void DefineWithNativeImplementationDefinesNativeImplementationType() { var config = new ConfigFile { Id = nameof(Simple), Namespace = nameof(Simple), Includes = { new IncludeRule { File = "interface.h", Attach = true, Namespace = nameof(Simple) } }, Extension = { new DefineExtensionRule { Interface = "Imported.Param", NativeImplementation = "Imported.ParamNative" } }, Bindings = { new BindRule("int", "System.Int32"), new BindRule("Param", "Imported.Param") } }; var iface = new CppInterface { Name = "Interface", TotalMethodCount = 1 }; var method = new CppMethod { Name = "method", ReturnValue = new CppReturnValue { TypeName = "int" } }; method.Add(new CppParameter { Name = "param", TypeName = "Param", Pointer = "*" }); iface.Add(method); var include = new CppInclude { Name = "interface" }; include.Add(iface); var module = new CppModule(); module.Add(include); var(solution, _) = MapModel(module, config); Assert.Single(solution.EnumerateDescendants().OfType <CsParameter>()); var param = solution.EnumerateDescendants().OfType <CsParameter>().First(); Assert.IsType <CsInterface>(param.PublicType); Assert.NotNull(((CsInterface)param.PublicType).NativeImplementation); Assert.False(Logger.HasErrors); }
public void PointerSizeReturnValueNotLarge() { var config = new Config.ConfigFile { Id = nameof(PointerSizeReturnValueNotLarge), Assembly = nameof(PointerSizeReturnValueNotLarge), Namespace = nameof(PointerSizeReturnValueNotLarge), Includes = { new Config.IncludeRule { File = "pointerSize.h", Attach = true, Namespace = nameof(PointerSizeReturnValueNotLarge) } }, Extension = { new DefineExtensionRule { Struct = "SharpGen.Runtime.PointerSize", SizeOf = 8, } }, Bindings = { new Config.BindRule("int", "SharpGen.Runtime.PointerSize") } }; var iface = new CppInterface { Name = "Interface", TotalMethodCount = 1 }; iface.Add(new CppMethod { Name = "method", ReturnValue = new CppReturnValue { TypeName = "int" } }); var include = new CppInclude { Name = "pointerSize" }; include.Add(iface); var module = new CppModule(); module.Add(include); var(solution, _) = MapModel(module, config); Assert.Single(solution.EnumerateDescendants().OfType <CsInterface>()); var csIface = solution.EnumerateDescendants().OfType <CsInterface>().First(); Assert.Single(csIface.Methods); var method = csIface.Methods.First(); Assert.False(method.IsReturnStructLarge); }