Commit Graph

140 Commits

Author SHA1 Message Date
Pavel Holejsovsky
d4c5e3b156 Add (allow-none) annotation for GValue setters.
Assorted g_value_set_xxx() and g_value_take_xxx() functions actually
allow NULL in source parameter.
2011-08-17 12:55:12 +02:00
Ryan Lortie
8f21e8145c gobject: remove -DG_DISABLE_CONST_RETURNS
GObject had a few cases of depending on G_CONST_RETURN not being defined
to 'const'.  Remove those in preparation for deprecation of
G_CONST_RETURN.
2011-06-09 11:11:30 -04:00
Matthias Clasen
d811f0cdc9 Fix a typo
And reword some docs.
2011-06-05 19:07:06 -04:00
Matthias Clasen
3b242bc5e9 Use g_param_spec_ref_sink instead of separate ref, sink 2011-06-04 23:43:05 -04:00
Matthias Clasen
38dc7955e4 No necessary to init qdata atomically 2011-06-04 23:14:32 -04:00
Alexander Larsson
0a918c0d2a Make g_object_get_data use the new faster g_datalist_get_data
https://bugzilla.gnome.org/show_bug.cgi?id=650458
2011-06-03 21:11:26 -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
Ryan Lortie
8382135265 glib: Rewrite gatomic.[ch]
- remove all inline assembly versions

 - implement the atomic operations using either GCC intrinsics, the
   Windows interlocked API or a mutex-based fallback

 - drop gatomic-gcc.c since these are now defined in the header file.
   Adjust Makefile.am accordingly.

 - expand the set of operations: support 'get', 'set', 'compare and
   exchange', 'add', 'or', and 'xor' for both integers and pointers

 - deprecate g_atomic_int_exchange_and_add since g_atomic_int_add (as
   with all the new arithmetic operations) now returns the prior value

 - unify the use of macros: all functions are now wrapped in macros that
   perform the proper casts and checks

 - remove G_GNUC_MAY_ALIAS use; it was never required for the integer
   operations (since casting between pointers that only vary in
   signedness of the target is explicitly permitted) and we avoid the
   need for the pointer operations by using simple 'void *' instead of
   'gpointer *' (which caused the 'type-punned pointer' warning)

 - provide function implementations of g_atomic_int_inc and
   g_atomic_int_dec_and_test: these were strictly macros before

 - improve the documentation to make it very clear exactly which types
   of pointers these operations may be used with

 - remove a few uses of the now-deprecated g_atomic_int_exchange_and_add

 - drop initialisation of gatomic from gthread (by using a GStaticMutex
   instead of a GMutex)

 - update glib.symbols and documentation sections files

Closes #650823 and #650935
2011-05-28 16:10:44 -04:00
Benjamin Otte
02877e2902 gobject: Warn if someone uses the wrong property in g_object_get/set
"Interface::property" was not detected before and led to a crash.
2011-05-02 19:33:51 +02:00
Dan Winship
bdc23c44e8 Fix compiler warnings 2011-05-02 11:50:23 -04:00
Stef Walter
6cd08472b2 Better documentation for g_value_dup_object().
State that NULL is returned when value is NULL.
2011-02-16 00:21:27 -05:00
Will Thompson
c2d98c5609 GObject: correct documentation typos 2011-02-11 15:21:12 +00:00
Michael Natterer
634e9e43cf gobject: add an empty default impl of GObject::constructed()
to allow unconditional upchaining.
2011-01-12 19:45:40 +01:00
Matthias Clasen
068d53358b Make object_interface_check_properties work
As pointed out in bug 637738, it does not currently work, since
g_type_class_peek always returns NULL.
2010-12-27 23:41:10 -05:00
Pavel Holejsovsky
58e36daf29 Add GI annotations to GObject 2010-12-27 22:08:15 +01:00
Pavel Holejsovsky
3264d8d159 Add GI annotations to GClosure and friends. 2010-12-19 22:20:21 +01:00
Pavel Holejsovsky
ea577d60d4 Add GI annotations to GValue and GValueArray. 2010-12-19 10:39:36 +01:00
Will Thompson
ac4722df1c g_object_get_property: document that value must be initialized
I couldn't tell from reading the documentation whether I had to pass in
an uninitialized value, or a value initialized to the exact type, or
something else. It turns out (from reading the source) that you have to
pass in an initialized value, but you can use any type to which the
property's actual type can be transformed.

