diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-04-24 11:27:14 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-04-24 11:27:14 +0200 |
commit | b9fe963646367f2da21ba1053bc086bd17b09967 (patch) | |
tree | 95fa1918897d2b96d55a6796cb9ce2fb0a70026a /odb | |
parent | 65713117ae73f692b25ad70f2e7d8650ee997c2d (diff) |
Implement id_type value type pragma
Diffstat (limited to 'odb')
-rw-r--r-- | odb/context.cxx | 1 | ||||
-rw-r--r-- | odb/pragma.cxx | 20 | ||||
-rw-r--r-- | odb/relational/type-processor.cxx | 33 |
3 files changed, 39 insertions, 15 deletions
diff --git a/odb/context.cxx b/odb/context.cxx index 2d64885..8a85dcd 100644 --- a/odb/context.cxx +++ b/odb/context.cxx @@ -190,6 +190,7 @@ comp_value_ (semantics::class_& c) r = r && c.count ("value"); r = r && !c.count ("table"); r = r && !c.count ("type"); + r = r && !c.count ("id-type"); r = r && !c.count ("value-type"); r = r && !c.count ("index-type"); r = r && !c.count ("key-type"); diff --git a/odb/pragma.cxx b/odb/pragma.cxx index c09c683..8cfc3fa 100644 --- a/odb/pragma.cxx +++ b/odb/pragma.cxx @@ -158,6 +158,17 @@ check_decl_type (tree d, string const& name, string const& p, location_t l) return false; } } + else if (p == "id_type") + { + // Id type can only be used for types. + // + if (!TYPE_P (d)) + { + error_at (l, "name %qs in db pragma %qs does not refer to a type", + name.c_str (), pc); + return false; + } + } else if (p == "type" || p == "value_type" || p == "index_type" || @@ -421,11 +432,13 @@ handle_pragma (cpp_reader* reader, tt = pragma_lex (&t); } else if (p == "type" || + p == "id_type" || p == "value_type" || p == "index_type" || p == "key_type") { // type ("<type>") + // id_type ("<type>") // value_type ("<type>") // index_type ("<type>") // key_type ("<type>") @@ -812,6 +825,12 @@ handle_pragma_db_type (cpp_reader* reader) } extern "C" void +handle_pragma_db_id_type (cpp_reader* reader) +{ + handle_pragma_qualifier (reader, "id_type"); +} + +extern "C" void handle_pragma_db_vtype (cpp_reader* reader) { handle_pragma_qualifier (reader, "value_type"); @@ -873,6 +892,7 @@ register_odb_pragmas (void*, void*) c_register_pragma_with_expansion ("db", "key_column", handle_pragma_db_kcolumn); c_register_pragma_with_expansion ("db", "id_column", handle_pragma_db_idcolumn); c_register_pragma_with_expansion ("db", "type", handle_pragma_db_type); + c_register_pragma_with_expansion ("db", "id_type", handle_pragma_db_id_type); c_register_pragma_with_expansion ("db", "value_type", handle_pragma_db_vtype); c_register_pragma_with_expansion ("db", "index_type", handle_pragma_db_itype); c_register_pragma_with_expansion ("db", "key_type", handle_pragma_db_ktype); diff --git a/odb/relational/type-processor.cxx b/odb/relational/type-processor.cxx index 97f4d85..511ac9e 100644 --- a/odb/relational/type-processor.cxx +++ b/odb/relational/type-processor.cxx @@ -31,7 +31,7 @@ namespace relational { context& c (context::current ()); semantics::data_member& id (context::id_member (*c.object)); - return id.get<string> ("ref-column-type"); + return id.get<string> ("column-type"); } struct data_member: traversal::data_member, context @@ -113,9 +113,6 @@ namespace relational if (m.count ("type")) type = m.get<string> ("type"); - if (type.empty () && t.count ("type")) - type = t.get<string> ("type"); - if (semantics::class_* c = process_object_pointer (m, t)) { // This is an object pointer. The column type is the pointed-to @@ -127,6 +124,9 @@ namespace relational if (type.empty () && id.count ("type")) type = id.get<string> ("type"); + if (type.empty () && idt.count ("id-type")) + type = idt.get<string> ("id-type"); + if (type.empty () && idt.count ("type")) type = idt.get<string> ("type"); @@ -139,20 +139,18 @@ namespace relational } else { - string orig (type); - type = database_type (t, orig, m, ctf_none); + if (type.empty () && m.count ("id") && t.count ("id-type")) + type = t.get<string> ("id-type"); + + if (type.empty () && t.count ("type")) + type = t.get<string> ("type"); - if (m.count ("id")) - ref_type = database_type (t, orig, m, ctf_none); + type = database_type (t, type, m, ctf_none); } if (!type.empty ()) { m.set ("column-type", type); - - if (!ref_type.empty ()) - m.set ("ref-column-type", ref_type); - return; } @@ -199,9 +197,6 @@ namespace relational if (type.empty () && ct.count (prefix + "-type")) type = ct.get<string> (prefix + "-type"); - if (type.empty () && t.count ("type")) - type = t.get<string> ("type"); - semantics::class_* c; if (obj_ptr && (c = process_object_pointer (m, t, prefix))) { @@ -214,6 +209,9 @@ namespace relational if (type.empty () && id.count ("type")) type = id.get<string> ("type"); + if (type.empty () && idt.count ("id-type")) + type = idt.get<string> ("id-type"); + if (type.empty () && idt.count ("type")) type = idt.get<string> ("type"); @@ -225,7 +223,12 @@ namespace relational type = database_type (idt, type, id, f); } else + { + if (type.empty () && t.count ("type")) + type = t.get<string> ("type"); + type = database_type (t, type, m, ctf_none); + } if (!type.empty ()) { |