Jump to content
  • Advertisement
Sign in to follow this  
mushr00m

__FUNCTION__, __LINE__ and a editor (AngelScript)

This topic is 4228 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

__FUNCTION__ __LINE__ Wouldn't it be great if you could use those macros inside your scripts? Debuging would be much easier. Also have you ever thought of making a script editor for AngelScript? I was thinking of building one this summer. Making some modifications to AngelScript that made it possible to export all declarations into a xml file that could be read by the editor. Otherwise you would have to write them manually all over again. By editor I mean something similiar to what visual studio have. Where you can check all functions of a object and run a syntax check. I guess it could be a quite big project.

Share this post


Link to post
Share on other sites
Advertisement
Those macros fall into the category of preprocessor commands, which is a layer above the AngelScript core library. I suggest you take a look at Deyja's preprocessor: http://www.omnisu.com/preprocessor.html, it may be able to handle that, or you could add it yourself.

I've thought about writing a script editor, but it's not something I'll do. I have a hard time finding the time to work on AngelScript itself. If you wish to write an editor yourself I'm willing to add necessary methods to AngelScript to make the editor work as best as possible.

kunitoki's editor is good one, though it is perhaps not generic enough to be used with all projects.

Gyrbo (I think it was him) was working on a generic debugging library for AngelScript that could be plugged into just about any project, but I'm not sure what's the state of that one.

Regards,
Andreas

Share this post


Link to post
Share on other sites
My preprocessor supports __LINE__ and __FILE__. __FUNCTION__, however, would be beyond it's scope, as it would require the preprocessor to parse code. It's really just a text substitution system, it doesn't know a thing about functions or classes or variables.

Share this post


Link to post
Share on other sites
Quote:
Original post by Deyja
My preprocessor supports __LINE__ and __FILE__. __FUNCTION__, however, would be beyond it's scope, as it would require the preprocessor to parse code. It's really just a text substitution system, it doesn't know a thing about functions or classes or variables.


Yeah thought so too. Thats why I think it would be more suited to use in AngelScripts parser. File is perhaps not possible but something like __MODULE__ perhaps.

Share this post


Link to post
Share on other sites
You know you can get this information at runtime, don't you?

In test_feature I register an assert function, to make simple affirmations. It looks like this:


void Assert(asIScriptGeneric *gen)
{
bool expr = gen->GetArgDWord(0) ? true : false;
if( !expr )
{
printf("--- Assert failed ---\n");
asIScriptContext *ctx = asGetActiveContext();
if( ctx )
{
asIScriptEngine *engine = ctx->GetEngine();
int funcID = ctx->GetCurrentFunction();
printf("func: %s\n", engine->GetFunctionDeclaration(funcID));
printf("mdle: %s\n", engine->GetFunctionModule(funcID));
printf("sect: %s\n", engine->GetFunctionSection(funcID));
printf("line: %d\n", ctx->GetCurrentLineNumber());
ctx->SetException("Assert failed");
printf("---------------------\n");
}
}
}


As you can see, it prints the current function, module, script section, and line number in case the assert fails. You should be able to easily adapt it do to what you need.

You may also want to take a look at test_debug.cpp, which does this through the line callback instead in order to trace the execution. It also goes beyond it and prints the variables and their values as well.

Regards,
Andreas

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!