(C ext to Ruby) variable args count class

U

unbewust

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
 
T

Tim Pease

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
 
U

unbewust

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top