Using LUA C API from corona

Is there an example of using a pure c function from corona. I can find straight lua and luajit examples but can’t get either to work in corona. Trying to learn how to use c library with corona.

Thanks in Advance…

Roger

I’m unclear on what you’re trying to do.

Are you trying to write and compile C code that hooks into the Corona APIs or trying to use C code in your Lua scripts.

The latter is not possible.

Hi Ed,

I am trying to call a function from a c library.

pass a var to c function and return the result from c.

I understand I have to push on to c stack and retrieve from stack (I think)

I am just starting to try to understand how to do this I have found ffi is not possible in corona 

but i have read we can use the LUA C API with corona.

just need examples or documentation to grasp it…

Thanks

Roger

You can see a plugin implemented in C here:

https://github.com/coronalabs/plugins-source-bit/tree/master/src

thanks how do you call it from corona file?

You can do this with “native” programming. See:

https://docs.coronalabs.com/native/index.html

https://docs.coronalabs.com/tutorial/native/iosIntro/index.html

Rob

Thanks Rob… 

I will study these…

Did you ever give the binary I posted here a try? Since that is a port of the FFI with some changes to run in Corona, I’m wondering if you played with it and ran into problems.

I will give it another shot.

thanks for the post.

Roger

I’m unclear on what you’re trying to do.

Are you trying to write and compile C code that hooks into the Corona APIs or trying to use C code in your Lua scripts.

The latter is not possible.

Hi Ed,

I am trying to call a function from a c library.

pass a var to c function and return the result from c.

I understand I have to push on to c stack and retrieve from stack (I think)

I am just starting to try to understand how to do this I have found ffi is not possible in corona 

but i have read we can use the LUA C API with corona.

just need examples or documentation to grasp it…

Thanks

Roger

You can see a plugin implemented in C here:

https://github.com/coronalabs/plugins-source-bit/tree/master/src

thanks how do you call it from corona file?

You can do this with “native” programming. See:

https://docs.coronalabs.com/native/index.html

https://docs.coronalabs.com/tutorial/native/iosIntro/index.html

Rob

Thanks Rob… 

I will study these…

Did you ever give the binary I posted here a try? Since that is a port of the FFI with some changes to run in Corona, I’m wondering if you played with it and ran into problems.

I will give it another shot.

thanks for the post.

Roger