gtk-ng: remove some woefully naive musings on GObject memory layout

pull/8237/head
Jeffrey C. Ollie 2025-08-16 16:51:25 -05:00 committed by Mitchell Hashimoto
parent 23b3adedc3
commit 34d10db7ea
1 changed files with 0 additions and 35 deletions

View File

@ -61,41 +61,6 @@ pub fn Common(
/// https://gitlab.gnome.org/GNOME/glib/-/blob/2c08654b62d52a31c4e4d13d7d85e12b989e72be/gobject/gtype.h#L555-571
/// https://gitlab.gnome.org/GNOME/glib/-/blob/2c08654b62d52a31c4e4d13d7d85e12b989e72be/gobject/gtype.h#L2673
///
/// This works because when you create a new object in GObject, the pointer
/// that you get back wasn't allocated using your original type struct.
/// Instead you get the following block of data:
///
///
///
///
///
/// Private
///
///
///
///
///
/// *object
/// TypeInstance
///
///
/// Class
/// *g_class
///
///
///
///
///
///
/// First is a block of data that holds the instance's private data. That private
/// data is accessed by taking the instance pointer and subtracting the size of the
/// private data to get a pointer to the data.
///
/// Next is an instance of a TypeInstance, whose purpose is to hold a pointer
/// to the class instance.
///
/// https://gitlab.gnome.org/GNOME/glib/-/blob/2c08654b62d52a31c4e4d13d7d85e12b989e72be/gobject/gtype.c#L1792-1912
///
pub fn getClass(self: *Self) ?*Self.Class {
const type_instance: *gobject.TypeInstance = @ptrCast(self);
return @ptrCast(type_instance.f_g_class orelse return null);