Exemplo n.º 1
0
        public bool Validate()
        {
            if (valid)
            {
                return(true);
            }

            if (elem == null)
            {
                return(false);
            }

            for (int i = 0; i < elem.ChildNodes.Count; i++)
            {
                var parm = elem.ChildNodes [i] as XmlElement;
                if (parm == null || parm.Name != "parameter")
                {
                    continue;
                }
                var p = new Parameter(parm);

                if (p.IsEllipsis)
                {
                    Console.Write("Ellipsis parameter ");
                    Clear();
                    return(false);
                }

                if ((p.CSType == "") || (p.Name == "") ||
                    (p.MarshalType == "") || (SymbolTable.Table.CallByName(p.CType, p.Name) == ""))
                {
                    Console.Write("Name: " + p.Name + " Type: " + p.CType + " ");
                    Clear();
                    return(false);
                }

                var gen = p.Generatable;

                if (p.IsArray)
                {
                    p = new ArrayParameter(parm);
                    if (i < elem.ChildNodes.Count - 1)
                    {
                        var next = elem.ChildNodes [i + 1] as XmlElement;
                        if (next != null || next.Name == "parameter")
                        {
                            var c = new Parameter(next);
                            if (c.IsCount)
                            {
                                p = new ArrayCountPair(parm, next, false);
                                i++;
                            }
                        }
                    }
                }
                else if (p.IsCount && i < elem.ChildNodes.Count - 1)
                {
                    var next = elem.ChildNodes [i + 1] as XmlElement;
                    if (next != null || next.Name == "parameter")
                    {
                        var a = new Parameter(next);
                        if (a.IsArray)
                        {
                            p = new ArrayCountPair(next, parm, true);
                            i++;
                        }
                    }
                }
                else if (p.CType == "GError**")
                {
                    p = new ErrorParameter(parm);
                }
                else if (gen is StructBase || gen is ByRefGen)
                {
                    p = new StructParameter(parm);
                }
                else if (gen is CallbackGen)
                {
                    HasCB = true;
                }
                param_list.Add(p);
            }

            if (HasCB && Count > 2 && this [Count - 3].Generatable is CallbackGen && this [Count - 2].IsUserData && this [Count - 1].IsDestroyNotify)
            {
                this [Count - 3].Scope = "notified";
            }

            valid = true;
            return(true);
        }
Exemplo n.º 2
0
        public bool Validate()
        {
            if (valid)
                return true;

            if (elem == null)
                return false;

            for (int i = first_is_instance ? 1 : 0; i < elem.ChildNodes.Count; i++) {
                XmlElement parm = elem.ChildNodes [i] as XmlElement;
                if (parm == null || parm.Name != "parameter")
                    continue;
                Parameter p = new Parameter (parm);

                if (p.IsEllipsis) {
                    Console.Write("Ellipsis parameter ");
                    Clear ();
                    return false;
                }

                if ((p.CSType == "") || (p.Name == "") ||
                    (p.MarshalType == "") || (SymbolTable.Table.CallByName(p.CType, p.Name) == "")) {
                    Console.Write ("Invalid parameter {0} of type {1}", p.Name, p.CType);
                    Clear ();
                    return false;
                }

                IGeneratable gen = p.Generatable;

                if (p.IsArray) {
                    p = new ArrayParameter (parm);
                    if (i < elem.ChildNodes.Count - 1) {
                        XmlElement next = elem.ChildNodes [i + 1] as XmlElement;
                        if (next != null || next.Name == "parameter") {
                            Parameter c = new Parameter (next);
                            if (c.IsCount) {
                                p = new ArrayCountPair (parm, next, false);
                                i++;
                            }
                        }
                    }
                } else if (p.IsCount && i < elem.ChildNodes.Count - 1) {
                    XmlElement next = elem.ChildNodes [i + 1] as XmlElement;
                    if (next != null || next.Name == "parameter") {
                        Parameter a = new Parameter (next);
                        if (a.IsArray) {
                            p = new ArrayCountPair (next, parm, true);
                            i++;
                        }
                    }
                } else if (p.CType == "GError**")
                    p = new ErrorParameter (parm);
                else if (gen is StructBase || gen is ByRefGen) {
                    p = new StructParameter (parm);
                } else if (gen is CallbackGen) {
                    has_cb = true;
                }
                param_list.Add (p);
            }

            if (has_cb && Count > 2 && this [Count - 3].Generatable is CallbackGen && this [Count - 2].IsUserData && this [Count - 1].IsDestroyNotify)
                this [Count - 3].Scope = "notified";

            valid = true;
            return true;
        }
Exemplo n.º 3
0
        public bool Validate(LogWriter log)
        {
            if (valid)
            {
                return(true);
            }

            if (elem == null)
            {
                return(false);
            }

            for (int i = first_is_instance ? 1 : 0; i < elem.ChildNodes.Count; i++)
            {
                XmlElement parm = elem.ChildNodes [i] as XmlElement;
                if (parm == null || parm.Name != "parameter")
                {
                    continue;
                }
                Parameter p = new Parameter(parm);

                if (p.IsEllipsis)
                {
                    log.Warn("Ellipsis parameter: hide and bind manually if no alternative exists. ");
                    Clear();
                    return(false);
                }

                if ((p.CSType == "") || (p.Name == "") ||
                    (p.MarshalType == "") || (SymbolTable.Table.CallByName(p.CType, p.Name) == ""))
                {
                    log.Warn("Unknown type {1} on parameter {0}", p.Name, p.CType);
                    Clear();
                    return(false);
                }

                if (p.IsOptional && p.PassAs == String.Empty && p.IsUserData == false)
                {
                    has_optional = true;
                }

                IGeneratable gen = p.Generatable;

                if (p.IsArray)
                {
                    p = new ArrayParameter(parm);
                    if (i < elem.ChildNodes.Count - 1)
                    {
                        XmlElement next = elem.ChildNodes [i + 1] as XmlElement;
                        if (next != null || next.Name == "parameter")
                        {
                            Parameter c = new Parameter(next);
                            if (c.IsCount)
                            {
                                p = new ArrayCountPair(parm, next, false);
                                i++;
                            }
                        }
                    }
                }
                else if (p.IsCount)
                {
                    p.IsCount = false;
                    if (i < elem.ChildNodes.Count - 1)
                    {
                        XmlElement next = elem.ChildNodes [i + 1] as XmlElement;
                        if (next != null || next.Name == "parameter")
                        {
                            Parameter a = new Parameter(next);
                            if (a.IsArray)
                            {
                                p = new ArrayCountPair(next, parm, true);
                                i++;
                            }
                        }
                    }
                }
                else if (p.CType == "GError**" && Throws)
                {
                    p = new ErrorParameter(parm);
                }
                else if (gen is StructBase || gen is ByRefGen)
                {
                    p = new StructParameter(parm);
                }
                else if (gen is CallbackGen)
                {
                    has_cb = true;
                }
                param_list.Add(p);
            }

            if (Parser.GetVersion(elem.OwnerDocument.DocumentElement) < 3 &&
                has_cb && Count > 2 && this [Count - 3].Generatable is CallbackGen && this [Count - 2].IsUserData && this [Count - 1].IsDestroyNotify)
            {
                this [Count - 3].Scope = "notified";
            }

            valid = true;
            return(true);
        }