3
0

upd(codegen): update some basic templates

This commit is contained in:
Tit Petric
2018-09-04 15:38:05 +02:00
parent bdb0844a48
commit 30d12b4041
3 changed files with 48 additions and 50 deletions

View File

@@ -1,31 +1,30 @@
<?php
foreach ($apis as $api) {
if (is_array($api['struct'])) {
$name = ucfirst($api['interface']);
$filename = $dirname . "/" . str_replace("..", ".", strtolower($name) . ".go");
$name = ucfirst($api['interface']);
$filename = $dirname . "/" . str_replace("..", ".", strtolower($name) . ".go");
$tpl->load("http_.tpl");
$tpl->assign($common);
$tpl->assign("package", basename(__DIR__));
$tpl->assign("name", $name);
$tpl->assign("api", $api);
$tpl->assign("self", strtolower(substr($name, 0, 1)));
$tpl->assign("structs", $api['struct']);
$imports = array();
foreach ($api['struct'] as $struct) {
if (isset($struct['imports']))
foreach ($struct['imports'] as $import) {
$imports[] = $import;
}
}
$tpl->assign("imports", $imports);
$tpl->assign("calls", $api['apis']);
$contents = str_replace("\n\n}", "\n}", $tpl->get());
if (!file_exists($filename)) {
file_put_contents($filename, $contents);
echo $filename . "\n";
$tpl->load("http_.tpl");
$tpl->assign($common);
$tpl->assign("package", basename(__DIR__));
$tpl->assign("name", $name);
$tpl->assign("api", $api);
$tpl->assign("self", strtolower(substr($name, 0, 1)));
$tpl->assign("structs", $api['struct']);
$imports = array();
if (is_array($api['struct']))
foreach ($api['struct'] as $struct) {
if (isset($struct['imports']))
foreach ($struct['imports'] as $import) {
$imports[] = $import;
}
}
$tpl->assign("imports", $imports);
$tpl->assign("calls", $api['apis']);
$contents = str_replace("\n\n}", "\n}", $tpl->get());
if (!file_exists($filename)) {
file_put_contents($filename, $contents);
echo $filename . "\n";
}
}