aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-04-08 12:19:26 -0700
committerJukka Jylänki <jujjyl@gmail.com>2013-04-18 20:08:04 +0300
commitf554c2fac03138bf6d3c25180b6dc6771fb80166 (patch)
tree0486c27f8cd2705ef4474b5ad92dcf7ba03313ca /system
parent040eb9db4222bf3b3eff2ba0ca72e83830f76d47 (diff)
Generalize class property access.
Diffstat (limited to 'system')
-rwxr-xr-xsystem/include/emscripten/bind.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index 57e44c0c..d70aec91 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -136,10 +136,12 @@ namespace emscripten {
void _embind_register_class_property(
TYPEID classType,
const char* fieldName,
- TYPEID fieldType,
+ TYPEID getterReturnType,
GenericFunction getter,
+ void* getterContext,
+ TYPEID setterArgumentType,
GenericFunction setter,
- void* context);
+ void* setterContext);
void _embind_register_class_class_function(
TYPEID classType,
@@ -980,11 +982,30 @@ namespace emscripten {
fieldName,
TypeID<FieldType>::get(),
reinterpret_cast<GenericFunction>(&MemberAccess<ClassType, FieldType>::template getWire<ClassType>),
+ getContext(field),
+ TypeID<FieldType>::get(),
reinterpret_cast<GenericFunction>(&MemberAccess<ClassType, FieldType>::template setWire<ClassType>),
getContext(field));
return *this;
}
+ template<typename Getter, typename Setter>
+ class_& property(const char* fieldName, Getter getter, Setter setter) {
+ using namespace internal;
+ typedef GetterPolicy<Getter> GP;
+ typedef SetterPolicy<Setter> SP;
+ _embind_register_class_property(
+ TypeID<ClassType>::get(),
+ fieldName,
+ TypeID<typename GP::ReturnType>::get(),
+ reinterpret_cast<GenericFunction>(&GP::template get<ClassType>),
+ GP::getContext(getter),
+ TypeID<typename SP::ArgumentType>::get(),
+ reinterpret_cast<GenericFunction>(&SP::template set<ClassType>),
+ SP::getContext(setter));
+ return *this;
+ }
+
template<typename ReturnType, typename... Args, typename... Policies>
class_& class_function(const char* methodName, ReturnType (*classMethod)(Args...), Policies...) {
using namespace internal;