Beispiel #1
0
 public AppJsObject(IronJS.Environment env, ICallable app)
     : base(env, env.NewObject())
 {
     Put("call",
         IronJS.Native.Utils.CreateFunction <Func <BoxedValue, CommonObject> >(env, 1,
                                                                               environ => ConvertArrayToObject(env, app.Call(CreateDictionary(environ.Object as EnvironmentJsObject)))));
 }
Beispiel #2
0
        public net(IronJS.Environment env)
            : base(env, env.Maps.Base, env.Prototypes.Object)
        {
            var objMethod = Utils.createHostFunction <Func <IronJS.FunctionObject, IronJS.CommonObject> >(Env, CreateServer);

            log.Trace(objMethod);
            this.Put("createServer", objMethod);
        }
Beispiel #3
0
        public http(IronJS.Environment env) : base(env, env.Maps.Base, env.Prototypes.Object)
        {
            // SetOwnProperty( "createServer", new Fn_CreateHttpServer( context ) );
            var objMethod = Utils.createHostFunction <Func <IronJS.FunctionObject, IronJS.CommonObject> >(Env, CreateServer);

            Console.WriteLine(objMethod);
            // this.Methods.PutRefProperty(this, "createServer", objMethod, IronJS.TypeTags.Function);
            this.Put("createServer", objMethod);
        }
Beispiel #4
0
        private static CommonObject ConvertArrayToObject(IronJS.Environment env, object[] objects)
        {
            var obj = env.NewObject();

            obj.Put("status", (string)objects[0]);
            obj.Put("headers", new EnvironmentJsObject((IDictionary <string, object>)objects[1], env, env.NewPrototype()));
            obj.Put("body", objects[2]);

            return(obj);
        }
Beispiel #5
0
        public EditorProviderObject(Env env, CommonObject prototype, IEditorProvider provider)
            : base(env, env.Maps.Base, prototype)
        {
            this.provider = provider;
            this.editorPrototype = EditorObject.CreatePrototype(env);

            var newEditor = Utils.CreateFunction(env, 0,
                (Func<FunctionObject, CommonObject, CommonObject>)NewEditor);
            this.Put("newEditor", newEditor, DescriptorAttrs.Immutable);
        }
Beispiel #6
0
        public HttpServer(IronJS.FunctionObject callback, IronJS.Environment env) : base(env, env.Maps.Base, env.Prototypes.Object, IronJS.Classes.Object)
        {
            // have to set this stuff up. not sure why yet

            Console.WriteLine("creating HttpServer");
            var objMethod = Utils.createHostFunction <Action <object, string> >(env, listen);

            // this.Methods.PutRefProperty(this, "listen", objMethod, IronJS.TypeTags.Function);
            this.Put("listen", objMethod, TypeTags.Function)

            this.addListener("connection", callback);
        }
Beispiel #7
0
        public NetStream(Stream stream, IronJS.Environment env)
            : base(env, env.Maps.Base, env.Prototypes.Object)
        {
            this.stream = stream;
            var objMethod = Utils.CreateFunction <Action <string, IronJS.FunctionObject> >(env, 0, addListener);

            this.Put("addListener", objMethod, DescriptorAttrs.Immutable);

            var objRemoveMethod = Utils.CreateFunction <Action <string> >(env, 0, removeAllListeners);

            this.Put("removeAllListeners", objRemoveMethod, DescriptorAttrs.Immutable);
        }
Beispiel #8
0
    public net(IronJS.Environment env) : base(env, env.Maps.Base, env.Prototypes.Object, IronJS.Classes.Object)
    {
        // have to set context to satisfy IronJS Obj
        Env     = env;
        Methods = Env.Methods.Object;

        // SetOwnProperty( "createServer", new Fn_CreateServer( context ) );
        var objMethod = IronJS.Api.HostFunction.create <Func <IronJS.Function, IronJS.Object> >(Env, CreateServer);

        Console.WriteLine(this.Methods == null);
        Console.WriteLine(objMethod);
        this.Methods.PutRefProperty(this, "createServer", objMethod, IronJS.TypeTags.Function);
    }
Beispiel #9
0
        public HttpServerRequest(NetStream in_stream, IronJS.Environment env) : base(env, env.Maps.Base, env.Prototypes.Object, IronJS.Classes.Object)
        {
            netStream = in_stream;
            m_parser  = new Parser();


            // this.SetOwnProperty( "addListener", new Action<string, IFunction>( this.addListener ) );
            var objMethod  = Utils.createHostFunction <Action <string, IronJS.FunctionObject> >(env, addListener);
            var objMethod2 = Utils.createHostFunction <Func <string> >(env, getPath);

            this.Methods.PutRefProperty(this, "addListener", objMethod, IronJS.TypeTags.Function);
            this.Methods.PutRefProperty(this, "getPath", objMethod2, IronJS.TypeTags.Function);
        }
            private BuilderJsObject(IronJS.Environment env, Builder builder)
                : base(env, env.NewPrototype())
            {
                Put("run",
                    IronJS.Native.Utils.CreateFunction <Action <CommonObject> >(env, 1, obj => builder.Run(new JavaScriptApp(obj))));

                Put("use",
                    IronJS.Native.Utils.CreateFunction <Action <CommonObject> >(env, 1,
                                                                                obj => builder.Use(typeof(JavaScriptApp), obj)));

                Put("map",
                    IronJS.Native.Utils.CreateFunction <Action <string, FunctionObject> >(env, 2,
                                                                                          (str, func) => builder.Map(str, MapBuilder(func))));
            }
        public EnvironmentJsObject(IDictionary <string, object> environment, IronJS.Environment env, CommonObject prototype)
            : base(env, env.Maps.Base, prototype)
        {
            foreach (var key in environment.Keys)
            {
                if (key == "rack.input")
                {
                    Put(key, new JsStream(env, environment[key] as Stream));
                    continue;
                }

                Put(key, environment[key].ToString());
            }
        }
