[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

C ext to Ruby) variable args count class

unbewust

8/6/2007 2:54:00 PM

i have a class "RFile" with varaible aruments number (1 to 3) this
class is defined under a module "ROSXUtils"

from the module i have three singleton :

m_trash(one arg)

m_move(two args)

m_rename(three args)

in such a situation how can i play with :

rb_class_new_instance(n, &arg, rb_path2class("RFile")); ???

because if i put n = 2 i can see that from the class initialisation
method

however i can't pass de 2 args needed here ???

the same with three args


does i have to build something like an array to pass as arg ???


for m_move by example i have :

m_move(VALUE src_path, VALUE dst_dir, self)

and i want to return an RFile class object using :

rFile = rb_class_new_instance(2, <what kind of args here ???>,
rb_path2class("RFile"));


any light apreciated ;-)

Yvon

2 Answers

Tim Pease

8/6/2007 3:28:00 PM

0

On 8/6/07, unbewust <yvon.thoraval@gmail.com> wrote:
>
>
> for m_move by example i have :
>
> m_move(VALUE src_path, VALUE dst_dir, self)
>
> and i want to return an RFile class object using :
>
> rFile = rb_class_new_instance(2, <what kind of args here ???>,
> rb_path2class("RFile"));
>

You need an array of type VALUE (either VALUE* or VALUE[2])

VALUE[2] args;

args[0] = your_first_argument;
args[1] = your_second_argument;

rFile = rb_class_new_instance(2, args, rb_path2class("RFile"));


Blessings,
TwP

unbewust

8/7/2007 8:22:00 AM

0

On 6 ao?t, 17:27, "Tim Pease" <tim.pe...@gmail.com> wrote:
> On 8/6/07, unbewust <yvon.thora...@gmail.com> wrote:
>
>
>
> > for m_move by example i have :
>
> > m_move(VALUE src_path, VALUE dst_dir, self)
>
> > and i want to return an RFile class object using :
>
> > rFile = rb_class_new_instance(2, <what kind of args here ???>,
> > rb_path2class("RFile"));
>
> You need an array of type VALUE (either VALUE* or VALUE[2])
>
> VALUE[2] args;
>
> args[0] = your_first_argument;
> args[1] = your_second_argument;
>
> rFile = rb_class_new_instance(2, args, rb_path2class("RFile"));
>
> Blessings,
> TwP


Ok thanks very very much !!!

I'm not too far of publishing a first alpha version of RSOXUtils for
Ruby ;-)

best,

Yvon