/* Zeta API - Z/classes/Selector.hpp ______ ______________ ___ |__ / | ___|___ ___|/ \ / /__| __| | | / - \ /______|_____| |__| /__/ \__\ Copyright (C) 2006-2024 Manuel Sainz de Baranda y Goñi. Released under the terms of the GNU Lesser General Public License v3. */ #ifndef Z_classes_Selector_HPP #define Z_classes_Selector_HPP #include #if Z_DIALECT_HAS(CPP98, SFINAE) && \ Z_DIALECT_HAS(CPP11, VARIADIC_TEMPLATE) && \ Z_DIALECT_HAS(CPP11, DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATE) # include # include # if Z_DIALECT_HAS(CPP11, RVALUE_REFERENCE) # include # endif # define Z_HAS_Selector 1 namespace Zeta { template struct Selector; template struct Selector { typedef r (* Send )(id, SEL, p...); typedef r (* SendSuper)(objc_super *, SEL, p...); SEL selector; Z_INLINE Selector() Z_DEFAULTED({}) Z_INLINE Selector(SEL selector_) : selector(selector_) {} Z_INLINE operator SEL() const Z_NOTHROW {return selector;} Z_INLINE r operator ()(id object, typename Type

::to_forwardable... arguments) const Z_NOTHROW { return (Send(ObjectiveC::send())) (object, selector, arguments...); } Z_INLINE r super(id object, typename Type

::to_forwardable... arguments) const Z_NOTHROW { objc_super object_super = {object, class_getSuperclass(object_getClass(object))}; return (SendSuper(ObjectiveC::send_super())) (&object_super, selector, arguments...); } Z_INLINE r super(const objc_super &object_super, typename Type

::to_forwardable... arguments) const Z_NOTHROW { return (SendSuper(ObjectiveC::send_super())) (const_cast(&object_super), selector, arguments...); } }; # if Z_DIALECT_HAS(CPP11, RVALUE_REFERENCE) template struct Selector { typedef r (* Send )(id, SEL, p..., ...); typedef r (* SendSuper)(objc_super *, SEL, p..., ...); SEL selector; Z_INLINE Selector() Z_DEFAULTED({}) Z_INLINE Selector(SEL selector) : selector(selector) {} Z_INLINE operator SEL() const Z_NOTHROW {return selector;} template Z_INLINE r operator ()(id object, pp&&... arguments) const Z_NOTHROW { return (Send(ObjectiveC::send())) (object, selector, forwardable(arguments)...); } template Z_INLINE r super(id object, pp&&... arguments) const Z_NOTHROW { objc_super object_super = {object, class_getSuperclass(object_getClass(object))}; return (SendSuper(ObjectiveC::send_super())) (&object_super, selector, forwardable(arguments)...); } template Z_INLINE r super(const objc_super &object_super, pp&&... arguments) const Z_NOTHROW { return (SendSuper(ObjectiveC::send_super())) (const_cast(&object_super), selector, forwardable(arguments)...); } }; # endif } #endif #endif // Z_classes_Selector_HPP