Example #1
0
        private static bool OnImport(IDLImporter importer, List <string> usingNamespaces, string sFileName,
                                     string sXmlFile, string sOutFile, string sNamespace, StringCollection idhFiles, StringCollection refFiles, bool fCreateComments)
        {
            Console.WriteLine("Generating {0}...", Path.GetFileName(sOutFile));

            importer.ResolveBaseType += importer_ResolveBaseType;
            bool fOk = importer.Import(usingNamespaces, sFileName, sXmlFile, sOutFile, sNamespace,
                                       idhFiles, refFiles, fCreateComments);

            importer.ResolveBaseType -= importer_ResolveBaseType;
            return(fOk);
        }
Example #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Do the import
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void ExecuteTask()
		{
			base.ExecuteTask();

			// Check to see if any of the underlying IDL files have changed
			// Otherwise, it's not necessary to reimport.
			if (NeedsCompiling())
			{
				Log(Level.Info, "Importing {0}", Path.GetFileName(IdlFile));

				try
				{
					IDLImporter importer = new IDLImporter();
					List<string> usingNamespaces = new List<string>();
					foreach(UsingNamespace ns in m_usingNamespaces)
						usingNamespaces.Add(ns.Namespace);

					bool fOk = importer.Import(usingNamespaces, IdlFile, m_configfile,
						OutputFile.FullName, Namespace, m_idhFiles.FileNames,
						m_refFiles.FileNames, m_fCreateXmlComments);
					if (!fOk)
						throw new BuildException("Import failed: data has errors", Location);
				}
				catch(Exception e)
				{
					throw new BuildException("Import failed.", Location, e);
				}
			}
		}
Example #3
0
        public static int Main(string[] args)
        {
            bool fOk = true;

            try
            {
                if (args.Length < 1 || args.Length == 1 && (args[0] == "/?" || args[0] == "-?"))
                {
                    ShowHelp();
                    return(0);
                }

                // Get all necessary file names
                List <string>    usingNamespaces = new List <string>();
                string           sFileName       = args[args.Length - 1];
                string           sXmlFile        = Path.ChangeExtension(Application.ExecutablePath, "xml");
                string           sOutFile        = Path.ChangeExtension(sFileName, "cs");
                string           sNamespace      = Path.GetFileNameWithoutExtension(sFileName);
                StringCollection idhFiles        = new StringCollection();
                StringCollection refFiles        = new StringCollection();
                bool             fCreateComments = true;

                for (int i = 0; i < (args.Length - 1) / 2; i++)
                {
                    switch (args[i * 2])
                    {
                    case "/o":
                    case "-o":
                        sOutFile = args[i * 2 + 1];
                        break;

                    case "/c":
                    case "-c":
                        sXmlFile = args[i * 2 + 1];
                        break;

                    case "/n":
                    case "-n":
                        sNamespace = args[i * 2 + 1];
                        break;

                    case "/u":
                    case "-u":
                        usingNamespaces.Add(args[i * 2 + 1]);
                        break;

                    case "/?":
                    case "-?":
                        ShowHelp();
                        return(0);

                    case "/x":
                    case "-x":
                        fCreateComments = (args[i * 2 + 1] == "0" ? false : true);
                        break;

                    case "/i":
                    case "-i":
                        idhFiles.Add(args[i * 2 + 1]);
                        break;

                    case "/r":
                    case "-r":
                        refFiles.Add(args[i * 2 + 1]);
                        break;

                    default:
                        Console.WriteLine("\nWrong parameter: {0}\n", args[i * 2]);
                        ShowHelp();
                        return(0);
                    }
                }

                Console.WriteLine("Generating {0}...", Path.GetFileName(sOutFile));

                IDLImporter imp = new IDLImporter();
                fOk = imp.Import(usingNamespaces, sFileName, sXmlFile, sOutFile, sNamespace,
                                 idhFiles, refFiles, fCreateComments);
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Internal program error in program {0}", e.Source);
                System.Console.WriteLine("\nDetails:\n{0}\nin method {1}.{2}\nStack trace:\n{3}",
                                         e.Message, e.TargetSite.DeclaringType.Name, e.TargetSite.Name, e.StackTrace);

                return(1);
            }

            return(fOk ? 0 : 2);
        }
Example #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Do the import
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override bool Execute()
		{
			try
			{
				IDLImporter importer = new IDLImporter();
				var namespaces = new List<string>();
				foreach (var s in GetFilesFrom(UsingNamespaces))
				{
					Log.LogMessage(MessageImportance.Low, "Using namespace " + s);
					namespaces.Add(s);
				}


				foreach (var idlFile in Sources)
				{
					//Log.LogMessage(MessageImportance.Normal, "Creating IDL File " + Path.GetFileName(idlFile.ItemSpec));
					Log.LogMessage(MessageImportance.Normal, "Processing IDL File " + Path.GetFileName(idlFile.ItemSpec) + " to produce " + Output);
					foreach (var s in GetFilesFrom(IdhFiles))
						Log.LogMessage(MessageImportance.Low, "IDH: " + s);
					foreach (var s in GetFilesFrom(ReferenceFiles))
						Log.LogMessage(MessageImportance.Low, "references: " + s);
					bool fOk = importer.Import(namespaces, idlFile.ItemSpec, null,
						Output, Namespace, GetFilesFrom(IdhFiles),
						GetFilesFrom(ReferenceFiles), CreateXmlComments);
					if (!fOk)
					{
						Log.LogMessage(MessageImportance.High, "IDL Import failed: data has errors " + Path.GetFileName(idlFile.ItemSpec));
						return false;
					}
				}
			}

			catch (Exception e)
			{
				Log.LogMessage(MessageImportance.High, "IDL Import threw an exception: " + e.Message);
				return false;
			}
			return true;
		}
Example #5
0
        public static int Main(string[] args)
        {
            bool fOk = true;
            try
            {
                if (args.Length < 1 || args.Length == 1 && (args[0] == "/?" || args[0] == "-?"))
                {
                    ShowHelp();
                    return 0;
                }

                // Get all necessary file names
                List<string> usingNamespaces = new List<string>();
                string sFileName = args[args.Length - 1];
                string sXmlFile = Path.ChangeExtension(Application.ExecutablePath, "xml");
                string sOutFile = Path.ChangeExtension(sFileName, "cs");
                string sNamespace = Path.GetFileNameWithoutExtension(sFileName);
                StringCollection idhFiles = new StringCollection();
                StringCollection refFiles = new StringCollection();
                bool fCreateComments = true;

                for (int i = 0; i < (args.Length-1)/2; i++)
                {
                    switch (args[i*2])
                    {
                        case "/o":
                        case "-o":
                            sOutFile = args[i*2+1];
                            break;
                        case "/c":
                        case "-c":
                            sXmlFile = args[i*2+1];
                            break;
                        case "/n":
                        case "-n":
                            sNamespace = args[i*2+1];
                            break;
                        case "/u":
                        case "-u":
                            usingNamespaces.Add(args[i*2+1]);
                            break;
                        case "/?":
                        case "-?":
                            ShowHelp();
                            return 0;
                        case "/x":
                        case "-x":
                            fCreateComments = (args[i*2+1] == "0" ? false : true);
                            break;
                        case "/i":
                        case "-i":
                            idhFiles.Add(args[i * 2 + 1]);
                            break;
                        case "/r":
                        case "-r":
                            refFiles.Add(args[i * 2 + 1]);
                            break;
                        default:
                            Console.WriteLine("\nWrong parameter: {0}\n", args[i*2]);
                            ShowHelp();
                            return 0;
                    }
                }

                Console.WriteLine("Generating {0}...", Path.GetFileName(sOutFile));

                IDLImporter imp = new IDLImporter();
                fOk = imp.Import(usingNamespaces, sFileName, sXmlFile, sOutFile, sNamespace,
                    idhFiles, refFiles, fCreateComments);
            }
            catch(Exception e)
            {
                System.Console.WriteLine("Internal program error in program {0}", e.Source);
                System.Console.WriteLine("\nDetails:\n{0}\nin method {1}.{2}\nStack trace:\n{3}",
                    e.Message, e.TargetSite.DeclaringType.Name, e.TargetSite.Name, e.StackTrace);

                return 1;
            }

            return fOk ? 0 : 2;
        }