So, let's document this.
2010-12-17 13:21:07 +00:00
Jonas Holmberg
349f547561 gobject: initialize memory in g_object_new_valist
memset parameters array in g_object_new_valist to zeroes when expanding
the array to avoid acces to uninitialized memory.
2010-11-28 18:27:30 -05:00
Ryan Lortie
1a1fc130ec New function: g_clear_object()
By analogy to g_clear_error, takes a pass-by-reference GObject reference
and, if non-%NULL, unrefs it and sets it equal to %NULL.

Bug #620263.
2010-11-08 18:21:51 -05:00
Florian Müllner
a62b43fd9c Fix deadlock in g_object_remove_toggle_ref()
The code section guarded with toggle_refs_mutex includes a call to
g_object_unref(), which may call toggle_refs_notify(). As the latter
tries to acquire the same mutex, glib locks up.

https://bugzilla.gnome.org/show_bug.cgi?id=632884
2010-10-22 14:52:41 +02:00
Alberto Garcia
b7616114c6 Protect access to closure, weak refs and toggle refs arrays
This fixes https://bugzilla.gnome.org/show_bug.cgi?id=613822
2010-10-21 15:20:55 +02:00
Emmanuele Bassi
44a8ff2f8f gobject: Improve install_properties()
Cache the parent type outside of the loop, and fix a typo in the
documentation.
2010-10-08 16:10:18 +01:00
Johan Dahlin
701ce5d201 [introspection] Add GObject annotations
These were moved in from gobject-introspection
2010-09-24 16:23:31 -03:00
Emmanuele Bassi
9cd43d7a4c gobject: Add install_properties()
Since we added g_object_notify_by_pspec(), an efficient way to install
and notify properties relies on storing the GParamSpec pointers inside
a static arrays, like we do for signal identifiers.

Instead of multiple calls to g_object_class_install_property(), we
should have a single function to take the static array of GParamSpecs
and iterate it.

https://bugzilla.gnome.org/show_bug.cgi?id=626919

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-13 12:34:53 +01:00
Emmanuele Bassi
016cecb179 Revert hack that broke things badly on Windows
This should fix bug #628952.

Don't include glib/gdatasetprivate.h directly. Especially don't define
GLIB_COMPILATION when doing that, as that causes breakage on Windows
because of the variable dllimport/dllexport stuff in gtypes.h that
checks GLIB_COMPILATION. That macro really should be defined only when
compiling code that goes into the libglib DLL. Otherwise the compiler
thinks that variables that should be imported from libglib are
actually defined in the code being compiled.

Just call g_atomic_pointer_get() as such, don't bother with
G_DATALIST_GET_FLAGS.

Signed-off-by: Tor Lillqvist <tml@iki.fi>
2010-09-08 12:06:49 +03:00
Emmanuele Bassi
01a46e5c65 Hack to include glib/gdatasetprivate.h directly
The gdatasetprivate.h header includes gatomic.h directly. It all works
well in GLib, but inside GObject it will trigger the single inclusion
guard.

Since this is a private header, and it's kind of a special case, one way
to fix it is to declare GLIB_COMPILATION around it and fool the single
inclusion guard in gatomic.h into thinking we're compiling GLib and not
GObject.
2010-09-04 17:25:37 +01:00
Olivier Crête
65797f7e54 notify: Remove g_object_notify_queue_from_object()
The function will not be safe with object locking in place, so we remove
it. The workaround is somewhat ugly, but it works.

