コード例 #1
0
ファイル: JTypeImporter.cs プロジェクト: wangchengqun/Cs2Java
        JsMode GetJsMode(ITypeDefinition ce)
        {
            var isGlobal = JMeta.IsGlobalType(ce);

            if (isGlobal)
            {
                return(JsMode.Global);
            }
            var isNative = JMeta.IsNativeType(ce);

            if (isNative)
            {
                return(JsMode.Prototype);
            }
            return(JsMode.Clr);
        }
コード例 #2
0
        private JTypeImporter GetTypeImporter(ITypeDefinition ce)
        {
            JTypeImporter export;
            var           isExtJs  = JMeta.IsExtJsType(ce);
            var           isGlobal = JMeta.IsGlobalType(ce) && !isExtJs;
            var           isNative = JMeta.IsNativeType(ce) && !isExtJs;

            isNative = true;
            isGlobal = false;
            isExtJs  = false;
            if (isGlobal)
            {
                throw new NotSupportedException();
            }
            else if (isNative)
            {
                if (NativeExport == null)
                {
                    NativeExport = new JTypeImporter {
                        Compiler = Compiler
                    }
                }
                ;
                export = NativeExport;
            }
            else if (isExtJs)
            {
                throw new NotSupportedException();
            }
            else
            {
                throw new NotSupportedException();
            }
            ConfigureTypeExport(export);
            return(export);
        }
コード例 #3
0
ファイル: JTypeImporter.cs プロジェクト: wangchengqun/Cs2Java
        /// <summary>
        /// Returns base type of a type, only if base type is Clr or Prototype
        /// </summary>
        /// <param name="ce"></param>
        /// <returns></returns>
        protected virtual IType GetBaseClassIfValid(ITypeDefinition ce, bool recursive)
        {
            var baseClass = ce.GetBaseType();

            while (baseClass != null)
            {
                if (JMeta.IsClrType(baseClass.GetDefinition()) || (JMeta.IsNativeType(baseClass.GetDefinition()) && !JMeta.IsGlobalType(baseClass.GetDefinition())) || !recursive)
                {
                    return(baseClass);
                }
                baseClass = baseClass.GetBaseType();
            }
            return(null);
        }