Accessing C structures in Ruby

J

Joe Van Dyk

(I've already looked at Swig, btw. I'd like to do this one by hand.)

I have the following:

typedef struct {
double x;
double y;
double z;
} VelocityRecord;

typedef struct {
double x;
double y;
double z;
} PositionRecord;

typedef struct {
int id;
int type;
PositionRecord position;
VelocityRecord velocity;
} Player;

Player Players[10];


The number of Players is fixed ahead of time. I want to be able to
access that data from Ruby. Ideally, something like:

module Simulation
attr_accessor :players # Other stuff will be here
class Player
class VelocityRecord
attr_accessor :x, :y :z
end
class PositionRecord
attr_accessor :x, :y, :z
end
end
end
 

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

Forum statistics

Threads
474,200
Messages
2,571,046
Members
47,646
Latest member
xayaci5906

Latest Threads

Top