コード例 #1
0
        private IntPtr OnStaticFunctionCallback(IntPtr ctx, IntPtr function, IntPtr thisObject,
                                                IntPtr argumentCount, IntPtr arguments, ref IntPtr exception)
        {
            var    context = new JSContext(ctx);
            var    fn      = new JSObject(ctx, function);
            string fn_name = null;

            if (fn.HasProperty("name"))
            {
                var prop = fn.GetProperty("name");
                if (prop != null && prop.IsString)
                {
                    fn_name = prop.StringValue;
                }
            }

            MethodInfo method = null;

            if (fn_name == null || !static_methods.TryGetValue(fn_name, out method))
            {
                return(JSValue.NewUndefined(context).Raw);
            }

            var result = method.Invoke(null, new object [] {
                fn,
                new JSObject(context, thisObject),
                JSValue.MarshalArray(ctx, arguments, argumentCount)
            });

            return(result == null
                ? JSValue.NewUndefined(context).Raw
                : ((JSValue)result).Raw);
        }
コード例 #2
0
        private IntPtr JSCallback(IntPtr ctx, IntPtr function, IntPtr thisObject,
                                  IntPtr argumentCount, IntPtr arguments, ref IntPtr exception)
        {
            var context = new JSContext(ctx);

            return(handler == null
                ? JSValue.NewUndefined(context).Raw
                : handler(this, new JSObject(context, thisObject),
                          JSValue.MarshalArray(ctx, arguments, argumentCount)).Raw);
        }
コード例 #3
0
        private IntPtr JSCallAsConstructor(IntPtr ctx, IntPtr constructor,
                                           IntPtr argumentCount, IntPtr arguments, ref IntPtr exception)
        {
            var result = OnJSCallAsConstructor(new JSObject(ctx, constructor),
                                               JSValue.MarshalArray(ctx, arguments, argumentCount));

            return(result == null
                ? JSValue.NewUndefined(new JSContext (ctx)).Raw
                : ((JSValue)result).Raw);
        }
コード例 #4
0
 protected virtual JSValue OnJSGetProperty(JSObject obj, string propertyName)
 {
     return(JSValue.NewUndefined(obj.Context));
 }