/// <summary>
        /// Applies friendly board to the bitboard and updates the visual board.
        /// </summary>
        /// <param name="friendlyBoard">The friendly board to apply.</param>
        /// <param name="whiteMode">The white generator mode.</param>
        /// <param name="blackMode">The black generator mode.</param>
        /// <param name="quiescenceSearch">If true, only quiescence moves (mainly captures) will be generated.</param>
        protected void CalculateBitboard(FriendlyBoard friendlyBoard, GeneratorMode whiteMode, GeneratorMode blackMode, bool quiescenceSearch)
        {
            Bitboard = new Bitboard(friendlyBoard);
            Bitboard.Calculate(whiteMode, blackMode, quiescenceSearch);

            VisualBoard.FriendlyBoard = new FriendlyBoard(Bitboard);
        }
        public WorldGenStepsMenu()
        {
            resizeable = false;

            mode      = TerrainManager.Generators.Keys.RandomElement();
            generator = TerrainManager.Generators[mode].RandomElement();
        }
Example #3
0
        private byte[] GenerateBlock(byte[] data, IReadOnlyList <byte[]> subKeys, GeneratorMode mode)
        {
            var message   = _desCryptoTransform.Map(data, _desCryptoSettings.InputPermutation);
            var blockSize = _desCryptoSettings.InputPermutation.Length;
            var left      = _desCryptoTransform.Map(message, 0, blockSize / 2);
            var right     = _desCryptoTransform.Map(message, blockSize / 2, blockSize / 2);

            for (var i = 0; i < subKeys.Count; i++)
            {
                var buffer = right;

                right = _desCryptoTransform.Map(right, _desCryptoSettings.ExpansionPermutation);
                right = _desCryptoTransform.Xor(right, GetSubKey(i));
                right = _desCryptoTransform.Replace(right);
                right = _desCryptoTransform.Map(right, _desCryptoSettings.Permutation);
                right = _desCryptoTransform.Xor(left, right);
                left  = buffer;
            }

            var concatinationResult = _desCryptoTransform.Concat(right, blockSize / 2, left, blockSize / 2);

            return(_desCryptoTransform.Map(concatinationResult, _desCryptoSettings.FinalPermutation));

            byte[] GetSubKey(int index) =>
            mode == GeneratorMode.Decrypt ? subKeys[subKeys.Count - index - 1] : subKeys[index];
        }
