#!/bin/sh

# This file provides ad-hoc fixups to the WINGsP provided by bindgen:
#  - Import Xlib symbols so that everything compiles.
#  - The opaque type names _XftDraw and _XftFont are replaced with void*.
#  - Pango bindings aren't yet pulled into our Rust code, so PangoLayout is also demoted to void*.

set -e

if [ "x$1" = "x" ]; then
    echo "Usage: $(basename $0) <file to patch>"
    exit 1
fi

FILE="$1"

exec sed -i -r \
     -e "1s/^/use wrlib_rs::ffi::*;\nuse wutil_rs::range::ffi::*;\nuse x11::xlib::*;\nuse crate::ffi::*;\n\n/" \
     -e "s/_XftDraw/::std::ffi::c_void/g" \
     -e "s/_XftFont/::std::ffi::c_void/g" \
     -e "s/PangoLayout/::std::ffi::c_void/g" \
     "$1"
