duktape icon indicating copy to clipboard operation
duktape copied to clipboard

duk_create_heap_default not found

Open urizennnn opened this issue 4 months ago • 1 comments

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)

urizennnn avatar Mar 30 '24 23:03 urizennnn

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

svaarala avatar Mar 31 '24 20:03 svaarala