summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-11-13 18:18:05 +0300
committerAndrew Dolgov <[email protected]>2021-11-13 18:18:05 +0300
commitb381e9579295b238d44532a50edb6422b8c6b4ab (patch)
tree0fbc08e8bc7d0a30f8e9ee970e146ca811806dd3 /utils
parent8a83f061bfa907af167090133738c1dc065dc69d (diff)
experimental: auto-generate and add all plugin hook methods to Plugin class
Diffstat (limited to 'utils')
-rw-r--r--utils/generate-plugin-hook-prototypes.sh30
1 files changed, 30 insertions, 0 deletions
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