librelist archives

« back to archive

Re: No Subject

Re: No Subject

From:
Alex MacCaw
Date:
2009-12-17 @ 21:03
I've sorted out the 'is not bound' issue. My class was inheriting from
something that Rice couldn't seem to wrap. It was fine if Rice called any of
the direct class method, but not if those methods where inherited.

I've also found out the issue with const_set. I didn't realize it took a
VALUE, I assumed that the second argument would get turned into a Ruby
VALUE.

Thanks,
Alex

On Thu, Dec 17, 2009 at 3:25 PM, Jason Roelofs <jameskilton@gmail.com>wrote:

> Btw, we've also got a mailing list up, I'd like to move this discussion
> over there. To subscribe, simply send a blank message to
> rice@librelist.com. I've CC'd the list for reference.
>
> Jason
>
>
> On Thu, Dec 17, 2009 at 10:24 AM, Jason Roelofs <jameskilton@gmail.com>wrote:
>
>> I've added Default arguments for constructors as a todo.
>>
>> wxTopLevelWindowMac: what looks to be happening here is that some method
>> you've got wrapped is returning, or using as arguments, this
>> wxTopLevelWindowMac. The error you're seeing comes from from_ruby<>,
>> basically informing you that Rice has no idea how to handle this type. I'd
>> need to see the code you've got that's causing this error to go further.
>>
>> As for the const issue, that's really weird. I'll try to find time to see
>> if I can reproduce it. I can't imagine the value of the const is messing
>> things up, but I'm not going to rule it out. Try casting it directly to an
>> int or something, see if you can find a way to get it working.
>>
>> Jason
>>
>>
>> On Thu, Dec 17, 2009 at 7:16 AM, Alex MacCaw <maccman@gmail.com> wrote:
>>
>>> Oh, and a really weird error. Some of the constants I set throw this Ruby
>>> error:
>>>  "[BUG] object allocation during garbage collection phase"
>>> One of them is: .const_set("FD_FILE_MUST_EXIST",  wxFD_FILE_MUST_EXIST)
>>>
>>> wxFD_FILE_MUST_EXIST's value is 0x0010
>>>
>>> Other constants such as wxFD_OPEN, who's value is 0x0001, work fine.
>>>
>>> Even if I try .const_set("FD_FILE_MUST_EXIST", 16) Ruby explodes.
>>>
>>> Alex
>>>
>>>
>>> On Thu, Dec 17, 2009 at 11:25 AM, Alex MacCaw <maccman@gmail.com> wrote:
>>>
>>>> Hi Jason,
>>>>
>>>> If you have a sec, got a few questions:
>>>>
>>>> Is there a way to pass default arguments to a constructor?
>>>>
>>>>
>>>> I'm getting an error 'Data type wxTopLevelWindowMac is not bound' when
>>>> calling methods from Ruby. I'll elaborate:
>>>> I have a Window class (that ultimately inherits from wxFrame).
>>>> I can call new on it, like so:
>>>>        window = Bowline::Desktop::Window.new("", "", true, [100, 100])
>>>> However, if I call anything on the window object, I get the above error.
>>>> If I construct the window in C++, everything works fine. I guess the error
>>>> is being raised in Data_Type.ipp.
>>>>
>>>>
>>>> Thanks,
>>>> Alex
>>>>
>>>
>>>
>>>
>>> --
>>> http://www.leadthinking.com | http://socialmod.com
>>>
>>
>>
>


-- 
http://www.leadthinking.com | http://socialmod.com

Re: [rice] Re:

From:
Jason Roelofs
Date:
2009-12-17 @ 21:16
Derp, right. I've even written into rb++ to write out ".const_set('NAME',
to_ruby<Type>(Constant));" I think that's something I should look into
handling better in Rice. Good catch.

And yes, Rice is trying to use a type it doesn't know about. Any type used
in define_class<>, or expected through parameters or a return type, Rice
needs to know about (either through wrapping or through a to_ruby /
from_ruby pair).

Jason

On Thu, Dec 17, 2009 at 4:03 PM, Alex MacCaw <maccman@gmail.com> wrote:

