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