This commit is contained in:
Chad Austin 2013-03-07 18:42:32 -08:00 коммит произвёл Jukka Jylänki
Родитель 770221aa38
Коммит b72bbd3938
2 изменённых файлов: 27 добавлений и 27 удалений

Просмотреть файл

@ -947,7 +947,7 @@ function __embind_register_class_class_function(
}); });
} }
function __embind_register_class_field( function __embind_register_class_property(
rawClassType, rawClassType,
fieldName, fieldName,
rawFieldType, rawFieldType,

Просмотреть файл

@ -128,7 +128,7 @@ namespace emscripten {
size_t memberFunctionSize, size_t memberFunctionSize,
void* memberFunction); void* memberFunction);
void _embind_register_class_field( void _embind_register_class_property(
TYPEID classType, TYPEID classType,
const char* fieldName, const char* fieldName,
TYPEID fieldType, TYPEID fieldType,
@ -363,17 +363,17 @@ namespace emscripten {
} }
}; };
template<typename ClassType, typename FieldType> template<typename ClassType, typename MemberType>
struct FieldAccess { struct MemberAccess {
typedef FieldType ClassType::*MemberPointer; typedef MemberType ClassType::*MemberPointer;
typedef internal::BindingType<FieldType> FieldBinding; typedef internal::BindingType<MemberType> MemberBinding;
typedef typename FieldBinding::WireType WireType; typedef typename MemberBinding::WireType WireType;
static WireType get( static WireType get(
ClassType& ptr, ClassType& ptr,
const MemberPointer& field const MemberPointer& field
) { ) {
return FieldBinding::toWireType(ptr.*field); return MemberBinding::toWireType(ptr.*field);
} }
static void set( static void set(
@ -381,7 +381,7 @@ namespace emscripten {
const MemberPointer& field, const MemberPointer& field,
WireType value WireType value
) { ) {
ptr.*field = FieldBinding::fromWireType(value); ptr.*field = MemberBinding::fromWireType(value);
} }
template<typename Getter> template<typename Getter>
@ -389,7 +389,7 @@ namespace emscripten {
ClassType& ptr, ClassType& ptr,
const Getter& getter const Getter& getter
) { ) {
return FieldBinding::toWireType(getter(ptr)); return MemberBinding::toWireType(getter(ptr));
} }
template<typename Setter> template<typename Setter>
@ -398,7 +398,7 @@ namespace emscripten {
const Setter& setter, const Setter& setter,
WireType value WireType value
) { ) {
setter(ptr, FieldBinding::fromWireType(value)); setter(ptr, MemberBinding::fromWireType(value));
} }
}; };
@ -424,8 +424,8 @@ namespace emscripten {
internal::_embind_register_tuple_element( internal::_embind_register_tuple_element(
internal::TypeID<ClassType>::get(), internal::TypeID<ClassType>::get(),
internal::TypeID<ElementType>::get(), internal::TypeID<ElementType>::get(),
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::get), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::get),
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::set), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::set),
sizeof(field), sizeof(field),
&field); &field);
@ -437,10 +437,10 @@ namespace emscripten {
internal::_embind_register_tuple_element_accessor( internal::_embind_register_tuple_element_accessor(
internal::TypeID<ClassType>::get(), internal::TypeID<ClassType>::get(),
internal::TypeID<ElementType>::get(), internal::TypeID<ElementType>::get(),
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::template propertyGet<ElementType(const ClassType&)>), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::template propertyGet<ElementType(const ClassType&)>),
sizeof(getter), sizeof(getter),
&getter, &getter,
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::template propertySet<void(ClassType&, ElementType)>), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::template propertySet<void(ClassType&, ElementType)>),
sizeof(setter), sizeof(setter),
&setter); &setter);
return *this; return *this;
@ -451,10 +451,10 @@ namespace emscripten {
internal::_embind_register_tuple_element_accessor( internal::_embind_register_tuple_element_accessor(
internal::TypeID<ClassType>::get(), internal::TypeID<ClassType>::get(),
internal::TypeID<ElementType>::get(), internal::TypeID<ElementType>::get(),
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::template propertyGet<ElementType(const ClassType&)>), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::template propertyGet<ElementType(const ClassType&)>),
sizeof(getter), sizeof(getter),
&getter, &getter,
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::template propertySet<void(ClassType&, ElementType)>), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::template propertySet<void(ClassType&, ElementType)>),
sizeof(setter), sizeof(setter),
&setter); &setter);
return *this; return *this;
@ -465,10 +465,10 @@ namespace emscripten {
internal::_embind_register_tuple_element_accessor( internal::_embind_register_tuple_element_accessor(
internal::TypeID<ClassType>::get(), internal::TypeID<ClassType>::get(),
internal::TypeID<ElementType>::get(), internal::TypeID<ElementType>::get(),
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::template propertyGet<ElementType(const ClassType&)>), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::template propertyGet<ElementType(const ClassType&)>),
sizeof(getter), sizeof(getter),
&getter, &getter,
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::template propertySet<void(ClassType&, ElementType)>), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::template propertySet<void(ClassType&, ElementType)>),
sizeof(setter), sizeof(setter),
&setter); &setter);
return *this; return *this;
@ -479,10 +479,10 @@ namespace emscripten {
internal::_embind_register_tuple_element_accessor( internal::_embind_register_tuple_element_accessor(
internal::TypeID<ClassType>::get(), internal::TypeID<ClassType>::get(),
internal::TypeID<ElementType>::get(), internal::TypeID<ElementType>::get(),
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::template propertyGet<ElementType(const ClassType&)>), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::template propertyGet<ElementType(const ClassType&)>),
sizeof(getter), sizeof(getter),
&getter, &getter,
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, ElementType>::template propertySet<void(ClassType&, ElementType)>), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, ElementType>::template propertySet<void(ClassType&, ElementType)>),
sizeof(setter), sizeof(setter),
&setter); &setter);
return *this; return *this;
@ -510,8 +510,8 @@ namespace emscripten {
internal::TypeID<ClassType>::get(), internal::TypeID<ClassType>::get(),
fieldName, fieldName,
internal::TypeID<FieldType>::get(), internal::TypeID<FieldType>::get(),
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, FieldType>::get), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, FieldType>::get),
reinterpret_cast<internal::GenericFunction>(&internal::FieldAccess<ClassType, FieldType>::set), reinterpret_cast<internal::GenericFunction>(&internal::MemberAccess<ClassType, FieldType>::set),
sizeof(field), sizeof(field),
&field); &field);
@ -799,15 +799,15 @@ namespace emscripten {
} }
template<typename FieldType> template<typename FieldType>
class_& field(const char* fieldName, FieldType ClassType::*field) { class_& property(const char* fieldName, FieldType ClassType::*field) {
using namespace internal; using namespace internal;
_embind_register_class_field( _embind_register_class_property(
TypeID<ClassType>::get(), TypeID<ClassType>::get(),
fieldName, fieldName,
TypeID<FieldType>::get(), TypeID<FieldType>::get(),
reinterpret_cast<GenericFunction>(&FieldAccess<ClassType, FieldType>::get), reinterpret_cast<GenericFunction>(&MemberAccess<ClassType, FieldType>::get),
reinterpret_cast<GenericFunction>(&FieldAccess<ClassType, FieldType>::set), reinterpret_cast<GenericFunction>(&MemberAccess<ClassType, FieldType>::set),
sizeof(field), sizeof(field),
&field); &field);
return *this; return *this;