bool GetPropertyFromUnmanaged(string scriptAlias, IntPtr[] uargs, int arg_count, ref Value value) { object[] args; if (ManagedObject is IDictionary && scriptAlias != "item") { args = new object[] { scriptAlias }; scriptAlias = "item"; } else { args = new object[arg_count]; for (int i = 0; i < arg_count; i++) { if (uargs[i] == IntPtr.Zero) { args[i] = null; } else { Value val = (Value)Marshal.PtrToStructure(uargs[i], typeof(Value)); args[i] = ScriptObjectHelper.FromValue(val); } } } object v = GetProperty(scriptAlias, args); ScriptObjectHelper.ToValue(ref value, v); return(true); }
internal object InvokeSelfInternal(params object [] args) { CheckHandle(); int length = args == null ? 0 : args.Length; object result = null; Mono.Value res; Mono.Value [] vargs = new Mono.Value [length]; for (int i = 0; i < length; i++) { ScriptObjectHelper.ToValue(ref vargs [i], args [i]); } try { if (!NativeMethods.html_object_invoke_self(PluginHost.Handle, Handle, vargs, (uint)length, out res)) { throw new InvalidOperationException(); } if (res.k != Mono.Kind.INVALID) { result = ScriptObjectHelper.FromValue(res); } } finally { res.Dispose(); foreach (var v in vargs) { v.Dispose(); } } return(result); }
bool SetPropertyFromUnmanaged(string scriptAlias, IntPtr[] uargs, int arg_count, ref Value value) { if (ManagedObject is IDictionary) { IDictionary dic = ManagedObject as IDictionary; dic[scriptAlias] = ScriptObjectHelper.FromValue(value); return(true); } else if (properties != null && properties.ContainsKey(scriptAlias)) { object[] args = new object[arg_count + 1]; for (int i = 0; i < arg_count; i++) { if (uargs[i] == IntPtr.Zero) { args[i] = null; } else { Value val = (Value)Marshal.PtrToStructure(uargs[i], typeof(Value)); args[i] = ScriptObjectHelper.FromValue(val); } } args[arg_count] = ScriptObjectHelper.FromValue(value); SetProperty(scriptAlias, args); return(true); } else if (events != null && events.ContainsKey(scriptAlias)) { if (arg_count != 0) { throw new InvalidOperationException("arg count != 0"); } EventInfo einfo = events[scriptAlias]; if (value.k != Kind.NPOBJ) { throw new InvalidOperationException("html bridge only allows function objects as event delegates"); } ScriptObject event_object = ScriptObjectHelper.FromValue(value) as ScriptObject; if (event_object == null) { RemoveEventHandler(scriptAlias, null); } else { AddEventHandler(scriptAlias, event_object, einfo); } return(true); } else { return(false); } }
internal object InvokeInternal(string name, params object [] args) { CheckName(name); CheckHandle(); int length = args == null ? 0 : args.Length; object result = null; Mono.Value res; Mono.Value [] vargs = new Mono.Value [length]; for (int i = 0; i < length; i++) { ScriptObjectHelper.ToValue(ref vargs [i], args [i]); } if (!NativeMethods.html_object_invoke(PluginHost.Handle, Handle, name, vargs, (uint)length, out res)) { throw new InvalidOperationException(); } using (res) if (res.k != Mono.Kind.INVALID) { result = ScriptObjectHelper.FromValue(res); } return(result); }
public override object Invoke(string name, params object [] args) { // this should likely call an Invoke overload passing ManagedObject in, instead of "this", // but we already do the book keeping in the base class, so do we need this method at all? Value v = new Value(); base.Invoke(name, args, ref v); return(ScriptObjectHelper.FromValue(v)); }
internal static object GetPropertyInternal(IntPtr h, string name) { object result = null; CheckName(name); Mono.Value res; NativeMethods.html_object_get_property(PluginHost.Handle, h, name, out res); using (res) if (res.k != Mono.Kind.INVALID) { result = ScriptObjectHelper.FromValue(res); } return(result); }
bool InvokeFromUnmanaged(string name, IntPtr[] uargs, int arg_count, ref Value return_value) { object[] args = new object[arg_count]; for (int i = 0; i < arg_count; i++) { if (uargs[i] == IntPtr.Zero) { args[i] = null; } else { Value v = (Value)Marshal.PtrToStructure(uargs[i], typeof(Value)); args[i] = ScriptObjectHelper.FromValue(v); } } Invoke(name, args, ref return_value); return(true); }
public object Eval(string code) { if (code == null) { throw new ArgumentNullException("code"); } if (code.Length == 0) { throw new ArgumentException("code"); } IntPtr result; result = Mono.NativeMethods.plugin_instance_evaluate(PluginHost.Handle, code); if (result != IntPtr.Zero) { Value v = (Value)Marshal.PtrToStructure(result, typeof(Value)); return(ScriptObjectHelper.FromValue(v)); } return(null); }