Exemplo n.º 1
0
        public JSFunction(JSContext context, string name, JSFunctionHandler handler) : base(context, IntPtr.Zero)
        {
            this.handler = handler;
            var native_name = JSString.New(name);

            Raw = JSObjectMakeFunctionWithCallback(context.Raw, native_name,
                                                   native_callback = new JSObject.CallAsFunctionCallback(JSCallback));
            native_name.Release();
        }
        public bool HasProperty(string propertyName)
        {
            var property = JSString.New(propertyName);

            try {
                return(JSObjectHasProperty(Context.Raw, Raw, property));
            } finally {
                property.Release();
            }
        }
Exemplo n.º 3
0
        public static JSValue FromJson(JSContext ctx, string json)
        {
            var json_native = JSString.New(json);

            try {
                return(FromJson(ctx, json_native));
            } finally {
                json_native.Release();
            }
        }
        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.º 5
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();
            }
        }
        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();
            }
        }
 public void AddName(string propertyName)
 {
     JSPropertyNameAccumulatorAddName(this, JSString.New(propertyName));
 }
Exemplo n.º 9
0
 public JSValue(JSContext ctx, string value) : this(ctx, JSValueMakeString(ctx.Raw, JSString.New(value)))
 {
 }