I have been using Swig for the first time since Lyle mentioned Phil
Tomson’s article in C/C++ Users Journal (http://www.cuj.com)
My goal is to use my company’s C/C++ API with Ruby.
I think it would add a great deal of flexibility to my current
programming.
I let Swig automatically create the wrapper for me (using the “truly
lazy way” interface…just pointing it to the header file.)
Amazingly, everything is working.
I’m able to load the shared library into Ruby.
I can see all the methods, constants, etc…
However, some of the methods I want to use require pointers.
Sorry for my ignorance, but I have only programmed in Java and Ruby…
so I don’t have any true exposure to C/C++ or the concept of pointers.
In the header file (API) I have are some typedef statments:
//
/* /
/ Global Data Types /
/ */
//
typedef char CoolBoolean;
typedef char* CoolString;
typedef int CoolClientHandle;
typedef int CoolTableHandle;
Now I want use the following connect method.
//
/ /
/ Opening and Closing Connection /
/ /
//
extern DllDecl CoolReturnCode CoolConnect
PROTO((char *srvHostName,
int serverNumber,
CoolClientHandle *handle));
How do I create a pointer of type “CoolClientHandle” in Ruby?
Am I thinking about this incorrectly?
I have read over the pointer documentation, however I have been unable
to make it work.
Any advice would be appreciated.
Thanks.