summaryrefslogtreecommitdiff
path: root/odb/inline.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-10-19 10:47:41 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-10-21 19:25:06 +0200
commit6bd95f51beb26d87fd5d5db22391c73f333eee6e (patch)
tree59621cec994f55fce7a1ced5c3b9edb93a41b084 /odb/inline.cxx
parent7623fb5259da19c33ffe6623b0f306f6c39ede27 (diff)
Add support for const data members
Const data members are automatically treated as readonly. New test: const-member.
Diffstat (limited to 'odb/inline.cxx')
-rw-r--r--odb/inline.cxx18
1 files changed, 14 insertions, 4 deletions
diff --git a/odb/inline.cxx b/odb/inline.cxx
index 612219f..6cbb3cc 100644
--- a/odb/inline.cxx
+++ b/odb/inline.cxx
@@ -24,15 +24,25 @@ namespace
if (transient (m))
return;
+ semantics::type& t (m.type ());
+
string const& name (public_name (m));
- string const& type (m.type ().fq_name (m.belongs ().hint ()));
+
+ semantics::names* hint;
+ semantics::type& ut (utype (m, hint));
+ string const& type (ut.fq_name (hint));
os << "inline" << endl
<< type << "& " << scope_ << "::" << endl
<< name << " (value_type& v)"
- << "{"
- << "return v." << m.name () << ";"
- << "}";
+ << "{";
+
+ if (const_type (t))
+ os << "return const_cast< " << type << "& > (v." << m.name () << ");";
+ else
+ os << "return v." << m.name () << ";";
+
+ os << "}";
os << "inline" << endl
<< "const " << type << "& " << scope_ << "::" << endl