Skip to content

Commit

Permalink
- function to get all the information of the record element. Used by …
Browse files Browse the repository at this point in the history
…debugger.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19634 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Mar 19, 2014
1 parent f97adf5 commit f07f98e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
36 changes: 36 additions & 0 deletions SimulationRuntime/c/meta/meta_modelica.c
Expand Up @@ -786,6 +786,42 @@ void changeStdStreamBuffer(void) {
setbuf(stderr, NULL);
}

/*
* Used by OMEdit for debugging.
* Returns the Record element as an array e.g ^done,omc_recordelement={name, displayName, type, value}
*/
char* getRecordElement(modelica_metatype arr, modelica_integer i) {
/* get the element from the record array */
void* name = (void*)mmc_gdb_arrayGet(0, arr, i);

/* get the name of the element */
getRecordElementName(arr, i - 2);
char* displayName = malloc(strlen(anyStringBuf) + 1);
strcpy(displayName, anyStringBuf);

/* get the type of the element */
getTypeOfAny(name);
char* type = malloc(strlen(anyStringBuf) + 1);
strcpy(type, anyStringBuf);

/* get the value of the element */
anyString(name);
char* value = malloc(strlen(anyStringBuf) + 1);
strcpy(value, anyStringBuf);

/* format the anyStringBuf as array to return it */
char* formatString = "^done,omc_recordelement={name=\"%ld\",displayName=\"%s\",type=\"%s\",value=\"%s\"}";
checkAnyStringBufSize(0, strlen(name) + strlen(displayName) + strlen(type) + strlen(value) + strlen(formatString));
sprintf(anyStringBuf, formatString, (long (*) (long, long, long))name, displayName, type, value);

/* free the memory */
free(displayName);
free(type);
free(value);

return anyStringBuf;
}

static inline unsigned long djb2_hash_iter(const unsigned char *str /* data; not null-terminated */, int len, unsigned long hash /* start at 5381 */)
{
int i;
Expand Down
3 changes: 3 additions & 0 deletions SimulationRuntime/c/meta/meta_modelica.h
Expand Up @@ -422,6 +422,9 @@ extern char* getRecordElementName(void*any, int element); /* For debugging */
extern int isOptionNone(void*any); /* For debugging */
extern void changeStdStreamBuffer(void); /* For debugging */

/* Debugging functions used by OMEdit */
extern char* getRecordElement(modelica_metatype arr, modelica_integer i);

/*
* Generated (Meta)Records should access a static, constant value of
* the record_description structure. This means the additional cost
Expand Down

0 comments on commit f07f98e

Please sign in to comment.