예제 #1
0
 public CppTreeWriter(GeneratorSettingsCpp settings)
 {
     Settings = settings;
 }
예제 #2
0
 public CppTreeWriter(PascalTree tree, GeneratorSettingsCpp settings) : base(tree)
 {
     Settings = settings;
 }
예제 #3
0
        static bool ParseTargets(Assembly assembly)
        {
            bool notargets = true;

            foreach (var target in assembly.GetCustomAttributes <GluonTargetAttribute>())
            {
                notargets = false;
                var cpp = target as GluonTargetCppAttribute;
                var cs  = target as GluonTargetCSharpAttribute;

                if (string.IsNullOrEmpty(target.TargetID))
                {
                    Errors.Generic("Target has no ID!");
                    return(false);
                }
                if (cpp != null && cs != null)
                {
                    Errors.Generic("Unrecognized generator type indicated by attribute: " + target.GetType().FullName);
                    return(false);
                }

                if (cpp != null)
                {
                    CppMode mode;

                    if (!Enum.TryParse(cpp.Mode, out mode))
                    {
                        Errors.Generic("Invalid mode specified for Cpp generator: " + cpp.Mode);
                        return(false);
                    }

                    var settings = new GeneratorSettingsCpp(cpp.TargetID);
                    settings.Mode              = mode;
                    settings.ProjectName       = string.IsNullOrEmpty(cpp.ProjectName) ? assembly.GetName().Name : cpp.ProjectName;
                    settings.OutputFolder      = string.IsNullOrEmpty(cpp.OutputFolder) ? ".\\" + cpp.TargetID : cpp.OutputFolder;
                    settings.ProjectFile       = string.IsNullOrEmpty(cpp.ProjectFile) ? assembly.GetName().Name + ".vcxproj" : cpp.ProjectFile;
                    settings.PrecompiledHeader = cpp.PrecompiledHeader;
                    settings.ConsolidateFiles  = cpp.ConsolidateFiles;
                    settings.FullIntellisense  = cpp.FullIntellisense;

                    GluonData.AllTargets[cpp.TargetID] = settings;
                }

                if (cs != null)
                {
                    CSharpMode mode;

                    if (!Enum.TryParse(cs.Mode, out mode))
                    {
                        Errors.Generic("Invalid mode specified for CSharp generator: " + cs.Mode);
                        return(false);
                    }

                    var settings = new GeneratorSettingsCSharp(cs.TargetID);
                    settings.Mode             = mode;
                    settings.ProjectName      = string.IsNullOrEmpty(cs.ProjectName) ? assembly.GetName().Name : cs.ProjectName;
                    settings.OutputFolder     = string.IsNullOrEmpty(cs.OutputFolder) ? ".\\" + cs.TargetID : cs.OutputFolder;
                    settings.ProjectFile      = string.IsNullOrEmpty(cs.ProjectFile) ? assembly.GetName().Name + ".csproj" : cs.ProjectFile;
                    settings.ImportedDll      = string.IsNullOrEmpty(cs.ImportedDll) ? assembly.GetName().Name + ".Cpp.dll" : cs.ImportedDll;
                    settings.ConsolidateFiles = cs.ConsolidateFiles;

                    GluonData.AllTargets[cs.TargetID] = settings;
                }
            }

            if (notargets)
            {
                var cpp = new GeneratorSettingsCpp("Cpp");
                GluonData.AllTargets["Cpp"] = cpp;

                var cs = new GeneratorSettingsCSharp("CSharp");
                GluonData.AllTargets["CSharp"] = cs;
            }

            return(true);
        }