tech.v3.datatype.ffi.clang

General utilites to work with clang in order to define things like structs or enumerations.

defstruct-from-layout

(defstruct-from-layout struct-dtype layout {:keys [failed-line-parser]})(defstruct-from-layout struct-dtype layout)

Function to take a partial clang record dump and make a struct defintion. In order to generate a file containing dumps we do something like:

clang avcodec.cpp -I/usr/include/x86_64-linux-gnu/libavcodec -Xclang -fdump-record-layouts > recordlayouts64.txt

Note the -fdump-record-layouts argument.

Then we take the record layouts and save them somewhere we can get to them at code generation time.

Example:

(def packet-layout
  "     0 |   AVBufferRef * buf
         8 |   int64_t pts
        16 |   int64_t dts
        24 |   uint8_t * data
        32 |   int size
        36 |   int stream_index
        40 |   int flags
        48 |   AVPacketSideData * side_data
        56 |   int side_data_elems
        64 |   int64_t duration
        72 |   int64_t pos
        80 |   int64_t convergence_duration")

(def packet-def* (delay (ffi-clang/defstruct-from-layout :av-packet packet-layout)))