__FUNCTION__, __LINE__ and a editor (AngelScript)

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

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 on other sites
if you like there is my IDE that uses angelscript:

http://www.anticore.org/juce/angeljuice

Share on other sites
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 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 on other sites
Quote:
 Original post by DeyjaMy 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 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 on other sites
Thank you :) that was sort of what I was looking for.