Out-of-line mode should support floating point types of arbitrary size and signness

Issue #218 resolved
Max Bélanger
created an issue

Related to issues 69 and 73, and similar to the change made in 43ee9d0dd03f to introduce the following syntax:

typedef int... foo_t;

It would also be useful to support floating-point types in such a way. We are working on writing an abstraction layer over CoreFoundation-based DLLs on Mac OS X, which defines CGFloat, for example, as being a float in i386 but as a double in x86_64 (IIRC).

Is this something planned or in the works for a future version? How can I help?

Comments (6)

  1. Armin Rigo

    It should not be too hard to add this. If you want to help, you're welcome. Start from the changeset 43ee9d0dd03f : we need something very similar for "typedef double... foo_t;" or "typedef float... foo_t;". There is even a test, test_some_float_type, added in that changeset and skipped so far. (Otherwise I can do it too)

    See also the comments at the link for 43ee9d0dd03f.

  2. Max Bélanger reporter

    Just noticed the following test failures (clang, Mac OS X 10.11) seemingly related to this ... I'm not yet well-versed enough in the internals of cffi to know exactly what's wrong here, but it looks like a signed-unsigned casting error.

    ______________________________________________________________ test_some_float_invalid_2 ______________________________________________________________
    
        def test_some_float_invalid_2():
            ffi = FFI()
            ffi.cdef("typedef double... foo_t; foo_t neg(foo_t);")
            lib = verify(ffi, 'test_some_float_invalid_2', """
                typedef unsigned long foo_t;
                foo_t neg(foo_t x) { return -x; }
            """)
    >       e = py.test.raises(ffi.error, getattr, lib, 'neg')
    E       NotImplementedError: prim=16777214
    
    testing/cffi1/test_recompiler.py:1089: NotImplementedError
    ______________________________________________________________ test_some_float_invalid_3 ______________________________________________________________
    
        def test_some_float_invalid_3():
            ffi = FFI()
            ffi.cdef("typedef double... foo_t; foo_t neg(foo_t);")
            lib = verify(ffi, 'test_some_float_invalid_3', """
                typedef long double foo_t;
                foo_t neg(foo_t x) { return -x; }
            """)
            if ffi.sizeof("long double") == ffi.sizeof("double"):
                assert lib.neg(12.3) == -12.3
            else:
    >           e = py.test.raises(ffi.error, getattr, lib, 'neg')
    E           NotImplementedError: prim=16777213
    

    Any ideas?

  3. Log in to comment