ArgObjMethod
Returns an object instance of the argument being passed to a
uCalc.Callback function
Parameters
Index
Int32
Index of the given argument. Note that
Index is 1-based; the
Index for the first arg is 1 (not 0)
Returns
The returned object can be used (where relevent) just like any other
uCalc.Item
Example 1: Displaying the data types of arguments when the data types are not known in advance
Sub DisplayArgsCB(ByVal ExprPartPtr As IntPtr)
Dim ExprPart As New uCalc.Callback(ExprPartPtr)
Dim x As Int32
for x = 1 To ExprPart.ArgCount()
Console.WriteLine(ExprPart.ArgStr(x) + " Type: " + ExprPart.ArgObj(x).GetDataType().Name())
Next
End Sub
Sub DisplayArgs()
uc.DefineFunction("DisplayArgs(Arg As AnyType ...)", uc.PinAddr(AddressOf DisplayArgsCB))
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))")
End Sub
static void DisplayArgsCB(IntPtr ExprPartPtr) {
var ExprPart = New uCalc.Callback(ExprPartPtr);
for (Int32 x = 1; x <= ExprPart.ArgCount(); x++) {
Console.WriteLine(ExprPart.ArgStr(x) + " Type: " + ExprPart.ArgObj(x).GetDataType().Name());
}
}
static void DisplayArgs() {
uc.DefineFunction("DisplayArgs(Arg As AnyType ...)", uc.PinAddr(DisplayArgsCB));
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))");
}
procedure DisplayArgsCB(ExprPartPtr: System.Pointer);
begin
for x := 1 to ExprPart.ArgCount() do
begin
WriteLn(ExprPart.ArgStr(x) + ' Type: ' + ExprPart.ArgObj(x).GetDataType().Name());
End;
End;
procedure DisplayArgs();
begin
uc.DefineFunction('DisplayArgs(Arg As AnyType ...)', DisplayArgsCB);
uc.Eval('DisplayArgs(5, 3+2*#i, "Hello", True, False, Int16(5+4.1))');
End;
void _stdcall DisplayArgsCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
for (int x = 1; x <= ExprPart.ArgCount(); x++) {
cout << ExprPart.ArgStr(x) << " Type: " << ExprPart.ArgObj(x).GetDataType().Name() << endl;
}
}
void DisplayArgs() {
uc.DefineFunction("DisplayArgs(Arg As AnyType ...)", DisplayArgsCB);
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))");
}
static void DisplayArgsCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
for (int x = 1; x <= ExprPart.ArgCount(); x++) {
Console::WriteLine(ExprPart.ArgStr(x) + " Type: " + ExprPart.ArgObj(x).GetDataType().Name());
}
}
static void DisplayArgs() {
uc.DefineFunction("DisplayArgs(Arg As AnyType ...)", ucPinAddr(DisplayArgsCB));
uc.Eval("DisplayArgs(5, 3+2*#i, 'Hello', True, False, Int16(5+4.1))");
}
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="ArgObj")> _
Private Function ArgObj__(ByVal ExprPartHandle As IntPtr,ByVal Index As Int32) As IntPtr
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="ArgObj")]
protected static extern IntPtr ArgObj_(IntPtr ExprPartHandle, Int32 Index);
{DLLImport}function ArgObj__(ExprPartHandle: System.Pointer;Index: Int32): System.Pointer; cdecl; external uCalcDLL name 'ArgObj';
typedef uCalcPtr (* __ArgObj)(void *ExprPartHandle, int32_t Index);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "ArgObj")]
static uCalcPtr ArgObj_(void * ExprPartHandle, Int32 Index);