Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


- - - - -

AngelScript 1.9.0 WIP 4 (2004/08/31)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
45 replies to this topic

#21 EddHead   Members   -  Reputation: 140

Like
0Likes
Like

Posted 25 August 2004 - 12:29 AM

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

Sponsor:

#22 Andreas Jonsson   Moderators   -  Reputation: 3438

Like
0Likes
Like

Posted 25 August 2004 - 01:31 AM

Line and column numbers are counted from the start of each script section. Are you getting some other results?
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#23 Lbas   Members   -  Reputation: 122

Like
0Likes
Like

Posted 25 August 2004 - 03:02 AM

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


#24 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 25 August 2004 - 04:12 AM

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.

#25 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 25 August 2004 - 04:42 AM

Also, can you give me a trick to raise a warning.

Thank's

#26 Andreas Jonsson   Moderators   -  Reputation: 3438

Like
0Likes
Like

Posted 25 August 2004 - 05:49 AM

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?
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#27 EddHead   Members   -  Reputation: 140

Like
0Likes
Like

Posted 25 August 2004 - 06:20 PM

My doubts are cleared. no problems as of now!
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.

#28 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 25 August 2004 - 08:00 PM

It's ok, i have raised a Warning like this :

int iWarning;
iWarning += 500;


That result in :

TheOtherCode (2, 1) : Info : Compiling void TheOtherCode()
TheOtherCode (11, 10) : Warning : 'iWarning' is not initialized.




#29 Andreas Jonsson   Moderators   -  Reputation: 3438

Like
0Likes
Like

Posted 29 August 2004 - 03:53 AM

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:


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

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

#30 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 29 August 2004 - 08:16 PM

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.

#31 Gyrbo   Members   -  Reputation: 187

Like
0Likes
Like

Posted 30 August 2004 - 12:46 AM

I see the reason for all this manual work (users might have special cases), but I don't think it's really needed.

I would preffer it to be more automated. Something like engine->BindImported("module") after all the modules that are needed are compiled.

Or with slightly more control: engine->BindImported("module", "ImportedName", "RealModuleName");

The completely manual approach can co-exist with this one, should application writers desire this.

Just offering my suggestions :).

#32 Andreas Jonsson   Moderators   -  Reputation: 3438

Like
0Likes
Like

Posted 30 August 2004 - 02:23 AM

abrken:

I'll answer your last question first: This will change the library interface. Though the changes won't be that big that you can't start using WIP 3 already.

Currently the script syntax is:


import void Function(int param) from "module";
import void AnotherFunc() from "module";
import void OneMoreFunc() from "module";


I am playing with the thought of changing this to:


import from "module"
{
void Function(int param);
void AnotherFunc();
void OneMoreFunc();
}


But that's not really the important change. I might even use both ways.

What I noticed when doing the tests for importing functions is that there can be a slight confusion between imported function IDs and script function IDs. The current loop for binding functions will change a little, but not that much that you can't start using WIP 3 already.

The code will probably end up something like this:


asIScriptModule *module = engine->GetModule(0);

// Bind imported functions
int c = module->GetImportedFunctionCount();
for( int n = 0; n < c; ++n )
{
char buffer[256];
module->GetImportedFunctionDeclaration(n, buffer, 256);

// Get module name from where the function should be imported
const char *moduleName = module->GetImportedFunctionSourceModule(n);

asIScriptModule *otherModule = engine->GetModule(moduleName);
asFUNCID funcID = otherModule->GetFunctionIDByDecl(buffer);
module->BindImportedFunction(n, funcID);
}



Basically, most of the functions that require a module name or module index will be moved into the module interface. There will be one more interface to keep track of but I think the interfaces will be more easy to understand and use.

Gyrbo:

I've had the same thoughts, and I just might go ahead and do something like 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

#33 Andreas Jonsson   Moderators   -  Reputation: 3438

Like
0Likes
Like

Posted 30 August 2004 - 03:35 AM

If anyone has any suggestion for how to improve the dynamic binding of modules now is the time to tell me. Give WIP 3 a try and give me your feedback.

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

