From f9bb3105c89639f834fee77ebf19c0bdebd20b23 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Wed, 2 Nov 2022 14:36:36 +0100 Subject: [PATCH] new interface --- hscript/IHScriptCustomBehaviour.hx | 6 ++++++ hscript/Interp.hx | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 hscript/IHScriptCustomBehaviour.hx diff --git a/hscript/IHScriptCustomBehaviour.hx b/hscript/IHScriptCustomBehaviour.hx new file mode 100644 index 0000000..587e71b --- /dev/null +++ b/hscript/IHScriptCustomBehaviour.hx @@ -0,0 +1,6 @@ +package hscript; + +interface IHScriptCustomBehaviour { + public function hset(name:String, val:Dynamic):Dynamic; + public function hget(name:String):Dynamic; +} \ No newline at end of file diff --git a/hscript/Interp.hx b/hscript/Interp.hx index 890c913..6f7a397 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -818,6 +818,9 @@ class Interp { }; if (getRedirects.exists(cl = Type.getClassName(Type.getClass(o))) && (redirect = getRedirects[cl]) != null) { return redirect(o, f); + } else if (o is IHScriptCustomBehaviour) { + var obj = cast(o, IHScriptCustomBehaviour); + return obj.hget(f); } else { var v = null; if ((v = Reflect.getProperty(o, f)) == null) @@ -846,6 +849,10 @@ class Interp { }; if (setRedirects.exists(cl = Type.getClassName(Type.getClass(o))) && (redirect = setRedirects[cl]) != null) return redirect(o, f, v); + else if (o is IHScriptCustomBehaviour) { + var obj = cast(o, IHScriptCustomBehaviour); + return obj.hset(f, v); + } Reflect.setProperty(o, f, v); return v;