Commit c480c7a869fab251dffe7673b57765ed3c80e926

Authored by totoro
1 parent ec4db71f

Add support of DS_Type_File

@@ -566,6 +566,7 @@ @@ -566,6 +566,7 @@
566 <Compile Include="src\generation\graphviz\graphviz_header.anubis" /> 566 <Compile Include="src\generation\graphviz\graphviz_header.anubis" />
567 <Compile Include="src\generation\graphviz\graphviz_main.anubis" /> 567 <Compile Include="src\generation\graphviz\graphviz_main.anubis" />
568 <Compile Include="src\generation\graphviz\graphviz_type.anubis" /> 568 <Compile Include="src\generation\graphviz\graphviz_type.anubis" />
  569 + <Compile Include="src\generation\intermediate_type.anubis" />
569 <Compile Include="src\generation\messages.anubis" /> 570 <Compile Include="src\generation\messages.anubis" />
570 <Compile Include="src\generation\message_header.anubis" /> 571 <Compile Include="src\generation\message_header.anubis" />
571 <Compile Include="src\generation\message_messages.anubis" /> 572 <Compile Include="src\generation\message_messages.anubis" />
densaku_lib @ e19a5e659e2
1 -Subproject commit aaa50241ac140b5441e8cfb34bd4e884a4828af7 1 +Subproject commit e19a5e659e24d4bf9c97e5a4f313f80a86414f5e
src/generation/files.anubis
@@ -18,9 +18,9 @@ read generation/graphviz/graphviz_main.anubis @@ -18,9 +18,9 @@ read generation/graphviz/graphviz_main.anubis
18 public define Maybe(One) 18 public define Maybe(One)
19 generate_message_files 19 generate_message_files
20 ( 20 (
21 - List(DS_Type) types, //Types description  
22 - List(DS_Message) messages,  
23 - String destination_dir 21 + List(DS_Type_File) type_files, //Types description
  22 + List(DS_Message) messages,
  23 + String destination_dir
24 )= 24 )=
25 //before processing the generation we check if we need to do it, by checking the SHA1 generated with the 25 //before processing the generation we check if we need to do it, by checking the SHA1 generated with the
26 //previous generation. If SHA1 is same, this means the database is exactly same and we have nothing to do. 26 //previous generation. If SHA1 is same, this means the database is exactly same and we have nothing to do.
@@ -28,14 +28,14 @@ public define Maybe(One) @@ -28,14 +28,14 @@ public define Maybe(One)
28 28
29 //process. We serialize the types and messages model and make SHA1 of the result. This result is stored in file densaku.ini 29 //process. We serialize the types and messages model and make SHA1 of the result. This result is stored in file densaku.ini
30 //in root of destination_dir 30 //in root of destination_dir
31 - with current_types_SHA1 = to_ascii(sha1(serialize(types))), 31 + with current_types_SHA1 = to_ascii(sha1(serialize(type_files))),
32 with current_messages_SHA1 = to_ascii(sha1(serialize(messages))), 32 with current_messages_SHA1 = to_ascii(sha1(serialize(messages))),
33 33
34 println("\nDensaku Generator"); 34 println("\nDensaku Generator");
35 println("Destination dir: "+destination_dir); 35 println("Destination dir: "+destination_dir);
36 with ini = loadIniFile(destination_dir+"/densaku.ini"), 36 with ini = loadIniFile(destination_dir+"/densaku.ini"),
37 37
38 - with types_SHA1 = readString(ini, "TYPES", "SHA1", "N/A"), 38 + with types_SHA1 = "::", //readString(ini, "TYPES", "SHA1", "N/A"),
39 with messages_SHA1 = readString(ini, "MESSAGES", "SHA1", "N/A"), 39 with messages_SHA1 = readString(ini, "MESSAGES", "SHA1", "N/A"),
40 40
41 println("Saved Types SHA1 = "+types_SHA1); 41 println("Saved Types SHA1 = "+types_SHA1);
@@ -48,25 +48,34 @@ public define Maybe(One) @@ -48,25 +48,34 @@ public define Maybe(One)
48 if types_SHA1 = current_types_SHA1 & messages_SHA1 = current_messages_SHA1 then 48 if types_SHA1 = current_types_SHA1 & messages_SHA1 = current_messages_SHA1 then
49 success(println("Types and messages already generated, nothing to do")) 49 success(println("Types and messages already generated, nothing to do"))
50 else 50 else
51 - if check_types(types) is  
52 - {  
53 - failure then failure,  
54 - success(_) then  
55 -  
56 - println("Generating types and message files");  
57 - make_all_types(types, destination_dir);  
58 -  
59 - println("Generating messages collection");  
60 - make_all_messages(messages, destination_dir);  
61 -  
62 - println("Generating graphviz");  
63 - forget(make_graphviz_types(types, destination_dir));  
64 -  
65 - writeString(ini, "TYPES", "SHA1", current_types_SHA1);  
66 - writeString(ini, "MESSAGES", "SHA1", current_messages_SHA1);  
67 - writeIniInfo(ini);  
68 - success(unique)  
69 - }. 51 + if map_escape((DS_Type_File file)
  52 + |->
  53 + since file is ds_type_file(output_dir, file_name, types),
  54 + if check_types(types) is
  55 + {
  56 + failure then failure,
  57 + success(_) then
  58 +
  59 + println("Generating types and message files");
  60 + make_all_types(output_dir, file_name, types, destination_dir);
  61 +
  62 + println("Generating messages collection");
  63 + make_all_messages(messages, destination_dir);
  64 +
  65 + println("Generating graphviz");
  66 + forget(make_graphviz_types(types, destination_dir));
  67 +
  68 + writeString(ini, "TYPES", "SHA1", current_types_SHA1);
  69 + writeString(ini, "MESSAGES", "SHA1", current_messages_SHA1);
  70 + writeIniInfo(ini);
  71 + success(unique)
  72 + },
  73 + type_files) is
  74 + {
  75 + failure then failure,
  76 + success(_) then success(unique)
  77 + }
  78 +.
70 79
71 global define DS_Generator_API 80 global define DS_Generator_API
72 ds_gen = 81 ds_gen =
src/generation/intermediate_type.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 12/04/2017
  5 + * Time: 05:42
  6 + * © Calexium
  7 + */
  8 +
  9 +read tools/basis.anubis
  10 +read densaku_lib/types/ds_types.anubis
  11 +read system/lists.anubis
  12 +
  13 +define Bool
  14 + is_higher_level
  15 + (
  16 + Int level,
  17 + String search_type,
  18 + List(DS_Type) beside_type,
  19 + Int beside_level
  20 + )=
  21 + if beside_type is
  22 + {
  23 + [] then false,
  24 + [h . t] then
  25 + since h is ds_type(name, _, _),
  26 + if search_type = name then
  27 + if beside_level > level then
  28 + true
  29 + else
  30 + false
  31 + else
  32 + is_higher_level(level, search_type, t, beside_level +1)
  33 + }
  34 +.
  35 +
  36 +define Bool
  37 + is_higher_level
  38 + (
  39 + Int level,
  40 + String search_type,
  41 + List(DS_Type) beside_type
  42 + )=
  43 + is_higher_level(level, search_type, beside_type, 0)
  44 +.
  45 +
  46 +define List(String)
  47 + extract_intermediate_type
  48 + (
  49 + Int level, //level of main type where belonging the component
  50 + List(DS_Component) components,
  51 + List(String) so_far,
  52 + List(DS_Type) beside_type
  53 + )=
  54 + if components is
  55 + {
  56 + [] then so_far,
  57 + [h . t] then
  58 + since h is component(_b_list, _anb_type, _name, _comment),
  59 + if _anb_type is ds_type(_type_name) then
  60 + if is_higher_level(level, _type_name, beside_type) then
  61 + extract_intermediate_type(level, t, append_once(so_far, _type_name), beside_type)
  62 + else
  63 + extract_intermediate_type(level, t, so_far, beside_type)
  64 + else if _anb_type is extern_type(_type_name, read_file) then
  65 + extract_intermediate_type(level, t, so_far, beside_type)
  66 + else
  67 + extract_intermediate_type(level, t, so_far, beside_type)
  68 + }
  69 +.
  70 +
  71 +define List(String)
  72 +/* look into each alternative
  73 + */
  74 + extract_intermediate_type
  75 + (
  76 + Int level,
  77 + List(DS_Alternative) alt,
  78 + List(String) so_far,
  79 + List(DS_Type) beside_type
  80 + )=
  81 + if alt is
  82 + {
  83 + [] then so_far,
  84 + [h . t] then
  85 + if h is
  86 + {
  87 + enum(_ , _) then extract_intermediate_type(level, t, so_far, beside_type)
  88 + alternative(_, _, components) then
  89 + extract_intermediate_type(level, t, extract_intermediate_type(level, components, so_far, beside_type), beside_type)
  90 + }
  91 + }
  92 +.
  93 +
  94 +public define List(String)
  95 + get_all_intermediate_type
  96 + (
  97 + DS_Type ds_type, //Type from which we want to extract the extern types
  98 + Int level,
  99 + List(DS_Type) beside_type //all known type in same file
  100 + )=
  101 + since ds_type is ds_type(_, _, ds_alternatives),
  102 + extract_intermediate_type(level, ds_alternatives, [], beside_type)
  103 +.
  104 +
  105 +public define List(String)
  106 + get_all_intermediate_type
  107 + (
  108 + List(DS_Type) beside_type, //all known type in same file
  109 + List(DS_Type) scrut,
  110 + Int level,
  111 + List(String) so_far
  112 + )=
  113 + if scrut is
  114 + {
  115 + [] then so_far,
  116 + [h . t] then
  117 + get_all_intermediate_type(beside_type, t, level+1, so_far + get_all_intermediate_type(h, level, beside_type))
  118 + }
  119 +.
  120 +
  121 +public define List(String)
  122 + get_all_intermediate_type
  123 + (
  124 + List(DS_Type) beside_type //all known type in same file
  125 + )=
  126 + get_all_intermediate_type(beside_type, beside_type, 0, [])
  127 +.
  128 +
  129 + if beside_type
  130 + since ds_type is ds_type(_, _, ds_alternatives),
  131 + extract_intermediate_type(level, ds_alternatives, [], beside_type)
  132 +.
