NameMethod
Returns the name of the data type
Example 1: Displaying the data type name and size of a variable
Dim MyVariable = uc.DefineVariable("MyVariable")
Console.WriteLine("MyVariable type: " + MyVariable.GetDataType().Name())
Console.WriteLine("MyVariable size: " + MyVariable.GetDataType().ByteSize())
var MyVariable = uc.DefineVariable("MyVariable");
Console.WriteLine("MyVariable type: " + MyVariable.GetDataType().Name());
Console.WriteLine("MyVariable size: " + MyVariable.GetDataType().ByteSize());
WriteLn('MyVariable type: ' + MyVariable.GetDataType().Name());
WriteLn('MyVariable size: ' + MyVariable.GetDataType().ByteSize());
auto MyVariable = uc.DefineVariable("MyVariable");
cout << "MyVariable type: " << MyVariable.GetDataType().Name() << endl;
cout << "MyVariable size: " << MyVariable.GetDataType().ByteSize() << endl;
auto MyVariable = uc.DefineVariable("MyVariable");
Console::WriteLine("MyVariable type: " + MyVariable.GetDataType().Name());
Console::WriteLine("MyVariable size: " + MyVariable.GetDataType().ByteSize());
Example 2: returning data type names for the different definitions of the "+" operator
Dim PlusOperator = uc.GetItemOf("+")
while PlusOperator.ItemHandle <> 0
Console.WriteLine("Def: " + PlusOperator.Text() + " Type: " + PlusOperator.GetDataType().Name())
PlusOperator = PlusOperator.NextOverload()
End while
var PlusOperator = uc.GetItemOf("+");
while (PlusOperator.ItemHandle != null) {
Console.WriteLine("Def: " + PlusOperator.Text() + " Type: " + PlusOperator.GetDataType().Name());
PlusOperator = PlusOperator.NextOverload();
}
while PlusOperator.ItemHandle <> 0 do
begin
WriteLn('Def: ' + PlusOperator.Text() + ' Type: ' + PlusOperator.GetDataType().Name());
PlusOperator = PlusOperator.NextOverload();
End;
auto PlusOperator = uc.GetItemOf("+");
while (PlusOperator.ItemHandle != NULL) {
cout << "Def: " << PlusOperator.Text() << " Type: " << PlusOperator.GetDataType().Name() << endl;
PlusOperator = PlusOperator.NextOverload();
}
auto PlusOperator = uc.GetItemOf("+");
while (PlusOperator.ItemHandle != 0) {
Console::WriteLine("Def: " + PlusOperator.Text() + " Type: " + PlusOperator.GetDataType().Name());
PlusOperator = PlusOperator.NextOverload();
}
Example 3: 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))");
}
Example 4: Determining properties of an expression part
Sub OpItemTestCB(ByVal ExprPartPtr As IntPtr)
Dim ExprPart As New uCalc.Callback(ExprPartPtr)
Console.WriteLine("Name: " + ExprPart.OpItem().Name())
Console.WriteLine("Data type: " + ExprPart.OpItem().GetDataType().Name())
Console.WriteLine("Param count: " + ExprPart.OpItem().ElementCount())
Console.WriteLine("Is operator? " + ExprPart.OpItem().IsProperty(ItemIsEnum.Operator_))
End Sub
Sub HandleTest()
uc.DefineFunction("AAA() As Double", uc.PinAddr(AddressOf OpItemTestCB))
uc.DefineFunction("BBB(x, y, z) As String", uc.PinAddr(AddressOf OpItemTestCB))
uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum.GroupLeftToRight, uc.PinAddr(AddressOf OpItemTestCB)):
uc.EvalStr("AAA()")
uc.EvalStr("BBB(9, 8, 7)")
uc.EvalStr("5 CCC 4")
End Sub
static void OpItemTestCB(IntPtr ExprPartPtr) {
var ExprPart = New uCalc.Callback(ExprPartPtr);
Console.WriteLine("Name: " + ExprPart.OpItem().Name());
Console.WriteLine("Data type: " + ExprPart.OpItem().GetDataType().Name());
Console.WriteLine("Param count: " + ExprPart.OpItem().ElementCount());
Console.WriteLine("Is operator? " + ExprPart.OpItem().IsProperty(ItemIsEnum.Operator));
}
static void HandleTest() {
uc.DefineFunction("AAA() As Double", uc.PinAddr(OpItemTestCB));
uc.DefineFunction("BBB(x, y, z) As String", uc.PinAddr(OpItemTestCB));
uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum.GroupLeftToRight, uc.PinAddr(OpItemTestCB));
uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");
}
procedure OpItemTestCB(ExprPartPtr: System.Pointer);
begin
WriteLn('Name: ' + ExprPart.OpItem().Name());
WriteLn('Data type: ' + ExprPart.OpItem().GetDataType().Name());
WriteLn('Param count: ' + ExprPart.OpItem().ElementCount());
WriteLn('Is operator? ' + ExprPart.OpItem().IsProperty(ItemIsEnum.Operator_));
End;
procedure HandleTest();
begin
uc.DefineFunction('AAA() As Double', OpItemTestCB);
uc.DefineFunction('BBB(x, y, z) As String', OpItemTestCB);
uc.DefineOperator('{x} CCC {y} As Int32', 0, GroupingEnum.GroupLeftToRight, OpItemTestCB);
uc.EvalStr('AAA()');
uc.EvalStr('BBB(9, 8, 7)');
uc.EvalStr('5 CCC 4');
End;
void _stdcall OpItemTestCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
cout << "Name: " << ExprPart.OpItem().Name() << endl;
cout << "Data type: " << ExprPart.OpItem().GetDataType().Name() << endl;
cout << "Param count: " << ExprPart.OpItem().ElementCount() << endl;
cout << "Is operator? " << ExprPart.OpItem().IsProperty(ItemIsEnum::Operator) << endl;
}
void HandleTest() {
uc.DefineFunction("AAA() As Double", OpItemTestCB);
uc.DefineFunction("BBB(x, y, z) As String", OpItemTestCB);
uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum::GroupLeftToRight, OpItemTestCB);
uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");
}
static void OpItemTestCB(uCalcPtr ExprPartPtr) {
auto ExprPart = uCalc::Callback(ExprPartPtr);
Console::WriteLine("Name: " + ExprPart.OpItem().Name());
Console::WriteLine("Data type: " + ExprPart.OpItem().GetDataType().Name());
Console::WriteLine("Param count: " + ExprPart.OpItem().ElementCount());
Console::WriteLine("Is operator? " + ExprPart.OpItem().IsProperty(ItemIsEnum::Operator));
}
static void HandleTest() {
uc.DefineFunction("AAA() As Double", ucPinAddr(OpItemTestCB));
uc.DefineFunction("BBB(x, y, z) As String", ucPinAddr(OpItemTestCB));
uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum::GroupLeftToRight, ucPinAddr(OpItemTestCB));
uc.EvalStr("AAA()");
uc.EvalStr("BBB(9, 8, 7)");
uc.EvalStr("5 CCC 4");
}
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="Name_Overload_DataType")> _
Private Function Name_Overload_DataType__(ByVal DataTypeHandle As IntPtr) As IntPtr
End Function
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="Name_Overload_DataType")]
protected static extern IntPtr Name_Overload_DataType_(IntPtr DataTypeHandle);
{DLLImport}function Name_Overload_DataType__(DataTypeHandle: System.Pointer): PAnsiChar; cdecl; external uCalcDLL name 'Name_Overload_DataType';
typedef const char * (* __Name_Overload_DataType)(void *DataTypeHandle);
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "Name_Overload_DataType")]
static STR_RETURN Name_Overload_DataType_(void * DataTypeHandle);