Skip to content

Instantly share code, notes, and snippets.

@chadaustin
Created April 2, 2013 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadaustin/5289435 to your computer and use it in GitHub Desktop.
Save chadaustin/5289435 to your computer and use it in GitHub Desktop.
template<
typename GetterReturnType,
typename GetterThisType,
typename SetterArgumentType,
typename SetterThisType>
value_struct& field(
const char* fieldName,
GetterReturnType (*getter)(const GetterThisType&),
void (*setter)(SetterThisType&, SetterArgumentType)
) {
using namespace internal;
_embind_register_struct_field(
TypeID<ClassType>::get(),
fieldName,
TypeID<GetterReturnType>::get(),
reinterpret_cast<GenericFunction>(
&PropertyAccess<ClassType, GetterReturnType>
::template propertyGet<decltype(getter)>),
getContext(getter),
TypeID<SetterArgumentType>::get(),
reinterpret_cast<GenericFunction>(
&PropertyAccess<ClassType, SetterArgumentType>
::template propertySet<decltype(setter)>),
getContext(setter));
return *this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment