On Thursday, Sep 12, 2002, at 19:38 US/Pacific, Maggie Xiao wrote:

> Is there anyone has used inline.rb to extend ruby in c? Should i 
> include the
> header file
> inside the class? and should i include them just like in c code? For 
> example:
> #include <unistd.h>
> #include <signal.h>

Ahh, stated this way I finally think I understand your question... 
Good. I didn't feel good with my last "huh?" response. :)

Actually, the current version of inline is far too stupid to deal with 
this, at least the way you'd expect. Actually, come to think of it, for 
simple C headers, I guess it would not only work, but also be totally 
legal. Let me explain with the following bogus call to inline:

class Blah
include Inline
   def something(*args)
     inline args, "some code"
   end
end

becomes the C code:

   #include <ruby.h>

   static VALUE t_something(int argc, VALUE *argv, VALUE self) {
         some code
   }

   VALUE cMod_Blah_something;

   void Init_Mod_Blah_something() {
     cMod_Blah_something = rb_define_module("Mod_Blah_something");
     rb_define_method(cMod_Blah_something, "_something", t_something, 
-1);
   }

Now, w/ a plain C header (no inlined code ala C++, no other weird fancy 
stuff), it _should_(*) be perfectly legal to have #include INSIDE the 
function, it will look weird, and nobody would every write a function 
that way, but it should compile.

That said, I think it sucks and I think I'll add an optional string for 
extra includes or something... Suggestions? I'd like to keep the 
signature relatively the same if possible, but changing the signature 
right now won't effect it too bad right now since it's so new.

*) I could be wrong, verify w/ your local pedant.