예제 #1
0
        public void IncAddIterator(DefIterator t, IndentStringBuilder sb)
        {
            if (!t.IsNested)
            {
                this.AddPreDeclaration("ref class " + t.CLRName + ";");
            }

            CheckTypeForDependancy(t.IterationElementTypeMember.Type);

            if (t.IsMapIterator)
                CheckTypeForDependancy(t.IterationKeyTypeMember.Type);

            sb.AppendIndent(Producer.GetProtectionString(t.ProtectionType));
            if (t.IsNested) sb.Append(":");

            if (t.IsMapIterator)
                sb.Append(" INC_DECLARE_MAP_ITERATOR");
            else
                sb.Append(" INC_DECLARE_ITERATOR");

            if (t.TypeMembers[0].Type.ProtectionType == ProtectionType.Protected
                && !t.TypeMembers[0].Type.ParentClass.AllowVirtuals)
            {
                // the container type will not be declared,
                // declare an iterator without a constructor that takes a container class
                sb.Append("_NOCONSTRUCTOR");
            }

            if (t.IsMapIterator)
                sb.Append("( " + t.CLRName + ", " + t.FullNativeName + ", " + t.TypeMembers[0].Type.FullCLRName + ", " + t.IterationElementTypeMember.CLRTypeName + ", " + t.IterationElementTypeMember.NativeTypeName + ", " + t.IterationKeyTypeMember.CLRTypeName + ", " + t.IterationKeyTypeMember.NativeTypeName + " )\n");
            else
                sb.Append("( " + t.CLRName + ", " + t.FullNativeName + ", " + t.TypeMembers[0].Type.FullCLRName + ", " + t.IterationElementTypeMember.CLRTypeName + ", " + t.IterationElementTypeMember.NativeTypeName + " )\n");

            sb.AppendLine();
        }
예제 #2
0
        public void CppAddIterator(DefIterator t, IndentStringBuilder sb)
        {
            string prefix;
            if (!t.IsNested)
            {
                prefix = t.FullNativeName;
                prefix = prefix.Substring(0, prefix.LastIndexOf("::"));
            }
            else
            {
                prefix = t.ParentClass.FullNativeName;
            }

            if (prefix.Contains("::"))
                prefix = prefix.Substring(prefix.IndexOf("::") + 2) + "::";
            else
                prefix = "";

            if (t.IsMapIterator)
                sb.Append("CPP_DECLARE_MAP_ITERATOR");
            else
                sb.Append("CPP_DECLARE_ITERATOR");

            bool noConstructor = t.TypeMembers[0].Type.ProtectionType == ProtectionType.Protected
                && !t.TypeMembers[0].Type.ParentClass.AllowVirtuals;

            if (noConstructor)
            {
                // the container type will not be declared,
                // declare an iterator without a constructor that takes a container class
                sb.Append("_NOCONSTRUCTOR");
            }

            if (t.IsMapIterator)
                sb.Append("( " + prefix + ", " + t.CLRName + ", " + t.FullNativeName + ", " + t.TypeMembers[0].Type.FullCLRName + ", " + t.IterationElementTypeMember.CLRTypeName + ", " + t.IterationElementTypeMember.NativeTypeName + ", " + t.IterationKeyTypeMember.CLRTypeName + ", " + t.IterationKeyTypeMember.NativeTypeName);
            else
                sb.Append("( " + prefix + ", " + t.CLRName + ", " + t.FullNativeName + ", " + t.TypeMembers[0].Type.FullCLRName + ", " + t.IterationElementTypeMember.CLRTypeName + ", " + t.IterationElementTypeMember.NativeTypeName);

            if (!noConstructor)
            {
                if (t.IsConstIterator)
                    sb.Append(", const");
                else
                    sb.Append(", ");
            }

            sb.Append(" )\n");

            AddTypeDependancy(t.TypeMembers[0].Type);

            sb.AppendLine();
        }