diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-08-15 11:46:00 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-08-15 11:46:00 +0200 |
commit | eacf52a9a4f3832274fdefc909ab23c13413e128 (patch) | |
tree | f1f754b6149797315f91d6f872363555201d5a65 /odb/context.hxx | |
parent | 396cad633b6f0559a39e5111827f9b1125c67506 (diff) |
Add support for member accessors/modifiers
New pragmas: get, set, access. New test: common/access.
Diffstat (limited to 'odb/context.hxx')
-rw-r--r-- | odb/context.hxx | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/odb/context.hxx b/odb/context.hxx index f201596..5d8c339 100644 --- a/odb/context.hxx +++ b/odb/context.hxx @@ -217,6 +217,27 @@ struct column_expr: std::vector<column_expr_part> location_t loc; }; +// +// +struct member_access +{ + member_access (location_t l): loc (l), by_value (false) {} + + // Return true of we have the (?) placeholder. + // + bool + placeholder () const; + + std::string + translate (std::string const& obj, + std::string const& val = std::string ()) const; + + location_t loc; // If zero, then this is a synthesized expression. + cxx_tokens expr; + bool by_value; // True if accessor returns by value. False doesn't + // necessarily mean that it is by reference. +}; + class context { public: @@ -260,11 +281,14 @@ public: static semantics::type& utype (semantics::data_member&, semantics::names*& hint); + // For arrays this function returns true if the (innermost) element + // type is const. + // static bool const_type (semantics::type&); static semantics::type& - member_type (semantics::data_member& m, string const& key_prefix); + member_type (semantics::data_member&, string const& key_prefix); static semantics::type& member_utype (semantics::data_member& m, string const& key_prefix) @@ -272,6 +296,44 @@ public: return utype (member_type (m, key_prefix)); } + // Form a reference type for a member type. If make_const is true, then + // add top-level const qualifier, unless it is already there. If it is + // false, then strip it if it is already there. If var is not empty, + // then embed the variable name into the type (e.g., char (*v)[3]). + // + static string + member_ref_type (semantics::data_member& m, + bool make_const, + string const& var = "") + { + return type_ref_type (m.type (), m.belongs ().hint (), make_const, var); + } + + static string + type_ref_type (semantics::type&, + semantics::names* hint, + bool make_const, + string const& var = ""); + + // Form a value type for a member type. If make_const is true, then add + // top-level const qualifier, unless it is already there. If it is false, + // then strip it if it is already there. If var is not empty, then embed + // the variable name into the type (e.g., char v[3]). + // + static string + member_val_type (semantics::data_member& m, + bool make_const, + string const& var = "") + { + return type_val_type (m.type (), m.belongs ().hint (), make_const, var); + } + + static string + type_val_type (semantics::type&, + semantics::names* hint, + bool make_const, + string const& var = ""); + // Predicates. // public: @@ -617,7 +679,7 @@ public: // Return a string literal that can be used in C++ source code. It // includes "". // - string + static string strlit (string const&); // Counts and other information. |