ruby 1.9 porting problem

Discussion in 'Ruby' started by Jeff Davis, Jan 1, 2008.

  1. Jeff Davis

    Jeff Davis Guest

    I am having problems porting my extension to 1.9.

    I'm doing something like:

    static VALUE my_alloc(VALUE klass)
    {
    return Data_Wrap_Struct(klass, NULL, my_free, NULL);
    }
    ...
    static VALUE my_init(int argc, VALUE *argv, VALUE self)
    {
    ...
    Check_Type(self,T_DATA);
    DATA_PTR(self) = my_var;
    ...
    }

    But on the "Check_Type(self,T_DATA)" I get:
    "[BUG] unknown type 0x12".

    This worked fine in 1.8. What's the correct way to do this in 1.9?

    Regards,
    Jeff Davis
    Jeff Davis, Jan 1, 2008
    #1
    1. Advertising

  2. Jeff Davis wrote:
    > I am having problems porting my extension to 1.9.
    >
    > I'm doing something like:
    >
    > static VALUE my_alloc(VALUE klass)
    > {
    > return Data_Wrap_Struct(klass, NULL, my_free, NULL);
    > }
    > ...
    > static VALUE my_init(int argc, VALUE *argv, VALUE self)
    > {
    > ...
    > Check_Type(self,T_DATA);
    > DATA_PTR(self) = my_var;



    That generally should work. Have you tried with a non-NULL value in
    Data_Wrap_Struct? Have you tried a 0-ary method first?

    static VALUE my_init(VALUE self)
    {
    ...
    Check_Type(self,T_DATA);
    DATA_PTR(self) = my_var;

    Regards,

    Michael
    Michael Neumann, Jan 1, 2008
    #2
    1. Advertising

  3. Jeff Davis

    Jeff Davis Guest

    On Wed, 2008-01-02 at 06:59 +0900, Michael Neumann wrote:
    > Jeff Davis wrote:
    > > I am having problems porting my extension to 1.9.
    > >
    > > I'm doing something like:
    > >
    > > static VALUE my_alloc(VALUE klass)
    > > {
    > > return Data_Wrap_Struct(klass, NULL, my_free, NULL);
    > > }
    > > ...
    > > static VALUE my_init(int argc, VALUE *argv, VALUE self)
    > > {
    > > ...
    > > Check_Type(self,T_DATA);
    > > DATA_PTR(self) = my_var;

    >
    >
    > That generally should work. Have you tried with a non-NULL value in
    > Data_Wrap_Struct? Have you tried a 0-ary method first?
    >
    > static VALUE my_init(VALUE self)
    > {
    > ...
    > Check_Type(self,T_DATA);
    > DATA_PTR(self) = my_var;
    >


    Thank you for the reply. I think I found the problem: I was compiling
    the extension against ruby 1.9, but when I ran irb, I was mistakenly
    running irb 1.8.

    Too many combinations of installations to keep track of when trying to
    do portability testing ;)

    Regards,
    Jeff Davis
    Jeff Davis, Jan 1, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Wilson
    Replies:
    2
    Views:
    152
    Robert Feldt
    Sep 25, 2003
  2. vasudevram
    Replies:
    0
    Views:
    230
    vasudevram
    Jul 25, 2006
  3. Replies:
    1
    Views:
    103
    Logan Capaldo
    Aug 8, 2006
  4. Martin Durai

    porting java methods to ruby

    Martin Durai, Nov 21, 2007, in forum: Ruby
    Replies:
    24
    Views:
    290
    Robert Dober
    Nov 22, 2007
  5. Prakash Maria susai

    Porting ruby scripts to JRuby

    Prakash Maria susai, Feb 24, 2009, in forum: Ruby
    Replies:
    2
    Views:
    144
    Prakash Maria susai
    Mar 3, 2009
Loading...

Share This Page