Skip to content

Commit

Permalink
refs modelica#3446: Add Include annotation for external function inte…
Browse files Browse the repository at this point in the history
…rface
  • Loading branch information
beutlich committed Feb 26, 2020
1 parent 3dfe883 commit b476b6b
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 109 deletions.
100 changes: 50 additions & 50 deletions Modelica/Blocks/Tables.mo

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions Modelica/Blocks/Types.mo
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ package Types
input Modelica.Blocks.Types.TimeEvents timeEvents=Modelica.Blocks.Types.TimeEvents.Always;
input Boolean verboseRead=true "= true: Print info message; = false: No info message";
output ExternalCombiTimeTable externalCombiTimeTable;
external"C" externalCombiTimeTable = ModelicaStandardTables_CombiTimeTable_init2(
external "C" externalCombiTimeTable = ModelicaStandardTables_CombiTimeTable_init2(
fileName,
tableName,
table,
Expand All @@ -128,14 +128,14 @@ package Types
extrapolation,
shiftTime,
timeEvents,
verboseRead) annotation (Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
verboseRead) annotation (Include="#include \"ModelicaStandardTables.h\"", Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
end constructor;

function destructor "Terminate 1-dim. table where first column is time"
extends Modelica.Icons.Function;
input ExternalCombiTimeTable externalCombiTimeTable;
external"C" ModelicaStandardTables_CombiTimeTable_close(
externalCombiTimeTable) annotation (Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
external "C" ModelicaStandardTables_CombiTimeTable_close(
externalCombiTimeTable) annotation (Include="#include \"ModelicaStandardTables.h\"", Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
end destructor;

end ExternalCombiTimeTable;
Expand All @@ -154,7 +154,7 @@ package Types
input Modelica.Blocks.Types.Extrapolation extrapolation=Modelica.Blocks.Types.Extrapolation.LastTwoPoints;
input Boolean verboseRead=true "= true: Print info message; = false: No info message";
output ExternalCombiTable1D externalCombiTable1D;
external"C" externalCombiTable1D = ModelicaStandardTables_CombiTable1D_init2(
external "C" externalCombiTable1D = ModelicaStandardTables_CombiTable1D_init2(
fileName,
tableName,
table,
Expand All @@ -164,14 +164,14 @@ package Types
size(columns, 1),
smoothness,
extrapolation,
verboseRead) annotation (Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
verboseRead) annotation (Include="#include \"ModelicaStandardTables.h\"", Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
end constructor;

function destructor "Terminate 1-dim. table defined by matrix"
extends Modelica.Icons.Function;
input ExternalCombiTable1D externalCombiTable1D;
external"C" ModelicaStandardTables_CombiTable1D_close(externalCombiTable1D)
annotation (Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
external "C" ModelicaStandardTables_CombiTable1D_close(externalCombiTable1D)
annotation (Include="#include \"ModelicaStandardTables.h\"", Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
end destructor;

end ExternalCombiTable1D;
Expand All @@ -189,22 +189,22 @@ package Types
input Modelica.Blocks.Types.Extrapolation extrapolation=Modelica.Blocks.Types.Extrapolation.LastTwoPoints;
input Boolean verboseRead=true "= true: Print info message; = false: No info message";
output ExternalCombiTable2D externalCombiTable2D;
external"C" externalCombiTable2D = ModelicaStandardTables_CombiTable2D_init2(
external "C" externalCombiTable2D = ModelicaStandardTables_CombiTable2D_init2(
fileName,
tableName,
table,
size(table, 1),
size(table, 2),
smoothness,
extrapolation,
verboseRead) annotation (Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
verboseRead) annotation (Include="#include \"ModelicaStandardTables.h\"", Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
end constructor;

function destructor "Terminate 2-dim. table defined by matrix"
extends Modelica.Icons.Function;
input ExternalCombiTable2D externalCombiTable2D;
external"C" ModelicaStandardTables_CombiTable2D_close(externalCombiTable2D)
annotation (Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
external "C" ModelicaStandardTables_CombiTable2D_close(externalCombiTable2D)
annotation (Include="#include \"ModelicaStandardTables.h\"", Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});
end destructor;

end ExternalCombiTable2D;
Expand Down
2 changes: 1 addition & 1 deletion Modelica/Math/FastFourierTransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ See detailed example model:
protected
Real work[3*size(u,1) + 2*(div(size(u,1),2)+1)];
external "C" info = ModelicaFFT_kiss_fftr(u, size(u,1), work, size(work,1), amplitudes, phases)
annotation(Library="ModelicaExternalC");
annotation(Include="#include \"ModelicaFFT.h\"", Library="ModelicaExternalC");
annotation (Documentation(revisions="<html>
<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">
<tr><th>Date</th> <th align=\"left\">Description</th></tr>
Expand Down
12 changes: 6 additions & 6 deletions Modelica/Math/Random.mo
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ and the returned state is the one from the last iteration.
output Integer stateOut[nState]
"The new internal states of the random number generator";
external "C" ModelicaRandom_xorshift64star(stateIn, stateOut, result)
annotation (Library="ModelicaExternalC");
annotation (Include="#include \"ModelicaRandom.h\"", Library="ModelicaExternalC");
annotation(Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down Expand Up @@ -395,7 +395,7 @@ random number generator is used to fill the internal state vector with 64 bit ra
output Integer stateOut[nState]
"The new internal states of the random number generator";
external "C" ModelicaRandom_xorshift128plus(stateIn, stateOut, result)
annotation (Library="ModelicaExternalC");
annotation (Include="#include \"ModelicaRandom.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down Expand Up @@ -572,7 +572,7 @@ random number generator is used to fill the internal state vector with 64 bit ra
output Integer stateOut[nState]
"The new internal states of the random number generator";
external "C" ModelicaRandom_xorshift1024star(stateIn, stateOut, result)
annotation (Library="ModelicaExternalC");
annotation (Include="#include \"ModelicaRandom.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down Expand Up @@ -935,7 +935,7 @@ If the same localSeed, globalSeed, nState is given, the same state vector is ret
extends Modelica.Icons.Function;
output Integer seed "Automatically generated seed";

external "C" seed = ModelicaRandom_automaticGlobalSeed(0.0) annotation (Library="ModelicaExternalC");
external "C" seed = ModelicaRandom_automaticGlobalSeed(0.0) annotation (Include="#include \"ModelicaRandom.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down Expand Up @@ -1073,7 +1073,7 @@ path is provided.
input Integer[33] rngState "The initial state";
input Integer id;
external "C" ModelicaRandom_setInternalState_xorshift1024star(rngState, size(rngState,1), id)
annotation (Library="ModelicaExternalC");
annotation (Include="#include \"ModelicaRandom.h\"", Library="ModelicaExternalC");
end setInternalState;

algorithm
Expand Down Expand Up @@ -1153,7 +1153,7 @@ random number generator to fill the internal state vector with 64 bit random num
output Real y
"A random number with a uniform distribution on the interval (0,1]";
external "C" y = ModelicaRandom_impureRandom_xorshift1024star(id)
annotation (Library="ModelicaExternalC");
annotation (Include="#include \"ModelicaRandom.h\"", Library="ModelicaExternalC");
annotation(Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down
4 changes: 2 additions & 2 deletions Modelica/Utilities/Files.mo
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ impure function fullPathName "Get full path name of file or directory name"
extends Modelica.Icons.Function;
input String name "Absolute or relative file or directory name";
output String fullName "Full path of 'name'";
external "C" fullName = ModelicaInternal_fullPathName(name) annotation(Library="ModelicaExternalC");
external "C" fullName = ModelicaInternal_fullPathName(name) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down Expand Up @@ -658,7 +658,7 @@ impure function temporaryFileName
"Return arbitrary name of a file that does not exist and is in a directory where access rights allow to write to this file (useful for temporary output of files)"
extends Modelica.Icons.Function;
output String fileName "Full path name of temporary file";
external "C" fileName=ModelicaInternal_temporaryFileName() annotation(Library="ModelicaExternalC");
external "C" fileName=ModelicaInternal_temporaryFileName() annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down
16 changes: 8 additions & 8 deletions Modelica/Utilities/Internal.mo
Original file line number Diff line number Diff line change
Expand Up @@ -163,41 +163,41 @@ package FileSystem
impure function mkdir "Make directory (POSIX: 'mkdir')"
extends Modelica.Icons.Function;
input String directoryName "Make a new directory";
external "C" ModelicaInternal_mkdir(directoryName) annotation(Library="ModelicaExternalC");
external "C" ModelicaInternal_mkdir(directoryName) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
end mkdir;

impure function rmdir "Remove empty directory (POSIX function 'rmdir')"
extends Modelica.Icons.Function;
input String directoryName "Empty directory to be removed";
external "C" ModelicaInternal_rmdir(directoryName) annotation(Library="ModelicaExternalC");
external "C" ModelicaInternal_rmdir(directoryName) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
end rmdir;

impure function stat "Inquire file information (POSIX function 'stat')"
extends Modelica.Icons.Function;
input String name "Name of file, directory, pipe etc.";
output Types.FileType fileType "Type of file";
external "C" fileType = ModelicaInternal_stat(name) annotation(Library="ModelicaExternalC");
external "C" fileType = ModelicaInternal_stat(name) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
end stat;

impure function rename "Rename existing file or directory (C function 'rename')"
extends Modelica.Icons.Function;
input String oldName "Current name";
input String newName "New name";
external "C" ModelicaInternal_rename(oldName, newName) annotation(Library="ModelicaExternalC");
external "C" ModelicaInternal_rename(oldName, newName) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
end rename;

impure function removeFile "Remove existing file (C function 'remove')"
extends Modelica.Icons.Function;
input String fileName "File to be removed";
external "C" ModelicaInternal_removeFile(fileName) annotation(Library="ModelicaExternalC");
external "C" ModelicaInternal_removeFile(fileName) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
end removeFile;

impure function copyFile
"Copy existing file (C functions 'fopen', 'fread', 'fwrite', 'fclose')"
extends Modelica.Icons.Function;
input String fromName "Name of file to be copied";
input String toName "Name of copy of file";
external "C" ModelicaInternal_copyFile(fromName, toName) annotation(Library="ModelicaExternalC");
external "C" ModelicaInternal_copyFile(fromName, toName) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
end copyFile;

impure function readDirectory
Expand All @@ -209,7 +209,7 @@ package FileSystem
"Number of names that are returned (inquire with getNumberOfFiles)";
output String names[nNames]
"All file and directory names in any order from the desired directory";
external "C" ModelicaInternal_readDirectory(directory,nNames,names) annotation(Library="ModelicaExternalC");
external "C" ModelicaInternal_readDirectory(directory,nNames,names) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
end readDirectory;

impure function getNumberOfFiles
Expand All @@ -218,7 +218,7 @@ impure function getNumberOfFiles
input String directory "Directory name";
output Integer result
"Number of files and directories present in 'directory'";
external "C" result = ModelicaInternal_getNumberOfFiles(directory) annotation(Library="ModelicaExternalC");
external "C" result = ModelicaInternal_getNumberOfFiles(directory) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
end getNumberOfFiles;

annotation (
Expand Down
18 changes: 9 additions & 9 deletions Modelica/Utilities/Streams.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package Streams "Read from files and write to files"
"File where to print (empty string is the terminal)"
annotation(Dialog(saveSelector(filter="Text files (*.txt)",
caption="Text file to store the output of print(..)")));
external "C" ModelicaInternal_print(string, fileName) annotation(Library="ModelicaExternalC");
external "C" ModelicaInternal_print(string, fileName) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down Expand Up @@ -49,7 +49,7 @@ Streams.print(\"x = \" + String(y), \"mytestfile.txt\");
annotation(Dialog(loadSelector(filter="Text files (*.txt)",
caption="Open text file for reading")));
output String stringVector[countLines(fileName)] "Content of file";
external "C" ModelicaInternal_readFile(fileName,stringVector,size(stringVector,1)) annotation(Library="ModelicaExternalC");
external "C" ModelicaInternal_readFile(fileName,stringVector,size(stringVector,1)) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand All @@ -74,7 +74,7 @@ Note, a fileName can be defined as URI by using the helper function
output String string "Line of text";
output Boolean endOfFile
"If true, end-of-file was reached when trying to read line";
external "C" string= ModelicaInternal_readLine(fileName,lineNumber,endOfFile) annotation(Library="ModelicaExternalC");
external "C" string= ModelicaInternal_readLine(fileName,lineNumber,endOfFile) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down Expand Up @@ -102,7 +102,7 @@ and endOfFile=true. Otherwise endOfFile=false.
caption="Open text file for counting lines")));

output Integer numberOfLines "Number of lines in file";
external "C" numberOfLines= ModelicaInternal_countLines(fileName) annotation(Library="ModelicaExternalC");
external "C" numberOfLines= ModelicaInternal_countLines(fileName) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand All @@ -120,7 +120,7 @@ separated by LF or CR-LF.
pure function error "Print error message and cancel all actions - in case of an unrecoverable error"
extends Modelica.Icons.Function;
input String string "String to be printed to error message window";
external "C" ModelicaError(string) annotation(Library="ModelicaExternalC");
external "C" ModelicaError(string) annotation(Include="#include \"ModelicaUtilities.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down Expand Up @@ -152,7 +152,7 @@ Streams.error(\"x (= \" + String(x) + \")\\nhas to be in the range 0 .. 1\");
input String fileName "Name of the file that shall be closed"
annotation(Dialog(loadSelector(filter="Text files (*.txt)",
caption="Close text file")));
external "C" ModelicaStreams_closeFile(fileName) annotation(Library="ModelicaExternalC");
external "C" ModelicaStreams_closeFile(fileName) annotation(Include="#include \"ModelicaInternal.h\"", Library="ModelicaExternalC");
annotation (Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand All @@ -172,7 +172,7 @@ file is already closed or does not exist.
input String matrixName "Name / identifier of the 2D Real array on the file";
output Integer dim[2] "Number of rows and columns of the 2D Real array";
external "C" ModelicaIO_readMatrixSizes(fileName, matrixName, dim)
annotation(Library={"ModelicaIO", "ModelicaMatIO", "zlib"});
annotation(Include="#include \"ModelicaIO.h\"", Library={"ModelicaIO", "ModelicaMatIO", "zlib"});
annotation(Documentation(info="<html>
<h4>Syntax</h4>
<blockquote><pre>
Expand Down Expand Up @@ -210,7 +210,7 @@ See <a href=\"modelica://Modelica.Utilities.Examples.ReadRealMatrixFromFile\">Ex
"= true: Print info message; = false: No info message";
output Real matrix[nrow, ncol] "2D Real array";
external "C" ModelicaIO_readRealMatrix(fileName, matrixName, matrix, size(matrix, 1), size(matrix, 2), verboseRead)
annotation(Library={"ModelicaIO", "ModelicaMatIO", "zlib"});
annotation(Include="#include \"ModelicaIO.h\"", Library={"ModelicaIO", "ModelicaMatIO", "zlib"});
annotation(
Documentation(info="<html>
<h4>Syntax</h4>
Expand Down Expand Up @@ -253,7 +253,7 @@ See <a href=\"modelica://Modelica.Utilities.Examples.ReadRealMatrixFromFile\">Ex
choice="7" "MATLAB v7 MAT file"));
output Boolean success "true if successful";
external "C" success = ModelicaIO_writeRealMatrix(fileName, matrixName, matrix, size(matrix, 1), size(matrix, 2), append, format)
annotation(Library={"ModelicaIO", "ModelicaMatIO", "zlib"});
annotation(Include="#include \"ModelicaIO.h\"", Library={"ModelicaIO", "ModelicaMatIO", "zlib"});
annotation(Documentation(info="<html>

<h4>Syntax</h4>
Expand Down

0 comments on commit b476b6b

Please sign in to comment.