> I've sorted out the 'is not bound' issue. My class was inheriting from
> something that Rice couldn't seem to wrap. It was fine if Rice called any of
> the direct class method, but not if those methods where inherited.
>
> I've also found out the issue with const_set. I didn't realize it took a
> VALUE, I assumed that the second argument would get turned into a Ruby
> VALUE.
>
> Thanks,
> Alex
>
> On Thu, Dec 17, 2009 at 3:25 PM, Jason Roelofs <jameskilton@gmail.com>wrote:
>
>> Btw, we've also got a mailing list up, I'd like to move this discussion
>> over there. To subscribe, simply send a blank message to
>> rice@librelist.com. I've CC'd the list for reference.
>>
>> Jason
>>
>>
>> On Thu, Dec 17, 2009 at 10:24 AM, Jason Roelofs <jameskilton@gmail.com>wrote:
>>
>>> I've added Default arguments for constructors as a todo.
>>>
>>> wxTopLevelWindowMac: what looks to be happening here is that some method
>>> you've got wrapped is returning, or using as arguments, this
>>> wxTopLevelWindowMac. The error you're seeing comes from from_ruby<>,
>>> basically informing you that Rice has no idea how to handle this type. I'd
>>> need to see the code you've got that's causing this error to go further.
>>>
>>> As for the const issue, that's really weird. I'll try to find time to see
>>> if I can reproduce it. I can't imagine the value of the const is messing
>>> things up, but I'm not going to rule it out. Try casting it directly to an
>>> int or something, see if you can find a way to get it working.
>>>
>>> Jason
>>>
>>>
>>> On Thu, Dec 17, 2009 at 7:16 AM, Alex MacCaw <maccman@gmail.com> wrote:
>>>
>>>> Oh, and a really weird error. Some of the constants I set throw this
>>>> Ruby error:
>>>>  "[BUG] object allocation during garbage collection phase"
>>>> One of them is: .const_set("FD_FILE_MUST_EXIST",  wxFD_FILE_MUST_EXIST)
>>>>
>>>> wxFD_FILE_MUST_EXIST's value is 0x0010
>>>>
>>>> Other constants such as wxFD_OPEN, who's value is 0x0001, work fine.
>>>>
>>>> Even if I try .const_set("FD_FILE_MUST_EXIST", 16) Ruby explodes.
>>>>
>>>> Alex
>>>>
>>>>
>>>> On Thu, Dec 17, 2009 at 11:25 AM, Alex MacCaw <maccman@gmail.com>wrote:
>>>>
>>>>> Hi Jason,
>>>>>
>>>>> If you have a sec, got a few questions:
>>>>>
>>>>> Is there a way to pass default arguments to a constructor?
>>>>>
>>>>>
>>>>> I'm getting an error 'Data type wxTopLevelWindowMac is not bound' when
>>>>> calling methods from Ruby. I'll elaborate:
>>>>> I have a Window class (that ultimately inherits from wxFrame).
>>>>> I can call new on it, like so:
>>>>>        window = Bowline::Desktop::Window.new("", "", true, [100, 100])
>>>>> However, if I call anything on the window object, I get the above
>>>>> error. If I construct the window in C++, everything works fine. I guess the
>>>>> error is being raised in Data_Type.ipp.
>>>>>
>>>>>
>>>>> Thanks,
>>>>> Alex
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> http://www.leadthinking.com | http://socialmod.com
>>>>
>>>
>>>
>>
>
>
> --
> http://www.leadthinking.com | http://socialmod.com
>

Re: [rice] Re:

From:
Paul Brannan
Date:
2009-12-17 @ 22:10
On Thu, Dec 17, 2009 at 4:03 PM, Alex MacCaw <maccman@gmail.com> wrote:

> I've sorted out the 'is not bound' issue. My class was inheriting from
> something that Rice couldn't seem to wrap. It was fine if Rice called any of
> the direct class method, but not if those methods where inherited.
>
> I've also found out the issue with const_set. I didn't realize it took a
> VALUE, I assumed that the second argument would get turned into a Ruby
> VALUE.
>

const_set takes an Object, not a VALUE (if you pass it a VALUE, it will be
implicitly converted to an Object first).

We could modify const_set so it automatically calls to_ruby on the parameter
you pass in.  If we do this, a VALUE will be interpreted as an integer
rather than an object reference.

Perhaps Object's constructor should be explicit to prevent this?  I
originally made it implicit so I wouldn't have to type so much, but implicit
constructors often come back to bite you in the end.

Paul