aboutsummaryrefslogtreecommitdiff
path: root/odb/pragma.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-09-11 11:06:34 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-09-11 11:06:34 +0200
commitd780414989ef7e101cdaf269d4b01003d0721e6a (patch)
treef657033eebe7d38032c4ad1ad4e202c990bb0d8c /odb/pragma.hxx
parente56ba020233ad7cb4762df300a6774db9195d817 (diff)
Generalize pragma code to support arbitrary types for context values
Diffstat (limited to 'odb/pragma.hxx')
-rw-r--r--odb/pragma.hxx39
1 files changed, 22 insertions, 17 deletions
diff --git a/odb/pragma.hxx b/odb/pragma.hxx
index 5ff6165..ba4aab8 100644
--- a/odb/pragma.hxx
+++ b/odb/pragma.hxx
@@ -13,10 +13,11 @@
#include <vector>
#include <string>
+#include <cutl/container/any.hxx>
+#include <cutl/compiler/context.hxx>
+
struct pragma
{
- enum mode_type {override, accumulate};
-
// Check that the pragma is applicable to the declaration. Return true
// on success, complain and return false otherwise.
//
@@ -25,46 +26,50 @@ struct pragma
std::string const& prag_name,
location_t);
- pragma (mode_type m,
- std::string const& pn,
+ // Add the pragma value to the context.
+ //
+ typedef void (*add_func) (cutl::compiler::context&,
+ std::string const& key,
+ cutl::container::any const& value,
+ location_t);
+
+ pragma (std::string const& pn,
std::string const& cn,
- std::string const& v,
- tree n,
+ cutl::container::any const& v,
location_t l,
- check_func c)
- : mode (m),
- pragma_name (pn),
+ check_func c,
+ add_func a)
+ : pragma_name (pn),
context_name (cn),
value (v),
- node (n),
loc (l),
- check (c)
+ check (c),
+ add (a)
{
}
bool
operator< (pragma const& y) const
{
- if (mode == override)
+ if (add == 0)
return pragma_name < y.pragma_name;
else
return pragma_name < y.pragma_name ||
(pragma_name == y.pragma_name && loc < y.loc);
}
- mode_type mode;
std::string pragma_name; // Actual pragma name for diagnostics.
std::string context_name; // Context entry name.
- std::string value;
- tree node;
+ cutl::container::any value;
location_t loc;
check_func check;
+ add_func add;
};
typedef std::vector<pragma> pragma_list;
-// A set of pragmas. Insertion of a pragma with the same name and override
-// mode overrides the old value.
+// A set of pragmas. Insertion of a pragma with the same name and no
+// custom add function overrides the old value.
//
struct pragma_set: std::set<pragma>
{