Exemplo n.º 1
0
        void CreateNormalWrappers(List <Function> wrappers)
        {
            Function f = new Function(this);

            f.WrapReturnType();
            f.WrapParameters(wrappers);
        }
Exemplo n.º 2
0
        void CreateWrappers()
        {
            List <Function> wrappers = new List <Function>();

            if (!NeedsWrapper)
            {
                // No special wrapper needed - just call this delegate:
                Function f = new Function(this);
                f.CreateBody(false);

                wrappers.Add(f);
            }
            else
            {
                Function f = new Function(this);
                f.WrapReturnType();
                f.WrapParameters(wrappers);
            }

            // If the function is not CLS-compliant (e.g. it contains unsigned parameters)
            // we need to create a CLS-Compliant overload. However, we should only do this
            // iff the opengl function does not contain unsigned/signed overloads itself
            // to avoid redefinitions.
            foreach (Function f in wrappers)
            {
                Function.Wrappers.AddChecked(f);

                if (!f.CLSCompliant)
                {
                    Function cls = new Function(f);

                    cls.Body.Clear();
                    cls.CreateBody(true);

                    bool somethingChanged = false;
                    for (int i = 0; i < f.Parameters.Count; i++)
                    {
                        cls.Parameters[i].CurrentType = cls.Parameters[i].GetCLSCompliantType();
                        if (cls.Parameters[i].CurrentType != f.Parameters[i].CurrentType)
                        {
                            somethingChanged = true;
                        }
                    }

                    if (somethingChanged)
                    {
                        Function.Wrappers.AddChecked(cls);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void CreateUntypedEnumWrappers(List <Function> wrappers)
        {
            Function f        = new Function(this);
            var      modified = false;

            f.Parameters = new ParameterCollection(f.Parameters.Select(p =>
            {
                if (p.IsEnum && p.CurrentType != Settings.CompleteEnumName)
                {
                    p.CurrentType = Settings.CompleteEnumName;
                    modified      = true;
                }
                return(p);
            }));
            if (modified)
            {
                f.WrapReturnType();
                f.WrapParameters(wrappers);
            }
        }
Exemplo n.º 4
0
        public void CreateWrappers()
        {
            if (this.Name.Contains("ReadPixels"))
            {
            }

            List <Function> wrappers = new List <Function>();

            if (!NeedsWrapper)
            {
                // No special wrapper needed - just call this delegate:
                Function f = new Function(this);

                if (f.ReturnType.CurrentType.ToLower().Contains("void"))
                {
                    f.Body.Add(String.Format("{0};", f.CallString()));
                }
                else
                {
                    f.Body.Add(String.Format("return {0};", f.CallString()));
                }

                wrappers.Add(f);
            }
            else
            {
                Function f = new Function(this);
                f.WrapReturnType();
                if ((Settings.Compatibility & Settings.Legacy.GenerateAllPermutations) == Settings.Legacy.None)
                {
                    f.WrapParameters(wrappers);
                }
                else
                {
                    f.WrapParametersComplete(wrappers);
                }
            }

            // If the function is not CLS-compliant (e.g. it contains unsigned parameters)
            // we need to create a CLS-Compliant overload. However, we should only do this
            // iff the opengl function does not contain unsigned/signed overloads itself
            // to avoid redefinitions.
            foreach (Function f in wrappers)
            {
                Bind.Structures.Function.Wrappers.AddChecked(f);
                //Bind.Structures.Function.Wrappers.Add(f);

                if (!f.CLSCompliant)
                {
                    Function cls = new Function(f);

                    cls.Body.Clear();
                    if (!cls.NeedsWrapper)
                    {
                        cls.Body.Add((f.ReturnType.CurrentType != "void" ? "return " + this.CallString() : this.CallString()) + ";");
                    }
                    else
                    {
                        cls.CreateBody(true);
                        //cls.Body.AddRange(this.CreateBody(cls, true));
                    }

                    bool somethingChanged = false;
                    for (int i = 0; i < f.Parameters.Count; i++)
                    {
                        cls.Parameters[i].CurrentType = cls.Parameters[i].GetCLSCompliantType();
                        if (cls.Parameters[i].CurrentType != f.Parameters[i].CurrentType)
                        {
                            somethingChanged = true;
                        }
                    }

                    if (somethingChanged)
                    {
                        Bind.Structures.Function.Wrappers.AddChecked(cls);
                    }
                }
            }
        }