2005-02-23 17:37:33 +00:00
|
|
|
// GtkSharp.Generation.StructBase.cs - The Structure/Boxed Base Class.
|
2002-11-10 10:03:51 +00:00
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
2004-06-25 16:35:15 +00:00
|
|
|
// Copyright (c) 2001-2003 Mike Kestner
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of version 2 of the GNU General Public
|
|
|
|
// License as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public
|
|
|
|
// License along with this program; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
|
|
|
|
2002-11-10 10:03:51 +00:00
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.IO;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Xml;
|
|
|
|
|
2004-12-26 19:33:34 +00:00
|
|
|
public abstract class StructBase : ClassBase {
|
2002-11-10 10:03:51 +00:00
|
|
|
|
* generator/StructBase.cs: update field-generation logic a bit
* generator/CodeGenerator.cs: add a --glue-includes flag
* generator/GenerationInfo.cs: Accept glue_includes value from
Main and output it to the glue_filename.
* generator/FieldBase.cs (Ignored): handle more ignorable cases.
(CheckGlue): New method to figure out what kind of glue we'll need
for a field.
(GenerateImports): generate appropriate imports per CheckGlue.
(GenerateGlue): Generate C glue for accessing a struct field;
either a fully-C-based accessor, or a method to just return the
field's offset in the struct.
(Generate): Use the generated glue to read the field.
* generator/PropertyBase.cs (CType): if the field is a single bit,
set its type to gboolean.
* generator/ObjectGen.cs (Generate):
* generator/OpaqueGen.cs (Generate): Call GenFields.
* generator/StructField.cs: Use FieldBase's glue-generation code
to handle bitfields. [#54489]
* generator/ObjectField.cs: Generates accessors for public fields
of objects and opaque structs. [#69514]
* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
create ObjectField objects.
(GenFields): Output field properties
(IgnoreMethod): Ignore Get/Set methods that duplicate fields
* generator/Makefile.am (sources): update
* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
public. Rename/retype some fields for consistency with earlier
hand-coded bindings.
* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
now be autogenerated.
* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
be autogenerated
* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update
svn path=/trunk/gtk-sharp/; revision=44563
2005-05-16 14:28:55 +00:00
|
|
|
new ArrayList fields = new ArrayList ();
|
2002-11-10 10:03:51 +00:00
|
|
|
|
2004-12-26 19:33:34 +00:00
|
|
|
protected StructBase (XmlElement ns, XmlElement elem) : base (ns, elem)
|
2002-11-10 10:03:51 +00:00
|
|
|
{
|
|
|
|
foreach (XmlNode node in elem.ChildNodes) {
|
|
|
|
|
|
|
|
if (!(node is XmlElement)) continue;
|
|
|
|
XmlElement member = (XmlElement) node;
|
|
|
|
|
|
|
|
switch (node.Name) {
|
|
|
|
case "field":
|
2005-05-02 18:40:30 +00:00
|
|
|
fields.Add (new StructField (member, this));
|
2002-11-10 10:03:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "callback":
|
|
|
|
Statistics.IgnoreCount++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (!IsNodeNameHandled (node.Name))
|
|
|
|
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-19 05:30:05 +00:00
|
|
|
public override string MarshalType {
|
2002-11-10 10:03:51 +00:00
|
|
|
get
|
|
|
|
{
|
|
|
|
return "ref " + QualifiedName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-19 05:30:05 +00:00
|
|
|
public override string MarshalReturnType {
|
2002-11-10 10:03:51 +00:00
|
|
|
get
|
|
|
|
{
|
|
|
|
return "IntPtr";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-18 22:19:31 +00:00
|
|
|
public override string ToNativeReturnType {
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return QualifiedName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-19 05:30:05 +00:00
|
|
|
public override string CallByName (string var_name)
|
2002-11-10 10:03:51 +00:00
|
|
|
{
|
|
|
|
return "ref " + var_name;
|
|
|
|
}
|
|
|
|
|
2004-01-19 05:30:05 +00:00
|
|
|
public override string CallByName ()
|
2002-11-10 10:03:51 +00:00
|
|
|
{
|
|
|
|
return "ref this";
|
|
|
|
}
|
|
|
|
|
2004-01-19 05:30:05 +00:00
|
|
|
public override string AssignToName {
|
2002-11-10 10:03:51 +00:00
|
|
|
get { return "raw"; }
|
|
|
|
}
|
|
|
|
|
2004-01-19 05:30:05 +00:00
|
|
|
public override string FromNative(string var)
|
2002-11-10 10:03:51 +00:00
|
|
|
{
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
2004-01-19 05:30:05 +00:00
|
|
|
public override string FromNativeReturn(string var)
|
2002-11-10 10:03:51 +00:00
|
|
|
{
|
|
|
|
return QualifiedName + ".New (" + var + ")";
|
|
|
|
}
|
|
|
|
|
2004-01-19 05:30:05 +00:00
|
|
|
public override string ToNativeReturn(string var)
|
2003-05-29 Rachel Hestilow <rachel@nullenvoid.com>
* gconf/Value.cs: Update to use new string marshalling.
* generator/StringGen.cs, ConstStringGen.cs: Added.
* generator/IGeneratable.cs: Add new method ToNativeReturn.
* generator/CallbackGen.cs: Implement ToNativeReturn. Call
ToNativeReturn for the return statement. Fix a couple of
places where s_ret was being used incorrectly for m_ret.
* generator/ClassGen.cs, EnumGen.cs, ManualGen.cs,
SimpleGen.cs, StructBase.cs: Implement ToNativeReturn.
* generator/SignalHandler.cs: Call ToNativeReturn for the
return statement, instead of CallByName.
* generator/SymbolTable.cs: Use StringGen for gchar, char,
and gunichar, and ConstStringGen for their const variants.
Add a new method wrapper for ToNativeReturn.
(Trim): Add a special-case for const strings so that the
const is not stripped. Otherwise there is no way of
resolving the const case.
* glade/XML.custom: Update to use new string marshalling.
* glib/Marshaller.cs: Added.
* glib/GException.cs, Markup.cs, ObjectManager.cs,
Value.cs: Update to use new string marshalling.
* glib/Object.cs: Remove old g_type_name DllImport
as it is no longer used.
* glue/fileselection.c (gtksharp_file_selection_get_fileop_entry):
Mark this as const return.
* gtk/ColorSelection.custom, FileSelection.custom,
SelectionData.custom: Update to use new string marshalling.
svn path=/trunk/gtk-sharp/; revision=15286
2003-06-10 18:09:47 +00:00
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
2004-06-02 20:28:42 +00:00
|
|
|
private bool DisableNew {
|
|
|
|
get {
|
|
|
|
return Elem.HasAttribute ("disable_new");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
* generator/StructBase.cs: update field-generation logic a bit
* generator/CodeGenerator.cs: add a --glue-includes flag
* generator/GenerationInfo.cs: Accept glue_includes value from
Main and output it to the glue_filename.
* generator/FieldBase.cs (Ignored): handle more ignorable cases.
(CheckGlue): New method to figure out what kind of glue we'll need
for a field.
(GenerateImports): generate appropriate imports per CheckGlue.
(GenerateGlue): Generate C glue for accessing a struct field;
either a fully-C-based accessor, or a method to just return the
field's offset in the struct.
(Generate): Use the generated glue to read the field.
* generator/PropertyBase.cs (CType): if the field is a single bit,
set its type to gboolean.
* generator/ObjectGen.cs (Generate):
* generator/OpaqueGen.cs (Generate): Call GenFields.
* generator/StructField.cs: Use FieldBase's glue-generation code
to handle bitfields. [#54489]
* generator/ObjectField.cs: Generates accessors for public fields
of objects and opaque structs. [#69514]
* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
create ObjectField objects.
(GenFields): Output field properties
(IgnoreMethod): Ignore Get/Set methods that duplicate fields
* generator/Makefile.am (sources): update
* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
public. Rename/retype some fields for consistency with earlier
hand-coded bindings.
* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
now be autogenerated.
* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
be autogenerated
* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update
svn path=/trunk/gtk-sharp/; revision=44563
2005-05-16 14:28:55 +00:00
|
|
|
protected new void GenFields (GenerationInfo gen_info)
|
2002-11-10 10:03:51 +00:00
|
|
|
{
|
* generator/StructBase.cs: update field-generation logic a bit
* generator/CodeGenerator.cs: add a --glue-includes flag
* generator/GenerationInfo.cs: Accept glue_includes value from
Main and output it to the glue_filename.
* generator/FieldBase.cs (Ignored): handle more ignorable cases.
(CheckGlue): New method to figure out what kind of glue we'll need
for a field.
(GenerateImports): generate appropriate imports per CheckGlue.
(GenerateGlue): Generate C glue for accessing a struct field;
either a fully-C-based accessor, or a method to just return the
field's offset in the struct.
(Generate): Use the generated glue to read the field.
* generator/PropertyBase.cs (CType): if the field is a single bit,
set its type to gboolean.
* generator/ObjectGen.cs (Generate):
* generator/OpaqueGen.cs (Generate): Call GenFields.
* generator/StructField.cs: Use FieldBase's glue-generation code
to handle bitfields. [#54489]
* generator/ObjectField.cs: Generates accessors for public fields
of objects and opaque structs. [#69514]
* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
create ObjectField objects.
(GenFields): Output field properties
(IgnoreMethod): Ignore Get/Set methods that duplicate fields
* generator/Makefile.am (sources): update
* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
public. Rename/retype some fields for consistency with earlier
hand-coded bindings.
* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
now be autogenerated.
* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
be autogenerated
* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update
svn path=/trunk/gtk-sharp/; revision=44563
2005-05-16 14:28:55 +00:00
|
|
|
int bitfields = 0;
|
2002-11-10 10:03:51 +00:00
|
|
|
bool need_field = true;
|
* generator/StructBase.cs: update field-generation logic a bit
* generator/CodeGenerator.cs: add a --glue-includes flag
* generator/GenerationInfo.cs: Accept glue_includes value from
Main and output it to the glue_filename.
* generator/FieldBase.cs (Ignored): handle more ignorable cases.
(CheckGlue): New method to figure out what kind of glue we'll need
for a field.
(GenerateImports): generate appropriate imports per CheckGlue.
(GenerateGlue): Generate C glue for accessing a struct field;
either a fully-C-based accessor, or a method to just return the
field's offset in the struct.
(Generate): Use the generated glue to read the field.
* generator/PropertyBase.cs (CType): if the field is a single bit,
set its type to gboolean.
* generator/ObjectGen.cs (Generate):
* generator/OpaqueGen.cs (Generate): Call GenFields.
* generator/StructField.cs: Use FieldBase's glue-generation code
to handle bitfields. [#54489]
* generator/ObjectField.cs: Generates accessors for public fields
of objects and opaque structs. [#69514]
* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
create ObjectField objects.
(GenFields): Output field properties
(IgnoreMethod): Ignore Get/Set methods that duplicate fields
* generator/Makefile.am (sources): update
* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
public. Rename/retype some fields for consistency with earlier
hand-coded bindings.
* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
now be autogenerated.
* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
be autogenerated
* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update
svn path=/trunk/gtk-sharp/; revision=44563
2005-05-16 14:28:55 +00:00
|
|
|
|
2005-05-02 18:40:30 +00:00
|
|
|
foreach (StructField field in fields) {
|
* generator/StructBase.cs: update field-generation logic a bit
* generator/CodeGenerator.cs: add a --glue-includes flag
* generator/GenerationInfo.cs: Accept glue_includes value from
Main and output it to the glue_filename.
* generator/FieldBase.cs (Ignored): handle more ignorable cases.
(CheckGlue): New method to figure out what kind of glue we'll need
for a field.
(GenerateImports): generate appropriate imports per CheckGlue.
(GenerateGlue): Generate C glue for accessing a struct field;
either a fully-C-based accessor, or a method to just return the
field's offset in the struct.
(Generate): Use the generated glue to read the field.
* generator/PropertyBase.cs (CType): if the field is a single bit,
set its type to gboolean.
* generator/ObjectGen.cs (Generate):
* generator/OpaqueGen.cs (Generate): Call GenFields.
* generator/StructField.cs: Use FieldBase's glue-generation code
to handle bitfields. [#54489]
* generator/ObjectField.cs: Generates accessors for public fields
of objects and opaque structs. [#69514]
* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
create ObjectField objects.
(GenFields): Output field properties
(IgnoreMethod): Ignore Get/Set methods that duplicate fields
* generator/Makefile.am (sources): update
* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
public. Rename/retype some fields for consistency with earlier
hand-coded bindings.
* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
now be autogenerated.
* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
be autogenerated
* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update
svn path=/trunk/gtk-sharp/; revision=44563
2005-05-16 14:28:55 +00:00
|
|
|
if (field.IsBitfield) {
|
|
|
|
if (need_field) {
|
|
|
|
StreamWriter sw = gen_info.Writer;
|
|
|
|
|
|
|
|
sw.WriteLine ("\t\tprivate uint _bitfield{0};\n", bitfields++);
|
2002-11-10 10:03:51 +00:00
|
|
|
need_field = false;
|
* generator/StructBase.cs: update field-generation logic a bit
* generator/CodeGenerator.cs: add a --glue-includes flag
* generator/GenerationInfo.cs: Accept glue_includes value from
Main and output it to the glue_filename.
* generator/FieldBase.cs (Ignored): handle more ignorable cases.
(CheckGlue): New method to figure out what kind of glue we'll need
for a field.
(GenerateImports): generate appropriate imports per CheckGlue.
(GenerateGlue): Generate C glue for accessing a struct field;
either a fully-C-based accessor, or a method to just return the
field's offset in the struct.
(Generate): Use the generated glue to read the field.
* generator/PropertyBase.cs (CType): if the field is a single bit,
set its type to gboolean.
* generator/ObjectGen.cs (Generate):
* generator/OpaqueGen.cs (Generate): Call GenFields.
* generator/StructField.cs: Use FieldBase's glue-generation code
to handle bitfields. [#54489]
* generator/ObjectField.cs: Generates accessors for public fields
of objects and opaque structs. [#69514]
* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
create ObjectField objects.
(GenFields): Output field properties
(IgnoreMethod): Ignore Get/Set methods that duplicate fields
* generator/Makefile.am (sources): update
* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
public. Rename/retype some fields for consistency with earlier
hand-coded bindings.
* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
now be autogenerated.
* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
be autogenerated
* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update
svn path=/trunk/gtk-sharp/; revision=44563
2005-05-16 14:28:55 +00:00
|
|
|
}
|
2002-11-10 10:03:51 +00:00
|
|
|
} else
|
|
|
|
need_field = true;
|
2005-05-02 18:40:30 +00:00
|
|
|
field.Generate (gen_info, "\t\t");
|
2002-11-10 10:03:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-23 17:37:33 +00:00
|
|
|
public bool Validate ()
|
|
|
|
{
|
2005-05-02 18:40:30 +00:00
|
|
|
foreach (StructField field in fields) {
|
2005-02-23 17:37:33 +00:00
|
|
|
if (!field.Validate ()) {
|
|
|
|
Console.WriteLine ("in Struct " + QualifiedName);
|
* generator/StructBase.cs: update field-generation logic a bit
* generator/CodeGenerator.cs: add a --glue-includes flag
* generator/GenerationInfo.cs: Accept glue_includes value from
Main and output it to the glue_filename.
* generator/FieldBase.cs (Ignored): handle more ignorable cases.
(CheckGlue): New method to figure out what kind of glue we'll need
for a field.
(GenerateImports): generate appropriate imports per CheckGlue.
(GenerateGlue): Generate C glue for accessing a struct field;
either a fully-C-based accessor, or a method to just return the
field's offset in the struct.
(Generate): Use the generated glue to read the field.
* generator/PropertyBase.cs (CType): if the field is a single bit,
set its type to gboolean.
* generator/ObjectGen.cs (Generate):
* generator/OpaqueGen.cs (Generate): Call GenFields.
* generator/StructField.cs: Use FieldBase's glue-generation code
to handle bitfields. [#54489]
* generator/ObjectField.cs: Generates accessors for public fields
of objects and opaque structs. [#69514]
* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
create ObjectField objects.
(GenFields): Output field properties
(IgnoreMethod): Ignore Get/Set methods that duplicate fields
* generator/Makefile.am (sources): update
* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
public. Rename/retype some fields for consistency with earlier
hand-coded bindings.
* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
now be autogenerated.
* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
be autogenerated
* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update
svn path=/trunk/gtk-sharp/; revision=44563
2005-05-16 14:28:55 +00:00
|
|
|
if (!field.IsPointer)
|
|
|
|
return false;
|
2005-02-23 17:37:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-12-26 19:33:34 +00:00
|
|
|
public override void Generate (GenerationInfo gen_info)
|
2002-11-10 10:03:51 +00:00
|
|
|
{
|
2003-10-28 15:45:35 +00:00
|
|
|
bool need_close = false;
|
|
|
|
if (gen_info.Writer == null) {
|
|
|
|
gen_info.Writer = gen_info.OpenStream (Name);
|
|
|
|
need_close = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
StreamWriter sw = gen_info.Writer;
|
2002-11-10 10:03:51 +00:00
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
sw.WriteLine ("namespace " + NS + " {");
|
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\tusing System;");
|
2002-11-10 10:03:51 +00:00
|
|
|
sw.WriteLine ("\tusing System.Collections;");
|
|
|
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
2003-01-05 23:51:37 +00:00
|
|
|
sw.WriteLine ("#region Autogenerated code");
|
2002-11-10 10:03:51 +00:00
|
|
|
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
|
|
|
sw.WriteLine ("\tpublic struct " + Name + " {");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
2005-05-02 18:40:30 +00:00
|
|
|
GenFields (gen_info);
|
2002-11-10 10:03:51 +00:00
|
|
|
sw.WriteLine ();
|
2003-10-05 00:20:17 +00:00
|
|
|
GenCtors (gen_info);
|
|
|
|
GenMethods (gen_info, null, null);
|
2003-01-05 23:51:37 +00:00
|
|
|
|
2003-10-28 15:45:35 +00:00
|
|
|
if (!need_close)
|
|
|
|
return;
|
|
|
|
|
2003-01-05 23:51:37 +00:00
|
|
|
sw.WriteLine ("#endregion");
|
2003-10-05 00:20:17 +00:00
|
|
|
AppendCustom(sw, gen_info.CustomDir);
|
2002-11-10 10:03:51 +00:00
|
|
|
|
|
|
|
sw.WriteLine ("\t}");
|
2003-10-05 00:20:17 +00:00
|
|
|
sw.WriteLine ("}");
|
|
|
|
sw.Close ();
|
|
|
|
gen_info.Writer = null;
|
2002-11-10 10:03:51 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
protected override void GenCtors (GenerationInfo gen_info)
|
2002-11-10 10:03:51 +00:00
|
|
|
{
|
2003-10-05 00:20:17 +00:00
|
|
|
StreamWriter sw = gen_info.Writer;
|
|
|
|
|
2002-11-10 10:03:51 +00:00
|
|
|
sw.WriteLine ("\t\tpublic static {0} Zero = new {0} ();", QualifiedName);
|
|
|
|
sw.WriteLine();
|
2004-06-02 20:28:42 +00:00
|
|
|
if (!DisableNew) {
|
|
|
|
sw.WriteLine ("\t\tpublic static " + QualifiedName + " New(IntPtr raw) {");
|
|
|
|
sw.WriteLine ("\t\t\tif (raw == IntPtr.Zero) {");
|
|
|
|
sw.WriteLine ("\t\t\t\treturn {0}.Zero;", QualifiedName);
|
|
|
|
sw.WriteLine ("\t\t\t}");
|
|
|
|
sw.WriteLine ("\t\t\t{0} self = new {0}();", QualifiedName);
|
|
|
|
sw.WriteLine ("\t\t\tself = ({0}) Marshal.PtrToStructure (raw, self.GetType ());", QualifiedName);
|
|
|
|
sw.WriteLine ("\t\t\treturn self;");
|
|
|
|
sw.WriteLine ("\t\t}");
|
|
|
|
sw.WriteLine ();
|
|
|
|
}
|
2002-11-10 10:03:51 +00:00
|
|
|
|
2005-01-24 18:25:02 +00:00
|
|
|
foreach (Ctor ctor in Ctors)
|
|
|
|
ctor.IsStatic = true;
|
2003-04-06 09:21:15 +00:00
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
base.GenCtors (gen_info);
|
2002-11-10 10:03:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|