Beispiel #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 ("");
        }
Beispiel #2
0
        public Arg(DataType type, CsharpGen cc)
        {
            _name = "amp";
            if(type.ContextId != null)
                _typeId = type.ContextId;
            else
                _typeId = type.Id;

            _id = type.Id;

            _cc = cc;
        }
Beispiel #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;
        }
Beispiel #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";
 }
Beispiel #5
0
 string OpenNamespaceCs(DataType t)
 {
     if(t.ContextId==null || t.isNamespace) return "";
     return OpenNsCsImpl(CC.Types[t.ContextId]);
 }
Beispiel #6
0
 string CloseNsCsImpl(DataType t)
 {
     if(t==null || t.ContextId==null || t.isClass) return "";
     return CloseNsCsImpl(CC.Types[t.ContextId]) + "}\n";
 }
Beispiel #7
0
 string cvt(DataType t)
 {
     return CC.Converter.CSPType(t);
 }
Beispiel #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;
        }
Beispiel #9
0
        public bool UseHandle(DataType type)
        {
            if(_dataTypeMap.ContainsKey(type.Namespace) || type.IsEnum)
                return false;

            return true;
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #12
0
 public void Add(DataType type)
 {
     type.Parent = this;
     if(type.TypeName == "void") _voidTypeId = type.Id;
     _types.Add(type.Id, type);
 }