public IntPtrTypeMap(TypedefNameDecl td, BindingContext ctx, TypeMapDatabase dataBase) { Type = td.Type; Context = ctx; TypeMapDatabase = dataBase; InjectedType = new CILType(typeof(IntPtr)); }
public bool VisitTypedefNameDecl(TypedefNameDecl typedef) { if (!VisitDeclaration(typedef)) { return(false); } return(typedef.Type.Visit(this, typedef.QualifiedType.Qualifiers)); }
public static bool IsCannonicalHandleTypeDef(this TypedefNameDecl td) { // Canonical form, declaration is a pointer to an opaque struct if (!(td.Type is PointerType pt)) { return(false); } return((pt.Pointee is TagType tt && tt.IsOpaqueStruct( )) || (pt.Pointee is BuiltinType bt && bt.Type == PrimitiveType.Void)); }
public HandleRefTypeMap(TypedefNameDecl td, BindingContext ctx, TypeMapDatabase dataBase) { Context = ctx; Type = td.Type; TypeMapDatabase = dataBase; InjectedType = new TagType(new Class( ) { Name = td.Name, Namespace = td.Namespace }); }
public static bool TryGetFunctionSignature(this TypedefNameDecl td, out FunctionType signature) { signature = null; if (td.Type is PointerType pt && pt.Pointee is FunctionType sig) { signature = sig; return(true); } return(false); }
public static bool TryGetHandleDecl(this CppSharp.AST.Type astType, out TypedefNameDecl decl) { switch (astType) { case TypedefType tdt when(tdt.Declaration.IsHandleTypeDef()): decl = tdt.Declaration; return(true); case PointerType pt when(pt.Pointee is TypedefType tdt && tdt.Declaration.IsHandleTypeDef()): decl = tdt.Declaration; return(true); default: decl = null; return(false); } }
public ParsedFunctionSignature(TypedefNameDecl td) { if (td.TryGetFunctionSignature(out FunctionType signature)) { if (signature.CallingConvention != CppSharp.AST.CallingConvention.C) { throw new NotSupportedException("Only delegates with the 'C' Calling convention are supported"); } Signature = signature; Comments = new ParsedComment(td); Name = td.Name; Attributes = new[] { UnmanagedFunctionPointerAttrib }; Introducer = "public delegate "; } else { throw new ArgumentException("pointer to function type required"); } }
public bool GenerateTypedef(TypedefNameDecl typedef) { if (!typedef.IsGenerated) { return(false); } FunctionType function; if (typedef.Type.IsPointerTo(out function)) { PushBlock(CLIBlockKind.Typedef, typedef); GenerateDeclarationCommon(typedef); var insideClass = typedef.Namespace is Class; var attributedType = typedef.Type.GetPointee() as AttributedType; if (attributedType != null) { var equivalentFunctionType = attributedType.Equivalent.Type as FunctionType; var callingConvention = equivalentFunctionType.CallingConvention.ToInteropCallConv(); if (callingConvention != System.Runtime.InteropServices.CallingConvention.Winapi) { WriteLine("[{0}({1}::{2})] ", "System::Runtime::InteropServices::UnmanagedFunctionPointer", "System::Runtime::InteropServices::CallingConvention", callingConvention); } } WriteLine("{0}{1};", !insideClass ? "public " : "", string.Format(TypePrinter.VisitDelegate(function), typedef.Name)); PopBlock(NewLineKind.BeforeNextBlock); return(true); } return(false); }
public bool GenerateTypedef(TypedefNameDecl typedef) { if (!typedef.IsGenerated) { return(false); } var functionType = typedef.Type as FunctionType; if (functionType != null || typedef.Type.IsPointerTo(out functionType)) { PushBlock(BlockKind.Typedef, typedef); GenerateDeclarationCommon(typedef); var insideClass = typedef.Namespace is Class; var attributedType = typedef.Type.GetPointee().Desugar(); var callingConvention = attributedType == null && functionType != null ? functionType.CallingConvention : ((FunctionType)attributedType).CallingConvention; var interopCallConv = callingConvention.ToInteropCallConv(); if (interopCallConv != System.Runtime.InteropServices.CallingConvention.Winapi) { WriteLine("[System::Runtime::InteropServices::UnmanagedFunctionPointer" + "(System::Runtime::InteropServices::CallingConvention::{0})] ", interopCallConv); } var visibility = !insideClass ? "public " : string.Empty; var result = CTypePrinter.VisitDelegate(functionType); result.Name = typedef.Name; WriteLine($"{visibility}{result};"); PopBlock(NewLineKind.BeforeNextBlock); return(true); } return(false); }
public override bool VisitTypedefNameDecl(TypedefNameDecl typedef) { if (!typedef.IsGenerated) { return(false); } var functionType = typedef.Type as FunctionType; if (functionType != null || typedef.Type.IsPointerTo(out functionType)) { PushBlock(BlockKind.Typedef, typedef); GenerateDeclarationCommon(typedef); var @delegate = string.Format(CTypePrinter.VisitDelegate(functionType), typedef.Name); WriteLine($"{@delegate};"); PopBlock(NewLineKind.BeforeNextBlock); return(true); } return(false); }
private TypedefNameDecl(TypedefNameDecl.__Internal native, bool skipVTables = false) : this(__CopyValue(native), skipVTables) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
private static void* __CopyValue(TypedefNameDecl.__Internal native) { var ret = Marshal.AllocHGlobal(136); global::CppSharp.Parser.AST.TypedefNameDecl.__Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); }
public static TypedefNameDecl __CreateInstance(TypedefNameDecl.__Internal native, bool skipVTables = false) { return new TypedefNameDecl(native, skipVTables); }
public static FunctionType GetFunctionPointerType(this TypedefNameDecl td) { return((td.Type is PointerType pt && pt.Pointee is FunctionType ft) ? ft : null); }
public override TypePrinterResult VisitTypedefNameDecl(TypedefNameDecl typedef) { return(VisitDeclaration(typedef)); }
public override bool VisitTypedefNameDecl(TypedefNameDecl typedef) { return(true); }
public static bool IsDelegateTypeDef(this TypedefNameDecl td) { return(td.TryGetFunctionSignature(out _)); }
public static bool IsOpaquHandleTypeDef(this TypedefNameDecl td) { // bad form, declaration is the opaque struct, not a pointer to the struct return(td.Type is TagType tt2 && tt2.IsOpaqueStruct()); }
public static bool IsHandleTypeDef(this TypedefNameDecl td) { return(IsCannonicalHandleTypeDef(td) || IsOpaquHandleTypeDef(td)); }
public virtual bool VisitTypedefNameDecl(TypedefNameDecl typedef) { return(typedef.Type.Visit(this, typedef.QualifiedType.Qualifiers)); }
public virtual bool VisitTypedefNameDecl(TypedefNameDecl typedef) { throw new NotImplementedException(); }
public TypePrinterResult VisitTypedefNameDecl(TypedefNameDecl typedef) { throw new NotImplementedException(); }