Professional Web Applications Themes

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

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 .... ...

  1. #1

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

    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
    James Adam Guest

  2. #2

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

    >>>>> "J" == James Adam <jameslazyatom.com> writes:

    J> however, with Ruby 1.8.0 this stopped working, giving the error:
    J> NameError: undefined constant Architecture

    see [ruby-talk:79302], [ruby-talk:79312]

    [url]http://www.ruby-talk.org/79302[/url]
    [url]http://www.ruby-talk.org/79312[/url]


    Guy Decoux

    ts Guest

Similar Threads

  1. class#methods how ?
    By Simon Strandgaard in forum Ruby
    Replies: 3
    Last Post: November 10th, 12:16 PM
  2. Instance- and class-variables (was mixing in class methods)
    By dblack@superlink.net in forum Ruby
    Replies: 2
    Last Post: October 3rd, 03:52 AM
  3. Instance- and class-variables (was mixing in class methods)
    By dblack@superlink.net in forum Ruby
    Replies: 0
    Last Post: October 2nd, 04:19 PM
  4. Instance- and class-variables (was mixing in class methods)
    By dblack@superlink.net in forum Ruby
    Replies: 0
    Last Post: October 2nd, 12:46 PM
  5. adding methods to an existing class
    By dblack@superlink.net in forum Ruby
    Replies: 1
    Last Post: August 6th, 06:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139