Please bear in mind that this currently has a few things in it that are specific to my game engine, but they are mostly utility functions.
What currently works:
- String concantenation when both vars represent strings.
- Arithmetic operations between variants regardless whether they represent a string or a primitive.
- All assignment operators.What does not work:
- Arithmetic assignment operators
- The string constructor (for who knows what reason).Some sample code from my test-case in my game engine.
void ConsCmd_VarTest( Console@ c, const string@[]@ args )
{
if( args.length() < 2 )
{
c.Print( "Not enough arguments. Need at leasst two numbers. Note that they can have decimals in them.");
return;
}
c.Print("Testing the 'var' datatype.");
var arg1 = args[0],
arg2 = args[1];
c.Print(arg1.asString()+" + "+arg2.asString()+" = "+var(arg1+arg2).asString());
c.Print(arg1.asString()+" - "+arg2.asString()+" = "+var(arg1-arg2).asString());
c.Print(arg1.asString()+" * "+arg2.asString()+" = "+var(arg1*arg2).asString());
c.Print(arg1.asString()+" / "+arg2.asString()+" = "+var(arg1/arg2).asString());
var arg3 = arg1;
var testconstructor( 10 );
arg3 += var("10");
c.Print(arg1.asString()+" += 10 -> "+arg3.asString() );
}