Hello all. I have a question about automatic function wrappers with
respect to bulk importing a C library.
I am working with a C library (call it 'LibX') that I want to use in
Perl. The C-Cookbook describes this use case, but only gives an example
for importing one single function from the library.
What I want to do is programatically bulk import not just every function
but every constant and enumerated type using Inline::C. This is in the
interests of Laziness; there are a lot of functions, and I'm too lazy to
type them all in. Also, since this library is a 3rd party product, the
C code compiles out to multiple architectures, and thus the function
prototypes change according to the architecture. (I'm only interested
in one architecture, but if I ever switch to a different one, it would
be a real hassle to go through and hand change out all of the
prototypes.)
My strategy to do this is as follows: first create a simple C program
-----------
#include <LibX.h>
void main() {}
-----------
and then compile this program out with a -E option ( stop after the
preprocessing stage; send output to stdout ). This gives me access to
all of the function prototypes, constants, and enumerated types. But
this is where I get stuck: in order to drag the function prototypes
into a "use Inline => C qq( #list of functions )" block of Perl code, I
have to 1) parse the output of the gcc -E command, 2) write code that
writes Perl code declaring the new package LibX and using Inline.
Step 2) isn't so bad, but parsing the C code/-E output in step 1) seems
a little scary.
So, some general questions..
1) Has anyone tried to do this before? Google search and search
on [EMAIL PROTECTED] archives gives me nothing.
2) Is the strategy described above sound? Any other ideas on how
to do this?
3) Is it possible to import C constants and enumerated types using
Inline::C? Cookbook doesn't talk about this use case.
Thanks in advance,
Lyle