[pypy-svn] r25325 - in pypy/dist/pypy/translator/c: . src

tismer at codespeak.net tismer at codespeak.net
Tue Apr 4 21:38:43 CEST 2006


Author: tismer
Date: Tue Apr  4 21:38:40 2006
New Revision: 25325

Modified:
   pypy/dist/pypy/translator/c/genc.py
   pypy/dist/pypy/translator/c/pyobj.py
   pypy/dist/pypy/translator/c/src/module.h
Log:
support for exporting simple objects, preparations for post-installation code

Modified: pypy/dist/pypy/translator/c/genc.py
==============================================================================
--- pypy/dist/pypy/translator/c/genc.py	(original)
+++ pypy/dist/pypy/translator/c/genc.py	Tue Apr  4 21:38:40 2006
@@ -56,10 +56,14 @@
         pfname = db.get(pf)
         self.exports[self.entrypoint.func_name] = pf
         for obj in exports:
+            objname = None
+            if type(obj) is tuple:
+                objname, obj = obj
             po = self.getentrypointptr(obj)
-            poname = objname = db.get(po)
+            poname = db.get(po)
             if hasattr(obj, '__name__'):
                 objname = obj.__name__
+            objname = objname or poname
             if objname in self.exports:
                 raise NameError, 'duplicate name in export: %s is %s and %s' % (
                     objname, db.get(self.exports[objname]), poname)
@@ -667,6 +671,7 @@
             wrapper_name))
     print >> f, '\t{ NULL }\t/* Sentinel */'
     print >> f, '};'
+    print >> f, 'static globalfunctiondef_t *globalfunctiondefsptr = &globalfunctiondefs[0];'
     print >> f
     print >> f, '/***********************************************************/'
     print >> f, '/***  Frozen Python bytecode: the initialization code    ***/'

Modified: pypy/dist/pypy/translator/c/pyobj.py
==============================================================================
--- pypy/dist/pypy/translator/c/pyobj.py	(original)
+++ pypy/dist/pypy/translator/c/pyobj.py	Tue Apr  4 21:38:40 2006
@@ -16,8 +16,6 @@
 # Should this be registered with the annotator?
 from pypy.interpreter.baseobjspace import ObjSpace
 
-from pypy.annotation.registry import IMPORT_HINTS
-
 class PyObjMaker:
     """Handles 'PyObject*'; factored out from LowLevelDatabase.
     This class contains all the nameof_xxx() methods that allow a wild variety
@@ -38,7 +36,8 @@
                                #   objects
         self.debugstack = ()  # linked list of nested nameof()
         self.wrappers = {}    # {'pycfunctionvariable': ('name', 'wrapperfn')}
-        self.import_hints = IMPORT_HINTS
+        self.import_hints = {} # I don't seem to need it any longer.
+        # leaving the import support intact, doesn't hurt.
         self.instantiators = instantiators
 
     def nameof(self, obj, debug=None):
@@ -169,10 +168,7 @@
     def skipped_function(self, func):
         # debugging only!  Generates a placeholder for missing functions
         # that raises an exception when called.
-
-        # XXX this is broken after the translationcontext change!
-        # the frozen attribute is gone. What to do?
-        if self.translator.frozen:
+        if self.translator.annotator.frozen:
             warning = 'NOT GENERATING'
         else:
             warning = 'skipped'

Modified: pypy/dist/pypy/translator/c/src/module.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/module.h	(original)
+++ pypy/dist/pypy/translator/c/src/module.h	Tue Apr  4 21:38:40 2006
@@ -57,6 +57,10 @@
 	PyMethodDef ml;
 } globalfunctiondef_t;
 
+/* helper-hook for post-setup */
+static globalfunctiondef_t *globalfunctiondefsptr;
+static PyObject *postsetup_get_type_dict(PyObject *tp);
+static PyObject *postsetup_build_method(int funcidx);
 
 /* implementations */
 
@@ -140,4 +144,21 @@
 	return 0;
 }
 
+static PyObject *postsetup_get_type_dict(PyObject *tp)
+{
+    PyTypeObject *type = (PyTypeObject *)tp;
+    PyObject *ret;
+
+    ret = type->tp_dict;
+    Py_INCREF(ret);
+    return ret;
+}
+
+static PyObject *postsetup_build_method(int funcidx, PyObject *type)
+{   
+    globalfunctiondef_t *gfuncdef = &globalfunctiondefsptr[funcidx];
+
+    return PyDescr_NewMethod((PyTypeObject *)type, &gfuncdef->ml);
+}
+
 #endif /* PYPY_NOT_MAIN_FILE */



More information about the Pypy-commit mailing list