Exemplo n.º 1
0
        public bool IsHidden(Parameter p)
        {
            int idx = param_list.IndexOf(p);

            if (idx > 0 && p.IsLength && p.PassAs == String.Empty && this [idx - 1].IsString)
            {
                return(true);
            }

            if (p.IsCount)
            {
                return(true);
            }

            if (p.IsHidden)
            {
                return(true);
            }

            if (p.CType == "GError**" && Throws)
            {
                return(true);
            }

            if (HasCB || HideData)
            {
                if (Parser.GetVersion(elem.OwnerDocument.DocumentElement) >= 3)
                {
                    foreach (Parameter param in param_list)
                    {
                        if (param.Closure == idx)
                        {
                            return(true);
                        }
                        if (param.DestroyNotify == idx)
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    if (p.IsUserData && (idx == Count - 1))
                    {
                        return(true);
                    }
                    if (p.IsUserData && (idx == Count - 2) && this [Count - 1] is ErrorParameter)
                    {
                        return(true);
                    }
                    if (p.IsUserData && idx > 0 && this [idx - 1].Generatable is CallbackGen)
                    {
                        return(true);
                    }
                    if (p.IsDestroyNotify && (idx == Count - 1) && this [idx - 1].IsUserData)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 2
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);
        }