diff options
author | shusa <shusa> | 2005-11-11 18:09:11 +0000 |
---|---|---|
committer | shusa <shusa> | 2005-11-11 18:09:11 +0000 |
commit | c5b1262415d8aa288176c75cd3e6588f219dbfb0 (patch) | |
tree | a8992045e59909a4e0a1474e6e16e101b49ad210 /Tools/CodeGen | |
parent | d7888aa3ecaf33f8e949313653e868f4ae89518a (diff) |
added functions DeclarePointer and DeclarePointers
Diffstat (limited to 'Tools/CodeGen')
-rw-r--r-- | Tools/CodeGen/CodeGen.m | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Tools/CodeGen/CodeGen.m b/Tools/CodeGen/CodeGen.m index ddb359e..817eb5e 100644 --- a/Tools/CodeGen/CodeGen.m +++ b/Tools/CodeGen/CodeGen.m @@ -45,9 +45,15 @@ IncludeFile::usage = "IncludeFile[name] returns a block of code" <> DeclareVariable::usage = "DeclareVariable[name, type] returns a block of code " <> "that declares a variable of given name and type. 'name' and 'type' should be " <> "strings."; -DeclareVariables::usage = "DeclareVariable[names, type] returns a block of code " <> +DeclareVariables::usage = "DeclareVariables[names, type] returns a block of code " <> "that declares a list of variables of given name and type. 'names' should be a list" <> " of strings and 'type' should be a string string."; +DeclarePointer::usage = "DeclarePointer[name, type] returns a block of code " <> + "that declares a pointer of given name and type. 'name' and 'type' should be " <> + "strings."; +DeclarePointers::usage = "DeclarePointers[names, type] returns a block of code " <> + "that declares a list of pointers of given name and type. 'names' should be a list" <> + " of strings and 'type' should be a string string."; DefineVariable::usage = "DefineVariable[name, type, value] returns a block of " <> "code that declares and initialised a variable 'name' of type 'type' to value 'value'."; AssignVariable::usage = "AssignVariable[dest_, src_] returns a block of code " <> @@ -211,6 +217,18 @@ If[SOURCELANGUAGE == "C", {type, " :: ", CommaSeparated@names, EOL[]} (* no value init avoids implicit SAVE attribute *) ]; +DeclarePointer[name_, type_] := +If[SOURCELANGUAGE == "C", + {type, " *", name, EOL[]}, + {type, ", target :: ", name, EOL[]} + ]; + +DeclarePointers[names_?ListQ, type_] := +If[SOURCELANGUAGE == "C", + {type, " *", CommaInitSeparated@names, EOL[]}, + {type, ", target :: ", CommaSeparated@names, EOL[]} + ]; + DeclareArray[name_, dim_, type_] := If[SOURCELANGUAGE == "C", DeclareArrayC[name, dim, type], |