Trying Zig to C bindings generator on real library

Поделиться
HTML-код
  • Опубликовано: 29 июн 2024
  • Stream from June 14, 2024 at / sphaerophoria
    00:00 Intro
    10:00 Fix pointer type resolution
    43:45 Fix missing function exports
    01:20:50 Figure out which structs need bindings

Комментарии • 7

  • @ryantaylor6470
    @ryantaylor6470 11 дней назад

    Great video! happy to find someone doing interesting things in Zig

  • @sphaerophoria
    @sphaerophoria  14 дней назад +2

    I played with an alternative method today and it worked really well.
    * Copy paste structs from zig to C header, mark structs as extern in zig
    * Write C bindings API by hand
    * Write a comptime function that asserts that structs are the same. Struct size, field offsets, struct alignment, etc.
    * Write a comptime function that asserts that all exported functions have parameters and return types that match according to previous bullet
    * Use the zig types in the bindings impl file

  • @bobby9568
    @bobby9568 14 дней назад

    Guru programmer at work! Amazing!

  • @distortions
    @distortions 14 дней назад

    whats up whats up whats up

  • @minma02262
    @minma02262 13 дней назад

    There is a lot of good knowledge here. Zig to wasm, rust to zig, zig to rust, zig to C. But all of it is 2 hours plus 😢😢😢.

  • @bart2019
    @bart2019 13 дней назад

    Spending more than an hour learning how to traverse a tree in Zig. 🙄

    • @sphaerophoria
      @sphaerophoria  13 дней назад +3

      What a rude and reductive comment, just a reminder that you get to choose if you want to be an ass hole or not
      I don't think in any part of this video we were struggling with "walking a tree" or with the fact that we were doing it in zig. The time comes from trying to find the data we care about, understand it's representation, and do what we want to do with it. There was a 20 min segment around 55:00 where we had to adjust our walking logic to account for a change in expectations about the tree layout, but I don't think that's an unreasonable amount of time to spend on something.
      Even if we were spending a lot of time on something, and you're wayyyyy smarter and could do it faster, there's no reason to try to make others feel bad about learning