3
0

upd(codegen): enable imports with requests

This commit is contained in:
Tit Petric
2018-12-04 15:26:51 +01:00
parent d98d8be69a
commit 43554592e4
39 changed files with 172 additions and 227 deletions

View File

@@ -38,9 +38,27 @@ function array_change_key_case_recursive($arr) {
}, array_change_key_case($arr));
}
function imports($api) {
$imports = array();
if (is_array($api['struct']))
foreach ($api['struct'] as $struct) {
if (isset($struct['imports']))
foreach ($struct['imports'] as $import) {
$import = explode(" ", $import);
if (count($import) == 1) {
$imports[] = '"' . $import[0] . '"';
} else {
$imports[] = $import[0] . ' "' . $import[1] . '"';
}
}
}
return array_unique($imports);
}
$tpl = new Monotek\MiniTPL\Template;
$tpl->set_compile_location("/tmp", true);
$tpl->add_default("newline", "\n");
$tpl->add_default("EOL", "\n");
$generators = array();
exec("find -L " . __DIR__ . "/" . $project . " -name index.php", $generators);
@@ -81,7 +99,7 @@ $parsers = array(
"[]uint64" => "parseUInt64A",
"int" => "parseInt",
"bool" => "parseBool",
"types.JSONText" => "parseJSONText",
"sqlxTypes.JSONText" => "parseJSONTextWithErr",
);
foreach ($generators as $generator) {