[pypy-dev] rffi strict typing
Simon Burton
simon at arrowtheory.com
Fri Jul 20 03:31:17 CEST 2007
The lltype's are very strict about types.
If I declare an llexternal that takes a Float arg,
I cannot call it with an int arg. Well maybe that's
not so bad. But in rlib.rsdl there are functions that take
Unsigned, and these don't work even if called with
a non-negative constant int... Can we loosen up
these restrictions ? Maybe put an "is_compatable(self, other)"
method on LowLevelType's ?
Simon.
using py lib: /home/simon/local/pypy-latest/py <rev 45205>
test/test_SDL.py[2] FF
__________________________________________________________________________________________________________________________________________________________________________________________________________ entrypoint: test_run ____________________________________________________________
def test_run():
> demo()
[/home/simon/local/pypy-latest/pypy/rlib/rsdl/test/test_SDL.py:48]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def demo():
> if SDL.Init(SDL.INIT_VIDEO) < 0:
[/home/simon/local/pypy-latest/pypy/rlib/rsdl/test/test_SDL.py:13]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def __call__(self, *args):
if isinstance(self._T, FuncType):
if len(args) != len(self._T.ARGS):
raise TypeError,"calling %r with wrong argument number: %r" % (self._T, args)
for a, ARG in zip(args, self._T.ARGS):
if typeOf(a) != ARG:
E raise TypeError,"calling %r with wrong argument types: %r" % (self._T, args)
> TypeError: calling <Func ( Unsigned ) -> Signed> with wrong argument types: (32,)
...
More information about the Pypy-dev
mailing list