[angelscript] Re: adding object methods as functions

  • From: "Daniel Krenn" <daniel@xxxxxxxxxxxxxxxx>
  • To: <angelscript@xxxxxxxxxxxxx>
  • Date: Mon, 8 Mar 2004 09:57:24 +1000

Wouldn't you need to use RegisterObjectMethod(...) to register the methods.
e.g.

engine->RegisterObjectType("MyClass", sizeof(MyClass), 0);
engine->RegisterObjectProperty("MyClass", "float myMemberVariable", 
offsetof(MyClass, myMemberVariable), 0);
engine->RegisterObjectMethod("MyClass", "void bstrWrite(bstr &)", 
asMETHOD(MyClass::bstrWrite), asCALL_THISCALL);

If you're wanting to register the class methods as global functions then I 
imagine you'd need to make the methods static.. I've never done this though, 
since I've never had a need to.

Regards,
Daniel.

----- Original Message ----- 
From: "Brian Adsbol Knudsen" <brian@xxxxxxxxx>
To: <angelscript@xxxxxxxxxxxxx>
Sent: 08 March, 2004 9:49 AM
Subject: [angelscript] adding object methods as functions


> Can I add object methods as functions? I'm having a hard time trying.
>  
> 
> I want to try something like this 
> 
>         r = engine->RegisterGlobalFunction("void bstrWrite(bstr&)",
> (asFUNCTION)::myClass:: bstrWrite,  asCALL_CDECL);
> assert( r >= 0 );
> 
>  
> 
> putting bstrWrite in a separate class for structure reasons, but
> assigning it as normal normal function within the engine.
> 
>  
> 
>  
> 
> Any clues ?
> 
>  
> 
>  
> 
> 
> 
> 
> AngelScript - AngelCode Scripting Library
> http://www.angelcode.com/angelscript/
> 

AngelScript - AngelCode Scripting Library
http://www.angelcode.com/angelscript/

Other related posts: