Jump to content
  • Advertisement
Sign in to follow this  

Macro Laziness

This topic is 5502 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!