Exemplo n.º 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);
 }
Exemplo n.º 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 ();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 9
0
 private static extern bool JSObjectHasProperty(IntPtr ctx, IntPtr obj, JSString propertyName);
Exemplo n.º 10
0
 private static extern bool JSObjectDeleteProperty(IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception);
Exemplo n.º 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);
Exemplo n.º 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;
     }
 }
Exemplo n.º 16
0
 private bool JSDeleteProperty(IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception)
 {
     return(OnJSDeleteProperty(new JSObject(ctx, obj), propertyName.Value));
 }
Exemplo n.º 17
0
 private static extern IntPtr JSObjectGetProperty (IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception);
Exemplo n.º 18
0
 private bool JSHasProperty(IntPtr ctx, IntPtr obj, JSString propertyName)
 {
     return(OnJSHasProperty(new JSObject(ctx, obj), propertyName.Value));
 }
Exemplo n.º 19
0
 private static extern void JSPropertyNameAccumulatorAddName (
     JSPropertyNameAccumulator accumulator, JSString propertyName);
Exemplo n.º 20
0
 public void AddName(string propertyName)
 {
     JSPropertyNameAccumulatorAddName(this, JSString.New(propertyName));
 }
Exemplo n.º 21
0
 private static extern void JSPropertyNameAccumulatorAddName(
     JSPropertyNameAccumulator accumulator, JSString propertyName);
Exemplo n.º 22
0
 private static extern bool JSObjectHasProperty (IntPtr ctx, IntPtr obj, JSString propertyName);
Exemplo n.º 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);
        }
Exemplo n.º 24
0
 public JSValue (JSContext ctx, JSString value) : this (ctx, JSValueMakeString (ctx.Raw, value)) { }
Exemplo n.º 25
0
 private bool JSHasProperty (IntPtr ctx, IntPtr obj, JSString propertyName)
 {
     return OnJSHasProperty (new JSObject (ctx, obj), propertyName.Value);
 }
Exemplo n.º 26
0
 private static extern void JSStringRelease (JSString str);
Exemplo n.º 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);
Exemplo n.º 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));
 }
Exemplo n.º 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);
Exemplo n.º 35
0
 private bool JSDeleteProperty (IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception)
 {
     return OnJSDeleteProperty (new JSObject (ctx, obj), propertyName.Value);
 }
Exemplo n.º 36
0
 private static extern IntPtr JSObjectGetProperty(IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception);
Exemplo n.º 37
0
 private static extern bool JSStringIsEqual (JSString a, JSString b);
Exemplo n.º 38
0
 private static extern void JSObjectSetProperty(IntPtr ctx, IntPtr obj, JSString propertyName,
                                                IntPtr value, JSPropertyAttribute attributes, ref IntPtr exception);
Exemplo n.º 39
0
 public bool IsEqual (JSString str)
 {
     return JSStringIsEqual (this, str);
 }
Exemplo n.º 40
0
 private static extern IntPtr JSStringGetLength (JSString str);
Exemplo n.º 41
0
 private static extern IntPtr JSStringGetCharactersPtr (JSString str);
Exemplo n.º 42
0
 private static extern IntPtr JSValueMakeFromJSONString (IntPtr ctx, JSString str);
Exemplo n.º 43
0
 private static extern IntPtr JSEvaluateScript(IntPtr ctx, JSString script,
     IntPtr thisObject, JSString sourceURL, int startingLineNumber, ref IntPtr exception);
Exemplo n.º 44
0
 private static extern IntPtr JSValueMakeString (IntPtr ctx, JSString value);
Exemplo n.º 45
0
 private static extern IntPtr JSValueMakeFromJSONString(IntPtr ctx, JSString str);
Exemplo n.º 46
0
 private static extern IntPtr JSObjectMakeFunctionWithCallback (IntPtr ctx, JSString name,
     CallAsFunctionCallback callAsFunction);
Exemplo n.º 47
0
 private static extern IntPtr JSValueMakeString(IntPtr ctx, JSString value);
Exemplo n.º 48
0
 private static extern JSString JSStringRetain (JSString str);
Exemplo n.º 49
0
 public JSValue(JSContext ctx, string value) : this(ctx, JSValueMakeString(ctx.Raw, JSString.New(value)))
 {
 }