From 932cd7a53b3996468fee5cfa63c2b2998dbe971a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 4 Jul 2011 17:53:47 +0200 Subject: Implement support for database operations callbacks New object pragma: callback. New test: common/callback. New manual section: 10.1.4, "callback". --- odb/pragma.cxx | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'odb/pragma.cxx') diff --git a/odb/pragma.cxx b/odb/pragma.cxx index a22c1d1..3b8d222 100644 --- a/odb/pragma.cxx +++ b/odb/pragma.cxx @@ -127,7 +127,8 @@ check_decl_type (tree d, string const& name, string const& p, location_t l) } else if (p == "object" || p == "pointer" || - p == "abstract") + p == "abstract" || + p == "callback") { if (tc != RECORD_TYPE) { @@ -374,6 +375,41 @@ handle_pragma (cpp_reader* reader, tt = pragma_lex (&t); } + else if (p == "callback") + { + // callback (name) + // + + // Make sure we've got the correct declaration type. + // + if (decl != 0 && !check_decl_type (decl, decl_name, p, loc)) + return; + + if (pragma_lex (&t) != CPP_OPEN_PAREN) + { + error () << "'(' expected after db pragma '" << p << "'" << endl; + return; + } + + tt = pragma_lex (&t); + + if (tt != CPP_NAME) + { + error () << "member function name expected in db pragma '" << p + << "'" << endl; + return; + } + + val = IDENTIFIER_POINTER (t); + + if (pragma_lex (&t) != CPP_CLOSE_PAREN) + { + error () << "')' expected at the end of db pragma '" << p << "'" << endl; + return; + } + + tt = pragma_lex (&t); + } else if (p == "id") { // id -- cgit v1.1