aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-28 14:02:58 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-11-01 13:14:55 +0200
commit4f1569e9f9b89e381194974bb437533c21310baf (patch)
tree60910d66abc14da4d57c88ff0393c77f0ba6402b
parentd7d26dcb641ec5b217e2073c0ffeebad87562698 (diff)
Generate an image inline function that will return its change_callback member
libodb-oracle references the change_callback member of an image even when code is generated without query support. In order to avoid invalid references, the change_callback member is accessed via a getter method that is always generated.
-rw-r--r--odb/relational/oracle/header.cxx22
-rw-r--r--odb/relational/oracle/source.cxx4
2 files changed, 22 insertions, 4 deletions
diff --git a/odb/relational/oracle/header.cxx b/odb/relational/oracle/header.cxx
index cb9dd8a..b93981c 100644
--- a/odb/relational/oracle/header.cxx
+++ b/odb/relational/oracle/header.cxx
@@ -23,8 +23,26 @@ namespace relational
virtual void
image_extra (type& c)
{
- if (options.generate_query () && !(composite (c) || abstract (c)))
- os << "oracle::change_callback change_callback;";
+ if (!(composite (c) || abstract (c)))
+ {
+ bool f (options.generate_query ());
+
+ if (f)
+ os << "oracle::change_callback change_callback_;"
+ << endl;
+
+ os << "oracle::change_callback*" << endl
+ << "change_callback ()"
+ << "{";
+
+ if (f)
+ os << "return &change_callback_;";
+ else
+ os << "return 0;";
+
+ os << "}"
+ << endl;
+ }
}
};
entry<image_type> image_type_;
diff --git a/odb/relational/oracle/source.cxx b/odb/relational/oracle/source.cxx
index 1876c81..62b417b 100644
--- a/odb/relational/oracle/source.cxx
+++ b/odb/relational/oracle/source.cxx
@@ -869,8 +869,8 @@ namespace relational
init_image_pre (type& c)
{
if (options.generate_query () && !(composite (c) || abstract (c)))
- os << "if (i.change_callback.callback != 0)"
- << "(i.change_callback.callback) (i.change_callback.context);"
+ os << "if (i.change_callback_.callback != 0)"
+ << "(i.change_callback_.callback) (i.change_callback_.context);"
<< endl;
}