?ukasz ?api?ski wrote:> I am experimenting with integration of C++ and Ruby. What exactly I would
> like to do is to provide an option to use Ruby and wxRuby for creation of
> GUI and doing algorithms in C++ and then displaying results in the openGL
> Canvas.
>
I wasn''t totally clear what you wanted - do you want to end up with a
ruby script that calls some C++ extensions, or a compiled C programme
that calls wxRuby to do a GUI. I think the latter will be
harder...> But I would also like to transfer the data from the form built using Ruby
> into some classes in C++. Like parameters: numbers and string. But I am
> wondering if it is possible to create controls in Ruby and then just
> assign then into C++ fields (the controls not values).
Not quite sure how this would work. Unless the interface of your C++
library is very complex, it might be easier to do it the other way
around, ie create a simple ruby wrapper around your C++ library (using
SWIG or RICE) then use Ruby to transfer the values into the C library.
Is there a particular reason this won''t work for
you?> I thought these are in fact the same controls, they were written in C++,
> but I guess txt is not of type [wxTextField *], but rather
> #<SWIG::TYPE_p_wxTextCtrl:0xb7c49944>
> so how to get the pointer to wxTextField so I can manipulate the control
> from cpp class like this
>
> someText->GetValue()
SWIG provides a lot of useful functions for doing this, if you want. See
http://www.swig.org/Doc1.3/Ruby.html#Ruby_nn50
in particular, SWIG_ConvertPtr which converts a VALUE to the underlying
C++ object.
It''s generally used little directly, as it''s easier to use
%extend to
write methods in which the placeholder variable $self refers to the C++
object.
alex