BNM 2.4.0
 
Loading...
Searching...
No Matches
BNM::Method< Ret > Struct Template Reference

Typed class for working with il2cpp methods. More...

#include <Method.hpp>

Public Member Functions

constexpr Method () noexcept=default
 Create empty method.
 
template<typename OtherType>
 Method (const Method< OtherType > &other)
 Copy method.
 
 Method (const IL2CPP::MethodInfo *info)
 Create method from il2cpp method.
 
 Method (const IL2CPP::Il2CppReflectionMethod *reflectionMethod)
 Create method from il2cpp reflection method.
 
 Method (const MethodBase &other)
 Convert base method to typed method.
 
Method< Ret > & operator[] (void *instance)
 Operator for setting instance.
 
Method< Ret > & operator[] (IL2CPP::Il2CppObject *instance)
 Operator for setting instance.
 
Method< Ret > & operator[] (UnityEngine::Object *instance)
 Operator for setting instance.
 
template<typename ... Parameters>
Ret Call (Parameters ...parameters) const
 Call method.
 
template<typename ... Parameters>
Ret operator() (Parameters ...parameters) const
 Call method operator. Alias for BNM::Method::Call.
 
Method< Ret > & operator= (const MethodBase &other)
 Convert base method to typed method.
 
- Public Member Functions inherited from BNM::MethodBase
constexpr MethodBase ()=default
 Create empty method base.
 
 MethodBase (const MethodBase &other)=default
 Copy method.
 
 MethodBase (const IL2CPP::MethodInfo *info)
 Create method from il2cpp method.
 
 MethodBase (const IL2CPP::Il2CppReflectionMethod *reflectionMethod)
 Create method from il2cpp reflection method.
 
MethodBaseSetInstance (IL2CPP::Il2CppObject *val)
 Set method instance if it's non-static.
 
IL2CPP::MethodInfo * GetInfo () const
 Get MethodInfo.
 
BNM_PTR GetOffset () const
 Get method offset.
 
MethodBase GetGeneric (const std::initializer_list< CompileTimeClass > &templateTypes) const
 Get typed version of current generic method.
 
MethodBase GetOverride () const
 Get overridden method of current virtual method.
 
MethodBaseoperator[] (void *instance)
 Operator for setting instance.
 
MethodBaseoperator[] (IL2CPP::Il2CppObject *instance)
 Operator for setting instance.
 
MethodBaseoperator[] (UnityEngine::Object *instance)
 Operator for setting instance.
 
bool IsValid () const noexcept
 Check if method is valid.
 
std::string str () const
 Get full method name.
 
template<typename NewType>
Method< NewType > & cast () const
 Cast method to be able to call it.
 

Additional Inherited Members

- Public Attributes inherited from BNM::MethodBase
IL2CPP::MethodInfo * _data {}
 
IL2CPP::Il2CppObject * _instance {}
 
uint8_t _isStatic: 1 = false
 
uint8_t _isVirtual: 1 = false
 

Detailed Description

template<typename Ret>
struct BNM::Method< Ret >

Typed class for working with il2cpp methods.

This class provides API for calling methods.

Template Parameters
RetReturn type of method

Constructor & Destructor Documentation

◆ Method() [1/4]

template<typename Ret>
template<typename OtherType>
BNM::Method< Ret >::Method ( const Method< OtherType > & other)
inline

Copy method.

Parameters
otherOther method
Template Parameters
OtherTypeType of other method

◆ Method() [2/4]

template<typename Ret>
BNM::Method< Ret >::Method ( const IL2CPP::MethodInfo * info)
inline

Create method from il2cpp method.

Parameters
infoIl2cpp method

◆ Method() [3/4]

template<typename Ret>
BNM::Method< Ret >::Method ( const IL2CPP::Il2CppReflectionMethod< Ret > * reflectionMethod)
inline

Create method from il2cpp reflection method.

Parameters
infoIl2cpp reflection method

◆ Method() [4/4]

template<typename Ret>
BNM::Method< Ret >::Method ( const MethodBase & other)
inline

Convert base method to typed method.

Parameters
otherBase method

Member Function Documentation

◆ Call()

template<typename Ret>
template<typename ... Parameters>
Ret BNM::Method< Ret >::Call ( Parameters ... parameters) const
inline

Call method.

Parameters
parametersParameters of method
Returns
Result of method call if method is valid, otherwise default value.

◆ operator=()

template<typename Ret>
Method< Ret > & BNM::Method< Ret >::operator= ( const MethodBase & other)
inline

Convert base method to typed method.

Parameters
otherBase method

◆ operator[]() [1/3]

template<typename Ret>
Method< Ret > & BNM::Method< Ret >::operator[] ( IL2CPP::Il2CppObject * instance)
inline

Operator for setting instance.

Parameters
instanceInstance
Returns
Reference to current Method

◆ operator[]() [2/3]

template<typename Ret>
Method< Ret > & BNM::Method< Ret >::operator[] ( UnityEngine::Object * instance)
inline

Operator for setting instance.

Parameters
instanceInstance
Returns
Reference to current Method

◆ operator[]() [3/3]

template<typename Ret>
Method< Ret > & BNM::Method< Ret >::operator[] ( void * instance)
inline

Operator for setting instance.

Parameters
instanceInstance
Returns
Reference to current Method