jameskilton / rbplusplus
- Source
- Commits
- Network (0)
- Issues (4)
- Downloads (5)
- Wiki (1)
- Graphs
-
Branch:
master
-
1 comment Created 2 months ago by jameskiltonTrees of virtual classes don't wrap properlybugxIf there's a hierarchy of virtual classes, the type hierarchy in Rice doesn't get setup properly. Need to use the Director classes as supertypes instead of the actual superclasses.
Comments
-
In Ogre.rb, noticed that:
ogre.classes(/SharedPtr/)
returns an Array while
ogre.classes.find(:name => /SharedPtr/)
properly returns a QueryResult.
Comments
jameskilton
Mon Nov 30 20:25:32 -0800 2009
| link
This is an issue with rbgccxml.
-
0 comments Created 2 months ago by jameskiltonCallback methods in Directors probably don't wrap righttodoxI haven't tested this out, but I'm pretty sure trying to wrap a method in a Director that takes a callback will fail. Will look at this if I need it, or someone comments on this Issue needing this feature.
Comments
-
0 comments Created 2 months ago by jameskiltonRb++ expects callback methods to only take the callbacktodoxRb++ properly wraps and handles this type of method:
void withCallback(func_pointer_type callback)
But the following won't wrap properly:
void withCallbackAndArg(int someArg, char* another, func_pointer_type callback);
Will look into this when needed by myself or someone using rb++.
Comments
-
I'm not sure if this is a bug or if I just don't know the right steps to take, but I figured this would be the best place to ask none-the-less. I have a C++ instance method that takes an array of structs as an argument.
struct foo { bool bar; }; class Test { public: Test(); ~Test(); void update(foo*); };I know I'm missing the namespace declaration in the above C++ code, but I have it in my real code and things compile fine. When I jump into an irb shell, and do the following:
require 'test' t = Test.new f = Foo.new t.update([f])I get the following error:
ArgumentError: Unable to convert Array to foo*Any ideas how I can make it possible to do this?
-- Thanks for a great and needed project!
BryanComments
jameskilton
Sun Dec 27 08:45:16 -0800 2009
| link
The short:
t.update(f)is what's going to work.
There's a problem with your example though. Test::update makes a lot of assumptions about the parameter passed in, but at first glance, and what GCC-XML gives me, Test::update takes a pointer to a single foo instance, not an array. Unfortunately, C/C++ decided to make arrays and pointers act the same, which makes this situation very difficult to reconcile.
There's another smaller issue, how does Test::update know how many elements are in the array? Do you expect a NULL at the end?
I'd recommend going with a std::vector, but Rice doesn't have the best support for collections like this yet.
I really don't know the best way of dealing with this situation right now. I would recommend starting with 1) changing that to a std::vector and 2) building a from_ruby method:
template<> std::vector<foo> from_ruby< std::vector<foo> >(Rice::Object obj) { Rice::Array arr(obj); std::vector<foo> vec; // ... do processing return vec; }In rb++, you'll need to put this in a custom code file. See http://github.com/jameskilton/ogrerb/tree/master/wrappers/noise/ for an example on how to do this.
scrapcoder
Sun Dec 27 09:35:51 -0800 2009
| link
Alrighty, thanks for the response and for the suggestions. I'll look into creating the from_ruby method.
-- Thanks again!
Bryan
scrapcoder
Mon Dec 28 10:10:51 -0800 2009
| link
Hi again... so from your example code, I see how I should use from_ruby to do conversions into C++ code. However, I'm not quite understanding where/how to use the specialized from_ruby templates. Do they get used automatically or do I have to specify its use in some of the code generated by rb++? Is there a file naming convention for the custom templates such that they can be used automatically? I looked at your ogrerb code to see how you were actually using the custom templates you pointed me to and I didn't see anything obvious.
-- Thanks!
Bryan
jameskilton
Mon Dec 28 11:01:58 -0800 2009
| link
The key is Extension#sources and the :include_source_dir option. What you see in the noise wrapper is the code/ directory with some source files. If you open up build_noise.rb, you'll see the :include_source_dir directive pointing to this directory.
What happens here is this directive is telling Rb++ to copy all source files (h hpp c cpp) into the working directory for compilation. At the same time, any header files found are then included into all generated source files.
Thus, with this mechanic, you can add your own code to the compiled extension.
As for naming convention, as long as the methods are Rice::to_ruby and Rice::from_ruby, they'll be picked up just fine (due to the type specification).
-
Need to add wiki documentation to include such things as:
- using :include_source_dir
- to_ruby / from_ruby specifications
- answers other questions asked by the community.
Comments





Fixed with a reworking of the Director class in Rice.