Commit 42e9e48d4f37546ab4d79393ed32ed67f5f2e0c1

Authored by totoro
1 parent f9e53009

add generation of graphviz file

densaku.aproj
... ... @@ -103,6 +103,7 @@
103 103 <Folder Include="src\generation" />
104 104 <Folder Include="src\generation\anubis" />
105 105 <Folder Include="src\generation\javascript" />
  106 + <Folder Include="src\generation\graphviz" />
106 107 <Compile Include="calexium_lib\asterisk\ami.anubis" />
107 108 <Compile Include="calexium_lib\asterisk\ami_commands.anubis" />
108 109 <Compile Include="calexium_lib\asterisk\ami_types.anubis" />
... ... @@ -164,6 +165,7 @@
164 165 <Compile Include="calexium_lib\web\CXM_web_arg_encode.anubis" />
165 166 <Compile Include="calexium_lib\web\CXM_web_arg_utils.anubis" />
166 167 <Compile Include="calexium_lib\web\CXM_web_dump.anubis" />
  168 + <Compile Include="calexium_lib\web\CXM_web_session.anubis" />
167 169 <Compile Include="calexium_lib\web\CXM_widgets.anubis" />
168 170 <Compile Include="calexium_lib\web\CXM_xml_rpc.anubis" />
169 171 <Compile Include="calexium_lib\web\CXM_xml_rpc_parser.anubis" />
... ... @@ -561,6 +563,9 @@
561 563 <Compile Include="library\xml\xml_parser.apg.anubis" />
562 564 <Compile Include="library\xml\xml_parser_types.anubis" />
563 565 <Compile Include="src\generation\files.anubis" />
  566 + <Compile Include="src\generation\graphviz\graphviz_header.anubis" />
  567 + <Compile Include="src\generation\graphviz\graphviz_main.anubis" />
  568 + <Compile Include="src\generation\graphviz\graphviz_type.anubis" />
564 569 <Compile Include="src\generation\messages.anubis" />
565 570 <Compile Include="src\generation\message_header.anubis" />
566 571 <Compile Include="src\generation\message_messages.anubis" />
... ...
src/generation/files.anubis
... ... @@ -13,6 +13,7 @@ read tools/basis.anubis
13 13 read types_checking.anubis
14 14 read generation/types.anubis //generate all types and the message for these types
15 15 read generation/messages.anubis //generate all messages collection
  16 +read generation/graphviz/graphviz_main.anubis
16 17  
17 18 public define Maybe(One)
18 19 generate_message_files
... ... @@ -57,6 +58,10 @@ public define Maybe(One)
57 58  
58 59 println("Generating messages collection");
59 60 make_all_messages(messages, destination_dir);
  61 +
  62 + println("Generating graphviz");
  63 + forget(make_graphviz_types(types, destination_dir));
  64 +
