Beispiel #1
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();
            }
        }
        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);
            }
        }
Beispiel #3
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();
            }
        }
        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();
            }
        }
        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();
            }
        }
Beispiel #6
0
 private static extern JSString JSStringRetain(JSString str);
Beispiel #7
0
 private static extern IntPtr JSStringGetCharactersPtr(JSString str);
 private static extern void JSPropertyNameAccumulatorAddName(
     JSPropertyNameAccumulator accumulator, JSString propertyName);
 private static extern void JSObjectSetProperty(IntPtr ctx, IntPtr obj, JSString propertyName,
                                                IntPtr value, JSPropertyAttribute attributes, ref IntPtr exception);
Beispiel #10
0
 private static extern IntPtr JSObjectMakeFunctionWithCallback(IntPtr ctx, JSString name,
                                                               CallAsFunctionCallback callAsFunction);
Beispiel #11
0
 private static extern IntPtr JSEvaluateScript(IntPtr ctx, JSString script,
                                               IntPtr thisObject, JSString sourceURL, int startingLineNumber, ref IntPtr exception);
 private static extern IntPtr JSValueMakeString(IntPtr ctx, JSString value);
 private static extern IntPtr JSValueMakeFromJSONString(IntPtr ctx, JSString str);
 public JSValue(JSContext ctx, string value) : this(ctx, JSValueMakeString(ctx.Raw, JSString.New(value)))
 {
 }
 private bool JSDeleteProperty(IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception)
 {
     return(OnJSDeleteProperty(new JSObject(ctx, obj), propertyName.Value));
 }
 private static extern IntPtr JSObjectGetProperty(IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception);
Beispiel #17
0
 private static extern void JSStringRelease(JSString str);
Beispiel #18
0
 private static extern bool JSStringIsEqual(JSString a, JSString b);
 private static extern bool JSObjectDeleteProperty(IntPtr ctx, IntPtr obj, JSString propertyName, ref IntPtr exception);
Beispiel #20
0
 public bool IsEqual(JSString str)
 {
     return(JSStringIsEqual(this, str));
 }
 private static extern bool JSObjectHasProperty(IntPtr ctx, IntPtr obj, JSString propertyName);
Beispiel #22
0
 private static extern IntPtr JSStringGetLength(JSString str);
 public void AddName(string propertyName)
 {
     JSPropertyNameAccumulatorAddName(this, JSString.New(propertyName));
 }
 private bool JSHasProperty(IntPtr ctx, IntPtr obj, JSString propertyName)
 {
     return(OnJSHasProperty(new JSObject(ctx, obj), propertyName.Value));
 }