Advertisement

__FUNCTION__, __LINE__ and a editor (AngelScript)

Started by March 23, 2007 06:49 AM
5 comments, last by mushr00m 17 years, 8 months ago
__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.
if you like there is my IDE that uses angelscript:

http://www.anticore.org/juce/angeljuice
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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.
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.
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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Thank you :) that was sort of what I was looking for.

This topic is closed to new replies.

Advertisement