Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Matt Someone
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-31 15:12
Great =)

I'll keep using SWIG on my project, in the hope that later I can use Rice or even rb++ with it.
I just don't trust the memory management behind the incredible complex .cxx file that SWIG produces.

By: Jason Roelofs
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-31 13:00
Glad to hear it. As for a 1.2.0 release, I've been working a lot on rb++[1] and rbgccxml[2] to work with the new features I've added to Rice. Once I've got them in pretty good shape and can prove to myself that the Rice features (Director and default arguments, mainly) are working as expected, I'll get a release out of everything.

[1] http://github.com/jameskilton/rbplusplus
[2] http://github.com/jameskilton/rbgccxml

By: Matt Someone
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-30 23:10
I've downloaded and compiled manually.

The test case works perfectly. I haven't tested the director feature explicitly, but I see you have a test for it already.

You should get this version released.

By: Matt Someone
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-28 15:46
I'll have to compile it later, the gem fails with the same error that rice 1.1 did:

cpp' || echo './'`detail/protect.cpp
mv -f .deps/protect.Tpo .deps/protect.Po
ruby -C detail ../rubypp.rb mininode.cpp.rpp mininode.cpp
Error on line 60:
mininode.cpp.rpp:42:in `require': no such file to load -- node_names (LoadError)
from mininode.cpp.rpp:42
make[2]: *** [detail/mininode.cpp] Error 1
make[2]: Leaving directory `/usr/lib/ruby/gems/1.8/gems/jameskilton-rice-1.2.0/rice'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/lib/ruby/gems/1.8/gems/jameskilton-rice-1.2.0/rice'
make: *** [all-recursive] Error 1

Because of this I had to compile rice by hand. I'll try that later.

By: Jason Roelofs
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-28 15:42
Bah, sorry. I've gotten use to people having the github sources.

gem install jameskilton-rice --source http://gems.github.com

By: Matt Someone
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-28 15:31
great news!

The gem command doesn't work, do I have to configure something to get gems from github?

Else, I'll try getting the sources later.

By: Jason Roelofs
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-28 00:42
And for the record, your code runs just fine with the current github code (unofficially 1.2.0).

By: Jason Roelofs
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-28 00:29
Rice is hosted on Github now, SVN code is an old snapshot. Here's the official repo, though see the bottom of this post for other info.

http://github.com/cout/rice

I will give this code a quick run, it could be something that got fixed after the move to git.

Funny you should mention directors, that's a feature I implemented not too long ago, among other things recently. Documentation is currently in the source and tests, see Director.hpp and test_Class.cpp. I've tried to make the API as easy to use as possible (took some hints from SWIG and Boost.Python) and would like feedback on it.

As I haven't heard from Paul in some time, I forked the repository on Github and have been working on some things I've needed. Please grab the code from my repo and give your code a try with it.

http://github.com/jameskilton/rice

gem install jameskilton-rice

By: Matt Someone
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-27 13:14
I'm using 1.1.0 (I've tried latest svn, but the problem is the same, the message only changes to something like "derived class not bound", which ocurrs in the same position on the code), and Ruby 1.8.7p174.

code is:
http://pastie.org/private/ifczj5srsze2tmg7mrtimg

As a side note, do you think there's a way for me to derive a C++ class (which has a virtual method), implement that method, so that when C++ calls that method on an instance of the derived class, the call is received by ruby? (IE: director feature of SWIG).

Thanks

PD: rice is really neat, keep it up =)

By: Jason Roelofs
RE: Deriving C++ wrapped classes from Ruby co [ reply ]  
2009-08-27 11:30
That's weird, what you've got should work perfectly. Could you gist/pastie all the code you're using for this test?

Also, what version of Rice are you using and which Ruby?

By: Matt Someone
Deriving C++ wrapped classes from Ruby code [ reply ]  
2009-08-26 05:16
Hi,
I've created a C++ class like:
class Base {
public:
Base(void);
void utility_method(void);
};

and created the wrapper with:
Rice::Data_Type<Base> rb_cBase = Rice::define_class<Base>("Base");
rb_cBase.define_constructor(Rice::Constructor<Base>());
rb_cBase.define_method("utility_method", &Base::utility_method);

And then did in Ruby:
require 'test'
class Child < Base
def initialize
super
puts '[Child] constructor'
end
end

child = Child.new
child.utility_method

which gives:
[Base] constructor
[Child] constructor
testme.rb:10:in `utility_method': Derived class Child is not registered/bound in Rice (RuntimeError)
from testme.rb:10

Is this a bug or am I doing something wrong? I imagine that when calling a C++ wrapped method, it shouldn't check wether the calling class (Child in this case) is bound, but if there's an ancestor which it is.

Thank you.