Followers 0

# AngelScript 1.9.0 WIP 4 (2004/08/31)

## 45 posts in this topic

Dear subscribers, I've had quite a lot of slack time at work lately so I've been able to put in a few hours here and there on AngelScript, this is why you've been seeing so many updates lately. Today I bring you the first work-in-progress version of 1.9.0 with the following changes: - Renamed RegisterTypeBehaviour() to RegisterObjectBehaviour() - Removed the flags asCALL_RETURNBYVAL and asCALL_RETURNBYREF - Removed the flags asOBJ_IS_COMPLEX and asOBJ_IS_NOT_COMPLEX - Compiler no longer outputs unecessary messages, such as "Building..." - Each error message now follows a standard format: {section name} ({row}, {col}) : {Error or Warning} : {Message} - Included support for saving and loading compiled bytecode (thanks Dennis Bollyn) I will probably release at least one more WIP this week. Though I haven't decided if I'll add dynamically growing script stacks first, or dynamic binding between modules. Regards, Andreas Jönsson Author of AngelScript [Edited by - WitchLord on August 31, 2004 7:50:38 PM]
0

##### Share on other sites
Can you Add custom build/error messages to the TODO list of 1.9.0?
0

##### Share on other sites
Cool :)

Would it be very difficult to have something like typedef in the scripts? So we could define aliases for the angelscript datatypes.

I know that I could replace the types during binding generation myself, but one thing I use Angelscript for is to experiment with algorithms. Once they are done I would like to cut and paste them into my C++ code. Typedefs would help to keep the code intact.

Keep up the good work.

Regards
Tom
0

##### Share on other sites

Are you talking about translated messages? I don't think I will do this dynamically as it would be easier to just translate the static text strings in as_texts. If you want present the messages in a different way than is returned by the library you can easily do so by parsing the message. Every message follow the same pattern:

<script name> (<row>, <col>) : <Error or Warning> : <message string>

If this is not what you meant, perhaps you would like to tell me (again) in more detail just exactly what you need with custom messages.

zola:

It certainly would be possible, though it probably would require quite a lot of work. I'm sorry to say that I'll have to put this at the bottom of the to-do list.
0

##### Share on other sites
zola: how about using the typdef in your C(++) code? You can probably also do a simply search-and-replace, but that's most likely not the answer you want ;).
0

##### Share on other sites
What i meant was, if i needed to change messages like Building.... to something else, from the host app if necessary! i wasnt talking about the format of the error code, just the strings used in them, including removing them altogether, just to make sure i treat each type of script init seperately( different messages to each script module GUI / State Changes etc.)
0

##### Share on other sites
Well, I've removed unecessary messages altogether. You'll no longer see "Building..." nor "Completed (0 errors, 0 warnings)". The only messages that are output are error messages and warnings. This will allow you to write whatever you like before and after compiling.

If you want a count of the errors and warnings you'll have to do a search for ": Error" or ": Warning" in the strings. It will be a bit more work for the application writer, but not too much I think, and it gives more flexibility.

bool isError = strstr(msg, ": Error") ? true : false;

I have ideas of making the error messages even more standardized and give each one of them a message number. The message number can be used to filter output, show help text, or even translate the message string. But I don't think I'll do this for this version.
0

##### Share on other sites
All I really needed was a possibility to change the basic type names for uint8 uint16 etc.
It turned out to be really easy, I just extend the tokenWords array and added my token aliases.
0

##### Share on other sites
Are you planning to support static variables in 1.9.0?
0

##### Share on other sites
Quote:
 Original post by WitchLordThe only messages that are output are error messages and warnings. This will allow you to write whatever you like before and after compiling.

As I was aswering to my last post about the '{' bug, I have realized that some messages are very important and hope that what you have written is partialy false :

in this compilation report
Building...Parsing: "FlipImage" Error   : (53, 0) Expected expression value Error   : (53, 0) Unexpected end of fileCompiling function 'AcceuilEng_MOUSE_0' in "AcceuilEng_MOUSE_0" Error   : (4, 1) Function 'FlipImage' not foundCompiling function 'AcceuilFra_MOUSE_0' in "AcceuilFra_MOUSE_0" Error   : (4, 1) Function 'FlipImage' not foundCompleted. (errors: 4, warnings: 0)

do the
Parsing: "FlipImage"
or
Compiling function 'AcceuilEng_MOUSE_0' in "AcceuilEng_MOUSE_0"
is still present in 1.9.x or not ?

If not, this is not a good thing because without those lines we wont be able to find in witch part of code the errors are detected when using multiple AddScriptSection call.

AbrKen.
0

##### Share on other sites
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?

0

##### Share on other sites
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.

0

##### Share on other sites
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?
0

Simply great !
0

##### Share on other sites
The latest WIP has been uploaded.
Changes:

- Removed the need to pass stack size when calling Prepare() or ExecuteString()
- 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.
0

##### Share on other sites
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?
0

##### Share on other sites
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) : ....").
0

##### Share on other sites

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.

0

##### Share on other sites
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)
0

##### Share on other sites
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.

0

##### Share on other sites
This is typically how i am using it, 1 for GUI, 1 for AI behaviors and 1 for Mission handling. i was just worried about correct display of erronous line numbers. I'll get back on that.
0

##### Share on other sites
Line and column numbers are counted from the start of each script section. Are you getting some other results?
0

##### Share on other sites
Ok, so a useful error message format for me would be the one used by the VC compiler :

fullFileName(lineNumber) : message

for example :

d:\projects\test\test.cpp(21) : error C2660: 'new' : function does not take 2 parameters

This way, by double-clicking on the error message in the Debug Tab (in debug session) the corresponding script file would be opened in the editor with the cursor focused on the corresponding line.

Lbas
0

##### Share on other sites
Hi,

Actually, I do implement the error reporting into my script editor that is Scintilla based.

No problems to find the correct position at witch the error occurs.

But, something is missing in the error report (at least for me !).

The number of characters that raised the error.

Example :

AbonneFra_MOUSE_1 (2, 1) : Info    : Compiling void AbonneFra_MOUSE_1()AbonneFra_MOUSE_1 (13, 1) : Error   : Function 'buggy' not found

How can I find the number of chars to hilight (length("buggy()").

Can you do something for this Mr WitchLord ?

<script name> (<row>, <col>, <len>) : <Error or Warning> : <message string>

without <len> I will hilight the word, and at the moment it's good enought.
0

##### Share on other sites
Also, can you give me a trick to raise a warning.

Thank's
0

## Create an account

Register a new account