[angelscript] Re: SV: Re: adding object methods as functions

  • From: "Daniel Krenn" <daniel@xxxxxxxxxxxxxxxx>
  • To: <angelscript@xxxxxxxxxxxxx>
  • Date: Mon, 8 Mar 2004 23:26:51 +1000

Incidentally, I should have mentioned that as far as what you said about
"granting access to the actual object and method" goes, yes, I would
generally recommend that approach, but that all depends on what you're
trying to achieve.. if you have a helper class such as a Math class, you
might just want to expose it's static methods so that every scripted
function can use them without needing to reference a class instance.

Just thoughts anyway..

Regards,
Daniel.

----- Original Message ----- 
From: "Sardaukar | Brian A. Knudsen " <sardaukar@xxxxxxxxxxxxxxxxxxxxx>
To: <angelscript@xxxxxxxxxxxxx>
Sent: 08 March, 2004 10:18 AM
Subject: [angelscript] SV: Re: adding object methods as functions


> Thanks for the repply, i dont know what i look for particular, as i am
> exploring :)=20
>
> I wanted some feedback on the subject as I'm no high-tech programmer, I
> just explore using "I wonder what happens if I do try this" approach.=20
>
> As for my question, I enterpret the answer as "its easier/better to
> grant access to the actual object and method", correct? Sorry for
> sounding like an c++ airhead ;)
>
> Brian
>
> -----Oprindelig meddelelse-----
> Fra: angelscript-bounce@xxxxxxxxxxxxx
> [mailto:angelscript-bounce@xxxxxxxxxxxxx] P=E5 vegne af Daniel Krenn
> Sendt: 8. marts 2004 00:57
> Til: angelscript@xxxxxxxxxxxxx
> Emne: [angelscript] Re: adding object methods as functions
>
> 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 -----=20
> 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.
> > =20
> >=20
> > I want to try something like this=20
> >=20
> >         r =3D engine->RegisterGlobalFunction("void bstrWrite(bstr&)",
> > (asFUNCTION)::myClass:: bstrWrite,  asCALL_CDECL);
> > assert( r >=3D 0 );
> >=20
> > =20
> >=20
> > putting bstrWrite in a separate class for structure reasons, but
> > assigning it as normal normal function within the engine.
> >=20
> > =20
> >=20
> > =20
> >=20
> > Any clues ?
> >=20
> > =20
> >=20
> > =20
> >=20
> >=20
> >=20
> >=20
> > AngelScript - AngelCode Scripting Library
> > http://www.angelcode.com/angelscript/
> >=20
>
> AngelScript - AngelCode Scripting Library
> http://www.angelcode.com/angelscript/
>
>
>
> AngelScript - AngelCode Scripting Library
> http://www.angelcode.com/angelscript/
>


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

Other related posts: