NuriaProject Framework
0.1
The NuriaProject Framework
|
The MetaMethod class lets you access methods from registered types. More...
#include <metaobject.hpp>
Public Types | |
enum | Type { Method = 0, Static = 1, Constructor = 2 } |
Public Member Functions | |
MetaMethod () | |
MetaAnnotation | annotation (int idx) const |
int | annotationCount () const |
int | annotationLowerBound (const QByteArray &name) const |
int | annotationUpperBound (const QByteArray &name) const |
QVector< QByteArray > | argumentNames () const |
QVector< QByteArray > | argumentTypes () const |
Callback | callback (void *instance=nullptr) const |
bool | isValid () const |
QByteArray | name () const |
QByteArray | returnType () const |
Callback | testCallback (void *instance=nullptr) const |
Type | type () const |
Callback | unsafeCallback (void *instance=nullptr) const |
Friends | |
class | MetaObject |
The MetaMethod class lets you access methods from registered types.
By default, constructors, static and member methods are exported.
Thus, the method int foo (int a = 1, int b = 2, int c = 3); would be expanded into four methods:
Type*
.Nuria::MetaMethod::MetaMethod | ( | ) |
Creates a invalid instance.
MetaAnnotation Nuria::MetaMethod::annotation | ( | int | idx | ) | const |
Returns the MetaAnnotation instance for the annotation at idx.
int Nuria::MetaMethod::annotationCount | ( | ) | const |
Returns the number of known annotations.
int Nuria::MetaMethod::annotationLowerBound | ( | const QByteArray & | name | ) | const |
Returns the index of the first annotation name. Returns -1
if there's no annotation called like that.
int Nuria::MetaMethod::annotationUpperBound | ( | const QByteArray & | name | ) | const |
Returns the index of the last annotation name. Returns -1
if there's no annotation called like that.
QVector< QByteArray > Nuria::MetaMethod::argumentNames | ( | ) | const |
Returns a list of all argument names.
QVector< QByteArray > Nuria::MetaMethod::argumentTypes | ( | ) | const |
Returns a list of all argument types.
Callback Nuria::MetaMethod::callback | ( | void * | instance = nullptr | ) | const |
Returns a callback of this method. Invoking it will call the method itself. If type() is Method
, then instance must point to a valid instance of the type this instance is pointing to. Not doing so will lead to undefined behaviour and probably crash the application.
The returned callback will also validate arguments if the method was annotated using NURIA_REQUIRE.
bool Nuria::MetaMethod::isValid | ( | ) | const |
Returns true
if this instance is valid.
QByteArray Nuria::MetaMethod::name | ( | ) | const |
Returns the name of the method.
QByteArray Nuria::MetaMethod::returnType | ( | ) | const |
Returns the result type name.
Callback Nuria::MetaMethod::testCallback | ( | void * | instance = nullptr | ) | const |
Returns a callback which returns true
when calling with arguments which would pass NURIA_REQUIRE tests. If the method doesn't have a NURIA_REQUIRE annotation, the returned callback is invalid.
Type Nuria::MetaMethod::type | ( | ) | const |
Returns the type of this method.
Callback Nuria::MetaMethod::unsafeCallback | ( | void * | instance = nullptr | ) | const |
Returns a callback pointing to the method. The only difference to callback() is that this method will not validate any arguments.
Use with care.