From 68ec3575595f25873fb5b80e7bec59de04b8b4c2 Mon Sep 17 00:00:00 2001
From: rurban
+if you know of any other servers that support interop tests, please send a note to
+ xmlrpc-epi-devel@lists.sourceforge.net
+ and we will add it to the list.
+END;
+
+}
+
+// some code which determines if we are in form display or response mode.
+$server_list = get_interop_servers();
+$server = get_server_from_user($server_list);
+if ($server) {
+ $debug = $GLOBALS['HTTP_GET_VARS']['debug'] || $GLOBALS['HTTP_GET_VARS']['start_debug'];
+ $output['version'] = $GLOBALS['HTTP_GET_VARS']['version'];
+ if ($server) {
+ $title = $server['title'];
+ echo "
";
+}
+
+function fail($method, $sent, $received) {
+ echo "fail $method()
";
+ if ($sent) {
+ echo "sent
received
";
+ $params = array($args);
+ $result = xu_rpc_http_concise(array(method => $method,
+ args => $params,
+ host => $server[host],
+ uri => $server[uri],
+ port => $server[port],
+ debug => $debug,
+ output => $output));
+ check_if_matches($method, $args, $result);
+ echo "";
+ flush();
+}
+
+function run_no_param_test($server, $debug, $output, $method) {
+ echo "
";
+ $result = xu_rpc_http_concise(array(method => $method,
+ host => $server[host],
+ uri => $server[uri],
+ port => $server[port],
+ debug => $debug,
+ output => $output));
+
+ if($result && gettype($result) === "integer") {
+ pass($method);
+ }
+ else {
+ fail($method, false, $result);
+ }
+
+ flush();
+}
+
+
+$decl_1 = "IN CONGRESS, July 4, 1776.";
+$decl_2 = "The unanimous Declaration of the thirteen united States of America,";
+$decl_3 = "When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
+$decl_4 = "We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights,that among these are Life, Liberty and the pursuit of Happiness.--That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, --That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient causes; and accordingly all experience hath shewn, that mankind are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms to which they are accustomed. But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security.--Such has been the patient sufferance of these Colonies; and such is now the necessity which constrains them to alter their former Systems of Government. The history of the present King of Great Britain is a history of repeated injuries and usurpations, all having in direct object the establishment of an absolute Tyranny over these States. To prove this, let Facts be submitted to a candid world.";
+
+// a method to run interop tests against remote server. tests described at bottom.
+function run_easy_tests($server, $debug=0, $output = null) {
+ global $decl_1, $decl_2, $decl_3, $decl_4;
+ run_test($server, $debug, $output, "interopEchoTests.echoString", "That government is best, which governs least");
+ run_test($server, $debug, $output, "interopEchoTests.echoBoolean", true);
+ run_test($server, $debug, $output, "interopEchoTests.echoInteger", 42);
+ run_test($server, $debug, $output, "interopEchoTests.echoFloat", 3.1416);
+ run_test($server, $debug, $output, "interopEchoTests.echoStruct", array("varFloat" => 1.2345,
+ "varInt" => 186000,
+ "varString" => "a string" ));
+ run_test($server, $debug, $output, "interopEchoTests.echoStringArray", array($decl_1, $decl_2, $decl_3, $decl_4));
+ run_test($server, $debug, $output, "interopEchoTests.echoIntegerArray", array(23, 234, 1, 0, -10, 999));
+ run_test($server, $debug, $output, "interopEchoTests.echoFloatArray", array(2.45, 9.9999));
+ run_test($server, $debug, $output, "interopEchoTests.echoStructArray", array(array("varFloat" => 1.2345,
+ "varInt" => 186000,
+ "varString" => "a string"),
+ array("varFloat" => 10.98765,
+ "varInt" => 3200,
+ "varString" => "happy little string" )
+ ));
+
+ $foo = "some base64 string";
+ xmlrpc_set_type(&$foo, "base64");
+ run_test($server, $debug, $output, "interopEchoTests.echoBase64", $foo);
+
+ $foo="19980717T14:08:55";
+ xmlrpc_set_type(&$foo, "datetime");
+ run_test($server, $debug, $output, "interopEchoTests.echoDate", $foo);
+
+ run_no_param_test($server, $debug, $output, "interopEchoTests.noInParams");
+}
+
+function ident($server, $debug=0, $output=null) {
+ $method = "interopEchoTests.whichToolkit";
+ $result = xu_rpc_http_concise(array('method' => $method,
+ 'host' => $server['host'],
+ 'uri' => $server['uri'],
+ 'port' => $server['port'],
+ 'debug' => $debug,
+ 'output' => $output));
+ if ($result && $result['toolkitDocsUrl'] && !$result['faultCode']) {
+ pass($method);
+ echo "
";
+ foreach($result as $key => $value) {
+ if(substr($value, 0, 7) === "http://") {
+ $value = "$value";
+ }
+ echo "$key: $value
";
+ }
+ }
+ else {
+ fail($method, false, $result);
+ }
+}
+
+function run_stress_tests($server, $debug=0, $output=null) {
+ global $decl_1, $decl_2, $decl_3, $decl_4;
+ run_test($server, $debug, $output, "interopEchoTests.echoString", "XML Comment in a string: ");
+ run_test($server, $debug, $output, "interopEchoTests.echoInteger", 4200000000);
+ run_test($server, $debug, $output, "interopEchoTests.echoFloat", 1.2);
+ run_test($server, $debug, $output, "interopEchoTests.echoStruct",
+ array("varFloat" => 1.2345,
+ "varInt" => 186000,
+ "varString" => "18 > 2 && 2 < 18 && 42 == the answer to life, the universe, and everything" ));
+ run_test($server, $debug, $output, "interopEchoTests.echoStringArray",
+ array($decl_1, $decl_2, $decl_3, $decl_4, "non-ascii chars above 127 (165-170): ¥, ¦, §, ¨, ©, ª"));
+ run_test($server, $debug, $output, "interopEchoTests.echoIntegerArray",
+ array(23, 234, 1, 0, -10, 999));
+ run_test($server, $debug, $output, "interopEchoTests.echoFloatArray",
+ array(2.45, 9.9999));
+ run_test($server, $debug, $output, "interopEchoTests.echoStructArray",
+ array(array("varFloat" => 1.2345,
+ "varInt" => 186000,
+ "varString" => "non-print char (8): "),
+ array("varFloat" => 10.98765,
+ "varInt" => 3200,
+ "varString" => "happy little string" )
+ ));
+}
+
+// a method to display an html form for invoking the script
+function print_html_form($servers_list) {
+
+ echo <<< END
+Choose an xmlrpc server to run interop tests against live!
+END;
+
+ print_servers_form($servers_list);
+
+echo <<< END
+
";
+
+ ident($server, $debug, $output);
+
+ if($GLOBALS['HTTP_GET_VARS']['stress'] == 1) {
+ run_stress_tests($server, $debug, $output);
+ }
+ else {
+ run_easy_tests($server, $debug, $output);
+ }
+ }
+ else {
+ echo "invalid option
";
+ }
+}
+else {
+ print_html_form($server_list);
+}
+
+/* Interop tests description:
+
+interopEchoTests.echoString (inputString) -- Sends a random string to the server, and checks that the
+response is a string whose value is the same as the string that was sent.
+
+interopEchoTests.echoInteger (inputInteger) -- Sends a random integer to the server, and checks that
+the response is an integer whose value is the same as the integer that was sent.
+
+interopEchoTests.echoFloat (inputFloat) -- Sends a random floating point number to the server, and
+checks that the response is a float whose value is the same as the number that was sent.
+
+interopEchoTests.echoStruct (inputStruct) -- Sends a struct to the server, which contains three
+elements: varString, varInt, and varFloat, a random string, a random integer, and a random float,
+respectively, and checks that the response is a struct containing the same values that were sent.
+
+interopEchoTests.echoStringArray (inputStringArray) -- Sends an array of random strings to the server,
+and checks that the response is an array of strings, whose values are the same as the values that were
+sent.
+
+interopEchoTests.echoIntegerArray (inputIntegerArray) -- Sends an array of random integers to the
+server, and checks that the response is an array of integers, whose values are the same as the values that
+were sent.
+
+interopEchoTests.echoFloatArray (inputFloatArray) -- Sends an array of random floating point numbers
+to the server, and checks that the response is an array of floats, whose values are the same as the values
+that were sent.
+
+interopEchoTests.echoStructArray (inputStructArray) -- Sends an array of structs to the server, and
+checks that the response is an array of structs, which contain the same values that were sent. Each struct
+contains three elements: varString, varInt, and varFloat, a string, an integer, and a floating point number,
+respectively.
+
+ */
\ No newline at end of file
diff --git a/tests/xmlrpc/interop-server.php b/tests/xmlrpc/interop-server.php
new file mode 100644
index 000000000..a7789037c
--- /dev/null
+++ b/tests/xmlrpc/interop-server.php
@@ -0,0 +1,269 @@
+ "http://xmlrpc-epi.sourceforge.net/",
+ toolkitName => "xmlrpc-epi-php",
+ toolkitVersion => "0.26", // (need to implement xmlrpc_get_version()
+ toolkitOperatingSystem => $GLOBALS[MACHTYPE]
+ );
+}
+
+/*
+interopEchoTests.echoString (inputString) -- Sends a random string to the server, and checks that the
+response is a string whose value is the same as the string that was sent.
+
+interopEchoTests.echoInteger (inputInteger) -- Sends a random integer to the server, and checks that
+the response is an integer whose value is the same as the integer that was sent.
+
+interopEchoTests.echoFloat (inputFloat) -- Sends a random floating point number to the server, and
+checks that the response is a float whose value is the same as the number that was sent.
+
+interopEchoTests.echoStruct (inputStruct) -- Sends a struct to the server, which contains three
+elements: varString, varInt, and varFloat, a random string, a random integer, and a random float,
+respectively, and checks that the response is a struct containing the same values that were sent.
+
+interopEchoTests.echoStringArray (inputStringArray) -- Sends an array of random strings to the server,
+and checks that the response is an array of strings, whose values are the same as the values that were
+sent.
+
+interopEchoTests.echoIntegerArray (inputIntegerArray) -- Sends an array of random integers to the
+server, and checks that the response is an array of integers, whose values are the same as the values that
+were sent.
+
+interopEchoTests.echoFloatArray (inputFloatArray) -- Sends an array of random floating point numbers
+to the server, and checks that the response is an array of floats, whose values are the same as the values
+that were sent.
+
+interopEchoTests.echoStructArray (inputStructArray) -- Sends an array of structs to the server, and
+checks that the response is an array of structs, which contain the same values that were sent. Each struct
+contains three elements: varString, varInt, and varFloat, a string, an integer, and a floating point number,
+respectively.
+*/
+
+$request_xml = $HTTP_RAW_POST_DATA;
+if(!$request_xml) {
+ $request_xml = $HTTP_POST_VARS[xml];
+}
+
+if(!$request_xml) {
+ echo "No XML input found!
";
+}
+else {
+ // create server
+ $xmlrpc_server = xmlrpc_server_create();
+
+ if($xmlrpc_server) {
+ // register xmlrpc methods
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoBoolean", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoString", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoInteger", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoFloat", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoBase64", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoDate", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoValue", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoStruct", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoStringArray", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoIntegerArray", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoFloatArray", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoStructArray", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoVoid", "method_echo_void");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.whichToolkit", "method_toolkit");
+ xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.noInParams", "method_no_in_params");
+
+ // soap methods (interop test naming conventions are slightly different for soap)
+ xmlrpc_server_register_method($xmlrpc_server, "echoBoolean", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoString", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoInteger", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoFloat", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoBase64", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoDate", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoValue", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoStruct", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoStringArray", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoIntegerArray", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoFloatArray", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoStructArray", "method_echo");
+ xmlrpc_server_register_method($xmlrpc_server, "echoVoid", "method_echo_void");
+ xmlrpc_server_register_method($xmlrpc_server, "whichToolkit", "method_toolkit");
+ xmlrpc_server_register_method($xmlrpc_server, "noInParams", "method_no_in_params");
+
+
+ xmlrpc_server_register_introspection_callback($xmlrpc_server, "introspection_cb");
+
+ //$val = xmlrpc_decode($request_xml, &$method);
+ //echo "xml: $request_xml\n";
+ //echo "method: $method\nvar: ";
+ //print_r($val);
+ // parse xml and call method
+ echo xmlrpc_server_call_method($xmlrpc_server, $request_xml, $response, array(output_type => "xml", version => "auto"));
+
+ // free server resources
+ $success = xmlrpc_server_destroy($xmlrpc_server);
+ }
+}
+
+
+
+/********************
+* API Documentation *
+********************/
+
+function introspection_cb($method) {
+ /* if our xml is not parsed correctly, a php warning will be displayed.
+ * however, very little structural validation is done, so we must be careful.
+ * make sure to test this xml for syntax errors by calling system.describeMethods()
+ * after making any changes.
+ */
+
+ $methods = array("boolean", "string", "integer", "float", "base64", "date", "value", "struct");
+ $type_map = array(integer => "int", float => "double", date => "datetime", value => "any");
+
+ foreach($methods as $method) {
+ $title = ucfirst($method);
+ $type = $type_map[$method] ? $type_map[$method] : $method;
+
+ $xml_methods .= <<< END
+
+ Ken MacLeod: \"This description isn't clear, I expected '2000.April.1' when in fact it's '2000.04.01'. Adding
+ a note saying that month and day are two-digits with leading 0s, and January is 01 would help.\" Done.",
+ xml =>
+"
+No XML input found!
";
+ }
+ else {
+ /* setup some (optional) output options */
+ $display = array();
+ if($HTTP_POST_VARS[verbosity]) {
+ $display[verbosity] = $HTTP_POST_VARS[verbosity];
+ }
+ if($HTTP_POST_VARS[escaping]) {
+ $display[escaping] = $HTTP_POST_VARS[escaping];
+ }
+ else {
+ $display[escaping] = array("non-ascii", "markup");
+ }
+ if($HTTP_POST_VARS[version]) {
+ $display[version] = $HTTP_POST_VARS[version];
+ }
+ if($HTTP_POST_VARS[encoding]) {
+ $display[encoding] = $HTTP_POST_VARS[encoding];
+ }
+ if($HTTP_POST_VARS[output_type]) {
+ $display[output_type] = $HTTP_POST_VARS[output_type];
+ }
+
+ /* handle the request */
+ $response = xmlrpc_server_call_method($server, $request_xml, $response, $display);
+
+ if($HTTP_POST_VARS[disp] === "html") {
+ if($HTTP_POST_VARS[output_type] === "php") {
+ echo "
";
+}
+
+function fail($method, $sent, $received) {
+ echo "fail $method()
";
+ if ($sent) {
+ echo "sent
received
";
+ $params = array($args);
+ if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support
+ $server['uri'] .= "?start_debug=1";
+ $result = xu_rpc_http_concise(array('method' => $method,
+ 'args' => $params,
+ 'host' => $server['host'],
+ 'uri' => $server['uri'],
+ 'port' => $server['port'],
+ 'debug' => $debug,
+ 'output' => $output));
+ check_if_matches($method, $args, $result);
+ echo "";
+ flush();
+}
+
+function run_no_param_test($server, $debug, $output, $method) {
+ global $HTTP_GET_VARS;
+ echo "
";
+ if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support
+ $server['uri'] .= "?start_debug=1";
+ $result = xu_rpc_http_concise(array('method' => $method,
+ 'host' => $server['host'],
+ 'uri' => $server['uri'],
+ 'port' => $server['port'],
+ 'debug' => $debug,
+ 'output' => $output));
+
+ if ($result && gettype($result) === "integer") {
+ pass($method);
+ }
+ else {
+ fail($method, false, $result);
+ }
+
+ flush();
+}
+
+
+// a method to run wiki tests against remote server. tests described at bottom.
+function run_easy_tests($server, $debug=0, $output = null) {
+
+ global $wiki_dmap;
+
+ run_no_param_test($server, $debug, $output, "wiki.getRPCVersionSupported");
+ // of the last day:
+ run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time()-86400, 1));
+ /* ... */
+}
+
+function run_stress_tests($server, $debug=0, $output=null) {
+
+ global $wiki_dmap;
+
+ run_no_param_test($server, $debug, $output, "wiki.getRPCVersionSupported");
+ // of the last day:
+ run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time()-86400, 1));
+ /* ... */
+}
+
+// a method to display an html form for invoking the script
+function print_html_form($servers_list) {
+
+ echo <<< END
+Choose an xmlrpc wiki server to run tests against
+END;
+
+ print_servers_form($servers_list);
+}
+
+// some code which determines if we are in form display or response mode.
+$server_list = get_wiki_servers();
+$server = get_server_from_user($server_list);
+if ($server) {
+ $debug = $GLOBALS['HTTP_GET_VARS']['debug'] || $GLOBALS['HTTP_GET_VARS']['start_debug'];
+ $output['version'] = $GLOBALS['HTTP_GET_VARS']['version'];
+ if ($server) {
+ $title = $server['title'];
+ echo "
";
+
+ if($GLOBALS['HTTP_GET_VARS']['stress'] == 1) {
+ run_stress_tests($server, $debug, $output);
+ }
+ else {
+ run_easy_tests($server, $debug, $output);
+ }
+ }
+ else {
+ echo "invalid option
";
+ }
+}
+else {
+ print_html_form($server_list);
+}
diff --git a/tests/xmlrpc/xmlrpc-introspect.php b/tests/xmlrpc/xmlrpc-introspect.php
new file mode 100644
index 000000000..e20c48a7c
--- /dev/null
+++ b/tests/xmlrpc/xmlrpc-introspect.php
@@ -0,0 +1,316 @@
+Methods\n";
+ foreach($methodList as $method) {
+ $name = $method[name];
+ $buf .= "
";
+ }
+ if ($typeList) {
+ $buf .= "Types\n";
+ foreach($typeList as $type) {
+ $name = $type[name];
+ $buf .= "
";
+ }
+
+
+ $buf .= "Methods
";
+ foreach($methodList as $method) {
+ $name = $method[name];
+ $author = $method[author] ? $method[author] : $unknown;
+ $version = $method[version] ? $method[version] : $unknown;
+ $desc = $method[purpose] ? $method[purpose] : $unknown;
+ $sigs = $method[signatures];
+ $buf .= "
";
+ $buf .= "$name " . field("Signature(s)", get_sigs($method), 3) . " ";
+ $buf .= "" . field("Author", $author, 2) . field("Version", $version) . " ";
+ $buf .= "" . field("Purpose", $desc, 3) . " ";
+
+ $exclude_list = array(
+ "see",
+ "signatures",
+ "purpose",
+ "version",
+ "author",
+ "name"
+ );
+ foreach($method as $key => $val) {
+ if (!in_array($key, $exclude_list)) {
+ if (is_array($val)) {
+ $buf .= " ";
+
+ foreach($val as $key2 => $desc) {
+ if (gettype($desc) === "string") {
+ if (gettype($key2) !== "string") {
+ $key2 = false;
+ }
+
+ $buf .= "" . ucfirst($key) . " " . field(ucfirst($key2), $desc, 3) . " ";
+ }
+ }
+ }
+ else {
+ $buf .= "" . field(ucfirst($key), $val, 3) . " ";
+ }
+ }
+ }
+
+
+ if ($sigs) {
+ $bmultiple = count($sigs) > 1;
+ foreach($sigs as $sig) {
+ if ($bmultiple) {
+ $count ++;
+ $buf .= " ";
+ }
+
+ if ($sig[params]) {
+ $buf .= "Signature $count: " . get_sig($name, $sig) . " ";
+
+ $buf .= "Parameters ";
+ }
+
+ if ($sig[returns]) {
+ $buf .= "";
+ $buf .= do_params($sig[params], false, false);
+ $buf .= " ";
+ $buf .= "Return Value(s) ";
+ }
+ }
+ }
+
+ if ($method[see]) {
+ $buf .= "";
+ $buf .= do_params($sig[returns], false, false);
+ $buf .= " ";
+
+ foreach($method[see] as $name => $desc) {
+ if ($method_hash[$name]) {
+ $name = "$name";
+ }
+
+ $buf .= "See Also " . field($name, $desc, 3) . " ";
+ }
+ }
+ }
+ $buf .= "Types
";
+ $buf .= "
";
+
+ return $buf;
+}
+
+/*********************************************************************
+* The following functions are non-public and may change at any time. *
+*********************************************************************/
+
+/* non public - format key/val pair in a ";
+ $buf .= "";
+
+ $buf .= do_params($typeList, true);
+
+ $buf .= " */
+function field($title, $text, $columns=false, $width=false) {
+ if ($columns) {
+ $colspan = " colspan='$columns'";
+ }
+ if ($width) {
+ $width = " width='$width' ";
+ }
+ $colon = $title && $text ? ":" : "";
+ return " $title$colon $text ";
+}
+
+function is_xmlrpc_type($type) {
+ static $types = array("array", "struct", "mixed", "string", "int", "i4", "datetime", "base64", "boolean");
+ return in_array($type, $types);
+}
+
+function user_type($type) {
+ global $xi_type_hash;
+ return $xi_type_hash[$type] ? true : false;
+}
+
+
+function do_param($param, $bNewType=false, $bLinkUserTypes=true, $depth=0) {
+ /* guard against serious craziness */
+ if (++ $depth >= 24) {
+ return "
" : "";
+ $buf = "\n\n";
+ foreach($params as $param) {
+ $buf .= do_param($param, $bNewType, $bLinkUserTypes, $depth);
+ }
+ $buf .= "
$br\n";
+ }
+ return $buf;
+}
+
+
+function get_sig($method_name, $sig) {
+ $buf = "";
+ if ($method_name && $sig) {
+ $return = $sig[returns][0][type];
+ if (!$return) {
+ $return = "void";
+ }
+ $buf .= "$return ";
+
+ $buf .= "$method_name( ";
+ $first = true;
+
+ if ($sig[params]) {
+ foreach($sig[params] as $param) {
+ $type = $param[type];
+ $opt = $param[optional];
+ $def = $param["default"];
+ $name = $param["name"];
+ if (user_type($type)) {
+ $type = "$type";
+ }
+
+ if ($opt) {
+ $buf .= $first ? '[' : ' [';
+ }
+ if (!$first) {
+ $buf .= ', ';
+ }
+ $buf .= "$type";
+ if (name) {
+ $buf .= " $name";
+ }
+ if ($def) {
+ $buf .= " = $def";
+ }
+ if ($opt) {
+ $buf .= ']';
+ }
+ $first = false;
+ }
+ }
+
+ $buf .= " )";
+ }
+
+ return $buf;
+}
+
+/* non public. generate method signature from method description */
+function get_sigs($method) {
+ $method_name = $method[name];
+
+ $buf = "";
+
+ if ($method[signatures]) {
+ foreach($method[signatures] as $sig) {
+ $buf .= "