aboutsummaryrefslogtreecommitdiff
path: root/odb/pragma.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-09-05 10:36:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-09-05 10:36:33 +0200
commit428558c89850fe8c79b9c89a943bd996912d12f5 (patch)
treeb6d8af6fd6a82b3e3822f7da4637c7c16ee7100d /odb/pragma.cxx
parenta7ec19749a76cc262240124f5c71c1ee4051cba7 (diff)
Support for views; native part
Diffstat (limited to 'odb/pragma.cxx')
-rw-r--r--odb/pragma.cxx90
1 files changed, 49 insertions, 41 deletions
diff --git a/odb/pragma.cxx b/odb/pragma.cxx
index 23d3fd3..ec3fb8d 100644
--- a/odb/pragma.cxx
+++ b/odb/pragma.cxx
@@ -126,9 +126,11 @@ check_decl_type (tree d, string const& name, string const& p, location_t l)
}
}
else if (p == "object" ||
+ p == "view" ||
p == "pointer" ||
p == "abstract" ||
- p == "callback")
+ p == "callback" ||
+ p == "query")
{
if (tc != RECORD_TYPE)
{
@@ -140,7 +142,7 @@ check_decl_type (tree d, string const& name, string const& p, location_t l)
else if (p == "table")
{
// Table can be used for both members (container) and types (container
- // or object).
+ // object, or view).
//
if (tc != FIELD_DECL && !TYPE_P (d))
{
@@ -442,6 +444,40 @@ handle_pragma (cpp_reader* reader,
tt = pragma_lex (&t);
}
+ else if (p == "query")
+ {
+ // query ("statement")
+ //
+
+ // 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_STRING)
+ {
+ error () << "query statement expected in db pragma '" << p << "'" << endl;
+ return;
+ }
+
+ val = TREE_STRING_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
@@ -839,47 +875,12 @@ handle_pragma_qualifier (cpp_reader* reader, string const& p)
// Pragma qualifiers.
//
- if (p == "object")
+ if (p == "object" ||
+ p == "view" ||
+ p == "value")
{
// object [(<identifier>)]
- //
-
- tt = pragma_lex (&t);
-
- if (tt == CPP_OPEN_PAREN)
- {
- tt = pragma_lex (&t);
-
- if (tt == CPP_NAME || tt == CPP_SCOPE)
- {
- decl = parse_scoped_name (t, tt, decl_name, true, p);
-
- if (decl == 0)
- return;
-
- // Make sure we've got the correct declaration type.
- //
- if (!check_decl_type (decl, decl_name, p, loc))
- return;
-
- if (tt != CPP_CLOSE_PAREN)
- {
- error () << "')' expected at the end of db pragma '" << p << "'"
- << endl;
- return;
- }
-
- tt = pragma_lex (&t);
- }
- else
- {
- error () << "type name expected in db pragma '" << p << "'" << endl;
- return;
- }
- }
- }
- else if (p == "value")
- {
+ // view [(<identifier>)]
// value [(<identifier>)]
//
@@ -1029,6 +1030,12 @@ handle_pragma_db_object (cpp_reader* r)
}
extern "C" void
+handle_pragma_db_view (cpp_reader* r)
+{
+ handle_pragma_qualifier (r, "view");
+}
+
+extern "C" void
handle_pragma_db_value (cpp_reader* r)
{
handle_pragma_qualifier (r, "value");
@@ -1229,6 +1236,7 @@ register_odb_pragmas (void*, void*)
/*
c_register_pragma_with_expansion ("db", "object", handle_pragma_db_object);
+ c_register_pragma_with_expansion ("db", "view", handle_pragma_db_view);
c_register_pragma_with_expansion ("db", "value", handle_pragma_db_value);
c_register_pragma_with_expansion ("db", "member", handle_pragma_db_member);
c_register_pragma_with_expansion ("db", "id", handle_pragma_db_id);