상속: GtkSharp.Generation.MethodBase
예제 #1
0
        void GetSpecialMethods(out Method ref_, out Method unref, out Method dispose)
        {
            ref_ = CheckSpecialMethod (GetMethod ("Ref"));
            unref = CheckSpecialMethod (GetMethod ("Unref"));

            dispose = GetMethod ("Free");
            if (dispose == null) {
                dispose = GetMethod ("Destroy");
                if (dispose == null)
                    dispose = GetMethod ("Dispose");
            }
            dispose = CheckSpecialMethod (dispose);
        }
예제 #2
0
        Method CheckSpecialMethod(Method method)
        {
            if (method == null)
                return null;
            if (method.ReturnType != "void" &&
                method.ReturnType != QualifiedName)
                return null;
            if (method.Signature.ToString () != "")
                return null;

            methods.Remove (method.Name);
            return method;
        }
예제 #3
0
		protected bool IgnoreMethod (Method method, ClassBase implementor)
		{	
			if (implementor != null && implementor.QualifiedName != this.QualifiedName && method.IsStatic)
				return true;

			string mname = method.Name;
			return ((method.IsSetter || (method.IsGetter && mname.StartsWith("Get"))) &&
				((props != null) && props.ContainsKey(mname.Substring(3)) ||
				 (fields != null) && fields.ContainsKey(mname.Substring(3))));
		}
예제 #4
0
		public InterfaceVM (XmlElement elem, Method target, ObjectBase container_type) : base (elem, container_type)
		{
			this.target = target;
			parms.HideData = true;
			this.Protection = "public";
		}
예제 #5
0
		void GetSpecialMethods (out Method ref_, out Method unref, out Method dispose, out Method set_gvalue)
		{
			ref_ = CheckSpecialMethod (GetMethod ("Ref"));
			unref = CheckSpecialMethod (GetMethod ("Unref"));

			dispose = GetMethod ("Free");
			if (dispose == null) {
				dispose = GetMethod ("Destroy");
				if (dispose == null)
					dispose = GetMethod ("Dispose");
			}
			dispose = CheckSpecialMethod (dispose);

			set_gvalue = GetMethod ("SetGValue");
			Methods.Remove ("SetGValue");
		}
예제 #6
0
        public override void Generate(GenerationInfo gen_info)
        {
            gen_info.CurrentType = QualifiedName;

            string        asm_name = gen_info.AssemblyName.Length == 0 ? NS.ToLower() + "-sharp" : gen_info.AssemblyName;
            DirectoryInfo di       = GetDirectoryInfo(gen_info.Dir, asm_name);

            StreamWriter sw = gen_info.Writer = gen_info.OpenStream(Name);

            sw.WriteLine("namespace " + NS + " {");
            sw.WriteLine();
            sw.WriteLine("\tusing System;");
            sw.WriteLine("\tusing System.Collections;");
            sw.WriteLine("\tusing System.Runtime.InteropServices;");
            sw.WriteLine();

            SymbolTable table = SymbolTable.Table;

            sw.WriteLine("#region Autogenerated code");
            if (IsDeprecated)
            {
                sw.WriteLine("\t[Obsolete]");
            }
            foreach (string attr in custom_attrs)
            {
                sw.WriteLine("\t" + attr);
            }
            sw.Write("\t{0} partial {1}class " + Name, IsInternal ? "internal" : "public", IsAbstract ? "abstract " : "");
            string cs_parent = table.GetCSType(Elem.GetAttribute("parent"));

            if (cs_parent != "")
            {
                di.objects.Add(CName, QualifiedName);
                sw.Write(" : " + cs_parent);
            }
            foreach (string iface in interfaces)
            {
                if (Parent != null && Parent.Implements(iface))
                {
                    continue;
                }
                sw.Write(", " + table.GetCSType(iface));
            }
            foreach (string iface in managed_interfaces)
            {
                if (Parent != null && Parent.Implements(iface))
                {
                    continue;
                }
                sw.Write(", " + iface);
            }
            sw.WriteLine(" {");
            sw.WriteLine();

            GenCtors(gen_info);
            GenProperties(gen_info, null);
            GenFields(gen_info);
            GenChildProperties(gen_info);

            bool has_sigs = (sigs != null && sigs.Count > 0);

            if (!has_sigs)
            {
                foreach (string iface in interfaces)
                {
                    InterfaceGen igen = table.GetClassGen(iface) as InterfaceGen;
                    if (igen != null && igen.Signals != null)
                    {
                        has_sigs = true;
                        break;
                    }
                }
            }

            if (has_sigs && Elem.HasAttribute("parent"))
            {
                GenSignals(gen_info, null);
            }

            GenClassMembers(gen_info, cs_parent);
            GenMethods(gen_info, null, null);

            if (interfaces.Count != 0)
            {
                Hashtable all_methods = new Hashtable();
                foreach (Method m in Methods.Values)
                {
                    all_methods[m.Name] = m;
                }
                Hashtable collisions = new Hashtable();
                foreach (string iface in interfaces)
                {
                    ClassBase igen = table.GetClassGen(iface);
                    foreach (Method m in igen.Methods.Values)
                    {
                        if (m.Name.StartsWith("Get") || m.Name.StartsWith("Set"))
                        {
                            if (GetProperty(m.Name.Substring(3)) != null)
                            {
                                collisions[m.Name] = true;
                                continue;
                            }
                        }
                        Method collision = all_methods[m.Name] as Method;
                        if (collision != null && collision.Signature.Types == m.Signature.Types)
                        {
                            collisions[m.Name] = true;
                        }
                        else
                        {
                            all_methods[m.Name] = m;
                        }
                    }
                }

                foreach (string iface in interfaces)
                {
                    if (Parent != null && Parent.Implements(iface))
                    {
                        continue;
                    }
                    InterfaceGen igen = table.GetClassGen(iface) as InterfaceGen;
                    igen.GenMethods(gen_info, collisions, this);
                    igen.GenProperties(gen_info, this);
                    igen.GenSignals(gen_info, this);
                    igen.GenVirtualMethods(gen_info, this);
                }
            }

            foreach (XmlElement str in strings)
            {
                sw.Write("\t\tpublic static string " + str.GetAttribute("name"));
                sw.WriteLine(" {\n\t\t\t get { return \"" + str.GetAttribute("value") + "\"; }\n\t\t}");
            }

            if (cs_parent != String.Empty && GetExpected(CName) != QualifiedName)
            {
                sw.WriteLine();
                sw.WriteLine("\t\tstatic " + Name + " ()");
                sw.WriteLine("\t\t{");
                sw.WriteLine("\t\t\tGtkSharp." + Studlify(asm_name) + ".ObjectManager.Initialize ();");
                sw.WriteLine("\t\t}");
            }

            sw.WriteLine("#endregion");
            AppendCustom(sw, gen_info.CustomDir);

            sw.WriteLine("\t}");
            sw.WriteLine("}");

            sw.Close();
            gen_info.Writer = null;
            Statistics.ObjectCount++;
        }