messages.anubis
1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 23/01/2017
* Time: 10:09
* © David RENÉ
*/
read generation/message_header.anubis
read generation/message_messages.anubis
read system/files.anubis
read system/string.anubis
read tools/streams.anubis
read tools/basis.anubis
read densaku_lib/types/ds_message.anubis
define Maybe(One)
make_message_file
(
DS_Message ds_message, //type description
String dest_dir
)
=
since ds_message is ds_message(name, _, fields),
println("Generating file for message ["+name+"]");
//TODO here replace all files by one with collection name
with file_name = dest_dir+"messages/generated/"+to_lower(name)+".anubis",
//create all necessary directories if doesn't exist.
make_directories(file_name);
if file(file_name, new) is
{
failure then println("can't create file "+file_name);failure,
success(fd) then
with strm = make_stream(fd),
if generate_message_header(strm, ds_message) is { failure then failure, success(_) then
// if generate_type(strm, ds_message) is { failure then failure, success(_) then
if generate_message_message_description(strm, ds_message) is { failure then failure, success(_) then
if generate_to_message(strm, ds_message) is { failure then failure, success(_) then
if generate_from_message(strm, ds_message) is { failure then failure, success(_) then
success(unique)}}}}//}
}
.
public define One
make_all_messages
(
List(DS_Message) messages,
String destination_dir
)=
map_forget((DS_Message message) |-> since message is ds_message(message_name, what_code, ds_fields),
println("generating message file for Message ["+message_name+"]");
make_message_file(message, destination_dir), messages)
.