60 65 writeString(ini, "TYPES", "SHA1", current_types_SHA1);
61 66 writeString(ini, "MESSAGES", "SHA1", current_messages_SHA1);
62 67 writeIniInfo(ini);
... ...
src/generation/graphviz/graphviz_header.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 05/04/2017
  5 + * Time: 20:37
  6 + * © Calexium
  7 + */
  8 +
  9 +read tools/basis.anubis
  10 +read tools/streams.anubis
  11 +read tools/ISO-8601.anubis
  12 +read system/string.anubis
  13 +
  14 +public define Maybe(One)
  15 + generate_graphviz_header
  16 + (
  17 + Stream stream
  18 + )=
  19 + write_string(stream,
  20 +"/*
  21 + * Created by 伝作 (Densaku).
  22 + * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
  23 + * Date: "+_Int_to_ISO_8601_date(now)+"
  24 + * Time: "+_Int_to_ISO_8601_time(now)+"
  25 + *
  26 + */
  27 +
  28 +digraph DS {
  29 + splines=true;
  30 + edge [color=gray50, fontname=\"verdana\", fontsize=10]
  31 + node [shape=none, bgcolor=gray40, fontname=\"verdana\", fontsize=10]
  32 +
  33 +"
  34 + )
  35 +.
  36 +
  37 +public define Maybe(One)
  38 + generate_graphviz_footer
  39 + (
  40 + Stream stream
  41 + )=
  42 + write_string(stream,"\n}\n")
  43 +.
... ...
src/generation/graphviz/graphviz_main.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 05/04/2017
  5 + * Time: 20:33
  6 + * © Calexium
  7 + */
  8 +
  9 +read tools/basis.anubis
  10 +read tools/streams.anubis
  11 +read densaku_lib/types/densaku.anubis
  12 +read generation/graphviz/graphviz_header.anubis
  13 +read generation/graphviz/graphviz_type.anubis
  14 +
  15 +public define Maybe(One)
  16 + make_graphviz_types
  17 + (
  18 + List(DS_Type) types,
  19 + String destination_dir
  20 + )=
  21 + with file_name = destination_dir+"types/generated/graphviz.gv",
  22 +
  23 + if file(file_name, new) is
  24 + {
  25 + failure then println("can't create file "+file_name);failure,
  26 + success(fd) then
  27 + with strm = make_stream(fd),
  28 +
  29 + if generate_graphviz_header(strm) is { failure then failure, success(_) then
  30 + if generate_graphviz_types(strm, types) is { failure then failure, success(_) then
  31 + if generate_graphviz_footer(strm) is { failure then failure, success(_) then
  32 + success(unique)
  33 + }}}
  34 + }
  35 +.
... ...
src/generation/graphviz/graphviz_type.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 05/04/2017
  5 + * Time: 20:48
  6 + * © Calexium
  7 + */
  8 +
  9 +read tools/basis.anubis
  10 +read tools/streams.anubis
  11 +read densaku_lib/types/densaku.anubis
  12 +read generation/graphviz/graphviz_type.anubis
  13 +
  14 +
  15 +public define One
  16 + generate_graphviz_DS_Anubis_Type_relation
  17 + (
  18 + DS_Anubis_Type anb_type,
  19 + String type_name,
  20 + String alternative_name,
  21 + String component_name,
  22 + Var(String) type_relation
  23 + )=
  24 +
  25 + if anb_type is
  26 + {
  27 + one then unique,
  28 + bool then unique,
  29 + int then unique,
  30 + word8 then unique,
  31 + word16 then unique,
  32 + word32 then unique,
  33 + string then unique,
  34 + float then unique,
  35 +// float32 then "Float32", reserved for future implementation in Anubis (still under construction in Anubis)
  36 +// float64 then "Float64", reserved for future implementation in Anubis (still under construction in Anubis)
  37 + ds_type(foreign_type_name) then
  38 + type_relation <- *type_relation + " "+type_name+":"+alternative_name+"_"+component_name+" -> "+foreign_type_name+":TYPE\n",
  39 +// println("* "+*type_relation),
  40 + extern_type(foreign_type_name, read) then
  41 + type_relation <- *type_relation + " "+type_name+":"+alternative_name+"_"+component_name+" -> "+foreign_type_name+":TYPE\n",
  42 +// println("* "+*type_relation),
  43 + }
  44 +.
  45 +
  46 +public define String
  47 + generate_graphviz_DS_Anubis_Type_color
  48 + (
  49 + DS_Anubis_Type anb_type
  50 + )=
  51 +
  52 + if anb_type is
  53 + {
  54 + one then "darkviolet",
  55 + bool then "darkviolet",
  56 + int then "darkviolet",
  57 + word8 then "darkviolet",
  58 + word16 then "darkviolet",
  59 + word32 then "darkviolet",
  60 + string then "darkviolet",
  61 + float then "darkviolet",
  62 +// float32 then "Float32", reserved for future implementation in Anubis (still under construction in Anubis)
  63 +// float64 then "Float64", reserved for future implementation in Anubis (still under construction in Anubis)
  64 + ds_type(type_name) then "mediumblue",
  65 + extern_type(type_name, read) then "mediumblue",
  66 + }
  67 +.
  68 +
  69 +public define String
  70 + generate_graphviz_DS_Component_list
  71 + (
  72 + List(DS_Component) components,
  73 + String type_name,
  74 + String alternative_name,
  75 + Var(String) type_relation
  76 + )=
  77 +
  78 + if components is
  79 + {
  80 + [] then
  81 + //close the alternative with ")"
  82 + " <TR><TD COLSPAN=\"2\" VALIGN=\"MIDDLE\" ALIGN=\"LEFT\"><FONT COLOR=\"orangered\"><B>)</B></FONT></TD></TR>\n",
  83 + [h . t] then
  84 + since h is component(b_list, anb_type, name, _),
  85 + generate_graphviz_DS_Anubis_Type_relation(anb_type, type_name, alternative_name, name, type_relation);
  86 + with line_head = if b_list is list then
  87 + // <- TYPE ->
  88 + " <TR><TD ALIGN=\"LEFT\"><B><FONT COLOR=\"darkviolet\">List</FONT>(<FONT COLOR=\""+generate_graphviz_DS_Anubis_Type_color(anb_type)+"\">"+dump(anb_type)+"</FONT>)</B></TD>"
  89 + else
  90 + " <TR><TD ALIGN=\"LEFT\"><B><FONT COLOR=\""+generate_graphviz_DS_Anubis_Type_color(anb_type)+"\">"+dump(anb_type)+"</FONT></B></TD>",
  91 +
  92 + //construct the complete line
  93 + line_head+"<TD ALIGN=\"LEFT\" PORT=\""+alternative_name+"_"+name+"\" >"+name+"</TD></TR>\n" +
  94 +
  95 + generate_graphviz_DS_Component_list(t, type_name, alternative_name, type_relation)
  96 + }
  97 +.
  98 +
  99 +public define String
  100 + generate_graphviz_DS_Alternative_list
  101 + (
  102 + List(DS_Alternative) ds_alts,
  103 + String type_name,
  104 + Var(String) type_relation
  105 + )=
  106 + with prefix = "\n ",
  107 + if ds_alts is
  108 + {
  109 + [] then println("empty");"\n",
  110 + [h . t] then
  111 + if h is
  112 + {
  113 + enum(name, _comment) then
  114 + "\n <TR><TD COLSPAN=\"2\" PORT=\"alt:"+name+"\" VALIGN=\"MIDDLE\" BGCOLOR=\"bisque\" ALIGN=\"LEFT\"><FONT COLOR=\"orangered\"><B>"+name+"</B></FONT></TD></TR>\n"+
  115 + generate_graphviz_DS_Alternative_list(t, type_name, type_relation),
  116 +
  117 + alternative(name, comment, components) then
  118 + "\n <TR><TD COLSPAN=\"2\" PORT=\"alt:"+name+"\" VALIGN=\"MIDDLE\" BGCOLOR=\"bisque\" ALIGN=\"LEFT\"><FONT COLOR=\"orangered\"><B>"+name+" (</B></FONT></TD></TR>\n"+
  119 + //dump(components, true, type_length, name_length)+
  120 + generate_graphviz_DS_Component_list(components, type_name, name, type_relation)+
  121 + generate_graphviz_DS_Alternative_list(t, type_name, type_relation)
  122 + }
  123 + }
  124 +.
  125 +
  126 +public define String
  127 + generate_graphviz_type
  128 + (
  129 + DS_Type _ds_type, //list of type description
  130 + String indent
  131 + )=
  132 + since _ds_type is ds_type(type_name, _, ds_alts),
  133 + with type_relation = var(""),
  134 +
  135 + with start = "\n\n"+
  136 + " "+type_name+" [ label=<\n"+
  137 + " <TABLE BORDER=\"1\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"2\" BGCOLOR=\"gray95\">\n"+
  138 + " <TR><TD COLSPAN=\"2\" PORT=\"TYPE\" VALIGN=\"MIDDLE\" ALIGN=\"CENTER\" BGCOLOR=\"lightblue\" ><FONT COLOR=\"mediumblue\"><B>"+type_name+"</B></FONT></TD></TR>\n"+
  139 + generate_graphviz_DS_Alternative_list(ds_alts, type_name, type_relation)+
  140 + " </TABLE>\n"+
  141 + " >];\n"+
  142 + "\n",
  143 + start+*type_relation
  144 +.
  145 +
  146 +public define Maybe(One)
  147 + generate_graphviz_types
  148 + (
  149 + Stream stream,
  150 + List(DS_Type) types //list of type description
  151 + )=
  152 +
  153 + map_forget((DS_Type type) |->
  154 + since type is ds_type(type_name, _, ds_alts),
  155 + println("generating graphviz for Type ["+type_name+"]");
  156 + write_string(stream,
  157 + generate_graphviz_type(type, " "))
  158 + ,
  159 + types);
  160 + success(unique)
  161 +.
... ...
src/generation/types.anubis
... ... @@ -8,6 +8,7 @@
8 8  
9 9 read generation/types_header.anubis
10 10 read generation/types_messages.anubis
  11 +read generation/graphviz/graphviz_main.anubis
11 12  
12 13 read system/files.anubis
13 14 read system/string.anubis
... ...