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();
        }
示例#2
0
        public bool HasProperty(string propertyName)
        {
            var property = JSString.New(propertyName);

            try {
                return(JSObjectHasProperty(Context.Raw, Raw, property));
            } finally {
                property.Release();
            }
        }
示例#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();
            }
        }
示例#4
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();
            }
        }
        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();
            }
        }
示例#6
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();
            }
        }
示例#7
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();
            }
        }
示例#8
0
 public void AddName(string propertyName)
 {
     JSPropertyNameAccumulatorAddName(this, JSString.New(propertyName));
 }
示例#9
0
 public JSValue(JSContext ctx, string value) : this(ctx, JSValueMakeString(ctx.Raw, JSString.New(value)))
 {
 }