diff --git a/include/coreir-c/coreir.h b/include/coreir-c/coreir.h index c99e95e76..98e4425bb 100644 --- a/include/coreir-c/coreir.h +++ b/include/coreir-c/coreir.h @@ -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); diff --git a/src/coreir-c/coreir-c.cpp b/src/coreir-c/coreir-c.cpp index b04f89a50..7c88b84a9 100644 --- a/src/coreir-c/coreir-c.cpp +++ b/src/coreir-c/coreir-c.cpp @@ -256,6 +256,16 @@ extern "C" { count++; } } + + const char* COREModuleGetMetaData(COREModule* core_mod) { + Module* mod = rcast(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)->getName().c_str();