Exemplo n.º 1
0
        public void IncAddType(DefType t, IndentStringBuilder sb)
        {
            if (t.HasAttribute<CustomIncClassDefinitionAttribute>())
            {
                string txt = t.GetAttribute<CustomIncClassDefinitionAttribute>().Text;
                sb.AppendLine(txt);
                return;
            }

            if (t is DefClass)
            {
                if (!t.HasAttribute<WrapTypeAttribute>())
                {
                    //Ignore
                }
                else
                {
                    switch (t.GetAttribute<WrapTypeAttribute>().WrapType)
                    {
                        case WrapTypes.NonOverridable:
                            new IncNonOverridableClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.Overridable:
                            new IncOverridableClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.NativeDirector:
                            new IncNativeDirectorClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.Interface:
                            new IncInterfaceClassProducer(this, t as DefClass, sb).Add();
                            new IncOverridableClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.Singleton:
                            new IncSingletonClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.ReadOnlyStruct:
                            new IncReadOnlyStructClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.ValueType:
                            new IncValueClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.NativePtrValueType:
                            new IncNativePtrValueClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.CLRHandle:
                            new IncCLRHandleClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.PlainWrapper:
                            new IncPlainWrapperClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.SharedPtr:
                            IncAddSharedPtrType(t, sb);
                            break;
                    }
                }
            }
            else if (t is DefEnum)
            {
                IncAddEnum(t as DefEnum, sb);
            }
            else if (t is DefTypeDef)
            {
                DefTypeDef explicitType;

                if (t.IsUnnamedSTLContainer)
                    explicitType = t as DefTypeDef;
                else
                    explicitType = (t.IsNested) ? t.ParentClass.FindType<DefTypeDef>(t.Name) : t.NameSpace.FindType<DefTypeDef>(t.Name);

                if (t.HasWrapType(WrapTypes.SharedPtr))
                {
                    IncAddSharedPtrType(t, sb);
                }
                else if (explicitType.IsSTLContainer)
                {
                    IncAddSTLContainer(explicitType, sb);
                }
                else if (explicitType is DefIterator)
                {
                    IncAddIterator(explicitType as DefIterator, sb);
                }
                else if (explicitType.BaseType is DefInternal)
                {
                    IncAddInternalTypeDef(explicitType, sb);
                }
                else if (explicitType.BaseType.HasAttribute<ValueTypeAttribute>())
                {
                    IncAddValueTypeTypeDef(explicitType, sb);
                }
            }
        }
Exemplo n.º 2
0
        public void CppAddType(DefType t, IndentStringBuilder sb)
        {
            if (t.HasAttribute<CustomCppClassDefinitionAttribute>())
            {
                string txt = t.GetAttribute<CustomCppClassDefinitionAttribute>().Text;
                sb.AppendLine(txt);
                return;
            }

            if (t is DefClass)
            {
                if (!t.HasAttribute<WrapTypeAttribute>())
                {
                    //Ignore
                }
                else
                {
                    switch (t.GetAttribute<WrapTypeAttribute>().WrapType)
                    {
                        case WrapTypes.NonOverridable:
                            new CppNonOverridableClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.Overridable:
                            new CppOverridableClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.Interface:
                            new CppOverridableClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.NativeDirector:
                            new CppNativeDirectorClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.NativePtrValueType:
                            new CppNativePtrValueClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.Singleton:
                            new CppSingletonClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.CLRHandle:
                            new CppCLRHandleClassProducer(this, t as DefClass, sb).Add();
                            break;
                        case WrapTypes.PlainWrapper:
                            new CppPlainWrapperClassProducer(this, t as DefClass, sb).Add();
                            break;
                    }
                }
            }
            else if (t is DefTypeDef)
            {
                DefTypeDef explicitType;

                if (t.IsUnnamedSTLContainer)
                    explicitType = t as DefTypeDef;
                else
                    explicitType = (t.IsNested) ? t.ParentClass.FindType<DefTypeDef>(t.Name) : t.NameSpace.FindType<DefTypeDef>(t.Name);

                if (explicitType.IsSTLContainer)
                {
                    CppAddSTLContainer(explicitType, sb);
                }
                else if (explicitType is DefIterator)
                {
                    CppAddIterator(explicitType as DefIterator, sb);
                }
            }
        }