[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pypy-svn
Subject:    [pypy-svn] r25171 - pypy/dist/pypy/rpython/lltypesystem
From:       tismer () codespeak ! net
Date:       2006-03-31 1:29:21
Message-ID: 20060331012921.DEEB5100D6 () code0 ! codespeak ! net
[Download RAW message or body]

Author: tismer
Date: Fri Mar 31 03:29:14 2006
New Revision: 25171

Modified:
   pypy/dist/pypy/rpython/lltypesystem/rclass.py
Log:
two-way wrapping works internally.
That is, we can wrap an instance and produce the real wrapper class.
This works in the test script. Now I"m building it into rclass.py
and change the generated python script.

Funny, lots of internal stuff, but no C code touched at all.
(will probably happen, when I optimize the internal PyCObjects away)

Modified: pypy/dist/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rclass.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rclass.py	Fri Mar 31 03:29:14 2006
@@ -330,8 +330,7 @@
             self.rbase.setup()
             #
             # PyObject wrapper support
-            if (self.rtyper.needs_wrapper(self.classdef) and '_wrapper_'
-                not in self.rbase.allinstancefields):
+            if self.has_wrapper and '_wrapper_' not in self.rbase.allinstancefields:
                 fields['_wrapper_'] = 'wrapper', pyobj_repr
                 llfields.append(('wrapper', Ptr(PyObject)))
 
@@ -386,6 +385,10 @@
     def create_instance(self):
         return malloc(self.object_type, flavor=self.getflavor()) # pick flavor
 
+    def has_wrapper(self):
+        return self.rtyper.needs_wrapper(self.classdef)
+    has_wrapper = property(has_wrapper)
+
     def get_ll_hash_function(self):
         if self.classdef is None:
             raise TyperError, 'missing hash support flag in classdef'
@@ -606,10 +609,14 @@
 
     #inst.inst___wrapper__ = nullptr(PyObject)
     #inst.inst_a = 42
+    inst._wrapper_ = nullptr(PyObject)
     
 def rtype_destruct_object(hop):
     v, = hop.inputargs(*hop.args_r)
-    hop.gendirectcall(ll_clear_wrapper, v)
+    #repr = hop.args_r[0]
+    null = hop.inputconst(Ptr(PyObject), nullptr(PyObject))
+    #repr.setfield('wrapper', null)
+    #hop.gendirectcall(ll_clear_wrapper, v)
     hop.genop('gc_unprotect', [v])
 
 extregistry.register_value(ll_call_destructor, 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic