How it all panned out...
A C function we will bind to the SL (Scripting Language) will take the form:
C_To_Magus_Return Function_Name ( Magus_To_C_Parameter_List Parameter_List );
An example function prints two integers:
// A function to be bound to the magus language
C_To_Magus_Return Print_Two_Integers(Magus_To_C_Parameter_List Parameter_List)
{
int a, b;
// Get parameter 0
if(Parameter_List.Get_Integer_At_Parameter_Index(0, a) == false)
return C_To_Magus_Return(0);
// Get parameter 1
if(Parameter_List.Get_Integer_At_Parameter_Index(1, b) == false)
return C_To_Magus_Return(0);
// Print the integers
cout << "Integer 0: "<< a << " Integer 1: " << b << endl;
// Return type integer
return C_To_Magus_Return(1);
}
You can see that type checking parameters is now in place. The overloaded C_To_Magus_Return constructors check return types. This function is then bound with the following function:
bool Bind_C_Function(C_To_Magus_Return(*Function_Pointer)(Magus_To_C_Parameter_List), string Function_Name, vector Parameter_Type_List, MagusC_Parameter_Type_e Return_Type);
The function can then be called from within the SL either as a part of an expression or as a standard function call.
function void main(void)
{
int x = Print_2_Integers(1; 2;);
print x;
Print_2_Integers(3; 4;);
}
Output:
Integer 0: 1 Integer 1: 2
1
Integer 0: 3 Integer 1: 4
What's next...
So far I only have integer types working. Next I'll add support for the 5 float types. I'm still working out how I'll add access to the float vector elements. I'd like to add swizzling if possible.