https://bugzilla.gnome.org/show_bug.cgi?id=166020
2010-07-22 21:56:20 +02:00
Ryan Lortie
0fc50fa5f7 gobject/: fully remove gobjectalias hacks 2010-07-07 19:40:48 -04:00
Christian Dywan
272836936e Introduce G_PARAM_DEPRECATED and G_ENABLE_DIAGNOSTIC
See https://bugzilla.gnome.org/show_bug.cgi?id=601686
2010-06-23 16:45:12 +02:00
Damien Lespiau
f3879a4bdc Introduce g_object_notify_by_pspec()
g_object_notify_by_pspec() will emit the "notify" signal on the given
pspec, short-circuiting the hash table lookup needed by
g_object_notify(). The suggested and documented way of using
g_object_notify_by_pspec() is similar to the way of emitting signals
with their ID.

Emission tests (with no handler attached to the notify signal) show a
10-15% speedup over using g_object_notify().

https://bugzilla.gnome.org/show_bug.cgi?id=615425
2010-06-15 10:51:36 +01:00
Alexander Larsson
8e41be13ef Add dtrace and systemtap support for gobject
This adds static markers and systemtap tapsets for:

* type creation
* object lifetimes (creation, ref, unref, dispose, finalize)
* signal creation and emission

Signal emissions and finalization marker have a corresponding
*_end (or *-end in dtrace) version that is when the corresponding
operation is finished.

https://bugzilla.gnome.org/show_bug.cgi?id=606044
2010-05-27 14:51:41 -04:00
Edward Hervey
cecf61d1c3 gobject: Don't use G_PARAM_SPEC_VALUE_TYPE when we know the pspec is valid
https://bugzilla.gnome.org/show_bug.cgi?id=605667
2010-02-23 18:42:03 +01:00
Benjamin Otte
914120b970 Ensure values are memset to 0 when calling G_VALUE_COLLECT_INIT()
The reason we need to enforce this is that the GTypeValueTable
documentation explicitly states that memory is memset to 0 when the
value_init function is called.

https://bugzilla.gnome.org/show_bug.cgi?id=603590
2010-01-18 14:46:55 +01:00
Edward Hervey
40bf3aa5d2 gobject: Use new G_VALUE_COLLECT_INIT variant
Makes g_object_new_valist 20% to 30% faster (against 2321e5a).

Profiled against the pan newsreader which uses a variant of simple
and complex object creation.

https://bugzilla.gnome.org/show_bug.cgi?id=603590
2010-01-13 10:16:49 +01:00
Kamal Mostafa
f4ccd96ea1 g_object_new(): skip varargs for simple calls
g_object_new() avoids useless varargs processing for simple calls with no
properties.  Fixes https://bugzilla.gnome.org/show_bug.cgi?id=605883
2010-01-11 15:34:41 +01:00
Benjamin Otte
2a78adc5e3 Only add object to list new objects when it has a custom constructor
This works around the need to take a custom mutex twice and add the
object to a GSList of objects that are currently in construction for the
common case. Only when the constructor is overwritten do we use the
previous behavior and allow things like singleton objects.

The only slightly incompatible change is that previously, it was ok to
call g_object_set() on construct-only properties while the object was
initialized. This will now fail. If that behavior is needed, setting a
custom constructor that just chains up will reenable this functionality.

https://bugzilla.gnome.org/show_bug.cgi?id=557151
2009-11-30 20:52:33 +01:00
Cody Russell
855deaa578 g_object_unref racy condition can lead to crash
Store whether the object has a toggleref before decrementing the
refcount to prevent race condition when two threads simultaneously
try to unref an object with a refcount of 2.
Patch by Antoine Tremblay.

https://bugzilla.gnome.org/show_bug.cgi?id=551706
2009-10-06 12:27:12 -04:00
Alexander Larsson
1937765f9f Add fast path for construction with no params
This avoids a bunch of code and makes construction of simple objects
faster.

Object construction performance improvement:
         Non-Threaded   Threaded
Simple:           14%         5%
Complex:        -1.1%      -2.2%

Other tests stable.

https://bugzilla.gnome.org/show_bug.cgi?id=557100
2009-10-02 21:02:48 +02:00
Alexander Larsson
ffc625ec9b Don't freeze/thaw notification during construction if no properties
If the class has no properties there could be no notification anyway.
This is an important optimization for construction of simple objects.

