return member(field, to_getter(getter), to_setter(setter));
}
+ template<class Param>
+ Ghost& member( const std::string& field,
+ const getter_t& getter,
+ void (raw_type::*setter)(Param) )
+ {
+ return member(field, getter, to_setter(setter));
+ }
+
+ template<class Ret>
+ Ghost& member( const std::string& field,
+ Ret (raw_type::*getter)() const,
+ const setter_t& setter )
+ {
+ return member(field, to_getter(getter), setter);
+ }
+
/**
* Register a read only member variable.
*
return member(field, to_getter(getter), setter_t());
}
+ Ghost& member( const std::string& field,
+ naRef (*getter)(const raw_type&, naContext) )
+ {
+ return member(field, getter_t(getter), setter_t());
+ }
+
+ Ghost& member( const std::string& field,
+ naRef (*getter)(raw_type&, naContext) )
+ {
+ return member(field, getter_t(getter), setter_t());
+ }
+
/**
* Register a write only member variable.
*
return member(field, getter_t(), to_setter(setter));
}
+ Ghost& member( const std::string& field,
+ void (*setter)(raw_type&, naContext, naRef) )
+ {
+ return member(field, getter_t(), setter_t(setter));
+ }
+
+ Ghost& member( const std::string& field,
+ const setter_t& setter )
+ {
+ return member(field, getter_t(), setter);
+ }
+
/**
* Register a member variable by passing a getter and/or setter method.
*
* {
* public:
* bool getMember( const std::string& key,
- * std::string& value_out );
+ * std::string& value_out ) const;
* }
*
* Ghost<MyClassPtr>::init("Test")
* @endcode
*/
template<class Param>
- Ghost& _get(bool (raw_type::*getter)(const std::string&, Param&))
+ Ghost& _get(bool (raw_type::*getter)(const std::string&, Param&) const)
{
return _get(
boost::function<bool (raw_type&, const std::string&, Param&)>(getter)
*/
Ghost& _get(bool (raw_type::*getter)( naContext,
const std::string&,
- naRef& ))
+ naRef& ) const)
{
return _get( fallback_getter_t(getter) );
}
{
return key == "test";
}
- bool genericGet(const std::string& key, std::string& val_out)
+ bool genericGet(const std::string& key, std::string& val_out) const
{
if( key != "get_test" )
return false;
int getX() const { return _x; }
void setX(int x) { _x = x; }
};
+
+naRef f_derivedGetRandom(const Derived&, naContext)
+{
+ return naNil();
+}
+void f_derivedSetX(Derived& d, naContext, naRef r)
+{
+ d._x = static_cast<int>(naNumValue(r).num);
+}
+
struct DoubleDerived:
public Derived
{
.bases<BasePtr>()
.member("x", &Derived::getX, &Derived::setX)
.member("x_alternate", &f_derivedGetX)
+ .member("x_mixed", &f_derivedGetRandom, &Derived::setX)
+ .member("x_mixed2", &Derived::getX, &f_derivedSetX)
+ .member("x_w", &f_derivedSetX)
.method("free_fn", &derivedFreeMember)
.method("free_member", &derivedFreeMember)
.method("baseDoIt", &baseFuncCallContext);