1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
/*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gobject.TypeClass;
private import gobject.ObjectG;
private import gobject.c.functions;
public import gobject.c.types;
public import gtkc.gobjecttypes;
private import gtkd.Loader;
/**
* An opaque structure used as the base of all classes.
*/
public class TypeClass
{
/** the main Gtk struct */
protected GTypeClass* gTypeClass;
protected bool ownedRef;
/** Get the main Gtk struct */
public GTypeClass* getTypeClassStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gTypeClass;
}
/** the main Gtk struct as a void* */
protected void* getStruct()
{
return cast(void*)gTypeClass;
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GTypeClass* gTypeClass, bool ownedRef = false)
{
this.gTypeClass = gTypeClass;
this.ownedRef = ownedRef;
}
~this ()
{
if ( Linker.isLoaded(LIBRARY_GOBJECT) && ownedRef )
g_type_class_unref(gTypeClass);
}
/**
* Registers a private structure for an instantiatable type.
*
* When an object is allocated, the private structures for
* the type and all of its parent types are allocated
* sequentially in the same memory block as the public
* structures, and are zero-filled.
*
* Note that the accumulated size of the private structures of
* a type and all its parent types cannot exceed 64 KiB.
*
* This function should be called in the type's class_init() function.
* The private structure can be retrieved using the
* G_TYPE_INSTANCE_GET_PRIVATE() macro.
*
* The following example shows attaching a private structure
* MyObjectPrivate to an object MyObject defined in the standard
* GObject fashion in the type's class_init() function.
*
* Note the use of a structure member "priv" to avoid the overhead
* of repeatedly calling MY_OBJECT_GET_PRIVATE().
*
* |[<!-- language="C" -->
* typedef struct _MyObject MyObject;
* typedef struct _MyObjectPrivate MyObjectPrivate;
*
* struct _MyObject {
* GObject parent;
*
* MyObjectPrivate *priv;
* };
*
* struct _MyObjectPrivate {
* int some_field;
* };
*
* static void
* my_object_class_init (MyObjectClass *klass)
* {
* g_type_class_add_private (klass, sizeof (MyObjectPrivate));
* }
*
* static void
* my_object_init (MyObject *my_object)
* {
* my_object->priv = G_TYPE_INSTANCE_GET_PRIVATE (my_object,
* MY_TYPE_OBJECT,
* MyObjectPrivate);
* // my_object->priv->some_field will be automatically initialised to 0
* }
*
* static int
* my_object_get_some_field (MyObject *my_object)
* {
* MyObjectPrivate *priv;
*
* g_return_val_if_fail (MY_IS_OBJECT (my_object), 0);
*
* priv = my_object->priv;
*
* return priv->some_field;
* }
* ]|
*
* Deprecated: Use the G_ADD_PRIVATE() macro with the `G_DEFINE_*`
* family of macros to add instance private data to a type
*
* Params:
* privateSize = size of private structure
*
* Since: 2.4
*/
public void addPrivate(size_t privateSize)
{
g_type_class_add_private(gTypeClass, privateSize);
}
/**
* Gets the offset of the private data for instances of @g_class.
*
* This is how many bytes you should add to the instance pointer of a
* class in order to get the private data for the type represented by
* @g_class.
*
* You can only call this function after you have registered a private
* data area for @g_class using g_type_class_add_private().
*
* Returns: the offset, in bytes
*
* Since: 2.38
*/
public int getInstancePrivateOffset()
{
return g_type_class_get_instance_private_offset(gTypeClass);
}
/** */
public void* getPrivate(GType privateType)
{
return g_type_class_get_private(gTypeClass, privateType);
}
/**
* This is a convenience function often needed in class initializers.
* It returns the class structure of the immediate parent type of the
* class passed in. Since derived classes hold a reference count on
* their parent classes as long as they are instantiated, the returned
* class will always exist.
*
* This function is essentially equivalent to:
* g_type_class_peek (g_type_parent (G_TYPE_FROM_CLASS (g_class)))
*
* Returns: the parent class
* of @g_class
*/
public TypeClass peekParent()
{
auto __p = g_type_class_peek_parent(gTypeClass);
if(__p is null)
{
return null;
}
return ObjectG.getDObject!(TypeClass)(cast(GTypeClass*) __p);
}
/**
* Decrements the reference count of the class structure being passed in.
* Once the last reference count of a class has been released, classes
* may be finalized by the type system, so further dereferencing of a
* class pointer after g_type_class_unref() are invalid.
*/
public void unref()
{
g_type_class_unref(gTypeClass);
}
/**
* A variant of g_type_class_unref() for use in #GTypeClassCacheFunc
* implementations. It unreferences a class without consulting the chain
* of #GTypeClassCacheFuncs, avoiding the recursion which would occur
* otherwise.
*/
public void unrefUncached()
{
g_type_class_unref_uncached(gTypeClass);
}
/** */
public static void adjustPrivateOffset(void* gClass, int* privateSizeOrOffset)
{
g_type_class_adjust_private_offset(gClass, privateSizeOrOffset);
}
/**
* This function is essentially the same as g_type_class_ref(),
* except that the classes reference count isn't incremented.
* As a consequence, this function may return %NULL if the class
* of the type passed in does not currently exist (hasn't been
* referenced before).
*
* Params:
* type = type ID of a classed type
*
* Returns: the #GTypeClass
* structure for the given type ID or %NULL if the class does not
* currently exist
*/
public static TypeClass peek(GType type)
{
auto __p = g_type_class_peek(type);
if(__p is null)
{
return null;
}
return ObjectG.getDObject!(TypeClass)(cast(GTypeClass*) __p);
}
/**
* A more efficient version of g_type_class_peek() which works only for
* static types.
*
* Params:
* type = type ID of a classed type
*
* Returns: the #GTypeClass
* structure for the given type ID or %NULL if the class does not
* currently exist or is dynamically loaded
*
* Since: 2.4
*/
public static TypeClass peekStatic(GType type)
{
auto __p = g_type_class_peek_static(type);
if(__p is null)
{
return null;
}
return ObjectG.getDObject!(TypeClass)(cast(GTypeClass*) __p);
}
alias doref = ref_;
/**
* Increments the reference count of the class structure belonging to
* @type. This function will demand-create the class if it doesn't
* exist already.
*
* Params:
* type = type ID of a classed type
*
* Returns: the #GTypeClass
* structure for the given type ID
*/
public static TypeClass ref_(GType type)
{
auto __p = g_type_class_ref(type);
if(__p is null)
{
return null;
}
return ObjectG.getDObject!(TypeClass)(cast(GTypeClass*) __p);
}
}
|