Sign in to follow this  

Macro Laziness

Recommended Posts

I'm trying to create some lazy macros. My scripting engine must be set up with pointers to variables and have an identification text version of that same variable. Like this..
Script->AddVariable(&MyInt, "MyInt");
Script->AddValue(ENUM_VALUE, "ENUM_VALUE");
As you can see, the names always match. Now imagine about 500 of these. It's ugly, and a maintenance nightmare. Actually, there are only a few of the AddVariable type lines, but many, many values. Are there any ways I can cheat here? At least on the value versions? How can I give the scripting engine the value of an enum and it's text name all at once?
#define ADD_VALUE(_eval_) AddValue(_eval_,"_eval_");
It would be even cooler to go through a loop for the whole slew of enum values of each type, but I'm almost sure the IDE wouldn't allow such hacking.
for(int i=0; i<ENUM_MAX; i++)
  AddValue( GetEnumValue(i), GetEnumLabel(i) );
The scripting engine is of my own creation, so feel free to offer any advice on how to avoid this situation to begin with. Thanks for any advice.

Share this post

Link to post
Share on other sites
Ahhh wow, really nice. Thanks. One little operator.

Original post by swiftcoder
But of course, this does not work dynamically, although maybe it doesn't need to.

To sound like an idiot: What do you mean dynamically?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this