Is there a faq?
Hello everyone,I've used Squirrel Script for some days,but squirrel doesn't support pod type pass as reference param like "fun(float& f)",neither does c++ array...so I want to know is anglescript better than it?Can anybody give me a comparison between them?
1.how to debug anglescript line by line? Is there an IDE to debug it?
2.is there a wrapper for "AS"?just like sqplus for squirrel.
3.Does "AS" support UNICODE?
4.is there a example of using "add_on\autowrapper"?I googled "asDECLARE_FUNCTION_WRAPPER" but there is 0 result
5.Is there a more easy way to call "AS" function?
instead of
ctx->SetArgDWord(0, 1);ctx->SetArgDouble(1, 3.141592);ctx->Execute();
like: asFunctionObj(1,3.14);?
[Edited by - huangyous on April 15, 2009 2:09:51 AM]
-I haven't heard of an IDE so I suppose you would need to debug it yourself using VS.
-There should be a thread about a month old (or younger) in this forum about an auto-wrapper, shouldn't be too hard to find.
I can't answer the other two though.
-There should be a thread about a month old (or younger) in this forum about an auto-wrapper, shouldn't be too hard to find.
I can't answer the other two though.
1.
There was work on an IDE for debugging AngelScript a couple of years ago, but it was probably never completed and would probably not be up-to-date as I haven't heard from it in a long time.
I have plans to provide a standard IDE with the SDK in the future, but I have enough work with the core library as it is, so it will be a very long time before I can implement that.
The AngelScript library provides the necessary functions for implementing the debugger yourself though. You can execute scripts line-by-line, and you can investigate call stack and variables during the script execution.
2.
There have been many attempts at writing wrappers for AS, but those that I've seen were all implemented to suit the author, so it wasn't something that I could add to AS as a standard add-on.
The autowrapper add-on partially provides the functionality, in that it automatically generates the wrappers for the generic calling convention. Most of the time you don't need to use the generic calling convention though, so you'll probably not need to wrap anything at all.
3.
Yes. AS supports Unicode, but only encoded as UTF8 at the moment. I may add support for UTF16 too, but it is not a high priority.
4.
The only example of using the autowrapper at the moment is in the test_feature project. Look for the test_generic.cpp file.
The template code is not compatible with older compilers so it's not something I can use everywhere.
5.
Not at the moment. But I plan on implementing something similar to the autowrapper for creating C++ functions for easily calling script functions.
Usually the application doesn't call too many different script functions though, so you'll probably spend very little time writing the actual code that calls the script function.
There was work on an IDE for debugging AngelScript a couple of years ago, but it was probably never completed and would probably not be up-to-date as I haven't heard from it in a long time.
I have plans to provide a standard IDE with the SDK in the future, but I have enough work with the core library as it is, so it will be a very long time before I can implement that.
The AngelScript library provides the necessary functions for implementing the debugger yourself though. You can execute scripts line-by-line, and you can investigate call stack and variables during the script execution.
2.
There have been many attempts at writing wrappers for AS, but those that I've seen were all implemented to suit the author, so it wasn't something that I could add to AS as a standard add-on.
The autowrapper add-on partially provides the functionality, in that it automatically generates the wrappers for the generic calling convention. Most of the time you don't need to use the generic calling convention though, so you'll probably not need to wrap anything at all.
3.
Yes. AS supports Unicode, but only encoded as UTF8 at the moment. I may add support for UTF16 too, but it is not a high priority.
4.
The only example of using the autowrapper at the moment is in the test_feature project. Look for the test_generic.cpp file.
The template code is not compatible with older compilers so it's not something I can use everywhere.
5.
Not at the moment. But I plan on implementing something similar to the autowrapper for creating C++ functions for easily calling script functions.
Usually the application doesn't call too many different script functions though, so you'll probably spend very little time writing the actual code that calls the script function.
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've written a basic AngelScript IDE with .NET. You can see the source code here. It's a Visual Studio 2008 project and requires Scintilla .NET.
I don't think you need a wrapper at all with angelscript. That's it's strenght.
Yes,now I feel it's more flexible than Squirrel&sqplus.But somehow I have to write some macro to make my binding code shorter,I hope there will be a more easy way to bind derive class.for example if I have these classes:
class Father
{
void SameFunction(){}
};
class Son:public Father
{...};
class Daughter:public Father
{...};
bind them:
...RegisterObjectType("Father"...
...RegisterObjectMethod("Father","void SameFunction()"...
...RegisterObjectType("Son"...
...RegisterObjectMethod("Son","void SameFunction()"...
...RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST,"Father@ f(Son@)"...
...RegisterObjectBehaviour("Father",asBEHAVE_REF_CAST,"Son@ f(Father@)"...
...RegisterObjectType("Daughter"...
...RegisterObjectMethod("Daughter","void SameFunction()"...
...RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST,"Father@ f(Daughter@)"...
...RegisterObjectBehaviour("Father",asBEHAVE_REF_CAST,"Daughter@f(Father@)"...
I have to register the SameFunction multitimes;Is there a more convenient way?
and In another case:
class Grandpa{};class Father{};class Son{};
bind "Son":
...RegisterObjectType("Son"...
...RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST,"Father@ f(Son@)"...
...RegisterObjectBehaviour("Father",asBEHAVE_REF_CAST,"Son@ f(Father@)"...
...RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST,"Grandpa@ f(Son@)"...
...RegisterObjectBehaviour("Grandpa",asBEHAVE_REF_CAST,"Son@ f(Grandpa@)"...
I have to register the "CAST" behavior between Grandpa<->Father and Father<->Son and Grandpa<->Son.
So I think it will be nice if I can just tell AS that "Son" derives from "Father",and don't need to bind "Father" method multitimes;
class Father
{
void SameFunction(){}
};
class Son:public Father
{...};
class Daughter:public Father
{...};
bind them:
...RegisterObjectType("Father"...
...RegisterObjectMethod("Father","void SameFunction()"...
...RegisterObjectType("Son"...
...RegisterObjectMethod("Son","void SameFunction()"...
...RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST,"Father@ f(Son@)"...
...RegisterObjectBehaviour("Father",asBEHAVE_REF_CAST,"Son@ f(Father@)"...
...RegisterObjectType("Daughter"...
...RegisterObjectMethod("Daughter","void SameFunction()"...
...RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST,"Father@ f(Daughter@)"...
...RegisterObjectBehaviour("Father",asBEHAVE_REF_CAST,"Daughter@f(Father@)"...
I have to register the SameFunction multitimes;Is there a more convenient way?
and In another case:
class Grandpa{};class Father{};class Son{};
bind "Son":
...RegisterObjectType("Son"...
...RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST,"Father@ f(Son@)"...
...RegisterObjectBehaviour("Father",asBEHAVE_REF_CAST,"Son@ f(Father@)"...
...RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST,"Grandpa@ f(Son@)"...
...RegisterObjectBehaviour("Grandpa",asBEHAVE_REF_CAST,"Son@ f(Grandpa@)"...
I have to register the "CAST" behavior between Grandpa<->Father and Father<->Son and Grandpa<->Son.
So I think it will be nice if I can just tell AS that "Son" derives from "Father",and don't need to bind "Father" method multitimes;
You can simplify your code through some clever code reuse, e.g:
You will only have to write the registration code for the methods of each type, once this way. Also, many of the behaviours can easily be implemented through macros or template code, so if you have a lot of similar types and behaviours, think about how to unify them.
I've planned to write an article in the manual for how to register class hierarchies. I'll probably include the above as one way of simplifying it.
// Implemented as a template function to support multiple inheritancetemplate <class T>void RegisterFathersMethods(asIScriptEngine *engine, const char *type){ engine->RegisterObjectMethod(type, "void aMethod()", asMETHOD(T, aMethod), asCALL_THISCALL);}template <class T>void RegisterSonsMethods(asIScriptEngine *engine, const char *type){ // Register the inherited methods by calling // registration of the fathers methods RegisterFathersMethods<T>(engine, type); // Now register my new methods engine->RegisterObjectMethod(typem "void aNewMethod()", asMETHOD(T, aNewMethod), asCALL_THISCALL);}void RegisterTypes(asIScriptEngine *engine){ engine->RegisterObjectType("father", 0, asOBJ_REF); RegisterFathersMethods<father>(engine, "father"); engine->RegisterObjectType("son", 0, asOBJ_REF); RegisterSonsMethods<son>(engine, "son");}
You will only have to write the registration code for the methods of each type, once this way. Also, many of the behaviours can easily be implemented through macros or template code, so if you have a lot of similar types and behaviours, think about how to unify them.
I've planned to write an article in the manual for how to register class hierarchies. I'll probably include the above as one way of simplifying it.
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 want to register class derived from value type class like this:
RegisterObjectType("NxActorDescBase",sizeof(NxActorDescBase),asOBJ_VALUE|asOBJ_POD|asOBJ_APP_CLASS_C)
...
RegisterObjectType("NxActorDesc",sizeof(NxActorDesc),asOBJ_VALUE|asOBJ_POD|asOBJ_APP_CLASS_C)
RegisterObjectBehaviour("NxActorDesc",asBEHAVE_IMPLICIT_VALUE_CAST,"NxActorDescBase f()", asFUNCTION(castNxActorDescToNxActorDescBase), asCALL_CDECL_OBJFIRST)
...
static Son castNxActorDescToNxActorDescBase(NxActorDesc* p){return*static_cast<NxActorDesc*>(p);}
and in AngelScript:
NxPlaneShapeDesc planedesc;
planedesc.normal=NxVec3(0.0f,-1.0f,0.0f);
planedesc.d=-20.0f;
NxActorDesc actorDesc;
actorDesc.AddShape(planedesc);
NxScene@ uiscene=PhysicsManager_I.GetScene(true);
uiscene.createActor(actorDesc);//fail here :invalid memory access
So what's the correct way to register "asOBJ_VALUE" derive class?
RegisterObjectType("NxActorDescBase",sizeof(NxActorDescBase),asOBJ_VALUE|asOBJ_POD|asOBJ_APP_CLASS_C)
...
RegisterObjectType("NxActorDesc",sizeof(NxActorDesc),asOBJ_VALUE|asOBJ_POD|asOBJ_APP_CLASS_C)
RegisterObjectBehaviour("NxActorDesc",asBEHAVE_IMPLICIT_VALUE_CAST,"NxActorDescBase f()", asFUNCTION(castNxActorDescToNxActorDescBase), asCALL_CDECL_OBJFIRST)
...
static Son castNxActorDescToNxActorDescBase(NxActorDesc* p){return*static_cast<NxActorDesc*>(p);}
and in AngelScript:
NxPlaneShapeDesc planedesc;
planedesc.normal=NxVec3(0.0f,-1.0f,0.0f);
planedesc.d=-20.0f;
NxActorDesc actorDesc;
actorDesc.AddShape(planedesc);
NxScene@ uiscene=PhysicsManager_I.GetScene(true);
uiscene.createActor(actorDesc);//fail here :invalid memory access
So what's the correct way to register "asOBJ_VALUE" derive class?
asBEHAVE_VALUE_CAST and asBEHAVE_IMPLICIT_VALUE_CAST must return a new value. They must not return a reference to the input value as it will mess up the memory since AngelScript thinks the two values are separate objects.
It is currently not possible to register reference cast behaviours for value types. I'll have to think about the implications of allowing this. If it is possible I'll add this support in a future version.
It is currently not possible to register reference cast behaviours for value types. I'll have to think about the implications of allowing this. If it is possible I'll add this support in a future version.
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
Popular Topics
Advertisement