an admittedly lazy programmer question...

  • From: William Adams <william_a_adams@xxxxxxx>
  • To: <luajit@xxxxxxxxxxxxx>
  • Date: Mon, 28 May 2012 20:53:43 +0000

I am doing some interop, and the C function looks like this:

 

void somefunc(FILE *f)

 

Meaning, it expects to the a FILE structure.  Typically because it's going to 
do the reading from the file on its own.  I really don't like these kinds of 
interfaces, but there you have it.

 

Question:

 

Would LuaJIT ffi do anything for me to translate from Luas io to this FILE 
structure?  Can I simply do:

 

fh = io.open(file)

somefunc(fh)

 

And have it work?  Assuming I've defined FILE in some FFI place.

 

Alternatively, I could redefine the function signature:

 

void somefunc(void *f)

 

But still, the question remains, is the io.open returning something I could 
feed to this function in some way?

 

-- William



===============================

- Shaping clay is easier than digging it out of the ground.


http://williamaadams.wordpress.com
http://www.thingiverse.com/WilliamAAdams
https://github.com/Wiladams                                       

Other related posts: