cvs: php4 /ext/ ext_skel /ext/skeleton/ create_stubs
| From: | Jouni Ahto | Date: | Sat, 10 Jun 2000 03:53:11 +0000 |
| Subject: | cvs: php4 /ext/ ext_skel /ext/skeleton/ create_stubs | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-132@lists.php.net to get a copy of this message | ||
jah Fri Jun 9 20:53:11 2000 EDT
Added files:
/php4/ext/skeleton create_stubs
Modified files:
/php4/ext ext_skel
Log:
- Automatically generate C code to handle arguments passed to a PHP function
based on function proto.
# Very cool! Try yourself, put for example the following line in file funcs:
# bool drawtext(string text, resource font, int x, int y [, resource color])
# and then run ./ext_skel foobar /full/path/to/funcs and then look at
# foobar.c...
Index: php4/ext/ext_skel
diff -u php4/ext/ext_skel:1.20 php4/ext/ext_skel:1.21
--- php4/ext/ext_skel:1.20 Fri Jun 9 11:04:17 2000
+++ php4/ext/ext_skel Fri Jun 9 20:53:11 2000
@@ -3,7 +3,8 @@
extname="$1"
EXTNAME=
echo $1|tr a-z A-Z
if [ ! -z $2 -a -r $2 ]; then
- functions=cat $2
+ functions=$2
+ echo=$2
fi
givup() {
@@ -12,7 +13,7 @@
}
if test "$extname" = ""; then
- givup "usage: $0 extension-name [function-names]"
+ givup "usage: $0 extension-name [/full/path/to/function-list]"
fi
if test -d "$extname" ; then
@@ -20,6 +21,7 @@
fi
test -f ext_skel || givup "ext_skel must be in the current directory"
+test -d skeleton || givup "subdirectory skeleton does not exist or is not directory"
if echo '\c' | grep -s c >/dev/null 2>&1
then
@@ -39,33 +41,8 @@
cd $extname
chmod 755 .
-touch function_entries
-touch function_declarations
-touch function_stubs
-
-if [ $2 ] ; then
- cat > function_stubs <<EOF
-/* Don't forget to remove the '#'-mark before protos when you have finished
- with your function, so PHP's documentation system recognizes it. And
- you really documented your function, didn't you?
-*/
-
-EOF
- for f in $functions; do
- $ECHO_E "\tPHP_FE($f,\tNULL)" >> function_entries
- $ECHO_E "PHP_FUNCTION($f);" >> function_declarations
- cat >> function_stubs <<EOF
-
-/* {{{ #proto $f()
- */
-PHP_FUNCTION($f)
-{
- php_error(E_WARNING, "$f: not yet implemented");
-}
-/* }}} */
-
-EOF
- done
+if [ ! -z $functions ]; then
+ cat $functions | awk -f ../skeleton/create_stubs
fi
$ECHO_N "Creating basic files:$ECHO_C"
@@ -148,9 +125,11 @@
-e "s/extname/$extname/g" \
> $extname.php
-rm function_entries
-rm function_declarations
-rm function_stubs
+if [ ! -z $functions ]; then
+ rm function_entries
+ rm function_declarations
+ rm function_stubs
+fi
chmod 644 *