src/generation/message_messages.anubis
@@ -144,9 +144,9 @@ define String @@ -144,9 +144,9 @@ define String
144 with name = "_"+to_lower(field_name), 144 with name = "_"+to_lower(field_name),
145 indent + "// [Field's type = "+(if b_list is list then "List(" else "")+dump(anb_type)+(if b_list is list then ")" else "")+"] Field's name '"+field_name+"'\n"+ 145 indent + "// [Field's type = "+(if b_list is list then "List(" else "")+dump(anb_type)+(if b_list is list then ")" else "")+"] Field's name '"+field_name+"'\n"+
146 (if b_list is list then 146 (if b_list is list then
147 - anb_type_list_from_message(indent, type_msg, anb_type, field_name, name, brace_counter) 147 + anb_type_list_from_message(indent, type_msg, anb_type, field_name, "_"+name+"_", brace_counter)
148 else 148 else
149 - anb_type_from_message(indent, type_msg, anb_type, field_name, name, brace_counter)) 149 + anb_type_from_message(indent, type_msg, anb_type, field_name, "_"+name+"_", brace_counter))
150 + 150 +
151 generate_fields_from_message(indent, type_msg, t, brace_counter) 151 generate_fields_from_message(indent, type_msg, t, brace_counter)
152 152
src/generation/types.anubis
@@ -12,62 +12,214 @@ read generation/graphviz/graphviz_main.anubis @@ -12,62 +12,214 @@ read generation/graphviz/graphviz_main.anubis
12 12
13 read system/files.anubis 13 read system/files.anubis
14 read system/string.anubis 14 read system/string.anubis
  15 +read system/lists.anubis
15 read tools/streams.anubis 16 read tools/streams.anubis
16 read tools/basis.anubis 17 read tools/basis.anubis
17 read densaku_lib/types/ds_types.anubis 18 read densaku_lib/types/ds_types.anubis
  19 +read generation/intermediate_type.anubis
18 20
19 -define Maybe(One)  
20 - generate_type 21 +type Type_File_Parts:
  22 + type_file_part(
  23 + String transmit,
  24 + List(String) intermediate,
  25 + String declaration,
  26 + String message_str
  27 + )
  28 +.
  29 +
  30 +define String
  31 + concat_transmit
21 ( 32 (
22 - Stream stream,  
23 - DS_Type ds_type 33 + List(Type_File_Parts) _parts
24 )= 34 )=
25 - if write_string(stream, dump_DS_Type(ds_type)) is failure then failure else 35 + join("",
  36 + map((Type_File_Parts part)
  37 + |->
  38 + since part is type_file_part(transmit_str, _, _, _),
  39 + transmit_str
  40 + ,
  41 + _parts
  42 + )
  43 + )
  44 +.
26 45
27 - success(unique) 46 +define List(String)
  47 + unique_intermediate
  48 + (
  49 + List(String) intermediate_types,
  50 + List(String) so_far
  51 + )=
  52 + if intermediate_types is
  53 + {
  54 + [] then so_far,
  55 + [h . t ] then unique_intermediate(t, append_once(so_far, h))
  56 + }
