* do not calculate array bounds in php, since they may be expressed via

symbolic constants rather than numerically
  * replace an empty C array (such as int[0]) with an empty record declaration
    rather than with an array of one element, since it doesn't take up any
    space in C either

git-svn-id: trunk@18111 -
This commit is contained in:
Jonas Maebe 2011-08-06 12:21:40 +00:00
parent b59c42f2c7
commit 9de57f1bd8

View File

@ -580,11 +580,14 @@ class ObjectivePParser extends ObjectivePParserBase {
// Makes a struct field into an inline array (or returns field un-changed) // Makes a struct field into an inline array (or returns field un-changed)
function MakeFieldInlineArray ($io_field, $line, $name, $type) { function MakeFieldInlineArray ($io_field, $line, $name, $type) {
if (eregi("\[([0-9]+)\];", $line, $array_size)) { if (eregi("\[([^]]+)\];", $line, $array_size)) {
$length = (int)$array_size[1] - 1; if ($array_size[1] == "")
if ($length > 0) { $io_field = "$name: array[0..0] of $type; { dynamically expanding, 0 elements in C }";
$io_field = " $name: array[0..$length] of $type;"; else if ($array_size[1] == "0")
} $io_field = "$name: record end; { array of 0 elements in C, does not allocate space }";
else
// array_size[1] may be a symbolic constant rather than a number, so don't calculate in php
$io_field = "$name: array[0..($array_size[1])-1] of $type;";
} }
return $io_field; return $io_field;