[pypy-svn] r7431 - pypy/trunk/src/pypy/translator

arigo at codespeak.net arigo at codespeak.net
Fri Nov 19 12:47:06 CET 2004


Author: arigo
Date: Fri Nov 19 12:47:05 2004
New Revision: 7431

Modified:
   pypy/trunk/src/pypy/translator/genc.h
   pypy/trunk/src/pypy/translator/genc.py
Log:
- generating constant dictionaries with non-string keys.
- fixed a typecast warning in the macros.


Modified: pypy/trunk/src/pypy/translator/genc.h
==============================================================================
--- pypy/trunk/src/pypy/translator/genc.h	(original)
+++ pypy/trunk/src/pypy/translator/genc.h	Fri Nov 19 12:47:05 2004
@@ -124,7 +124,7 @@
 	(PyObject_SetAttrString(t, attr, value) >= 0)
 
 #define SETUP_INSTANCE(i, cls)                  \
-	(i = PyType_GenericAlloc(cls, 0))
+	(i = PyType_GenericAlloc((PyTypeObject *)cls, 0))
 
 /* we need a subclass of 'builtin_function_or_method' which can be used
    as methods: builtin function objects that can be bound on instances */

Modified: pypy/trunk/src/pypy/translator/genc.py
==============================================================================
--- pypy/trunk/src/pypy/translator/genc.py	(original)
+++ pypy/trunk/src/pypy/translator/genc.py	Fri Nov 19 12:47:05 2004
@@ -293,9 +293,14 @@
         name = self.uniquename('g%ddict' % len(dic))
         def initdict():
             for k in dic:
-                assert type(k) is str, "can only dump dicts with string keys"
-                yield '\tINITCHK(PyDict_SetItemString(%s, "%s", %s) >= 0)'%(
-                    name, k, self.nameof(dic[k]))
+                if type(k) is str:
+                    yield ('\tINITCHK(PyDict_SetItemString'
+                           '(%s, "%s", %s) >= 0)'%(
+                               name, k, self.nameof(dic[k])))
+                else:
+                    yield ('\tINITCHK(PyDict_SetItem'
+                           '(%s, %s, %s) >= 0)'%(
+                               name, self.nameof(k), self.nameof(dic[k])))
         self.globaldecl.append('static PyObject* %s;' % name)
         self.initcode.append('INITCHK(%s = PyDict_New())' % (name,))
         self.latercode.append(initdict())



More information about the Pypy-commit mailing list