Quellcode durchsuchen

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

master
kevin vor 9 Jahren
Ursprung
Commit
611eda87de
2 geänderte Dateien mit 132 neuen und 0 gelöschten Zeilen
  1. 110
    0
      app/cmDspPgmJsonToDot.c
  2. 22
    0
      app/cmDspPgmJsonToDot.h

+ 110
- 0
app/cmDspPgmJsonToDot.c Datei anzeigen

@@ -0,0 +1,110 @@
1
+
2
+typedef struct cmDotPort_str
3
+{
4
+  cmChar_t*             label;
5
+  struct cmDotPort_str* link;
6
+} cmDotPort_t;
7
+
8
+typedef struct cmDotProc_str
9
+{
10
+  cmChar_t*             class;
11
+  cmChar_t*             inst;
12
+  
13
+  cmDotPort_t*          list;
14
+  struct cmDotProc_str* link;
15
+} cmDotProc_t;
16
+
17
+typedef struct cmDot_str
18
+{
19
+  cmDotProc_t* list;
20
+} cmDot_t;
21
+
22
+
23
+void _cmDotNewProc( cmDot_t* p, const cmChar_t* class, const cmChar_t* inst )
24
+{
25
+  
26
+}
27
+
28
+void _cmDotNewPort( cmDot_t* p, const cmChar_t* srcStr, const cmChar_t* srcPortStr, const cmChar_t* dstStr, const cmChar_t* dstPortStr )
29
+{
30
+}
31
+
32
+
33
+cmDotRC_t cmDspPgmJsonToDot( cmCtx_t* ctx, const cmChar_t* inFn, const cmChar_t* outFn )
34
+{
35
+  cmDotRC_t rc  = kOkDotRC;
36
+  cmJsonH_t jsH = cmJsonNullHandle;
37
+  cmErr_t   err;
38
+  cmJsonNode_t* arr;
39
+    cmJsonNode_t* rp;
40
+    const char* errLbl = NULL;
41
+  
42
+  cmErrSetup(&err,&ctx->rpt,"cmDspPgmJsonToDot");
43
+  
44
+  if( cmJsonInitializeFromFile( &jsH, inFn, ctx ) != kOkJsRC )
45
+    return cmErrMsg(&err,kJsonFailDotRC,"The program description file '%s' could not be opened.",cmStringNullGuard(inFn));
46
+
47
+  if((arr = cmJsonFindValue(jsH, "inst_array", NULL, kArrayTId )) == NULL )
48
+  {
49
+  }
50
+
51
+  unsigned n = cmJsonChildCount(arr);
52
+  
53
+  for(i=0; i<n; ++i)
54
+  {
55
+    
56
+    if((rp = cmJsonArrayElement(arr,i)) == NULL )
57
+    {
58
+    }
59
+
60
+    cmChar_t* classStr = NULL;
61
+    cmChar_t* instStr = NULL;
62
+    if( cmJsonMemberValues(rp, &errLbl,
63
+        "class", kStringTId, &classStr,
64
+        "label", kStringTId, &instStr
65
+        NULL ) != kOkJsRC )
66
+    {
67
+    }
68
+
69
+    _cmDotNewProc( p, classStr, instStr );
70
+    
71
+  }
72
+
73
+  if((arr = cmJsonFindValue(jsH, "conn_array", NULL, kArrayTId)) == NULL )
74
+  {
75
+  }
76
+
77
+  unsigned n = cmJsonChildCount(arr);
78
+
79
+  for(i=0; i<n; ++i)
80
+  {
81
+    if((rp = cmJsonArrayElement(arr,i)) == NULL )
82
+    {
83
+    }
84
+
85
+    cmChar_t* srcStr     = NULL;
86
+    cmChar_t* srcPortStr = NULL;
87
+    cmChar_t* dstStr     = NULL;
88
+    cmChar_t* dstPortStr = NULL;
89
+
90
+    if( cmJsonMemberValues(rp, &errLbl,
91
+        "sid",  kStringTId, &srcStr,
92
+        "svar", kStringTId, &srcPortStr,
93
+        "did",  kStringTId, &dstStr,
94
+        "dvar", kStringTId, &dstPortStr,
95
+        NULL) != kOkJsRC )
96
+    {
97
+    }
98
+
99
+    _cmDotNewPort( p, srcStr, srcPortStr, dstStr, dstPortStr );
100
+    
101
+    
102
+  }
103
+  
104
+
105
+  
106
+ errLabel:
107
+  cmJsonFinalize(&jsH);
108
+  
109
+  return rc;
110
+}

+ 22
- 0
app/cmDspPgmJsonToDot.h Datei anzeigen

@@ -0,0 +1,22 @@
1
+#ifndef cmDspPgmJsonToDot_h
2
+#define cmDspPgmJsonToDot_h
3
+
4
+#ifdef __cplusplus
5
+extern "C" {
6
+#endif
7
+
8
+  enum
9
+  {
10
+    kOkDotRC,
11
+    kJsonFailDotRC
12
+  };
13
+
14
+  typedef unsigned cmDotRC_t;
15
+
16
+  
17
+  
18
+#ifdef __cplusplus
19
+}
20
+#endif
21
+  
22
+#endif

Laden…
Abbrechen
Speichern