28 . 57 .
29 58
30 -define Maybe(One)  
31 - make_type_file 59 +define List(String)
  60 + unique_intermediate
32 ( 61 (
33 - DS_Type ds_type, //type description  
34 - String dest_dir 62 + List(Type_File_Parts) _parts,
  63 + List(String) so_far
  64 + )=
  65 + if _parts is
  66 + {
  67 + [] then so_far,
  68 + [h . t] then
  69 + since h is type_file_part(_, intermediate, _, _),
  70 + unique_intermediate(intermediate, so_far)
  71 + }
  72 +.
  73 +
  74 +
  75 +
  76 +define String
  77 + concat_intermediate
  78 + (
  79 + List(Type_File_Parts) _parts
  80 + )=
  81 + with final_list = unique_intermediate(_parts, []),
  82 + join("\n",
  83 + map((String intermediate)
  84 + |->
  85 + "public type "+intermediate+":..."
  86 + ,
  87 + final_list
  88 + )
  89 + )+"\n"
  90 +.
  91 +
  92 +define String
  93 + concat_declaration
  94 + (
  95 + List(Type_File_Parts) _parts
  96 + )=
  97 + join("\n\n",
  98 + map((Type_File_Parts part)
  99 + |->
  100 + since part is type_file_part(_, _, declaration_str, _),
  101 + declaration_str
  102 + ,
  103 + _parts
  104 + )
35 ) 105 )
36 - =  
37 - since ds_type is ds_type(name, generation, alternatives),  
38 - println("Generating file for type ["+name+"]");  
39 - with file_name = dest_dir+"types/generated/"+to_lower(name)+".anubis", 106 +.
  107 +
  108 +define String
  109 + concat_message
  110 + (
  111 + List(Type_File_Parts) _parts
  112 + )=
  113 + join("\n\n",
  114 + map((Type_File_Parts part)
  115 + |->
  116 + since part is type_file_part(_, _, _, message_str),
  117 + message_str
  118 + ,
  119 + _parts
  120 + )
  121 + )
  122 +.
40 123
  124 +define Maybe(One)
  125 + write_type_file
  126 + (
  127 + String file_name,
  128 + String header,
  129 + List(Type_File_Parts) file_parts
  130 + )=
  131 +
  132 + //with file_name = dest_dir+to_lower(name)+".anubis",
41 //create all necessary directories if doesn't exist. 133 //create all necessary directories if doesn't exist.
42 make_directories(file_name); 134 make_directories(file_name);
43 -  
44 if file(file_name, new) is 135 if file(file_name, new) is
45 { 136 {
46 failure then println("can't create file "+file_name);failure, 137 failure then println("can't create file "+file_name);failure,
47 success(fd) then 138 success(fd) then
48 with strm = make_stream(fd), 139 with strm = make_stream(fd),
49 - if generate_type_header(strm, ds_type) is { failure then failure, success(_) then  
50 - if generate_type(strm, ds_type) is { failure then failure, success(_) then  
51 - if generation is  
52 - {  
53 - no_message then success(unique),  
54 - message then  
55 - if generate_type_message_description(strm, ds_type) is { failure then failure, success(_) then  
56 - if generate_type_to_message(strm, ds_type) is { failure then failure, success(_) then  
57 - if generate_type_from_message(strm, ds_type) is { failure then failure, success(_) then  
58 - success(unique)}}}  
59 - }}} 140 + write_string(strm,
  141 + header +
  142 + concat_transmit(file_parts) + "\n" +
  143 + concat_intermediate(file_parts) + "\n" +
  144 + concat_declaration(file_parts) +
  145 + concat_message(file_parts)
  146 + )
60 } 147 }
61 . 148 .
  149 +
  150 +define Type_File_Parts
  151 + make_type_file
  152 + (
  153 + DS_Type ds_type, //type description
  154 + String dest_dir,
  155 + List(DS_Type) same_file_types
  156 + )
  157 + =
  158 + since ds_type is ds_type(name, generation, alternatives),
  159 + println("Generating file for type ["+name+"]");
  160 + with transmit_foreign = generate_transmit_foreign_type(ds_type, same_file_types),
  161 + with intermediate_type= get_all_intermediate_type(same_file_types),
  162 + with type_declaration = dump_DS_Type(ds_type),
  163 + with message_str =
  164 + if generation is
  165 + {
  166 + no_message then "",
  167 + message then
  168 + generate_type_message_description(ds_type) +
  169 + generate_type_to_message(ds_type) +
  170 + generate_type_from_message(ds_type)
  171 + },
  172 + type_file_part(transmit_foreign, intermediate_type, type_declaration, message_str)
  173 +.
62 174
63 public define One 175 public define One
64 make_all_types 176 make_all_types
65 ( 177 (
66 - List(DS_Type) types,  
67 - String destination_dir 178 + DS_Type_File_Output_Dir out_dir,
  179 + DS_Type_File_Output_Name output_file_name,
  180 + List(DS_Type) types,
  181 + String destination_dir
68 )= 182 )=
69 - map_forget((DS_Type type) |-> since type is ds_type(type_name, _, ds_alts),  
70 - println("generating type file for Type ["+type_name+"]");  
71 - make_type_file(type, destination_dir), types) 183 + with final_destination_dir =
  184 + if out_dir is
  185 + {
  186 + auto then destination_dir + "types/generated/",
  187 + relative_path(path) then destination_dir + path + "/",
  188 + absolute_path(path) then path
  189 + },
  190 +
  191 + if output_file_name is
  192 + {
  193 + auto then
  194 + map_forget((DS_Type type)
  195 + |->
  196 + since type is ds_type(type_name, _, ds_alts),
  197 +
  198 + with file_name = final_destination_dir+to_lower(type_name)+".anubis",
  199 + println("generating type file for Type ["+type_name+"] to "+file_name);
  200 +
  201 + with header = generate_header,
  202 + with file_parts = make_type_file(type, final_destination_dir, []),
  203 +
  204 + write_type_file(file_name, header, [file_parts])
  205 + ,
  206 + types)
  207 +
  208 + name(_file_name) then
  209 + with file_name = final_destination_dir+_file_name+".anubis",
  210 +
  211 + with header = generate_header,
  212 + with file_parts =
  213 + map((DS_Type type)
  214 + |->
  215 + since type is ds_type(type_name, _, ds_alts),
  216 + println("generating type file for Type ["+type_name+"] to "+file_name);
  217 + make_type_file(type, final_destination_dir, types)
  218 + ,
  219 + types),
  220 +
  221 + forget(write_type_file(file_name, header, file_parts))
  222 +
  223 + }
  224 +
72 . 225 .
73 -  
src/generation/types_header.anubis
@@ -11,24 +11,32 @@ read tools/streams.anubis @@ -11,24 +11,32 @@ read tools/streams.anubis
11 read tools/ISO-8601.anubis 11 read tools/ISO-8601.anubis
12 read system/string.anubis 12 read system/string.anubis
13 read densaku_lib/types/ds_types.anubis 13 read densaku_lib/types/ds_types.anubis
14 - 14 +read generation/intermediate_type.anubis
15 15
16 public define String 16 public define String
17 - insert_read_foreign_type 17 + generate_transmit_foreign_type
18 ( 18 (
19 - DS_Type sd_type //type description 19 + DS_Type ds_t, //type description,
  20 + List(DS_Type) beside_type //type belonging of that file
20 )= 21 )=
21 - with foreign_type_list = get_all_extern_type(sd_type), 22 + with foreign_type_list = get_all_extern_type(ds_t, beside_type),
22 join("", map((Extern_type ext_type) |-> since ext_type is extern(_, read_file), "transmit "+read_file+"\n", foreign_type_list)) 23 join("", map((Extern_type ext_type) |-> since ext_type is extern(_, read_file), "transmit "+read_file+"\n", foreign_type_list))
23 . 24 .
24 -  
25 -public define Maybe(One)  
26 - generate_type_header 25 +
  26 + public define List(String)
  27 + generate_intermediate_type
