Example #1
0
        public string GetSystemTypeName(bool addComment = false)
        {
            if (type.Pointee is CppSharp.AST.FunctionType)
            {
                return(TypeWrapperFactory.CreateTypeWrapper(type.Pointee).GetSystemTypeName());
            }
            else if (type.Pointee is CppSharp.AST.BuiltinType)
            {
                CppSharp.AST.BuiltinType buildin = type.Pointee as CppSharp.AST.BuiltinType;
                if (buildin.Type == CppSharp.AST.PrimitiveType.UInt8 ||
                    buildin.Type == CppSharp.AST.PrimitiveType.Int8 ||
                    buildin.Type == CppSharp.AST.PrimitiveType.Char ||
                    buildin.Type == CppSharp.AST.PrimitiveType.UChar)
                {
                    return("string");
                }
            }
            string pointeeTypeName = TypeWrapperFactory.CreateTypeWrapper(type.Pointee).GetSystemTypeName();
            string ret             = "IntPtr";

            if (addComment)
            {
                ret += "/* " + pointeeTypeName + "*  */";
            }
            return(ret);
        }
Example #2
0
        public string GetRawTypeName()
        {
            string functionTag = "";

            functionTag += TypeWrapperFactory.CreateTypeWrapper(type.ReturnType.Type).GetSystemTypeName();
            functionTag += "(";
            for (int i = 0; i < type.Parameters.Count; i++)
            {
                var param = type.Parameters[i];
                functionTag += TypeWrapperFactory.CreateTypeWrapper(param.Type).GetSystemTypeName();
                if (i != (type.Parameters.Count - 1))
                {
                    functionTag += ",";
                }
            }
            functionTag += ")";
            return(functionTag);
        }
Example #3
0
        public string GetMarshalTag()
        {
            if (type.Pointee is CppSharp.AST.FunctionType)
            {
                return(TypeWrapperFactory.CreateTypeWrapper(type.Pointee).GetMarshalTag());
            }

            else if (type.Pointee is CppSharp.AST.BuiltinType)
            {
                CppSharp.AST.BuiltinType buildin = type.Pointee as CppSharp.AST.BuiltinType;
                if (buildin.Type == CppSharp.AST.PrimitiveType.UInt8 ||
                    buildin.Type == CppSharp.AST.PrimitiveType.Int8 ||
                    buildin.Type == CppSharp.AST.PrimitiveType.Char ||
                    buildin.Type == CppSharp.AST.PrimitiveType.UChar)
                {
                    return("[MarshalAs(UnmanagedType.LPStr)]");
                }
            }

            return("");
        }
Example #4
0
        public string GetSystemTypeName(bool addComment = false)
        {
            string tag = GetRawTypeName();

            if (TypeWrapperFactory.DelegateGenerator.ContainsKey(tag))
            {
                return(TypeWrapperFactory.DelegateGenerator[tag].name);
            }
            else
            {
                DelegateDefine deleg = new DelegateDefine();
                deleg.tag  = tag;
                deleg.name = TypeWrapperFactory.CurrentPrefix + "_func_" + TypeWrapperFactory.DelegateGenerator.Count.ToString();
                //public delegate int GetBufferCallback(IntPtr pAVCodecContext, IntPtr pAVFrame);
                deleg.fullName  = "public delegate ";
                deleg.fullName += TypeWrapperFactory.CreateTypeWrapper(type.ReturnType.Type).GetSystemTypeName(true);
                deleg.fullName += " " + deleg.name + "(\r\n";
                for (int i = 0; i < type.Parameters.Count; i++)
                {
                    var param = type.Parameters[i];
                    deleg.fullName += "\t" + TypeWrapperFactory.CreateTypeWrapper(param.Type).GetMarshalTag();
                    deleg.fullName += TypeWrapperFactory.CreateTypeWrapper(param.Type).GetSystemTypeName(true);
                    if (!string.IsNullOrEmpty(param.Name))
                    {
                        deleg.fullName += " " + param.Name;
                    }
                    else
                    {
                        deleg.fullName += " __arg" + i.ToString();
                    }
                    if (i != (type.Parameters.Count - 1))
                    {
                        deleg.fullName += ", \r\n";
                    }
                }
                deleg.fullName += ");";
                TypeWrapperFactory.DelegateGenerator.Add(tag, deleg);
                return(deleg.name);
            }
        }
Example #5
0
 public static string GetMarshalTag(CppSharp.AST.Type type)
 {
     return(TypeWrapperFactory.CreateTypeWrapper(type).GetMarshalTag());
 }
Example #6
0
 public static string GetSystemTypeName(CppSharp.AST.Type type, bool addComment = false)
 {
     return(TypeWrapperFactory.CreateTypeWrapper(type).GetSystemTypeName(addComment));
 }
Example #7
0
 public static string GetRawTypeName(CppSharp.AST.Type type)
 {
     return(TypeWrapperFactory.CreateTypeWrapper(type).GetRawTypeName());
 }
Example #8
0
        public string GetRawTypeName()
        {
            string typeName = TypeWrapperFactory.CreateTypeWrapper(type.Type).GetRawTypeName();

            return(typeName);
        }
Example #9
0
 public string GetMarshalTag()
 {
     return(TypeWrapperFactory.CreateTypeWrapper(type.Declaration.Type).GetMarshalTag());
 }
Example #10
0
 public string GetSystemTypeName(bool addComment = false)
 {
     return(TypeWrapperFactory.CreateTypeWrapper(type.Declaration.Type).GetSystemTypeName());
 }
Example #11
0
 public string GetRawTypeName()
 {
     return(TypeWrapperFactory.CreateTypeWrapper(type.Declaration.Type).GetRawTypeName());
 }