summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2011-01-31 18:06:39 -0500
committerNat Goodspeed <nat@lindenlab.com>2011-01-31 18:06:39 -0500
commitd6e95923294483a5044fb6c66f7530442d55d338 (patch)
tree9910ba899cb3928a0912eaafb21d67acd7cf6fac
parent8b7c903e5cf5620deaab09ec39e978d62ddb45c3 (diff)
Resolve LLEventDispatcher::add(function(const LLSD&)) ambiguity.
A free function or static method accepting(const LLSD&) was being intercepted by the free-function-with-arbitrary-parameters overload instead of the original Callable overload. Added an overload that specifically redirects that case. Documented limit of ~6 arbitrary parameters for directly-called functions (5 for methods). Beyond that many, you have to write a Callable wrapper function and unpack the parameters from the LLSD by hand.
-rw-r--r--indra/llcommon/lleventdispatcher.h42
1 files changed, 29 insertions, 13 deletions
diff --git a/indra/llcommon/lleventdispatcher.h b/indra/llcommon/lleventdispatcher.h
index ce0fc7b585..b37189b58b 100644
--- a/indra/llcommon/lleventdispatcher.h
+++ b/indra/llcommon/lleventdispatcher.h
@@ -112,6 +112,19 @@ public:
const LLSD& required=LLSD());
/**
+ * The case of a free function (or static method) accepting(const LLSD&)
+ * could also be intercepted by the arbitrary-args overload below. Ensure
+ * that it's directed to the Callable overload above instead.
+ */
+ void add(const std::string& name,
+ const std::string& desc,
+ void (*f)(const LLSD&),
+ const LLSD& required=LLSD())
+ {
+ add(name, desc, Callable(f), required);
+ }
+
+ /**
* Special case: a subclass of this class can pass an unbound member
* function pointer (of an LLEventDispatcher subclass) without explicitly
* specifying the <tt>boost::bind()</tt> expression. The passed @a method
@@ -137,19 +150,6 @@ public:
addMethod<CLASS>(name, desc, method, required);
}
-/*==========================================================================*|
- /// Convenience: for LLEventDispatcher, not every callable needs a
- /// documentation string. The passed @a callable accepts a single LLSD
- /// value, presumably containing other parameters.
- template <typename CALLABLE>
- void add(const std::string& name,
- CALLABLE callable,
- const LLSD& required=LLSD())
- {
- add(name, "", callable, required);
- }
-|*==========================================================================*/
-
//@}
/// @name Register functions with arbitrary param lists
@@ -159,6 +159,10 @@ public:
* Register a free function with arbitrary parameters. (This also works
* for static class methods.)
*
+ * @note This supports functions with up to about 6 parameters -- after
+ * that you start getting dismaying compile errors in which
+ * boost::fusion::joint_view is mentioned a surprising number of times.
+ *
* When calling this name, pass an LLSD::Array. Each entry in turn will be
* converted to the corresponding parameter type using LLSDParam.
*/
@@ -171,6 +175,10 @@ public:
/**
* Register a nonstatic class method with arbitrary parameters.
*
+ * @note This supports functions with up to about 6 parameters -- after
+ * that you start getting dismaying compile errors in which
+ * boost::fusion::joint_view is mentioned a surprising number of times.
+ *
* To cover cases such as a method on an LLSingleton we don't yet want to
* instantiate, instead of directly storing an instance pointer, accept a
* nullary callable returning a pointer/reference to the desired class
@@ -192,6 +200,10 @@ public:
* Register a free function with arbitrary parameters. (This also works
* for static class methods.)
*
+ * @note This supports functions with up to about 6 parameters -- after
+ * that you start getting dismaying compile errors in which
+ * boost::fusion::joint_view is mentioned a surprising number of times.
+ *
* Pass an LLSD::Array of parameter names, and optionally another
* LLSD::Array of default parameter values, a la LLSDArgsMapper.
*
@@ -210,6 +222,10 @@ public:
/**
* Register a nonstatic class method with arbitrary parameters.
*
+ * @note This supports functions with up to about 6 parameters -- after
+ * that you start getting dismaying compile errors in which
+ * boost::fusion::joint_view is mentioned a surprising number of times.
+ *
* To cover cases such as a method on an LLSingleton we don't yet want to
* instantiate, instead of directly storing an instance pointer, accept a
* nullary callable returning a pointer/reference to the desired class