From b381e9579295b238d44532a50edb6422b8c6b4ab Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Nov 2021 18:18:05 +0300 Subject: experimental: auto-generate and add all plugin hook methods to Plugin class --- utils/generate-plugin-hook-prototypes.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 utils/generate-plugin-hook-prototypes.sh (limited to 'utils/generate-plugin-hook-prototypes.sh') diff --git a/utils/generate-plugin-hook-prototypes.sh b/utils/generate-plugin-hook-prototypes.sh new file mode 100644 index 000000000..586f3f2c6 --- /dev/null +++ b/utils/generate-plugin-hook-prototypes.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +TMPFILE=$(mktemp) + +grep 'hook_.*(' ../classes/pluginhost.php | sed -e 's#[\t ]*/[* ]*##' \ + -e 's# [*]/$##' \ + -e 's# *(byref) *##' \ + -e 's#GLOBAL: ##' | while read F; do + + cat << EOF >> $TMPFILE + function $F { + user_error("Dummy method invoked.", E_USER_ERROR); + } + +EOF +done + +cat ../classes/plugin.tpl | while IFS=\n read L; do + case $L in + *AUTO_GENERATED_HOOKS_GO_HERE* ) + echo "\t/* plugin hook methods (auto-generated) */\n" + cat $TMPFILE + ;; + * ) + echo "$L" + ;; + esac +done > ../classes/plugin.php + +rm -f -- $TMPFILE -- cgit v1.2.3