From 3a2d3aaafe8ceaa80c501bb104d847bb6efa544d Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 12 Mar 2017 22:19:49 +0100 Subject: [PATCH] add support of float_field --- src/generation/columns.anubis | 5 ++++- src/generation/fields.anubis | 25 ++++++++++++++++--------- src/generation/html.anubis | 1 + src/generation/icons.anubis | 1 + 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis index d2b3ba8..be6a596 100644 --- a/src/generation/columns.anubis +++ b/src/generation/columns.anubis @@ -145,6 +145,7 @@ public define Maybe(String) }, foreign_key(_,_) then success(name), integer_field(_) then success(name), + float_field then success(name), char_field(_,_) then success(name), password_field(_) then success(name), text_field(_) then success(name) @@ -246,7 +247,8 @@ public define Maybe(String) else success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), } - + float_field then success("float(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), + //TODO make choices selection if need char_field(choices,_) then if choices is @@ -329,6 +331,7 @@ public define String datetime_field(attrs) then "to_String("+current_type_name+"."+name+")" foreign_key(app,foreign_table) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")", integer_field(_) then "to_String("+current_type_name+"."+name+")", + float_field then "float_to_string("+current_type_name+"."+name+",5)", char_field(_,_) then current_type_name+"."+name, password_field(_) then current_type_name+"."+name, text_field(_) then current_type_name+"."+name diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis index ef4cb7e..34476a1 100644 --- a/src/generation/fields.anubis +++ b/src/generation/fields.anubis @@ -32,6 +32,7 @@ public define String datetime_field(_) then "DB_datetime", foreign_key(_,_) then "DB_id", integer_field(_) then "Int", + float_field then "Float", char_field(_,_) then "String", password_field(_) then "String", text_field(_) then "String" @@ -55,6 +56,7 @@ public define String datetime_field(_) then "extern_type(\"DB_datetime\", \"calexium_lib/database/db_types.anubis\")", foreign_key(_,_) then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")", integer_field(_) then "int", + float_field then "float", char_field(_,_) then "string", password_field(_) then "string", text_field(_) then "string" @@ -69,16 +71,17 @@ public define String if t is { //anubis(_T) then "ByteArray", - p_key then fill("INTEGER", 15) +" PRIMARY KEY", - boolean_field then fill("BOOL", 15) +format_attributes(attributes), - date_field(_) then fill("DATE", 15) +format_attributes(attributes), - time_field(_) then fill("TIME", 15) +format_attributes(attributes), - datetime_field(_) then fill("DATETIME", 15)+format_attributes(attributes), - foreign_key(app,fk) then fill("INTEGER", 15) +format_attributes(attributes)+" REFERENCES "+fk+"(id) ", - integer_field(_) then fill("INTEGER", 15) +format_attributes(attributes), + p_key then fill("INTEGER", 15) + " PRIMARY KEY", + boolean_field then fill("BOOL", 15) + format_attributes(attributes), + date_field(_) then fill("DATE", 15) + format_attributes(attributes), + time_field(_) then fill("TIME", 15) + format_attributes(attributes), + datetime_field(_) then fill("DATETIME", 15) + format_attributes(attributes), + foreign_key(app,fk) then fill("INTEGER", 15) + format_attributes(attributes)+" REFERENCES "+fk+"(id) ", + integer_field(_) then fill("INTEGER", 15) + format_attributes(attributes), + float_field then fill("DOUBLE", 15) + format_attributes(attributes), char_field(_,size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes), - password_field(_) then fill("TEXT", 15) +format_attributes(attributes), - text_field(_) then fill("TEXT", 15) +format_attributes(attributes), + password_field(_) then fill("TEXT", 15) + format_attributes(attributes), + text_field(_) then fill("TEXT", 15) + format_attributes(attributes), }. public define String @@ -97,6 +100,7 @@ public define String datetime_field(_) then "db_datetime(\"\")", foreign_key(_,_) then "(DB_id)none", integer_field(_) then "(Int)0", + float_field then "(Float)0.0", char_field(choices,size) then "\"\"", password_field(min_size) then "\"\"", text_field(_) then "\"\"" @@ -119,6 +123,7 @@ public define String datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_datetime,", foreign_key(_,_) then "with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),", integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\")", + float_field then "get_Float(lwa, __prefix__+\""+name+"\")", char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", password_field(min_size) then "get_String(lwa, __prefix__+\""+name+"_1\")", text_field(_) then "get_String(lwa, __prefix__+\""+name+"\")" @@ -141,6 +146,7 @@ public define String datetime_field(_) then "db_datetime(text"+cursor_index+")", foreign_key(_,_) then "db_id((Int)db_integer"+cursor_index+")", integer_field(_) then "(Int)db_integer"+cursor_index, + float_field then "db_float"+cursor_index, char_field(_,_) then "text"+cursor_index, password_field(_) then "text"+cursor_index, text_field(_) then "text"+cursor_index @@ -174,6 +180,7 @@ public define String }, foreign_key(_,_) then "bind_DB_id_or_NULL(\":v_"+name+"\", "+type_name+"."+name+")", integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", + float_field then "bind_Float(\":v_"+name+"\", "+type_name+"."+name+")", char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", password_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", text_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")" diff --git a/src/generation/html.anubis b/src/generation/html.anubis index f2f3093..dff109e 100644 --- a/src/generation/html.anubis +++ b/src/generation/html.anubis @@ -94,6 +94,7 @@ public define String datetime_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), foreign_key(app, foreign_table) then to_HTML_cell_text(column, data_name, general_type_name), integer_field(choices) then to_HTML_cell_text(column, data_name, general_type_name), + float_field then to_HTML_cell_text(column, data_name, general_type_name), char_field(choices, size) then to_HTML_cell_text(column, data_name, general_type_name), password_field(min_size) then to_HTML_cell_text(column, data_name, general_type_name), text_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), diff --git a/src/generation/icons.anubis b/src/generation/icons.anubis index 97cdfd6..4731cb0 100644 --- a/src/generation/icons.anubis +++ b/src/generation/icons.anubis @@ -30,6 +30,7 @@ public define String datetime_field(attrs) then icn16_clock, foreign_key(app,foreign_table) then icn16_question, integer_field(choice) then icn16_question, + float_field then icn16_question, char_field(choice, size) then icn16_question, password_field(min_size) then icn16_question, text_field(_) then icn16_question -- libgit2 0.21.4