コード例 #1
1
ファイル: GObjectVM.cs プロジェクト: Gravecorp/gtk-sharp
 public GObjectVM(XmlElement elem, ObjectBase container_type)
     : base(elem, container_type)
 {
     parms.HideData = false;
     this.Protection = "protected";
     class_struct_name = container_type.ClassStructName;
 }
コード例 #2
0
ファイル: GObjectVM.cs プロジェクト: liberostelios/gtk-sharp
		protected virtual bool CanGenerate (GenerationInfo gen_info, ObjectBase implementor)
		{
			if (implementor != null || this.CName.Length == 0 || CodeType == VMCodeType.None || (CodeType == VMCodeType.Glue && !gen_info.GlueEnabled))
				return false;
			else
				return true;
		}
コード例 #3
0
ファイル: DefaultSignalHandler.cs プロジェクト: jwzl/ossbuild
		protected override void GenerateUnmanagedInvocation (GenerationInfo gen_info, ObjectBase implementor)
		{
			if (!base.CanGenerate (gen_info, implementor))
				GenerateChainVirtualMethod (gen_info.Writer, implementor);
			else
				base.GenerateUnmanagedInvocation (gen_info, implementor);
		}
コード例 #4
0
		public VirtualMethod (XmlElement elem, ObjectBase container_type) : base (elem, container_type)
		{
			if (container_type.ParserVersion == 1) {
				// The old pre 2.14 parser didn't drop the 1st parameter in all <signal> and <virtual_method> elements
				parms = new Parameters (elem ["parameters"], true);
			}
			retval = new ReturnValue (elem ["return-type"]);
		}
コード例 #5
0
ファイル: Signal.cs プロジェクト: shana/gtk-sharp
 public Signal(XmlElement elem, ObjectBase container_type)
 {
     this.elem = elem;
     name = elem.GetAttribute ("name");
     marshaled = elem.GetAttribute ("manual") == "true";
     retval = new ReturnValue (elem ["return-type"]);
     parms = new Parameters (elem["parameters"], container_type.ParserVersion == 1 ? true : false);
     this.container_type = container_type;
 }
コード例 #6
0
ファイル: GObjectVM.cs プロジェクト: jwzl/ossbuild
		public void Generate (GenerationInfo gen_info, ObjectBase implementor)
		{
			if (!CanGenerate (gen_info, implementor))
				throw new NotSupportedException (String.Format ("Cannot generate virtual method {0}.{1}. Make sure a writable glue path was provided to the generator.", container_type.Name, this.CallString));

			GenerateOverride (gen_info, implementor);
			GenerateCallback (gen_info.Writer, implementor);
			if (!IsStatic)
				GenerateUnmanagedInvocation (gen_info, implementor);
		}
コード例 #7
0
ファイル: DefaultSignalHandler.cs プロジェクト: jwzl/ossbuild
		protected override void GenerateOverride (GenerationInfo gen_info, ObjectBase implementor)
		{
			StreamWriter sw = gen_info.Writer;

			if (!base.CanGenerate (gen_info, implementor)) {
				GenerateOverrideBody (sw);
				sw.WriteLine ("\t\t\tOverrideVirtualMethod (gtype, \"{0}\", callback);", signal_name);
				sw.WriteLine ("\t\t}");
			} else
				base.GenerateOverride (gen_info, implementor);
		}
コード例 #8
0
ファイル: DefaultSignalHandler.cs プロジェクト: jwzl/ossbuild
		private void GenerateChainVirtualMethod (StreamWriter sw, ObjectBase implementor)
		{
			GenerateMethodBody (sw, implementor);
			if (retval.IsVoid)
				sw.WriteLine ("\t\t\tGst.GLib.Value ret = Gst.GLib.Value.Empty;");
			else
				sw.WriteLine ("\t\t\tGst.GLib.Value ret = new Gst.GLib.Value (" + ReturnGType + ");");

			sw.WriteLine ("\t\t\tGst.GLib.ValueArray inst_and_params = new Gst.GLib.ValueArray (" + (parms.Count + 1) + ");");
			sw.WriteLine ("\t\t\tGst.GLib.Value[] vals = new Gst.GLib.Value [" + (parms.Count + 1) + "];");
			sw.WriteLine ("\t\t\tvals [0] = new Gst.GLib.Value (this);");
			sw.WriteLine ("\t\t\tinst_and_params.Append (vals [0]);");
			string cleanup = "";
			for (int i = 0; i < parms.Count; i++) {
				Parameter p = parms [i];
				if (p.PassAs != "") {
					if (SymbolTable.Table.IsBoxed (p.CType)) {
						if (p.PassAs == "ref")
							sw.WriteLine ("\t\t\tvals [" + (i + 1) + "] = new Gst.GLib.Value (" + p.Name + ");");
						else
							sw.WriteLine ("\t\t\tvals [" + (i + 1) + "] = new Gst.GLib.Value ((Gst.GLib.GType)typeof (" + p.CSType + "));");
						cleanup += "\t\t\t" + p.Name + " = (" + p.CSType + ") vals [" + i + "];\n";
					} else {
						if (p.PassAs == "ref")
							sw.WriteLine ("\t\t\tIntPtr " + p.Name + "_ptr = Gst.GLib.Marshaller.StructureToPtrAlloc (" + p.Generatable.CallByName (p.Name) + ");");
						else
							sw.WriteLine ("\t\t\tIntPtr " + p.Name + "_ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + p.MarshalType + ")));");

						sw.WriteLine ("\t\t\tvals [" + (i + 1) + "] = new Gst.GLib.Value (" + p.Name + "_ptr);");
						cleanup += "\t\t\t" + p.Name + " = " + p.FromNative ("(" + p.MarshalType + ") Marshal.PtrToStructure (" + p.Name + "_ptr, typeof (" + p.MarshalType + "))") + ";\n";
						cleanup += "\t\t\tMarshal.FreeHGlobal (" + p.Name + "_ptr);\n";
					}
				} else if (p.IsLength && i > 0 && parms [i - 1].IsString)
					sw.WriteLine ("\t\t\tvals [" + (i + 1) + "] = new Gst.GLib.Value (System.Text.Encoding.UTF8.GetByteCount (" + parms [i-1].Name + "));");
				else
					sw.WriteLine ("\t\t\tvals [" + (i + 1) + "] = new Gst.GLib.Value (" + p.Name + ");");

				sw.WriteLine ("\t\t\tinst_and_params.Append (vals [" + (i + 1) + "]);");
			}

			sw.WriteLine ("\t\t\tg_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);");
			if (cleanup != "")
				sw.WriteLine (cleanup);
			sw.WriteLine ("\t\t\tforeach (Gst.GLib.Value v in vals)");
			sw.WriteLine ("\t\t\t\tv.Dispose ();");
			if (!retval.IsVoid) {
				IGeneratable igen = SymbolTable.Table [retval.CType];
				sw.WriteLine ("\t\t\t" + retval.CSType + " result = (" + (igen is EnumGen ? retval.CSType + ") (Enum" : retval.CSType) + ") ret;");
				sw.WriteLine ("\t\t\tret.Dispose ();");
				sw.WriteLine ("\t\t\treturn result;");
			}
			sw.WriteLine ("\t\t}\n");
		}
コード例 #9
0
ファイル: ObjectBase.cs プロジェクト: nuxleus/gtk-sharp
 public void GenSignals(GenerationInfo gen_info, ObjectBase implementor)
 {
     foreach (Signal sig in sigs.Values)
         sig.Generate (gen_info, implementor);
 }
