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

duk_create_heap_default not found #2565

Open
urizennnn opened this issue Mar 30, 2024 · 1 comment
Open

duk_create_heap_default not found #2565

urizennnn opened this issue Mar 30, 2024 · 1 comment

Comments

@urizennnn
Copy link

This is the error is get when trying to execute a lua file

:source (no file)` command. Specifically, it mentions "cannot resolve symbol 'duk_create_heap_default': The specified procedure could not be found."

The lua file :

--utils.lua
local ffi = require("ffi")
ffi.cdef[[


typedef struct duk_hthread duk_context;
duk_context *duk_create_heap_default(void);
void duk_destroy_heap(duk_context *ctx);
void duk_eval_string(duk_context *ctx, const char *src);
const char *duk_safe_to_string(duk_context *ctx, int index);
]]

local duktape = ffi.load("C:/duktape-2.7.0/libduktaped.so.207.20700")


local function eval_js(code)
	local ctx = duktape.duk_create_heap_default()
	duktape.duk_eval_string(ctx, code)
	local result = ffi.string(duktape.duk_safe_to_string(ctx, -1))
	duktape.duk_destroy_heap(ctx)
	return result
end
return {
	eval_js = eval_js
}

-- setup.lua
vim.opt.runtimepath:append("C:/Users/Victor/Desktop/vim-mapper")
local setup =require("plugin.utils")


local js = ("./ai/test.js")
local result = setup.eval_js(js)
print(result)
@svaarala
Copy link
Owner

duk_create_heap_default() is not an exposed function, it's a macro in duktape.h.

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

2 participants