AngelScript 1.9.0 WIP 4 (2004/08/31)

Started by
44 comments, last by WitchLord 19 years, 7 months ago
The output for your example would be like this:

FlipImage (53, 0) : Error   : Expected expression valueFlipImage (53, 0) : Error   : Unexpected end of fileAcceuilEng_MOUSE_0 (4, 1) : Error   : Function 'FlipImage' not foundAcceuilFra_MOUSE_0 (4, 1) : Error   : Function 'FlipImage' not found


The only thing missing is the function name, but you'll be able to find the error by the line number. I hope that's ok?

Maybe I could add the function name for those messages where it is known. Do you think it is necessary?

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
Honestly I think that's enought for most application ... but in my case it is not !

The missing function name will miss me.

My application have global script and script triggered by event (like a browser).

The script that are triggered are named "not pure" because it is encapsulated with some code that is injected at runtime.

AcceuilEng_MOUSE_0 is triggered on a mouse hot spot click in page AcceuilEng.

When the user define the script his got an emply blank page where ... he write the script.
But in some case, he can use a trick to add it's own functions in the script.
The trick is to enter the ending code encapsulation, the declare your function with the correct beginning code encapsulation.

The code encapsulation is at the beginning :
void thefunctionname(){asBStrSetTransaction(1);{


The code encapsulation is at the ending :
}asBStrFreeTransaction(1);}


Example :
The user enter a script on mouse hot spot click in page AcceuilEng.

He (or she) enter a script like that :
TheOtherCode();

and nothing else.

The application then translate this to :
void AcceuilEng_MOUSE_O(){asBStrSetTransaction(1);{TheOtherCode();}asBStrFreeTransaction(1);}


Now the tricky user wants something special and use the trick in its code and enter :

TheOtherCode();gogo(1, 5);}asBStrFreeTransaction(1);}int gogo(int i, int j){  return i * j;}void TrickyEnd(){asBStrSetTransaction(1);{


If the user enter a compilation error in its gogo function the actual AS outputs :

Building...Compiling function 'gogo' in "AcceuilFra_OnBeforeParse" Error   : (9, 1) Function 'TheBuggyCall' not foundCompleted. (errors: 1, warnings: 0)


but in 1.9.x it will (I think if I have well understood !) output :
AcceuilFra_OnBeforeParse (9, 1) : Error : Function 'TheBuggyCall' not found


gogo is missing !

But once again, I think it's enought for most applications.

Understood. I'll provide some way of showing the function name as well. Right now I think it will be like so:

AcceuilFra_OnBeforeParse (9, 1) : Info  : Compiling int gogo(int, int)AcceuilFra_OnBeforeParse (9, 1) : Error : Function 'TheBuggyCall' not found


That way you'll get the extra information of the exact function interface in case of function overloads.

The info line will only appear if there was an error or warning in the function.

What do you think about that?

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

Simply great !
The latest WIP has been uploaded.
Changes:

- Removed the need to pass stack size when calling Prepare() or ExecuteString()
- Added the method SetDefaultContextStackSize()
- New error message asINVALID_CONFIGURATION, which is returned by Build() if the configuration failed
- The context stack now dynamically grows as needed
- bug fix: An unclosed statement block could lead to assert failure in the parser (thanks Alain "abrken" Bridel)
- Removed AS_CALL from the interface. This changes the exported function names.
- bug fix: An object with asBEHAVE_ASSIGNMENT registered could be assigned even though it was declared as const (thanks _MrC_)
- Added informational compiler messages that tell what function or global variable is currently being compiled when an error or warning occurs.

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

Is there a way we could make the engine display messages sectionwise rather than filewise. this would help me load multiple files into one engine instance and debug correctly (relevant line numbers for error messages). Are static variables supported in 1.9.0?
Jayanth.KRaptor Entertainment Pvt. Ltd.http://www.raptorentertainment.com---------------------------------------------------------Why Mr. Anderson? Why? ...Why keep fighting? Do you think you're fighting for something - for more than your survival? Can you tell me what it is? Do you even know? Is it freedom, or truth, perhaps peace, could it be for love? Illusions Mr. Anderson, vagaries of perception. Temporary constructs of a feeble human intellect trying desperately to justify an existence without meaning or purpose.
Regarding compiling messages, I know there's probably more important features to focus on but...

What about a SetErrorFormat( strFormat ) (or such) where user could pass desired report format using template paramaters (for example %f for fileName, %s for section, %l for line number, %c for column number, and so on...).

This way, you could, for example, format report messages in Visual compliant form, so that, when debugging you can redirect message to the Debug tab (using OutputDebugString()) and double-click on the message line in the Debug tab to directly access to the file/line of buggy code (formating messages "%f(%l) : ....").
Lbas
EddHead:

The messages report the section name. Exactly what the section name means is up to you, but I suggest that you set the section name to the filename from where the code was loaded.

What do you mean with static variables? The script global variables keep their value between executions, is this what you mean with static?

lbas:

I don't see much need for a way to change the format dynamically, but I could support different formats during compile time with a #define in as_config.h. Let me know what format you want to have and I'll prepare it for you.




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

I was aware of that, but i thought having a local static was more legible than global variables. global variables are pretty good enough though. What would your suggestion be to properly manage about 50 odd script files meant for AI and initialization? (number of engineinstances versus scriptsections)
Jayanth.KRaptor Entertainment Pvt. Ltd.http://www.raptorentertainment.com---------------------------------------------------------Why Mr. Anderson? Why? ...Why keep fighting? Do you think you're fighting for something - for more than your survival? Can you tell me what it is? Do you even know? Is it freedom, or truth, perhaps peace, could it be for love? Illusions Mr. Anderson, vagaries of perception. Temporary constructs of a feeble human intellect trying desperately to justify an existence without meaning or purpose.
Oh, you meant local static variables, like:

void func(){  static int local_static;    ... do something}


Well, I agree that it is a better coding practice to use them in situations where they really are local to the functions. But I think this is not really necessary to implement them in AngelScript, at least not yet.

My suggestion is that you have one engine instance per interface to your application, i.e. all your AI entities will probably use the same interface to the application so they should share one engine. Whether your scripts for initialization will use another engine or not depends on if they need access to application functionality that the AI routines shouldn't have access to. It might also be advantageous to use one module per AI entity type, in which case all the types can use the exact same function names, and also have global variables that are only shared between entities of that type.

Ideally you'd map one script file to each script section, and use the filename for the script section name. To the script library there is no difference if you would use separate script sections or concatenate all of them into one.

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

This topic is closed to new replies.

Advertisement