Skip to content

Commit

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

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19726 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Mar 24, 2014
1 parent fbf364c commit 7049f60
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions SimulationRuntime/c/meta/meta_modelica.c
Expand Up @@ -886,6 +886,37 @@ char* getOptionItem(modelica_metatype arr, modelica_integer i) {
return anyStringBuf;
}

/*
* Used by OMEdit for debugging.
* Returns the Tuple element as an array e.g ^done,omc_tupleelement={name, displayName, type}
*/
char* getTupleElement(modelica_metatype arr, modelica_integer i) {
/* get the element from the record array */
void* name = (void*)mmc_gdb_arrayGet(0, arr, i);
char nameStr[40], displayName[40], *ty = NULL, *formatString = NULL;

/* print the pointer as long to a buffer to get the string length */
sprintf(nameStr, "%ld", (long)name);

/* get the name of the element */
sprintf(displayName, "%d", (int)i);

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

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

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

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 @@ -431,6 +431,7 @@ extern void changeStdStreamBuffer(void); /* For debugging */
extern char* getRecordElement(modelica_metatype arr, modelica_integer i);
extern char* getListItem(modelica_metatype lst, modelica_integer i);
extern char* getOptionItem(modelica_metatype arr, modelica_integer i);
extern char* getTupleElement(modelica_metatype arr, modelica_integer i);

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

0 comments on commit 7049f60

Please sign in to comment.