summaryrefslogtreecommitdiff
path: root/source/tools
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-04-26 20:11:49 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-04-27 17:01:06 +0200
commit9b4acc78d2a56a5f79d69f50e72197930509505e (patch)
treeb30e03bd1e80d859b578324425e2486f122c5ac8 /source/tools
parented763d50c7363af5f09d24d0e04b95ca59ff7960 (diff)
downloadmupdf-9b4acc78d2a56a5f79d69f50e72197930509505e.tar.xz
Add fz_close_device function.
Garbage collected languages need a way to signal that they are done with a device other than freeing it. Call it implicitly on fz_drop_device; so take care not to call it again in case it has been explicitly called already.
Diffstat (limited to 'source/tools')
-rw-r--r--source/tools/murun.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/tools/murun.c b/source/tools/murun.c
index 541930eb..b5726770 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -1134,6 +1134,16 @@ static fz_device *new_js_device(fz_context *ctx, js_State *J)
/* device calling into c from js */
+static void ffi_Device_close(js_State *J)
+{
+ fz_context *ctx = js_getcontext(J);
+ fz_device *dev = js_touserdata(J, 0, "fz_device");
+ fz_try(ctx)
+ fz_close_device(ctx, dev);
+ fz_catch(ctx)
+ rethrow(J);
+}
+
static void ffi_Device_fillPath(js_State *J)
{
fz_context *ctx = js_getcontext(J);
@@ -2953,6 +2963,8 @@ int murun_main(int argc, char **argv)
js_newobject(J);
{
+ jsB_propfun(J, "Device.close", ffi_Device_close, 0);
+
jsB_propfun(J, "Device.fillPath", ffi_Device_fillPath, 6);
jsB_propfun(J, "Device.strokePath", ffi_Device_strokePath, 6);
jsB_propfun(J, "Device.clipPath", ffi_Device_clipPath, 3);