X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=libs%2Fproperty.h;h=f195ae244926adf9bdce476d6b16d6fc40f3ba16;hb=HEAD;hp=abdb32f4d4a945b84120d449c1c640c67c3ecc6e;hpb=e36a9e0f374477a0a4c778d06454a979cd53fc47;p=xonotic%2Fnetradiant.git diff --git a/libs/property.h b/libs/property.h index abdb32f4..f195ae24 100644 --- a/libs/property.h +++ b/libs/property.h @@ -102,6 +102,23 @@ Property make_property(Self &self) { // chain +template +struct make_property_chain_I_1 { + static void ExportThunk(const Callback &self, SRC value) { + PropertyImpl::Export(value, self); + } + + static void Export(const X &self, const Callback &returnz) { + A::Get::thunk_(self, ConstReferenceCaller, void(SRC), ExportThunk>(returnz)); + } + + static void Import(X &self, DST value) { + SRC out; + PropertyImpl::Import(out, value); + A::Set::thunk_(self, out); + } +}; + template Property> make_property_chain(detail::propertyimpl_self &it) { using DST = detail::propertyimpl_other; @@ -109,45 +126,35 @@ Property> make_property_chain(detail::proper using X = detail::propertyimpl_self; using A = property_impl; - struct I { - static void ExportThunk(const Callback &self, SRC value) { - PropertyImpl::Export(value, self); - } - - static void Export(const X &self, const Callback &returnz) { - A::Get::thunk_(self, ConstReferenceCaller, void(SRC), ExportThunk>(returnz)); - } - - static void Import(X &self, DST value) { - SRC out; - PropertyImpl::Import(out, value); - A::Set::thunk_(self, out); - } - }; + using I = make_property_chain_I_1; return make_property>(it); } +template +struct make_property_chain_I_2 { + static void ExportThunk(const Callback &self, SRC value) { + PropertyImpl::Export(value, self); + } + + static void Export(const Callback &returnz) { + A::Get::thunk_(nullptr, ConstReferenceCaller, void(SRC), ExportThunk>(returnz)); + } + + static void Import(DST value) { + SRC out; + PropertyImpl::Import(out, value); + A::Set::thunk_(nullptr, out); + } +}; + template Property> make_property_chain() { using DST = detail::propertyimpl_other; using SRC = detail::propertyimpl_self; using A = property_impl_free; - struct I { - static void ExportThunk(const Callback &self, SRC value) { - PropertyImpl::Export(value, self); - } - - static void Export(const Callback &returnz) { - A::Get::thunk_(nullptr, ConstReferenceCaller, void(SRC), ExportThunk>(returnz)); - } - - static void Import(DST value) { - SRC out; - PropertyImpl::Import(out, value); - A::Set::thunk_(nullptr, out); - } - }; + using I = make_property_chain_I_2; + return make_property>(); }