Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle string record members mapping to external records. (#9981)
- Record member variables of String type are now properly handled when mapped from a Modelica record to the C record. This mimics what is done for normal String variables (non record member) passed to external functions. Both solutions do not make deep copy right now!. If this needs to be changed then it should be changed for both cases. - The reverse operation (receiving string data from external record) is still disabled until we are sure what more is needed or we get a MWE.
- Loading branch information
Showing
5 changed files
with
26 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
testsuite/simulation/modelica/external_functions/ExternalCFuncInputOnly.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
#include <stdio.h> | ||
#include "ExternalCFuncInputOnly.h" | ||
|
||
void WriteDataC(Data* data) { | ||
|
||
void WriteDataC(Data* data) | ||
{ | ||
if (data->value) | ||
{ | ||
printf("received name: %s\n",data->name); | ||
} | ||
} |
9 changes: 7 additions & 2 deletions
9
testsuite/simulation/modelica/external_functions/ExternalCFuncInputOnly.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
typedef struct { | ||
int value; | ||
|
||
typedef struct | ||
{ | ||
|
||
int value; | ||
const char* name; | ||
|
||
} Data; | ||
|
||
void WriteDataC(Data* data); |
3 changes: 2 additions & 1 deletion
3
testsuite/simulation/modelica/external_functions/ExternalCFuncInputOnly.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters