Ryujinx-GtkSharp/glib/Opaque.cs
Rachel Hestilow 967e3e9c5a 2002-07-30 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: Change hasDefaultConstructor to protected,
	adjust now that it is an attr and not a subnode. Also add virtual
	property AssignToName (for ctors).

	* generator/Ctor.cs: Add property ForceStatic.
	(Generate): Optimize return code a bit for the static case.

	* generator/Method.cs: Assign to a "raw_ret" pointer before calling
	FromNativeReturn.

	* generator/Parameters.cs: Change "out ref" to "out", not "ref".

	* generator/Property.cs: Fix to work correctly with all object and
	struct types (mostly just some if-cases added).

	* generator/SignalHandler.cs: Remove args_type and argfields (unused).
	(Generate): Initialize struct if necessary.

	* generator/StructBase.cs: Massive reworking to support methods, ctors,
	etc.

	* generator/SymbolTable.cs: Add GdkAtom and gconstpointer simple types.

	* glib/Boxed.cs: Accept both IntPtr and object ctors. Add access for both.

	* glib/Opaque.cs: Fix copy/pasted copyright notice, remove data and event
	fields. Fix docs.

	* glib/Value.cs: Work correctly with boxed properties.

	* gnome/Modules.cs: Use new struct ctors.

	* gnome/Program.custom: Remove Get, this is being generated now.

	* parser/Gdk.metadata: Fix the drawable classes to inherit correctly.

	* parser/Metadata.pm: Change per-class attributes to actually be
	attributes.

	* parser/Gtk.metadata: Add a dummy attribute value for disabledefaultctor.

	* parser/gapi2xml.pl: Add hacks for the (broken) Drawable and Bitmap
	typedefs.

	* sample/test/TestColorSelection.cs: Display color string in hex format,
	update to use IsNull instead of == null, and size dialog to look pretty.

	* sample/Size.cs: Added.

svn path=/trunk/gtk-sharp/; revision=6264
2002-07-30 23:02:12 +00:00

142 lines
2.8 KiB
C#

// Opaque .cs - Opaque struct wrapper implementation
//
// Authors: Bob Smith <bob@thestuff.net>
// Mike Kestner <mkestner@speakeasy.net>
// Rachel Hestilow <hestilow@ximian.com>
//
// (c) 2001 Bob Smith and Mike Kestner, 2002 Rachel Hestilow
namespace GLib {
using System;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;
/// <summary>
/// Object Class
/// </summary>
///
/// <remarks>
/// Wrapper class for GObject.
/// </remarks>
public class Opaque : IWrapper {
// Private class and instance members
IntPtr _obj;
static Hashtable Opaques = new Hashtable();
/// <summary>
/// GetObject Shared Method
/// </summary>
///
/// <remarks>
/// Used to obtain a CLI typed object associated with a
/// given raw object pointer. This method is primarily
/// used to wrap object references that are returned
/// by either the signal system or raw class methods that
/// return opaque struct references.
/// </remarks>
///
/// <returns>
/// The wrapper instance.
/// </returns>
public static Opaque GetOpaque(IntPtr o)
{
Opaque obj = (Opaque)Opaques[(int)o];
if (obj != null) return obj;
return null; //FIXME: Call TypeParser here eventually.
}
/// <summary>
/// Opaque Constructor
/// </summary>
///
/// <remarks>
/// Dummy constructor needed for derived classes.
/// </remarks>
public Opaque () {}
/// <summary>
/// Opaque Constructor
/// </summary>
///
/// <remarks>
/// Creates an opaque wrapper from a raw object reference.
/// </remarks>
public Opaque (IntPtr raw)
{
Raw = raw;
}
/// <summary>
/// Raw Property
/// </summary>
///
/// <remarks>
/// The raw Opaque reference associated with this wrapper.
/// Only subclasses of Opaque can access this read/write
/// property. For public read-only access, use the
/// Handle property.
/// </remarks>
protected IntPtr Raw {
get {
return _obj;
}
set {
Opaques [value] = this;
_obj = value;
}
}
/// <summary>
/// Handle Property
/// </summary>
///
/// <remarks>
/// The raw Opaque reference associated with this object.
/// Subclasses can use Raw property for read/write
/// access.
/// </remarks>
public IntPtr Handle {
get {
return _obj;
}
set {
_obj = value;
}
}
public override bool Equals (object o)
{
if (!(o is Opaque))
return false;
return (Handle == ((Opaque) o).Handle);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return Handle.GetHashCode ();
}
public static explicit operator System.IntPtr (Opaque opaque) {
return opaque.Handle;
}
}
}