本文整理汇总了C#中GtkSharp.Generation.GenerationInfo类的典型用法代码示例。如果您正苦于以下问题:C# GenerationInfo类的具体用法?C# GenerationInfo怎么用?C# GenerationInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenerationInfo类属于GtkSharp.Generation命名空间,在下文中一共展示了GenerationInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateUnmanagedInvocation
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);
}
示例2: CanGenerate
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: Generate
public override void Generate(GenerationInfo gen_info)
{
gen_info.CurrentType = Name;
StreamWriter sw = gen_info.Writer = gen_info.OpenStream(Name);
sw.WriteLine ("namespace " + NS + " {");
sw.WriteLine ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
sw.WriteLine ();
sw.WriteLine ("#region Autogenerated code");
if (IsDeprecated)
sw.WriteLine ("\t[Obsolete]");
sw.Write ("\t{0} class " + Name, IsInternal ? "internal" : "public");
sw.WriteLine (" {");
sw.WriteLine ();
GenProperties (gen_info, null);
GenMethods (gen_info, null, null);
sw.WriteLine ("#endregion");
AppendCustom(sw, gen_info.CustomDir);
sw.WriteLine ("\t}");
sw.WriteLine ("}");
sw.Close ();
gen_info.Writer = null;
}
示例4: Generate
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);
}
示例5: GenerateOverride
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);
}
示例6: Generate
public virtual void Generate (GenerationInfo gen_info, string indent)
{
StreamWriter sw = gen_info.Writer;
sw.WriteLine ("{0}public const {1} {2} = {3}{4}{5};",
indent,
ConstType,
Name,
IsString ? "@\"": String.Empty,
value,
IsString ? "\"": String.Empty);
}
示例7: Initialize
public void Initialize (GenerationInfo gen_info, bool is_get, bool is_set, string indent)
{
if (parameters.Count == 0)
return;
StreamWriter sw = gen_info.Writer;
for (int i = 0; i < parameters.Count; i++) {
Parameter p = parameters [i];
IGeneratable gen = p.Generatable;
string name = p.Name;
if (is_set)
name = "value";
p.CallName = name;
foreach (string prep in p.Prepare)
sw.WriteLine (indent + "\t\t\t" + prep);
if (gen is CallbackGen) {
CallbackGen cbgen = gen as CallbackGen;
string wrapper = cbgen.GenWrapper(gen_info);
switch (p.Scope) {
case "notified":
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
sw.WriteLine (indent + "\t\t\tIntPtr {0};", parameters [i + 1].Name);
sw.WriteLine (indent + "\t\t\t{0} {1};", parameters [i + 2].CSType, parameters [i + 2].Name);
sw.WriteLine (indent + "\t\t\tif ({0} == null) {{", name);
sw.WriteLine (indent + "\t\t\t\t{0} = IntPtr.Zero;", parameters [i + 1].Name);
sw.WriteLine (indent + "\t\t\t\t{0} = null;", parameters [i + 2].Name);
sw.WriteLine (indent + "\t\t\t} else {");
sw.WriteLine (indent + "\t\t\t\t{0} = (IntPtr) GCHandle.Alloc ({1}_wrapper);", parameters [i + 1].Name, name);
sw.WriteLine (indent + "\t\t\t\t{0} = GLib.DestroyHelper.NotifyHandler;", parameters [i + 2].Name, parameters [i + 2].CSType);
sw.WriteLine (indent + "\t\t\t}");
break;
case "async":
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
sw.WriteLine (indent + "\t\t\t{0}_wrapper.PersistUntilCalled ();", name);
break;
case "call":
default:
if (p.Scope == String.Empty)
Console.WriteLine ("Defaulting " + gen.Name + " param to 'call' scope in method " + gen_info.CurrentMember);
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
break;
}
}
}
if (ThrowsException)
sw.WriteLine (indent + "\t\t\tIntPtr error = IntPtr.Zero;");
}
示例8: Generate
public override void Generate(GenerationInfo gen_info)
{
Method copy = methods["Copy"] as Method;
Method free = methods["Free"] as Method;
methods.Remove ("Copy");
methods.Remove ("Free");
gen_info.CurrentType = QualifiedName;
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
base.Generate (gen_info);
sw.WriteLine ("\t\tpublic static explicit operator GLib.Value (" + QualifiedName + " boxed)");
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\tGLib.Value val = GLib.Value.Empty;");
sw.WriteLine ("\t\t\tval.Init (" + QualifiedName + ".GType);");
sw.WriteLine ("\t\t\tval.Val = boxed;");
sw.WriteLine ("\t\t\treturn val;");
sw.WriteLine ("\t\t}");
sw.WriteLine ();
sw.WriteLine ("\t\tpublic static explicit operator " + QualifiedName + " (GLib.Value val)");
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\treturn (" + QualifiedName + ") val.Val;");
sw.WriteLine ("\t\t}");
if (copy != null && copy.IsDeprecated) {
sw.WriteLine ();
sw.WriteLine ("\t\t[Obsolete(\"This is a no-op\")]");
sw.WriteLine ("\t\tpublic " + QualifiedName + " Copy() {");
sw.WriteLine ("\t\t\treturn this;");
sw.WriteLine ("\t\t}");
}
if (free != null && free.IsDeprecated) {
sw.WriteLine ();
sw.WriteLine ("\t\t[Obsolete(\"This is a no-op\")]");
sw.WriteLine ("\t\tpublic " + QualifiedName + " Free () {");
sw.WriteLine ("\t\t\treturn this;");
sw.WriteLine ("\t\t}");
}
sw.WriteLine ("#endregion");
AppendCustom(sw, gen_info.CustomDir);
sw.WriteLine ("\t}");
sw.WriteLine ("}");
sw.Close ();
gen_info.Writer = null;
Statistics.BoxedCount++;
}
示例9: Generate
public override void Generate(GenerationInfo gen_info)
{
Method copy = methods["Copy"] as Method;
methods.Remove ("Copy");
methods.Remove ("Free");
gen_info.CurrentType = Name;
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
base.Generate (gen_info);
sw.WriteLine ("\t\t[DllImport(\"glibsharpglue-2\")]");
sw.WriteLine ("\t\tstatic extern IntPtr glibsharp_value_get_boxed (ref GLib.Value val);");
sw.WriteLine ();
sw.WriteLine ("\t\t[DllImport(\"glibsharpglue-2\")]");
sw.WriteLine ("\t\tstatic extern void glibsharp_value_set_boxed (ref GLib.Value val, ref " + QualifiedName + " boxed);");
sw.WriteLine ();
sw.WriteLine ("\t\tpublic static explicit operator GLib.Value (" + QualifiedName + " boxed)");
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\tGLib.Value val = GLib.Value.Empty;");
sw.WriteLine ("\t\t\tval.Init (" + QualifiedName + ".GType);");
sw.WriteLine ("\t\t\tglibsharp_value_set_boxed (ref val, ref boxed);");
sw.WriteLine ("\t\t\treturn val;");
sw.WriteLine ("\t\t}");
sw.WriteLine ();
sw.WriteLine ("\t\tpublic static explicit operator " + QualifiedName + " (GLib.Value val)");
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\tIntPtr boxed_ptr = glibsharp_value_get_boxed (ref val);");
sw.WriteLine ("\t\t\treturn New (boxed_ptr);");
sw.WriteLine ("\t\t}");
if (copy != null && copy.IsDeprecated) {
sw.WriteLine ();
sw.WriteLine ("\t\t[Obsolete(\"This is a no-op\")]");
sw.WriteLine ("\t\tpublic " + QualifiedName + " Copy() {");
sw.WriteLine ("\t\t\treturn this;");
sw.WriteLine ("\t\t}");
}
sw.WriteLine ("#endregion");
AppendCustom(sw, gen_info.CustomDir);
sw.WriteLine ("\t}");
sw.WriteLine ("}");
sw.Close ();
gen_info.Writer = null;
Statistics.BoxedCount++;
}
示例10: Generate
public override void Generate (GenerationInfo gen_info)
{
StreamWriter sw = gen_info.OpenStream (Name);
sw.WriteLine ("namespace " + NS + " {");
sw.WriteLine ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
sw.WriteLine ();
sw.WriteLine ("#region Autogenerated code");
if (Elem.GetAttribute("type") == "flags")
sw.WriteLine ("\t[Flags]");
if (Elem.HasAttribute("gtype"))
sw.WriteLine ("\t[Gst.GLib.GType (typeof (" + NS + "." + Name + "GType))]");
string access = IsInternal ? "internal" : "public";
sw.WriteLine ("\t" + access + " enum " + Name + enum_type + " {");
sw.WriteLine ();
foreach (string member in members)
sw.WriteLine (member);
sw.WriteLine ("\t}");
if (Elem.HasAttribute ("gtype")) {
sw.WriteLine ();
sw.WriteLine ("\tinternal class " + Name + "GType {");
sw.WriteLine ("\t\t[DllImport (\"" + LibraryName + "\", CallingConvention = CallingConvention.Cdecl)]");
sw.WriteLine ("\t\tstatic extern IntPtr " + Elem.GetAttribute ("gtype") + " ();");
sw.WriteLine ();
sw.WriteLine ("\t\tpublic static Gst.GLib.GType GType {");
sw.WriteLine ("\t\t\tget {");
sw.WriteLine ("\t\t\t\treturn new Gst.GLib.GType (" + Elem.GetAttribute ("gtype") + " ());");
sw.WriteLine ("\t\t\t}");
sw.WriteLine ("\t\t}");
sw.WriteLine ("\t}");
}
sw.WriteLine ("#endregion");
sw.WriteLine ("}");
sw.Close ();
Statistics.EnumCount++;
}
示例11: GenerateStatic
void GenerateStatic (GenerationInfo gen_info)
{
StreamWriter sw = gen_info.Writer;
sw.WriteLine("\t\t" + Protection + " static " + Safety + Modifiers + name + " " + StaticName + "(" + Signature + ")");
sw.WriteLine("\t\t{");
Body.Initialize(gen_info, false, false, "");
sw.Write("\t\t\t" + name + " result = ");
if (container_type is StructBase)
sw.Write ("{0}.New (", name);
else
sw.Write ("new {0} (", name);
sw.WriteLine (CName + "(" + Body.GetCallString (false) + "));");
Body.Finish (sw, "");
Body.HandleException (sw, "");
sw.WriteLine ("\t\t\treturn result;");
}
示例12: Generate
public override void Generate(GenerationInfo gen_info)
{
gen_info.CurrentType = QualifiedName;
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
base.Generate (gen_info);
if (GetMethod ("GetType") == null && GetMethod ("GetGType") == null) {
sw.WriteLine ("\t\tprivate static GLib.GType GType {");
sw.WriteLine ("\t\t\tget { return GLib.GType.Pointer; }");
sw.WriteLine ("\t\t}");
}
sw.WriteLine ("#endregion");
sw.WriteLine ("\t}");
sw.WriteLine ("}");
sw.Close ();
gen_info.Writer = null;
Statistics.StructCount++;
}
示例13: Generate
public override void Generate (GenerationInfo gen_info)
{
bool need_close = false;
if (gen_info.Writer == null) {
gen_info.Writer = gen_info.OpenStream (Name, NS);
need_close = true;
}
StreamWriter sw = gen_info.Writer;
sw.WriteLine ("namespace " + NS + " {");
sw.WriteLine ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ("\tusing System.Collections;");
sw.WriteLine ("\tusing System.Collections.Generic;");
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
sw.WriteLine ();
sw.WriteLine ("#region Autogenerated code");
if (IsDeprecated)
sw.WriteLine ("\t[Obsolete]");
string access = IsInternal ? "internal" : "public";
sw.WriteLine ("\t" + access + " partial class {0} : {1} IEquatable<{0}> {{", Name, Parent == null ? "GLib.IWrapper," : (Parent.QualifiedName + ","));
sw.WriteLine ();
GenNativeStruct (gen_info);
GenNativeAccessor (gen_info);
GenFields (gen_info);
sw.WriteLine ();
GenCtors (gen_info);
GenMethods (gen_info, null, this);
GenEqualsAndHash (sw);
if (!need_close)
return;
sw.WriteLine ("#endregion");
sw.WriteLine ("\t}");
sw.WriteLine ("}");
sw.Close ();
gen_info.Writer = null;
}
示例14: Generate
public override void Generate(GenerationInfo gen_info)
{
GenerateAdapter (gen_info);
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
sw.WriteLine ("namespace " + NS + " {");
sw.WriteLine ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ();
sw.WriteLine ("#region Autogenerated code");
string access = IsInternal ? "internal" : "public";
sw.WriteLine ("\t" + access + " interface " + Name + " : GLib.IWrapper {");
sw.WriteLine ();
foreach (Signal sig in sigs.Values) {
sig.GenerateDecl (sw);
sig.GenEventHandler (gen_info);
}
foreach (Method method in methods.Values) {
if (IgnoreMethod (method, this))
continue;
method.GenerateDecl (sw);
}
foreach (Property prop in props.Values)
prop.GenerateDecl (sw, "\t\t");
AppendCustom (sw, gen_info.CustomDir);
sw.WriteLine ("\t}");
GenerateImplementorIface (sw);
sw.WriteLine ("#endregion");
sw.WriteLine ("}");
sw.Close ();
gen_info.Writer = null;
Statistics.IFaceCount++;
}
示例15: GenEventHandler
public void GenEventHandler(GenerationInfo gen_info)
{
if (IsEventHandler)
return;
string ns = container_type.NS;
StreamWriter sw = gen_info.OpenStream (EventHandlerName);
sw.WriteLine ("namespace " + ns + " {");
sw.WriteLine ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ();
sw.WriteLine ("\tpublic delegate void " + EventHandlerName + "(object o, " + EventArgsName + " args);");
sw.WriteLine ();
sw.WriteLine ("\tpublic class " + EventArgsName + " : GLib.SignalArgs {");
for (int i = 0; i < parms.Count; i++) {
sw.WriteLine ("\t\tpublic " + parms[i].CSType + " " + parms[i].StudlyName + "{");
if (parms[i].PassAs != "out") {
sw.WriteLine ("\t\t\tget {");
if (SymbolTable.Table.IsInterface (parms [i].CType))
sw.WriteLine ("\t\t\t\treturn {0}Adapter.GetObject (Args [{1}] as GLib.Object);", parms [i].CSType, i);
else
sw.WriteLine ("\t\t\t\treturn ({0}) Args [{1}];", parms [i].CSType, i);
sw.WriteLine ("\t\t\t}");
}
if (parms[i].PassAs != "") {
sw.WriteLine ("\t\t\tset {");
if (SymbolTable.Table.IsInterface (parms [i].CType))
sw.WriteLine ("\t\t\t\tArgs [{0}] = value is {1}Adapter ? (value as {1}Adapter).Implementor : value;", i, parms [i].CSType);
else
sw.WriteLine ("\t\t\t\tArgs[" + i + "] = (" + parms[i].CSType + ")value;");
sw.WriteLine ("\t\t\t}");
}
sw.WriteLine ("\t\t}");
sw.WriteLine ();
}
sw.WriteLine ("\t}");
sw.WriteLine ("}");
sw.Close ();
}