本文整理汇总了C#中GtkSharp.Generation.GenerationInfo类的典型用法代码示例。如果您正苦于以下问题:C# GenerationInfo类的具体用法?C# GenerationInfo怎么用?C# GenerationInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenerationInfo类属于GtkSharp.Generation命名空间,在下文中一共展示了GenerationInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:jwzl,项目名称:ossbuild,代码行数:7,代码来源:DefaultSignalHandler.cs
示例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;
}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:7,代码来源:GObjectVM.cs
示例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;
}
开发者ID:Yetangitu,项目名称:f-spot,代码行数:31,代码来源:ClassGen.cs
示例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);
}
开发者ID:jwzl,项目名称:ossbuild,代码行数:10,代码来源:GObjectVM.cs
示例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);
}
开发者ID:jwzl,项目名称:ossbuild,代码行数:11,代码来源:DefaultSignalHandler.cs
示例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);
}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:12,代码来源:Constant.cs
示例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;");
}
开发者ID:ystk,项目名称:debian-gtk-sharp2,代码行数:52,代码来源:MethodBody.cs
示例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++;
}
开发者ID:nuxleus,项目名称:gtk-sharp,代码行数:50,代码来源:BoxedGen.cs
示例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++;
}
开发者ID:Yetangitu,项目名称:f-spot,代码行数:48,代码来源:BoxedGen.cs
示例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++;
}
开发者ID:jwzl,项目名称:ossbuild,代码行数:45,代码来源:EnumGen.cs
示例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;");
}
开发者ID:ystk,项目名称:debian-gtk-sharp2,代码行数:18,代码来源:Ctor.cs
示例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++;
}
开发者ID:pabloescribano,项目名称:gtk-sharp,代码行数:18,代码来源:StructGen.cs
示例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;
}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:43,代码来源:NativeStructGen.cs
示例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++;
}
开发者ID:saraa,项目名称:fishtastic,代码行数:38,代码来源:InterfaceGen.cs
示例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 ();
}
开发者ID:shana,项目名称:gtk-sharp,代码行数:42,代码来源:Signal.cs
示例16: Generate
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++;
}
开发者ID:shana,项目名称:gtk-sharp,代码行数:11,代码来源:Signal.cs
示例17: Main
public static int Main(string[] args)
{
if (args.Length < 2) {
Console.WriteLine ("Usage: codegen --generate <filename1...>");
return 0;
}
bool generate = false;
string dir = "";
string assembly_name = "";
string glue_filename = "";
string glue_includes = "";
string gluelib_name = "";
SymbolTable table = SymbolTable.Table;
ArrayList gens = new ArrayList ();
foreach (string arg in args) {
if (arg.StartsWith ("--customdir=")) {
Console.WriteLine ("Using .custom files is not supported anymore, use partial classes instead.");
return 0;
}
string filename = arg;
if (arg == "--generate") {
generate = true;
continue;
} else if (arg == "--include") {
generate = false;
continue;
} else if (arg.StartsWith ("-I:")) {
generate = false;
filename = filename.Substring (3);
} else if (arg.StartsWith ("--outdir=")) {
generate = false;
dir = arg.Substring (9);
continue;
} else if (arg.StartsWith ("--assembly-name=")) {
generate = false;
assembly_name = arg.Substring (16);
continue;
} else if (arg.StartsWith ("--glue-filename=")) {
generate = false;
glue_filename = arg.Substring (16);
continue;
} else if (arg.StartsWith ("--glue-includes=")) {
generate = false;
glue_includes = arg.Substring (16);
continue;
} else if (arg.StartsWith ("--gluelib-name=")) {
generate = false;
gluelib_name = arg.Substring (15);
continue;
}
Parser p = new Parser ();
IGeneratable[] curr_gens = p.Parse (filename);
table.AddTypes (curr_gens);
if (generate)
gens.AddRange (curr_gens);
}
// Now that everything is loaded, validate all the to-be-
// generated generatables and then remove the invalid ones.
ArrayList invalids = new ArrayList ();
foreach (IGeneratable gen in gens) {
if (!gen.Validate ())
invalids.Add (gen);
}
foreach (IGeneratable gen in invalids)
gens.Remove (gen);
GenerationInfo gen_info = null;
if (dir != "" || assembly_name != "" || glue_filename != "" || glue_includes != "" || gluelib_name != "")
gen_info = new GenerationInfo (dir, assembly_name, glue_filename, glue_includes, gluelib_name);
foreach (IGeneratable gen in gens) {
if (gen_info == null)
gen.Generate ();
else
gen.Generate (gen_info);
}
ObjectGen.GenerateMappers ();
if (gen_info != null)
gen_info.CloseGlueWriter ();
Statistics.Report();
return 0;
}
开发者ID:pabloescribano,项目名称:gtk-sharp,代码行数:89,代码来源:CodeGenerator.cs
示例18: Generate
public override void Generate (GenerationInfo gen_info, string indent)
{
if (Hidden)
return;
visible = Access != "private";
StreamWriter sw = gen_info.Writer;
SymbolTable table = SymbolTable.Table;
string wrapped = table.GetCSType (CType);
string wrapped_name = SymbolTable.Table.MangleName (CName);
IGeneratable gen = table [CType];
if (IsArray && !IsNullTermArray) {
sw.WriteLine (indent + "[MarshalAs (UnmanagedType.ByValArray, SizeConst=" + ArrayLength + ")]");
sw.WriteLine (indent + "{0} {1} {2};", Access, CSType, StudlyName);
} else if (IsArray && IsNullTermArray) {
sw.WriteLine (indent + "private {0} {1};", "IntPtr", StudlyName+ "Ptr");
if ((Readable || Writable) && Access == "public") {
sw.WriteLine (indent + "public {0} {1} {{", CSType, StudlyName);
if (Readable)
sw.WriteLine (indent + "\tget {{ return GLib.Marshaller.StructArrayFromNullTerminatedIntPtr<{0}> ({1}); }}",
base.CSType, StudlyName + "Ptr");
if (Writable)
sw.WriteLine (indent + "\tset {{ {0} = GLib.Marshaller.StructArrayToNullTerminatedStructArrayIntPtr<{1}> (value); }}",
StudlyName + "Ptr", base.CSType);
sw.WriteLine (indent + "}");
}
} else if (IsBitfield) {
base.Generate (gen_info, indent);
} else if (gen is IAccessor) {
sw.WriteLine (indent + "private {0} {1};", gen.MarshalType, Name);
if (Access != "private") {
IAccessor acc = table [CType] as IAccessor;
sw.WriteLine (indent + Access + " " + wrapped + " " + StudlyName + " {");
acc.WriteAccessors (sw, indent + "\t", Name);
sw.WriteLine (indent + "}");
}
} else if (IsPointer && (gen is StructGen || gen is BoxedGen || gen is UnionGen)) {
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
sw.WriteLine ();
if (Access != "private") {
sw.WriteLine (indent + Access + " " + wrapped + " " + wrapped_name + " {");
sw.WriteLine (indent + "\tget { return " + table.FromNative (CType, Name) + "; }");
sw.WriteLine (indent + "}");
}
} else if (IsPointer && CSType != "string") {
// FIXME: probably some fields here which should be visible.
visible = false;
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
} else {
sw.WriteLine (indent + "{0} {1} {2};", Access, CSType, Access == "public" ? StudlyName : Name);
}
}
开发者ID:arkydon,项目名称:gtk-sharp,代码行数:56,代码来源:StructField.cs
示例19: Main
public static int Main(string[] args)
{
bool show_help = false;
string dir = "";
string assembly_name = "";
string glue_filename = "";
string glue_includes = "";
string gluelib_name = "";
string schema_name = "";
SymbolTable table = SymbolTable.Table;
var gens = new List<IGeneratable> ();
var filenames = new List<string> ();
var includes = new List<string> ();
var options = new OptionSet () {
{ "generate=", "Generate the C# code for this GAPI XML file.",
(string v) => { filenames.Add (v); } },
{ "I|include=", "GAPI XML file that contain symbols used in the main GAPI XML file.",
(string v) => { includes.Add (v); } },
{ "outdir=", "Directory where the C# files will be generated.",
(string v) => { dir = v; } },
{ "assembly-name=", "Name of the assembly for which the code is generated.",
(string v) => { assembly_name = v; } },
{ "glue-filename=", "Filename for the generated C glue code.",
(string v) => { glue_filename = v; } },
{ "glue-includes=", "Content of #include directive to add in the generated C glue code.",
(string v) => { glue_includes = v; } },
{ "gluelib-name=", "Name of the C library into which the C glue code will be compiled. " +
"Used to generated correct DllImport attributes.",
(string v) => { gluelib_name = v; } },
{ "schema=", "Validate all GAPI XML files against this XSD schema.",
(string v) => { schema_name = v; } },
{ "h|help", "Show this message and exit",
v => show_help = v != null },
};
List<string> extra;
try {
extra = options.Parse (args);
}
catch (OptionException e) {
Console.Write ("gapi-codegen: ");
Console.WriteLine (e.Message);
Console.WriteLine ("Try `gapi-codegen --help' for more information.");
return 0;
}
if (show_help) {
ShowHelp (options);
return 1;
}
if (filenames.Count == 0) {
Console.WriteLine ("You need to specify a file to process using the --generate option.");
Console.WriteLine ("Try `gapi-codegen --help' for more information.");
return 0;
}
if (extra.Exists (v => { return v.StartsWith ("--customdir"); })) {
Console.WriteLine ("Using .custom files is not supported anymore, use partial classes instead.");
return 0;
}
if (!String.IsNullOrEmpty (schema_name) && !File.Exists (schema_name)) {
Console.WriteLine ("WARNING: Could not find schema file at '{0}', no validation will be done.", schema_name);
schema_name = null;
}
Parser p = new Parser ();
foreach (string include in includes) {
IGeneratable[] curr_gens = p.Parse (include, schema_name);
table.AddTypes (curr_gens);
}
foreach (string filename in filenames) {
IGeneratable[] curr_gens = p.Parse (filename, schema_name);
table.AddTypes (curr_gens);
gens.AddRange (curr_gens);
}
// Now that everything is loaded, validate all the to-be-
// generated generatables and then remove the invalid ones.
var invalids = new List<IGeneratable> ();
foreach (IGeneratable gen in gens) {
if (!gen.Validate ())
invalids.Add (gen);
}
foreach (IGeneratable gen in invalids)
gens.Remove (gen);
GenerationInfo gen_info = null;
if (dir != "" || assembly_name != "" || glue_filename != "" || glue_includes != "" || gluelib_name != "")
gen_info = new GenerationInfo (dir, assembly_name, glue_filename, glue_includes, gluelib_name);
foreach (IGeneratable gen in gens) {
if (gen_info == null)
gen.Generate ();
else
//.........这里部分代码省略.........
开发者ID:0x6e3078,项目名称:gtk-sharp,代码行数:101,代码来源:CodeGenerator.cs
示例20: GenerateClassStruct
protected void GenerateClassStruct(GenerationInfo gen_info)
{
if (class_struct_name == null || !CanGenerateClassStruct) return;
StreamWriter sw = gen_info.Writer;
sw.WriteLine ("\t\t[StructLayout (LayoutKind.Sequential)]");
sw.WriteLine ("\t\tstruct " + class_struct_name + " {");
foreach (object member in class_members) {
if (member is VirtualMethod) {
VirtualMethod vm = member as VirtualMethod;
if (hidden_vms.Contains (vm) || (is_interface && vm is DefaultSignalHandler))
sw.WriteLine ("\t\t\tIntPtr {0};", vm.Name);
else
sw.WriteLine ("\t\t\tpublic {0}NativeDelegate {0};", vm.Name);
} else if (member is ClassField) {
ClassField field = member as ClassField;
field.Generate (gen_info, "\t\t\t");
}
}
sw.WriteLine ("\t\t}");
sw.WriteLine ();
}
开发者ID:nuxleus,项目名称:gtk-sharp,代码行数:23,代码来源:ObjectBase.cs
注:本文中的GtkSharp.Generation.GenerationInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论