CallingConventions 열거형

정의

메서드에 대한 유효한 호출 규칙을 정의합니다.

이 열거형은 멤버 값의 비트 조합을 지원합니다.

public enum class CallingConventions
[System.Flags]
public enum CallingConventions
[System.Flags]
[System.Serializable]
public enum CallingConventions
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum CallingConventions
[<System.Flags>]
type CallingConventions = 
[<System.Flags>]
[<System.Serializable>]
type CallingConventions = 
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CallingConventions = 
Public Enum CallingConventions
상속
CallingConventions
특성

필드

Any 3

Standard 또는 VarArgs 호출 규칙 중 사용할 수 있는 호출 규칙을 지정합니다.

ExplicitThis 64

시그니처를 인스턴스 또는 가상 메서드(정적 메서드 아님)에 대한 호출을 나타내는 함수 포인터 서명으로 지정합니다. ExplicitThis를 설정하면 HasThis도 설정해야 합니다. 호출된 메서드에 전달된 첫 번째 인수는 this 포인터지만 이 인수의 형식은 알 수 없습니다. 그러므로 this 포인터의 형식 또는 클래스를 설명하는 토큰은 명시적으로 메타데이터 시그니처에 저장됩니다.

HasThis 32

인스턴스 또는 가상 메서드(정적 메서드가 아님)를 지정합니다. 런타임에서, 호출된 메서드는 대상 개체를 가리키는 포인터에 첫 번째 인수(this 포인터)로 전달됩니다. 메서드를 알고 있고 메타데이터에서 소유자 클래스를 검색할 수 있으므로 메타데이터에 저장된 시그니처에는 이 첫 번째 인수의 형식이 포함되지 않습니다.

Standard 1

공용 언어 런타임에서 결정한 대로 기본 호출 규칙을 지정합니다. 정적 메서드에는 이 호출 규칙을 사용하고, 인스턴스나 가상 메서드에는 HasThis를 사용합니다.

VarArgs 2

가변 인수를 사용하여 메서드에 대한 호출 규칙을 지정합니다.

예제

using namespace System;
using namespace System::Reflection;
using namespace System::Security;
public ref class MyClass1
{
public:
   MyClass1( int i ){}

};

int main()
{
   try
   {
      Type^ myType = MyClass1::typeid;
      array<Type^>^types = gcnew array<Type^>(1);
      types[ 0 ] = int::typeid;
      
      // Get the public instance constructor that takes an integer parameter.
      ConstructorInfo^ constructorInfoObj = myType->GetConstructor( static_cast<BindingFlags>(BindingFlags::Instance | BindingFlags::Public), nullptr, CallingConventions::HasThis, types, nullptr );
      if ( constructorInfoObj != nullptr )
      {
         Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is: " );
         Console::WriteLine( constructorInfoObj );
      }
      else
      {
         Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is not available." );
      }
   }
   catch ( ArgumentNullException^ e ) 
   {
      Console::WriteLine( "ArgumentNullException: {0}", e->Message );
   }
   catch ( ArgumentException^ e ) 
   {
      Console::WriteLine( "ArgumentException: {0}", e->Message );
   }
   catch ( SecurityException^ e ) 
   {
      Console::WriteLine( "SecurityException: {0}", e->Message );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }
}
using System;
using System.Reflection;
using System.Security;

public class MyClass1
{
    public MyClass1(int i){}
    public static void Main()
    {
        try
        {
            Type  myType = typeof(MyClass1);
            Type[] types = new Type[1];
            types[0] = typeof(int);
            // Get the public instance constructor that takes an integer parameter.
            ConstructorInfo constructorInfoObj = myType.GetConstructor(
                BindingFlags.Instance | BindingFlags.Public, null,
                CallingConventions.HasThis, types, null);
            if(constructorInfoObj != null)
            {
                Console.WriteLine("The constructor of MyClass1 that is a public " +
                    "instance method and takes an integer as a parameter is: ");
                Console.WriteLine(constructorInfoObj.ToString());
            }
            else
            {
                Console.WriteLine("The constructor of MyClass1 that is a public instance " +
                    "method and takes an integer as a parameter is not available.");
            }
        }
        catch(ArgumentNullException e)
        {
            Console.WriteLine("ArgumentNullException: " + e.Message);
        }
        catch(ArgumentException e)
        {
            Console.WriteLine("ArgumentException: " + e.Message);
        }
        catch(SecurityException e)
        {
            Console.WriteLine("SecurityException: " + e.Message);
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception: " + e.Message);
        }
    }
}
Public Class MyClass1
    Public Sub New(ByVal i As Integer)
    End Sub
    Public Shared Sub Main()
        Try
            Dim myType As Type = GetType(MyClass1)
            Dim types(0) As Type
            types(0) = GetType(Integer)
            ' Get the public instance constructor that takes an integer parameter.
            Dim constructorInfoObj As ConstructorInfo = _
                        myType.GetConstructor(BindingFlags.Instance Or _
                        BindingFlags.Public, Nothing, _
                        CallingConventions.HasThis, types, Nothing)
            If Not (constructorInfoObj Is Nothing) Then
                Console.WriteLine("The constructor of MyClass1 that " + _
                                  "is a public instance method and takes an " + _
                                  "integer as a parameter is: ")
                Console.WriteLine(constructorInfoObj.ToString())
            Else
                Console.WriteLine("The constructor MyClass1 that " + _
                                  "is a public instance method and takes an " + _
                                  "integer as a parameter is not available.")
            End If
        Catch e As ArgumentNullException
            Console.WriteLine("ArgumentNullException: " + e.Message)
        Catch e As ArgumentException
            Console.WriteLine("ArgumentException: " + e.Message)
        Catch e As SecurityException
            Console.WriteLine("SecurityException: " + e.Message)
        Catch e As Exception
            Console.WriteLine("Exception: " + e.Message)
        End Try
    End Sub
End Class

설명

네이티브 호출 규칙은 컴파일된 메서드에 전달되는 인수의 순서 및 레이아웃을 제어하는 규칙 집합입니다. 또한 반환 값을 전달하는 방법, 인수에 사용할 레지스터 및 호출된 메서드 또는 호출 메서드가 스택에서 인수를 제거하는지 여부를 제어합니다.

적용 대상