TypeBuilder.MakePointerType メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TypeBuilder.MakePointerType メソッドの意味・解説 

TypeBuilder.MakePointerType メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

現在の型へのアンマネージ ポインタの型を表す Type オブジェクト返します

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overrides Function
 MakePointerType As Type
Dim instance As TypeBuilder
Dim returnValue As Type

returnValue = instance.MakePointerType
public override Type MakePointerType ()
public:
virtual Type^ MakePointerType () override
public Type MakePointerType ()

戻り値
現在の型へのアンマネージ ポインタの型を表す Type オブジェクト

解説解説

MakePointerType メソッドは、パラメータ リストポインタ型生成する手段提供します

メモメモ

MSIL (Microsoft Intermediate Language ) の構文で、現在の TypeBuilder が MyType表している場合、このメソッドによって返される型は MyType* です。

使用例使用例

動的モジュールSample という名前の抽象型、および TestMethod という名前の抽象メソッド作成するコード例次に示しますTestMethod は、Sample 型の ref パラメータ (Visual Basic では ByRef)、Sample 型のポインタSample 型の配列使用します。このメソッドは、Sample 型の 2 次元配列返します。このコード例では、MSIL 逆アセンブラ (Ildasm.exe) を使用してチェックできるように、動的モジュールディスク保存します

Imports System
Imports System.Reflection
Imports System.Reflection.Emit
Imports Microsoft.VisualBasic

Public Class Example
    Public Shared Sub Main()
        ' Define a dynamic assembly to contain the sample type. The
        ' assembly will not be run, but only saved to disk, so
        ' AssemblyBuilderAccess.Save is specified.
        '
        Dim myDomain As AppDomain = AppDomain.CurrentDomain
        Dim myAsmName As New
 AssemblyName("MakeXxxTypeExample")
        Dim myAssembly As AssemblyBuilder =
 myDomain.DefineDynamicAssembly( _
            myAsmName, _
            AssemblyBuilderAccess.Save)

        ' An assembly is made up of executable modules. For a single-
        ' module assembly, the module name and file name are the same
 
        ' as the assembly name. 
        '
        Dim myModule As ModuleBuilder = myAssembly.DefineDynamicModule(
 _
            myAsmName.Name, _
            myAsmName.Name & ".dll")

        ' Define the sample type.
        Dim myType As TypeBuilder = myModule.DefineType(
 _
            "Sample", _
            TypeAttributes.Public Or TypeAttributes.Abstract)

        ' Define a method that takes a ByRef argument of type Sample
,
        ' a pointer to type Sample, and an array of Sample objects.
 The
        ' method returns a two-dimensional array of Sample objects.
        '
        ' To create this method, you need Type objects that represent
 the
        ' parameter types and the return type. Use the MakeByRefType,
 
        ' MakePointerType, and MakeArrayType methods to create the Type
        ' objects.
        '
        Dim byRefMyType As Type = myType.MakeByRefType
        Dim pointerMyType As Type = myType.MakePointerType
        Dim arrayMyType As Type = myType.MakeArrayType
        Dim twoDimArrayMyType As Type = myType.MakeArrayType(2)

        ' Create the array of parameter types.
        Dim parameterTypes() As Type = _
            {byRefMyType, pointerMyType, arrayMyType}

        ' Define the abstract Test method. After you have compiled
        ' and run this code example code, you can use ildasm.exe 
        ' to open MakeXxxTypeExample.dll, examine the Sample type,
        ' and verify the parameter types and return type of the
        ' TestMethod method.
        '
        Dim myMethodBuilder As MethodBuilder
 = myType.DefineMethod( _
            "TestMethod", _
            MethodAttributes.Abstract Or MethodAttributes.Virtual
 _
                Or MethodAttributes.Public, _
            twoDimArrayMyType, _
            parameterTypes)

        ' Create the type and save the assembly. For a single-file 
        ' assembly, there is only one module to store the manifest 
        ' information in.
        '
        myType.CreateType()
        myAssembly.Save(myAsmName.Name & ".dll")

    End Sub
End Class
using System;
using System.Reflection;
using System.Reflection.Emit;
using Microsoft.VisualBasic;

public class Example
{
    public static void Main()
    {
        // Define a dynamic assembly to contain the sample type. The
        // assembly will not be run, but only saved to disk, so
        // AssemblyBuilderAccess.Save is specified.
        //
        AppDomain myDomain = AppDomain.CurrentDomain;
        AssemblyName myAsmName = new AssemblyName("MakeXxxTypeExample");
        AssemblyBuilder myAssembly = myDomain.DefineDynamicAssembly(
            myAsmName, 
            AssemblyBuilderAccess.Save);

        // An assembly is made up of executable modules. For a single-
        // module assembly, the module name and file name are the same
 
        // as the assembly name. 
        //
        ModuleBuilder myModule = myAssembly.DefineDynamicModule(
            myAsmName.Name, 
            myAsmName.Name + ".dll");

        // Define the sample type.
        TypeBuilder myType = myModule.DefineType(
            "Sample", 
            TypeAttributes.Public | TypeAttributes.Abstract);

        // Define a method that takes a ref argument of type Sample
,
        // a pointer to type Sample, and an array of Sample objects.
 The
        // method returns a two-dimensional array of Sample objects.
        //
        // To create this method, you need Type objects that represent
 the
        // parameter types and the return type. Use the MakeByRefType,
 
        // MakePointerType, and MakeArrayType methods to create the
 Type
        // objects.
        //
        Type byRefMyType = myType.MakeByRefType();
        Type pointerMyType = myType.MakePointerType();
        Type arrayMyType = myType.MakeArrayType();
        Type twoDimArrayMyType = myType.MakeArrayType(2);

        // Create the array of parameter types.
        Type[] parameterTypes = {byRefMyType, pointerMyType, arrayMyType};

        // Define the abstract Test method. After you have compiled
        // and run this code example code, you can use ildasm.exe 
        // to open MakeXxxTypeExample.dll, examine the Sample type,
        // and verify the parameter types and return type of the
        // TestMethod method.
        //
        MethodBuilder myMethodBuilder = myType.DefineMethod(
            "TestMethod", 
            MethodAttributes.Abstract | MethodAttributes.Virtual 
                | MethodAttributes.Public,
            twoDimArrayMyType,
            parameterTypes);

        // Create the type and save the assembly. For a single-file
 
        // assembly, there is only one module to store the manifest
 
        // information in.
        //
        myType.CreateType();
        myAssembly.Save(myAsmName.Name + ".dll");
    }
}
import System.*;
import System.Reflection.*;
import System.Reflection.Emit.*;
import Microsoft.VisualBasic.*;

public class Example
{
    public static void main(String[]
 args)
    {
        // Define a dynamic assembly to contain the sample type. The
        // assembly will not be run, but only saved to disk, so
        // AssemblyBuilderAccess.Save is specified.
        //
        AppDomain myDomain = AppDomain.get_CurrentDomain();
        AssemblyName myAsmName = new AssemblyName("MakeXxxTypeExample");
        AssemblyBuilder myAssembly = myDomain.DefineDynamicAssembly(myAsmName, 
            AssemblyBuilderAccess.Save);
        // An assembly is made up of executable modules. For a single-
        // module assembly, the module name and file name are the same
 
        // as the assembly name. 
        //
        ModuleBuilder myModule = myAssembly.DefineDynamicModule(
            myAsmName.get_Name(), myAsmName.get_Name() + ".dll");
        // Define the sample type.
        TypeBuilder myType = myModule.DefineType("Sample", TypeAttributes.Public
 
            | TypeAttributes.Abstract);
        // Define a method that takes a ref argument of type Sample
,
        // a pointer to type Sample, and an array of Sample objects.
 The
        // method returns a two-dimensional array of Sample objects.
        //
        // To create this method, you need Type objects that represent
 the
        // parameter types and the return type. Use the MakeByRefType,
 
        // MakePointerType, and MakeArrayType methods to create the
 Type
        // objects.
        //
        Type byRefMyType = myType.MakeByRefType();
        Type pointerMyType = myType.MakePointerType();
        Type arrayMyType = myType.MakeArrayType();
        Type twoDimArrayMyType = myType.MakeArrayType(2);
        // Create the array of parameter types.
        Type parameterTypes[] =  { byRefMyType, pointerMyType, arrayMyType };
        // Define the abstract Test method. After you have compiled
        // and run this code example code, you can use ildasm.exe 
        // to open MakeXxxTypeExample.dll, examine the Sample type,
        // and verify the parameter types and return type of the
        // TestMethod method.
        //
        MethodBuilder myMethodBuilder = myType.DefineMethod("TestMethod",
 
            MethodAttributes.Abstract | MethodAttributes.Virtual 
            | MethodAttributes.Public, twoDimArrayMyType, parameterTypes);
        // Create the type and save the assembly. For a single-file
 
        // assembly, there is only one module to store the manifest
 
        // information in.
        //
        myType.CreateType();
        myAssembly.Save((myAsmName.get_Name() + ".dll"));
    } //main
} //Example
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TypeBuilder クラス
TypeBuilder メンバ
System.Reflection.Emit 名前空間
MakeByRefType
MakeArrayType


このページでは「.NET Framework クラス ライブラリ リファレンス」からTypeBuilder.MakePointerType メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からTypeBuilder.MakePointerType メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からTypeBuilder.MakePointerType メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

TypeBuilder.MakePointerType メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TypeBuilder.MakePointerType メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS