示例#1
0
        public Context(XmlTextReader reader, CsharpGen generator)
            : base(reader, generator)
        {
            GenStructors = false;
            if(Attr.Export)
                GenStructors = true;
            _typedef = null;

            switch(reader.Name)
            {
            case "Class":		type_ = "class"; break;
            case "Struct":		type_ = "struct"; break;
            case "Namespace":	type_ = "namespace"; break;
            case "Union":		type_ = "union"; break;
            default:			Console.WriteLine("cannot process context type \"" + reader.Name + "\""); break;
            }

            _bases = new List<string>();
            string baseList = reader["bases"];
            if(baseList != null && baseList.Length != 0)
            {
                string[] baseSplit = baseList.Split(new string[]{" "}, StringSplitOptions.RemoveEmptyEntries);
                foreach(string str in baseSplit)
                    _bases.Add(str);
            }

            functions_ = new List<Function>();
            contexts_ = new List<Context>();
            _enums = new List<Enumeration>();
            _fields = new List<Field>();

            if(Name == "Mathf")
                Console.Write ("");
        }
示例#2
0
文件: Arg.cs 项目: yuckify/cppsharp
        public Arg(DataType type, CsharpGen cc)
        {
            _name = "amp";
            if(type.ContextId != null)
                _typeId = type.ContextId;
            else
                _typeId = type.Id;

            _id = type.Id;

            _cc = cc;
        }
示例#3
0
        public string CPCRetCast(DataType arg, Attributes attr, string str)
        {
            if(arg == null)
                return str;

            string ret = "";
            if(!arg.isVoid)
                ret = "return ";

            if(arg.IsRClass)
                ret += "&";

            if(arg.IsEnum)
                ret += "(long long int)";

            if(arg.Namespace == "::std::string")
                ret += "mono_string_new(mono_domain_get(), " + str + ".c_str())";
            else if(arg.IsPVClass || (arg.IsPClass && !attr.NoDestructor))
                ret += "new " + arg.Namespace + "(" + (arg.isPointer ? "*" : "") + str + ")";
            else
                ret += str;

            return ret;
        }
示例#4
0
 string OpenNsCsImpl(DataType t)
 {
     if(t==null || t.ContextId==null || t.isClass) return "";
     return OpenNsCsImpl(CC.Types[t.ContextId]) + "namespace " + t.Name +"\n{\n";
 }
示例#5
0
 string OpenNamespaceCs(DataType t)
 {
     if(t.ContextId==null || t.isNamespace) return "";
     return OpenNsCsImpl(CC.Types[t.ContextId]);
 }
示例#6
0
 string CloseNsCsImpl(DataType t)
 {
     if(t==null || t.ContextId==null || t.isClass) return "";
     return CloseNsCsImpl(CC.Types[t.ContextId]) + "}\n";
 }
示例#7
0
 string cvt(DataType t)
 {
     return CC.Converter.CSPType(t);
 }
示例#8
0
        public string CPType(DataType type)
        {
            if(type.Namespace == "::std::string") return "MonoString *";
            if(type.IsEnum) return "long long int";
            if(type.IsPRVClass) return type.Namespace + " *";
            if(type.IsPRPod) return type.Namespace + " *";

            return type.Namespace;
        }
示例#9
0
        public bool UseHandle(DataType type)
        {
            if(_dataTypeMap.ContainsKey(type.Namespace) || type.IsEnum)
                return false;

            return true;
        }
示例#10
0
        public string CSPType(DataType type)
        {
            // if the input is a fundamental type convert it with the table
            if(_dataTypeMap.ContainsKey(type.Namespace))
                return _dataTypeMap[type.Namespace].CsType;

            return type.NamespaceCs;
        }
示例#11
0
        public string CSESType(DataType type)
        {
            if(type == null)
                return null;

            if(type.IsPRPod)
                return _dataTypeMap[type.Namespace].CsType + " *";

            // if the input is a fundamental type convert it with the table
            if(_dataTypeMap.ContainsKey(type.Namespace))
                return _dataTypeMap[type.Namespace].CsType;

            if(type.IsEnum)
                return "long";

            // this will trigger true for class "string"
            if(type.IsPRVClass)
                return "IntPtr";

            return type.Name;
        }
示例#12
0
 public void Add(DataType type)
 {
     type.Parent = this;
     if(type.TypeName == "void") _voidTypeId = type.Id;
     _types.Add(type.Id, type);
 }