]> git.mxchange.org Git - simgear.git/commitdiff
cppbind: add naContext/naRef overload to Ghost::_set
authorThomas Geymayer <tomgey@gmail.com>
Tue, 6 May 2014 14:11:13 +0000 (16:11 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Tue, 6 May 2014 16:10:35 +0000 (18:10 +0200)
simgear/nasal/cppbind/Ghost.hxx

index d34849018a2a3037590b49a80a8136b478345579..346f6fbba66757011ed89b17588b2ed9c42284c0 100644 (file)
@@ -538,7 +538,7 @@ namespace nasal
        * @endcode
        */
       template<class Param>
-      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<MyClassPtr>::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.