diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-06-19 19:57:35 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-06-19 19:57:35 +0200 |
commit | 6e35807bd495c0001cba229fd082e45f0421100e (patch) | |
tree | 229d40ebc69bcc9ef04147ef95534ddb39771b8d /odb/pragma.cxx | |
parent | cf469aa28804418338c79a5f9c68608ea2f2807a (diff) |
Populate custom type map, make available in context
Diffstat (limited to 'odb/pragma.cxx')
-rw-r--r-- | odb/pragma.cxx | 101 |
1 files changed, 48 insertions, 53 deletions
diff --git a/odb/pragma.cxx b/odb/pragma.cxx index 01c31d2..733d19c 100644 --- a/odb/pragma.cxx +++ b/odb/pragma.cxx @@ -869,11 +869,56 @@ handle_pragma (cxx_lexer& l, tt = l.next (tl, &tn); - using relational::custom_db_type; - using relational::custom_cxx_type; + if (qualifier_value.type_info () == typeid (custom_cxx_type)) + { + // C++ type mapping. + // + custom_cxx_type& ct (qualifier_value.value<custom_cxx_type> ()); + + if (p == "type" || p == "as") + { + // Can be built-in type (e.g., bool). + // + if (tt == CPP_NAME || tt == CPP_KEYWORD || tt == CPP_SCOPE) + { + string name; + tree decl ( + resolve_scoped_name ( + l, tt, tl, tn, current_scope (), name, true, p)); + + if (decl == 0) + return; // Diagnostics has already been issued. + + if (TREE_CODE (decl) != TYPE_DECL) + { + error (loc) << "name '" << name << "' in db pragma " + << p << " does not refer to a type" << endl; + return; + } - if (qualifier_value.type_info () == typeid (custom_db_type)) + (p == "type" ? ct.type_node : ct.as_node) = TREE_TYPE (decl); + (p == "type" ? ct.type_name : ct.as_name) = name; + } + else + { + error (l) << "type name expected in db pragma " << p << endl; + return; + } + } + else if (p == "to" || p == "from") + { + if (tt != CPP_CLOSE_PAREN) // Empty expression is ok. + { + if (!parse_expression ( + l, tt, tl, tn, (p == "to" ? ct.to : ct.from), p)) + return; // Diagnostics has already been issued. + } + } + } + else { + using relational::custom_db_type; + // Database type mapping. // custom_db_type& ct (qualifier_value.value<custom_db_type> ()); @@ -932,54 +977,6 @@ handle_pragma (cxx_lexer& l, tt = l.next (tl, &tn); } - else - { - // C++ type mapping. - // - custom_cxx_type& ct (qualifier_value.value<custom_cxx_type> ()); - - if (p == "type" || p == "as") - { - // Can be built-in type (e.g., bool). - // - if (tt == CPP_NAME || tt == CPP_KEYWORD || tt == CPP_SCOPE) - { - string name; - tree type ( - resolve_scoped_name ( - l, tt, tl, tn, current_scope (), name, true, p)); - - if (type == 0) - return; // Diagnostics has already been issued. - - if (TREE_CODE (type) != TYPE_DECL) - { - error (loc) << "name '" << name << "' in db pragma " - << p << " does not refer to a type" << endl; - return; - } - - type = TREE_TYPE (type); - - (p == "type" ? ct.type_node : ct.as_node) = type; - (p == "type" ? ct.type_name : ct.as_name) = name; - } - else - { - error (l) << "type name expected in db pragma " << p << endl; - return; - } - } - else if (p == "to" || p == "from") - { - if (tt != CPP_CLOSE_PAREN) // Empty expression is ok. - { - if (!parse_expression ( - l, tt, tl, tn, (p == "to" ? ct.to : ct.from), p)) - return; // Diagnostics has already been issued. - } - } - } if (tt != CPP_CLOSE_PAREN) { @@ -3118,8 +3115,6 @@ handle_pragma_qualifier (cxx_lexer& l, string p) } else { - using relational::custom_cxx_type; - custom_cxx_type ct; ct.loc = loc; val = ct; |