예제 #1
0
        private void Init(PythonContext inPython, string stubPath, IAllocator inAllocator)
        {
            this.GIL       = new Lock();
            this.python    = inPython;
            this.allocator = inAllocator;

            this.importNames.Push("");
            this.importFiles.Push(null);

            this.CreateScratchModule();
            this.kindaDictProxy = this.CreateFromSnippet(CodeSnippets.KINDA_DICT_PROXY_CODE, "KindaDictProxy");

            if (stubPath != null)
            {
                this.stub = new StubReference(stubPath);
                this.stub.Init(new dgt_getfuncptr(this.GetFuncPtr), new dgt_registerdata(this.RegisterData));

                string path    = Environment.GetEnvironmentVariable("PATH");
                string newpath = path + ";" + Path.Combine(Path.GetDirectoryName(stubPath), "support");
                Environment.SetEnvironmentVariable("PATH", newpath);

                this.ReadyBuiltinTypes();
                this.importer       = new PydImporter();
                this.removeSysHacks = this.CreateFromSnippet(CodeSnippets.INSTALL_IMPORT_HOOK_CODE, "remove_sys_hacks");

                // TODO: load builtin modules only on demand?
                this.stub.LoadBuiltinModule("posix");
                this.stub.LoadBuiltinModule("mmap");
                this.stub.LoadBuiltinModule("_csv");
            }
            this.alive = true;
        }
예제 #2
0
        private void Init(PythonContext inPython, string stubPath, IAllocator inAllocator)
        {
            this.GIL = new Lock();
            this.python = inPython;
            this.allocator = inAllocator;

            this.importNames.Push("");
            this.importFiles.Push(null);

            this.CreateScratchModule();
            this.kindaDictProxy = this.CreateFromSnippet(CodeSnippets.KINDA_DICT_PROXY_CODE, "KindaDictProxy");

            if (stubPath != null)
            {
                this.stub = new StubReference(stubPath);
                this.stub.Init(new dgt_getfuncptr(this.GetFuncPtr), new dgt_registerdata(this.RegisterData));

                string path = Environment.GetEnvironmentVariable("PATH");
                string newpath = path + ";" + Path.Combine(Path.GetDirectoryName(stubPath), "support");
                Environment.SetEnvironmentVariable("PATH", newpath);

                this.ReadyBuiltinTypes();
                this.importer = new PydImporter();
                this.removeSysHacks = this.CreateFromSnippet(CodeSnippets.INSTALL_IMPORT_HOOK_CODE, "remove_sys_hacks");

                // TODO: load builtin modules only on demand?
                this.stub.LoadBuiltinModule("posix");
                this.stub.LoadBuiltinModule("mmap");
                this.stub.LoadBuiltinModule("_csv");
            }
            this.alive = true;
        }