Beispiel #12
0
        public HttpServerResponse(NetStream in_stream, IronJS.Environment env) : base(env, env.Maps.Base, env.Prototypes.Object, IronJS.Classes.Object)
        {
            netStream = in_stream;
            // Context = in_context;

            // this.SetOwnProperty( "write", new Action<string>( write ) );
            var writeMethod = Utils.createHostFunction <Action <string> >(env, write);

            this.Methods.PutRefProperty(this, "write", writeMethod, IronJS.TypeTags.Function);

            // this.SetOwnProperty( "end", new Action( end ) );
            var endMethod = Utils.createHostFunction <Action>(env, end);

            this.Methods.PutRefProperty(this, "end", endMethod, IronJS.TypeTags.Function);
        }
Beispiel #13
0
        public static CommonObject CreatePrototype(Env env)
        {
            var getText = Utils.CreateFunction<GetStr>(env, 0, GetText);
            var setText = Utils.CreateFunction<SetStr>(env, 1, SetText);
            var getTitle = Utils.CreateFunction<GetStr>(env, 0, GetTitle);
            var setTitle = Utils.CreateFunction<SetStr>(env, 1, SetTitle);

            var prototype = new CommonObject(env, env.Maps.Base, env.Prototypes.Object);

            prototype.Put("getText", getText, DescriptorAttrs.Immutable);
            prototype.Put("setText", setText, DescriptorAttrs.Immutable);
            prototype.Put("getTitle", getTitle, DescriptorAttrs.Immutable);
            prototype.Put("setTitle", setTitle, DescriptorAttrs.Immutable);

            return prototype;
        }
Beispiel #14
0
        public NetServer(IronJS.Function callback, IronJS.Environment env) : base(env, env.Maps.Base, env.Prototypes.Object, IronJS.Classes.Object)
        {
            // have to set this stuff up. not sure why yet
            Env     = env;
            Methods = Env.Methods.Object;

            // Prototype = context.ObjectConstructor.Object_prototype;
            // Class = ObjClass.Array;

            Console.WriteLine("creating NetServer");

            //this.SetOwnProperty( "listen", new Action<object, string>( listen ) );
            var objMethod = IronJS.Api.HostFunction.create <Action <object, string> >(env, listen);

            this.Methods.PutRefProperty(this, "listen", objMethod, IronJS.TypeTags.Function);

            this.addListener("connection", callback);
        }
Beispiel #15
0
        public NetStream(Stream stream, IronJS.Environment env) : base(env, env.Maps.Base, env.Prototypes.Object, IronJS.Classes.Object)
        {
            // have to set this stuff up to satisfy IObj. not sure why yet
            Env     = env;
            Methods = Env.Methods.Object;

            // IronJS objects set up the following also, not sure if we
            // really need this stuff though
            // Prototype = context.ObjectConstructor.Object_prototype;
            // Class = ObjClass.Array;

            this.stream = stream;

            var objMethod = IronJS.Api.HostFunction.create <Action <string, IronJS.Function> >(env, addListener);

            this.Methods.PutRefProperty(this, "addListener", objMethod, IronJS.TypeTags.Function);

            // this.SetOwnProperty( "addListener", new Action<string, IFunction>( addListener ) );
        }
Beispiel #16
0
        public NetServer(IronJS.FunctionObject callback, IronJS.Environment env) : base(env)
        {
            // TODO: move as much of this as possible to EventEmitter
            Callbacks = new Dictionary <string, ArrayList>()
            {
                { "connect", new ArrayList() },
                { "close", new ArrayList() }
            };

            log.Trace("creating NetServer");

            var objMethod = Utils.createHostFunction <Func <object, string, CommonObject> >(env, listen);

            var removeAllListenersMethod = Utils.createHostFunction <Action <string> >(env, removeAllListeners);

            this.Put("listen", objMethod, TypeTags.Function);
            this.Put("removeAllListeners", removeAllListenersMethod, TypeTags.Function);
            this.addListener("connect", callback);
        }
            public JsStream(IronJS.Environment env, Stream stream)
                : base(env, env.NewPrototype())
            {
                Put("read",
                    IronJS.Native.Utils.CreateFunction <Func <CommonObject> >(env, 0,
                                                                              () =>
                {
                    if (stream == null)
                    {
                        return(null);
                    }

                    string input;
                    using (var strm = stream)
                    {
                        strm.Position = 0;
                        var reader    = new StreamReader(strm);
                        input         = reader.ReadToEnd();
                        strm.Close();
                    }

                    return(env.NewString(input));
                }));
            }
 public ConfigJsObject(IronJS.Environment env, ConfigBase config, CommonObject prototype)
     : base(env, prototype)
 {
     configBase = config;
 }
Beispiel #19
0
 public EditorObject(Env env, CommonObject prototype, IEditor editor)
     : base(env, env.Maps.Base, prototype)
 {
     this.editor = editor;
 }
Beispiel #20
0
 public CommandObject(Env env, CommonObject prototype)
     : base(env, prototype)
 {
     Children = new ObservableCollection<ICommand>();
 }
Beispiel #21
0
 public ConsoleObject(Environment env, CommonObject prototype)
     : base(env, env.Maps.Base, prototype)
 {
 }
Beispiel #22
0
 public EventObject(Env env, CommonObject prototype)
     : base(env, env.Maps.Base, prototype)
 {
     events = new Dictionary<string, List<FunctionObject>>();
 }
Beispiel #23
0
 public WindowObject(Env env, CommonObject prototype, IMainWindow window)
     : base(env, env.Maps.Base, prototype)
 {
     this.window = window;
 }