예제 #1
0
 public void SetProperty(string propertyName, object value)
 {
     using (var context = new AutoJSContext(_globalWindow))
     {
         var jsObject = context.ConvertCOMObjectToJSObject(_thisObject);
         if (!SpiderMonkey.JS_SetProperty(context.ContextPointer, jsObject, propertyName,
                                          ConvertTypes(new[] { value }, context).First()))
         {
             throw new GeckoException(String.Format("Property '{0}' of value '{1}' could not be set on object",
                                                    propertyName, value));
         }
     }
 }
예제 #2
0
 public void SetProperty(string propertyName, object value)
 {
     using (var context = new AutoJSContext(_globalWindowProxy))
         using (var jsObject = context.ConvertCOMObjectToJSObject(_thisObject, true))
         {
             DisposablCollection disposablCollection;
             var types = ConvertTypes(new[] { value }, context, out disposablCollection).First();
             var jso   = jsObject.JSObject;
             try
             {
                 if (!SpiderMonkey.JS_SetProperty(context.ContextPointer, ref jso, propertyName,
                                                  ref types))
                 {
                     throw new GeckoException(
                               String.Format("Property '{0}' of value '{1}' could not be set on object",
                                             propertyName, value));
                 }
             }
             finally
             {
                 disposablCollection.Dispose();
             }
         }
 }
