app/cmDspPgmJsonToDot.h/c : Initial partial implementation.

This commit is contained in:
kevin 2015-09-24 19:14:27 -04:00
parent 47db49bb43
commit 611eda87de
2 changed files with 132 additions and 0 deletions

110
app/cmDspPgmJsonToDot.c Normal file
View File

@ -0,0 +1,110 @@
typedef struct cmDotPort_str
{
cmChar_t* label;
struct cmDotPort_str* link;
} cmDotPort_t;
typedef struct cmDotProc_str
{
cmChar_t* class;
cmChar_t* inst;
cmDotPort_t* list;
struct cmDotProc_str* link;
} cmDotProc_t;
typedef struct cmDot_str
{
cmDotProc_t* list;
} cmDot_t;
void _cmDotNewProc( cmDot_t* p, const cmChar_t* class, const cmChar_t* inst )
{
}
void _cmDotNewPort( cmDot_t* p, const cmChar_t* srcStr, const cmChar_t* srcPortStr, const cmChar_t* dstStr, const cmChar_t* dstPortStr )
{
}
cmDotRC_t cmDspPgmJsonToDot( cmCtx_t* ctx, const cmChar_t* inFn, const cmChar_t* outFn )
{
cmDotRC_t rc = kOkDotRC;
cmJsonH_t jsH = cmJsonNullHandle;
cmErr_t err;
cmJsonNode_t* arr;
cmJsonNode_t* rp;
const char* errLbl = NULL;
cmErrSetup(&err,&ctx->rpt,"cmDspPgmJsonToDot");
if( cmJsonInitializeFromFile( &jsH, inFn, ctx ) != kOkJsRC )
return cmErrMsg(&err,kJsonFailDotRC,"The program description file '%s' could not be opened.",cmStringNullGuard(inFn));
if((arr = cmJsonFindValue(jsH, "inst_array", NULL, kArrayTId )) == NULL )
{
}
unsigned n = cmJsonChildCount(arr);
for(i=0; i<n; ++i)
{
if((rp = cmJsonArrayElement(arr,i)) == NULL )
{
}
cmChar_t* classStr = NULL;
cmChar_t* instStr = NULL;
if( cmJsonMemberValues(rp, &errLbl,
"class", kStringTId, &classStr,
"label", kStringTId, &instStr
NULL ) != kOkJsRC )
{
}
_cmDotNewProc( p, classStr, instStr );
}
if((arr = cmJsonFindValue(jsH, "conn_array", NULL, kArrayTId)) == NULL )
{
}
unsigned n = cmJsonChildCount(arr);
for(i=0; i<n; ++i)
{
if((rp = cmJsonArrayElement(arr,i)) == NULL )
{
}
cmChar_t* srcStr = NULL;
cmChar_t* srcPortStr = NULL;
cmChar_t* dstStr = NULL;
cmChar_t* dstPortStr = NULL;
if( cmJsonMemberValues(rp, &errLbl,
"sid", kStringTId, &srcStr,
"svar", kStringTId, &srcPortStr,
"did", kStringTId, &dstStr,
"dvar", kStringTId, &dstPortStr,
NULL) != kOkJsRC )
{
}
_cmDotNewPort( p, srcStr, srcPortStr, dstStr, dstPortStr );
}
errLabel:
cmJsonFinalize(&jsH);
return rc;
}

22
app/cmDspPgmJsonToDot.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef cmDspPgmJsonToDot_h
#define cmDspPgmJsonToDot_h
#ifdef __cplusplus
extern "C" {
#endif
enum
{
kOkDotRC,
kJsonFailDotRC
};
typedef unsigned cmDotRC_t;
#ifdef __cplusplus
}
#endif
#endif