🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

AngelScript 1.9.0 WIP 4 (2004/08/31)

Started by
44 comments, last by WitchLord 19 years, 10 months ago
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 :).
Advertisement
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 functionsint 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

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

WIP3 is not as easy to integrate as others ... acString changed to asString need extra work !
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

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

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

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

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 !

This topic is closed to new replies.

Advertisement