|
|
@ -36,7 +36,8 @@ class CStructArrayExporter extends BaseExporter |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function writeDocument() |
|
|
|
protected function writeDocument() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$fields = array_map(function (Column $c) { |
|
|
|
$any_bool = false; |
|
|
|
|
|
|
|
$fields = array_map(function (Column $c) use (&$any_bool) { |
|
|
|
$type = $c->type; |
|
|
|
$type = $c->type; |
|
|
|
if ($type == 'string') { |
|
|
|
if ($type == 'string') { |
|
|
|
$type = 'const char *'; |
|
|
|
$type = 'const char *'; |
|
|
@ -44,13 +45,17 @@ class CStructArrayExporter extends BaseExporter |
|
|
|
|
|
|
|
|
|
|
|
$name = $this->cify($c->name); |
|
|
|
$name = $this->cify($c->name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($c->type == 'bool') $any_bool = true; |
|
|
|
|
|
|
|
|
|
|
|
return (object)['name' => $c->name, 'type' => $c->type, 'ctype' => $type, 'cname' => $name]; |
|
|
|
return (object)['name' => $c->name, 'type' => $c->type, 'ctype' => $type, 'cname' => $name]; |
|
|
|
}, $this->columns); |
|
|
|
}, $this->columns); |
|
|
|
|
|
|
|
|
|
|
|
$ctablename = $this->cify($this->table->name); |
|
|
|
$ctablename = $this->cify($this->table->name); |
|
|
|
|
|
|
|
|
|
|
|
// preamble |
|
|
|
// preamble |
|
|
|
|
|
|
|
if ($any_bool) { |
|
|
|
echo "#include <stdbool.h>\n\n"; |
|
|
|
echo "#include <stdbool.h>\n\n"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
echo "struct " . $ctablename . " {\n"; |
|
|
|
echo "struct " . $ctablename . " {\n"; |
|
|
|
foreach ($fields as $field) { |
|
|
|
foreach ($fields as $field) { |
|
|
|