mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
- 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.
This commit is contained in:
parent
9ded807a20
commit
495a957c99
5 changed files with 401 additions and 152 deletions
|
@ -9,19 +9,26 @@ HOW TO USE IT
|
||||||
|
|
||||||
Very simple. First, cd do directory ext/ in PHP 4 sources. If you just need
|
Very simple. First, cd do directory ext/ in PHP 4 sources. If you just need
|
||||||
the basic framework and will be writing all the code in your functions
|
the basic framework and will be writing all the code in your functions
|
||||||
yourself, you can now do './ext_skel your_module_name' and everything you
|
yourself, you can now do
|
||||||
need is placed in directory your_module_name. In fact, if you don't need to
|
|
||||||
test the existence of any external header files, libraries or functions in
|
./ext_skel --extname=module_name
|
||||||
them, the module is already almost ready to be compiled in PHP. Just remove
|
|
||||||
3 comments in your_module_name/config.m4, cd back up to PHP sources top
|
and everything you need is placed in directory module_name. In fact, if you
|
||||||
directory, and do './buildconf; ./configure --enable-your_module_name; make'.
|
don't need to test the existence of any external header files, libraries or
|
||||||
|
functions in them, the module is already almost ready to be compiled in PHP.
|
||||||
|
Just remove 3 comments in your_module_name/config.m4, cd back up to PHP
|
||||||
|
sources top directory, and do
|
||||||
|
|
||||||
|
./buildconf; ./configure --enable-module_name; make
|
||||||
|
|
||||||
But if you already have planned the overall scheme of your module, what
|
But if you already have planned the overall scheme of your module, what
|
||||||
functions it will contain, their return types and the arguments they take
|
functions it will contain, their return types and the arguments they take
|
||||||
(a very good idea) and don't want to bother yourself with creating function
|
(a very good idea) and don't want to bother yourself with creating function
|
||||||
definitions and handling arguments passed yourself, it's time to create a
|
definitions and handling arguments passed yourself, it's time to create a
|
||||||
function definitions file, which you will give as the second argument to
|
function definitions file, which you will give as an argument to ext_skel
|
||||||
ext_skel.
|
with option
|
||||||
|
|
||||||
|
--proto=filename.
|
||||||
|
|
||||||
FORMAT OF FUNCTION DEFINITIONS FILE
|
FORMAT OF FUNCTION DEFINITIONS FILE
|
||||||
|
|
||||||
|
@ -36,7 +43,7 @@ FORMAT OF FUNCTION DEFINITIONS FILE
|
||||||
Arguments are given in parenthesis after the function name, and are of
|
Arguments are given in parenthesis after the function name, and are of
|
||||||
the form 'argument_type argument_name'. Arguments are separated from each
|
the form 'argument_type argument_name'. Arguments are separated from each
|
||||||
other with a comma and optional space. Argument_type can be one of int,
|
other with a comma and optional space. Argument_type can be one of int,
|
||||||
double, string, array, object or mixed.
|
bool, double, float, string, array, object or mixed.
|
||||||
|
|
||||||
An optional argument is separated from the previous by an optional space,
|
An optional argument is separated from the previous by an optional space,
|
||||||
then '[' and of course comma and optional space, like all the other
|
then '[' and of course comma and optional space, like all the other
|
||||||
|
@ -59,17 +66,71 @@ FORMAT OF FUNCTION DEFINITIONS FILE
|
||||||
The file must contain nothing else but function definitions, no comments or
|
The file must contain nothing else but function definitions, no comments or
|
||||||
empty lines.
|
empty lines.
|
||||||
|
|
||||||
CURRENT LIMITATIONS AND BUGS
|
OTHER OPTIONS
|
||||||
|
|
||||||
Only arguments of types int, float, string and array are handled. For other
|
--no-help
|
||||||
types you must write the code yourself. And for type mixed, it wouldn't even
|
|
||||||
be possible to write anything, because only you know what to expect.
|
By default, ext_skel creates both comments in the source code and a test
|
||||||
|
function to help first time module writers to get started and testing
|
||||||
|
configuring and compiling their module. This option turns off all such things
|
||||||
|
which may just annoy experienced PHP module coders. Especially useful with
|
||||||
|
|
||||||
|
--stubs=file
|
||||||
|
|
||||||
|
which will leave out also all module specific stuff and write just function
|
||||||
|
stubs with function value declarations and passed argument handling, and
|
||||||
|
function entries and definitions at the end of the file, for copying and
|
||||||
|
pasting into an already existing module.
|
||||||
|
|
||||||
|
--assign-params
|
||||||
|
--string-lens
|
||||||
|
|
||||||
|
By default, function proto 'void foo(string bar)' creates the following:
|
||||||
|
...
|
||||||
|
zval **bar;
|
||||||
|
... (zend_get_parameters_ex() called in the middle...)
|
||||||
|
convert_to_string_ex(bar);
|
||||||
|
|
||||||
|
Specifying both of these options changes the generated code to:
|
||||||
|
...
|
||||||
|
zval **bar_arg;
|
||||||
|
int bar_len;
|
||||||
|
char *bar = NULL;
|
||||||
|
... (zend_get_parameters_ex() called in the middle...)
|
||||||
|
convert_to_string_ex(bar_arg);
|
||||||
|
bar = Z_STRVAL_PP(bar_arg);
|
||||||
|
bar_len = Z_STRLEN_PP(bar_arg);
|
||||||
|
|
||||||
|
You shouldn't have to ask what happens if you leave --string-lens out. If you
|
||||||
|
have to, it's questionable whether you should be reading this document.
|
||||||
|
|
||||||
|
--with-xml[=file]
|
||||||
|
|
||||||
|
Creates the basics for phpdoc .xml file.
|
||||||
|
|
||||||
|
--full-xml
|
||||||
|
|
||||||
|
Not implemented yet. When or if there will ever be created a framework for
|
||||||
|
self-contained extensions to use phpdoc system for their documentation, this
|
||||||
|
option enables it on the created xml file.
|
||||||
|
|
||||||
|
CURRENT LIMITATIONS, BUGS AND OTHER ODDITIES
|
||||||
|
|
||||||
|
Only arguments of types int, bool, double, float, string and array are
|
||||||
|
handled. For other types you must write the code yourself. And for type
|
||||||
|
mixed, it wouldn't even be possible to write anything, because only you
|
||||||
|
know what to expect.
|
||||||
|
|
||||||
It doesn't yet handle correctly grouped optional arguments, ie. it thinks
|
It can't handle correctly, and probably never will, variable list of
|
||||||
'type function(type arg1 [, type arg2, type arg3]' to actually be
|
of arguments. (void foo(int bar [, ...])
|
||||||
'type function(type arg1 [, type arg2 [, type arg3]]', so you have to
|
|
||||||
manually correct the switch construct created. But it's nothing more than
|
Don't trust too much the generated code. It tries to be useful in most of
|
||||||
deleting a few 'case ?:' lines and fixing PHP in-source documentation proto.
|
the situations you might encounter, but automatic code generating will never
|
||||||
|
beat a programmer who knows the real situation at hand. axt_skel is generally
|
||||||
|
best suited for quickly generating a wrapper for c-library functions you
|
||||||
|
might want to have available in PHP too.
|
||||||
|
|
||||||
|
This program doesn't have a --help option. It has --no-help instead.
|
||||||
|
|
||||||
EXAMPLE
|
EXAMPLE
|
||||||
|
|
||||||
|
|
154
ext/ext_skel
154
ext/ext_skel
|
@ -1,19 +1,76 @@
|
||||||
#!/bin/sh
|
#!/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() {
|
givup() {
|
||||||
echo $*
|
echo $*
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if test "$extname" = ""; then
|
usage() {
|
||||||
givup "usage: $0 extension-name [function-list]"
|
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
|
fi
|
||||||
|
|
||||||
if test -d "$extname" ; then
|
if test -d "$extname" ; then
|
||||||
|
@ -32,15 +89,18 @@ else
|
||||||
ECHO_C='\c'
|
ECHO_C='\c'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Creating directory"
|
if [ -z $stubs ]; then
|
||||||
|
echo "Creating directory $extname"
|
||||||
|
stubfile=$extname"/function_stubs"
|
||||||
|
|
||||||
mkdir $extname || givup "Cannot create directory $extname"
|
mkdir $extname || givup "Cannot create directory $extname"
|
||||||
|
|
||||||
if [ ! -z $functions ]; then
|
|
||||||
echo $functions
|
|
||||||
cat $functions | awk -v extname=$extname -f ./skeleton/create_stubs
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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
|
cd $extname
|
||||||
chmod 755 .
|
chmod 755 .
|
||||||
|
|
||||||
|
@ -102,32 +162,59 @@ libs.mk
|
||||||
eof
|
eof
|
||||||
|
|
||||||
$ECHO_N " $extname.c$ECHO_C"
|
$ECHO_N " $extname.c$ECHO_C"
|
||||||
cat ../skeleton/skeleton.c | sed \
|
echo "s/extname/$extname/g" > sedscript
|
||||||
-e "s/extname/$extname/g" \
|
echo "s/EXTNAME/$EXTNAME/g" >> sedscript
|
||||||
-e "s/EXTNAME/$EXTNAME/g" \
|
echo '/__function_entries_here__/r function_entries' >> sedscript
|
||||||
-e '/__function_entries_here__/r function_entries' \
|
echo '/__function_stubs_here__/r function_stubs' >> sedscript
|
||||||
-e '/__function_stubs_here__/r function_stubs' \
|
echo '/__header_here__/r ../../header' >> sedscript
|
||||||
-e '/__function_entries_here__/D' \
|
echo '/__footer_here__/r ../../footer' >> sedscript
|
||||||
-e '/__function_stubs_here__/D' \
|
echo '/__function_entries_here__/D' >> sedscript
|
||||||
> $extname.c
|
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"
|
$ECHO_N " php_$extname.h$ECHO_C"
|
||||||
cat ../skeleton/php_skeleton.h | sed \
|
echo "s/extname/$extname/g" > sedscript
|
||||||
-e "s/extname/$extname/g" \
|
echo "s/EXTNAME/$EXTNAME/g" >> sedscript
|
||||||
-e "s/EXTNAME/$EXTNAME/g" \
|
echo '/__function_declarations_here__/r function_declarations' >> sedscript
|
||||||
-e '/__function_declarations_here__/r function_declarations' \
|
echo '/__header_here__/r ../../header' >> sedscript
|
||||||
-e '/__function_declarations_here__/D' \
|
echo '/__footer_here__/r ../../footer' >> sedscript
|
||||||
> php_$extname.h
|
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"
|
$ECHO_N " $extname.php$ECHO_C"
|
||||||
cat ../skeleton/skeleton.php | sed \
|
cat ../skeleton/skeleton.php | sed \
|
||||||
-e "s/extname/$extname/g" \
|
-e "s/extname/$extname/g" \
|
||||||
> $extname.php
|
> $extname.php
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -z $functions ]; then
|
if [ ! -z $proto ]; then
|
||||||
rm function_entries
|
if [ -z $stubs ]; then
|
||||||
rm function_declarations
|
rm function_entries
|
||||||
rm function_stubs
|
rm function_declarations
|
||||||
|
rm function_stubs
|
||||||
|
fi
|
||||||
if [ -f function_warning ]; then
|
if [ -f function_warning ]; then
|
||||||
rm function_warning
|
rm function_warning
|
||||||
warning="
|
warning="
|
||||||
|
@ -139,9 +226,11 @@ in the instructions above.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 644 *
|
chmod 644 *
|
||||||
|
fi
|
||||||
|
|
||||||
echo " [done]."
|
echo " [done]."
|
||||||
|
|
||||||
|
if [ -z "$no_help" -a -z "$stubs" ]; then
|
||||||
cat <<eof
|
cat <<eof
|
||||||
|
|
||||||
To use your new extension, you will have to execute the following steps:
|
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.
|
code and repeat the last two steps as often as necessary.
|
||||||
$warning
|
$warning
|
||||||
eof
|
eof
|
||||||
|
fi
|
||||||
|
|
|
@ -9,39 +9,101 @@ function gobble(s, x)
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
||||||
function convert(i, j)
|
function convert(i, j, t)
|
||||||
{
|
{
|
||||||
type = argtypes[i,j]
|
type = argtypes[i,j]
|
||||||
name = argnames[i,j]
|
name = argnames[i,j]
|
||||||
opt = optionals[i,j]
|
opt = optionals[i,j]
|
||||||
x = ""
|
tabs = x = ""
|
||||||
|
|
||||||
|
for (i = 0; i < t; i++) { tabs = tabs "\t" }
|
||||||
|
|
||||||
if (type == "int") {
|
if (type == "int") {
|
||||||
x = "convert_to_long_ex(" name ");\n"
|
x = tabs "convert_to_long_ex(" name ext ");\n" \
|
||||||
|
(ext? tabs name " = Z_LVAL_PP(" name ext ");\n": "")
|
||||||
|
ints = ints "\tint " name ";\n"
|
||||||
|
} else if (type == "bool") {
|
||||||
|
x = tabs "convert_to_long_ex(" name ext ");\n" \
|
||||||
|
(ext? tabs name " = Z_LVAL_PP(" name ext ");\n": "")
|
||||||
|
ints = ints "\tint " name ";\n"
|
||||||
} else if (type == "double") {
|
} else if (type == "double") {
|
||||||
x = "convert_to_double_ex(" name ");\n"
|
x = tabs "convert_to_double_ex(" name ext ");\n" \
|
||||||
|
(ext? tabs name " = Z_DVAL_PP(" name ext ");\n": "")
|
||||||
|
doubles = doubles "\tdouble " name ";\n"
|
||||||
|
} else if (type == "float") {
|
||||||
|
x = tabs "convert_to_double_ex(" name ext ");\n" \
|
||||||
|
(ext? tabs name " = (float) Z_DVAL_PP(" name ext ");\n": "")
|
||||||
|
floats = floats "\tfloat " name ";\n"
|
||||||
} else if (type == "string") {
|
} else if (type == "string") {
|
||||||
x = "convert_to_string_ex(" name ");\n"
|
x = tabs "convert_to_string_ex(" name ext ");\n" \
|
||||||
|
(ext? tabs name " = Z_STRVAL_PP(" name ext ");\n": "")
|
||||||
|
(ext ? strings = strings "\tchar *" name " = NULL;\n" : 0)
|
||||||
|
if (string_lens) {
|
||||||
|
x = x tabs name "_len = Z_STRLEN_PP(" name ext ");\n"
|
||||||
|
ints = ints "\tint " name "_len;\n"
|
||||||
|
}
|
||||||
} else if (type == "array") {
|
} else if (type == "array") {
|
||||||
x = "convert_to_array_ex(" name ");\n"
|
x = "convert_to_array_ex(" name ext ");\n"
|
||||||
} else if (type == "resource") {
|
} else if (type == "resource") {
|
||||||
if (opt && i) {
|
if (opt && i > -1) {
|
||||||
resources = resources "\tif (argc < " j+1 ") {\n\t\t/* Argument not given, do something before\n\t\t trying to fetch resource " name ". */\n\t}\n\tZEND_FETCH_RESOURCE(???, ???, " name ", " name "_id, \"???\", ???G());\n"
|
resources = resources "\tif (argc < " j+1 ") {\n" \
|
||||||
|
comment("\t\t/* Argument not given, do something before\n\t\t trying to fetch resource " name ". */\n") \
|
||||||
|
"\t}\n\tZEND_FETCH_RESOURCE(???, ???, " name ext ", " name "_id, \"???\", ???G());\n"
|
||||||
} else {
|
} else {
|
||||||
resources = resources "\tZEND_FETCH_RESOURCE(???, ???, " name ", " name "_id, \"???\", ???G());\n"
|
resources = resources "\tZEND_FETCH_RESOURCE(???, ???, " name ext ", " name "_id, \"???\", ???G());\n"
|
||||||
}
|
}
|
||||||
funcvals = funcvals "\tint " name "_id = -1;\n"
|
funcvals = funcvals "\tint " name "_id = -1;\n"
|
||||||
} else {
|
} else {
|
||||||
x = "/* Write your own code here to handle argument " name ". */\n"
|
x = comment("/* Write your own code here to handle argument " name ". */\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x) return x
|
if (x) return x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function comment(s)
|
||||||
|
{
|
||||||
|
if (i_know_what_to_do_shut_up_i_dont_need_your_help_mode) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
name = "[_A-Za-z][_A-Za-z0-9]*"
|
name = "[_A-Za-z][_A-Za-z0-9]*"
|
||||||
type = "int|double|string|bool|array|object|resource|mixed|void"
|
type = "int|double|float|string|bool|array|object|resource|mixed|void"
|
||||||
num_funcs = 0
|
num_funcs = 0
|
||||||
|
|
||||||
|
if (assign_params) ext = "_arg"
|
||||||
|
|
||||||
|
if (xml && xml != "yes") {
|
||||||
|
xmldoc = xml
|
||||||
|
} else {
|
||||||
|
xmldoc = extname "/" extname ".xml"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmlhead = " <reference id=\"ref." extname "\">\n" \
|
||||||
|
" <title> functions</title>\n" \
|
||||||
|
" <titleabbrev></titleabbrev>\n\n"
|
||||||
|
|
||||||
|
xmlfoot = " </reference>\n\n" \
|
||||||
|
"<!-- Keep this comment at the end of the file\n" \
|
||||||
|
"Local variables:\n" \
|
||||||
|
"mode: sgml\n" \
|
||||||
|
"sgml-omittag:t\n" \
|
||||||
|
"sgml-shorttag:t\n" \
|
||||||
|
"sgml-minimize-attributes:nil\n" \
|
||||||
|
"sgml-always-quote-attributes:t\n" \
|
||||||
|
"sgml-indent-step:1\n" \
|
||||||
|
"sgml-indent-data:t\n" \
|
||||||
|
"sgml-parent-document:nil\n" \
|
||||||
|
"sgml-default-dtd-file:\"../../manual.ced\"\n" \
|
||||||
|
"sgml-exposed-tags:nil\n" \
|
||||||
|
"sgml-local-catalogs:nil\n" \
|
||||||
|
"sgml-local-ecat-files:nil\n" \
|
||||||
|
"End:\n" \
|
||||||
|
"-->\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -72,7 +134,11 @@ BEGIN {
|
||||||
optional++
|
optional++
|
||||||
}
|
}
|
||||||
|
|
||||||
gobble(",")
|
y = gobble(",")
|
||||||
|
if (!x && y && optional) {
|
||||||
|
check_argc_in_switch[num_funcs] = 1
|
||||||
|
grouped_optional_param[num_funcs,i] = 1
|
||||||
|
}
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,24 +152,44 @@ BEGIN {
|
||||||
}
|
}
|
||||||
|
|
||||||
END {
|
END {
|
||||||
|
if (xml) print xmlhead > xmldoc
|
||||||
for (i = 0; i < num_funcs; i++) {
|
for (i = 0; i < num_funcs; i++) {
|
||||||
|
|
||||||
compareargc = maxargs[i] - minargs[i]
|
compareargc = maxargs[i] - minargs[i]
|
||||||
funcvals = resources = handleargs = closeopts = ""
|
closefetch = xmlparams = funcvals = resources = handleargs = closeopts = ""
|
||||||
|
ints = doubles = floats = strings = arrays = ""
|
||||||
|
|
||||||
proto = "/* {{{ proto " types[i] " " funcs[i] "("
|
proto = "/* {{{ proto " types[i] " " funcs[i] "("
|
||||||
|
|
||||||
|
|
||||||
|
refid = funcs[i]
|
||||||
|
gsub(/_/, "-", refid)
|
||||||
|
xmlstr = " <refentry id=\"function." refid "\">\n" \
|
||||||
|
" <refnamediv>\n" \
|
||||||
|
" <refname>" funcs[i] "</refname>\n" \
|
||||||
|
" <refpurpose></refpurpose>\n" \
|
||||||
|
" </refnamediv>\n" \
|
||||||
|
" <refsect1>\n" \
|
||||||
|
" <title>Description</title>\n" \
|
||||||
|
" <funcsynopsis>\n" \
|
||||||
|
" <funcdef>" types[i] " <function>" funcs[i] "</function></funcdef>\n"
|
||||||
|
|
||||||
if (maxargs[i]) {
|
if (maxargs[i]) {
|
||||||
zvals = "\tzval "
|
zvals = "\tzval "
|
||||||
if (compareargc) {
|
if (compareargc) {
|
||||||
funcvals = "\tint argc;\n"
|
funcvals = "\tint argc;\n"
|
||||||
if (minargs[i]) {
|
if (minargs[i]) {
|
||||||
fetchargs = "\targc = ZEND_NUM_ARGS();\n\tif (argc < " minargs[i] " || argc > " maxargs[i] " || zend_get_parameters_ex(argc, "
|
fetchargs = "\targc = ZEND_NUM_ARGS();\n\tif (argc < " \
|
||||||
|
minargs[i] " || argc > " maxargs[i] \
|
||||||
|
" || zend_get_parameters_ex(argc, "
|
||||||
} else {
|
} else {
|
||||||
fetchargs = "\targc = ZEND_NUM_ARGS();\n\tif ((argc && argc < " maxargs[i]+1 " || zend_get_parameters_ex(argc, "
|
fetchargs = "\targc = ZEND_NUM_ARGS();\n\tif (argc > " \
|
||||||
|
maxargs[i] " || (argc && zend_get_parameters_ex(argc, "
|
||||||
|
closefetch = ")"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fetchargs = "\tif (ZEND_NUM_ARGS() != " maxargs[i] " || zend_get_parameters_ex(" maxargs[i] ", "
|
fetchargs = "\tif (ZEND_NUM_ARGS() != " maxargs[i] \
|
||||||
|
" || zend_get_parameters_ex(" maxargs[i] ", "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,63 +200,122 @@ END {
|
||||||
fetchargs = fetchargs ", "
|
fetchargs = fetchargs ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
zvals = zvals "**" argnames[i,j]
|
zvals = zvals "**" argnames[i,j] ext
|
||||||
fetchargs = fetchargs "&" argnames[i,j]
|
fetchargs = fetchargs "&" argnames[i,j] ext
|
||||||
|
|
||||||
|
xmlparams = xmlparams " <paramdef>" argtypes[i,j]
|
||||||
if (j > minargs[i]-1) {
|
if (j > minargs[i]-1) {
|
||||||
if (j) proto = proto " "
|
if (!grouped_optional_param[i,j-1]) {
|
||||||
proto = proto "["
|
if (j > 0) proto = proto " "
|
||||||
closeopts = closeopts "]"
|
proto = proto "["
|
||||||
|
closeopts = closeopts "]"
|
||||||
|
}
|
||||||
|
xmlparams = xmlparams "\n <parameter><optional>" \
|
||||||
|
argnames[i,j] \
|
||||||
|
"</optional></parameter>\n </paramdef>\n"
|
||||||
|
} else {
|
||||||
|
xmlparams = xmlparams \
|
||||||
|
" <parameter>" \
|
||||||
|
argnames[i,j] \
|
||||||
|
"</parameter></paramdef>\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j > 0) proto = proto ", "
|
if (j > 0) proto = proto ", "
|
||||||
proto = proto argtypes[i,j] " " argnames[i,j]
|
proto = proto argtypes[i,j] " " argnames[i,j]
|
||||||
|
|
||||||
code = convert(i, j)
|
# code = convert(i, j)
|
||||||
|
|
||||||
|
# Clean up this mess...
|
||||||
|
|
||||||
if (useswitch[i]) {
|
if (useswitch[i]) {
|
||||||
if (j > minargs[i]-1) {
|
if (grouped_optional_param[i,j] && code) {
|
||||||
if (code) {
|
handleargs = convert(i, j, 3) \
|
||||||
handleargs = "\t\tcase " j+1 ":\n\t\t\t" code "\t\t\t/* Fall-through. */\n" handleargs
|
((grouped_optional_param[i,j-1]) ? "" : comment("\t\t\t/* Fall-through. */\n")) \
|
||||||
} else {
|
handleargs
|
||||||
handleargs = "\t\tcase " j+1 ":\t/* Fall-through. */\n" handleargs
|
|
||||||
}
|
|
||||||
} else if (j >= minargs[i]-1) {
|
|
||||||
if (code) {
|
|
||||||
handleargs = "\t\tcase " j+1 ":\n\t\t\t" code handleargs
|
|
||||||
} else {
|
|
||||||
handleargs = "\t\tcase " j+1 ":\n" handleargs
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
handleargs = "\t\t\t" code handleargs
|
if (j > minargs[i]-1) {
|
||||||
|
if (code = convert(i, j, 3)) {
|
||||||
|
handleargs = "\t\tcase " j+1 ":\n" code \
|
||||||
|
((grouped_optional_param[i,j-1]) ? "" : comment("\t\t\t/* Fall-through. */\n")) \
|
||||||
|
handleargs
|
||||||
|
} else {
|
||||||
|
handleargs = "\t\tcase " j+1 ":" \
|
||||||
|
comment("\t/* Fall-through. */") \
|
||||||
|
"\n" handleargs
|
||||||
|
}
|
||||||
|
} else if (j >= minargs[i]-1) {
|
||||||
|
if (code = convert(i, j, 3)) {
|
||||||
|
handleargs = "\t\tcase " j+1 ":\n" code handleargs
|
||||||
|
} else {
|
||||||
|
handleargs = "\t\tcase " j+1 ":\n" handleargs
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (code = convert(i, j, 3)) handleargs = code handleargs
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (code) handleargs = handleargs "\t" code
|
if (code = convert(i, j, 1)) handleargs = handleargs code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proto = proto closeopts ")\n */\nPHP_FUNCTION(" funcs[i] ")\n{"
|
proto = proto closeopts ")\n */\nPHP_FUNCTION(" funcs[i] ")\n{"
|
||||||
if (maxargs[i]) {
|
if (maxargs[i]) {
|
||||||
zvals = zvals ";"
|
zvals = zvals ";"
|
||||||
fetchargs = fetchargs ") == FAILURE) {\n\t\tWRONG_PARAM_COUNT;\n\t}\n"
|
fetchargs = fetchargs ") == FAILURE)" closefetch "{\n\t\tWRONG_PARAM_COUNT;\n\t}\n"
|
||||||
}
|
}
|
||||||
if (resources ) funcvals = funcvals "\t???LS_FETCH();\n"
|
funcvals = ints doubles floats strings funcvals
|
||||||
if (useswitch[i]) handleargs = "\tswitch (argc) {\n" handleargs "\t\t\tbreak;\n\t\tdefault:\n\t\t\tWRONG_PARAM_COUNT;\n\t}"
|
if (resources) funcvals = funcvals "\t???LS_FETCH();\n"
|
||||||
|
if (useswitch[i]) {
|
||||||
|
if (check_argc_in_switch[i]) {
|
||||||
|
check_argc = "\t\tdefault:\n\t\t\tWRONG_PARAM_COUNT;\n"
|
||||||
|
} else {
|
||||||
|
check_argc = ""
|
||||||
|
}
|
||||||
|
handleargs = "\tswitch (argc) {\n" \
|
||||||
|
handleargs \
|
||||||
|
(minargs[i] ? "" : "\t\tcase 0:\n") \
|
||||||
|
"\t\t\tbreak;\n" check_argc "\t}"
|
||||||
|
}
|
||||||
|
xmlstr = xmlstr xmlparams \
|
||||||
|
" </funcsynopsis>\n" \
|
||||||
|
" <para>\n" \
|
||||||
|
" </para>\n" \
|
||||||
|
" </refsect1>\n" \
|
||||||
|
" </refentry>\n"
|
||||||
|
|
||||||
print proto > extname "/function_stubs"
|
print proto > stubfile
|
||||||
if (zvals) print zvals > extname "/function_stubs"
|
if (zvals) print zvals > stubfile
|
||||||
if (funcvals) print funcvals > extname "/function_stubs"
|
if (funcvals) print funcvals > stubfile
|
||||||
if (fetchargs) print fetchargs > extname "/function_stubs"
|
if (fetchargs) print fetchargs > stubfile
|
||||||
if (resources) {
|
if (resources) {
|
||||||
print resources > extname "/function_stubs"
|
print resources > stubfile
|
||||||
print "" > extname "/function_warning"
|
if (!stubs) print "" > extname "/function_warning"
|
||||||
}
|
}
|
||||||
if (handleargs) print handleargs > extname "/function_stubs"
|
if (handleargs) print handleargs > stubfile
|
||||||
print "\n\tphp_error(E_WARNING, \"" funcs[i] ": not yet implemented\");" > extname "/function_stubs"
|
if (!i_know_what_to_do_shut_up_i_dont_need_your_help_mode) {
|
||||||
print "}\n/* }}} */\n" > extname "/function_stubs"
|
print "\n\tphp_error(E_WARNING, \"" funcs[i] ": not yet implemented\");" > stubfile
|
||||||
print "PHP_FUNCTION(" funcs[i] ");" > extname "/function_declarations"
|
}
|
||||||
print "\tPHP_FE(" funcs[i] ",\tNULL)" > extname "/function_entries"
|
print "}\n/* }}} */\n" > stubfile
|
||||||
|
|
||||||
|
if (stubs) {
|
||||||
|
h_stubs = h_stubs "PHP_FUNCTION(" funcs[i] ");\n"
|
||||||
|
c_stubs = c_stubs "\tPHP_FE(" funcs[i] ",\tNULL)\n"
|
||||||
|
} else {
|
||||||
|
print "PHP_FUNCTION(" funcs[i] ");" > extname "/function_declarations"
|
||||||
|
print "\tPHP_FE(" funcs[i] ",\tNULL)" > extname "/function_entries"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xml) print xmlstr > xmldoc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stubs) {
|
||||||
|
print "\n/* ----------------------------------------------------------- */\n" > stubfile
|
||||||
|
print c_stubs > stubfile
|
||||||
|
print "\n/* ----------------------------------------------------------- */\n" > stubfile
|
||||||
|
print h_stubs > stubfile
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xml) print xmlfoot > xmldoc
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,22 +1,4 @@
|
||||||
/*
|
/* __header_here__ */
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
| PHP version 4.0 |
|
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
|
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
| This source file is subject to version 2.02 of the PHP license, |
|
|
||||||
| that is bundled with this package in the file LICENSE, and is |
|
|
||||||
| available at through the world-wide-web at |
|
|
||||||
| http://www.php.net/license/2_02.txt. |
|
|
||||||
| If you did not receive a copy of the PHP license and are unable to |
|
|
||||||
| obtain it through the world-wide-web, please send a note to |
|
|
||||||
| license@php.net so we can mail you a copy immediately. |
|
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
| Authors: |
|
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id: */
|
|
||||||
|
|
||||||
#ifndef _PHP_EXTNAME_H
|
#ifndef _PHP_EXTNAME_H
|
||||||
#define _PHP_EXTNAME_H
|
#define _PHP_EXTNAME_H
|
||||||
|
@ -79,9 +61,4 @@ typedef struct {
|
||||||
|
|
||||||
#endif /* _PHP_EXTNAME_H */
|
#endif /* _PHP_EXTNAME_H */
|
||||||
|
|
||||||
/*
|
/* __footer_here__ */
|
||||||
* Local variables:
|
|
||||||
* tab-width: 4
|
|
||||||
* c-basic-offset: 4
|
|
||||||
* End:
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,22 +1,4 @@
|
||||||
/*
|
/* __header_here__ */
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
| PHP version 4.0 |
|
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
|
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
| This source file is subject to version 2.02 of the PHP license, |
|
|
||||||
| that is bundled with this package in the file LICENSE, and is |
|
|
||||||
| available at through the world-wide-web at |
|
|
||||||
| http://www.php.net/license/2_02.txt. |
|
|
||||||
| If you did not receive a copy of the PHP license and are unable to |
|
|
||||||
| obtain it through the world-wide-web, please send a note to |
|
|
||||||
| license@php.net so we can mail you a copy immediately. |
|
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
| Authors: |
|
|
||||||
+----------------------------------------------------------------------+
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id: */
|
|
||||||
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "php_ini.h"
|
#include "php_ini.h"
|
||||||
|
@ -102,8 +84,7 @@ PHP_MINFO_FUNCTION(extname)
|
||||||
|
|
||||||
/* Remove the following function when you have succesfully modified config.m4
|
/* Remove the following function when you have succesfully modified config.m4
|
||||||
so that your module can be compiled into PHP, it exists only for testing
|
so that your module can be compiled into PHP, it exists only for testing
|
||||||
purposes.
|
purposes. */
|
||||||
*/
|
|
||||||
|
|
||||||
/* Every user-visible function in PHP should document itself in the source */
|
/* Every user-visible function in PHP should document itself in the source */
|
||||||
/* {{{ proto string confirm_extname_compiled(string arg)
|
/* {{{ proto string confirm_extname_compiled(string arg)
|
||||||
|
@ -134,9 +115,4 @@ PHP_FUNCTION(confirm_extname_compiled)
|
||||||
|
|
||||||
#endif /* HAVE_EXTNAME */
|
#endif /* HAVE_EXTNAME */
|
||||||
|
|
||||||
/*
|
/* __footer_here__ */
|
||||||
* Local variables:
|
|
||||||
* tab-width: 4
|
|
||||||
* c-basic-offset: 4
|
|
||||||
* End:
|
|
||||||
*/
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue