YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

C++ constructor with paramenetrs anyone?
anandrathi
#1 Posted : Wednesday, April 4, 2012 9:41:03 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/10/2011(UTC)
Posts: 5
Location: Brisbane

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I am using sqrrat as a c++ binding is it possible to register constructor with parameters?
atai
#2 Posted : Wednesday, April 4, 2012 5:24:14 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/16/2005(UTC)
Posts: 310

Thanks: 18 times
Was thanked: 18 time(s) in 14 post(s)
This is an unresolved issue and I plan to release the next version (0.8.2) without any changes in this regard. The eventual solution needs some time to be figured out.

There were existing patches for this but that conflicted with the default constructor.

anandrathi wrote:
I am using sqrrat as a c++ binding is it possible to register constructor with parameters?

anandrathi
#3 Posted : Thursday, April 5, 2012 8:14:49 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/10/2011(UTC)
Posts: 5
Location: Brisbane

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Can we have _init_ function registerered for invoking cosntructor?
I am inspired by libperl++ library ?
atai
#4 Posted : Thursday, April 5, 2012 5:20:56 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/16/2005(UTC)
Posts: 310

Thanks: 18 times
Was thanked: 18 time(s) in 14 post(s)
Never seen libperl++ before. Will take a look

anandrathi wrote:
Can we have _init_ function registerered for invoking cosntructor?
I am inspired by libperl++ library ?

khoowaikeong
#5 Posted : Thursday, November 22, 2012 8:58:25 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/20/2012(UTC)
Posts: 6

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
hope this get resolved. :)
atai
#6 Posted : Sunday, November 25, 2012 8:43:19 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/16/2005(UTC)
Posts: 310

Thanks: 18 times
Was thanked: 18 time(s) in 14 post(s)
A work around for this constructor with argument issue in SQRat:

create static methods that wrap around the constructor and then bind the wrapper functions. This can be a workaround for now.

for example (rough code, not tested as is but the approach worked for me)

In C++,

Code:

class C
{
public:
    C() {}
    C(int arg1) {   }

    C(int arg2, char arg3) {  }

    C(int arg4, char arg5, void *arg6) {   }

    static C* make_c0() { return new C(); }
    static C* make_c1(int arg1) { return new C(arg1); }
    static C* make_c2(int arg2, char arg3) { return new C(arg2, arg3); }
    static C* make_c3(int arg4, char arg5, void *arg6) { return new C(arg4, arg5, arg6); }
};





then bind the make_c* functions and export them to Squirrel
Guest
#7 Posted : Saturday, December 22, 2012 7:16:33 AM(UTC)
Rank: Guest

Groups:

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Message was deleted by Moderator.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.155 seconds.