Example #4
0
 private static void SetGeneratorMode(string dirName, string arg)
 {
     if (arg == "gl" || arg == "gl2" || arg == "gl3" || arg == "gl4")
     {
         mode = GeneratorMode.GL2;
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
     }
     else if (arg == "es10")
     {
         mode = GeneratorMode.ES10;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES10";
     }
     else if (arg == "es11")
     {
         mode = GeneratorMode.ES11;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES11";
     }
     else if (arg == "es20")
     {
         mode = GeneratorMode.ES20;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES20";
     }
     else if (arg == "es30")
     {
         mode = GeneratorMode.ES30;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES30";
     }
     else if (arg == "es31")
     {
         mode = GeneratorMode.ES31;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES31";
     }
     else if (arg == "cl" || arg == "cl10")
     {
         mode = GeneratorMode.CL10;
     }
     else
     {
         throw new NotSupportedException();
     }
 }
        /// <summary>
        /// Creates the options for the specified generator mode.
        /// </summary>
        /// <param name="generatorMode">The generator mode.</param>
        /// <returns>ParameterGeneratorOptions.</returns>
        /// <autogeneratedoc />
        public static ParameterGeneratorOptions Create(GeneratorMode generatorMode)
        {
            var m = matrix[generatorMode];

            return(new ParameterGeneratorOptions {
                Modifiers = m[0],
                Type = m[1],
                Name = m[2],
            });
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Generator"/> class.
 /// </summary>
 /// <param name="generatorMode">The generator mode.</param>
 private Generator(GeneratorMode generatorMode)
 {
     GeneratorMode       = generatorMode;
     _fieldGenerator     = new FieldGenerator(this);
     _eventGenerator     = new EventGenerator(this);
     _methodGenerator    = new MethodGenerator(this);
     _parameterGenerator = new ParameterGenerator(this);
     _propertyGenerator  = new PropertyGenerator(this);
     _typeNameGenerator  = new TypeNameGenerator(this);
 }
        /// <summary>
        /// Creates the options for the specified generator mode.
        /// </summary>
        /// <param name="generatorMode">The generator mode.</param>
        /// <returns>FieldGeneratorOptions.</returns>
        /// <autogeneratedoc />
        public static PropertyGeneratorOptions Create(GeneratorMode generatorMode)
        {
            var m = matrix[generatorMode];

            return(new PropertyGeneratorOptions {
                Access = m[0],
                Modifiers = m[1],
                Type = m[2],
                Name = m[3],
            });
        }
        /// <summary>
        /// Creates the options for the specified generator mode.
        /// </summary>
        /// <param name="generatorMode">The generator mode.</param>
        /// <returns>MethodGeneratorOptions.</returns>
        /// <autogeneratedoc />
        public static MethodGeneratorOptions Create(GeneratorMode generatorMode)
        {
            var m = matrix[generatorMode];

            return(new MethodGeneratorOptions {
                Access = m[0],
                Modifiers = m[1],
                ReturnType = m[2],
                Name = m[3],
                Parameter = ParameterGeneratorOptions.Create(generatorMode)
            });
        }
        private static async Task GenerateAssets(string[] files, GeneratorMode mode, string destinationDirectory,
                                                 int quality, string postfix)
        {
            var generator = mode.CreateGenerator();

            foreach (var filepath in files.OrderBy(s => s).ToList())
            {
                Console.WriteLine($"Creating assets from {filepath}");
                var filename = Path.GetFileNameWithoutExtension(filepath);
                await generator.CreateAsset(filepath, filename, destinationDirectory, quality, postfix);
            }
        }
Example #10
0
        private static void SetGeneratorMode(string dirName, string arg)
        {
            switch (arg)
            {
            case "gl":
            case "gl2":
                mode = GeneratorMode.GL2;
                Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
                break;

            case "gl3":
            case "gl4":
                mode = GeneratorMode.GL4;
                Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL4";
                break;

            case "es10":
                mode = GeneratorMode.ES10;
                Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES10";
                break;

            case "es11":
                mode = GeneratorMode.ES11;
                Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES11";
                break;

            case "es2":
            case "es20":
                mode = GeneratorMode.ES20;
                Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES20";
                break;

            case "es3":
            case "es30":
                mode = GeneratorMode.ES30;
                Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES30";
                break;

            case "es31":
                mode = GeneratorMode.ES31;
                Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES31";
                break;

            case "cl":
            case "cl10":
                mode = GeneratorMode.CL10;
                Settings.DefaultOutputNamespace = "OpenTK.Compute.OpenCL";
                break;

            default:
                throw new NotSupportedException();
            }
        }
Example #11
0
        /// <summary>
        /// Calculates available moves.
        /// </summary>
        /// <param name="whiteMode">The white generator mode.</param>
        /// <param name="blackMode">The black generator mode.</param>
        /// <param name="quiescenceSearch">If true, only quiescence moves (mainly captures) will be generated.</param>
        private void CalculateAvailableMoves(GeneratorMode whiteMode, GeneratorMode blackMode, bool quiescenceSearch)
        {
            var whiteGeneratorParameters = GetGeneratorParameters(Color.White, whiteMode, quiescenceSearch);
            var blackGeneratorParameters = GetGeneratorParameters(Color.Black, blackMode, quiescenceSearch);

            CalculateAvailableMoves(whiteGeneratorParameters);
            CalculateAvailableMoves(blackGeneratorParameters);

            CalculateCastling(whiteGeneratorParameters);
            CalculateCastling(blackGeneratorParameters);

            _calculated = true;
        }
Example #12
0
        /// <summary>
        /// Creates the options for the specified mode.
        /// </summary>
        /// <param name="mode">The mode.</param>
        /// <returns>MemberGeneratorOptions.</returns>
        /// <autogeneratedoc />
        public static MemberGeneratorOptions Create(GeneratorMode mode)
        {
            switch (mode)
            {
            case GeneratorMode.CompareIgnoreReturnType: return(new MemberGeneratorOptions {
                    Access = true, Modifiers = true, ReturnType = false, Name = true
                });

            default:                                    return(new MemberGeneratorOptions {
                    Access = true, Modifiers = true, ReturnType = false, Name = true
                });
            }
        }
Example #13
0
        /// <summary>   Constructor. </summary>
        ///
        /// <remarks>   Ken, 10/3/2020. </remarks>
        ///
        /// <param name="projectType">          Type of the project. </param>
        /// <param name="projectFolderRoot">    The project folder root. </param>
        /// <param name="appName">              Name of the application. </param>
        /// <param name="appDescription">       Information describing the application. </param>
        /// <param name="organizationName">     Name of the organization. </param>
        /// <param name="additionalOptions">    Options for controlling the additional. </param>
        /// <param name="generatorMode">        (Optional) The generator mode. </param>
        /// <param name="generatorOptions">     (Optional) Options for controlling the generator. </param>

        public WorkspaceGeneratorEngine(Guid projectType, string projectFolderRoot, string appName, string appDescription, string organizationName, Dictionary <string, object> additionalOptions, GeneratorMode generatorMode = GeneratorMode.Console, GeneratorOptions generatorOptions = null)
        {
            IGeneratorOverrides appNameOverride;
            IGeneratorOverrides appDescriptionOverride;
            KeyValuePair <string, IGeneratorOverrides> appNameOverridePair;
            KeyValuePair <string, IGeneratorOverrides> appDescriptionOverridePair;
            string      argumentsKind;
            var         thisAssembly = Assembly.GetEntryAssembly();
            List <Type> types;

            this.generatorOverridePairs = this.GetOverrides().ToList();
            this.projectType            = projectType;
            this.projectFolderRoot      = projectFolderRoot;
            this.organizationName       = organizationName;

            appNameOverridePair        = generatorOverridePairs.Where(o => o.Value.OverridesAppName).LastOrDefault();
            appDescriptionOverridePair = generatorOverridePairs.Where(o => o.Value.OverridesAppDescription).LastOrDefault();

            argumentsKind          = appNameOverridePair.Key;
            appNameOverride        = appNameOverridePair.Value;
            appDescriptionOverride = appDescriptionOverridePair.Value;

            if (appDescriptionOverride == null)
            {
                this.appDescription = appDescription;
            }
            else
            {
                this.appDescription = appDescriptionOverride.GetAppDescription(this.GeneratorConfiguration, argumentsKind);
            }

            if (appNameOverride == null)
            {
                this.appName = appName;
            }
            else
            {
                var originalNamespace = appName;

                appNameOverride.OriginalNamespace = originalNamespace;
                this.appName = appNameOverride.GetAppName(this.GeneratorConfiguration, argumentsKind);
            }

            supportedTokens = additionalOptions.Where(p => p.Key == "SupportedTokens").SelectMany(p => (List <string>)p.Value).ToArray();

            types = thisAssembly.GetAllTypes().OrderBy(t => t.Name).ToList();

            this.GeneratorConfiguration = new GeneratorConfiguration(projectType, projectFolderRoot, appName, appDescription, additionalOptions, generatorOptions, this, types);
            this.generatorMode          = generatorMode;
            this.generatorOptions       = generatorOptions;
        }
Example #14
0
        /// <summary>
        /// Creates the options for the specified generator mode.
        /// </summary>
        /// <param name="generatorMode">The generator mode.</param>
        /// <returns><see cref="ParameterGeneratorOptions"/>.</returns>
        public static ParameterGeneratorOptions Create(GeneratorMode generatorMode)
        {
            switch (generatorMode)
            {
            case GeneratorMode.CompareIgnoreReturnType:
            case GeneratorMode.Compare: return(new ParameterGeneratorOptions {
                    Name = false
                });

            default: return(new ParameterGeneratorOptions {
                    Name = true
                });
            }
        }
Example #15
0
        private byte[] ProcessInner(byte[] data, byte[] key, GeneratorMode mode)
        {
            var subKeys = _desCryptoTransform.GenerateSubKeys(key);
            var result  = new byte[data.Length];
            var block   = new byte[_blockSize];

            for (var i = 0; i < data.Length / _blockSize; i++)
            {
                Array.Copy(data, _blockSize * i, block, 0, _blockSize);
                Array.Copy(mode == GeneratorMode.Decrypt ? DecryptBlock(block, subKeys) : EncryptBlock(block, subKeys),
                           0, result, _blockSize * i, _blockSize);
            }

            return(result);
        }
Example #16
0
        /// <summary>
        /// Calculates generator parameters for the specified player and generator mode.
        /// </summary>
        /// <param name="color">The player color.</param>
        /// <param name="mode">The generator mode.</param>
        /// <param name="quiescenceSearch">If true, only quiescence moves (mainly captures) will be generated.</param>
        /// <returns>The generator parameters.</returns>
        private GeneratorParameters GetGeneratorParameters(Color color, GeneratorMode mode, bool quiescenceSearch)
        {
            return(new GeneratorParameters
            {
                Bitboard = this,

                FriendlyColor = color,
                EnemyColor = ColorOperations.Invert(color),
                Mode = mode,

                OccupancySummary = Occupancy[(int)Color.White] | Occupancy[(int)Color.Black],
                FriendlyOccupancy = Occupancy[(int)color],
                EnemyOccupancy = Occupancy[(int)ColorOperations.Invert(color)],

                QuiescenceSearch = quiescenceSearch
            });
        }
        /// <summary>   Constructor. </summary>
        ///
        /// <remarks>   Ken, 10/1/2020. </remarks>
        ///
        /// <param name="projectType">          Type of the project. </param>
        /// <param name="projectFolderRoot">    The project folder root. </param>
        /// <param name="templateFile">         The template file. </param>
        /// <param name="additionalOptions">    Options for controlling the additional. </param>
        /// <param name="generatorMode">        (Optional) The generator mode. </param>
        /// <param name="generatorOptions">     (Optional) Options for controlling the generator. </param>

        public BusinessModelGeneratorEngine(Guid projectType, string projectFolderRoot, string templateFile, Dictionary <string, object> additionalOptions, GeneratorMode generatorMode = GeneratorMode.Console, GeneratorOptions generatorOptions = null)
        {
            var thisAssembly = Assembly.GetEntryAssembly();
            var inputFiles   = new Dictionary <string, string> {
                { "templateFile", templateFile }
            };
            List <Type> types;

            this.projectType       = projectType;
            this.projectFolderRoot = projectFolderRoot;

            types = thisAssembly.GetAllTypes().OrderBy(t => t.Name).ToList();

            this.GeneratorConfiguration = new GeneratorConfiguration(projectType, projectFolderRoot, inputFiles, additionalOptions, generatorOptions, this, types);
            this.generatorMode          = generatorMode;
            this.generatorOptions       = generatorOptions;
        }
Example #18
0
        private static void SetGeneratorMode(string arg)
        {
            switch (arg)
            {
            case "gl":
            case "gl2":
                mode = GeneratorMode.GL2;
                break;

            case "gl3":
            case "gl4":
                mode = GeneratorMode.GL4;
                break;

            case "es10":
                mode = GeneratorMode.ES10;
                break;

            case "es11":
                mode = GeneratorMode.ES11;
                break;

            case "es2":
            case "es20":
                mode = GeneratorMode.ES20;
                break;

            case "es3":
            case "es30":
                mode = GeneratorMode.ES30;
                break;

            case "es31":
                mode = GeneratorMode.ES31;
                break;

            case "cl":
            case "cl10":
                mode = GeneratorMode.CL10;
                break;

            default:
                throw new NotSupportedException();
            }
        }
Example #19
0
        public LatticeNoiseGenerator(Random Random, LatticeNoiseSettings Settings)
            : this(Random)
        {
            _Frequency   = Settings.Frequency;
            _Lacunarity  = Settings.Lacunarity;
            _Octaves     = Settings.Octaves;
            _Persistence = Settings.Persistence;
            _Bias        = Settings.Bias;
            _Factor      = Settings.Factor;

            _Interpolator = Settings.Interpolator;
            _Evaluator    = Settings.Evaluator;

            GeneratorMode    = Settings.GeneratorMode;
            PreTreatment     = Settings.PreTreatment;
            PostTreatment    = Settings.PostTreatment;
            Turbulence       = Settings.Turbulence;
            PostModification = Settings.PostModification;
        }
 private void ProgressStep(float progress01, int step, GeneratorMode mod)
 {
     string[] labels = mod == GeneratorMode.Map ? MAP_STEP_LABELS : CHARACTER_STEP_LABELS;
     if (step >= labels.Length)
     {
         Util.ClearProgressBar();
         return;
     }
     step = Mathf.Clamp(step, 0, labels.Length - 1);
     Util.ProgressBar(
         "Working...",
         string.Format(
             labels[step],
             (step + 1).ToString(),
             labels.Length.ToString(),
             (progress01 * 100).ToString("00")
             ),
         progress01 / labels.Length + step / (labels.Length - 1f)
         );
 }
Example #21
0
 private ParticleGenerator(GeneratorMode mode, Vector3 position, Quaternion orientation, Vector3 initialVelocity, Vector3 gravity, float scale, float bounciness, float alphaDecrease, Vector2 planeSize, Vector3 boxSize)
 {
     Mode = mode;
     Position = position;
     Orientation = orientation;
     InitialVelocity = initialVelocity;
     Gravity = gravity;
     Bounciness = bounciness;
     PlaneSize = planeSize;
     BoxSize = boxSize;
     Scale = scale;
     AlphaDecrease = alphaDecrease;
     Info3d = Generators.Object3dGenerator.CreateGround(new Vector2(-1, -1), new Vector2(1, 1), new Vector2(1), Vector3.UnitY);
     Program = ShaderProgram.Compile("ParticleGenerator.vertex.glsl", "ParticleGenerator.fragment.glsl");
     DepthWriter = ShaderProgram.Compile("ParticleGenerator.vertex.glsl", "ParticleGeneratorWriteDepth.fragment.glsl");
     TimeRate = 9.0f / 1000000.0f;
     TimeToLife = 9.0f;
     MaxInstances = 1000000;
     StartTime = DateTime.Now;
     Tex = new Texture(Media.Get("smoke.png"));
 }
        private void ProgressStep(float progress01, float step01, GeneratorMode mod)
        {
            if (step01 > 1.001f)
            {
                Util.ClearProgressBar();
                return;
            }
            string[] labels = mod == GeneratorMode.Map ? MAP_STEP_LABELS : CHARACTER_STEP_LABELS;
            int      step   = Mathf.Clamp((int)(step01 * (labels.Length + 1)), 0, labels.Length - 1);

            Util.ProgressBar(
                "Generating...",
                string.Format(
                    labels[step],
                    (step + 1).ToString(),
                    labels.Length.ToString(),
                    (progress01 * 100).ToString("00")
                    ),
                progress01 / labels.Length + step01
                );
        }
        public void Generate(params string[] csharpCode)
        {
            this.collectedClasses = new Dictionary <string, CombinedClass>();

            this.mode = GeneratorMode.CollectClasses;
            foreach (var code in csharpCode)
            {
                var tree = (CSharpSyntaxTree)CSharpSyntaxTree.ParseText(code);

                var errorList = tree.GetDiagnostics().Where(f => f.Severity == DiagnosticSeverity.Error).ToList();
                if (errorList.Count != 0)
                {
                    throw new SyntaxErrorException(string.Join(Environment.NewLine, errorList));
                }

                VisitCompilationUnit((CompilationUnitSyntax)tree.GetRoot());
            }

            this.mode = GeneratorMode.GenerateCode;
            this.collectedClasses.Values.Consume(VisitCombinedClass);
        }
 private void SwitchGeneratorMode(GeneratorMode mode)
 {
     CurrentModelIndex    = 0;
     VoxelFilePath        = "";
     CurrentGeneratorMode = mode;
     Data = VoxelData.CreateNewData();
     // Node Open
     if (Data)
     {
         foreach (var gp in Data.Groups)
         {
             if (!NodeOpen.ContainsKey(gp.Key))
             {
                 NodeOpen.Add(gp.Key, false);
             }
         }
     }
     // Switch Model
     SwitchModel(CurrentModelIndex);
     Load_Generation();
     DataDirty = false;
 }
Example #25
0
 public static IAssetGenerator CreateGenerator(this GeneratorMode mode) =>
 mode == GeneratorMode.AppIconIos || mode == GeneratorMode.iOS
         ? (IAssetGenerator) new IosAssetGenerator()
         : mode == GeneratorMode.AppIconUWP || mode == GeneratorMode.UWP
             ? (IAssetGenerator) new UWPAssetGenerator()
             : new AndroidAssetGenerator();
Example #26
0
        private static void SetGeneratorMode(string dirName, string arg)
        {
            switch (arg)
            {
                case "gl":
                case "gl2":
                    mode = GeneratorMode.GL2;
                    Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
                    break;

                case "gl3":
                case "gl4":
                    mode = GeneratorMode.GL2;
                    Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL4";
                    break;

                case "es10":
                    mode = GeneratorMode.ES10;
                    Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES10";
                    break;

                case "es11":
                    mode = GeneratorMode.ES11;
                    Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES11";
                    break;

                case "es2":
                case "es20":
                    mode = GeneratorMode.ES20;
                    Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES20";
                    break;

                case "es3":
                case "es30":
                    mode = GeneratorMode.ES30;
                    Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES30";
                    break;

                case "cl":
                case "cl10":
                    mode = GeneratorMode.CL10;
                    Settings.DefaultOutputNamespace = "OpenTK.Compute.OpenCL";
                    break;

                default:
                    throw new NotSupportedException();
            }
        }
Example #27
0
 public static bool IsAppIcon(this GeneratorMode mode) =>
 mode == GeneratorMode.AppIconAndroid || mode == GeneratorMode.AppIconIos || mode == GeneratorMode.AppIconUWP;
Example #28
0
 protected static BuildConstants CreateBuildConstants(string intermediateOutputPath = DefaultIntermediateOutputPath, string targetPath = DefaultTargetPath, GeneratorMode generatorMode = GeneratorMode.MsBuild)
 => new BuildConstants(
     intermediateOutputPath: intermediateOutputPath,
     targetPath: targetPath,
     generatorMode: generatorMode
     );
Example #29
0
 /// <summary>
 /// Creates the options for the specified generator mode.
 /// </summary>
 /// <param name="generatorMode">The mode.</param>
 /// <returns>TypeNameGeneratorOptions.</returns>
 /// <autogeneratedoc />
 public static TypeNameGeneratorOptions Create(GeneratorMode generatorMode)
 {
     return(new TypeNameGeneratorOptions {
         Access = true, Modifiers = true, Name = true
     });
 }
Example #30
0
        static void Main(string[] arguments)
        {
            Debug.Listeners.Clear();
            Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
            Debug.AutoFlush = true;
            Trace.Listeners.Clear();
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
            Trace.AutoFlush = true;

            Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
                System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
            //Console.WriteLine(" - the OpenTK team ;-)");
            Console.WriteLine();

            try
            {
                foreach (string a in arguments)
                {
                    if (a.StartsWith("--") || a.StartsWith("-") || a.StartsWith("/"))
                    {
                        string[] b = a.Split(new char[] { '-', ':', '=' }, StringSplitOptions.RemoveEmptyEntries);
                        switch (b[0])
                        {
                            case "?":
                            case "help":
                                ShowHelp();
                                return;
                            case "in":
                            case "input":
                                Settings.InputPath = b[1];
                                break;
                            case "out":
                            case "output":
                                Settings.OutputPath = b[1];
                                break;
                            case "mode":
                                string arg = b[1].ToLower();
                                mode =
                                    arg == "gl" ? GeneratorMode.GL2 : 
                                    arg == "gl2" ? GeneratorMode.GL2 : 
                                    arg == "gl3" ? GeneratorMode.GL3 :
                                    arg == "wgl" ? GeneratorMode.Wgl : 
                                    arg == "glu" ? GeneratorMode.Glu :
                                    arg == "glx" ? GeneratorMode.Glx : GeneratorMode.Unknown;
                                if (mode == GeneratorMode.Unknown)
                                    throw new ArgumentException(String.Format("Mode {0} unknown.", arg));
                                break;
                            case "namespace":
                            case "ns":
                                Settings.OutputNamespace = b[1];
                                break;
                            case "class":
                                Settings.OutputClass = b[1];
                                break;
                            case "gl":
                                Settings.GLClass = b[1];
                                break;
                            case "legacy":
                            case "o":
                            case "option":
                                Settings.Compatibility |= b[1].ToLower().Contains("tao") ? Settings.Legacy.Tao : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower().Contains("enums") ? Settings.Legacy.NoAdvancedEnumProcessing : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower().Contains("safe") ? Settings.Legacy.NoPublicUnsafeFunctions : Settings.Legacy.None;
                                //Settings.Compatibility |= b[1].ToLower().Contains("novoid") ? Settings.Legacy.TurnVoidPointersToIntPtr : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower().Contains("permutations") ? Settings.Legacy.GenerateAllPermutations : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower().Contains("enums_in_class") ? Settings.Legacy.NestedEnums : Settings.Legacy.None;
                                break;
                            default:
                                throw new ArgumentException(
                                    String.Format("Argument {0} not recognized. Use the '/?' switch for help.", a)
                                );
                        }
                    }
                }
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Argument error ({0}). Please use the '-?' switch for help.", e.ToString());
                return;
            }
            catch (ArgumentException e)
            {
                Console.WriteLine("Argument error ({0}). Please use the '-?' switch for help.", e.ToString());
                return;
            }

            try
            {
                long ticks = System.DateTime.Now.Ticks;

                switch (mode)
                {
                    case GeneratorMode.GL2:
                        Generator = new Bind.GL2.Generator();
                        break;

                    case GeneratorMode.Wgl:
                        Generator = new Bind.Wgl.Generator();
                        break;

                    case GeneratorMode.Glu:
                        Generator = new Bind.Glu.Generator();
                        break;

                    case GeneratorMode.Glx:
                        Generator = new Bind.Glx.Generator();
                        break;

                    case GeneratorMode.GL3:
                        throw new NotImplementedException(String.Format("Mode {0} not implemented.", mode));
                    
                    case GeneratorMode.Unknown:
                    default:
                        Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl3/glu/wgl/glx])'");
                        return;
                        
                }

                Generator.Process();

                ticks = System.DateTime.Now.Ticks - ticks;

                Console.WriteLine();
                Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
                Console.WriteLine();
                //Console.WriteLine("Press any key to continue...");
                Console.ReadKey(true);
            }
            catch (SecurityException e)
            {
                Console.WriteLine("Security violation \"{0}\" in method \"{1}\".", e.Message, e.Method);
                Console.WriteLine("This application does not have permission to take the requested actions.");
            }
            catch (NotImplementedException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("The requested functionality is not implemented yet.");
            }
        }
Example #31
0
        static void Main(string[] arguments)
        {
            Debug.Listeners.Clear();
            Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
            Debug.AutoFlush = true;
            Trace.Listeners.Clear();
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
            Trace.AutoFlush = true;

            Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
                Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
            Console.WriteLine();

            string dirName =  null;

            try
            {
                foreach (string a in arguments)
                {
                    if (a.StartsWith("--") || a.StartsWith("-") || a.StartsWith("/"))
                    {
                        string[] b = a.Split(new char[] { '-', '/', ':', '=' }, StringSplitOptions.RemoveEmptyEntries);
                        switch (b[0])
                        {
                            case "?":
                            case "help":
                                ShowHelp();
                                return;
                            case "in":
                            case "input":
                                Settings.InputPath = string.Join(Path.DirectorySeparatorChar.ToString(), b.Skip(1).ToArray());
                                break;
                            case "out":
                            case "output":
                                Settings.OutputPath = string.Join(Path.DirectorySeparatorChar.ToString(), b.Skip(1).ToArray());
                                break;
                            case "mode":
                                string arg = b[1].ToLower();
                                if (arg == "gl" || arg == "gl2")
                                    mode = GeneratorMode.GL2;
                                else if (arg == "es10")
                                    mode = GeneratorMode.ES10;
                                else if (arg == "es11")
                                    mode = GeneratorMode.ES11;
                                else if (arg == "es20")
                                    mode = GeneratorMode.ES20;
                                else if (arg=="cl" || arg == "cl10")
                                    mode = GeneratorMode.CL10;
                                else
                                    throw new NotImplementedException();
                                if (b.Length > 2)
                                    dirName = b[2];
                                break;
                            case "namespace":
                            case "ns":
                                Settings.OutputNamespace = b[1];
                                break;
                            case "class":
                                Settings.OutputClass = b[1];
                                break;
                            case "gl":
                                Settings.GLClass = b[1];
                                break;
                            case "legacy":
                            case "o":
                            case "option":
                                Settings.Compatibility |= b[1].ToLower() == "tao" ? Settings.Legacy.Tao : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower() == "simple_enums" ? Settings.Legacy.NoAdvancedEnumProcessing : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower() == "safe" ? Settings.Legacy.NoPublicUnsafeFunctions : Settings.Legacy.None;
                                //Settings.Compatibility |= b[1].ToLower().Contains("novoid") ? Settings.Legacy.TurnVoidPointersToIntPtr : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower() == "permutations" ? Settings.Legacy.GenerateAllPermutations : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower() == "enums_in_class" ? Settings.Legacy.NestedEnums : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower() == "nodocs" ? Settings.Legacy.NoDocumentation : Settings.Legacy.None;
                                Settings.Compatibility |= b[1].ToLower() == "keep_untyped_enums" ? Settings.Legacy.KeepUntypedEnums : Settings.Legacy.None;
                                break;
                            default:
                                throw new ArgumentException(
                                    String.Format("Argument {0} not recognized. Use the '/?' switch for help.", a)
                                );
                        }
                    }
                }
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Argument error ({0}). Please use the '-?' switch for help.", e.ToString());
                return;
            }
            catch (ArgumentException e)
            {
                Console.WriteLine("Argument error ({0}). Please use the '-?' switch for help.", e.ToString());
                return;
            }

            try
            {
                long ticks = DateTime.Now.Ticks;

                switch (mode)
                {
                    case GeneratorMode.GL2:
                        Generator = new Generator();
                        break;

                    case GeneratorMode.ES10:
                        Generator = new ESGenerator("ES10", dirName);
                        break;
                    
                    case GeneratorMode.ES11:
                        Generator = new ESGenerator("ES11", dirName);
                        break;
                    
                    case GeneratorMode.ES20:
                        Generator = new ESGenerator("ES20", dirName);
                        break;

                    case GeneratorMode.CL10:
                        Generator = new CLGenerator("CL10", dirName);
                        break;
                    
                    case GeneratorMode.Wgl:
                        Generator = new Wgl.Generator();
                        break;

                    case GeneratorMode.Glu:
                        Generator = new Glu.Generator();
                        break;

                    case GeneratorMode.Glx:
                        Generator = new Glx.Generator();
                        break;

                    case GeneratorMode.GL3:
                        throw new NotImplementedException(String.Format("Mode {0} not implemented.", mode));

                    case GeneratorMode.Unknown:
                    default:
                        Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl3/glu/wgl/glx])'");
                        return;

                }

                Generator.Process();

                ticks = DateTime.Now.Ticks - ticks;

                Console.WriteLine();
                Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
                Console.WriteLine();
            }
            catch (SecurityException e)
            {
                Console.WriteLine("Security violation \"{0}\" in method \"{1}\".", e.Message, e.Method);
                Console.WriteLine("This application does not have permission to take the requested actions.");
            }
            catch (NotImplementedException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("The requested functionality is not implemented yet.");
            }
        }
Example #32
0
 protected static BuildConstants CreateBuildConstants(string intermediateOutputPath = DefaultIntermediateOutputPath, string targetPath = DefaultTargetPath, GeneratorMode generatorMode = GeneratorMode.MsBuild)
     => new BuildConstants(
         intermediateOutputPath: intermediateOutputPath, 
         targetPath: targetPath,
         generatorMode: generatorMode
     );
 private static async Task GenerateIcons(string filePath, string destinationDirectory, int quality, GeneratorMode mode) =>
 await mode.CreateGenerator().CreateIcon(filePath, Path.GetFileNameWithoutExtension(filePath),
                                         destinationDirectory, quality);
Example #34
0
        public CodeCompileUnit GenerateDotNetCode(MgaProject project, string paradigmXmpFile, string outputDir, GeneratorMode mode)
        {
            //paradigm = MgaMeta.DsmlModel.GetParadigm(paradigmXmpFile);
            Generator.Configuration.DsmlModel = new MgaMeta.DsmlModel(paradigmXmpFile);
            // Important step
            //Generator.Configuration.LocalFactory.Clear();
            Generator.Configuration.DsmlName = project.RootFolder.Name;
            List <MgaObject> all = new List <MgaObject>();

            // TODO: add version
            //var fileVersion = new CodeAttributeDeclaration() {
            //    Name = "AssemblyFileVersionAttribute",
            //};

            //var version = new CodeAttributeDeclaration()
            //{
            //    Name = "AssemblyVersion"
            //};
            //fileVersion.Arguments.Add(new CodeAttributeArgument("AssemblyFileVersionAttribute", new CodeSnippetExpression("1.0.0.*")));
            //version.Arguments.Add(new CodeAttributeArgument(new CodeSnippetExpression("1.0.0.*")));

            //compileunit.AssemblyCustomAttributes.Add(fileVersion);
            //compileunit.AssemblyCustomAttributes.Add(version);

            all.AddRange(
                FlattenMga <IMgaObject>(project.RootFolder, x => x.ChildObjects.Cast <MgaObject>()).
                Cast <MgaObject>());

            int countImplIntInheritance = all.
                                          Where(x =>
                                                x.MetaBase.Name == "ImplementationInheritance" ||
                                                x.MetaBase.Name == "InterfaceInheritance").Count();

            if (countImplIntInheritance > 0)
            {
                throw new NotSupportedException("ImplementationInheritance and InterfaceInheritance elements are not supported.");
            }

            List <string> l = new List <string>();

            l.Add("Atom");
            l.Add("Model");
            l.Add("Reference");
            l.Add("FCO");
            l.Add("Connection");
            l.Add("Set");
            l.Add("Folder");
            l.Add("RootFolder");

            Func <MgaObject, bool> condition =
                new Func <MgaObject, bool>(x => l.Contains(x.MetaBase.Name));

            GMEConsole.Info.WriteLine("Processing graph...");

            CodeCompileUnit compileunit = new CodeCompileUnit();

            foreach (var obj in all.Where(condition))
            {
                if (obj.MetaBase.Name == "RootFolder" &&
                    string.IsNullOrEmpty((obj as MgaFolder).LibraryName) == false)
                {
                    //throw new NotSupportedException("Attached libraries are not supported yet.");
                    continue;
                }

                GMEConsole.Info.WriteLine("{0} {1} {2}", obj.Name, obj.MetaBase.Name, obj.ObjType);
                Generator.FCO b = new Generator.FCO(
                    obj,
                    new CodeTypeReferenceCollection(),
                    new CodeTypeReferenceCollection());

                // assumption we have two namespaces only
                //  (this is the main global namespace for classes/interfaces , other
                //  namespaces, which are defined in the project will be under this namespace.)
                // - one for the classes
                // - one for the interfaces
                CodeNamespace nsClass = compileunit.Namespaces.
                                        Cast <CodeNamespace>().
                                        FirstOrDefault(x => x.Name == b.GeneratedClass.Name);

                if (nsClass == null)
                {
                    compileunit.Namespaces.Add(b.GeneratedClass);
                }
                else
                {
                    nsClass.Types.AddRange(b.GeneratedClass.Types);
                }

                CodeNamespace nsInterface = compileunit.Namespaces.
                                            Cast <CodeNamespace>().
                                            FirstOrDefault(x => x.Name == b.GeneratedInterface.Name);

                if (nsClass == null)
                {
                    compileunit.Namespaces.Add(b.GeneratedInterface);
                }
                else
                {
                    nsInterface.Types.AddRange(b.GeneratedInterface.Types);
                }
            }


            // TODO: a lot of parameters must be set based on the user's choice.
            CodeDomGenerateCode(
                CodeDomProvider.CreateProvider(language),
                compileunit,
                Path.Combine(outputDir, project.Name),
                mode);

            GMEConsole.Info.WriteLine("API has been generated.");
            return(compileunit);
        }
Example #35
0
        private static void SetGeneratorMode(string arg)
        {
            switch (arg)
            {
                case "gl":
                case "gl2":
                    mode = GeneratorMode.GL2;
                    break;

                case "gl3":
                case "gl4":
					mode = GeneratorMode.GL4;
                    break;

                case "es10":
                    mode = GeneratorMode.ES10;
                    break;

                case "es11":
                    mode = GeneratorMode.ES11;
                    break;

                case "es2":
                case "es20":
                    mode = GeneratorMode.ES20;
                    break;

                case "es3":
                case "es30":
                    mode = GeneratorMode.ES30;
                    break;

                case "es31":
                    mode = GeneratorMode.ES31;
                    break;

                case "cl":
                case "cl10":
                    mode = GeneratorMode.CL10;
                    break;

                default:
                    throw new NotSupportedException();
            }
        }
Example #36
0
 private static void SetGeneratorMode(string dirName, string arg)
 {
     if (arg == "gl" || arg == "gl2" || arg == "gl3" || arg == "gl4")
     {
         mode = GeneratorMode.GL2;
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
     }
     else if (arg == "es10")
     {
         mode = GeneratorMode.ES10;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES10";
     }
     else if (arg == "es11")
     {
         mode = GeneratorMode.ES11;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES11";
     }
     else if (arg == "es20")
     {
         mode = GeneratorMode.ES20;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES20";
     }
     else if (arg == "es30")
     {
         mode = GeneratorMode.ES30;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES30";
     }
     else if (arg == "es31")
     {
         mode = GeneratorMode.ES31;
         Settings.DefaultOutputPath = Path.Combine(
             Directory.GetParent(Settings.DefaultOutputPath).ToString(),
             dirName);
         Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES31";
     }
     else if (arg == "cl" || arg == "cl10")
     {
         mode = GeneratorMode.CL10;
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Example #37
0
        public List <string> CodeDomGenerateCode(
            CodeDomProvider provider,
            CodeCompileUnit compileunit,
            string outputFileName = "",
            GeneratorMode mode    = GeneratorMode.OneFile)
        {
            GMEConsole.Info.WriteLine("Generating source code.");
            string outputDir = Path.GetDirectoryName(outputFileName);

            List <string> sourceFiles = new List <string>();

            CodeGeneratorOptions options = new CodeGeneratorOptions();

            options.BlankLinesBetweenMembers = true;
            options.BracingStyle             = "C";
            options.IndentString             = "\t";

            if (mode == GeneratorMode.OneFile)
            {
                string fileName = "TestAPI";
                if (string.IsNullOrEmpty(outputFileName) == false)
                {
                    fileName = Path.GetFileNameWithoutExtension(outputFileName);
                }

                // Build the source file name with the appropriate
                // language extension.
                String sourceFile;
                if (provider.FileExtension[0] == '.')
                {
                    sourceFile = fileName + provider.FileExtension;
                }
                else
                {
                    sourceFile = fileName + "." + provider.FileExtension;
                }

                // Create an IndentedTextWriter, constructed with
                // a StreamWriter to the source file.
                IndentedTextWriter tw = new IndentedTextWriter(
                    new StreamWriter(sourceFile, false));
                sourceFiles.Add(sourceFile);

                // Generate source code using the code generator.
                provider.GenerateCodeFromCompileUnit(compileunit, tw, options);

                GMEConsole.Info.WriteLine("- {0}", Path.GetFullPath(sourceFile));
                // Close the output file.
                tw.Close();
            }
            else if (mode == GeneratorMode.Namespaces)
            {
                foreach (CodeNamespace ns in compileunit.Namespaces)
                {
                    // Build the source file name with the appropriate
                    // language extension.
                    String sourceFile;
                    if (provider.FileExtension[0] == '.')
                    {
                        sourceFile = ns.Name + provider.FileExtension;
                    }
                    else
                    {
                        sourceFile = ns.Name + "." + provider.FileExtension;
                    }
                    sourceFile = Path.Combine(outputDir, sourceFile);

                    CodeCompileUnit ccu = new CodeCompileUnit();
                    ccu.Namespaces.Add(ns);

                    // Create an IndentedTextWriter, constructed with
                    // a StreamWriter to the source file.
                    IndentedTextWriter tw = new IndentedTextWriter(
                        new StreamWriter(sourceFile, false));
                    sourceFiles.Add(sourceFile);

                    // Generate source code using the code generator.
                    provider.GenerateCodeFromCompileUnit(ccu, tw, options);
                    GMEConsole.Info.WriteLine("- {0}", Path.GetFullPath(sourceFile));
                    // Close the output file.
                    tw.Close();
                }
            }
            else if (mode == GeneratorMode.Many)
            {
                foreach (CodeNamespace ns in compileunit.Namespaces)
                {
                    foreach (CodeTypeDeclaration ctd in ns.Types)
                    {
                        CodeNamespace nsNew = new CodeNamespace()
                        {
                            Name = ns.Name,
                        };
                        nsNew.Imports.AddRange(ns.Imports.Cast <CodeNamespaceImport>().ToArray());
                        nsNew.Comments.AddRange(ns.Comments.Cast <CodeCommentStatement>().ToArray());

                        // only one type (class or interface)
                        nsNew.Types.Add(ctd);

                        // Build the source file name with the appropriate
                        // language extension.
                        String sourceFile;
                        if (provider.FileExtension[0] == '.')
                        {
                            sourceFile = nsNew.Name + "." + ctd.Name + provider.FileExtension;
                        }
                        else
                        {
                            sourceFile = nsNew.Name + "." + ctd.Name + "." + provider.FileExtension;
                        }
                        sourceFile = Path.Combine(outputDir, sourceFile);

                        CodeCompileUnit ccu = new CodeCompileUnit();
                        ccu.Namespaces.Add(nsNew);

                        // Create an IndentedTextWriter, constructed with
                        // a StreamWriter to the source file.
                        IndentedTextWriter tw = new IndentedTextWriter(
                            new StreamWriter(sourceFile, false));
                        sourceFiles.Add(sourceFile);

                        // Generate source code using the code generator.
                        provider.GenerateCodeFromCompileUnit(ccu, tw, options);
                        GMEConsole.Info.WriteLine("- {0}", Path.GetFullPath(sourceFile));
                        // Close the output file.
                        tw.Close();
                    }
                }
            }
            return(sourceFiles);
        }