#!/bin/bash -e

if [ $# -lt 1 ]; then
    echo "Wrong parameters. Usage: ${0} <srcdir>"
    exit 1
fi

SRCDIR="${1}"
find "${SRCDIR}" -type f -name "*.mojom" | while read file; do
  sed --in-place --regexp-extended \
    -e 's/pending_remote<(.*)>/\1/g' \
    -e 's/pending_receiver<(.*)>/\1\&/g' \
    -e 's/pending_associated_remote<(.*)>/associated \1/g' \
    -e 's/pending_associated_receiver<(.*)>/associated \1\&/g' \
    "${file}"
done

echo "All done."
exit 0
