public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { TypeMap typeMap; if (TypeMapDatabase.FindTypeMap(typedef, out typeMap) && typeMap.IsIgnored) { Ignore(); return false; } return base.VisitTypedefType(typedef, quals); }
private TypedefType(TypedefType.Internal native) : this(__CopyValue(native)) { __ownsNativeInstance = true; }
internal TypedefType(TypedefType.Internal native) : this(__CopyValue(native)) { }
public string VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { return(GetDeclName(typedef.Declaration)); }
private TypedefType(TypedefType.Internal native) : this(__CopyValue(native)) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
public static TypedefType __CreateInstance(TypedefType.Internal native) { return new TypedefType(native); }
private TypedefType(TypedefType.Internal native, bool skipVTables = false) : this(__CopyValue(native), skipVTables) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
private static void* __CopyValue(TypedefType.__Internal native) { var ret = Marshal.AllocHGlobal(12); global::CppSharp.Parser.AST.TypedefType.__Internal.cctor_2(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); }
public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { var decl = typedef.Declaration; TypeMap typeMap; if (Context.Driver.TypeDatabase.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling) { typeMap.CLIMarshalToNative(Context); return typeMap.IsValueType; } FunctionType func; if (decl.Type.IsPointerTo(out func)) { VisitDelegateType(func, "::" + typedef.Declaration.QualifiedOriginalName); return true; } PrimitiveType primitive; if (decl.Type.IsPrimitiveType(out primitive)) { Context.Return.Write("(::{0})", typedef.Declaration.QualifiedOriginalName); } return decl.Type.Visit(this); }
public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { var decl = typedef.Declaration; TypeMap typeMap; if (Context.Driver.TypeDatabase.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling) { typeMap.CLIMarshalToNative(Context); return typeMap.IsValueType; } FunctionType func; if (decl.Type.IsPointerTo(out func)) { // Use the original typedef name if available, otherwise just use the function pointer type string cppTypeName; if (!decl.IsSynthetized) cppTypeName = "::" + typedef.Declaration.QualifiedOriginalName; else { var cppTypePrinter = new CppTypePrinter(Context.Driver.TypeDatabase); cppTypeName = decl.Type.Visit(cppTypePrinter, quals); } VisitDelegateType(func, cppTypeName); return true; } PrimitiveType primitive; if (decl.Type.IsPrimitiveType(out primitive)) { Context.Return.Write("(::{0})", typedef.Declaration.QualifiedOriginalName); } return decl.Type.Visit(this); }
public bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { return(false); }
public virtual TypePrinterResult VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { throw new NotImplementedException(); }
public virtual bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { return(typedef.Declaration.Visit(this)); }
internal TypedefType(TypedefType.Internal* native) : this(new global::System.IntPtr(native)) { }
public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { var decl = typedef.Declaration; TypeMap typeMap; if (Context.Driver.TypeDatabase.FindTypeMap(decl, out typeMap) && typeMap.DoesMarshalling) { typeMap.Type = typedef; typeMap.CLIMarshalToManaged(Context); return typeMap.IsValueType; } FunctionType function; if (decl.Type.IsPointerTo(out function)) { Context.Return.Write("safe_cast<{0}>(", typedef); Context.Return.Write("System::Runtime::InteropServices::Marshal::"); Context.Return.Write("GetDelegateForFunctionPointer("); Context.Return.Write("IntPtr({0}), {1}::typeid))",Context.ReturnVarName, typedef.ToString().TrimEnd('^')); return true; } return decl.Type.Visit(this); }
internal TypedefType(TypedefType.Internal native) : this(&native) { }
/// <summary> /// Generates a new typedef for the given type if necessary and returns the new type. /// </summary> /// <param name="namespace">The namespace the typedef will be added to.</param> /// <param name="type">The type to check.</param> /// <returns>The new type.</returns> private QualifiedType CheckType(DeclarationContext @namespace, QualifiedType type) { if (type.Type.IsDependent) return type; var pointerType = type.Type as PointerType; if (pointerType == null) return type; var functionType = pointerType.Pointee as FunctionType; if (functionType == null) return type; List<Typedef> typedefs; if (!allTypedefs.TryGetValue(@namespace.QualifiedName, out typedefs)) { typedefs = new List<Typedef>(); allTypedefs.Add(@namespace.QualifiedName, typedefs); } var typedef = FindMatchingTypedef(typedefs, functionType); if (typedef == null) { for (int i = 0; i < functionType.Parameters.Count; i++) { functionType.Parameters[i].Name = string.Format("_{0}", i); } typedef = new TypedefDecl { Access = AccessSpecifier.Public, Name = string.Format("__AnonymousDelegate{0}", typedefs.Count), Namespace = @namespace, QualifiedType = type, IsSynthetized = true }; typedefs.Add(new Typedef { Context = @namespace, Declaration = typedef }); } var typedefType = new TypedefType { Declaration = typedef }; return new QualifiedType(typedefType); }
public static TypedefType __CreateInstance(TypedefType.Internal native, bool skipVTables = false) { return new TypedefType(native, skipVTables); }
public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { if (!VisitType(typedef, quals)) return false; var decl = typedef.Declaration; FunctionType func; if (decl.Type.IsPointerTo<FunctionType>(out func)) { VisitDelegateType(func, typedef.Declaration.OriginalName); return true; } return decl.Type.Visit(this); }
protected TypedefType(TypedefType.Internal* native, bool skipVTables = false) : base((CppSharp.Parser.AST.Type.Internal*) null) { __PointerAdjustment = 0; if (native == null) return; __Instance = new global::System.IntPtr(native); }
public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { if (!VisitType(typedef, quals)) return false; var decl = typedef.Declaration; FunctionType function; if (decl.Type.IsPointerTo(out function)) { var ptrName = Generator.GeneratedIdentifier("ptr") + Context.ParameterIndex; Context.SupportBefore.WriteLine("var {0} = {1};", ptrName, Context.ReturnVarName); Context.Return.Write("({1})Marshal.GetDelegateForFunctionPointer({0}, typeof({1}))", ptrName, typedef.ToString()); return true; } return decl.Type.Visit(this); }
private static TypedefType.Internal* __CopyValue(TypedefType.Internal native) { var ret = Marshal.AllocHGlobal(16); CppSharp.Parser.AST.TypedefType.Internal.cctor_2(ret, new global::System.IntPtr(&native)); return (TypedefType.Internal*) ret; }
protected AST.Type GetType(string typeName) { if (typeCache == null) typeCache = new Dictionary<string, AST.Type>(); AST.Type result; if (!typeCache.TryGetValue(typeName, out result)) { var typeDef = Driver.ASTContext.FindTypedef(typeName) .FirstOrDefault(); if (typeDef != null) result = new TypedefType() { Declaration = typeDef }; typeCache.Add(typeName, result); } return result; }
protected TypedefType(TypedefType.Internal* native, bool isInternalImpl = false) : base((CppSharp.Parser.AST.Type.Internal*) native) { }
public bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals) { throw new NotImplementedException(); }