public void SaveAndLoad6() { NativeFunctionPointer fptr = new NativeFunctionPointer("f1"); Assert.Equal(NativeCallingConvention.WinApi, fptr.CallingConvention); fptr.CallingConvention = NativeCallingConvention.Pascal; fptr.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeChar); NativeProcedure proc = new NativeProcedure("p1"); Assert.Equal(NativeCallingConvention.WinApi, proc.CallingConvention); proc.CallingConvention = NativeCallingConvention.CDeclaration; proc.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeChar); var ns = new BasicSymbolStorage(); ns.AddProcedure(proc); ns.AddDefinedType(fptr); NativeDefinedType temp = null; NativeFunctionPointer retPtr = null; Assert.True(ns.TryGetGlobalSymbol(fptr.Name, out temp)); retPtr = (NativeFunctionPointer)temp; Assert.Equal(NativeCallingConvention.Pascal, retPtr.CallingConvention); NativeProcedure retProc = null; Assert.True(ns.TryGetGlobalSymbol(proc.Name, out retProc)); Assert.Equal(NativeCallingConvention.CDeclaration, retProc.CallingConvention); }
/// <summary> /// Verification of the generated code /// </summary> /// <param name="ns"></param> /// <remarks></remarks> private static void VerifyGeneratedStorage(BasicSymbolStorage ns) { NativeProcedure proc = null; VerifyTrue(ns.TryGetGlobalSymbol("SendMessageA", out proc)); VerifyTrue(ns.TryGetGlobalSymbol("SendMessageW", out proc)); VerifyTrue(ns.TryGetGlobalSymbol("GetForegroundWindow", out proc)); VerifyTrue(ns.TryGetGlobalSymbol("CreateWellKnownSid", out proc)); NativeTypeDef typedef = null; VerifyTrue(ns.TryGetGlobalSymbol("LPCSTR", out typedef)); VerifyTrue(ns.TryGetGlobalSymbol("LPWSTR", out typedef)); NativeType defined = null; VerifyTrue(ns.TryGetType("WNDPROC", out defined)); VerifyTrue(ns.TryGetType("HOOKPROC", out defined)); VerifyTrue(ns.TryGetType("tagPOINT", out defined)); VerifyTrue(ns.TryGetType("_SYSTEM_INFO", out defined)); NativeConstant c = null; VerifyTrue(ns.TryGetGlobalSymbol("WM_PAINT", out c)); VerifyTrue(ns.TryGetGlobalSymbol("WM_LBUTTONDOWN", out c)); }
public void SaveAndLoad5() { NativeConstant c1 = new NativeConstant("c1", "v1"); NativeConstant c2 = new NativeConstant("c2", "v2", ConstantKind.MacroMethod); var ns = new BasicSymbolStorage(); ns.AddConstant(c1); ns.AddConstant(c2); NativeConstant ret = null; Assert.True(ns.TryGetGlobalSymbol("c1", out ret)); Assert.Equal("c1", ret.Name); Assert.Equal("v1", ret.Value.Expression); Assert.Equal(ConstantKind.Macro, ret.ConstantKind); Assert.True(ns.TryGetGlobalSymbol("c2", out ret)); Assert.Equal("c2", ret.Name); Assert.Equal("\"v2\"", ret.Value.Expression); Assert.Equal(ConstantKind.MacroMethod, ret.ConstantKind); }
public void LoadByName1() { NativeStruct s1 = new NativeStruct("s"); s1.Members.Add(new NativeMember("m1", new NativeBuiltinType(BuiltinType.NativeInt32))); NativeType s2 = null; var ns = new BasicSymbolStorage(); ns.AddDefinedType(s1); Assert.True(ns.TryGetGlobalSymbol(s1.Name, out s2)); }
public void Proc4() { NativeStruct s1 = new NativeStruct("s1"); s1.Members.Add(new NativeMember("m1", new NativeBuiltinType(BuiltinType.NativeByte))); NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = s1; var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); NativeProcedure retp1 = null; Assert.True(ns.TryGetGlobalSymbol(p1.Name, out retp1)); Assert.Equal(p1.DisplayName, retp1.DisplayName); NativeDefinedType rets1 = null; Assert.False(ns.TryGetGlobalSymbol(s1.Name, out rets1)); }
public void Proc1() { NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeByte); var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); NativeProcedure retp1 = null; Assert.True(ns.TryGetGlobalSymbol(p1.Name, out retp1)); Assert.Equal(p1.DisplayName, retp1.DisplayName); }
public void FuncPtr1() { NativeFunctionPointer fptr = new NativeFunctionPointer("f1"); fptr.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeChar); fptr.Signature.Parameters.Add(new NativeParameter("f", new NativeBuiltinType(BuiltinType.NativeFloat))); var ns = new BasicSymbolStorage(); ns.AddDefinedType(fptr); NativeDefinedType retFptr = null; Assert.True(ns.TryGetGlobalSymbol(fptr.Name, out retFptr)); Assert.Equal("char (*f1)(float f)", ((NativeFunctionPointer)retFptr).DisplayName); }
public void Sal2() { NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeChar); p1.Signature.ReturnTypeSalAttribute = new NativeSalAttribute(new NativeSalEntry(SalEntryType.Deref, "foo")); var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); NativeProcedure retp1 = null; Assert.True(ns.TryGetGlobalSymbol(p1.Name, out retp1)); Assert.Equal("Deref(foo)", retp1.Signature.ReturnTypeSalAttribute.DisplayName); }
public void Sal3() { NativeParameter param = new NativeParameter("p"); param.SalAttribute = new NativeSalAttribute(SalEntryType.Deref); param.NativeType = new NativeBuiltinType(BuiltinType.NativeChar); NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeChar); p1.Signature.Parameters.Add(param); var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); NativeProcedure retp1 = null; Assert.True(ns.TryGetGlobalSymbol(p1.Name, out retp1)); Assert.Equal("Deref", retp1.Signature.Parameters[0].SalAttribute.DisplayName); }
public void SaveAndLoad1() { NativeStruct s1 = new NativeStruct("s1"); s1.Members.Add(new NativeMember("m1", new NativeBuiltinType(BuiltinType.NativeFloat))); NativeStruct s2 = new NativeStruct("s2"); s2.Members.Add(new NativeMember("m1", s1)); var ns = new BasicSymbolStorage(); ns.AddDefinedType(s2); NativeDefinedType rets2 = null; Assert.True(ns.TryGetGlobalSymbol(s2.Name, out rets2)); Assert.NotNull(rets2); Assert.True(NativeTypeEqualityComparer.AreEqualRecursive(s2, rets2)); Assert.True(NativeTypeEqualityComparer.AreEqualTopLevel(s2, rets2)); }