I am trying to convert a macro in C to something that would work similarly in Actionscript.
The C macro takes a string, and using ##
checks the type against other macros to check that the item's property is of the right type.
To clarify, the C:
...
#define STACK_NUM 52
...
#define CHECK_TYPE(i, t) \
( ((i).type == t##_NUM) ) \
I'm trying to convert this into something of the same in Actionscript. The current way I am doing it is creating a class
public class StringMacro extends String {
public var macro:int;
public function
StringMacro(value:int)
{
super();
macro = value;
}
}
and defining all the macros from C in variables of this class, but this takes up a large amount of space and I really don't want to do it this way.
So, what I came up with was something like this:
public class Macros {
...
public var STACK_NUM:uint = 52;
...
public function
Macros()
{
}
}
I want to reference the Macros class doing something like this:
private var macros:Macros = new Macros();
if(CHECK_TYPE(10, STACK))
....
private function
CHECK_TYPE(value:int, t:String):Boolean
{
if(value == macros.(t)) {
return true;
}
}
so I can pass t into the function and it will check it among the definitions in the Macro class.
Is there a way to make this work or something like it?