Jump to content
  • Advertisement
Sign in to follow this  
coollofty

how to do these in 2.1.0??

This topic is 4908 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I always use the version 1.10, yesterday I update to the version 2.1.0, but some errors make me don't know how to fix :( 1.pEngine->RegisterGlobalFunction("void sincos(float, float & sine, float & cosine)", asFUNCTIONPR(fSinCos, (float, float&, float&), void), asCALL_CDECL); 2.pEngine->RegisterObjectMethod("File", "int Read(void *, int)", asMETHODPR(scriptFileClass, Read, (void*, int), int), asCALL_THISCALL); 3.pEngine->RegisterObjectMethod("File", "int Write(const void *, int)", asMETHODPR(scriptFileClass, Write, (const void*, int), int), asCALL_THISCALL); ...... above code is some my functions register, and are get error returned. in the version 1.10 there were no any problem, and I could not find the correct usage from the manual. I think I can not thought out what error happened :( please help me, thx.

Share this post


Link to post
Share on other sites
Advertisement
In steps (2) and (3) you are registering methods for the object type "File". Before you register object methods, first you need to register the object type "File" with the method RegisterObjectType(...). I do not know if this is a requirement strictly for versions 2.x onwards of Angelscript as I've never used 1.10.

edit: Also, if you're going to register methods that use other object types in their parameter list or the return type, these object types must be registered beforehand.

[Edited by - SharkBait on May 11, 2005 4:00:55 AM]

Share this post


Link to post
Share on other sites
Quote:
In steps (2) and (3) you are registering methods...


He didn't post all the code. Chances are, registering the types didn't fail, so he didn't post them.

The problem is in the types being used as parameters to the functions. 2.0 handles it quite a bit differently. Pointers can no longer be used directly, and 'in out' keywords have been added, and all sorts of other things that involve using @. You'd best take a long walk through the app and script writers manuals again.

Share this post


Link to post
Share on other sites
Indeed. Version 2.0.0 changed the script language slightly to provide a safer environment for scripting.

The registrations fail because you use the byref type modifier without one of 'in', 'out', or 'inout' keywords. The extra keyword is obligatory, because AngelScript needs to know what you intend to do with the values passed in the argument.

The pointer type modifier * is no longer available in AS 2.0.0. It has been somewhat replaced by the object handle @. An object handle is basically a reference counted pointer, and it requires the object type to have the addref and release behaviours registered.

I suggest you take a look at the sample application for more information on how things work now.

Share this post


Link to post
Share on other sites
So that's why, hehe.

In steps 2 and 3, I registed the object type first, but I'm not post the full code, sorry:)

Infact, I like this script engine, because it like the C++ language. But remove the point operator, I don't know why? With my personal viewpoint, point is a very convenient thing, and same in script language, although the safety maybe a little bit bad......

However the problem is cleared up, THX:)

Share this post


Link to post
Share on other sites
I agree that pointers are convenient. But unfortunately it is almost impossible to make the script environment safe and secure and still allow pointers, which is why I had to remove them.

Share this post


Link to post
Share on other sites
I recently simplified the move to 2.x by binding smart pointers to objects instead of actual objects. To the scripts, the change is invisible. To the app, they are still essentially pointers, with the bonus that I can pass them by value and not have to worry about screwing up AngelScript's own reference counting.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!