From: Thomas Geymayer Date: Tue, 6 May 2014 14:11:13 +0000 (+0200) Subject: cppbind: add naContext/naRef overload to Ghost::_set X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9642f6d9464aa17be3d541f0802992fc7d2e5078;p=simgear.git cppbind: add naContext/naRef overload to Ghost::_set --- diff --git a/simgear/nasal/cppbind/Ghost.hxx b/simgear/nasal/cppbind/Ghost.hxx index d3484901..346f6fbb 100644 --- a/simgear/nasal/cppbind/Ghost.hxx +++ b/simgear/nasal/cppbind/Ghost.hxx @@ -538,7 +538,7 @@ namespace nasal * @endcode */ template - Ghost _set(bool (raw_type::*setter)(const std::string&, Param)) + Ghost& _set(bool (raw_type::*setter)(const std::string&, Param)) { // Setter signature: bool( naContext, // raw_type&, @@ -552,6 +552,34 @@ namespace nasal )); } + /** + * Register a method which is called upon setting an unknown member of + * this ghost. + * + * @code{cpp} + * class MyClass + * { + * public: + * bool setMember( naContext c, + * const std::string& key, + * naRef value ); + * } + * + * Ghost::init("Test") + * ._set(&MyClass::setMember); + * @endcode + */ + Ghost& _set(bool (raw_type::*setter)( naContext, + const std::string&, + naRef )) + { + // Setter signature: bool( naContext, + // raw_type&, + // const std::string&, + // naRef ) + return _set( boost::bind(setter, _2, _1, _3, _4) ); + } + /** * Register anything that accepts an object instance and a * nasal::CallContext and returns naRef as method.