adding methods to a C++ class in 1.8.0 - has anything changed?

J

James Adam

Hi

I'm currently writing a tool where the data-structure is coded in C++,
but manipulated in wonderful Ruby. I had also added some 'ruby
goodness' to the C++ classes, such as providing ".each_X" iteration
methods for use within the ruby part of the system.

assume that the class Architecture is defined in a module Nest, all
implemented in C++ but with ruby hooks generated by SWIG.

with ruby 1.6.8, i could do the following:

require 'Nest' # load the C++ extension
=> true
include Nest
=> Object
class Architecture
def newMethod
puts "hi from ruby"
end
end
=> nil

.... and now i could call 'newMethod' along with all the other instance
methods for Architecture defined in the C++ source.

however, with Ruby 1.8.0 this stopped working, giving the error:

NameError: undefined constant Architecture


....and the only way I can get it running is if i do the following:

require 'Nest'
include Nest
class Nest::Architecture
# define the new methods
end

is this expected?

- James Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top