Add custom c module loading code for luvit.

zmq3.0
Robert G. Jakabosky 15 years ago
parent 95367457f7
commit 26200cf9c0

@ -936,7 +936,22 @@ static const char zmq_ffi_lua_code[] = "local ffi=require\"ffi\"\n"
"local p_config = package.config\n"
"local p_cpath = package.cpath\n"
"\n"
"local function ffi_load_cmodule(name, global)\n"
"local ffi_load_cmodule\n"
"\n"
"-- try to detect luvit.\n"
"if p_config == nil and p_cpath == nil then\n"
" ffi_load_cmodule = function(name, global)\n"
" for path,module in pairs(package.loaded) do\n"
" if type(module) == 'string' and path:match(\"zmq\") then\n"
" local C, err = ffi_safe_load(path .. '.luvit', global)\n"
" -- return opened library\n"
" if C then return C end\n"
" end\n"
" end\n"
" error(\"Failed to find: \" .. name)\n"
" end\n"
"else\n"
" ffi_load_cmodule = function(name, global)\n"
" local dir_sep = p_config:sub(1,1)\n"
" local path_sep = p_config:sub(3,3)\n"
" local path_mark = p_config:sub(5,5)\n"
@ -951,6 +966,7 @@ static const char zmq_ffi_lua_code[] = "local ffi=require\"ffi\"\n"
" if C then return C end\n"
" end\n"
" error(\"Failed to find: \" .. name)\n"
" end\n"
"end\n"
"\n"
"local _M, _priv, udata_new = ...\n"

Loading…
Cancel
Save