Ejemplo n.º 1
0
        public void WriteFunction(PrxFunction function)
        {
            // /* Comment string */
            // // source
            // // original decl
            // [attrs]
            // transformed decl

            //if( function.Source.CommentBlock != null )
            //	_writer.WriteLine( "{0}{1}", _indent, function.Source.CommentBlock );

            // We trim out the nasty source file path
            string sourceFile = function.Source.FileName;

            foreach (string path in _searchPaths)
            {
                if (sourceFile.StartsWith(path) == true)
                {
                    sourceFile = sourceFile.Replace(path, "");
                    break;
                }
            }
            sourceFile = sourceFile.Replace('\\', '/');

            // Attributes
            _writer.WriteLine("{0}[NotImplemented]", _indent);
            _writer.WriteLine("{0}[BiosFunction( 0x{1:X8}, \"{2}\" )] [Stateless]", _indent, function.NID, function.Name);

            // Original decl & source
            _writer.WriteLine("{0}// {1} ({2}:{3})", _indent, function.Source.DeclarationBlock, sourceFile, function.Source.LineNumber);

            bool   hasReturn;
            string transformed = TransformDeclaration(function.Name, function.Source.DeclarationBlock, out hasReturn);

            // Function body
            _writer.Write("{0}{1}", _indent, transformed);
            if (hasReturn == true)
            {
                _writer.WriteLine("{ return NISTUBRETURN; }");
            }
            else
            {
                _writer.WriteLine("{}");
            }

            _writer.WriteLine();
        }
Ejemplo n.º 2
0
        public static NidList FromFile(string xmlFile)
        {
            if (File.Exists(xmlFile) == false)
            {
                Console.WriteLine("NidList: File not found: {0}", xmlFile);
                return(null);
            }

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(xmlFile);
            }
            catch (Exception ex)
            {
                Console.WriteLine("NidList: Could not load XML document {0}; possibly malformed.", xmlFile);
                Console.WriteLine(ex.ToString());
                return(null);
            }

            NidList list = new NidList();

            list.Files = new List <PrxFile>(1024);
            int fileCount     = 0;
            int libraryCount  = 0;
            int functionCount = 0;

            foreach (XmlElement fileElement in doc.SelectNodes("/PSPLIBDOC/PRXFILES/PRXFILE"))
            {
                PrxFile file = new PrxFile();
                file.FileName = fileElement.SelectSingleNode("PRX").InnerText;
                file.Name     = fileElement.SelectSingleNode("PRXNAME").InnerText;
                Debug.Assert((file.Name != null) && (file.Name.Length > 0));

                file.Libraries = new List <PrxLibrary>(10);
                foreach (XmlElement libraryElement in fileElement.SelectNodes("LIBRARIES/LIBRARY"))
                {
                    PrxLibrary lib = new PrxLibrary();
                    lib.File = file;

                    lib.Name = libraryElement.SelectSingleNode("NAME").InnerText;
                    Debug.Assert((lib.Name != null) && (lib.Name.Length > 0));
                    lib.Flags = Convert.ToInt32(libraryElement.SelectSingleNode("FLAGS").InnerText, 16);

                    lib.Functions = new List <PrxFunction>(64);
                    foreach (XmlElement functionElement in libraryElement.SelectNodes("FUNCTIONS/FUNCTION"))
                    {
                        PrxFunction func = new PrxFunction();
                        func.Library = lib;

                        func.Name = functionElement.SelectSingleNode("NAME").InnerText;
                        Debug.Assert((func.Name != null) && (func.Name.Length > 0));
                        func.NID = Convert.ToInt32(functionElement.SelectSingleNode("NID").InnerText, 16);

                        functionCount++;
                        lib.Functions.Add(func);
                    }

                    libraryCount++;
                    file.Libraries.Add(lib);
                }

                fileCount++;
                list.Files.Add(file);
            }

            Console.WriteLine("NidList: Loaded {0} functions in {1} libraries from {2} prxs", functionCount, libraryCount, fileCount);

            return(list);
        }
Ejemplo n.º 3
0
 public FindRequest(string query, PrxFunction function)
 {
     Query    = query;
     Function = function;
 }
Ejemplo n.º 4
0
 public void AddRequest(string query, PrxFunction function)
 {
     PendingRequests.Add(new FindRequest(query, function));
 }
Ejemplo n.º 5
0
        public void WriteFunction(PrxFunction function)
        {
            // /* Comment string */
            // // source
            // // original decl
            // [attrs]
            // transformed decl

            //if( function.Source.CommentBlock != null )
            //	_writer.WriteLine( "{0}{1}", _indent, function.Source.CommentBlock );

            // We may not have Source! If we don't, just write as much as we can!

            string sourceFile = "Not found";

            if (function.Source != null)
            {
                // We trim out the nasty source file path
                sourceFile = function.Source.FileName;
                foreach (string path in _searchPaths)
                {
                    if (sourceFile.StartsWith(path) == true)
                    {
                        sourceFile = sourceFile.Replace(path, "");
                        break;
                    }
                }
                sourceFile = sourceFile.Replace('\\', '/');
            }

            // Attributes
            _writer.WriteLine("{0}[NotImplemented]", _indent);
            _writer.WriteLine("{0}[Stateless]", _indent);
            _writer.WriteLine("{0}[BiosFunction( 0x{1:X8}, \"{2}\" )]", _indent, function.NID, function.Name);

            // Original decl & source
            if (function.Source != null)
            {
                _writer.WriteLine("{0}// SDK location: {1}:{2}", _indent, sourceFile, function.Source.LineNumber);
                _writer.WriteLine("{0}// SDK declaration: {1}", _indent, function.Source.DeclarationBlock);
            }

            bool   hasReturn = true;
            string transformed;

            if (function.Source != null)
            {
                transformed = TransformDeclaration(function.Name, function.Source.DeclarationBlock, out hasReturn);
            }
            else
            {
                transformed = string.Format("int {0}()", function.Name);
            }

            // Function body
            _writer.Write("{0}{1}", _indent, transformed);
            if (hasReturn == true)
            {
                _writer.WriteLine("{ return Module.NotImplementedReturn; }");
            }
            else
            {
                _writer.WriteLine("{}");
            }

            _writer.WriteLine();
        }
Ejemplo n.º 6
0
 public void AddRequest( string query, PrxFunction function )
 {
     PendingRequests.Add( new FindRequest( query, function ) );
 }
Ejemplo n.º 7
0
 public FindRequest( string query, PrxFunction function )
 {
     Query = query;
     Function = function;
 }
Ejemplo n.º 8
0
        public static NidList FromFile( string xmlFile )
        {
            if( File.Exists( xmlFile ) == false )
            {
                Console.WriteLine( "NidList: File not found: {0}", xmlFile );
                return null;
            }

            XmlDocument doc = new XmlDocument();
            try
            {
                doc.Load( xmlFile );
            }
            catch( Exception ex )
            {
                Console.WriteLine( "NidList: Could not load XML document {0}; possibly malformed.", xmlFile );
                Console.WriteLine( ex.ToString() );
                return null;
            }

            NidList list = new NidList();
            list.Files = new List<PrxFile>( 1024 );
            int fileCount = 0;
            int libraryCount = 0;
            int functionCount = 0;

            foreach( XmlElement fileElement in doc.SelectNodes( "/PSPLIBDOC/PRXFILES/PRXFILE" ) )
            {
                PrxFile file = new PrxFile();
                file.FileName = fileElement.SelectSingleNode( "PRX" ).InnerText;
                file.Name = fileElement.SelectSingleNode( "PRXNAME" ).InnerText;
                Debug.Assert( ( file.Name != null ) && ( file.Name.Length > 0 ) );

                file.Libraries = new List<PrxLibrary>( 10 );
                foreach( XmlElement libraryElement in fileElement.SelectNodes( "LIBRARIES/LIBRARY" ) )
                {
                    PrxLibrary lib = new PrxLibrary();
                    lib.File = file;

                    lib.Name = libraryElement.SelectSingleNode( "NAME" ).InnerText;
                    Debug.Assert( ( lib.Name != null ) && ( lib.Name.Length > 0 ) );
                    lib.Flags = Convert.ToInt32( libraryElement.SelectSingleNode( "FLAGS" ).InnerText, 16 );

                    lib.Functions = new List<PrxFunction>( 64 );
                    foreach( XmlElement functionElement in libraryElement.SelectNodes( "FUNCTIONS/FUNCTION" ) )
                    {
                        PrxFunction func = new PrxFunction();
                        func.Library = lib;

                        func.Name = functionElement.SelectSingleNode( "NAME" ).InnerText;
                        Debug.Assert( ( func.Name != null ) && ( func.Name.Length > 0 ) );
                        func.NID = Convert.ToInt32( functionElement.SelectSingleNode( "NID" ).InnerText, 16 );

                        functionCount++;
                        lib.Functions.Add( func );
                    }

                    libraryCount++;
                    file.Libraries.Add( lib );
                }

                fileCount++;
                list.Files.Add( file );
            }

            Console.WriteLine( "NidList: Loaded {0} functions in {1} libraries from {2} prxs", functionCount, libraryCount, fileCount );

            return list;
        }
Ejemplo n.º 9
0
        public void WriteFunction( PrxFunction function )
        {
            // /* Comment string */
            // // source
            // // original decl
            // [attrs]
            // transformed decl

            //if( function.Source.CommentBlock != null )
            //	_writer.WriteLine( "{0}{1}", _indent, function.Source.CommentBlock );

            // We may not have Source! If we don't, just write as much as we can!

            string sourceFile = "Not found";
            if( function.Source != null )
            {
                // We trim out the nasty source file path
                sourceFile = function.Source.FileName;
                foreach( string path in _searchPaths )
                {
                    if( sourceFile.StartsWith( path ) == true )
                    {
                        sourceFile = sourceFile.Replace( path, "" );
                        break;
                    }
                }
                sourceFile = sourceFile.Replace( '\\', '/' );
            }

            // Attributes
            _writer.WriteLine( "{0}[NotImplemented]", _indent );
            _writer.WriteLine( "{0}[Stateless]", _indent );
            _writer.WriteLine( "{0}[BiosFunction( 0x{1:X8}, \"{2}\" )]", _indent, function.NID, function.Name );

            // Original decl & source
            if( function.Source != null )
            {
                _writer.WriteLine( "{0}// SDK location: {1}:{2}", _indent, sourceFile, function.Source.LineNumber );
                _writer.WriteLine( "{0}// SDK declaration: {1}", _indent, function.Source.DeclarationBlock );
            }

            bool hasReturn = true;
            string transformed;
            if( function.Source != null )
                transformed = TransformDeclaration( function.Name, function.Source.DeclarationBlock, out hasReturn );
            else
                transformed = string.Format( "int {0}()", function.Name );

            // Function body
            _writer.Write( "{0}{1}", _indent, transformed );
            if( hasReturn == true )
                _writer.WriteLine( "{ return Module.NotImplementedReturn; }" );
            else
                _writer.WriteLine( "{}" );

            _writer.WriteLine();
        }