diff options
Diffstat (limited to 'system')
-rwxr-xr-x | system/include/emscripten/bind.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index a3886031..0bb21290 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -991,7 +991,23 @@ namespace emscripten { return *this; } - template<typename FieldType> + template<typename FieldType, typename = typename std::enable_if<!std::is_function<FieldType>::value>::type> + class_& property(const char* fieldName, const FieldType ClassType::*field) { + using namespace internal; + + _embind_register_class_property( + TypeID<ClassType>::get(), + fieldName, + TypeID<FieldType>::get(), + reinterpret_cast<GenericFunction>(&MemberAccess<ClassType, FieldType>::template getWire<ClassType>), + getContext(field), + 0, + 0, + 0); + return *this; + } + + template<typename FieldType, typename = typename std::enable_if<!std::is_function<FieldType>::value>::type> class_& property(const char* fieldName, FieldType ClassType::*field) { using namespace internal; @@ -1007,6 +1023,22 @@ namespace emscripten { return *this; } + template<typename Getter> + class_& property(const char* fieldName, Getter getter) { + using namespace internal; + typedef GetterPolicy<Getter> GP; + _embind_register_class_property( + TypeID<ClassType>::get(), + fieldName, + TypeID<typename GP::ReturnType>::get(), + reinterpret_cast<GenericFunction>(&GP::template get<ClassType>), + GP::getContext(getter), + 0, + 0, + 0); + return *this; + } + template<typename Getter, typename Setter> class_& property(const char* fieldName, Getter getter, Setter setter) { using namespace internal; |