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;