27 ( 28 (
28 - Stream stream,  
29 - DS_Type sd_type //type description  
30 - )=  
31 - write_string(stream, 29 + DS_Type ds_t, //type description,
  30 + List(DS_Type) beside_type //type belonging of that file
  31 + )=
  32 + with intermediate_list = get_all_intermediate_type(beside_type),
  33 +
  34 + //join("", map((String intermediate_type) |-> intermediate_type, intermediate_list))
  35 +.
  36 +
  37 +public define String
  38 + generate_header
  39 + =
32 "/* 40 "/*
33 * Created by 伝作 (Densaku). 41 * Created by 伝作 (Densaku).
34 * Types & Messages generator written by フランスのトトロ aka (David RENÉ) 42 * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
@@ -41,9 +49,13 @@ transmit system/muscle.anubis @@ -41,9 +49,13 @@ transmit system/muscle.anubis
41 transmit system/convert.anubis 49 transmit system/convert.anubis
42 transmit tools/basis.anubis 50 transmit tools/basis.anubis
43 51
44 -" + 52 +"
  53 +.
  54 + +
45 insert_read_foreign_type(sd_type)+ 55 insert_read_foreign_type(sd_type)+
46 "\n" 56 "\n"
47 ) 57 )
48 - . 58 +.
  59 +
  60 +
49 61
src/generation/types_messages.anubis
@@ -16,29 +16,28 @@ read densaku_lib/types/ds_types.anubis @@ -16,29 +16,28 @@ read densaku_lib/types/ds_types.anubis
16 public define String 16 public define String
17 insert_read_foreign_type 17 insert_read_foreign_type
18 ( 18 (
19 -// Stream stream,  
20 - DS_Type ds_type //type description 19 + DS_Type ds_type, //type description
  20 + List(DS_Type) beside_type
21 )= 21 )=
22 - with foreign_type_list = get_all_extern_type(ds_type), 22 + with foreign_type_list = get_all_extern_type(ds_type, beside_type),
23 join("", map((Extern_type ext_type) |-> since ext_type is extern(_, read_file), "read "+read_file+"\n", foreign_type_list)) 23 join("", map((Extern_type ext_type) |-> since ext_type is extern(_, read_file), "read "+read_file+"\n", foreign_type_list))
24 . 24 .
25 25
26 -public define Maybe(One) 26 +public define String
27 generate_type_message_description 27 generate_type_message_description
28 ( 28 (
29 - Stream stream, 29 + //Stream stream,
30 DS_Type ds_type //type description 30 DS_Type ds_type //type description
31 )= 31 )=
32 since ds_type is ds_type(type_name, _, alternatives), 32 since ds_type is ds_type(type_name, _, alternatives),
33 with title = type_name+" message format", 33 with title = type_name+" message format",
34 - write_string(stream, 34 +
35 "\n"+ 35 "\n"+
36 " "+title+"\n"+ 36 " "+title+"\n"+
37 " "+fill(length(title), '=')+"\n\n"+ 37 " "+fill(length(title), '=')+"\n\n"+
38 // insert_type_message_description(ds_type)+ 38 // insert_type_message_description(ds_type)+
39 "\n" 39 "\n"
40 - )  
41 - . 40 +.
42 41
43 public define String 42 public define String
44 anb_type_to_message 43 anb_type_to_message
@@ -153,16 +152,15 @@ define String @@ -153,16 +152,15 @@ define String
153 } 152 }
154 . 153 .
155 154
156 -public define Maybe(One) 155 +public define String
157 generate_type_to_message 156 generate_type_to_message
158 ( 157 (
159 - Stream stream,  
160 DS_Type ds_type //type description 158 DS_Type ds_type //type description
161 - )= 159 + )=
162 since ds_type is ds_type(type_name, _, alternatives), 160 since ds_type is ds_type(type_name, _, alternatives),
163 with lower_type_name = "_"+to_lower(type_name), 161 with lower_type_name = "_"+to_lower(type_name),
164 type_msg = lower_type_name+"_message", 162 type_msg = lower_type_name+"_message",
165 - write_string(stream, 163 +
166 "public define Message\n"+ 164 "public define Message\n"+
167 " to_Message\n"+ 165 " to_Message\n"+
168 " (\n"+ 166 " (\n"+
@@ -175,7 +173,6 @@ public define Maybe(One) @@ -175,7 +173,6 @@ public define Maybe(One)
175 " };\n"+ 173 " };\n"+
176 " "+type_msg+"\n"+ 174 " "+type_msg+"\n"+
177 ".\n\n" 175 ".\n\n"
178 - )  
179 . 176 .
180 177
181 /****************************** FROM MESSAGE ***********************************/ 178 /****************************** FROM MESSAGE ***********************************/
@@ -308,7 +305,7 @@ define String @@ -308,7 +305,7 @@ define String
308 since h is component(b_list, anb_type, name, comment), 305 since h is component(b_list, anb_type, name, comment),
309 indent + "// [type = "+(if b_list is list then "List(" else "")+dump(anb_type)+(if b_list is list then ")" else "")+"] "+alt_name+"."+name+"\n"+ 306 indent + "// [type = "+(if b_list is list then "List(" else "")+dump(anb_type)+(if b_list is list then ")" else "")+"] "+alt_name+"."+name+"\n"+
310 (if b_list is list then 307 (if b_list is list then
311 - anb_type_list_from_message(indent, type_msg, anb_type, name, name, brace_counter) 308 + anb_type_list_from_message(indent, type_msg, anb_type, name, "_"+name+"_", brace_counter)
312 else 309 else
313 anb_type_from_message(indent, type_msg, anb_type, name, "_"+name+"_", brace_counter)) 310 anb_type_from_message(indent, type_msg, anb_type, name, "_"+name+"_", brace_counter))
314 + 311 +
@@ -371,16 +368,15 @@ define String @@ -371,16 +368,15 @@ define String
371 } 368 }
372 . 369 .
373 370
374 -public define Maybe(One) 371 +public define String
375 generate_type_from_message 372 generate_type_from_message
376 ( 373 (
377 - Stream stream,  
378 DS_Type ds_type //type description 374 DS_Type ds_type //type description
379 )= 375 )=
380 since ds_type is ds_type(type_name, _, alternatives), 376 since ds_type is ds_type(type_name, _, alternatives),
381 with lower_type_name = "_"+to_lower(type_name), 377 with lower_type_name = "_"+to_lower(type_name),
382 type_msg = lower_type_name+"_message", 378 type_msg = lower_type_name+"_message",
383 - write_string(stream, 379 +
384 "public define Maybe("+type_name+")\n"+ 380 "public define Maybe("+type_name+")\n"+
385 " from_Message\n"+ 381 " from_Message\n"+
386 " (\n"+ 382 " (\n"+
@@ -395,5 +391,4 @@ public define Maybe(One) @@ -395,5 +391,4 @@ public define Maybe(One)
395 " failure //Type not found in message !\n"+ 391 " failure //Type not found in message !\n"+
396 " }}\n"+ 392 " }}\n"+
397 ".\n\n" 393 ".\n\n"
398 - )  
399 . 394 .
@@ -32,74 +32,106 @@ public define List(DS_Message) the_messages_list = @@ -32,74 +32,106 @@ public define List(DS_Message) the_messages_list =
32 ]) 32 ])
33 ]. 33 ].
34 34
35 -public define List(DS_Type) the_types_list = 35 +public define List(DS_Type_File) the_types_list =
36 [ 36 [
37 - ds_type("User_Account", [  
38 - alternative("account", [  
39 - component(string, "first_name"),  
40 - component(string, "last_name"),  
41 - component(int, "extension") 37 + ds_type_file( auto, auto,
  38 + [
  39 + ds_type("User_Account", [
  40 + alternative("account", [
  41 + component(string, "first_name"),
  42 + component(string, "last_name"),
  43 + component(int, "extension")
  44 + ]),
  45 + alternative("account_ext", [
  46 + component(string, "first_name"),
  47 + component(string, "last_name"),
  48 + component(list, int, "extension_list")
  49 + ]),
  50 + alternative("account_super_extended", [
  51 + component(string, "first_name"),
  52 + component(string, "last_name"),
  53 + component(list, int, "extension_list"),
  54 + component(extern_type("DB_id", "calexium_lib/model/db_types.anubis"), "db_id")
  55 + ])
42 ]), 56 ]),
43 - alternative("account_ext", [  
44 - component(string, "first_name"),  
45 - component(string, "last_name"),  
46 - component(list, int, "extension_list")  
47 - ]),  
48 - alternative("account_super_extended", [  
49 - component(string, "first_name"),  
50 - component(string, "last_name"),  
51 - component(list, int, "extension_list"),  
52 - component(extern_type("DB_id", "calexium_lib/model/db_types.anubis"), "db_id")  
53 - ])  
54 - ]),  
55 -  
56 - ds_type("Trunk_SIP", [  
57 - alternative("account", [  
58 - component(string, "login"),  
59 - component(string, "password"),  
60 - component(string, "host")  
61 - ])  
62 - ]),  
63 -  
64 - ds_type("HK_App", [  
65 - alternative("hk_app", [  
66 - component(string, "app_name", comment("Name of the application")),  
67 - component(ds_type("HK_Icon"), "icon", comment("Icon description")),  
68 - component(ds_type("HK_Help_Text"), "help"),  
69 - component(list, ds_type("HK_Table"),"hk_tables")  
70 - ])  
71 - ]),  
72 - ds_type("HK_Database", [  
73 - alternative("hk_database", [  
74 - component(string, "name", comment("name of the database")),  
75 - component(list, ds_type("HK_App"), "apps", comment("list of applications"))  
76 - ])  
77 - ]),  
78 -  
79 - ds_type("HK_Help_Text", [  
80 - enum("no_help_text", comment("no help text available")),  
81 - alternative("help_text_TAG", [component(string, "tag_name", comment("TAG use with Anubis translation tool /locale/L3.anubis"))]),  
82 - alternative("help_text", [component(string, "help_text", comment("pure text to show"))])  
83 - ]),  
84 - ds_type("HK_Icon", [  
85 - enum("no_icon"),  
86 - alternative("icon16", [component(string, "name")]) 57 +
  58 + ds_type("Trunk_SIP", [
  59 + alternative("account", [
  60 + component(string, "login"),
  61 + component(string, "password"),
  62 + component(string, "host")
  63 + ])
  64 + ]),
  65 +
  66 + ds_type("HK_App", [
  67 + alternative("hk_app", [
  68 + component(string, "app_name", comment("Name of the application")),
  69 + component(ds_type("HK_Icon"), "icon", comment("Icon description")),
  70 + component(ds_type("HK_Help_Text"), "help"),
  71 + component(list, ds_type("HK_Table"),"hk_tables")
  72 + ])
  73 + ]),
  74 + ds_type("HK_Database", [
  75 + alternative("hk_database", [
  76 + component(string, "name", comment("name of the database")),
  77 + component(list, ds_type("HK_App"), "apps", comment("list of applications"))
  78 + ])
  79 + ]),
  80 +
  81 + ds_type("HK_Help_Text", [
  82 + enum("no_help_text", comment("no help text available")),
  83 + alternative("help_text_TAG", [component(string, "tag_name", comment("TAG use with Anubis translation tool /locale/L3.anubis"))]),
  84 + alternative("help_text", [component(string, "help_text", comment("pure text to show"))])
  85 + ]),
  86 + ds_type("HK_Icon", [
  87 + enum("no_icon"),
  88 + alternative("icon16", [component(string, "name")])
  89 + ]),
  90 +
  91 + ds_type("HK_Form", no_message, [
  92 + alternative("hk_form_in_list", [
  93 + component(string, "table_name", comment("database table name which belonging this form")),
  94 + component(string, "view_name", comment("name of the view")),
  95 + component(list, extern_type("HK_Form_Entry", "hk_form_entry.anubis"), "list"),
  96 + component(list, extern_type("HK_Form_Tab", "hk_form_tab.anubis"), "tabs")
  97 + ]),
  98 + alternative("hk_form_in_table", [
  99 + component(string, "table_name", comment("database table name which belonging this form")),
  100 + component(string, "view_name", comment("name of the view")),
  101 + component(extern_type("HK_Form_Table", "hk_form_table.anubis"), "form_in_table")
  102 + ])
  103 + ])
87 ]), 104 ]),
88 105
89 - ds_type("HK_Form", no_message, [  
90 - alternative("hk_form_in_list", [  
91 - component(string, "table_name", comment("database table name which belonging this form")),  
92 - component(string, "view_name", comment("name of the view")),  
93 - component(list, extern_type("HK_Form_Entry", "hk_form_entry.anubis"), "list"),  
94 - component(list, extern_type("HK_Form_Tab", "hk_form_tab.anubis"), "tabs") 106 + ds_type_file( relative_path("hayamiki_lib/view/types/"), name("HK_Editor_Table"),
  107 + [
  108 + ds_type("HK_Editor_Table_Cell", [
  109 + enum("empty"),
  110 + alternative("column", [
  111 + component(string, "column_name")
  112 + ]),
  113 + alternative("label", [
  114 + component(string, "label"),
  115 + ]),
  116 + alternative("table", [
  117 + component(list, ds_type("HK_Editor_Table_Line"), "lines")
  118 + ])
95 ]), 119 ]),
96 - alternative("hk_form_in_table", [  
97 - component(string, "table_name", comment("database table name which belonging this form")),  
98 - component(string, "view_name", comment("name of the view")),  
99 - component(extern_type("HK_Form_Table", "hk_form_table.anubis"), "form_in_table")  
100 - ])  
101 - ])  
102 - ]. 120 +
  121 + ds_type("HK_Editor_Table_Line", [
  122 + alternative("line", [
  123 + component(list, ds_type("HK_Editor_Table_Cell"), "cells")
  124 + ])
  125 + ]),
  126 +
  127 + ds_type("HK_Editor_Table", [
  128 + alternative("table", [
  129 + component(list, ds_type("HK_Editor_Table_Line"), "lines")
  130 + ])
  131 + ]),
  132 + ])
  133 + ]
  134 +.
103 135
104 136
105 137