Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LuaJIT FFI Bindings for CoolProp High-level API #438

Closed
bungle opened this issue Jan 28, 2015 · 7 comments
Closed

LuaJIT FFI Bindings for CoolProp High-level API #438

bungle opened this issue Jan 28, 2015 · 7 comments

Comments

@bungle
Copy link
Contributor

bungle commented Jan 28, 2015

I have implemented LuaJIT bindings for CoolProp High-level API here:
https://github.com/bungle/lua-resty-coolprop

You can also find the library from LuaRocks:
https://rocks.moonscript.org/modules/bungle/lua-resty-coolprop

@jowr
Copy link
Member

jowr commented Jan 28, 2015

Great, thanks for contributing! Would you like to keep things separated or would you be interested in integrating your code as a new wrapper? Lua would be in good company there, see http://coolprop.sourceforge.net/coolprop/wrappers/index.html

Do people that use Lua know how to use your code or would some documentation be helpful? Is there anything we can do to support your efforts?

@bungle
Copy link
Contributor Author

bungle commented Jan 28, 2015

Hi,

I think it would be nice if this could be integrated in CoolProp wrappers. Do you want me to make a pull request here: https://github.com/CoolProp/CoolProp/tree/master/wrappers

I think that correct name for this wrapper is LuaJIT (as for PUC Lua (the normal one) you need a different kind of wrapper that uses the Lua C API, and not LuaJIT's FFI. I may look at implementing Lua C API as well, but right now I got this LuaJIT FFI wrapper working. I think that the code is quite alright, and the API is easy to use from client Lua code. I will do some more testing, and check if there is something missing. I think that if we could integrate this code in your CoolProp repository I will drop that resty-prefix, so that you could use it something like this:

local coolprop = require "coolprop"

I think that we could also integrate the normal Lua C-api in this Lua wrapper so that it will automatically select either LuaJIT FFI-bindings or Lua C API bindings depending on the runtime where it is executed. But let's start with LuaJIT, maybe somebody will join the efforts and write Lua C-API bindings as well (that is C-coded wrapper).

@jowr
Copy link
Member

jowr commented Jan 28, 2015

That sounds like a plan. Is there anything that needs compilation? Do you use a static or a shared library? Does LuaJIT run on all major platforms? It would be very helpful if you also added a description here: https://github.com/CoolProp/CoolProp/tree/master/Web/coolprop/wrappers . Have a look at the other pages for how to use internal variables for links to the download repositories if needed.

@bungle
Copy link
Contributor Author

bungle commented Jan 28, 2015

This binding is using shared-library (I can probably include a check if the CoolProp lib has been linked statically so that it works on both cases), and doesn't need any compilation. LuaJIT runs on many platforms:
http://luajit.org/luajit.html (it's kinda like Lua 5.1 + some additions from 5.2 and then this JIT compiling runtime with jittable FFI library and then some). If we also do Lua C API implementation, then that need C-compiler. The current code is tested to work on OS/X and Linux, but Windows may need a slight modifications to ffi.cdef's. And yes, I will include .rst as well. Let's have something to start with, and then build on that when we get more feedback.

@jowr
Copy link
Member

jowr commented Jan 28, 2015

OK, great. To me it sound like LuaJIT is somewhat similar to Julia, maybe it helps to look at the docs for the Julia wrapper. I do not have Windows, so I cannot be your tester, but I am sure that we find someone to run your code. Maybe @ibell is interested...
The C code has to be integrated with the CMakeLists.txt file in the base directory, but we can help you with that as soon as the JIT stuff is working properly.

@ibell
Copy link
Contributor

ibell commented Jan 29, 2015

I quickly took a look at your wrapper, and I only have one small comment.
Please keep the naming of the wrapped functions as close to the original
names as possible. Identical, ideally. That way we can help to avoid
confusion and keep the interfaces all the same.

Compiling all this stuff together shouldn't be too bad, assuming Lua
handles STL without too much of a problem. If it can wrap all these
functions (
https://github.com/CoolProp/CoolProp/blob/master/include/CoolProp.h), we
should be in business.

@jowr is right about checking the Julia wrapper, I think it is structured
in a similar way.

On Wed, Jan 28, 2015 at 2:44 PM, Jorrit Wronski notifications@github.com
wrote:

OK, great. To me it sound like LuaJIT is somewhat similar to Julia, maybe
it helps to look at the docs for the Julia wrapper. I do not have Windows,
so I cannot be your tester, but I am sure that we find someone to run your
code. Maybe @ibell https://github.com/ibell is interested...
The C code has to be integrated with the CMakeLists.txt file in the base
directory, but we can help you with that as soon as the JIT stuff is
working properly.


Reply to this email directly or view it on GitHub
#438 (comment).

@bungle
Copy link
Contributor Author

bungle commented Jan 29, 2015

Let's move the discussion here:
#440

@bungle bungle closed this as completed Jan 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants