Commit Graph

130 Commits

Author SHA1 Message Date
Owen W. Taylor
011bf876e7 Add simple instance count facility
Add GOBJECT_DEBUG=instance-count which enables internal accounting
of the number of instances of each GType, and g_type_get_instance_count()
to retrieve the result.

https://bugzilla.gnome.org/show_bug.cgi?id=354457
2014-10-11 13:54:29 -04:00
Kang Hu
baef9d1811 gobject: move _g_type_debug_flags from gtype.h to gtype-private.h
_g_type_debug_flags is used internally to suport GOBJECT_DEBUG
environment variable. it should never be exposed to the outside.

https://bugzilla.gnome.org/show_bug.cgi?id=729914
2014-06-28 14:00:32 -04:00
Matthias Clasen
adfaf0e456 docs: GType documentation cleanup
Still some markup left.
2014-05-31 20:55:00 -04:00
Emmanuele Bassi
24ab95582b docs: Replace <function> XML tag with back ticks
https://bugzilla.gnome.org/show_bug.cgi?id=731050
2014-05-31 19:22:15 +01:00
Edward Hervey
6072e3650f gtype: Add check for fundamental instance type
When checking whether an instance is of a given fundamental type (such
as G_TYPE_OBJECT), we can avoid over 60%+ of the cost of checking types.

https://bugzilla.gnome.org/show_bug.cgi?id=730984
2014-05-31 15:45:29 +02:00
Mathieu Bridon
24fdee7a78 Fix some typos in documentation 2014-05-05 18:30:56 +08:00
Philip Withnall
704852ff09 gobject: Document that classes/objects/interfaces are zero-filled
On initialisation, GObject guarantees to zero-fill
class/object/interface structures. Document this so people don’t spend
forever writing:
    my_object->priv->some_member = NULL;
    my_object->priv->some_other_member = NULL;

https://bugzilla.gnome.org/show_bug.cgi?id=729167
2014-04-29 10:40:20 +01:00
Volker Sobek
4441595378 docs: Remove <!-- --> comment before plural s
These did show up in the html. Since symbol names are checked for a
trailing plural s when generating the docs, the links stay functional
after removing these comments.

https://bugzilla.gnome.org/show_bug.cgi?id=728380
2014-04-24 13:42:37 +02:00
Volker Sobek
9f0ad54c80 docs: Use markdown links in all .c and .h files
Commit e7fd3de86d already did most of this.

https://bugzilla.gnome.org/show_bug.cgi?id=728285
2014-04-15 22:19:07 +02:00
Sebastian Dröge
012011538f gtype – Mark _get_instance_private() function as G_GNUC_UNUSED
clang likes to complain about it being unused.

https://bugzilla.gnome.org/show_bug.cgi?id=723899
2014-03-08 09:01:52 -05:00
Matthias Clasen
49cc207e35 docs: Ditch more markup
Some markup was hiding in docs in headers. Drop it there, too.
2014-03-02 18:23:43 -05:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Misty De Meo
54e79d7dcb gobject: Fix compilation on OS X/ppc64
Apple's GCC compilers cannot deal well with 64-bit pointers in
transparent unions on ppc64, so compilation of
_G_DEFINE_BOXED_TYPE_BEGIN was failing. Fortunately glib already
provides a fallback for compilers that can't deal with it; this adds
this specific case to the check.

https://bugzilla.gnome.org/show_bug.cgi?id=647145
2013-09-19 08:39:18 -04:00
Dieter Verfaillie
9bcb6d3f00 Fix G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE documentation
https://bugzilla.gnome.org/show_bug.cgi?id=706469
2013-08-22 20:52:17 +02:00
Rico Tzschichholz
023e3b31a5 Fix a typo
Introduced by 3b01cbe8a8
2013-07-27 09:02:58 +02:00
Matthias Clasen
3b01cbe8a8 Document restrictions on private names
With the new machinery, private structs must be named
TypeNamePrivate if TypeName is the name of the instance
struct.
2013-07-26 14:42:22 -04:00
Sébastien Wilmet
b3968fb150 Improve documentation
- Mention G_SOURCE_CONTINUE and G_SOURCE_REMOVE in the GSourceFunc doc;
- Mention G_PARAM_READWRITE and G_PARAM_STATIC_STRINGS in the
  GParamFlags doc;
- Fix "Since:" version for G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE;
- Fix typo.

https://bugzilla.gnome.org/show_bug.cgi?id=704250
2013-07-20 11:07:46 +02:00
Emmanuele Bassi
a4c352cd99 Ensure that MAX_ALLOWED keeps working with the type macros
When using the GLIB_VERSION_MAX_ALLOWED macro to define the upper bound
of allowed API the G_DEFINE_TYPE_EXTENDED starts warning about the newly
added g_type_class_adjust_private_offset() function; this effectively
introduces a run-time dependency on GLib 2.38 even if we don't use its
API explicitly.

