diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-27 17:36:59 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-27 17:36:59 +0200 |
commit | 7f6c64f2211d37db76a97fbc79a4b5492302ef2f (patch) | |
tree | f2e386644fcaab5c51e3f5ad0ac737ea5b4d5bd2 /odb/inline.cxx | |
parent | 5259b98c75f3754a0f713bcee4bddd0ed7ce35ef (diff) |
Implement support for composite value types
New test: common/composite.
Diffstat (limited to 'odb/inline.cxx')
-rw-r--r-- | odb/inline.cxx | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/odb/inline.cxx b/odb/inline.cxx new file mode 100644 index 0000000..630cf1b --- /dev/null +++ b/odb/inline.cxx @@ -0,0 +1,97 @@ +// file : odb/inline.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v3; see accompanying LICENSE file + +#include <odb/common.hxx> +#include <odb/inline.hxx> + +namespace +{ + struct data_member: traversal::data_member, context + { + data_member (context& c, semantics::class_& cl) + : context (c) + { + scope_ = "access::value_traits< " + cl.fq_name () + " >"; + } + + virtual void + traverse (semantics::data_member& m) + { + if (m.count ("transient")) + return; + + string const& name (public_name (m)); + string const& type (m.type ().fq_name (m.belongs ().hint ())); + + os << "inline" << endl + << type << "& " << scope_ << "::" << endl + << name << " (value_type& v)" + << "{" + << "return v." << m.name () << ";" + << "}"; + + os << "inline" << endl + << "const " << type << "& " << scope_ << "::" << endl + << name << " (const value_type& v)" + << "{" + << "return v." << m.name () << ";" + << "}"; + } + + private: + string scope_; + }; + + struct class_: traversal::class_, context + { + class_ (context& c) + : context (c) + { + } + + virtual void + traverse (type& c) + { + if (c.file () != unit.file ()) + return; + + if (!comp_value (c)) + return; + + os << "// " << c.name () << endl + << "//" << endl; + + data_member member (*this, c); + traversal::names member_names (member); + names (c, member_names); + } + }; +} + +void +generate_inline (context& /*ctx*/) +{ + /* + traversal::unit unit; + traversal::defines unit_defines; + traversal::namespace_ ns; + class_ c (ctx); + + unit >> unit_defines >> ns; + unit_defines >> c; + + traversal::defines ns_defines; + + ns >> ns_defines >> ns; + ns_defines >> c; + + ctx.os << "namespace odb" + << "{"; + + unit.dispatch (ctx.unit); + + ctx.os << "}"; + */ +} |