示例#1
0
        private TFileType readInterfaceType()
        {
            TFileType t = new TFileType();

            currentInterfaceType = t;
            if (currentToken.nextTokenIs(ECodeToken.brSmallBraceBegin))
            {
                t.attributes = readAttributes();
            }
            else
            {
                getNextToken();
            }
            if (currentToken.token == ECodeToken.ltString)
            {
                t.name = readType().name;
                //t.checkAlias();
                if (currentToken.token == ECodeToken.syDoublePoint)
                {
                    do
                    {
                        getNextToken();
                        t.baseType.Add(readType());
                    }while (currentToken.token == ECodeToken.syComma);
                }
                readMembers(t);
            }
            return(t);
        }
示例#2
0
 public TMember(TFileType parentType)
 {
     this.parentType = parentType;
     resultType      = new TType()
     {
         name = "void"
     };
 }
示例#3
0
 private static bool hasConstructor(TFileType t)
 {
     foreach (var member in t.members)
     {
         if (member is TMethod)
         {
             var method = (TMethod)member;
             if (method.isConstructor)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#4
0
        private void readMembers(TFileType t)
        {
            string name    = "";
            bool   vStatic = false;
            bool   vFinal  = false;

            while (currentToken != null)
            {
                if (currentToken.token == ECodeToken.brBigBraceEnd)
                {
                    break;
                }
                TMember mem = readMember();
                if (mem != null)
                {
                    if (!mem.name.ToLower().StartsWith("webkit") && !mem.name.ToLower().StartsWith("onwebkit"))
                    {
                        if (mem is TMethod)
                        {
                            var met = mem as TMethod;
                            for (var i = 0; i < met.parameters.Count; i++)
                            {
                                if (met.parameters[i].isOptional())
                                {
                                    var newMem = new TMethod(t)
                                    {
                                        baseMethod = met.baseMethod, isPrivate = met.isPrivate, name = met.name, resultType = met.resultType
                                    };
                                    for (var i2 = 0; i2 < i; i2++)
                                    {
                                        newMem.parameters.Add(met.parameters[i2]);
                                    }
                                    t.members.addWithCheck(newMem);
                                }
                            }
                        }
                        t.members.addWithCheck(mem);
                    }
                }
                getNextToken();
            }
        }
示例#5
0
 public TField(TFileType parentType) : base(parentType)
 {
 }
示例#6
0
 public TProperty(TFileType parentType) : base(parentType)
 {
 }
示例#7
0
 public TMethod(TFileType parentType)
     : base(parentType)
 {
     //if (parentType == null) throw new ArgumentException("parentType");
 }
示例#8
0
 public TFragmentMember(TFileType parentType) : base(parentType)
 {
 }
示例#9
0
        public void convertFile(string inFile, string outFile)
        {
            nsList       = new TNamespaceList(this);
            this.outFile = outFile;
            this.inFile  = inFile;
            var localIdlFile  = Program.idlOutTempDirectory + @"\" + Path.GetFileName(inFile);
            var localIdlFile2 = Program.idlOutTempDirectory + @"\" + Path.GetFileNameWithoutExtension(inFile) + ".i";
            var path          = Path.GetDirectoryName(inFile).Replace(Program.idlInDirectory, "").Replace("\\", ".");

            if (File.Exists(localIdlFile))
            {
                File.Delete(localIdlFile);
            }
            File.Copy(inFile, localIdlFile);

            Environment.CurrentDirectory = Path.GetDirectoryName(localIdlFile);
            if (Program.runPreprocessor)
            {
                Process.Start(new ProcessStartInfo(Program.preprocessorExe, localIdlFile + " /P /DLANGUAGE_JAVASCRIPT=1")
                {
                    WindowStyle = ProcessWindowStyle.Hidden
                }).WaitForExit();
            }

            var lines = File.ReadAllLines(localIdlFile2);

            for (var i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith("#"))
                {
                    lines[i] = "";
                }
            }
            TScriptTokenizer tokenizer = new TScriptTokenizer(string.Join("\r\n", lines), localIdlFile2);
            TCodeTokenFile   tf        = tokenizer.GetTokenFile();

            setTokens(tf.tokens);

            TNamespace ns = new TNamespace(this);

            nsList.Add(ns);

            //path = path.Replace("modules.", "");
            if (TransformationConfig.moveToRootNamespace.Contains(path.ToLower()))
            {
                ns.name = "randori.webkit";
            }
            else
            {
                ns.name = "randori.webkit." + path.ToLower();
                if (!Generator.namespaceNames.Contains(ns.name))
                {
                    Generator.namespaceNames.Add(ns.name);
                }
            }

            getNextToken();
            TAttributeList attributes = new TAttributeList();

            while (true)
            {
                //if (currentToken.token == ECodeToken.kwModule)
                //{
                //    getNextToken();
                //    var module = readDottedString();
                //    ns.name = "SharpKit.Html";

                //    //var seperateModules = new HashSet<string>(new string[]{
                //    //    "svg",
                //    //    "storage",
                //    //    "threads",
                //    //    "audio",
                //    //    "webaudio",
                //    //});

                //    if (TransformationConfig.createSubNamespaceForModule.Contains(module))
                //    {
                //        ns.name += "." + module;
                //        if (!Generator.namespaceNames.Contains(ns.name)) Generator.namespaceNames.Add(ns.name);
                //    }

                //}



                //if (CurrentToken.Token == ECodeToken.kwImport) {
                //  GetNextToken();
                //  string imp = readDottedString();
                //  if (!(imp.Contains("org.w3c.dom.html.Function"))) {
                //    ns.ImportList.Add(imp);
                //  }
                //}
                ns.importList.Clear();

                if (currentToken.token == ECodeToken.brSmallBraceBegin)
                {
                    attributes = readAttributes();
                }

                if (currentToken.token == ECodeToken.kwInterface) //new type
                {
                    TFileType t = readInterfaceType();
                    t.attributes = attributes;
                    foreach (var attr in t.attributes)
                    {
                        if (attr is TConstructorAttribute)
                        {
                            ((TConstructorAttribute)attr).constructor.parentType = t;
                        }
                    }
                    attributes = new TAttributeList(); //reset
                    t.ns       = ns;
                    ns.types.Add(t);
                    t.checkProp();
                }
                getNextToken();
                if (_IsEndOfDocument)
                {
                    break;
                }
            }
        }