summaryrefslogtreecommitdiff
path: root/ext/ext_skel
diff options
context:
space:
mode:
authorJouni Ahto <jah@php.net>2000-06-15 01:57:23 +0000
committerJouni Ahto <jah@php.net>2000-06-15 01:57:23 +0000
commit495a957c99cc49677979e19920900e2b0a62a76c (patch)
treeb5b3f269bc6d6d3f2362e98291814b03b518b083 /ext/ext_skel
parent9ded807a20a48d4482d21bea8cb4cc24f20f04bc (diff)
downloadphp-git-495a957c99cc49677979e19920900e2b0a62a76c.tar.gz
- Fixed incorrect code generated when all parameters are optional.
- Fixed handling of grouped optional parameters. - Added an option to generate xml documentation. - Added an option not to be nice and helpful and create all kinds of comments and testing functions. - Added on option to create function stubs only. - Added options --assing-params and --string-lens that change the generated code. - Updated documentation.
Diffstat (limited to 'ext/ext_skel')
-rwxr-xr-xext/ext_skel152
1 files changed, 121 insertions, 31 deletions
diff --git a/ext/ext_skel b/ext/ext_skel
index b6235469bb..fb60bf2d81 100755
--- a/ext/ext_skel
+++ b/ext/ext_skel
@@ -1,19 +1,76 @@
#!/bin/sh
-extname="$1"
-EXTNAME=`echo $1|tr a-z A-Z`
-if [ ! -z $2 -a -r $2 ]; then
- functions=$2
- echo=$2
-fi
-
givup() {
echo $*
exit 1
}
-if test "$extname" = ""; then
- givup "usage: $0 extension-name [function-list]"
+usage() {
+echo "$0 --extname=module [--proto=file] [--stubs=file] [--xml[=file]]"
+echo " [--full-xml] [--no-help] [--assign-params [--string-lens]]"
+echo ""
+echo " --extname=module module is the name of your extension"
+echo " --proto=file file contains prototypes of functions to create"
+echo " --stubs=file generate only function stubs in file"
+echo " --xml generate xml documentation to be added to phpdoc-cvs"
+echo " --full-xml generate xml documentation for a self-contained extension"
+echo " (not yet implemented)"
+echo " --no-help don't try to be nice and create comments in the code"
+echo " and helper functions to test if the module compiled"
+echo " --assign-params"
+echo " --string-lens"
+exit 1
+}
+
+if test $# -eq 0; then
+ usage
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ case $1 in
+ --extname=?*)
+ extname=$optarg
+ EXTNAME=`echo $extname | tr a-z A-Z`
+ ;;
+ --proto=?*)
+ proto=$optarg
+ ;;
+ --stubs=*)
+ stubs=yes
+ stubfile=$optarg
+ ;;
+ --xml)
+ xml="yes"
+ ;;
+ --xml=?*)
+ xml=$optarg
+ ;;
+ --full-xml)
+ full_xml="yes"
+ ;;
+ --no-help)
+ no_help="yes"
+ ;;
+ --assign-params)
+ assign_params="yes"
+ ;;
+ --string-lens)
+ string_lens="yes"
+ ;;
+ *)
+ usage
+ ;;
+ esac
+ shift
+done
+
+if [ -z "$assign_params" -a ! -z "$string_lens" ]; then
+ usage
fi
if test -d "$extname" ; then
@@ -32,15 +89,18 @@ else
ECHO_C='\c'
fi
-echo "Creating directory"
+if [ -z $stubs ]; then
+echo "Creating directory $extname"
+stubfile=$extname"/function_stubs"
mkdir $extname || givup "Cannot create directory $extname"
+fi
-if [ ! -z $functions ]; then
- echo $functions
- cat $functions | awk -v extname=$extname -f ./skeleton/create_stubs
+if [ ! -z $proto ]; then
+ cat $proto | awk -v extname=$extname -v stubs=$stubs -v stubfile=$stubfile -v xml=$xml -v full_xml=$full_xml -v i_know_what_to_do_shut_up_i_dont_need_your_help_mode=$no_help -v assign_params=$assign_params -v string_lens=$string_lens -f ./skeleton/create_stubs
fi
+if [ -z $stubs ]; then
cd $extname
chmod 755 .
@@ -102,32 +162,59 @@ libs.mk
eof
$ECHO_N " $extname.c$ECHO_C"
-cat ../skeleton/skeleton.c | sed \
--e "s/extname/$extname/g" \
--e "s/EXTNAME/$EXTNAME/g" \
--e '/__function_entries_here__/r function_entries' \
--e '/__function_stubs_here__/r function_stubs' \
--e '/__function_entries_here__/D' \
--e '/__function_stubs_here__/D' \
-> $extname.c
+echo "s/extname/$extname/g" > sedscript
+echo "s/EXTNAME/$EXTNAME/g" >> sedscript
+echo '/__function_entries_here__/r function_entries' >> sedscript
+echo '/__function_stubs_here__/r function_stubs' >> sedscript
+echo '/__header_here__/r ../../header' >> sedscript
+echo '/__footer_here__/r ../../footer' >> sedscript
+echo '/__function_entries_here__/D' >> sedscript
+echo '/__function_stubs_here__/D' >> sedscript
+echo '/__header_here__/D' >> sedscript
+echo '/__footer_here__/D' >> sedscript
+if [ ! -z $no_help ]; then
+ echo "/confirm_$extname_compiled/D" >> sedscript
+ echo '/Remove the following/,/^\*\//D' >> sedscript
+ echo 's/[[:space:]]\/\*.\+\*\///' >> sedscript
+ echo 's/^\/\*.*\*\/$//' >> sedscript
+ echo '/^[[:space:]]*\/\*/,/^[[:space:]]*\*\//D' >> sedscript
+fi
+
+cat ../skeleton/skeleton.c | sed -f sedscript > $extname.c
+
$ECHO_N " php_$extname.h$ECHO_C"
-cat ../skeleton/php_skeleton.h | sed \
--e "s/extname/$extname/g" \
--e "s/EXTNAME/$EXTNAME/g" \
--e '/__function_declarations_here__/r function_declarations' \
--e '/__function_declarations_here__/D' \
-> php_$extname.h
+echo "s/extname/$extname/g" > sedscript
+echo "s/EXTNAME/$EXTNAME/g" >> sedscript
+echo '/__function_declarations_here__/r function_declarations' >> sedscript
+echo '/__header_here__/r ../../header' >> sedscript
+echo '/__footer_here__/r ../../footer' >> sedscript
+echo '/__function_declarations_here__/D' >> sedscript
+echo '/__header_here__/D' >> sedscript
+echo '/__footer_here__/D' >> sedscript
+if [ ! -z $no_help ]; then
+ echo "/confirm_$extname_compiled/D" >> sedscript
+ echo 's/[[:space:]]\/\*.\+\*\///' >> sedscript
+ echo 's/^\/\*.*\*\/$//' >> sedscript
+ echo '/^[[:space:]]*\/\*/,/^[[:space:]]*\*\//D' >> sedscript
+fi
+cat ../skeleton/php_skeleton.h | sed -f sedscript > php_$extname.h
+
+rm sedscript
+if [ -z "$stubs" -a -z "$no_help" ]; then
$ECHO_N " $extname.php$ECHO_C"
cat ../skeleton/skeleton.php | sed \
-e "s/extname/$extname/g" \
> $extname.php
+fi
-if [ ! -z $functions ]; then
- rm function_entries
- rm function_declarations
- rm function_stubs
+if [ ! -z $proto ]; then
+ if [ -z $stubs ]; then
+ rm function_entries
+ rm function_declarations
+ rm function_stubs
+ fi
if [ -f function_warning ]; then
rm function_warning
warning="
@@ -139,9 +226,11 @@ in the instructions above.
fi
chmod 644 *
+fi
echo " [done]."
+if [ -z "$no_help" -a -z "$stubs" ]; then
cat <<eof
To use your new extension, you will have to execute the following steps:
@@ -160,3 +249,4 @@ step 6 confirms that your module is compiled in PHP. Then, start writing
code and repeat the last two steps as often as necessary.
$warning
eof
+fi