예제 #3
0
        /// <summary>
        /// Please keep these in alphabetical order.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <KeyValuePair <string, Action <IntPtr> > > EntryPoints()
        {
            yield return(new KeyValuePair <string, Action <IntPtr> >("CurrentGlobalOrNull", (c) => SpiderMonkey.CurrentGlobalOrNull(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("GetGlobalForObjectCrossCompartment", (c) => SpiderMonkey.GetGlobalForObjectCrossCompartment(IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("IsObjectInContextCompartment", (c) => SpiderMonkey.IsObjectInContextCompartment(IntPtr.Zero, c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_BeginRequest", (c) => SpiderMonkey.JS_BeginRequest(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_CallFunctionName", (c) => SpiderMonkey.JS_CallFunctionName(c, IntPtr.Zero, "", new JsVal[0])));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_CallFunctionValue", (c) => SpiderMonkey.JS_CallFunctionValue(c, IntPtr.Zero, new JsVal())));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EncodeString", (c) => SpiderMonkey.JS_EncodeString(IntPtr.Zero, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EncodeStringToUTF8", (c) => SpiderMonkey.JS_EncodeStringToUTF8(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EndRequest", (c) => SpiderMonkey.JS_EndRequest(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EnterCompartment", (c) => SpiderMonkey.JS_EnterCompartment(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_ExecuteScript", (c) => { JsVal val; SpiderMonkey.JS_ExecuteScript(c, "", out val); }));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_Free", (c) => SpiderMonkey.JS_Free(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetClass", (c) => SpiderMonkey.JS_GetClass(IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetClassObject", (c) => SpiderMonkey.JS_GetClassObject(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetCompartmentPrincipals", (c) => SpiderMonkey.JS_GetCompartmentPrincipals(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_ContextIterator", (c) => { var pt = IntPtr.Zero; SpiderMonkey.JS_ContextIterator(IntPtr.Zero, ref pt); }));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetContextPrivate", (c) => SpiderMonkey.JS_GetContextPrivate(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetEmptyStringValue", (c) => SpiderMonkey.JS_GetEmptyStringValue(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetGlobalForObject", (c) => SpiderMonkey.JS_GetGlobalForObject(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetProperty", (c) => SpiderMonkey.JS_GetProperty(c, IntPtr.Zero, "")));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetStringLength", (c) => SpiderMonkey.JS_GetStringLength(IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetStringEncodingLength", (c) => SpiderMonkey.JS_GetStringEncodingLength(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_HasProperty", (c) => SpiderMonkey.JS_HasProperty(c, IntPtr.Zero, "")));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetNegativeInfinityValue", (c) => SpiderMonkey.JS_GetNegativeInfinityValue(IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetPendingException", (c) => SpiderMonkey.JS_GetPendingException(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_LeaveCompartment", (c) => SpiderMonkey.JS_LeaveCompartment(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_NewContext", (c) => SpiderMonkey.JS_NewContext(IntPtr.Zero, 0)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_NewPlainObject", (c) => SpiderMonkey.JS_NewPlainObject(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_NewStringCopyN", (c) => SpiderMonkey.JS_NewStringCopyN(c, "", 0)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SaveFrameChain", (c) => SpiderMonkey.JS_SaveFrameChain(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetCompartmentPrincipals", (c) => SpiderMonkey.JS_SetCompartmentPrincipals(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetContextCallback", (c) => SpiderMonkey.JS_SetContextCallback(IntPtr.Zero, null)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetContextPrivate", (c) => SpiderMonkey.JS_SetContextPrivate(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetErrorReporter", (c) => SpiderMonkey.JS_SetErrorReporter(c, (cx, message, report) => { })));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetProperty", (c) => SpiderMonkey.JS_SetProperty(c, IntPtr.Zero, "", new JsVal())));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetTrustedPrincipals", (c) => SpiderMonkey.JS_SetTrustedPrincipals(IntPtr.Zero, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_TypeOfValue", (c) => SpiderMonkey.JS_TypeOfValue(IntPtr.Zero, default(JsVal))));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_ValueToObject", (c) => SpiderMonkey.JS_ValueToObject(IntPtr.Zero, default(JsVal))));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_WrapObject", (c) => SpiderMonkey.JS_WrapObject(IntPtr.Zero, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("ToStringSlow", (c) => SpiderMonkey.ToStringSlow(IntPtr.Zero, default(JsVal))));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetRuntime", (c) => SpiderMonkey.JS_GetRuntime(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_WrapObject", (c) => SpiderMonkey.JS_WrapObject(c, IntPtr.Zero)));
        }
        /// <summary>
        /// Please keep these in alphabetical order.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <KeyValuePair <string, Action <IntPtr, IntPtr> > > EntryPoints()
        {
            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("CurrentGlobalOrNull", (c, j) => SpiderMonkey.CurrentGlobalOrNull(c)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("GetGlobalForObjectCrossCompartment", (c, j) => SpiderMonkey.GetGlobalForObjectCrossCompartment(j)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("IsObjectInContextCompartment", (c, j) => SpiderMonkey.IsObjectInContextCompartment(j, c)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_BeginRequest", (c, j) => SpiderMonkey.JS_BeginRequest(c)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_CallFunctionName", (c, j) => SpiderMonkey.JS_CallFunctionName(c, j, "", new JsVal[0])));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_CallFunctionValue", (c, j) => SpiderMonkey.JS_CallFunctionValue(c, j, new JsVal())));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_EncodeString", (c, j) => SpiderMonkey.JS_EncodeString(c, TestString(c))));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_EndRequest", (c, j) => SpiderMonkey.JS_EndRequest(c)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_EnterCompartment", (c, j) => SpiderMonkey.JS_EnterCompartment(c, j)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_ExecuteScript", (c, j) => { JsVal val; SpiderMonkey.JS_ExecuteScript(c, "", out val); }));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_Free", (c, j) => SpiderMonkey.JS_Free(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetClass", (c, j) => SpiderMonkey.JS_GetClass(j)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetClassObject", (c, j) => SpiderMonkey.JS_GetClassObject(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetCompartmentPrincipals", (c, j) => SpiderMonkey.JS_GetCompartmentPrincipals(c)));

#if PORTFF60
            // unstable
            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetEmptyStringValue", (c, j) => SpiderMonkey.JS_GetEmptyStringValue(c)));
#endif
            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetGlobalForObject", (c, j) => SpiderMonkey.JS_GetGlobalForObject(c, j)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetProperty", (c, j) => SpiderMonkey.JS_GetProperty(c, j, "")));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetStringLength", (c, j) => SpiderMonkey.JS_GetStringLength(TestString(c))));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetStringEncodingLength", (c, j) => SpiderMonkey.JS_GetStringEncodingLength(c, TestString(c))));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_HasProperty", (c, j) => SpiderMonkey.JS_HasProperty(c, j, "")));

#if PORTFF60
            // unstable
            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetNegativeInfinityValue", (c, j) => SpiderMonkey.JS_GetNegativeInfinityValue(c)));
#endif
            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetPendingException", (c, j) => SpiderMonkey.JS_GetPendingException(c)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_LeaveCompartment", (c, j) => SpiderMonkey.JS_LeaveCompartment(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_NewPlainObject", (c, j) => SpiderMonkey.JS_NewPlainObject(c)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_NewStringCopyN", (c, j) => SpiderMonkey.JS_NewStringCopyN(c, "", 0)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_SetCompartmentPrincipals", (c, j) => SpiderMonkey.JS_SetCompartmentPrincipals(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_SetProperty", (c, j) => SpiderMonkey.JS_SetProperty(c, j, "", new JsVal())));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_TypeOfValue", (c, j) => SpiderMonkey.JS_TypeOfValue(c, default(JsVal))));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_ValueToObject", (c, j) => SpiderMonkey.JS_ValueToObject(c, default(JsVal))));

            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_WrapObject", (c, j) => SpiderMonkey.JS_WrapObject(c, j)));

#if PORTFF60
            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("ToStringSlow", (c, j) => SpiderMonkey.ToStringSlow(IntPtr.Zero, default(JsVal))));
#endif
            yield return(new KeyValuePair <string, Action <IntPtr, IntPtr> >("JS_GetRuntime", (c, j) => SpiderMonkey.JS_GetRuntime(c)));
        }