コード例 #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
ファイル: CLIMarshal.cs プロジェクト: corefan/CppSharp
        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
ファイル: CLIMarshal.cs プロジェクト: KonajuGames/CppSharp
        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
ファイル: TypePrinter.cs プロジェクト: zanjs/CppSharp
 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
ファイル: CLIMarshal.cs プロジェクト: corefan/CppSharp
        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)
 {
 }
コード例 #17
0
        /// <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
ファイル: CSharpMarshal.cs プロジェクト: fangsunjian/CppSharp
        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
ファイル: CSharpMarshal.cs プロジェクト: fangsunjian/CppSharp
        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;
 }
コード例 #23
0
 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
ファイル: CodeGenerator.cs プロジェクト: sunyuan213/CppSharp
 public bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
 {
     throw new NotImplementedException();
 }