Skip to content

Instantly share code, notes, and snippets.

@hugeblank
Last active October 27, 2018 00:04
Show Gist options
  • Save hugeblank/f0f93d3954d347ef66d2f6fbe5d60c1f to your computer and use it in GitHub Desktop.
Save hugeblank/f0f93d3954d347ef66d2f6fbe5d60c1f to your computer and use it in GitHub Desktop.
Convert the CC libraries, or any of your own libraries into importable lisp variants (probably for urn)
local args = {...}
local env
if #args > 0 then
for i = 1, #args do
if _ENV[lib] then
env = _ENV[lib]
else
print(lib.." is not a library in _ENV")
end
end
else
env = _G
end
for lib in pairs(env) do
if type(env[lib]) == "table" and not (lib == "_G" or lib == "_ENV") then
local file = fs.open("lib/cc/"..lib..".lisp", "w") -- Open up a file in the cc directory
print("writing "..lib)
for method in pairs(env[lib]) do -- For each method
file.writeLine("(define-native "..method.." :bind-to \""..lib.."."..method.."\")") -- Write it lispified
end
file.close() -- Close and move on
elseif #args > 0 then
print(lib.." is not a library in _ENV")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment