From 9642f6d9464aa17be3d541f0802992fc7d2e5078 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Tue, 6 May 2014 16:11:13 +0200 Subject: [PATCH] cppbind: add naContext/naRef overload to Ghost::_set --- simgear/nasal/cppbind/Ghost.hxx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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. -- 2.39.5