 |
Forums |
Admin Discussion Forums: help Start New Thread
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 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: 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.
|
|
 |