#include <coherence/lang/TypedMethod.hpp>
Inherits Method.
Rather then making direct use of this class it is recommended to utilize the following helper macros. For each of these methods there are nine variants suffixed 0..8 which indicate the number of arguments the method takes.
Additionally the following macros will create setter and getter Methods for a "property".
These macros output Method objects which can then be registered with their corresponding Class object. This registration can either be performed as part of the Class registration, or it can be done in multiple COH_REGISTER_METHOD blocks, allowing the Method definition to reside next to the actual method implementation.
// Person.hpp class Person : public class_spec<Person> { friend class factory<Person>; protected: Person(String::View vsName = String::null_string, int32_t nAge = 0); public: virtual void setName(String::View vsName); virtual String::View getName() const; virtual void setAge(int32_t nAge); virtual int32_t getAge() const; ... };
// Person.cpp - using single class registration block COH_REGISTER_CLASS(TypedClass<Person>::create() ->declare(COH_CONSTRUCTOR2(Person, String::View, BoxHandle<const Integer32>)) ->declare(COH_PROPERTY(Person, Name, String::View)) ->declare(COH_BOX_PROPERTY(Person, Age, Integer32::View));
// Person.cpp - using multi method registration blocks COH_REGISTER_TYPED_CLASS(Person); Person::Person(String::View vsName, int32_t nAge) { ... } COH_REGISTER_METHOD(Person, COH_CONSTRUCTOR2(Person, String::View, BoxHandle<const Integer32>)); void Person::setName(String::View vsName) { ... } COH_REGISTER_METHOD(Person, COH_METHOD1(void, Person::Handle, setName, String::View)); String::View Person::getName() const { ... } COH_REGISTER_METHOD(Person, COH_METHOD0(String::View, Person::View, getName)); void Person::setAge(int32_t nAge) { ... } COH_REGISTER_METHOD(Person, COH_METHOD1(void, Person::Handle, setName, BoxHandle<const Integer32>)); int32_t Person::getAge() const { ... } COH_REGISTER_METHOD(Person, COH_METHOD0(BoxHandle<const Integer32>, Person::View, getName));
Public Types | |||||||
typedef spec::Handle | Handle | ||||||
TypedMethod<P, R, C, H, M, A1, A2, A3, A4, A5, A6, A7, A8> Handle definition. | |||||||
typedef spec::View | View | ||||||
TypedMethod<P, R, C, H, M, A1, A2, A3, A4, A5, A6, A7, A8> View definition. | |||||||
typedef spec::Holder | Holder | ||||||
TypedMethod<P, R, C, H, M, A1, A2, A3, A4, A5, A6, A7, A8> Holder definition. | |||||||
Public Member Functions | |||||||
virtual int32_t | getModifiers () const | ||||||
Return the method modifiers.
| |||||||
virtual ObjectArray::View | getParameterTypes () const | ||||||
Return an array of Class::Views representing the method parameter types.
| |||||||
virtual Method::ClassView | getReturnType () const | ||||||
Return the Class::View representing the method's return type, or NULL for void.
| |||||||
virtual Method::ClassView | getDeclaringClass () const | ||||||
Return the Class::View representing the class in which the method is declared.
| |||||||
virtual Object::Holder | invoke (Object::Holder oh, ObjectArray::View vaArgs) const | ||||||
Execute the method.
| |||||||
Protected Member Functions | |||||||
TypedMethod (String::View vsName) | |||||||
Construct a TypedMethod. |
TypedMethod | ( | String::View | vsName | ) | [inline, protected] |