Skip to content

Commit

Permalink
Merge pull request #731 from rdaly525/c-metadata
Browse files Browse the repository at this point in the history
added funtion to get metadata for modules
  • Loading branch information
rdaly525 authored Apr 26, 2019
2 parents b5c74df + e13986e commit 26c4ded
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/coreir-c/coreir.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ extern void COREModuleDefAddConnectionMetaDataStr(COREModuleDef* module_def,
COREWireable* a, COREWireable* b, char *key, char *value);
extern void COREModuleAddMetaDataStr(COREModule* module, char *key, char *value);

//This returns a malloc'd string that should be freed by the user
extern const char* COREModuleGetMetaData(COREModule* module);

// BEGIN : directedview
extern const char** COREDirectedConnectionGetSrc(COREDirectedConnection* directed_connection);
extern const char** COREDirectedConnectionGetSnk(COREDirectedConnection* directed_connection);
Expand Down
10 changes: 10 additions & 0 deletions src/coreir-c/coreir-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ extern "C" {
count++;
}
}

const char* COREModuleGetMetaData(COREModule* core_mod) {
Module* mod = rcast<Module*>(core_mod);
string mstr = mod->getMetaData().dump();
std::size_t len = mstr.size() + 1;
char* cstr = (char*) malloc(len);
strcpy(cstr,mstr.c_str());
return cstr;
}


const char* COREModuleGetName(COREModule* module) {
return rcast<Module*>(module)->getName().c_str();
Expand Down

0 comments on commit 26c4ded

Please sign in to comment.