#include "livecode/api/api.h" namespace Inkscape { namespace Livecode { static Context *_context = nullptr; Context &ctx() { if (!_context) { janet_panic("Livecode Context uninitialized!!"); } return *_context; } extern "C" Janet cfun_input_point(int32_t argc, Janet *argv) { janet_fixarity(argc, 2); ctx().input_point(janet_getcstring(argv, 0), &janet_unwrap_point(argv[1])); return janet_wrap_nil(); } extern "C" Janet cfun_input_line(int32_t argc, Janet *argv) { janet_fixarity(argc, 3); ctx().input_line(janet_getcstring(argv, 0), &janet_unwrap_point(argv[1]), &janet_unwrap_point(argv[2])); return janet_wrap_nil(); } extern "C" Janet cfun_input_arrow(int32_t argc, Janet *argv) { janet_fixarity(argc, 3); ctx().input_arrow(janet_getcstring(argv, 0), &janet_unwrap_point(argv[1]), &janet_unwrap_point(argv[2])); return janet_wrap_nil(); } const JanetReg it_cfuns[] = { { "input/point", cfun_input_point, "(input/point id p)\n\nMake p modifiable via a handle.\n" "This function mutates p." }, { "input/line", cfun_input_line, "(input/line id p1 p2)\n\nMake a modifiable line between p1 and p2\n" "This function mutates p1 and p2." }, { "input/arrow", cfun_input_arrow, "(input/arrow id from to)\n\nMake a modifiable arrow between from and to\n" "This function mutates from and to." }, {NULL, NULL, NULL} }; void janet_lib_context(JanetTable *env, Context &context) { _context = &context; janet_cfuns(env, NULL, it_cfuns); } } }