|
|||||
|
|
#1 |
|
|
what's the correct way to do this? i'm poking around in file.c now - no File.new to be found... IO.open perhaps? i need to return an open file from a c function... cheers. -a -- ================================================== ============================= | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; and a weed grows, even though we do | not love it. --Dogen ================================================== ============================= |
|
|
#2 |
|
|
> what's the correct way to do this? i'm poking around in file.c now - no > File.new to be found... IO.open perhaps? i need to return an open file > from a c function... This should work: return rb_funcall(rb_cFile, rb_intern(":new"), rb_str_new2("filename")); Sean O'Dell |
|
|
#3 |
|
|
> > This should work: > > return rb_funcall(rb_cFile, rb_intern(":new"), rb_str_new2("filename")); Oops, try: return rb_funcall(rb_cFile, rb_intern(":new"), 1, rb_str_new2("filename")); Sean O'Dell |
|
|
#4 |
|
|
On Tue, 22 Jun 2004, Sean O'Dell wrote:
> On Monday 21 June 2004 14:25, Sean O'Dell wrote: >> >> This should work: >> >> return rb_funcall(rb_cFile, rb_intern(":new"), rb_str_new2("filename")); > > Oops, try: > > return rb_funcall(rb_cFile, rb_intern(":new"), 1, rb_str_new2("filename")); > > Sean O'Dell hmmm. is this really the best way? i mean, why not call the dispatched to method directly? i suppose this insulates you from name changes - but it seems like one should be to call it directly doesn't it? cheers. -a -- ================================================== ============================= | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; and a weed grows, even though we do | not love it. --Dogen ================================================== ============================= |
|
|
#5 |
|
|
Hi,
At Tue, 22 Jun 2004 06:26:39 +0900, Sean O'Dell wrote in [ruby-talk:104279]: > > This should work: > > > > return rb_funcall(rb_cFile, rb_intern(":new"), rb_str_new2("filename")); > > Oops, try: > > return rb_funcall(rb_cFile, rb_intern(":new"), 1, rb_str_new2("filename")); rb_intern(":new") differs from rb_intern("new"). You also can use rb_cl***_new_instance() instead. return rb_cl***_new_instance(1, rb_str_new2("filename"), rb_cFile); -- Nobu Nakada |
|
|
#6 |
|
|
Ara.T.Howard wrote:
> > what's the correct way to do this? i'm poking around in file.c now - no > File.new to be found... IO.open perhaps? i need to return an open file > from a c function... > Hmmm...do you want MakeOpenFile() from rubyio.h? |
|
|
#7 |
|
|
Hi,
At Tue, 22 Jun 2004 06:23:13 +0900, Ara.T.Howard wrote in [ruby-talk:104277]: > what's the correct way to do this? i'm poking around in file.c now - no > File.new to be found... IO.open perhaps? i need to return an open file from > a c function... You should see io.c. VALUE rb_file_open(const char *fname, const char *mode); VALUE rb_file_sysopen(const char *fname, int flags, int mode); Hmmm, but rb_file_sysopen() lacks the prototype... -- Nobu Nakada |
|
|
#8 |
|
|
On Monday 21 June 2004 14:37, nobu.nokada@softhome.net wrote:
> Hi, > > At Tue, 22 Jun 2004 06:26:39 +0900, > > Sean O'Dell wrote in [ruby-talk:104279]: > > > This should work: > > > > > > return rb_funcall(rb_cFile, rb_intern(":new"), > > > rb_str_new2("filename")); > > > > Oops, try: > > > > return rb_funcall(rb_cFile, rb_intern(":new"), 1, > > rb_str_new2("filename")); > > rb_intern(":new") differs from rb_intern("new"). Typing too fast again, you're right. Sean O'Dell |
|
|
#9 |
|
|
On Monday 21 June 2004 14:43, Ara.T.Howard wrote:
> On Tue, 22 Jun 2004, Sean O'Dell wrote: > > On Monday 21 June 2004 14:25, Sean O'Dell wrote: > >> This should work: > >> > >> return rb_funcall(rb_cFile, rb_intern(":new"), rb_str_new2("filename")); > > > > Oops, try: > > > > return rb_funcall(rb_cFile, rb_intern(":new"), 1, > > rb_str_new2("filename")); > > > > Sean O'Dell > > hmmm. is this really the best way? i mean, why not call the dispatched to > method directly? i suppose this insulates you from name changes - but it > seems like one should be to call it directly doesn't it? Since in C you don't have access to all of the C functions that implement every method in every cl***, it's simply the most consistent way to make the call. If you know the actual C function name, I'm sure you could call that directly. Sean O'Dell |
|
|
#10 |
|
|
On Tue, 22 Jun 2004 nobu.nokada@softhome.net wrote:
> VALUE rb_file_open(const char *fname, const char *mode); bingo. that solve's problem one. problem two - correct way for turning a FILE *filep into a rb_cFile; -a -- ================================================== ============================= | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; and a weed grows, even though we do | not love it. --Dogen ================================================== ============================= |