public static JsVal JS_CallFunctionName(IntPtr cx, IntPtr jsObject, string name, JsVal[] args) { if ((args == null) || (args.Length == 0)) { return(JS_CallFunctionName(cx, jsObject, name)); } bool result; JsVal value = default(JsVal); using (var argsArray = new HandleValueArray(args.Length, args)) { MutableHandleValue mutableHandle = new MutableHandleValue(); result = JS_CallFunctionName(cx, ref jsObject, name, argsArray.Ptr, ref mutableHandle); if (result) { value = JsVal.FromPtr(mutableHandle.Handle); } } if (!result) { HandleInvokeFailure(cx, jsObject, name); } return(value); }
public static JsVal JS_CallFunctionValue(IntPtr cx, IntPtr jsObject, JsVal func) { var mutableHandle = new MutableHandleValue(); bool success; using (var args = new HandleValueArray(0, new JsVal[0])) success = JS_CallFunctionValue(cx, jsObject, ref func, args.Ptr, ref mutableHandle); if (success) { return(JsVal.FromPtr(mutableHandle.Handle)); } HandleInvokeFailure(cx, jsObject, func.ToString()); throw new Exception("HandleInvokeFailure always throws execption, so this line is never reached."); }