diff --git a/src/embind/embind.js b/src/embind/embind.js index f850c73f2..845bf98bb 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -419,30 +419,34 @@ function __embind_register_tuple_element( function __embind_register_tuple_element_accessor( rawTupleType, - rawElementType, - rawStaticGetter, + getterReturnType, + getter, getterContext, - rawStaticSetter, + setterArgumentType, + setter, setterContext ) { var tupleType = requireRegisteredType(rawTupleType, 'tuple'); - rawStaticGetter = FUNCTION_TABLE[rawStaticGetter]; - rawStaticSetter = FUNCTION_TABLE[rawStaticSetter]; + getter = FUNCTION_TABLE[getter]; + setter = FUNCTION_TABLE[setter]; - whenDependentTypesAreResolved([], [rawElementType], function(elementType) { - elementType = elementType[0]; + // TODO: test incomplete registration of value tuples + whenDependentTypesAreResolved([], [getterReturnType, setterArgumentType], function(types) { + var getterReturnType = types[0]; + var setterArgumentType = types[1]; tupleType.elements.push({ read: function(ptr) { - return elementType.fromWireType(rawStaticGetter( - getterContext, - ptr)); + return getterReturnType.fromWireType( + getter( + getterContext, + ptr)); }, write: function(ptr, o) { var destructors = []; - rawStaticSetter( + setter( setterContext, ptr, - elementType.toWireType(destructors, o)); + setterArgumentType.toWireType(destructors, o)); runDestructors(destructors); } }); diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index 947f0b307..a002ca239 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -77,9 +77,10 @@ namespace emscripten { void _embind_register_tuple_element_accessor( TYPEID tupleType, - TYPEID elementType, + TYPEID getterReturnType, GenericFunction staticGetter, void* getterContext, + TYPEID setterArgumentType, GenericFunction staticSetter, void* setterContext); @@ -419,54 +420,23 @@ namespace emscripten { return *this; } - template - value_tuple& element(ElementType (*getter)(const ClassType&), void (*setter)(ClassType&, ElementType)) { + template + value_tuple& element( + GetterReturnType (*getter)(const ClassType&), + void (*setter)(ClassType&, SetterArgumentType) + ) { using namespace internal; _embind_register_tuple_element_accessor( TypeID::get(), - TypeID::get(), - reinterpret_cast(&MemberAccess::template propertyGet), + TypeID::get(), + reinterpret_cast( + &MemberAccess + ::template propertyGet), getContext(getter), - reinterpret_cast(&MemberAccess::template propertySet), - getContext(setter)); - return *this; - } - - template - value_tuple& element(ElementType (*getter)(const ClassType&), void (*setter)(ClassType&, const ElementType&)) { - using namespace internal; - _embind_register_tuple_element_accessor( - TypeID::get(), - TypeID::get(), - reinterpret_cast(&MemberAccess::template propertyGet), - getContext(getter), - reinterpret_cast(&MemberAccess::template propertySet), - getContext(setter)); - return *this; - } - - template - value_tuple& element(ElementType (*getter)(const ClassType&), void (*setter)(ClassType&, const ElementType&&)) { - using namespace internal; - _embind_register_tuple_element_accessor( - TypeID::get(), - TypeID::get(), - reinterpret_cast(&MemberAccess::template propertyGet), - getContext(getter), - reinterpret_cast(&MemberAccess::template propertySet), - getContext(setter)); - return *this; - } - - template - value_tuple& element(ElementType (*getter)(const ClassType&), void (*setter)(ClassType&, ElementType&)) { - using namespace internal; - _embind_register_tuple_element_accessor( - TypeID::get(), - TypeID::get(), - reinterpret_cast(&MemberAccess::template propertyGet), - getContext(getter), - reinterpret_cast(&MemberAccess::template propertySet), + TypeID::get(), + reinterpret_cast( + &MemberAccess + ::template propertySet), getContext(setter)); return *this; }