Beispiel #1
0
        public ScriptScope /*!*/ ImportModule(ScriptEngine /*!*/ engine, string /*!*/ name)
        {
            if (Importer.ImportModule(_context.SharedClsContext, _context.SharedClsContext.GlobalDict, name, false, 0) is PythonModule module)
            {
                return(HostingHelpers.CreateScriptScope(engine, module.Scope));
            }

            throw PythonOps.ImportError("no module named {0}", name);
        }
Beispiel #2
0
        public ScriptScope /*!*/ CreateModule(string name, string filename, string docString)
        {
            var module = new PythonModule();

            _context.PublishModule(name, module);
            module.__init__(name, docString);
            module.__dict__["__file__"] = filename;

            return(HostingHelpers.CreateScriptScope(_engine, module.Scope));
        }
Beispiel #3
0
        public ScriptScope /*!*/ GetClr()
        {
            if (_clr == null)
            {
                Interlocked.CompareExchange(
                    ref _clr,
                    HostingHelpers.CreateScriptScope(_engine, _context.ClrModule.Scope),
                    null
                    );
            }

            return(_clr);
        }
Beispiel #4
0
        public ScriptScope /*!*/ GetBuiltins()
        {
            if (_builtins == null)
            {
                Interlocked.CompareExchange(
                    ref _builtins,
                    HostingHelpers.CreateScriptScope(_engine, _context.BuiltinModuleInstance.Scope),
                    null
                    );
            }

            return(_builtins);
        }
Beispiel #5
0
        public ScriptScope /*!*/ GetSystemState()
        {
            if (_sys == null)
            {
                Interlocked.CompareExchange(
                    ref _sys,
                    HostingHelpers.CreateScriptScope(_engine, _context.SystemState.Scope),
                    null
                    );
            }

            return(_sys);
        }
Beispiel #6
0
        public ScriptScope /*!*/ ImportModule(ScriptEngine /*!*/ engine, string /*!*/ name)
        {
            //Debug.WriteLine("Importing step 2: " + name);

            PythonModule module = Importer.ImportModule(_context.SharedClsContext, _context.SharedClsContext.GlobalDict, name, false, -1) as PythonModule;

            if (module != null)
            {
                //Debug.WriteLine("Module not null: " + name);
                return(HostingHelpers.CreateScriptScope(engine, module.Scope));
            }

            throw PythonOps.ImportError("no module named {0}", name);
        }