cvs: pearweb /include pear-database.php signatures.php xmlrpc-methods.php /public_html test.php

From: Date: Sun, 04 Nov 2001 00:41:00 +0000
Subject: cvs: pearweb /include pear-database.php signatures.php xmlrpc-methods.php /public_html test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1251@lists.php.net to get a copy of this message
ssb Sat Nov 3 19:41:00 2001 EDT Modified files: /pearweb/include pear-database.php signatures.php xmlrpc-methods.php /pearweb/public_html test.php Log: * initial version of xmlrpc introspection (auto-generated xmlrpc docs) Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.28 pearweb/include/pear-database.php:1.29 --- pearweb/include/pear-database.php:1.28 Wed Oct 31 01:21:10 2001 +++ pearweb/include/pear-database.php Sat Nov 3 19:41:00 2001 @@ -295,15 +295,18 @@ } // }}} - // {{{ proto bool release::upload(string, string, string, binary, string) + // {{{ proto bool release::upload(string, string, string, string, binary, string) - function upload($package, $version, $relnotes, &$tarball, $md5sum) + function upload($package, $version, $state, $relnotes, &$tarball, $md5sum) { global $dbh, $auth_user; // (2) verify that package exists $test = $dbh->getOne("SELECT name FROM packages WHERE name = ?", array($package)); + if (PEAR::isError($test)) { + return $test; + } if (empty($test)) { return PEAR::raiseError("no such package: $package"); } @@ -312,6 +315,9 @@ $test = $dbh->getOne("SELECT version FROM releases ". "WHERE package = ? AND version = ?", array($package, $version)); + if (PEAR::isError($test)) { + return $test; + } if ($test) { return PEAR::raiseError("already exists: $package $version"); } Index: pearweb/include/signatures.php diff -u pearweb/include/signatures.php:1.4 pearweb/include/signatures.php:1.5 --- pearweb/include/signatures.php:1.4 Fri Oct 26 07:45:25 2001 +++ pearweb/include/signatures.php Sat Nov 3 19:41:00 2001 @@ -13,14 +13,13 @@ // format: array( array(returntype, methodname, paramlist), ... ) settype($signatures, "array"); $matches = array(); - if (preg_match_all('/proto\s+([a-z|]+)\s+([a-zA-Z0-9_:]+)\s*\(([^\)]*)\)\s*?\n(\s*?\/\/\s*?(.*?)\s*?\n)?/s', + if (preg_match_all('/proto\s+([a-z|]+)\s+([a-zA-Z0-9_:]+)\s*\(([^\)]*)\)\s*?\n(\s*?\/\/\s+?(.*?)\s*?\n)?/s', $contents, $matches)) { for ($i = 0; $i < sizeof($matches[0]); $i++) { - $return_type = $matches[1][$i]; - $method_name = $matches[2][$i]; - $parameters = $matches[3][$i]; -// $docstrings = $matches[5][$i]; // XXX unfinished - //print "signature: $return_type <b>$method_name</b>($parameters)<br />\n"; + $return_type = $matches[1][$i]; + $method_name = $matches[2][$i]; + $parameters = $matches[3][$i]; + //$purpose = @$matches[5][$i]; // XXX unfinished $return_type_permutations = explode("|", $return_type); $xmlrpc_method = str_replace("::", ".", $method_name); $param_list = preg_split('/\s*,\s*/', $parameters); @@ -56,7 +55,6 @@ } $params[$j] = $param_variations[$j][0]; } - //print "$nump params, $v variations<br>\n"; if (sizeof($varyat) > 0) { _signature_worker($paramlist_permutations, $params, $varyat, $param_variations); } else { @@ -64,6 +62,7 @@ } } if ($out_format == "full_description") { + // XXX this format is still buggy foreach ($return_type_permutations as $ret_type) { foreach ($paramlist_permutations as $paramlist => $dummy) { foreach (explode(",", $paramlist) as $ind => $pp) { @@ -82,12 +81,13 @@ } } else { foreach ($return_type_permutations as $ret_type) { - foreach ($paramlist_permutations as $paramlist => $dummy) { - $signatures[] = array($xmlrpc_method, $ret_type, $paramlist); - } + $signatures[] = array( + "method_name" => $xmlrpc_method, + "return_type" => $ret_type, + "param_types" => array_keys($paramlist_permutations), + ); } } - //print "<br>\n"; } } return true; Index: pearweb/include/xmlrpc-methods.php diff -u pearweb/include/xmlrpc-methods.php:1.7 pearweb/include/xmlrpc-methods.php:1.8 --- pearweb/include/xmlrpc-methods.php:1.7 Wed Oct 31 01:21:10 2001 +++ pearweb/include/xmlrpc-methods.php Sat Nov 3 19:41:00 2001 @@ -2,7 +2,8 @@ require_once "signatures.php"; -parse_signatures_from_file("../include/pear-database.php", &$xmlrpc_method_index, "index"); +parse_signatures_from_file("../include/pear-database.php", + &$xmlrpc_method_index, "index"); function pear_register_xmlrpc_methods($xs) { @@ -11,6 +12,7 @@ // error_log("registering $method"); xmlrpc_server_register_method($xs, $method, "pear_xmlrpc_dispatcher"); } + xmlrpc_server_register_introspection_callback($xs, "pear_xmlrpc_introspection_callback"); } function pear_xmlrpc_dispatcher($method_name, $params, $appdata) @@ -51,6 +53,45 @@ error_log("$method_name returned ".ob_get_contents()); ob_end_clean(); */ + return $ret; +} + + +function pear_xmlrpc_introspection_callback($userdata) +{ + parse_signatures_from_file("../include/pear-database.php", &$signatures, + "signatures"); + $ret = "<introspection version='1.0'>\n"; + $ret .= " <methodList>\n"; + foreach ($signatures as $sig) { + $ret .= " <methodDescription name='$sig[method_name]'>\n"; + $ret .= " <author/>\n"; + $ret .= " <purpose/>\n"; + $ret .= " <signatures>\n"; + foreach ($sig["param_types"] as $params) { + $ret .= " <signature>\n"; + $ret .= " <params>\n"; + $paramlist = explode(",", $params); + foreach ($paramlist as $param) { + $ret .= " <value type='$param'/>\n"; + } + $ret .= " </params>\n"; + $ret .= " <returns>\n"; + $ret .= " <value type='$sig[return_type]'/>\n"; + $ret .= " </returns>\n"; + $ret .= " </signature>\n"; + } + $ret .= " </signatures>\n"; + $ret .= " <see/>\n"; + $ret .= " <examples/>\n"; + $ret .= " <errors/>\n"; + $ret .= " <notes/>\n"; + $ret .= " <bugs/>\n"; + $ret .= " <todo/>\n"; + $ret .= " </methodDescription>\n"; + } + $ret .= " </methodList>\n"; + $ret .= "</introspection>\n"; return $ret; } Index: pearweb/public_html/test.php diff -u pearweb/public_html/test.php:1.4 pearweb/public_html/test.php:1.5 --- pearweb/public_html/test.php:1.4 Fri Oct 5 05:15:41 2001 +++ pearweb/public_html/test.php Sat Nov 3 19:41:00 2001 @@ -2,19 +2,42 @@ require_once "signatures.php"; -$signatures = parse_signatures_from_file("../include/pear-database.php", "index"); -print "<pre>"; -//var_dump($signatures); -print "</pre>\n"; +parse_signatures_from_file("../include/pear-database.php", &$signatures, + "signatures"); -class foo { - function bar($str) { - return "bing: $str"; +print "<pre>"; +$ret = "<introspection version='1.0'>\n"; +$ret .= " <methodList>\n"; +foreach ($signatures as $sig) { + $ret .= " <methodDescription name='$sig[method_name]'>\n"; + $ret .= " <author/>\n"; + $ret .= " <purpose/>\n"; + $ret .= " <signatures>\n"; + foreach ($sig["param_types"] as $params) { + $ret .= " <signature>\n"; + $ret .= " <params>\n"; + $paramlist = explode(",", $params); + foreach ($paramlist as $param) { + $ret .= " <value type='$param'/>\n"; + } + $ret .= " </params>\n"; + $ret .= " <returns>\n"; + $ret .= " <value type='$sig[return_type]'/>\n"; + $ret .= " </returns>\n"; + $ret .= " </signature>\n"; } + $ret .= " </signatures>\n"; + $ret .= " <see/>\n"; + $ret .= " <examples/>\n"; + $ret .= " <errors/>\n"; + $ret .= " <notes/>\n"; + $ret .= " <bugs/>\n"; + $ret .= " <todo/>\n"; + $ret .= " </methodDescription>\n"; } - -$params = array("gazonk"); -$func = "foo"; -var_dump(@call_user_method_array("bar", $func, $params)); +$ret .= " </methodList>\n"; +$ret .= "</introspection>\n"; +print htmlspecialchars($ret); +print "</pre>\n"; ?>

« previous php.pear.cvs (#1251) next »