Пример #1
0
 InitialiseScope()
 {
     this.tp_name = CPyMarshal.ReadCStringField(this.ptr, typeof(PyTypeObject), "tp_name");
     CallableBuilder.ExtractNameModule(this.tp_name, ref this.__name__, ref this.__module__);
     this.tablePrefix = this.__name__ + ".";
     this.code.Append("_ironclad_class_attrs = dict()");
 }
Пример #2
0
        Py_InitModule4(string name, IntPtr methodsPtr, string doc, IntPtr selfPtr, int apiver)
        {
            name = this.FixImportName(name);

            PythonDictionary methodTable = new PythonDictionary();
            PythonModule     module      = new PythonModule();

            this.AddModule(name, module);
            this.CreateModulesContaining(name);

            PythonDictionary __dict__ = module.Get__dict__();

            __dict__["__doc__"]  = doc;
            __dict__["__name__"] = name;
            string __file__ = this.importFiles.Peek();

            __dict__["__file__"] = __file__;
            List __path__ = new List();

            if (__file__ != null)
            {
                __path__.append(Path.GetDirectoryName(__file__));
            }
            __dict__["__path__"]    = __path__;
            __dict__["_dispatcher"] = new Dispatcher(this, methodTable, selfPtr);

            StringBuilder moduleCode = new StringBuilder();

            moduleCode.Append(CodeSnippets.USEFUL_IMPORTS);
            CallableBuilder.GenerateFunctions(moduleCode, methodsPtr, methodTable);
            this.ExecInModule(moduleCode.ToString(), module);

            return(this.Store(module));
        }
Пример #3
0
        GenerateMethods()
        {
            IntPtr methodsPtr = CPyMarshal.ReadPtrField(this.ptr, typeof(PyTypeObject), "tp_methods");

            CallableBuilder.GenerateMethods(this.code, methodsPtr, this.methodTable, this.tablePrefix);
        }