From e9b1a890529486fb8216e9940b1bae196f4951ff Mon Sep 17 00:00:00 2001 From: Philosopher Date: Sun, 2 Feb 2014 12:31:48 -0600 Subject: [PATCH] Clean up some global wrappers --- Nasal/globals.nas | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Nasal/globals.nas b/Nasal/globals.nas index d7bba2886..4be967a86 100644 --- a/Nasal/globals.nas +++ b/Nasal/globals.nas @@ -48,6 +48,8 @@ var isa = func(obj, class) { # var fgcommand = func(cmd, node=nil) { if(isa(node, props.Node)) node = node._g; + elsif(typeof(node) == 'hash') + node = props.Node.new(node)._g; _fgcommand(cmd, node); } @@ -85,7 +87,8 @@ var abs = func(v) { return v < 0 ? -v : v } # var interpolate = func(node, val...) { if(isa(node, props.Node)) node = node._g; - elsif(typeof(node) != "scalar") return; + elsif(typeof(node) != "scalar" and typeof(node) != "ghost") + die("bad argument to interpolate()"); _interpolate(node, val); } @@ -101,6 +104,8 @@ var interpolate = func(node, val...) { # var setlistener = func(node, fn, init = 0, runtime = 1) { if(isa(node, props.Node)) node = node._g; + elsif(typeof(node) != "scalar" and typeof(node) != "ghost") + die("bad argument to setlistener()"); var id = _setlistener(node, func(chg, lst, mode, is_child) { fn(props.wrapNode(chg), props.wrapNode(lst), mode, is_child); }, init, runtime);