Fix heredoc/nowdoc bugs with large docs, docs crossing buffer boundaries
[hiphop-php.git] / hphp / idl / idl_list.php
blob950bb69cf928646cb7c769413c3ecbae4528d889
1 <?php
3 $format = $argv[1];
4 $output = $argv[2];
5 $files = array_slice($argv, 3);
7 ($f = fopen($output, 'w')) || die("cannot open $output");
9 fwrite($f, "\n/* Generated by idl_list.php. Do NOT modify. */\n\n");
11 sort($files);
12 foreach ($files as $file) {
13 preg_match('%^(?:.*/([^/]*)/)?(.*)\.idl\.php$%', $file, $matches);
14 $prefix = $matches[1];
15 $name = $matches[2];
16 $ucname = $prefix ? camelCase($name) : ucfirst($name);
18 switch ($format) {
19 case 'inc':
20 $path = $prefix ? "$prefix/" : "";
21 fwrite($f, "#include \"$path$name.inc\"\n");
22 break;
23 case 'test_ext':
24 $path = $prefix ?: "test";
25 fwrite($f, "#include <$path/test_ext_$name.h>\n");
26 break;
27 case 'test_suites':
28 fwrite($f, "RUN_TESTSUITE(TestExt$ucname);\n");
29 break;
30 case 'ext':
31 $path = $prefix ?: "runtime/ext";
32 fwrite($f, "#include <$path/ext_$name.h>\n");
33 break;
37 fclose($f);
39 function camelCase($name) {
40 $names = explode('_', $name);
41 return implode(array_map("ucfirst", $names));