#34 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 30 August 2004 - 04:03 AM

WIP3 is not as easy to integrate as others ... acString changed to asString need extra work !

#35 Andreas Jonsson   Moderators   -  Reputation: 3438

Like
0Likes
Like

Posted 30 August 2004 - 04:21 AM

Yes, I decided to include acCString and acCArray as integrated parts of the library, which meant changing the name of them to follow the naming standard of the library.

Are you using acCString/acCArray outside the library?


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

#36 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 30 August 2004 - 04:26 AM

Did you try to compile AngelScrit as Debug ?

Try it and you get compil error in as_bytecode.cpp.

This is what I was meaning in : it's not so easy ...


void asCByteCode::DebugOutput(const char *name)
{
#ifdef AS_DEBUG

mkdir("AS_DEBUG");

acCString str = "AS_DEBUG\\";


Also, I'm working with source control, witch mean changing files, and it takes some times too !

And finaly, no I'm not using acStrings !

Ooops, Yes finaly I was using acString !

Oooops 2, I must write some wrapper code to pure virtual methods added to asIScriptEngine !

#37 zola   Members   -  Reputation: 122

Like
0Likes
Like

Posted 30 August 2004 - 04:46 AM

Hi everyone

This might sound a little stupid, but why do we need to bind modules manually?

Wouldn't it be much easyer if we just define that modules from which we use functions must be previously declared?

In the importing module we could write

BModule::trackEntity(e);

and the engines build method tries to bind the function automatically.

In case we need late binding (if we have circular dependencies) we still could do the binding by hand (although the engine could do this too by keeping track of what was bound and what is still unbound and checking for unbound functions after a new module is included), but this should not be the regular case.

Now, there are probably some good reasons why we need to do this by hand. I'm not familiar with the internals of AngelScript so forgive me if this really sounds like a silly thing to do.

Regards,
Tom



#38 Andreas Jonsson   Moderators   -  Reputation: 3438

Like
0Likes
Like

Posted 30 August 2004 - 05:08 AM

abrken:

Ooops from me too [wink]. I haven't compiled with the AS_DEBUG flag in quite some time. I'll do that to check the code.

You are doing some heavy integration with the library. It's only expected that you are going to have more work to do with each version.

zola:

I chose not to require the modules to be compiled in a specific order because it makes it easier to use. With the import statement a module can be correctly compiled even if the other module doesn't exist yet. You can even execute the code, but if an imported function is called before being bound you'll get a script exception.

I also wanted to allow rebinding afterwards, so that the imported functions could be exchanged at runtime, possibly even by a function called from the script itself.

Another reason why I didn't want to make it automatic is that I want to allow an application to have control over which functions that are bound. It might be that an application don't want to allow binding of all script functions, in which case it must verify what functions the script is trying to bind.

If I didn't have the above requirements I could have used automatic binding. However, I will probably do what Gyrbo suggested and provide a method that automatically binds all imported functions after compilation, which is probably what most want to do anyway.


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

#39 Andreas Jonsson   Moderators   -  Reputation: 3438

Like
0Likes
Like

Posted 30 August 2004 - 08:32 AM

After giving it a try I've decided not to create the separate module interface.

It got more awkward to work with the engine when using a separate interface. It became necessary to explicitly create the modules, and then keep track of references, etc. It was good that there was less parameters to pass with each call, but the negative impact outweighed the good ones.

I will still do some changes to the interface, but they will be minor and mostly cosmetic, e.g. using a struct for function IDs instead of just an integer (for compile time verification).

Just thought I'd let you know...
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#40 abrken   Members   -  Reputation: 130

Like
0Likes
Like

Posted 30 August 2004 - 10:00 PM

After having integrated WIP3 I get returned to WIP2 !

My program that was working suddenly get troubles on string destructors (std::string integrated).

Sad to say that I can't reproduce the bug in a code snippset, so I have decided to continue working with WIP2.

When I get time I'll try to understand what's going on with ~string, at the time it re-work perfectly with WIP2 !




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS