types.anubis
2.09 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 21/01/2017
* Time: 01:33
* © Calexium
*/
read generation/types_header.anubis
read generation/types_messages.anubis
read generation/graphviz/graphviz_main.anubis
read system/files.anubis
read system/string.anubis
read tools/streams.anubis
read tools/basis.anubis
read densaku_lib/types/ds_types.anubis
define Maybe(One)
generate_type
(
Stream stream,
DS_Type ds_type
)=
if write_string(stream, dump_DS_Type(ds_type)) is failure then failure else
success(unique)
.
define Maybe(One)
make_type_file
(
DS_Type ds_type, //type description
String dest_dir
)
=
since ds_type is ds_type(name, generation, alternatives),
println("Generating file for type ["+name+"]");
with file_name = dest_dir+"types/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_type_header(strm, ds_type) is { failure then failure, success(_) then
if generate_type(strm, ds_type) is { failure then failure, success(_) then
if generation is
{
no_message then success(unique),
message then
if generate_type_message_description(strm, ds_type) is { failure then failure, success(_) then
if generate_type_to_message(strm, ds_type) is { failure then failure, success(_) then
if generate_type_from_message(strm, ds_type) is { failure then failure, success(_) then
success(unique)}}}
}}}
}
.
public define One
make_all_types
(
List(DS_Type) types,
String destination_dir
)=
map_forget((DS_Type type) |-> since type is ds_type(type_name, _, ds_alts),
println("generating type file for Type ["+type_name+"]");
make_type_file(type, destination_dir), types)
.