[pypy-svn] r26156 - in pypy/dist/pypy/translator/c: test winproj/extension
tismer at codespeak.net
tismer at codespeak.net
Sun Apr 23 05:25:47 CEST 2006
Author: tismer
Date: Sun Apr 23 05:25:43 2006
New Revision: 26156
Modified:
pypy/dist/pypy/translator/c/test/test_wrapping.py
pypy/dist/pypy/translator/c/winproj/extension/extension.vcproj
Log:
passing tuples containing instances in and out works.
methods like __add__ work nicely from outside, although they need to be spelled
directly from inside [ inst1.__add__(inst2) ]
Modified: pypy/dist/pypy/translator/c/test/test_wrapping.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_wrapping.py (original)
+++ pypy/dist/pypy/translator/c/test/test_wrapping.py Sun Apr 23 05:25:43 2006
@@ -47,7 +47,7 @@
clsdef = bk.getuniqueclassdef(obj)
rtyper.add_wrapper(clsdef)
elif isinstance(obj, types.FunctionType):
- t.annotator.build_types(obj, get_annotation(obj))
+ pass#t.annotator.build_types(obj, get_annotation(obj))
if view:
t.viewcg()
@@ -161,6 +161,11 @@
delmonitor.notify()
if P:print 'del'
+ def __add__(self, other):
+ # XXX I would like to use type(), but its support is very limited
+ #return type(self)(self.a + other.a, self.b + other.b)
+ return DemoClass(self.a + other.a, self.b + other.b)
+
# see if we get things exported with subclassing
class DemoSubclass(DemoClass):
def __init__(self, a, b, c):
@@ -279,20 +284,29 @@
res = obj.demo()
assert res == DemoClass(2, 3).demo()
+def extfunc(inst):
+ return inst.demo()
+
+def extfunc2(tup):
+ inst1, inst2 = tup
+ return inst1.__add__(inst2)
+
def t(a=int, b=int, c=DemoClass):
x = DemoClass(a, b)
x.demo()
DemoSubclass(a, a, b).demo()
DemoSubclass(a, a, b).demo(6)
y = DemoSubclass(a, a, b).demo(6, 'hu')
+ extfunc(x)
+ extfunc2( (x, x) )
if isinstance(c, DemoSubclass):
print 42
- return DemoBaseNotExposed(17, 4) # see if it works without wrapper
+ return x.__add__(x), DemoBaseNotExposed(17, 4) # see if it works without wrapper
# exposing and using classes from a generasted extension module
def test_asd():
m = get_compiled_module(t, use_boehm=not True, exports=[
- DemoClass, DemoSubclass, DemoNotAnnotated])
+ DemoClass, DemoSubclass, DemoNotAnnotated, extfunc, extfunc2])
obj = m.DemoClass(2, 3)
res = obj.demo()
assert res == DemoClass(2, 3).demo()
Modified: pypy/dist/pypy/translator/c/winproj/extension/extension.vcproj
==============================================================================
--- pypy/dist/pypy/translator/c/winproj/extension/extension.vcproj (original)
+++ pypy/dist/pypy/translator/c/winproj/extension/extension.vcproj Sun Apr 23 05:25:43 2006
@@ -208,7 +208,7 @@
</File>
</Filter>
<File
- RelativePath="..\..\..\..\..\..\..\Documents and Settings\ctismer\Local Settings\Temp\usession-2024\testing_1\testing_1.c">
+ RelativePath="..\..\..\..\..\..\..\Documents and Settings\ctismer\Local Settings\Temp\usession-2331\testing_1\testing_1.c">
</File>
</Files>
<Globals>
More information about the Pypy-commit
mailing list