Example #1
0
 public JSValue EvaluateScript(JSString script, JSObject thisObject,
     JSString sourceUrl, int startingLineNumber)
 {
     var exception = IntPtr.Zero;
     var result = JSEvaluateScript (Raw, script,
         thisObject == null ? IntPtr.Zero : thisObject.Raw,
         sourceUrl, startingLineNumber, ref exception);
     JSException.Proxy (this, exception);
     return new JSValue (this, result);
 }
Example #2
0
        internal static string ToStringAndRelease (JSString str)
        {
            if (str.Equals (JSString.Zero) || str.raw.Equals (IntPtr.Zero)) {
                return null;
            }

            try {
                return str.Value;
            } finally {
                str.Release ();
            }
        }
Example #3
0
        public void SetProperty(string propertyName, JSValue value, JSPropertyAttribute attributes)
        {
            var exception = IntPtr.Zero;
            var property  = JSString.New(propertyName);

            try {
                JSObjectSetProperty(Context.Raw, Raw, property, value.Raw, attributes, ref exception);
                JSException.Proxy(Context, exception);
            } finally {
                property.Release();
            }
        }
Example #4
0
        public JSValue EvaluateScript(string script, JSObject thisObject, string sourceUrl, int startingLineNumber)
        {
            var js_script     = JSString.New(script);
            var js_source_url = JSString.New(sourceUrl);

            try {
                return(EvaluateScript(js_script, thisObject, js_source_url, startingLineNumber));
            } finally {
                js_script.Release();
                js_source_url.Release();
            }
        }
Example #5
0
        private bool JSSetProperty(IntPtr ctx, IntPtr obj, JSString propertyName,
                                   IntPtr value, ref IntPtr exception)
        {
            var context = new JSContext(ctx);

            try {
                return(OnJSSetProperty(new JSObject(context, obj), propertyName.Value, new JSValue(context, value)));
            } catch (JSErrorException e) {
                exception = e.Error.Raw;
                return(false);
            }
        }
        internal static string ToStringAndRelease(JSString str)
        {
            if (str.Equals(JSString.Zero) || str.raw.Equals(IntPtr.Zero))
            {
                return(null);
            }

            try {
                return(str.Value);
            } finally {
                str.Release();
            }
        }
Example #7
0
        public bool DeleteProperty(string propertyName)
        {
            var exception = IntPtr.Zero;
            var property  = JSString.New(propertyName);

            try {
                var result = JSObjectDeleteProperty(Context.Raw, Raw, property, ref exception);
                JSException.Proxy(Context, exception);
                return(result);
            } finally {
                property.Release();
            }
        }
Example #8
0
        public JSValue GetProperty(string propertyName)
        {
            var exception = IntPtr.Zero;
            var property  = JSString.New(propertyName);

            try {
                var result = JSObjectGetProperty(Context.Raw, Raw, property, ref exception);
                JSException.Proxy(Context, exception);
                return(new JSValue(Context, result));
            } finally {
                property.Release();
            }
        }
Example #9
0
 private static extern bool JSObjectHasProperty(IntPtr ctx, IntPtr obj, JSString propertyName);
Example #10
0
 private static extern bool JSObjectDeleteProperty(IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception);
Example #11
0
 private static extern bool JSObjectDeleteProperty (IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception);
 private static extern IntPtr JSStringGetCharactersPtr(JSString str);
 public bool IsEqual(JSString str)
 {
     return(JSStringIsEqual(this, str));
 }
 private static extern void JSStringRelease(JSString str);
Example #15
0
 private bool JSSetProperty (IntPtr ctx, IntPtr obj, JSString propertyName,
     IntPtr value, ref IntPtr exception)
 {
     var context = new JSContext (ctx);
     try {
         return OnJSSetProperty (new JSObject (context, obj), propertyName.Value, new JSValue (context, value));
     } catch (JSErrorException e) {
         exception = e.Error.Raw;
         return false;
     }
 }
Example #16
0
 private bool JSDeleteProperty(IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception)
 {
     return(OnJSDeleteProperty(new JSObject(ctx, obj), propertyName.Value));
 }
Example #17
0
 private static extern IntPtr JSObjectGetProperty (IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception);
Example #18
0
 private bool JSHasProperty(IntPtr ctx, IntPtr obj, JSString propertyName)
 {
     return(OnJSHasProperty(new JSObject(ctx, obj), propertyName.Value));
 }
 private static extern void JSPropertyNameAccumulatorAddName (
     JSPropertyNameAccumulator accumulator, JSString propertyName);
Example #20
0
 public void AddName(string propertyName)
 {
     JSPropertyNameAccumulatorAddName(this, JSString.New(propertyName));
 }
Example #21
0
 private static extern void JSPropertyNameAccumulatorAddName(
     JSPropertyNameAccumulator accumulator, JSString propertyName);
Example #22
0
 private static extern bool JSObjectHasProperty (IntPtr ctx, IntPtr obj, JSString propertyName);
Example #23
0
        public static JSValue FromJson (JSContext ctx, JSString json)
        {
            var obj = JSValueMakeFromJSONString (ctx.Raw, json);
            if (obj.Equals (IntPtr.Zero)) {
                throw new JSException (ctx, "Invalid JSON");
            }

            return new JSValue (ctx, obj);
        }
Example #24
0
 public JSValue (JSContext ctx, JSString value) : this (ctx, JSValueMakeString (ctx.Raw, value)) { }
Example #25
0
 private bool JSHasProperty (IntPtr ctx, IntPtr obj, JSString propertyName)
 {
     return OnJSHasProperty (new JSObject (ctx, obj), propertyName.Value);
 }
Example #26
0
 private static extern void JSStringRelease (JSString str);
Example #27
0
 private IntPtr JSGetProperty (IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception)
 {
     var context = new JSContext (ctx);
     return (OnJSGetProperty (new JSObject (context, obj),
         propertyName.Value) ?? JSValue.NewNull (context)).Raw;
 }
 private static extern bool JSStringIsEqual(JSString a, JSString b);
 private static extern JSString JSStringRetain(JSString str);
 private static extern IntPtr JSStringGetLength(JSString str);
 private static extern IntPtr JSObjectMakeFunctionWithCallback(IntPtr ctx, JSString name,
                                                               CallAsFunctionCallback callAsFunction);
Example #32
0
 private bool JSSetProperty (IntPtr ctx, IntPtr obj, JSString propertyName,
     IntPtr value, ref IntPtr exception)
 {
     var context = new JSContext (ctx);
     return OnJSSetProperty (new JSObject (context, obj), propertyName.Value, new JSValue (context, value));
 }
Example #33
0
 private static extern void JSObjectSetProperty (IntPtr ctx, IntPtr obj, JSString propertyName,
     IntPtr value, JSPropertyAttribute attributes, ref IntPtr exception);
 private static extern IntPtr JSEvaluateScript(IntPtr ctx, JSString script,
                                               IntPtr thisObject, JSString sourceURL, int startingLineNumber, ref IntPtr exception);
Example #35
0
 private bool JSDeleteProperty (IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception)
 {
     return OnJSDeleteProperty (new JSObject (ctx, obj), propertyName.Value);
 }
Example #36
0
 private static extern IntPtr JSObjectGetProperty(IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception);
Example #37
0
 private static extern bool JSStringIsEqual (JSString a, JSString b);
Example #38
0
 private static extern void JSObjectSetProperty(IntPtr ctx, IntPtr obj, JSString propertyName,
                                                IntPtr value, JSPropertyAttribute attributes, ref IntPtr exception);
Example #39
0
 public bool IsEqual (JSString str)
 {
     return JSStringIsEqual (this, str);
 }
Example #40
0
 private static extern IntPtr JSStringGetLength (JSString str);
Example #41
0
 private static extern IntPtr JSStringGetCharactersPtr (JSString str);
Example #42
0
 private static extern IntPtr JSValueMakeFromJSONString (IntPtr ctx, JSString str);
Example #43
0
 private static extern IntPtr JSEvaluateScript(IntPtr ctx, JSString script,
     IntPtr thisObject, JSString sourceURL, int startingLineNumber, ref IntPtr exception);
Example #44
0
 private static extern IntPtr JSValueMakeString (IntPtr ctx, JSString value);
Example #45
0
 private static extern IntPtr JSValueMakeFromJSONString(IntPtr ctx, JSString str);
Example #46
0
 private static extern IntPtr JSObjectMakeFunctionWithCallback (IntPtr ctx, JSString name,
     CallAsFunctionCallback callAsFunction);
Example #47
0
 private static extern IntPtr JSValueMakeString(IntPtr ctx, JSString value);
Example #48
0
 private static extern JSString JSStringRetain (JSString str);
Example #49
0
 public JSValue(JSContext ctx, string value) : this(ctx, JSValueMakeString(ctx.Raw, JSString.New(value)))
 {
 }