cvs: php4 / README.EXT_SKEL /ext/skeleton/ create_stubs

From: Date: Sat, 10 Jun 2000 09:45:27 +0000
Subject: cvs: php4 / README.EXT_SKEL /ext/skeleton/ create_stubs
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142@lists.php.net to get a copy of this message
jah Sat Jun 10 02:45:27 2000 EDT Modified files: /php4 README.EXT_SKEL /php4/ext/skeleton create_stubs Log: - Fix incorrect code creation when an optional argument is resource type. Index: php4/README.EXT_SKEL diff -u php4/README.EXT_SKEL:1.1 php4/README.EXT_SKEL:1.2 --- php4/README.EXT_SKEL:1.1 Sat Jun 10 01:59:43 2000 +++ php4/README.EXT_SKEL Sat Jun 10 02:45:27 2000 @@ -71,9 +71,6 @@ manually correct the switch construct created. But it's nothing more than deleting a few 'case ?:' lines and fixing PHP in-source documentation proto. - It creates incorrect code to handle arguments passed to function when an - optional argument is of type 'resource'. - EXAMPLE The following _one_ line Index: php4/ext/skeleton/create_stubs diff -u php4/ext/skeleton/create_stubs:1.2 php4/ext/skeleton/create_stubs:1.3 --- php4/ext/skeleton/create_stubs:1.2 Fri Jun 9 22:47:22 2000 +++ php4/ext/skeleton/create_stubs Sat Jun 10 02:45:27 2000 @@ -9,7 +9,7 @@ return x } -function convert(t, n) +function convert(t, n, o, i) { if (t == "int") x = "convert_to_long_ex(" n ");\n" else if (t == "double") x = "convert_to_double_ex(" n ");\n" @@ -17,7 +17,11 @@ else if (t == "array") x = "convert_to_array_ex(" n ");\n" else if (t == "resource") { x = "/* " n ": fetching resources already handled. */\n" - resources = resources "\tZEND_FETCH_RESOURCE(???, ???, " n ", " n "_id, \"???\", ???G());\n" + if (o) { + resources = resources "\tif (argc > " i ") {\n\t\tZEND_FETCH_RESOURCE(???, ???, " n ", " n "_id, \"???\", ???G());\n\t}\n" + } else { + resources = resources "\tZEND_FETCH_RESOURCE(???, ???, " n ", " n "_id, \"???\", ???G());\n" + } funcvals = funcvals "\tint " n "_id = -1;\n" } else x = "/* You must write your own code here to handle argument " n ". */\n" @@ -31,7 +35,7 @@ } { - args_max = args_min = optional = 0 + args_max = args_min = optional = i = 0 line = $0 func_type = gobble(type); @@ -45,10 +49,16 @@ argnames[num_funcs,args_max] = arg_name args_max++ - if (!optional) args_min++ + if (optional) { + optionals[num_funcs,i] = optional + } else { + args_min++ + } + + if (gobble("\\[")) optional++ - if (gobble("\\[")) optional = 1 gobble(",") + i++ } } @@ -98,14 +108,14 @@ if (useswitch) { if (j > minargs[i]-1) { - handleargs = "\t\tcase " j+1 ":\n\t\t\t" convert(argtypes[i,j], argnames[i,j]) "\t\t\t/* Fall-through. */\n" handleargs + handleargs = "\t\tcase " j+1 ":\n\t\t\t" convert(argtypes[i,j], argnames[i,j], optionals[i,j], j) "\t\t\t/* Fall-through. */\n" handleargs } else if (j >= minargs[i]-1) { - handleargs = "\t\tcase " j+1 ":\n\t\t\t" convert(argtypes[i,j], argnames[i,j]) handleargs + handleargs = "\t\tcase " j+1 ":\n\t\t\t" convert(argtypes[i,j], argnames[i,j], optionals[i,j], j) handleargs } else { - handleargs = "\t\t\t" convert(argtypes[i,j], argnames[i,j]) handleargs + handleargs = "\t\t\t" convert(argtypes[i,j], argnames[i,j], optionals[i,j], j) handleargs } } else { - handleargs = handleargs "\t" convert(argtypes[i,j], argnames[i,j]) + handleargs = handleargs "\t" convert(argtypes[i,j], argnames[i,j], optionals[i,j], j) } }

« previous php.cvs (#142) next »