https://bugzilla.gnome.org/show_bug.cgi?id=703191
2013-07-03 09:37:03 -04:00
Emmanuele Bassi
54cc43630d Rename the generated private data getter function
As it turns out, we have examples of internal functions called
type_name_get_private() in the wild (especially among older libraries),
so we need to use a name for the per-instance private data getter
function that hopefully won't conflict with anything.
2013-06-24 15:43:04 +01:00
Emmanuele Bassi
39ba7c8142 gobject: Add private field access macros
Similar to G_STRUCT_MEMBER and G_STRUCT_MEMBER_P, but automatically using
the G_PRIVATE_OFFSET macro.

https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Emmanuele Bassi
d91d114a54 Add G_PRIVATE_OFFSET
A macro that evaluates to the offset of a field inside an instance
private data structure.

https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Emmanuele Bassi
d3dec6ec80 Allow registering instance private data during get_type()
For static types, it should be possible to register a private data
structure right when we are registering the type, i.e. from the
get_type() implementation. By allowing this, we can take advantage of
the existing type definition macros to cut down the amount of code
necessary (as well as the knowledge baggage) when creating a new type.

The main issue with this new feature is that it cannot be mixed with the
old idiomatic way of adding private instance data by calling a function
in the middle of the class_init() implementation, as that imposes the
additional constraint of initializing the whole type hierarchy in order
to retrieve the offset of the private data in the GTypeInstance
allocation.

For this reason we are going to follow a two-step process; in the first
step, we are going to introduce the new (semi-private) API to register
the intent to add private instance data from within the get_type()
implementation, and hide it behind a macro; at the same time, the
G_DEFINE_TYPE_EXTENDED macro is going to be modified so that it will
register the private instance data if the macro was used, using a new
(semi-private) function as well. Once we have migrated all our code, we
will make the first new function perform the actual private data
registration, and turn the second new function into a no-op. This should
guarantee a transparent migration of existing code to the new idiomatic
form.

https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Ryan Lortie
c30c0bb34d GType: add accessor for instance private offset
Since instance private data is now always at a constant offset to the
instance pointer, we can add an accessor for it that doesn't also
require an instance.

The idea is that classes can call this from their class_init and store
it in a file-scoped static variable and use that to find their private
data on instances very quickly, without a priv pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=698056
2013-04-23 14:39:09 -04:00
Andres G. Aragoneses
859e4239c5 gobject: fix G_DEFINE_TYPE_EXTENDED docs so code snippet actually compiles
Flags being used in the G_DEFINE_TYPE_EXTENDED sample was "0", so it
should expand to 0 as well, otherwise the compiler would bark with:
maman-bar.c: In function ‘maman_bar_get_type’:
maman-bar.c:36:53: error: ‘flags’ undeclared (first use in this function)
maman-bar.c:36:53: note: each undeclared identifier is reported only once for each function it appears in

https://bugzilla.gnome.org/show_bug.cgi?id=697250
2013-04-04 12:11:06 +01:00
Ryan Lortie
0156092a42 various: add GLIB_AVAILABLE_IN_ALL everywhere else
Add the GLIB_AVAILABLE_IN_ALL annotation to all old functions (that
haven't already been annotated with the GLIB_AVAILABLE_IN_* macros or a
deprecation macro).

If we discover in the future that we cannot use only one macro on
Windows, it will be an easy sed patch to fix that.

https://bugzilla.gnome.org/show_bug.cgi?id=688681
2013-01-13 13:11:57 -05:00
Matthias Clasen
e1b99b2ddc Move single-include guards inside include guards
gcc has optimizations for include guards that only work
if they are outermost in the the header.
https://bugzilla.gnome.org/show_bug.cgi?id=689810
2012-12-27 23:43:14 -05:00
Alexander Larsson
e218b96a6b Add g_type_get_type_registration_serial()
This lets you cache type lookup information and then know when
the cache information is out of date. In particular, we want this
in order to be able to cache g_type_from_name() lookups in the Gtk+
theme machinery.

https://bugzilla.gnome.org/show_bug.cgi?id=689847
2012-12-10 12:55:28 +01:00
Ryan Lortie
df02fa1e4c Properly deprecate g_type_init()
Now that all internal users of it are gone.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Ryan Lortie
7c42ab23b5 Convert g_type_init() to a ctor
Move the guts of g_type_init() into a ctor and turn g_type_init() itself
into a do-nothing function.

g_type_init_with_debug_flags() now ignores its arguments, but it has
always been possible to achieve the same effect via environment
variables.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Emmanuele Bassi
2a87010831 Constify collect and lcopy strings in GTypeValueTable
This avoids warnings when creating idiomatic value tables, like:

  static const GTypeValueTable _clutter_shader_float_value_table = {
    clutter_value_init_shader_float,
    clutter_value_free_shader_float,
    clutter_value_copy_shader_float,
    clutter_value_peek_pointer,
    "ip",
    clutter_value_collect_shader_float,
    "pp",
    clutter_value_lcopy_shader_float
  };

Because the strings are literals. And, really: nobody should be using
allocated values for the collection and lcopy strings.

