Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Add custom c module loading code for luvit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neopallium committed Dec 3, 2011
1 parent 9536745 commit 26200cf
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions src/pre_generated-zmq.nobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,21 +936,37 @@ 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 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"
" local path_match = \"([^\" .. path_sep .. \"]*)\" .. path_sep\n"
" -- convert dotted name to directory path.\n"
" name = name:gsub('%.', dir_sep)\n"
" -- try each path in search path.\n"
" for path in p_cpath:gmatch(path_match) do\n"
" local fname = path:gsub(path_mark, name)\n"
" local C, err = ffi_safe_load(fname, global)\n"
" -- return opened library\n"
" if C then return C end\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"
" local path_match = \"([^\" .. path_sep .. \"]*)\" .. path_sep\n"
" -- convert dotted name to directory path.\n"
" name = name:gsub('%.', dir_sep)\n"
" -- try each path in search path.\n"
" for path in p_cpath:gmatch(path_match) do\n"
" local fname = path:gsub(path_mark, name)\n"
" local C, err = ffi_safe_load(fname, global)\n"
" -- return opened library\n"
" if C then return C end\n"
" end\n"
" error(\"Failed to find: \" .. name)\n"
" end\n"
" error(\"Failed to find: \" .. name)\n"
"end\n"
"\n"
"local _M, _priv, udata_new = ...\n"
Expand Down

0 comments on commit 26200cf

Please sign in to comment.