AngelScript 1.9.0 WIP 4 (2004/08/31)
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.
Line and column numbers are counted from the start of each script section. Are you getting some other results?
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
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
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 :
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.
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.
Ok, I'll work on some way of defining the message format in as_config.h. Probably a simple printf() formatting string, with numbered arguments.
I'll also see if I can give better information on the exact token that causes the message. This can be either the length, or the exact token, or both.
Another thing I've been thinking on adding is a line offset when calling AddScriptSection(), this will allow you to offset the line numbers reported in error messages and exceptions thrown by the scripts. This would be used by those who, like abrken, add code before the actual script.
abrken:
Could you give me a little more detail on what you want? What do you mean with a trick to raise a warning?
I'll also see if I can give better information on the exact token that causes the message. This can be either the length, or the exact token, or both.
Another thing I've been thinking on adding is a line offset when calling AddScriptSection(), this will allow you to offset the line numbers reported in error messages and exceptions thrown by the scripts. This would be used by those who, like abrken, add code before the actual script.
abrken:
Could you give me a little more detail on what you want? What do you mean with a trick to raise a warning?
It's ok, i have raised a Warning like this :
That result in :
int iWarning;iWarning += 500;
That result in :
TheOtherCode (2, 1) : Info : Compiling void TheOtherCode()TheOtherCode (11, 10) : Warning : 'iWarning' is not initialized.
I've uploaded WIP 3 now.
This version adds dynamic binding of functions between modules, which allow functions to call into other modules.
The following code shows how the import can be done:
I'm however not satisfied with how the asIScriptEngine interface has become so bloated with the latest additions. I will therefore break out the module interface, which will make it easier to work with.
Regards,
Andreas Jönsson
This version adds dynamic binding of functions between modules, which allow functions to call into other modules.
The following code shows how the import can be done:
//// Tests importing functions from other modules//// Test author: Andreas Jonsson//#include "angelscript.h"#include <stdio.h>#include <stddef.h>#include <string.h>#include <string>namespace TestImport{#define TESTNAME "TestImport"static std::string output;class COutStream : public asIOutputStream{public: void Write(const char *text) { printf(text); /*output += text;*/ }};static const char *script1 ="import void Test() from \"DynamicModule\"; \n""void main() \n""{ \n"" Test(); \n""} \n";static const char *script2 ="void Test() \n""{ \n"" number = 1234567890; \n""} \n";bool Test(){ bool fail = false; int number = 0; asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); engine->RegisterGlobalProperty("int number", &number); COutStream out; engine->AddScriptSection(0, TESTNAME ":1", script1, strlen(script1)); engine->Build(0, &out); engine->AddScriptSection("DynamicModule", TESTNAME ":2", script2, strlen(script2)); engine->Build("DynamicModule", &out); int module1 = engine->GetModuleID(0); // Bind imported functions int c = engine->GetImportedFunctionCount(0); for( int n = 0; n < c; ++n ) { char buffer[256]; engine->GetImportedFunctionDeclaration(module1 + n, buffer, 256); // Get module name from where the function should be imported const char *moduleName = engine->GetImportedFunctionSourceModule(module1 + n); int funcID = engine->GetFunctionIDByDecl(moduleName, buffer); engine->BindImportedFunction(module1 + n, funcID); } engine->ExecuteString(0, "main()", &out, 0); engine->Release(); if( number != 1234567890 ) { printf("%s: Failed to set the number as expected\n", TESTNAME); fail = true; } // Success return fail;}} // namespace
I'm however not satisfied with how the asIScriptEngine interface has become so bloated with the latest additions. I will therefore break out the module interface, which will make it easier to work with.
Regards,
Andreas Jönsson
Quote:Original post by WitchLord
I'm however not satisfied with how the asIScriptEngine interface has become so bloated with the latest additions. I will therefore break out the module interface, which will make it easier to work with.
What do you mean when you write this ?
1/ Do the syntax that is discribed in your code will change for the script (import ... from ...)
2/ Do the link between the modules will change for the C++ (loop GetImportedFunctionCount)
3/ Is this going to be an internal change that wont change anything from script to C++ interface.
Since I was waiting for dynamic binding of functions between modules, I can wait for another version if WIP 3 is just a primary approach.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement