Browse Source

* 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 -

Jonas Maebe 14 years ago
parent
commit
9de57f1bd8
1 changed files with 8 additions and 5 deletions
  1. 8 5
      packages/cocoaint/utils/source/objp.php

+ 8 - 5
packages/cocoaint/utils/source/objp.php

@@ -580,11 +580,14 @@ class ObjectivePParser extends ObjectivePParserBase {
 	// Makes a struct field into an inline array (or returns field un-changed)
 	function MakeFieldInlineArray ($io_field, $line, $name, $type) {
 
-		if (eregi("\[([0-9]+)\];", $line, $array_size)) {
-			$length = (int)$array_size[1] - 1;
-			if ($length > 0) {
-				$io_field = "    $name: array[0..$length] of $type;";
-			}
+		if (eregi("\[([^]]+)\];", $line, $array_size)) {
+			if ($array_size[1] == "")
+				$io_field = "$name: array[0..0] of $type; { dynamically expanding, 0 elements in C }";
+			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;