tags:

views:

83

answers:

1

Hi,

Is there any body can confirm the description here is true? My experience is that I can not use Example::Vector.new at all.

C/C++ structs are wrapped as Ruby classes, with accessor methods (i.e. "getters" and "setters") for all of the struct members. For example, this struct declaration:

struct Vector {
 double x, y;
};

gets wrapped as a Vector class, with Ruby instance methods x, x=, y and y=. These methods can be used to access structure data from Ruby as follows:

$ irb
irb(main):001:0> require 'Example'
true
irb(main):002:0> f = Example::Vector.new
#<Example::Vector:0x4020b268>
irb(main):003:0> f.x = 10
nil
irb(main):004:0> f.x
10.0
A: 

Solved. I should also need add the type definition in the example.i file ,just include the .h is not enough.

pierr