From efb26af672084914b9971358bea919dc5a4f7b23 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 4 Jul 2022 20:45:52 +0000 Subject: [PATCH] Add more tests CallFunc. See root-project/root#10850 --- root/meta/callfunc/runsimpleFunc.C | 50 +++++++++++++++++++++++++++++- root/meta/callfunc/simpleFunc.ref | 12 +++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/root/meta/callfunc/runsimpleFunc.C b/root/meta/callfunc/runsimpleFunc.C index 6762b703dd..011a7069b3 100644 --- a/root/meta/callfunc/runsimpleFunc.C +++ b/root/meta/callfunc/runsimpleFunc.C @@ -91,6 +91,18 @@ namespace A { printf("Double32PtrOneArg(int p, float f, double* d).\n"); return new Double32_t(p + f - *d); } + int AddIntPtrs (int* a, int* b) { + printf("AddIntPtrs(int *a, int* b).\n"); + return *a + *b; + } + long long* LLPtrAddLLPtrs (long long* a, long long* b) { + printf("AddLLPtrs (long long* a, long long* b).\n"); + return new long long (*a + *b); + } + unsigned long long* ULLPtrAddULLPtrs (unsigned long long* a, unsigned long long* b) { + printf("AddULLPtrs (unsigned long long* a, unsigned long long* b).\n"); + return new unsigned long long (*a + *b); + } } namespace A { @@ -163,10 +175,31 @@ void runAllThroughTInterpreterInterfaces() { gInterpreter->CallFunc_SetFuncProto(mc, namespaceA, "Double32TPtrThreeArgs", "int, float, double *", &offset); gInterpreter->CallFunc_SetArg(mc, (Long_t)1+1); gInterpreter->CallFunc_SetArg(mc, (Double_t)1.-1); - gInterpreter->CallFunc_SetArg(mc, (ULong64_t)new double(3.000)); + gInterpreter->CallFunc_SetArg(mc, new double(3.000)); result_long = gInterpreter->CallFunc_ExecInt(mc, /* void* */0); printf("Result of A::Double32TPtrThreeArgs = %f\n", *reinterpret_cast(result_long)); + // Run int A::AddIntPtrs (int* a, int* b) + gInterpreter->CallFunc_SetFuncProto(mc, namespaceA, "AddIntPtrs", "int*, int*", &offset); + gInterpreter->CallFunc_SetArg(mc, new int(-2)); + gInterpreter->CallFunc_SetArg(mc, new int(-3)); + result_long = gInterpreter->CallFunc_ExecInt(mc, /* void* */0); + printf("Result of A::AddIntPtrs = %ld\n", result_long); + + // Run long long* LLPtrAddLLPtrs (long long* a, long long* b) + gInterpreter->CallFunc_SetFuncProto(mc, namespaceA, "LLPtrAddLLPtrs", "long long*, long long*", &offset); + gInterpreter->CallFunc_SetArg(mc, new long long(-1)); + gInterpreter->CallFunc_SetArg(mc, new long long(-2)); + result_long = gInterpreter->CallFunc_ExecInt(mc, /* void* */0); + printf("Result of A::LLPtrAddLLPtrs = %lld\n", *reinterpret_cast(result_long)); + + // Run unsigned long long* ULLPtrAddULLPtrs (unsigned long long* a, unsigned long long* b) + gInterpreter->CallFunc_SetFuncProto(mc, namespaceA, "ULLPtrAddULLPtrs", "unsigned long long*, unsigned long long*", &offset); + gInterpreter->CallFunc_SetArg(mc, new unsigned long long(1)); + gInterpreter->CallFunc_SetArg(mc, new unsigned long long(2)); + result_long = gInterpreter->CallFunc_ExecInt(mc, /* void* */0); + printf("Result of A::ULLPtrAddULLPtrs = %llu\n", *reinterpret_cast(result_long)); + // Run A::A1::A2::A3::NestedNamespaceIntOneArg (int return) ClassInfo_t* namespaceA3 = gInterpreter->ClassInfo_Factory("A::A1::A2::A3"); gInterpreter->CallFunc_SetFuncProto(mc, namespaceA3, "NestedNamespaceIntOneArg", "int", &offset); @@ -228,6 +261,21 @@ void runAllThroughTMethodCall() { method.Execute(result_long); printf("Result of A::Double32TPtrThreeArgs = %f\n", *reinterpret_cast(result_long)); + // Run int A::AddIntPtrs (int* a, int* b) + method = TMethodCall("A::AddIntPtrs", "new int(-2), new int(-3)"); + method.Execute(result_long); + printf("Result of A::AddIntPtrs = %ld\n", result_long); + + // Run long long* AddLLPtrs (long long* a, long long* b) + method = TMethodCall("A::LLPtrAddLLPtrs", "new long long (-1), new long long(-2)"); + method.Execute(result_long); + printf("Result of A::LLPtrAddLLPtrs = %lld\n", *reinterpret_cast(result_long)); + + // Run unsigned long long* ULLPtrAddULLPtrs (unsigned long long* a, unsigned long long* b) + method = TMethodCall("A::ULLPtrAddULLPtrs", "new unsigned long long(1), new unsigned long long(2)"); + method.Execute(result_long); + printf("Result of A::ULLPtrAddULLPtrs = %llu\n", *reinterpret_cast(result_long)); + // Run A::A1::A2::A3::NestedNamespaceIntOneArg (int return) method.InitWithPrototype("A::A1::A2::A3::NestedNamespaceIntOneArg", "int"); method.SetParam((Long_t)11); diff --git a/root/meta/callfunc/simpleFunc.ref b/root/meta/callfunc/simpleFunc.ref index 6f396de0b6..14706a80bc 100644 --- a/root/meta/callfunc/simpleFunc.ref +++ b/root/meta/callfunc/simpleFunc.ref @@ -15,6 +15,12 @@ p=3 Result of FloatPtrOneArg = 3.000000 Double32PtrOneArg(int p, float f, double* d). Result of A::Double32TPtrThreeArgs = -1.000000 +AddIntPtrs(int *a, int* b). +Result of A::AddIntPtrs = -5 +AddLLPtrs (long long* a, long long* b). +Result of A::LLPtrAddLLPtrs = -3 +AddULLPtrs (unsigned long long* a, unsigned long long* b). +Result of A::ULLPtrAddULLPtrs = 3 Result of A::A1::A2::A3::NestedNamespaceIntOneArg = 14 ====================================================== Running through TMethodCall... @@ -32,4 +38,10 @@ p=3 Result of FloatPtrOneArg = 3.000000 Double32PtrOneArg(int p, float f, double* d). Result of A::Double32TPtrThreeArgs = -1.000000 +AddIntPtrs(int *a, int* b). +Result of A::AddIntPtrs = -5 +AddLLPtrs (long long* a, long long* b). +Result of A::LLPtrAddLLPtrs = -3 +AddULLPtrs (unsigned long long* a, unsigned long long* b). +Result of A::ULLPtrAddULLPtrs = 3 Result of A::A1::A2::A3::NestedNamespaceIntOneArg = 14