Search Results for

    Show / Hide Table of Contents

    Class MMethod

    Encapsulates information about a single Mono (managed) method belonging to some managed class. This object also allows you to invoke the method.

    Inheritance
    MMethod
    Assembly: FlaxEngine.dll
    File: Engine/Scripting/ManagedCLR/MMethod.h
    Syntax
    public class MMethod

    Constructors

    MMethod(MClass* parentClass, StringAnsi&& name, void* handle, int32 paramsCount, MMethodAttributes attributes)

    Declaration
    public MMethod(MClass* parentClass, StringAnsi&& name, void* handle, int32 paramsCount, MMethodAttributes attributes)
    Parameters
    MClass parentClass

    StringAnsi name

    void handle

    int32 paramsCount

    MMethodAttributes attributes

    Fields

    _attributes

    Declaration
    protected Array<MObject* > _attributes
    Field Value
    Array<MObject >

    _cachedThunk

    Declaration
    protected void* _cachedThunk = nullptr
    Field Value
    void

    _handle

    Declaration
    protected void* _handle
    Field Value
    void

    _hasCachedAttributes

    Declaration
    protected int32 _hasCachedAttributes
    Field Value
    int32

    _hasCachedSignature

    Declaration
    protected int32 _hasCachedSignature
    Field Value
    int32

    _isStatic

    Declaration
    protected int32 _isStatic
    Field Value
    int32

    _name

    Declaration
    protected StringAnsi _name
    Field Value
    StringAnsi

    _parameterTypes

    Declaration
    protected Array<void* , InlinedAllocation<8>> _parameterTypes
    Field Value
    Array<void , InlinedAllocation<8>>

    _paramsCount

    Declaration
    protected int32 _paramsCount
    Field Value
    int32

    _parentClass

    Declaration
    protected MClass* _parentClass
    Field Value
    MClass

    _returnType

    Declaration
    protected void* _returnType
    Field Value
    void

    _visibility

    Declaration
    protected MVisibility _visibility
    Field Value
    MVisibility

    ProfilerData

    Declaration
    public SourceLocationData ProfilerData
    Field Value
    SourceLocationData

    ProfilerName

    Declaration
    public StringAnsi ProfilerName
    Field Value
    StringAnsi

    Methods

    CacheSignature()

    Declaration
    protected void CacheSignature() const

    GetAttribute(const MClass* klass)

    Returns an instance of an attribute of the specified type. Returns null if the method doesn't have such an attribute.

    Declaration
    public MObject* GetAttribute(const MClass* klass) const
    Parameters
    MClass klass

    The attribute Class to take.

    Returns
    MObject

    The attribute object.

    GetAttributes()

    Returns an instance of all attributes connected with given method. Returns null if the method doesn't have any attributes.

    Declaration
    public Array<MObject* > GetAttributes() const
    Returns
    Array<MObject >

    The array of attribute objects.

    GetName()

    Gets the method name.

    Declaration
    public StringAnsi GetName() const
    Returns
    StringAnsi

    GetParameterIsOut(int32 paramIdx)

    Returns the value indicating whenever the method parameter at the specified index is marked as output parameter.

    Declaration
    public bool GetParameterIsOut(int32 paramIdx) const
    Parameters
    int32 paramIdx

    The parameter type.

    Returns
    bool

    True if parameter is marked as output, otherwise false.

    GetParametersCount()

    Returns the number of parameters the method expects.

    Declaration
    public int32 GetParametersCount() const
    Returns
    int32

    GetParameterType(int32 paramIdx)

    Returns the type of the method parameter at the specified index.

    Declaration
    public MType* GetParameterType(int32 paramIdx) const
    Parameters
    int32 paramIdx

    The parameter type.

    Returns
    MType

    The parameter type.

    GetParentClass()

    Returns the parent class that this method is contained with.

    Declaration
    public MClass* GetParentClass() const
    Returns
    MClass

    GetReturnType()

    Returns the type of the return value. Returns null if method has no return value.

    Declaration
    public MType* GetReturnType() const
    Returns
    MType

    GetThunk()

    Gets a thunk for this method. A thunk is a C++ like function pointer that you can use for calling the method.

    This is the fastest way of calling managed code. Get thunk from class if you want to call static method. You need to call it from method of a instance wrapper to call a specific instance. Thunks return boxed value but for some smaller types (eg. bool, int, float) the return is inlined into pointer.

    Declaration
    public void* GetThunk()
    Returns
    void

    The method thunk pointer.

    GetVisibility()

    Gets method visibility in the class.

    Declaration
    public MVisibility GetVisibility() const
    Returns
    MVisibility

    HasAttribute()

    Checks if method has an attribute of any type.

    Declaration
    public bool HasAttribute() const
    Returns
    bool

    True if has any custom attribute, otherwise false.

    HasAttribute(const MClass* klass)

    Checks if method has an attribute of the specified type.

    Declaration
    public bool HasAttribute(const MClass* klass) const
    Parameters
    MClass klass

    The attribute class to check.

    Returns
    bool

    True if has attribute of that class type, otherwise false.

    InflateGeneric()

    Creates a method that is inflated out of generic method.

    Declaration
    public MMethod* InflateGeneric() const
    Returns
    MMethod

    The inflated generic method.

    Invoke(void* instance, void* *params, MObject* *exception)

    Invokes the method on the provided object instance. This does not respect polymorphism and will invoke the exact method of the class this object was retrieved from.Use invokeVirtual() if you need polymorphism.

    This method is slow! Use it ONLY if you will call it only once for whole application life cycle, or you don't have 64 bytes of memory available.

    Declaration
    public MObject* Invoke(void* instance, void* *params, MObject* *exception) const
    Parameters
    void instance

    Instance of the object to invoke the method on. Can be null for static methods.

    void params

    Array of parameters to pass to the method. Caller must ensure they match method parameter count and type.For value types parameters should be pointers to the values and for reference types they should be pointers to MObject.

    MObject exception

    An optional pointer to the exception value to store exception object reference.

    Returns
    MObject

    A boxed return value, or null if method has no return value.

    InvokeVirtual(MObject* instance, void* *params, MObject* *exception)

    Invokes the method on the provided object instance. If the instance has an override of this method it will be called.

    This method is slow! Use it ONLY if you will call it only once for whole application life cycle, or you don't have 64 bytes of memory available.

    Declaration
    public MObject* InvokeVirtual(MObject* instance, void* *params, MObject* *exception) const
    Parameters
    MObject instance

    Instance of the object to invoke the method on.

    void params

    Array of parameters to pass to the method. Caller must ensure they match method parameter count and type. For value types parameters should be pointers to the values and for reference types they should be pointers to MObject.

    MObject exception

    An optional pointer to the exception value to store exception object reference.

    Returns
    MObject

    A boxed return value, or null if method has no return value.

    IsStatic()

    Returns true if the method doesn't require a class instance.

    Declaration
    public bool IsStatic() const
    Returns
    bool

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat