Skip to content

Commit

Permalink
- function to get all the information of the list item. Used by debug…
Browse files Browse the repository at this point in the history
…ger.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19641 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Mar 19, 2014
1 parent e34d97f commit 795c77b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions SimulationRuntime/c/meta/meta_modelica.c
Expand Up @@ -817,6 +817,31 @@ char* getRecordElement(modelica_metatype arr, modelica_integer i) {
return anyStringBuf;
}

/*
* Used by OMEdit for debugging.
* Returns the List Item as an array e.g ^done,omc_listitem={name, displayName, type}
*/
char* getListItem(modelica_metatype lst, modelica_integer i) {
/* get the item from the list */
void* name = (void*)mmc_gdb_listGet(0, lst, i);
char *displayName = NULL, *type = NULL, *formatString = NULL;

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

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

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

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
1 change: 1 addition & 0 deletions SimulationRuntime/c/meta/meta_modelica.h
Expand Up @@ -424,6 +424,7 @@ extern void changeStdStreamBuffer(void); /* For debugging */

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

/*
* Generated (Meta)Records should access a static, constant value of
Expand Down

0 comments on commit 795c77b

Please sign in to comment.