コード例 #10
0
        private void GenerateChainVirtualMethod(StreamWriter sw, ObjectBase implementor)
        {
            GenerateMethodBody(sw, implementor);
            if (retval.IsVoid)
            {
                sw.WriteLine("\t\t\tGLib.Value ret = GLib.Value.Empty;");
            }
            else
            {
                sw.WriteLine("\t\t\tGLib.Value ret = new GLib.Value (" + ReturnGType + ");");
            }

            sw.WriteLine("\t\t\tGLib.ValueArray inst_and_params = new GLib.ValueArray (" + (parms.Count + 1) + ");");
            sw.WriteLine("\t\t\tGLib.Value[] vals = new GLib.Value [" + (parms.Count + 1) + "];");
            sw.WriteLine("\t\t\tvals [0] = new GLib.Value (this);");
            sw.WriteLine("\t\t\tinst_and_params.Append (vals [0]);");
            string cleanup = "";

            for (int i = 0; i < parms.Count; i++)
            {
                Parameter p = parms [i];
                if (p.PassAs != "")
                {
                    if (SymbolTable.Table.IsBoxed(p.CType))
                    {
                        if (p.PassAs == "ref")
                        {
                            sw.WriteLine("\t\t\tvals [" + (i + 1) + "] = new GLib.Value (" + p.Name + ");");
                        }
                        else
                        {
                            sw.WriteLine("\t\t\tvals [" + (i + 1) + "] = new GLib.Value ((GLib.GType)typeof (" + p.CSType + "));");
                        }
                        cleanup += "\t\t\t" + p.Name + " = (" + p.CSType + ") vals [" + i + "];\n";
                    }
                    else
                    {
                        if (p.PassAs == "ref")
                        {
                            sw.WriteLine("\t\t\tIntPtr " + p.Name + "_ptr = GLib.Marshaller.StructureToPtrAlloc (" + p.Generatable.CallByName(p.Name) + ");");
                        }
                        else
                        {
                            sw.WriteLine("\t\t\tIntPtr " + p.Name + "_ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + p.MarshalType + ")));");
                        }

                        sw.WriteLine("\t\t\tvals [" + (i + 1) + "] = new GLib.Value (" + p.Name + "_ptr);");
                        cleanup += "\t\t\t" + p.Name + " = " + p.FromNative("(" + p.MarshalType + ") Marshal.PtrToStructure (" + p.Name + "_ptr, typeof (" + p.MarshalType + "))") + ";\n";
                        cleanup += "\t\t\tMarshal.FreeHGlobal (" + p.Name + "_ptr);\n";
                    }
                }
                else if (p.IsLength && i > 0 && parms [i - 1].IsString)
                {
                    sw.WriteLine("\t\t\tvals [" + (i + 1) + "] = new GLib.Value (System.Text.Encoding.UTF8.GetByteCount (" + parms [i - 1].Name + "));");
                }
                else
                {
                    sw.WriteLine("\t\t\tvals [" + (i + 1) + "] = new GLib.Value (" + p.Name + ");");
                }

                sw.WriteLine("\t\t\tinst_and_params.Append (vals [" + (i + 1) + "]);");
            }

            sw.WriteLine("\t\t\tg_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);");
            if (cleanup != "")
            {
                sw.WriteLine(cleanup);
            }
            sw.WriteLine("\t\t\tforeach (GLib.Value v in vals)");
            sw.WriteLine("\t\t\t\tv.Dispose ();");
            if (!retval.IsVoid)
            {
                IGeneratable igen = SymbolTable.Table [retval.CType];
                sw.WriteLine("\t\t\t" + retval.CSType + " result = (" + (igen is EnumGen ? retval.CSType + ") (Enum" : retval.CSType) + ") ret;");
                sw.WriteLine("\t\t\tret.Dispose ();");
                sw.WriteLine("\t\t\treturn result;");
            }
            sw.WriteLine("\t\t}\n");
        }
コード例 #11
0
ファイル: GObjectVM.cs プロジェクト: Gravecorp/gtk-sharp
 protected virtual void GenerateUnmanagedInvocation(GenerationInfo gen_info, ObjectBase implementor)
 {
     if (CodeType == VMCodeType.Glue)
         GenerateUnmanagedInvocation_glue (gen_info);
     else
         GenerateUnmanagedInvocation_managed (gen_info);
 }
コード例 #12
0
ファイル: GObjectVM.cs プロジェクト: Gravecorp/gtk-sharp
 protected virtual void GenerateOverride(GenerationInfo gen_info, ObjectBase implementor)
 {
     if (CodeType == VMCodeType.Glue)
         GenerateOverride_glue (gen_info);
     else
         GenerateOverride_managed (gen_info.Writer);
 }
コード例 #13
0
ファイル: Signal.cs プロジェクト: shana/gtk-sharp
 private bool NeedNew(ObjectBase implementor)
 {
     return elem.HasAttribute ("new_flag") ||
         (container_type != null && container_type.GetSignalRecursively (Name) != null) ||
         (implementor != null && implementor.GetSignalRecursively (Name) != null);
 }
コード例 #14
0
ファイル: Signal.cs プロジェクト: shana/gtk-sharp
        public void Generate(GenerationInfo gen_info, ObjectBase implementor)
        {
            StreamWriter sw = gen_info.Writer;

            if (implementor == null)
                GenEventHandler (gen_info);

            GenEvent (sw, implementor, "this");

            Statistics.SignalCount++;
        }
コード例 #15
0
 protected override bool CanGenerate(GenerationInfo gen_info, ObjectBase implementor)
 {
     return(true);
 }
コード例 #16
0
ファイル: DefaultSignalHandler.cs プロジェクト: jwzl/ossbuild
		protected override bool CanGenerate (GenerationInfo gen_info, ObjectBase implementor)
		{
			return true;
		}
コード例 #17
0
ファイル: DefaultSignalHandler.cs プロジェクト: jwzl/ossbuild
		public DefaultSignalHandler (XmlElement elem, ObjectBase container_type) : base (elem, container_type)
		{
			signal_name = elem.GetAttribute ("cname");
		}
コード例 #18
0
 public GObjectVM(XmlElement elem, ObjectBase container_type) : base(elem, container_type)
 {
     parms.HideData    = false;
     this.Protection   = "protected";
     class_struct_name = container_type.ClassStructName;
 }
コード例 #19
0
ファイル: ClassField.cs プロジェクト: gitcoolguy/gtk-sharp
 public ClassField(XmlElement elem, ObjectBase container_type) : base(elem, container_type)
 {
     this.container_type = container_type;
 }
コード例 #20
0
ファイル: InterfaceVM.cs プロジェクト: glib-sharp/gtk-sharp
 public InterfaceVM(XmlElement elem, Method target, ObjectBase container_type) : base(elem, container_type)
 {
     this.target     = target;
     parms.HideData  = true;
     this.Protection = "public";
 }
コード例 #21
0
ファイル: ObjectBase.cs プロジェクト: nuxleus/gtk-sharp
 public void GenVirtualMethods(GenerationInfo gen_info, ObjectBase implementor)
 {
     foreach (GObjectVM vm in virtual_methods)
         vm.Generate (gen_info, implementor);
 }
コード例 #22
0
ファイル: Signal.cs プロジェクト: shana/gtk-sharp
 private bool NeedNew(ObjectBase implementor)
 {
     return(elem.HasAttribute("new_flag") ||
            (container_type != null && container_type.GetSignalRecursively(Name) != null) ||
            (implementor != null && implementor.GetSignalRecursively(Name) != null));
 }
コード例 #23
0
ファイル: Signal.cs プロジェクト: liberostelios/gtk-sharp
		public void GenEvent (StreamWriter sw, ObjectBase implementor, string target)
		{
			string args_type = IsEventHandler ? "" : ", typeof (" + EventArgsQualifiedName + ")";
			
			if (Marshaled) {
				GenCallback (sw);
				args_type = ", new " + DelegateName + "(" + CallbackName + ")";
			}

			sw.WriteLine("\t\t[GLib.Signal("+ CName + ")]");
			sw.Write("\t\tpublic ");
			if (NeedNew (implementor))
				sw.Write("new ");
			sw.WriteLine("event " + EventHandlerQualifiedName + " " + Name + " {");
			sw.WriteLine("\t\t\tadd {");
			sw.WriteLine("\t\t\t\t{0}.AddSignalHandler ({1}, value{2});", target, CName, args_type);
			sw.WriteLine("\t\t\t}");
			sw.WriteLine("\t\t\tremove {");
			sw.WriteLine("\t\t\t\t{0}.RemoveSignalHandler ({1}, value);", target, CName);
			sw.WriteLine("\t\t\t}");
			sw.WriteLine("\t\t}");
			sw.WriteLine();
		}
コード例 #24
0
ファイル: Signal.cs プロジェクト: shana/gtk-sharp
        public void GenEvent(StreamWriter sw, ObjectBase implementor, string target)
        {
            string args_type = IsEventHandler ? "" : ", typeof (" + EventArgsQualifiedName + ")";

            if (Marshaled) {
                GenCallback (sw);
                args_type = ", new " + DelegateName + "(" + CallbackName + ")";
            }

            sw.WriteLine("\t\t[GLib.Signal("+ CName + ")]");
            sw.Write("\t\tpublic ");
            if (NeedNew (implementor))
                sw.Write("new ");
            sw.WriteLine("event " + EventHandlerQualifiedName + " " + Name + " {");
            sw.WriteLine("\t\t\tadd {");
            sw.WriteLine("\t\t\t\tGLib.Signal sig = GLib.Signal.Lookup (" + target + ", " + CName + args_type + ");");
            sw.WriteLine("\t\t\t\tsig.AddDelegate (value);");
            sw.WriteLine("\t\t\t}");
            sw.WriteLine("\t\t\tremove {");
            sw.WriteLine("\t\t\t\tGLib.Signal sig = GLib.Signal.Lookup (" + target + ", " + CName + args_type + ");");
            sw.WriteLine("\t\t\t\tsig.RemoveDelegate (value);");
            sw.WriteLine("\t\t\t}");
            sw.WriteLine("\t\t}");
            sw.WriteLine();
        }
コード例 #25
0
ファイル: ClassField.cs プロジェクト: liberostelios/gtk-sharp
		public ClassField (XmlElement elem, ObjectBase container_type) : base (elem, container_type) {
			this.container_type = container_type;
		}
コード例 #26
0
 public DefaultSignalHandler(XmlElement elem, ObjectBase container_type) : base(elem, container_type)
 {
     signal_name = elem.GetAttribute("cname");
 }
コード例 #27
0
ファイル: InterfaceVM.cs プロジェクト: jwzl/ossbuild
		public InterfaceVM (XmlElement elem, Method target, ObjectBase container_type) : base (elem, container_type)
		{
			this.target = target;
			parms.HideData = true;
			this.Protection = "public";
		}