Object construction performance improvement:
         Non-Threaded   Threaded
Simple:           84%        91%
Complex:        -1.4%      -0.6%

Other tests stable.

https://bugzilla.gnome.org/show_bug.cgi?id=557100
2009-10-02 21:02:48 +02:00
Alexander Larsson
302d13a757 Add a check that no properties are added after a class is derived
We can't support that, because that would cause the CLASS_HAS_PROPS_FLAG
class flag to not be correct.
2009-10-02 21:02:48 +02:00
Alexander Larsson
39a1fe5782 Add GObjectClass flag CLASS_HAS_PROPS_FLAG
This is set if a class or any of its parents have installed any
properties.

https://bugzilla.gnome.org/show_bug.cgi?id=557100
2009-10-02 21:02:48 +02:00
Matthias Clasen
f548330275 Fix "it's" vs "its" confusion throughout the source. Patch by Will
* Fix "it's" vs "its" confusion throughout the source. Patch
        by Will Thompson.


svn path=/trunk/; revision=7897
2009-02-23 04:30:06 +00:00
Matthias Clasen
c8e37b63e7 Fix strict aliasing warnings and viiolations to make GLib and
GLib users buildable with gcc 4.4. Patch by Jakub Jelinek.

        * glib/gatomic.[hc]: Add G_GNUC_MAY_ALIAS to pointer arguments,
        fix macro versions to only operate on objects of the same size.

        * glib/gdataset.c:
        * glib/gthread.[hc]:
        * glib/gdatasetprivate.h: Remove unnecessary casts in
        g_atomic_pointer_get calls.


svn path=/trunk/; revision=7875
2009-02-17 16:14:39 +00:00
Behdad Esfahbod
bf201e0fb7 Bug 565136 – Gobject's "notify" signal parameters are wrong in gtk-doc
2009-01-02  Behdad Esfahbod  <behdad@gnome.org>

        Bug 565136 – Gobject's "notify" signal parameters are wrong in gtk-doc
        Patch from  Andrzej Zaborowski

        * gobject.c (g_object_do_class_init): Fix param order in docs.


svn path=/trunk/; revision=7759
2009-01-02 06:09:26 +00:00
Matthias Clasen
8b14e3744c Expand the docs of g_object_class_install_property. Proposed by Maciej
* gobject.c: Expand the docs of g_object_class_install_property.
Proposed by Maciej Piechotka

svn path=/trunk/; revision=7642
2008-11-04 04:17:40 +00:00
Dan Winship
7afe2bb07a add uint* -> int* casts in g_atomic_int calls to avoid gcc warnings
* gobject.c (g_object_ref, g_object_unref)
	(g_object_freeze_notify, g_object_notify, g_object_thaw_notify):
	* gparam.c (g_param_spec_ref, g_param_spec_unref):
	* gsignal.c (handler_ref, handler_unref_R): add uint* -> int*
	casts in g_atomic_int calls to avoid gcc warnings

svn path=/trunk/; revision=7551
2008-09-26 16:00:33 +00:00
Johan Dahlin
306db46123 Bug 548800 – Missing a g_object_get_type function
2008-08-21  Johan Dahlin  <johan@gnome.org>

    Bug 548800 – Missing a g_object_get_type function

    * gobject.c (g_object_get_type):
    * gobject.h:
    * gobject.symbols:
    Add g_object_get_type


svn path=/trunk/; revision=7377
2008-08-21 09:18:25 +00:00
Michael Natterer
6f1f1342e4 remove unused #define PREALLOC_CPARAMS.
2008-07-04  Michael Natterer  <mitch@imendio.com>

	* gobject.c: remove unused #define PREALLOC_CPARAMS.


svn path=/trunk/; revision=7159
2008-07-04 13:08:39 +00:00
Matthias Clasen
d6d221911d Fix up section comments
svn path=/trunk/; revision=7137
2008-07-02 03:43:13 +00:00