https://bugzilla.gnome.org/show_bug.cgi?id=671545
2012-07-05 23:27:35 -04:00
Dan Winship
e011d2c921 Add g_type_ensure() and use it rather than playing games with volatile
https://bugzilla.gnome.org/show_bug.cgi?id=605976
2012-05-15 13:46:38 -04:00
Nicola Fontana
f24d8247b3 Do not use static GTypeInfo and GInterfaceInfo
Either g_type_register_static_simple (used by G_DEFINE_TYPE_EXTENDED)
and G_IMPLEMENT_INTERFACE use automatic variables for GTypeInfo and
GInterfaceInfo structs, while tutorials and source code often use
static variables. This commit consistently adopts the former method.

https://bugzilla.gnome.org/show_bug.cgi?id=600161
2011-11-29 22:03:25 -05:00
Ryan Lortie
9829d04be8 GObject docs: resolve broken links
Some links were broken due to typos, because functionality was removed
in GLib 2.0 or for various other reasons.  Fix up as many of them as is
reasonable.
2011-09-05 18:46:59 -04:00
Behdad Esfahbod
ea6e2968bf [gobject] Fix G_DEFINE_BOXED_TYPE compilation with C++ 2011-08-11 19:03:02 +02:00
Ryan Lortie
8073759f8c Remove all uses of G_CONST_RETURN
Just use 'const'.

https://bugzilla.gnome.org/show_bug.cgi?id=644611
2011-06-09 11:15:40 -04:00
Colin Walters
3bd3067ffc gobject: Use _ prefixing in private headers over G_GNUC_INTERNAL in public headers
This helps out gtk-doc and g-ir-scanner, and also makes much clearer
what's private versus public.

https://bugzilla.gnome.org/show_bug.cgi?id=651745
2011-06-03 12:40:01 -04:00
Murray Cumming
30fdc1a799 Docs: Changed can not to cannot. 2011-03-24 09:33:55 +01:00
Emmanuele Bassi
08f0a31289 Revert "Remove all uses of G_CONST_RETURN"
This reverts commit 36741245cc.

The removal has not been discussed, except on Bugzilla:

https://bugzilla.gnome.org/show_bug.cgi?id=644611
2011-03-15 09:03:28 +00:00
Ryan Lortie
36741245cc Remove all uses of G_CONST_RETURN
Just use 'const'.
2011-03-15 01:32:22 -04:00
Matthias Clasen
9dd1f75a41 Document G_VALUE_NOCOPY_CONTENTS
https://bugzilla.gnome.org/show_bug.cgi?id=624943
2011-02-18 22:42:24 -05:00
Christian Persch
dc1999316d Add G_DEFINE_{BOXED,POINTER}_TYPE[_WITH_CODE]
Add convenience type definition macros for boxed and pointer types
similar to G_DEFINE_TYPE for object types. Bug #449565.
2010-08-18 00:12:22 +02:00
Christian Persch
db68f8203a Add g_value_take_variant
Turns out we do need g_value_take_variant(), so we can correctly
implement VARIANT:* marshalers.

Bug #621947.
2010-06-19 19:07:36 +02:00
Christian Persch
4708b8ecc3 Add fundamental type and pspec for GVariant
Make G_TYPE_VARIANT a fundamental type instead of boxed, and add
g_variant_{set,get,dup}_variant.

Add GParamSpecVariant.

Bug #610863.
2010-06-17 21:00:54 +02:00
Sebastian Dröge
41383b303c Bug 612502 - Add support for class private data
This adds the two new functions g_type_add_class_private()
and g_type_class_get_private() and a convenience macro
for the getter G_TYPE_CLASS_GET_PRIVATE().
2010-03-17 15:11:00 +01:00
Javier Jardón
dba6cef3c9 [docs] Fix G_DEFINE_INTERFACE "Since" tag
This symbol is available since Glib 2.24, not 2.20.
2009-12-21 23:07:13 +01:00
Javier Jardón
9917024949 G_DEFINE_INTERFACE_* documentation is not generated
Fix the documentation: Replace "@Since:" with "Since:"

https://bugzilla.gnome.org/show_bug.cgi?id=604645
2009-12-19 02:17:33 +01:00
Dan Winship
91d96350a7 Add G_DEFINE_INTERFACE
This is a macro similar to G_DEFINE_TYPE but it lets you define
interfaces rather than classes.

For discussion, see bug #320482
2009-12-01 10:44:42 +01:00
Edward Hervey
68b1ca0443 gobject/gtype.h: Fix _G_TYPE_CVH macro. Fixes #597194
If __val doesn't exist, we shouldn't do any other checks.
2009-10-03 16:17:17 +02:00
Matthias Clasen
8b3853b8a1 Reduce false positives in static analysis
Tools like clang fail to recognize that stanzas like
g_return_if_fail (GTK_IS_FOO (w)) guarantee w != NULL. By minimally
rewriting the type-checking macros, we can avoid these false positives.
2009-09-18 19:20:06 -04:00
Matthias Clasen
e68a35689f Fix G_DEFINE_TYPE_EXTENDED docs
Make the docs for G_DEFINE_TYPE_EXTENDED match the actual
definition of the macro.  (#577985)
2009-04-09 14:56:49 -04:00