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); }
/// <summary> /// JS_CallFunctionName without args /// </summary> /// <param name="cx"></param> /// <param name="jsObject"></param> /// <param name="name"></param> /// <returns></returns> public static JsVal JS_CallFunctionName(IntPtr cx, IntPtr jsObject, string name) { bool result; JsVal value; int parameterCount = 0; var mutableHandle = new MutableHandleValue(); if (!JS_CallFunctionName(cx, ref jsObject, name, ref parameterCount, ref mutableHandle)) { HandleInvokeFailure(cx, jsObject, name); } value = JsVal.FromPtr(mutableHandle.Handle); 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."); }
public static bool JS_ExecuteScript(IntPtr cx, string script, out JsVal jsval) { jsval = default(JsVal); var scriptHandle = new MutableHandle(); if (!JS_CompileUCScript(cx, script, script.Length, GetCompileOptions(cx), ref scriptHandle)) { throw new GeckoException("Failed to compile script."); } var val = new MutableHandleValue(); var handle = scriptHandle.Handle; if (!JS_ExecuteScript(cx, ref handle, ref val)) { return(false); } jsval = JsVal.FromPtr(val.Handle); return(true); }
internal static extern bool JS_ExecuteScript(IntPtr cx, ref IntPtr handleScript, ref MutableHandleValue jsValue);
internal static extern bool JS_CallFunctionValue(IntPtr cx, IntPtr jsObject, ref JsVal fval, IntPtr passZero, ref MutableHandleValue jsValue);
internal static extern bool JS_CallFunctionName(IntPtr cx, ref IntPtr jsObject, string name, ref int args, ref MutableHandleValue jsValue);