protected string UnwrapValue(string valueCode, RgacType type)
        {
            switch (type.Kind)
            {
            case RgacTypeKind.Primitive:
            {
                switch (type.PrimitiveKind)
                {
                case RgacPrimitiveKind.String:
                case RgacPrimitiveKind.StringReference:
                case RgacPrimitiveKind.ConstStringReference:
                    return(valueCode + ".Buffer()");

                default:
                    return(valueCode);
                }
            }

            case RgacTypeKind.Class:
            case RgacTypeKind.ClassReference:
            case RgacTypeKind.ConstClassReference:
                return(string.Format("*__GacUIInternal<{0}>::GetInternalObject({1})",
                                     type.AssociatedRgacType.ToString(),
                                     valueCode
                                     ));

            case RgacTypeKind.ClassPointer:
            case RgacTypeKind.ClassSmartPointer:
                return(string.Format("__GacUIInternal<{0}>::GetInternalObject({1})",
                                     type.AssociatedRgacType.ToString(),
                                     valueCode
                                     ));

            case RgacTypeKind.Struct:
            case RgacTypeKind.StructReference:
            case RgacTypeKind.ConstStructReference:
                return(string.Format("*__GacUIInternal<{0}>::GetInternalObject({1})",
                                     type.AssociatedRgacType.ToString(),
                                     valueCode
                                     ));

            case RgacTypeKind.StructPointer:
            case RgacTypeKind.StructSmartPointer:
                return(string.Format("__GacUIInternal<{0}>::GetInternalObject({1})",
                                     type.AssociatedRgacType.ToString(),
                                     valueCode
                                     ));

            case RgacTypeKind.Enum:
                return(string.Format("({0}){1}",
                                     type.OriginalGacType.ToString(),
                                     valueCode
                                     ));

            case RgacTypeKind.OtherGacType:
                return(valueCode);
            }
            return(" /*UNKNOWN_TYPE[ " + type.ToString() + " ]*/");
        }
        protected string GetType(RgacType type)
        {
            switch (type.Kind)
            {
            case RgacTypeKind.Primitive:
            {
                switch (type.PrimitiveKind)
                {
                case RgacPrimitiveKind.String:
                    return("GacString");

                case RgacPrimitiveKind.StringReference:
                    return("GacString&");

                case RgacPrimitiveKind.ConstStringReference:
                    return("const GacString&");

                default:
                    return(type.OriginalGacType.Name);
                }
            }

            case RgacTypeKind.Class:
            case RgacTypeKind.ClassPointer:
            case RgacTypeKind.ClassReference:
            case RgacTypeKind.ConstClassReference:
                return("rptr<" + GacUdtTypeName(type.AssociatedRgacType) + ">");

            case RgacTypeKind.ClassSmartPointer:
                return("sptr<" + GacUdtTypeName(type.AssociatedRgacType) + ">");

            case RgacTypeKind.Struct:
                return(GacUdtTypeName(type.AssociatedRgacType));

            case RgacTypeKind.StructPointer:
            case RgacTypeKind.StructReference:
            case RgacTypeKind.ConstStructReference:
                return("rptr<" + GacUdtTypeName(type.AssociatedRgacType) + ">");

            case RgacTypeKind.StructSmartPointer:
                return("sptr<" + GacUdtTypeName(type.AssociatedRgacType) + ">");

            case RgacTypeKind.Enum:
                return(GacUdtTypeName(type.AssociatedRgacType));

            case RgacTypeKind.OtherGacType:
            {
                string result = GetType(type.OriginalGacType);
                if (result != null)
                {
                    return(result);
                }
            }
            break;
            }
            return("0 /*UNKNOWN_TYPE[ " + type.ToString() + " ]*/");
        }
        protected string GetType(RgacType type)
        {
            switch (type.Kind)
            {
            case RgacTypeKind.Primitive:
            {
                switch (type.PrimitiveKind)
                {
                case RgacPrimitiveKind.SInt8:
                    return(GetPrimaryTypeCacheVariable("SInt8"));

                case RgacPrimitiveKind.SInt16:
                    return(GetPrimaryTypeCacheVariable("SInt16"));

                case RgacPrimitiveKind.SInt32:
                    return(GetPrimaryTypeCacheVariable("SInt32"));

                case RgacPrimitiveKind.SInt64:
                    return(GetPrimaryTypeCacheVariable("SInt64"));

                case RgacPrimitiveKind.UInt8:
                    return(GetPrimaryTypeCacheVariable("UInt8"));

                case RgacPrimitiveKind.UInt16:
                    return(GetPrimaryTypeCacheVariable("UInt16"));

                case RgacPrimitiveKind.UInt32:
                    return(GetPrimaryTypeCacheVariable("UInt32"));

                case RgacPrimitiveKind.UInt64:
                    return(GetPrimaryTypeCacheVariable("UInt64"));

                case RgacPrimitiveKind.Char:
                    return(GetPrimaryTypeCacheVariable("Char"));

                case RgacPrimitiveKind.String:
                    return(GetPrimaryTypeCacheVariable("String"));

                case RgacPrimitiveKind.StringReference:
                    return(GetPrimaryTypeCacheVariable("String") + "->GetReferenceType()");

                case RgacPrimitiveKind.ConstStringReference:
                    return(GetPrimaryTypeCacheVariable("String") + "->GetConstReferenceType()");

                case RgacPrimitiveKind.Bool:
                    return(GetPrimaryTypeCacheVariable("Bool"));

                case RgacPrimitiveKind.Float:
                    return(GetPrimaryTypeCacheVariable("Float"));

                case RgacPrimitiveKind.Double:
                    return(GetPrimaryTypeCacheVariable("Double"));

                case RgacPrimitiveKind.Void:
                    return(GetPrimaryTypeCacheVariable("Void"));
                }
            }
            break;

            case RgacTypeKind.Class:
                return(GetTypeCacheVariable(type.AssociatedRgacType));

            case RgacTypeKind.ClassPointer:
                return(GetTypeCacheVariable(type.AssociatedRgacType) + "->GetPointerType()");

            case RgacTypeKind.ClassSmartPointer:
                return(GetTypeCacheVariable(type.AssociatedRgacType) + "->GetSmartPointerType()");

            case RgacTypeKind.ClassReference:
                return(GetTypeCacheVariable(type.AssociatedRgacType) + "->GetReferenceType()");

            case RgacTypeKind.ConstClassReference:
                return(GetTypeCacheVariable(type.AssociatedRgacType) + "->GetConstReferenceType()");

            case RgacTypeKind.Struct:
                return(GetTypeCacheVariable(type.AssociatedRgacType));

            case RgacTypeKind.StructPointer:
                return(GetTypeCacheVariable(type.AssociatedRgacType) + "->GetPointerType()");

            case RgacTypeKind.StructSmartPointer:
                return(GetTypeCacheVariable(type.AssociatedRgacType) + "->GetSmartPointerType()");

            case RgacTypeKind.StructReference:
                return(GetTypeCacheVariable(type.AssociatedRgacType) + "->GetReferenceType()");

            case RgacTypeKind.ConstStructReference:
                return(GetTypeCacheVariable(type.AssociatedRgacType) + "->GetConstReferenceType()");

            case RgacTypeKind.Enum:
                return(GetTypeCacheVariable(type.AssociatedRgacType));

            case RgacTypeKind.OtherGacType:
            {
                string result = GetType(type.OriginalGacType);
                if (result != null)
                {
                    return(result);
                }
            }
            break;
            }
            UnknownTypes.Add(type.ToString());
            return("0 /*UNKNOWN_TYPE[ " + type.ToString() + " ]*/");
        }