예제 #1
0
파일: Types.cs 프로젝트: ddobrev/CppSharp
        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);
        }
예제 #2
0
파일: AST.cs 프로젝트: KonajuGames/CppSharp
 private TypedefType(TypedefType.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
 }
예제 #3
0
파일: AST.cs 프로젝트: vovkasm/CppSharp
 internal TypedefType(TypedefType.Internal native)
     : this(__CopyValue(native))
 {
 }
예제 #4
0
 public string VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
 {
     return(GetDeclName(typedef.Declaration));
 }
예제 #5
0
파일: AST.cs 프로젝트: RainsSoft/CppSharp
 private TypedefType(TypedefType.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
예제 #6
0
파일: AST.cs 프로젝트: RainsSoft/CppSharp
 public static TypedefType __CreateInstance(TypedefType.Internal native)
 {
     return new TypedefType(native);
 }
예제 #7
0
파일: AST.cs 프로젝트: CSRedRat/CppSharp
 private TypedefType(TypedefType.Internal native, bool skipVTables = false)
     : this(__CopyValue(native), skipVTables)
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
예제 #8
0
 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();
 }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
 public bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
 {
     return(false);
 }
예제 #12
0
 public virtual TypePrinterResult VisitTypedefType(TypedefType typedef,
                                                   TypeQualifiers quals)
 {
     throw new NotImplementedException();
 }
예제 #13
0
 public virtual bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
 {
     return(typedef.Declaration.Visit(this));
 }
예제 #14
0
파일: AST.cs 프로젝트: kidleon/CppSharp
 internal TypedefType(TypedefType.Internal* native)
     : this(new global::System.IntPtr(native))
 {
 }
예제 #15
0
        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);
        }
예제 #16
0
파일: AST.cs 프로젝트: kidleon/CppSharp
 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);
        }
예제 #18
0
파일: AST.cs 프로젝트: CSRedRat/CppSharp
 public static TypedefType __CreateInstance(TypedefType.Internal native, bool skipVTables = false)
 {
     return new TypedefType(native, skipVTables);
 }
예제 #19
0
        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);
        }
예제 #20
0
파일: AST.cs 프로젝트: CSRedRat/CppSharp
 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);
 }
예제 #21
0
        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);
        }
예제 #22
0
파일: AST.cs 프로젝트: RainsSoft/CppSharp
 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;
 }
예제 #24
0
파일: AST.cs 프로젝트: RainsSoft/CppSharp
 protected TypedefType(TypedefType.Internal* native, bool isInternalImpl = false)
     : base((CppSharp.Parser.AST.Type.Internal*) native)
 {
 }
예제 #25
0
 public bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
 {
     throw new NotImplementedException();
 }