Hi Armin We ended up (Aleksandr is here at pycon russia) using rffi_platform to get the exact shape of the structure from the header file. There were a few bugs how exactly this got mapped, so it ended up being a good way to do it.
On Sat, Jul 15, 2017 at 8:02 AM, Armin Rigo <armin.r...@gmail.com> wrote: > Hi Aleksandr, > > On 11 July 2017 at 18:33, Aleksandr Koshkin <tinysnipp...@gmail.com> wrote: >> So ok, I have to specify headers containing my structs and somehow push it >> to rpython toolchain, if I got you correctly. >> 0. Why? This structures are already described in the vm file as a bunch of >> ffi.CStruct objects. > > rffi.CStruct() is used to declare the RPython interface for structs > that are originally defined in C. > > You can use lltype.Struct(), but it's not recommended in your case > because lltype.Struct() is meant to define structs in RPython where > you *don't* need a precise C-level struct; for example, > lltype.Struct() could rename and reorder the fields in C if it is more > efficient. > > We don't have a direct way to declare the struct in RPython but also > force it to generate exactly the C struct declaration you want, > because we never needed it. You need to use rffi.CStruct() and write > the struct in the .h file manually too. > >> 1. If I have to, how would I do that, is there any example of embedding >> rpython into something? > > Not really. Look maybe at tests using rpython.rlib.entrypoint, like > rpython/translator/c/test/test_genc:test_entrypoints. > > > A bientôt, > > Armin. _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev