/* * Created by PyramIDE. * User: フランスのトトロ aka (David RENÉ) * Date: 26/01/2017 * Time: 00:14 * © Calexium */ read hayamiki_lib/types/hayamiki.anubis read tools/basis.anubis read tools/streams.anubis read system/string.anubis read fields.anubis read columns.anubis read tools/ISO-8601.anubis define List(String) /** */ _generate_densaku_type ( List(HK_Model_Column) columns, List(String) so_far )= if columns is { [] then reverse(so_far), [h . t ] then since h is hk_column(name, col_type, _, _), _generate_densaku_type(t, [ " component("+fill(to_densaku_type(col_type), 12) + ", \"" + name +"\")". so_far]) }. public define Maybe(One) generate_densaku_type ( Stream stream, HK_Table table )= since table is hk_table(name, short_name, model, display), since model is hk_model(columns, show_string), with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. //generate the type of the HK_Table that contain all components if write_string(stream, " ds_type(\""+type_name+"\", [\n"+ " alternative(\""+name+"\", [\n"+ //head of the type declaration join(",\n",_generate_densaku_type(columns, []))+ //all components of the type " ])\n"+ " ]),\n") is //end of declaration { failure then println("can't write type "+type_name); failure, success(_) then success(unique) }. public define Maybe(One) /* */ generate_densaku_type ( HK_Table table, String dest_dir, Bool use_densaku )= if use_densaku then with file_name = dest_dir+"database/generated/densaku_type.anubis", if file(file_name, append) is { failure then println("can't create file "+file_name);failure, success(fd) then with strm = make_stream(fd), generate_densaku_type(strm, table) } else success(unique) . public define One make_densaku_header ( String dest_dir, Bool use_densaku )= if use_densaku then with file_name = dest_dir+"database/generated/densaku_type.anubis", if file(file_name, new) is { failure then unique, success(fd) then with strm = make_stream(fd), forget(write_string(strm, "/* * Created by 早見木 (Hayamiki). * Types & Messages generator written by フランスのトトロ aka (David RENÉ) * Date: "+_Int_to_ISO_8601_date(now)+" * Time: "+_Int_to_ISO_8601_time(now)+" * */ read densaku_lib/types/densaku.anubis public define List(DS_Type) hayamiki_types_list = [\n")) } else unique . public define One close_densaku_file ( String dest_dir, Bool use_densaku )= if use_densaku then with file_name = dest_dir+"database/generated/densaku_type.anubis", if file(file_name, append) is { failure then unique, success(fd) then with strm = make_stream(fd), forget(write_string(strm, " ] .\n")) } else unique .