+Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
+
+ * glib-object.h: add gvaluearray.h.
+
+ * gstring.[hc]: fixup naming of g_string_sprint*.
+
+ * gtypes.h: fixed GCompareDataFunc naming.
+
2001-03-07 Christian Meyer <chrisime@gnome.org>
* configure.in: Added de (German) to ALL_LINGUAS.
+Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
+
+ * glib-object.h: add gvaluearray.h.
+
+ * gstring.[hc]: fixup naming of g_string_sprint*.
+
+ * gtypes.h: fixed GCompareDataFunc naming.
+
2001-03-07 Christian Meyer <chrisime@gnome.org>
* configure.in: Added de (German) to ALL_LINGUAS.
+Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
+
+ * glib-object.h: add gvaluearray.h.
+
+ * gstring.[hc]: fixup naming of g_string_sprint*.
+
+ * gtypes.h: fixed GCompareDataFunc naming.
+
2001-03-07 Christian Meyer <chrisime@gnome.org>
* configure.in: Added de (German) to ALL_LINGUAS.
+Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
+
+ * glib-object.h: add gvaluearray.h.
+
+ * gstring.[hc]: fixup naming of g_string_sprint*.
+
+ * gtypes.h: fixed GCompareDataFunc naming.
+
2001-03-07 Christian Meyer <chrisime@gnome.org>
* configure.in: Added de (German) to ALL_LINGUAS.
+Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
+
+ * glib-object.h: add gvaluearray.h.
+
+ * gstring.[hc]: fixup naming of g_string_sprint*.
+
+ * gtypes.h: fixed GCompareDataFunc naming.
+
2001-03-07 Christian Meyer <chrisime@gnome.org>
* configure.in: Added de (German) to ALL_LINGUAS.
+Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
+
+ * glib-object.h: add gvaluearray.h.
+
+ * gstring.[hc]: fixup naming of g_string_sprint*.
+
+ * gtypes.h: fixed GCompareDataFunc naming.
+
2001-03-07 Christian Meyer <chrisime@gnome.org>
* configure.in: Added de (German) to ALL_LINGUAS.
+Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
+
+ * glib-object.h: add gvaluearray.h.
+
+ * gstring.[hc]: fixup naming of g_string_sprint*.
+
+ * gtypes.h: fixed GCompareDataFunc naming.
+
2001-03-07 Christian Meyer <chrisime@gnome.org>
* configure.in: Added de (German) to ALL_LINGUAS.
+Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
+
+ * glib-object.h: add gvaluearray.h.
+
+ * gstring.[hc]: fixup naming of g_string_sprint*.
+
+ * gtypes.h: fixed GCompareDataFunc naming.
+
2001-03-07 Christian Meyer <chrisime@gnome.org>
* configure.in: Added de (German) to ALL_LINGUAS.
+Wed Mar 7 09:33:27 2001 Tim Janik <timj@gtk.org>
+
+ * gobject/Makefile.am: shuffled rules to avoid excessive
+ rebuilds.
+
+ * gobject/gobject-sections.txt: updates.
+
+ * gobject/tmpl/*: bunch of updates, added another patch
+ from Eric Lemings <eric.b.lemings@lmco.com>.
+
2001-03-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/glib-sections.txt, glib/tmpl/messages.sgml: Removed
+<!-- ##### USER_FUNCTION GCompareFuncData ##### -->
+<para>
+
+</para>
+
+@a:
+@b:
+@user_data:
+@Returns:
+
<!-- ##### USER_FUNCTION GCompletionStrcmpFunc ##### -->
<para>
@data:
-<!-- ##### USER_FUNCTION GCompareFuncData ##### -->
-<para>
-
-</para>
-
-@a:
-@b:
-@user_data:
-@Returns:
-
-
<!-- ##### FUNCTION g_qsort_with_data ##### -->
<para>
@Returns: the destination #GString.
-<!-- ##### FUNCTION g_string_sprintf ##### -->
+<!-- ##### MACRO g_string_sprintf ##### -->
<para>
Writes a formatted string into a #GString.
This is similar to the standard <function>sprintf()</function> function,
The previous contents of the GString are destroyed.
</para>
+<!-- # Unused Parameters # -->
@string: a #GString.
@format: the string format. See the <function>sprintf()</function>
documentation.
@Varargs: the parameters to insert into the format string.
-<!-- ##### FUNCTION g_string_sprintfa ##### -->
+<!-- ##### MACRO g_string_sprintfa ##### -->
<para>
Appends a formatted string onto the end of a #GString.
This function is is similar to g_string_sprintf() except that
the text is appended to the GString.
</para>
+<!-- # Unused Parameters # -->
@string: a #GString.
@format: the string format. See the <function>sprintf()</function>
documentation.
# The name of the module.
DOC_MODULE=gobject
-
# The top-level SGML file.
DOC_MAIN_SGML_FILE=gobject-docs.sgml
-
+# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE)
+EXTRA_DIST +=
# The directory containing the source code. Relative to $(srcdir)
DOC_SOURCE_DIR=../../../gobject
-
# Extra options to supply to gtkdoc-scan
SCAN_OPTIONS=
-
# Extra options to supply to gtkdoc-mkdb
MKDB_OPTIONS=
-
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=--extra-dir=$(srcdir)/../glib/html
+# Images to copy into HTML directory
+HTML_IMAGES =
# Used for dependencies
HFILE_GLOB=$(top_srcdir)/gobject/*.h
CFILE_GLOB=$(top_srcdir)/gobject/*.c
-
# Headers to ignore
IGNORE_HFILES= \
+ .saved \
+ glib-genmarshal.c \
gbsearcharray.h
-
# Extra files to add when scanning
EXTRA_HFILES=
-# Images to copy into HTML directory
-HTML_IMAGES =
-
-# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE)
-content_files =
-
-# Other files to distribute
-extra_files =
-
# CFLAGS and LDFLAGS for compiling scan program. Only needed
# if $(DOC_MODULE).types is non-empty.
GTKDOC_CFLAGS =
GTKDOC_LIBS =
-
# Commands for compiling and linking
GTKDOC_CC=$(LIBTOOL) --mode=compile $(CC)
GTKDOC_LD=$(LIBTOOL) --mode=link $(CC)
TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
-EXTRA_DIST = \
- $(content_files) \
- $(extra_files) \
- $(HTML_IMAGES) \
- $(DOC_MAIN_SGML_FILE) \
- $(DOC_MODULE).types \
- $(DOC_MODULE)-sections.txt \
- $(DOC_MODULE)-overrides.txt
+DOC_STAMPS = $(srcdir)/tmpl.stamp $(srcdir)/sgml.stamp $(srcdir)/html.stamp \
+ build-scan.stamp build-tmpl.stamp build-sgml.stamp build-html.stamp
+# gtkdoc-mktmpl: creates, and on changes touches: tmpl.stamp
+# gtkdoc-mkdb: creates, and on changes touches: sgml.stamp
+# gtkdoc-mkhtml: creates, and on changes touches: html.stamp
-DOC_STAMPS=scan-build.stamp tmpl-build.stamp sgml-build.stamp html-build.stamp
-if ENABLE_GTK_DOC
-all-local: html-build.stamp
+.PHONY: gtkdoc-build-all
+if ENABLE_GTK_DOC
SCANOBJ_FILES = \
$(DOC_MODULE).args \
$(DOC_MODULE).hierarchy \
$(DOC_MODULE).signal
-scan-build.stamp: $(HFILE_GLOB)
+all-local: gtkdoc-build-all
+
+gtkdoc-build-all: build-sgml.stamp build-html.stamp
+ @true
+build-scan.stamp: $(HFILE_GLOB)
@echo '*** Scanning header files ***'
cd $(srcdir) && ( \
- if grep -l '^.+$$' $(DOC_MODULE).types > /dev/null ; then \
+ if grep -l '^.+$$' $(DOC_MODULE).types > /dev/null 2>/dev/null ; then \
CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" CFLAGS="$(GTKDOC_CFLAGS)" LDFLAGS="$(GTKDOC_LIBS)" gtkdoc-scangobj --module=$(DOC_MODULE) ; \
else \
for i in $(SCANOBJ_FILES) ; do \
fi )
cd $(srcdir) && \
gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="$(IGNORE_HFILES)" $(SCAN_OPTIONS) $(EXTRA_HFILES)
- touch scan-build.stamp
-
-check_scan:
- $(MAKE) scan-build.stamp
-
-$(DOC_MODULE)-decl.txt $(SCANOBJ_FILES): check_scan
-
-tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt
+ touch build-scan.stamp
+build-tmpl.stamp: build-scan.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(srcdir)/tmpl/*.sgml
@echo '*** Rebuilding template files ***'
cd $(srcdir) && gtkdoc-mktmpl --module=$(DOC_MODULE)
- touch tmpl-build.stamp
-
-check_templates:
- $(MAKE) tmpl-build.stamp
-
-tmpl.stamp: check_templates
-
-sgml-build.stamp: tmpl.stamp $(CFILE_GLOB)
+ touch build-tmpl.stamp
+tmpl.stamp: build-tmpl.stamp
+ @true
+build-sgml.stamp: tmpl.stamp $(CFILE_GLOB)
@echo '*** Building SGML ***'
cd $(srcdir) && \
gtkdoc-mkdb --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) $(MKDB_OPTIONS)
- touch sgml-build.stamp
-
-check_sgml:
- $(MAKE) sgml-build.stamp
-
-sgml.stamp: check_sgml
-
-html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE)
+ touch build-sgml.stamp
+sgml.stamp: build-sgml.stamp
+ @true
+build-html.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE)
@echo '*** Building HTML ***'
test -d $(srcdir)/html || mkdir $(srcdir)/html
cd $(srcdir)/html && gtkdoc-mkhtml $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
test "x$(HTML_IMAGES)" = "x" || ( cd $(srcdir) && cp $(HTML_IMAGES) html )
@echo '-- Fixing Crossreferences'
cd $(srcdir) && gtkdoc-fixxref --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
- touch html-build.stamp
+ touch build-html.stamp
endif
clean-local:
- rm -f *~ *.bak $(SCANOBJ_FILES) *-unused.txt $(DOC_STAMPS) $(srcdir)/sgml.stamp
+ rm -f *~ *.bak $(SCANOBJ_FILES) *-unused.txt $(DOC_STAMPS)
maintainer-clean-local: clean
cd $(srcdir) && rm -rf sgml html $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
cp $(srcdir)/$$i $(distdir)/html ; \
done
-.PHONY : check_sgml check_templates check_scan dist-hook-local
+.PHONY: dist-hook-local
+
+
+EXTRA_DIST = \
+ $(HTML_IMAGES) \
+ $(DOC_MAIN_SGML_FILE) \
+ $(DOC_MODULE).types \
+ $(DOC_MODULE)-sections.txt \
+ $(DOC_MODULE)-overrides.txt
GTypeInfo
GTypeFundamentalInfo
GInterfaceInfo
-GTypeValueTable
<TITLE>GType</TITLE>
G_TYPE_FROM_INSTANCE
GObjectConstructParam
GObjectGetPropertyFunc
GObjectSetPropertyFunc
+GObjectFinalizeFunc
+G_TYPE_IS_OBJECT
G_OBJECT
+G_IS_OBJECT
+G_OBJECT_CLASS
+G_IS_OBJECT_CLASS
G_OBJECT_GET_CLASS
G_OBJECT_TYPE
G_OBJECT_TYPE_NAME
G_OBJECT_CLASS_TYPE
G_OBJECT_CLASS_NAME
-G_IS_VALUE_OBJECT
-G_TYPE_IS_OBJECT
-G_IS_OBJECT
-G_OBJECT_CLASS
-G_IS_OBJECT_CLASS
-GObjectFinalizeFunc
+G_VALUE_HOLDS_OBJECT
g_object_class_install_property
g_object_class_find_property
g_object_new
-g_object_new_valist
+g_object_ref
+g_object_unref
+g_object_connect
+g_object_disconnect
g_object_set
g_object_get
-g_object_set_valist
-g_object_get_valist
-g_object_set_property
-g_object_get_property
-g_object_freeze_notify
g_object_notify
+g_object_freeze_notify
g_object_thaw_notify
-g_object_ref
-g_object_unref
-g_object_get_qdata
-g_object_set_qdata
-g_object_set_qdata_full
-g_object_steal_qdata
g_object_get_data
g_object_set_data
g_object_set_data_full
g_object_steal_data
+g_object_get_qdata
+g_object_set_qdata
+g_object_set_qdata_full
+g_object_steal_qdata
+g_object_set_property
+g_object_get_property
+g_object_new_valist
+g_object_set_valist
+g_object_get_valist
+g_object_watch_closure
g_value_set_object
g_value_get_object
g_value_dup_object
-g_object_watch_closure
G_OBJECT_WARN_INVALID_PROPERTY_ID
</SECTION>
G_IS_FLAGS_CLASS
G_FLAGS_CLASS_TYPE
G_FLAGS_CLASS_TYPE_NAME
-G_IS_VALUE_ENUM
-G_IS_VALUE_FLAGS
+G_VALUE_HOLDS_ENUM
+G_VALUE_HOLDS_FLAGS
GEnumValue
GFlagsValue
g_enum_get_value
g_boxed_free
g_value_set_boxed
g_value_set_static_boxed
+g_value_set_boxed_take_ownership
g_value_get_boxed
g_value_dup_boxed
g_boxed_type_register_static
<SUBSECTION Standard>
-G_IS_VALUE_BOXED
+G_VALUE_HOLDS_BOXED
G_TYPE_IS_BOXED
</SECTION>
GValue
g_value_init
g_value_copy
-g_value_convert
g_value_reset
g_value_unset
g_value_fits_pointer
+g_value_peek_pointer
+g_value_convert
g_values_exchange
g_value_types_exchangable
g_value_register_exchange_func
+GTypeValueTable
+</SECTION>
+
+<SECTION>
+<TITLE>Value arrays</TITLE>
+<FILE>value_types</FILE>
+GValueArray
+g_value_array_new
+g_value_array_copy
+g_value_array_free
+g_value_array_index
+g_value_array_append
+g_value_array_prepend
+g_value_array_insert
+g_value_array_remove
+g_value_array_sort
+g_value_array_sort_with_data
</SECTION>
<SECTION>
<TITLE>Standard value types</TITLE>
<FILE>value_types</FILE>
-G_IS_VALUE_CHAR
-G_IS_VALUE_UCHAR
-G_IS_VALUE_BOOLEAN
-G_IS_VALUE_INT
-G_IS_VALUE_UINT
-G_IS_VALUE_LONG
-G_IS_VALUE_ULONG
-G_IS_VALUE_FLOAT
-G_IS_VALUE_DOUBLE
-G_IS_VALUE_STRING
-G_IS_VALUE_POINTER
-G_IS_VALUE_CCALLBACK
-G_IS_VALUE_PARAM
+G_VALUE_HOLDS_CHAR
+G_VALUE_HOLDS_UCHAR
+G_VALUE_HOLDS_BOOLEAN
+G_VALUE_HOLDS_INT
+G_VALUE_HOLDS_UINT
+G_VALUE_HOLDS_LONG
+G_VALUE_HOLDS_ULONG
+G_VALUE_HOLDS_FLOAT
+G_VALUE_HOLDS_DOUBLE
+G_VALUE_HOLDS_STRING
+G_VALUE_HOLDS_POINTER
+G_VALUE_HOLDS_PARAM
g_value_set_char
g_value_get_char
g_value_set_uchar
g_value_get_double
g_value_set_string
g_value_set_static_string
+g_value_set_string_take_ownership
g_value_get_string
g_value_dup_string
g_value_set_param
g_value_get_param
g_value_dup_param
-g_value_get_ccallback
g_value_get_pointer
g_value_set_pointer
-g_value_get_as_pointer
-g_value_set_ccallback
g_value_set_instance
</SECTION>
G_PARAM_SPEC_POINTER
G_IS_PARAM_SPEC_BOXED
G_PARAM_SPEC_BOXED
-G_IS_PARAM_SPEC_CCALLBACK
-G_PARAM_SPEC_CCALLBACK
G_IS_PARAM_SPEC_PARAM
G_PARAM_SPEC_PARAM
G_IS_PARAM_SPEC_OBJECT
GParamSpecDouble
GParamSpecString
GParamSpecBoxed
-GParamSpecCCallback
GParamSpecParam
GParamSpecPointer
GParamSpecObject
g_param_spec_string
g_param_spec_string_c
g_param_spec_boxed
-g_param_spec_ccallback
g_param_spec_param
g_param_spec_pointer
g_param_spec_object
GSignalFlags
GSignalMatchType
GSignalQuery
+G_SIGNAL_TYPE_STATIC_SCOPE
+G_SIGNAL_MATCH_MASK
+G_SIGNAL_FLAGS_MASK
g_signal_newc
g_signal_newv
g_signal_new_valist
@class:
-<!-- ##### MACRO G_IS_VALUE_ENUM ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_ENUM ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_FLAGS ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_FLAGS ##### -->
<para>
</para>
@boxed:
+<!-- ##### FUNCTION g_value_set_boxed_take_ownership ##### -->
+<para>
+This is an internal function introduced mainly for C marshallers.
+</para>
+
+@value:
+@boxed:
+
+
<!-- ##### FUNCTION g_value_get_boxed ##### -->
<para>
</para>
@name:
+@boxed_init:
@boxed_copy:
@boxed_free:
+@is_refcounted:
@Returns:
<!-- ##### SECTION Title ##### -->
-Generic values
+Generic Values
<!-- ##### SECTION Short_Description ##### -->
-
+A polymorphic type that can hold values of any other type.
<!-- ##### SECTION Long_Description ##### -->
<para>
-
+The #GValue structure is basically a variable container that consists
+of a type identifier and a specific value of that type.
+The type identifier within a #GValue structure always determines the
+type of the associated value.
+To create a undefined #GValue structure, simply create a zero-filled
+#GValue structure. To intialize the #GValue, use the g_value_init()
+function. A #GValue cannot be used until it is initialized.
+The basic type operations (such as freeing and copying) are determined
+by the #GTypeValueTable associated with the type ID stored in the #GValue.
+Other #GValue operations (such as converting values between types) are
+provided by this interface.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
-
+The fundamental types which all support #GValue operations and thus
+can be used as a type initializer for g_value_init() are defined by
+a separate interface. See the Standard Values API for details.
</para>
<!-- ##### MACRO G_VALUE_HOLDS ##### -->
<para>
-
+Returns #TRUE if @value holds (or contains) a value of @type.
+This macro will also check for @value != #NULL and issue a
+warning if the check fails.
</para>
@value:
-@g_type:
+@type:
<!-- ##### MACRO G_VALUE_TYPE ##### -->
<para>
-
+Returns the type identifier of @value.
</para>
-@value:
+@value: A #GValue structure.
<!-- ##### MACRO G_VALUE_TYPE_NAME ##### -->
<para>
-
+Returns the type name of @value.
</para>
-@value:
+@value: A #GValue structure.
<!-- ##### MACRO G_TYPE_IS_VALUE ##### -->
<para>
-
+Return whether the passed in type ID can be used for g_value_init().
+That is, this macro checks whether this type provides an implementation
+of the #GTypeValueTable functions required for a type to create a #GValue of.
</para>
-@type:
+@type: A #GType value.
+@Returns: Whether @type is suitable as a #GValue type.
<!-- ##### MACRO G_IS_VALUE ##### -->
<para>
-
+Returns #TRUE if @value is a valid and initialized #GValue structure.
</para>
-@value:
+@value: A #GValue structure.
<!-- ##### USER_FUNCTION GValueExchange ##### -->
<!-- ##### STRUCT GValue ##### -->
<para>
-
+A mostly opaque structure used to hold a #GValue object. Mostly because
+the data within the structure has protected scope: it is accessible only
+to functions within a #GTypeValueTable structure, or implementations of
+the g_value_*() API.
</para>
<!-- ##### FUNCTION g_value_init ##### -->
<para>
-
+Initializes @value with the default value of @type.
</para>
-@value:
-@g_type:
+@value: A zero-filled (uninitialized) #GValue structure.
+@g_type: Type the #GValue should hold values of.
+@Returns:
<!-- ##### FUNCTION g_value_copy ##### -->
<para>
-
+Copies the value of @src_value into @dest_value.
</para>
-@src_value:
-@dest_value:
-
-
-<!-- ##### FUNCTION g_value_convert ##### -->
-<para>
-
-</para>
-
-@src_value:
-@dest_value:
-@Returns:
+@src_value: An initialized #GValue structure.
+@dest_value: An initialized #GValue structure of the same type as @src_value.
<!-- ##### FUNCTION g_value_reset ##### -->
<para>
-
+Clears the current value in @value and resets it to the default value
+(as if the value had just been initialized).
</para>
-@value:
+@value: An initialized #GValue structure.
+@Returns:
<!-- ##### FUNCTION g_value_unset ##### -->
<para>
-
+Clears the current value in @value and "unsets" the type,
+this releases all resources associated with this GValue.
+An unset value is the same as an uninitialized (zero-filled)
+#GValue structure.
</para>
-@value:
+@value: An initialized #GValue structure.
<!-- ##### FUNCTION g_value_fits_pointer ##### -->
<para>
-
+Determines if @value will fit inside the size of a pointer value.
+This is an internal function introduced mainly for C marshallers.
</para>
-@value:
-@Returns:
+@value: An initialized #GValue structure.
+@Returns: #TRUE if @value will fit inside a pointer value.
-<!-- ##### FUNCTION g_values_exchange ##### -->
+<!-- ##### FUNCTION g_value_peek_pointer ##### -->
<para>
-
+Return the value contents as pointer. This function asserts that
+g_value_fits_pointer() returned #TRUE for the passed in value.
+This is an internal function introduced mainly for C marshallers.
</para>
-@value1:
-@value2:
-@Returns:
+@value: An initialized #GValue structure.
+@Returns: #TRUE if @value will fit inside a pointer value.
-<!-- ##### FUNCTION g_value_types_exchangable ##### -->
+<!-- ##### FUNCTION g_value_convert ##### -->
<para>
</para>
-@value_type1:
-@value_type2:
+@src_value:
+@dest_value:
@Returns:
-<!-- ##### FUNCTION g_value_register_exchange_func ##### -->
+<!-- ##### STRUCT GTypeValueTable ##### -->
<para>
-
+The #GTypeValueTable provides the functions required by the #GValue implementation,
+to serve as a container for values of a type.
</para>
-@value_type1:
-@value_type2:
-@func:
-
+@value_init: Default initialize @values contents by poking values
+ directly into the value->data array. The data array of
+ the #GValue passed into this function was zero-filled
+ with memset, so no care has to be taken to free any
+ old contents. E.g. for the implementation of a string
+ value that may never be NULL, the implementation might
+ look like:
+<msgtext><programlisting>
+{
+ value->data[0].v_pointer = g_strdup ("");
+}
+</programlisting></msgtext>
+@value_free: Free any old contents that might be left in the
+ data array of the passed in @value. No resources may
+ remain allocated through the #GValue contents after
+ this function returns. E.g. for our above string type:
+<msgtext><programlisting>
+{
+ /* only free strings without a specific flag for static storage */
+ if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
+ g_free (value->data[0].v_pointer);
+}
+</programlisting></msgtext>
+@value_copy: @dest_value is a #GValue with zero-filled data section
+ and @src_value is a properly setup #GValue of same or
+ derived type.
+ The purpose of this function is to copy the contents of
+ @src_value into @dest_value in a way, that even after
+ @src_value has been freed, the contents of @dest_value
+ remain valid. String type example:
+<msgtext><programlisting>
+{
+ dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer);
+}
+</programlisting></msgtext>
+@value_peek_pointer: If the value contents fit into a pointer, such as objects
+ or strings, return this pointer, so the caller can peek at
+ the current contents. To extend on our above string example:
+<msgtext><programlisting>
+{
+ return value->data[0].v_pointer;
+}
+</programlisting></msgtext>
+@collect_format: A string format describing how to collect the contents of
+ this value, bit-by-bit. Each character in the format represents
+ an argument to be collected, the characters themselves indicate
+ the type of the argument. Currently supported arguments are:
+<msgtext><variablelist>
+ <varlistentry><term></term><listitem><para>
+ 'i' - Integers. passed as collect_values[].v_int.
+ </para></listitem></varlistentry>
+ <varlistentry><term></term><listitem><para>
+ 'l' - Longs. passed as collect_values[].v_long.
+ </para></listitem></varlistentry>
+ <varlistentry><term></term><listitem><para>
+ 'd' - Doubles. passed as collect_values[].v_double.
+ </para></listitem></varlistentry>
+ <varlistentry><term></term><listitem><para>
+ 'p' - Pointers. passed as collect_values[].v_pointer.
+ </para></listitem></varlistentry>
+</variablelist></msgtext>
+ It should be noted, that for variable argument list construction,
+ ANSI C promotes every type smaller than an integer to an int, and
+ floats to doubles. So for collection of short int or char, 'i'
+ needs to be used, and for collection of floats 'd'.
+@collect_value: The collect_value() function is responsible for converting the
+ values collected from a variable argument list into contents
+ suitable for storage in a GValue. This function should setup
+ @value similar to value_init(), e.g. for a string value that
+ does not allow NULL pointers, it needs to either spew an error,
+ or do an implicit conversion by storing an empty string.
+ The @value passed in to this function has a zero-filled data
+ array, so just like for @value_init it is guarranteed to not
+ contain any old contents that might need freeing.
+ @n_collect_values is exactly the string length of @collect_format,
+ and @collect_values is an array of unions #GTypeCValue with
+ length @n_collect_values, containing the collected values
+ according to @collect_format.
+ @collect_flags is an argument provided as a hint by the caller,
+ which may contain the flag #G_VALUE_NOCOPY_CONTENTS indicating,
+ that the collected value contents may be considered "static"
+ for the duration of the #@value lifetime.
+ Thus an extra copy of the contents stored in @collect_values is
+ not required for assignment to @value.
+ For our above string example, we continue with:
+<msgtext><programlisting>
+{
+ if (!collect_values[0].v_pointer)
+ value->data[0].v_pointer = g_strdup ("");
+ else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
+ {
+ value->data[0].v_pointer = collect_values[0].v_pointer;
+ /* keep a flag for the value_free() implementation to not free this string */
+ value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
+ }
+ else
+ value->data[0].v_pointer = g_strdup (collect_values[0].v_pointer);
+
+ return NULL;
+}
+</programlisting></msgtext>
+ It should be noted, that it is generally a bad idea to follow the
+ #G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to
+ reentrancy requirements and reference count assertions performed
+ by the GSignal code, reference counts should always be incremented
+ for reference counted contents stored in the value->data array.
+ To deviate from our string example for a moment, and taking a look
+ at an exemplary implementation for collect_value() of #GObject:
+<msgtext><programlisting>
+{
+ if (collect_values[0].v_pointer)
+ {
+ GObject *object = G_OBJECT (collect_values[0].v_pointer);
+
+ /* never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types */
+ value->data[0].v_pointer = g_object_ref (object);
+ return NULL;
+ }
+ else
+ return g_strdup_printf ("Object passed as invalid NULL pointer");
+}
+</programlisting></msgtext>
+ The reference count for valid objects is always incremented,
+ regardless of @collect_flags. For invalid objects, the example
+ returns a newly allocated string without altering @value.
+ Upon success, collect_value() needs to return NULL, if however
+ a malicious condition occoured, collect_value() may spew an
+ error by returning a newly allocated non-NULL string, giving
+ a suitable description of the error condition.
+ The calling code makes no assumptions about the @value
+ contents being valid upon error returns, @value
+ is simply thrown away without further freeing. As such, it is
+ a good idea to not allocate #GValue contents, prior to returning
+ an error, however, collect_values() is not obliged to return
+ a correctly setup @value for error returns, simply because
+ any non-NULL return is considered a fatal condition so further
+ program behaviour is undefined.
+@lcopy_format: Format description of the arguments to collect for @lcopy_value,
+ analogous to @collect_format. Usually, @lcopy_format string consist
+ only of 'p's to provide lcopy_value() with pointers to storage locations.
+@lcopy_value: This function is responsible for storing the @value contents into
+ arguments passed through a variable argument list which got
+ collected into @collect_values according to @lcopy_format.
+ @n_collect_values equals the string length of @lcopy_format,
+ and @collect_flags may contain #G_VALUE_NOCOPY_CONTENTS.
+ In contrast to collect_value(), lcopy_value() is obliged to
+ always properly support #G_VALUE_NOCOPY_CONTENTS.
+ Similar to collect_value() the function may prematurely abort
+ by returning a newly allocated string describing an error condition.
+ To complete the string example:
+<msgtext><programlisting>
+{
+ gchar **string_p = collect_values[0].v_pointer;
+
+ if (!string_p)
+ return g_strdup_printf ("string location passed as NULL");
+
+ if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
+ *string_p = value->data[0].v_pointer;
+ else
+ *string_p = g_strdup (value->data[0].v_pointer);
+
+}
+</programlisting></msgtext>
+ And an exemplary version of lcopy_value() for
+ reference-counted types:
+<msgtext><programlisting>
+{
+ GObject **object_p = collect_values[0].v_pointer;
+
+ if (!object_p)
+ return g_strdup_printf ("object location passed as NULL");
+ if (!value->data[0].v_pointer)
+ *object_p = NULL;
+ else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) /* always honour */
+ *object_p = value->data[0].v_pointer;
+ else
+ *object_p = g_object_ref (value->data[0].v_pointer);
+ return NULL;
+}
+</programlisting></msgtext>
-<!-- ##### SECTION ./tmpl/closures.sgml:Long_Description ##### -->
+<!-- ##### FUNCTION g_type_value_is_a ##### -->
<para>
-
-</para>
-
-
-<!-- ##### SECTION ./tmpl/closures.sgml:See_Also ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### SECTION ./tmpl/closures.sgml:Short_Description ##### -->
-
-
-
-<!-- ##### SECTION ./tmpl/closures.sgml:Title ##### -->
-Closures
-
-
-<!-- ##### SECTION ./tmpl/gtypemodule.sgml.sgml:Long_Description ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### SECTION ./tmpl/gtypemodule.sgml.sgml:See_Also ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### SECTION ./tmpl/gtypemodule.sgml.sgml:Short_Description ##### -->
-
-
-
-<!-- ##### SECTION ./tmpl/gtypemodule.sgml.sgml:Title ##### -->
-gtypemodule.sgml
-
-
-<!-- ##### SECTION ./tmpl/signals.sgml:Long_Description ##### -->
-<para>
-The basic concept of the signal system is that of the <emphasis>emission</emphasis>
-of a signal.
-Signals are introduced per-type and are identified through strings.
-Signals introduced for a parent type are availale in derived types as well,
-so basically they are a per-type facility that is inherited.
-A signal emission mainly involves invocation of a certain set of callbacks in
-precisely defined manner. There are two main categories of such callbacks,
-per-object
- <footnote><para> Although signals can deal with any kind of type, i'm
- referring to those types as "object types" in the following, simply
- because that is the context most users will encounter signals in.
- </para></footnote>
-ones and user provided ones.
-The per-object callbacks are most often referred to as "object method
-handler" or "default (signal) handler", while user provided callbacks are
-usually just called "signal handler".
-The object method handler is provided at signal creation time (this most
-frequently happens at the end of an object class' creation), while user
-provided handlers are frequently connected and disconnected to/from a certain
-signal on certain object instances.
-</para>
-<para>
-A signal emission consists of five stages, unless prematurely stopped:
-<variablelist>
- <varlistentry><term></term><listitem><para>
- 1 - Invocation of the object method handler for %G_SIGNAL_RUN_FIRST signals
- </para></listitem></varlistentry>
- <varlistentry><term></term><listitem><para>
- 2 - Invocation of normal user-provided signal handlers (<emphasis>after</emphasis> flag %FALSE)
- </para></listitem></varlistentry>
- <varlistentry><term></term><listitem><para>
- 3 - Invocation of the object method handler for %G_SIGNAL_RUN_LAST signals
- </para></listitem></varlistentry>
- <varlistentry><term></term><listitem><para>
- 4 - Invocation of user provided signal handlers, connected with an <emphasis>after</emphasis> flag of %TRUE
- </para></listitem></varlistentry>
- <varlistentry><term></term><listitem><para>
- 5 - Invocation of the object method handler for %G_SIGNAL_RUN_CLEANUP signals
- </para></listitem></varlistentry>
-</variablelist>
-The user provided signal handlers are called in the order they were
-connected in.
-All handlers may prematurely stop a signal emission, and any number of
-handlers may be connected, disconnected, blocked or unblocked during
-a signal emission.
-There are certain criteria for skipping user handlers in stages 2 and 4
-of a signal emission.
-First, user handlers may be <emphasis>blocked</emphasis>, blocked handlers are omitted
-during callback invocation, to return from the "blocked" state, a
-handler has to get unblocked exactly the same amount of times
-it has been blocked before.
-Second, upon emission of a %G_SIGNAL_DETAILED signal, an additional
-"detail" argument passed in to g_signal_emit() has to match the detail
-argument of the signal handler currently subject to invocation.
-Specification of no detail argument for signal handlers (omission of the
-detail part of the signal specification upon connection) serves as a
-wildcard and matches any detail argument passed in to emission.
-</para>
-
-
-<!-- ##### SECTION ./tmpl/signals.sgml:See_Also ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### SECTION ./tmpl/signals.sgml:Short_Description ##### -->
-Signals provide a means for customization of object behaviour and are used
-as general purpose notification mechanism.
-
-
-<!-- ##### SECTION ./tmpl/signals.sgml:Title ##### -->
-Signals
-
-
-<!-- ##### USER_FUNCTION GObjectGetParamFunc ##### -->
-<para>
-
-</para>
-
-@object:
-@param_id:
-@value:
-@pspec:
-@trailer:
-
-<!-- ##### USER_FUNCTION GObjectSetParamFunc ##### -->
-<para>
-
-</para>
-
-@object:
-@param_id:
-@value:
-@pspec:
-@trailer:
-
-<!-- ##### ENUM GSignalType ##### -->
-<para>
-
-</para>
-
-@G_SIGNAL_RUN_FIRST:
-@G_SIGNAL_RUN_LAST:
-@G_SIGNAL_RUN_CLEANUP:
-@G_SIGNAL_NO_RECURSE:
-@G_SIGNAL_ACTION:
-@G_SIGNAL_NO_HOOKS:
-
-<!-- ##### USER_FUNCTION GTypePluginFillInterfaceInfo ##### -->
-<para>
-
-</para>
-
-@plugin:
-@interface_type:
-@instance_type:
-@info:
-
-<!-- ##### USER_FUNCTION GTypePluginFillTypeInfo ##### -->
-<para>
-
-</para>
-
-@plugin:
-@g_type:
-@info:
-@value_table:
-
-<!-- ##### USER_FUNCTION GTypePluginRef ##### -->
-<para>
-
-</para>
-
-@plugin:
-
-<!-- ##### USER_FUNCTION GTypePluginUnRef ##### -->
-<para>
-
-</para>
-
-@plugin:
-
-<!-- ##### STRUCT GTypePluginVTable ##### -->
-<para>
-
+Determines if @value is a #GValue whose type conforms to @type.
</para>
-@plugin_ref:
-@plugin_unref:
-@complete_type_info:
-@complete_interface_info:
+@value: A valid #GValue structure.
+@type: A #GType value.
+@Returns: #TRUE if @value is a #GValue of @type or #FALSE if not.
-<!-- ##### MACRO G_IS_PARAM_VALUE ##### -->
+<!-- ##### FUNCTION g_value_register_exchange_func ##### -->
<para>
</para>
-@pspec:
-@value:
-
-<!-- ##### MACRO G_NOTIFY_PRIORITY ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### MACRO G_WARN_INVALID_PARAM_ID ##### -->
-<para>
-
-</para>
-
-@object:
-@param_id:
-@pspec:
-
-<!-- ##### FUNCTION g_object_class_find_param_spec ##### -->
-<para>
-
-</para>
-
-@oclass:
-@param_name:
-@Returns:
-
-<!-- ##### FUNCTION g_object_class_install_param ##### -->
-<para>
-
-</para>
-
-@oclass:
-@param_id:
-@pspec:
-
-<!-- ##### FUNCTION g_object_get_param ##### -->
-<para>
-
-</para>
-
-@object:
-@param_name:
-@value:
-
-<!-- ##### FUNCTION g_object_queue_param_changed ##### -->
-<para>
-
-</para>
-
-@object:
-@param_name:
-
-<!-- ##### FUNCTION g_object_set_param ##### -->
-<para>
-
-</para>
-
-@object:
-@param_name:
-@value:
-
-<!-- ##### FUNCTION g_param_spec_hash_table_insert ##### -->
-<para>
-
-</para>
-
-@hash_table:
-@pspec:
-@owner_type:
-
-<!-- ##### FUNCTION g_param_spec_hash_table_lookup ##### -->
-<para>
-
-</para>
-
-@hash_table:
-@param_name:
-@owner_type:
-@try_ancestors:
-@trailer:
-@Returns:
-
-<!-- ##### FUNCTION g_param_spec_hash_table_new ##### -->
-<para>
-
-</para>
-
-@Returns:
-
-<!-- ##### FUNCTION g_param_spec_hash_table_remove ##### -->
-<para>
-
-</para>
-
-@hash_table:
-@pspec:
-
-<!-- ##### FUNCTION g_signal_type_closure_new ##### -->
-<para>
-
-</para>
-
-@itype:
-@struct_offset:
-@Returns:
-
-<!-- ##### FUNCTION g_signals_destroy ##### -->
-<para>
-
-</para>
-
-@itype:
-
-<!-- ##### FUNCTION g_type_conforms_to ##### -->
-<para>
-
-</para>
-
-@type:
-@iface_type:
-@Returns:
-
-<!-- ##### FUNCTION g_type_instance_conforms_to ##### -->
-<para>
-
-</para>
-
-@instance:
-@iface_type:
-@Returns:
+@value_type1:
+@value_type2:
+@func:
-<!-- ##### FUNCTION g_type_is_dynamic ##### -->
+<!-- ##### FUNCTION g_value_types_exchangable ##### -->
<para>
</para>
-@type:
-@flags:
+@value_type1:
+@value_type2:
@Returns:
-<!-- ##### FUNCTION g_type_value_conforms_to ##### -->
+<!-- ##### FUNCTION g_values_exchange ##### -->
<para>
</para>
-@value:
-@type:
+@value1:
+@value2:
@Returns:
@pspec:
@value:
-@trailer:
<!-- ##### USER_FUNCTION GObjectGetPropertyFunc ##### -->
<para>
@property_id:
@value:
@pspec:
+<!-- # Unused Parameters # -->
@trailer:
@property_id:
@value:
@pspec:
+<!-- # Unused Parameters # -->
@trailer:
-<!-- ##### MACRO G_OBJECT ##### -->
+<!-- ##### USER_FUNCTION GObjectFinalizeFunc ##### -->
<para>
</para>
@object:
-<!-- ##### MACRO G_OBJECT_GET_CLASS ##### -->
+<!-- ##### MACRO G_TYPE_IS_OBJECT ##### -->
<para>
</para>
-@object:
+@type:
-<!-- ##### MACRO G_OBJECT_TYPE ##### -->
+<!-- ##### MACRO G_OBJECT ##### -->
<para>
</para>
@object:
-<!-- ##### MACRO G_OBJECT_TYPE_NAME ##### -->
+<!-- ##### MACRO G_IS_OBJECT ##### -->
<para>
</para>
@object:
-<!-- ##### MACRO G_OBJECT_CLASS_TYPE ##### -->
+<!-- ##### MACRO G_OBJECT_CLASS ##### -->
<para>
</para>
@class:
-<!-- ##### MACRO G_OBJECT_CLASS_NAME ##### -->
+<!-- ##### MACRO G_IS_OBJECT_CLASS ##### -->
<para>
</para>
@class:
-<!-- ##### MACRO G_IS_VALUE_OBJECT ##### -->
+<!-- ##### MACRO G_OBJECT_GET_CLASS ##### -->
<para>
</para>
-@value:
+@object:
-<!-- ##### MACRO G_TYPE_IS_OBJECT ##### -->
+<!-- ##### MACRO G_OBJECT_TYPE ##### -->
<para>
</para>
-@type:
+@object:
-<!-- ##### MACRO G_IS_OBJECT ##### -->
+<!-- ##### MACRO G_OBJECT_TYPE_NAME ##### -->
<para>
</para>
@object:
-<!-- ##### MACRO G_OBJECT_CLASS ##### -->
+<!-- ##### MACRO G_OBJECT_CLASS_TYPE ##### -->
<para>
</para>
@class:
-<!-- ##### MACRO G_IS_OBJECT_CLASS ##### -->
+<!-- ##### MACRO G_OBJECT_CLASS_NAME ##### -->
<para>
</para>
@class:
-<!-- ##### USER_FUNCTION GObjectFinalizeFunc ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_OBJECT ##### -->
<para>
</para>
-@object:
+@value:
<!-- ##### FUNCTION g_object_class_install_property ##### -->
@first_param_name:
-<!-- ##### FUNCTION g_object_new_valist ##### -->
+<!-- ##### FUNCTION g_object_ref ##### -->
<para>
</para>
-@object_type:
-@first_property_name:
-@var_args:
+@object:
@Returns:
-<!-- # Unused Parameters # -->
-@first_param_name:
-<!-- ##### FUNCTION g_object_set ##### -->
+<!-- ##### FUNCTION g_object_unref ##### -->
<para>
</para>
@object:
-@first_property_name:
+
+
+<!-- ##### FUNCTION g_object_connect ##### -->
+<para>
+
+</para>
+
+@object:
+@signal_spec:
@Varargs:
-<!-- # Unused Parameters # -->
-@first_param_name:
+@Returns:
-<!-- ##### FUNCTION g_object_get ##### -->
+<!-- ##### FUNCTION g_object_disconnect ##### -->
<para>
</para>
@object:
-@first_property_name:
+@signal_spec:
@Varargs:
-<!-- # Unused Parameters # -->
-@first_param_name:
+@Returns:
-<!-- ##### FUNCTION g_object_set_valist ##### -->
+<!-- ##### FUNCTION g_object_set ##### -->
<para>
</para>
@object:
@first_property_name:
-@var_args:
+@Varargs:
+@Returns:
<!-- # Unused Parameters # -->
@first_param_name:
-<!-- ##### FUNCTION g_object_get_valist ##### -->
+<!-- ##### FUNCTION g_object_get ##### -->
<para>
</para>
@object:
@first_property_name:
-@var_args:
+@Varargs:
<!-- # Unused Parameters # -->
@first_param_name:
-<!-- ##### FUNCTION g_object_set_property ##### -->
+<!-- ##### FUNCTION g_object_notify ##### -->
<para>
</para>
@object:
@property_name:
-@value:
-<!-- ##### FUNCTION g_object_get_property ##### -->
+<!-- ##### FUNCTION g_object_freeze_notify ##### -->
<para>
</para>
@object:
-@property_name:
-@value:
-<!-- ##### FUNCTION g_object_freeze_notify ##### -->
+<!-- ##### FUNCTION g_object_thaw_notify ##### -->
<para>
</para>
@object:
-<!-- ##### FUNCTION g_object_notify ##### -->
+<!-- ##### FUNCTION g_object_get_data ##### -->
<para>
</para>
@object:
-@property_name:
+@key:
+@Returns:
-<!-- ##### FUNCTION g_object_thaw_notify ##### -->
+<!-- ##### FUNCTION g_object_set_data ##### -->
<para>
</para>
@object:
+@key:
+@data:
-<!-- ##### FUNCTION g_object_ref ##### -->
+<!-- ##### FUNCTION g_object_set_data_full ##### -->
<para>
</para>
@object:
-@Returns:
+@key:
+@data:
+@destroy:
-<!-- ##### FUNCTION g_object_unref ##### -->
+<!-- ##### FUNCTION g_object_steal_data ##### -->
<para>
</para>
@object:
+@key:
+@Returns:
<!-- ##### FUNCTION g_object_get_qdata ##### -->
@Returns:
-<!-- ##### FUNCTION g_object_get_data ##### -->
+<!-- ##### FUNCTION g_object_set_property ##### -->
<para>
</para>
@object:
-@key:
+@property_name:
+@value:
+
+
+<!-- ##### FUNCTION g_object_get_property ##### -->
+<para>
+
+</para>
+
+@object:
+@property_name:
+@value:
+
+
+<!-- ##### FUNCTION g_object_new_valist ##### -->
+<para>
+
+</para>
+
+@object_type:
+@first_property_name:
+@var_args:
@Returns:
+<!-- # Unused Parameters # -->
+@first_param_name:
-<!-- ##### FUNCTION g_object_set_data ##### -->
+<!-- ##### FUNCTION g_object_set_valist ##### -->
<para>
</para>
@object:
-@key:
-@data:
+@first_property_name:
+@var_args:
+<!-- # Unused Parameters # -->
+@first_param_name:
-<!-- ##### FUNCTION g_object_set_data_full ##### -->
+<!-- ##### FUNCTION g_object_get_valist ##### -->
<para>
</para>
@object:
-@key:
-@data:
-@destroy:
+@first_property_name:
+@var_args:
+<!-- # Unused Parameters # -->
+@first_param_name:
-<!-- ##### FUNCTION g_object_steal_data ##### -->
+<!-- ##### FUNCTION g_object_watch_closure ##### -->
<para>
</para>
@object:
-@key:
-@Returns:
+@closure:
<!-- ##### FUNCTION g_value_set_object ##### -->
@Returns:
-<!-- ##### FUNCTION g_object_watch_closure ##### -->
-<para>
-
-</para>
-
-@object:
-@closure:
-
-
<!-- ##### MACRO G_OBJECT_WARN_INVALID_PROPERTY_ID ##### -->
<para>
@G_PARAM_WRITABLE:
@G_PARAM_CONSTRUCT:
@G_PARAM_CONSTRUCT_ONLY:
+@G_PARAM_LAX_VALIDATION:
@G_PARAM_PRIVATE:
<!-- ##### FUNCTION g_param_spec_ref ##### -->
@param_name:
@owner_type:
@walk_ancestors:
-@trailer_p:
@Returns:
+<!-- # Unused Parameters # -->
+@trailer_p:
<!-- ##### FUNCTION g_param_spec_internal ##### -->
A signal emission mainly involves invocation of a certain set of callbacks in
precisely defined manner. There are two main categories of such callbacks,
per-object
- <footnote><para> Although signals can deal with any kind of type, i'm
- referring to those types as "object types" in the following, simply
+ <footnote><para> Although signals can deal with any kind of instantiatable type,
+ i'm referring to those types as "object types" in the following, simply
because that is the context most users will encounter signals in.
</para></footnote>
ones and user provided ones.
#gpointer data2);
</programlisting></msgtext>
+<!-- ##### MACRO G_SIGNAL_TYPE_STATIC_SCOPE ##### -->
+<para>
+
+</para>
+
+
+
+<!-- ##### MACRO G_SIGNAL_MATCH_MASK ##### -->
+<para>
+
+</para>
+
+
+
+<!-- ##### MACRO G_SIGNAL_FLAGS_MASK ##### -->
+<para>
+
+</para>
+
+
+
<!-- ##### FUNCTION g_signal_newc ##### -->
<para>
@pspec:
-<!-- ##### MACRO G_IS_PARAM_SPEC_CCALLBACK ##### -->
-<para>
-
-</para>
-
-@pspec:
-
-
-<!-- ##### MACRO G_PARAM_SPEC_CCALLBACK ##### -->
-<para>
-
-</para>
-
-@pspec:
-
-
<!-- ##### MACRO G_IS_PARAM_SPEC_PARAM ##### -->
<para>
@parent_instance:
-<!-- ##### STRUCT GParamSpecCCallback ##### -->
-<para>
-
-</para>
-
-@parent_instance:
-
<!-- ##### STRUCT GParamSpecParam ##### -->
<para>
@Returns:
-<!-- ##### FUNCTION g_param_spec_ccallback ##### -->
-<para>
-
-</para>
-
-@name:
-@nick:
-@blurb:
-@flags:
-@Returns:
-
-
<!-- ##### FUNCTION g_param_spec_param ##### -->
<para>
The predefined identifiers of the reserved fundamental types.
</para>
-@G_TYPE_INVALID: Usually a return value indicating an error.
-@G_TYPE_NONE: A synonym for the "void" type in C.
-@G_TYPE_INTERFACE: Root type of all interface types.
-@G_TYPE_CHAR: Identifier for the built-in type "gchar".
-@G_TYPE_UCHAR: Identifier for the built-in type "guchar".
-@G_TYPE_BOOLEAN: Identifier for the built-in type "gboolean".
-@G_TYPE_INT: Identifier for the built-in type "gint".
-@G_TYPE_UINT: Identifier for the built-in type "guint".
-@G_TYPE_LONG: Identifier for the built-in type "glong".
-@G_TYPE_ULONG: Identifier for the built-in type "gulong".
-@G_TYPE_ENUM: Identifier for the "#GEnum" type.
-@G_TYPE_FLAGS: Identifier for the "#GFlags" type.
-@G_TYPE_FLOAT: Identifier for the built-in type "gfloat".
+@G_TYPE_INVALID: Usually a return value indicating an error.
+@G_TYPE_NONE: A synonym for the "void" type in C.
+@G_TYPE_INTERFACE: Root type of all interface types.
+@G_TYPE_CHAR: Identifier for the built-in type "gchar".
+@G_TYPE_UCHAR: Identifier for the built-in type "guchar".
+@G_TYPE_BOOLEAN: Identifier for the built-in type "gboolean".
+@G_TYPE_INT: Identifier for the built-in type "gint".
+@G_TYPE_UINT: Identifier for the built-in type "guint".
+@G_TYPE_LONG: Identifier for the built-in type "glong".
+@G_TYPE_ULONG: Identifier for the built-in type "gulong".
+@G_TYPE_ENUM: Identifier for the "#GEnum" type.
+@G_TYPE_FLAGS: Identifier for the "#GFlags" type.
+@G_TYPE_FLOAT: Identifier for the built-in type "gfloat".
@G_TYPE_DOUBLE: Identifier for the built-in type "gdouble".
@G_TYPE_STRING: Identifier for a pointer to a null-terminated string "gchar*".
-@G_TYPE_PARAM: Identifier for the "#GParam" type.
-@G_TYPE_BOXED: Identifier for the "#GBoxed" type.
-@G_TYPE_POINTER: Identifier for anonymous pointers "void*".
-@G_TYPE_CCALLBACK: Identifier for a pointer to a C function.
+@G_TYPE_POINTER: Identifier for anonymous pointers "void*".
+@G_TYPE_BOXED: Identifier for the "#GBoxed" type.
+@G_TYPE_PARAM: Identifier for the "#GParam" type.
@G_TYPE_OBJECT: Identifier for the "#GObject" type.
-@G_TYPE_GTK_SIGNAL: Reserved for use by the Gtk+ software package.
-@G_TYPE_BSE_PROCEDURE: Reserved for use by the BSE software package.
-@G_TYPE_BSE_TIME: Reserved for use by the BSE software package.
-@G_TYPE_BSE_NOTE: Reserved for use by the BSE software package.
-@G_TYPE_BSE_DOTS: Reserved for use by the BSE software package.
-@G_TYPE_GLE_GOBJECT: Reserved for use by the GLE software package.
-@G_TYPE_LAST_RESERVED_FUNDAMENTAL: New third-party fundamental types have to use IDs higher than this.
-@G_TYPE_PARAM_CHAR: Identifier for the "#GParamSpecChar" type.
-@G_TYPE_PARAM_UCHAR: Identifier for the "#GParamSpecUChar" type.
-@G_TYPE_PARAM_BOOLEAN: Identifier for the "#GParamSpecBoolean" type.
-@G_TYPE_PARAM_INT: Identifier for the "#GParamSpecInt" type.
-@G_TYPE_PARAM_UINT: Identifier for the "#GParamSpecUInt" type.
-@G_TYPE_PARAM_LONG: Identifier for the "#GParamSpecLong" type.
-@G_TYPE_PARAM_ULONG: Identifier for the "#GParamSpecULong" type.
-@G_TYPE_PARAM_ENUM: Identifier for the "#GParamSpecEnum" type.
-@G_TYPE_PARAM_FLAGS: Identifier for the "#GParamSpecFlags" type.
-@G_TYPE_PARAM_FLOAT: Identifier for the "#GParamSpecFloat" type.
-@G_TYPE_PARAM_DOUBLE: Identifier for the "#GParamSpecDouble" type.
-@G_TYPE_PARAM_STRING: Identifier for the "#GParamSpecString" type.
-@G_TYPE_PARAM_PARAM: Identifier for the "#GParamSpecParam" type.
-@G_TYPE_PARAM_POINTER: Identifier for the "#GParamSpecPointer" type.
-@G_TYPE_PARAM_CCALLBACK: Identifier for the "#GParamSpecCCallback" type.
-@G_TYPE_PARAM_BOXED: Identifier for the "#GParamSpecBoxed" type.
-@G_TYPE_PARAM_OBJECT: Identifier for the "#GParamSpecObject" type.
+@G_TYPE_RESERVED_BSE_FIRST: First fundamental type ID reserved for BSE.
+@G_TYPE_RESERVED_BSE_LAST: Last fundamental type ID reserved for BSE.
+@G_TYPE_RESERVED_LAST_FUNDAMENTAL: Last reserved fundamental type ID.
+@G_TYPE_CLOSURE:
+@G_TYPE_VALUE_ARRAY:
+@G_TYPE_PARAM_CHAR: Identifier for the "#GParamSpecChar" type.
+@G_TYPE_PARAM_UCHAR: Identifier for the "#GParamSpecUChar" type.
+@G_TYPE_PARAM_BOOLEAN: Identifier for the "#GParamSpecBoolean" type.
+@G_TYPE_PARAM_INT: Identifier for the "#GParamSpecInt" type.
+@G_TYPE_PARAM_UINT: Identifier for the "#GParamSpecUInt" type.
+@G_TYPE_PARAM_LONG: Identifier for the "#GParamSpecLong" type.
+@G_TYPE_PARAM_ULONG: Identifier for the "#GParamSpecULong" type.
+@G_TYPE_PARAM_ENUM: Identifier for the "#GParamSpecEnum" type.
+@G_TYPE_PARAM_FLAGS: Identifier for the "#GParamSpecFlags" type.
+@G_TYPE_PARAM_FLOAT: Identifier for the "#GParamSpecFloat" type.
+@G_TYPE_PARAM_DOUBLE: Identifier for the "#GParamSpecDouble" type.
+@G_TYPE_PARAM_STRING: Identifier for the "#GParamSpecString" type.
+@G_TYPE_PARAM_PARAM: Identifier for the "#GParamSpecParam" type.
+@G_TYPE_PARAM_BOXED: Identifier for the "#GParamSpecBoxed" type.
+@G_TYPE_PARAM_POINTER: Identifier for the "#GParamSpecPointer" type.
+@G_TYPE_PARAM_VALUE_ARRAY: Identifier for the "#GParamSpecValueArray" type.
+@G_TYPE_PARAM_CLOSURE: Identifier for the "#GParamClosure" type.
+@G_TYPE_PARAM_OBJECT: Identifier for the "#GParamSpecObject" type.
<!-- ##### STRUCT GTypeInterface ##### -->
<para>
@instance_size: Size of the instance (object) structure (required for instantiatable types only).
@n_preallocs: Number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching).
@instance_init: Location of the instance initialization function (optional, for instantiatable types only).
-@value_table: Function table for generic handling of GValues of this type (usualy only usefull for
- fundamental types).
+@value_table: A #GTypeValueTable function table for generic handling of GValues of this type (usualy only
+ usefull for fundamental types).
<!-- ##### STRUCT GTypeFundamentalInfo ##### -->
<para>
@interface_data: Location of user data passed to the @interface_init and
@interface_finalize functions (optional).
-<!-- ##### STRUCT GTypeValueTable ##### -->
-<para>
-
-</para>
-
-@value_init:
-@value_free:
-@value_copy:
-@value_peek_pointer:
-@collect_format:
-@collect_value:
-@lcopy_format:
-@lcopy_value:
-
<!-- ##### MACRO G_TYPE_FROM_INSTANCE ##### -->
<para>
Returns the type identifier from a given @instance structure.
to find out whether a specific type has been registered for the passed in ID yet).
</para>
-@type: Type to return name for.
-@Returns: Static type name or NULL.
+@type: Type to return name for.
+@Returns: Static type name or NULL.
<!-- ##### FUNCTION g_type_qname ##### -->
<!-- ##### FUNCTION g_type_next_base ##### -->
<para>
-Given a @type and a @base_type which is contained in its anchestry, return
-the type that @base_type is the direct parent type for.
-In other words, for a given type branch, e.g. Root-Derived1-Derived2-Leaf, specified
-through @type=Leaf, return the nextmost child of @base_type. In this example, for
-@base_type=Derived1, the returned value would be Derived2, for @base_type=Root, the
-returned value would be Derived1.
+Given a @leaf_type and a @root_type which is contained in its anchestry, return
+the type that @root_type is the immediate parent of.
+In other words, this function determines the type that is derived directly from
+@root_type which is also a base class of @leaf_type. Given a root type and a
+leaf type, this function can be used to determine the types and order in which
+the leaf type is descended from the root type.
</para>
-@type: Descendant of @base_type and the type to be returned.
-@base_type: Direct parent of the returned type.
-@Returns: Immediate child of @base_type and anchestor of @type.
+@leaf_type: Descendant of @root_type and the type to be returned.
+@root_type: Immediate parent of the returned type.
+@Returns: Immediate child of @root_type and anchestor of @leaf_type.
<!-- ##### FUNCTION g_type_is_a ##### -->
@G_TYPE_FLAG_ABSTRACT: Indicates an abstract type. No instances can be
created for an abstract type.
+@G_TYPE_FLAG_VALUE_ABSTRACT:
<!-- ##### ENUM GTypeFundamentalFlags ##### -->
<para>
@Returns:
-<!-- ##### FUNCTION g_type_value_is_a ##### -->
-<para>
-Determines if @value is a #GValue whose type conforms to @type.
-</para>
-
-@value: A valid #GValue structure.
-@type: A #GType value.
-@Returns: #TRUE if @value is a #GValue of @type or #FALSE if not.
-
-
<!-- ##### FUNCTION g_type_value_table_peek ##### -->
<para>
Returns the location of the #GTypeValueTable associated with @type.
</para>
+
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
-<!-- ##### MACRO G_IS_VALUE_CHAR ##### -->
-<para>
-</para>
-
-@value:
-
-
-<!-- ##### MACRO G_IS_VALUE_UCHAR ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_CHAR ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_BOOLEAN ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_UCHAR ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_INT ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_BOOLEAN ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_UINT ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_INT ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_LONG ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_UINT ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_ULONG ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_LONG ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_FLOAT ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_ULONG ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_DOUBLE ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_FLOAT ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_STRING ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_DOUBLE ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_POINTER ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_STRING ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_CCALLBACK ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_POINTER ##### -->
<para>
</para>
@value:
-<!-- ##### MACRO G_IS_VALUE_PARAM ##### -->
+<!-- ##### MACRO G_VALUE_HOLDS_PARAM ##### -->
<para>
</para>
@v_string:
+<!-- ##### FUNCTION g_value_set_string_take_ownership ##### -->
+<para>
+This is an internal function introduced mainly for C marshallers.
+</para>
+
+@value:
+@v_string:
+
+
<!-- ##### FUNCTION g_value_get_string ##### -->
<para>
@Returns:
-<!-- ##### FUNCTION g_value_get_ccallback ##### -->
-<para>
-
-</para>
-
-@value:
-@callback_func:
-@callback_data:
-
-
<!-- ##### FUNCTION g_value_get_pointer ##### -->
<para>
@v_pointer:
-<!-- ##### FUNCTION g_value_get_as_pointer ##### -->
-<para>
-
-</para>
-
-@value:
-@Returns:
-
-
-<!-- ##### FUNCTION g_value_set_ccallback ##### -->
-<para>
-
-</para>
-
-@value:
-@callback_func:
-@callback_data:
-
-
<!-- ##### FUNCTION g_value_set_instance ##### -->
<para>
void
g_array_sort_with_data (GArray *farray,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
GRealArray *array = (GRealArray*) farray;
void
g_ptr_array_sort_with_data (GPtrArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
g_return_if_fail (array != NULL);
void
g_byte_array_sort_with_data (GByteArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
g_array_sort_with_data ((GArray *) array, compare_func, user_data);
void g_array_sort (GArray *array,
GCompareFunc compare_func);
void g_array_sort_with_data (GArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
/* Resizable pointer array. This interface is much less complicated
void g_ptr_array_sort (GPtrArray *array,
GCompareFunc compare_func);
void g_ptr_array_sort_with_data (GPtrArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
void g_byte_array_sort (GByteArray *array,
GCompareFunc compare_func);
void g_byte_array_sort_with_data (GByteArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
#include <gobject/gtypemodule.h>
#include <gobject/gtypeplugin.h>
#include <gobject/gvalue.h>
+#include <gobject/gvaluearray.h>
#include <gobject/gvaluetypes.h>
void
g_array_sort_with_data (GArray *farray,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
GRealArray *array = (GRealArray*) farray;
void
g_ptr_array_sort_with_data (GPtrArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
g_return_if_fail (array != NULL);
void
g_byte_array_sort_with_data (GByteArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
g_array_sort_with_data ((GArray *) array, compare_func, user_data);
void g_array_sort (GArray *array,
GCompareFunc compare_func);
void g_array_sort_with_data (GArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
/* Resizable pointer array. This interface is much less complicated
void g_ptr_array_sort (GPtrArray *array,
GCompareFunc compare_func);
void g_ptr_array_sort_with_data (GPtrArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
void g_byte_array_sort (GByteArray *array,
GCompareFunc compare_func);
void g_byte_array_sort_with_data (GByteArray *array,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Tim Janik
+ * Copyright (C) 2000-2001 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
}
else
barray->nodes = g_realloc (barray->nodes, barray->n_nodes * sizeof_node);
- check = (char *) barray->nodes + i * sizeof_node;
+ check = ((guint8*) barray->nodes) + i * sizeof_node;
g_memmove (check + sizeof_node, check, (n_nodes - i) * sizeof_node);
replace = TRUE;
SKIP_GROW:
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Tim Janik
+ * Copyright (C) 2000-2001 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
G_INLINE_FUNC
gpointer g_bsearch_array_get_nth (GBSearchArray *barray,
guint n);
+G_INLINE_FUNC
+guint g_bsearch_array_get_index (GBSearchArray *barray,
+ gpointer node_in_array);
/* --- implementation details --- */
{
if (n < barray->n_nodes)
{
- guint8 *nodes = (guint8 *) barray->nodes;
+ guint8 *nodes = (guint8*) barray->nodes;
return nodes + n * barray->sizeof_node;
}
else
return NULL;
}
-#endif /* G_CAN_INLINE && __G_BSEARCHARRAY_C__ */
+G_INLINE_FUNC
+guint
+g_bsearch_array_get_index (GBSearchArray *barray,
+ gpointer node_in_array)
+{
+ guint distance = ((guint8*) node_in_array) - ((guint8*) barray->nodes);
+
+ distance /= barray->sizeof_node;
+
+ return MIN (distance, barray->n_nodes);
+}
+#endif /* G_CAN_INLINE || __G_BSEARCHARRAY_C__ */
#include <gobject/gtypemodule.h>
#include <gobject/gtypeplugin.h>
#include <gobject/gvalue.h>
+#include <gobject/gvaluearray.h>
#include <gobject/gvaluetypes.h>
while (l1 && l2)
{
if (use_data)
- cmp = ((GCompareFuncData) compare_func) (l1->data, l2->data, user_data);
+ cmp = ((GCompareDataFunc) compare_func) (l1->data, l2->data, user_data);
else
cmp = ((GCompareFunc) compare_func) (l1->data, l2->data);
GList *
g_list_sort_with_data (GList *list,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
return g_list_sort_real (list, (GFunc) compare_func, TRUE, user_data);
GList* g_list_sort (GList *list,
GCompareFunc compare_func);
GList* g_list_sort_with_data (GList *list,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
gpointer g_list_nth_data (GList *list,
guint n);
g_qsort_with_data (gconstpointer pbase,
gint total_elems,
size_t size,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
register char *base_ptr = (char *) pbase;
void g_qsort_with_data (gconstpointer pbase,
gint total_elems,
size_t size,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
G_END_DECLS
while (l1 && l2)
{
if (use_data)
- cmp = ((GCompareFuncData) compare_func) (l1->data, l2->data, user_data);
+ cmp = ((GCompareDataFunc) compare_func) (l1->data, l2->data, user_data);
else
cmp = ((GCompareFunc) compare_func) (l1->data, l2->data);
GSList *
g_slist_sort_with_data (GSList *list,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
return g_slist_sort_real (list, (GFunc) compare_func, TRUE, user_data);
GSList* g_slist_sort (GSList *list,
GCompareFunc compare_func);
GSList* g_slist_sort_with_data (GSList *list,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
gpointer g_slist_nth_data (GSList *list,
guint n);
}
static void
-g_string_sprintfa_int (GString *string,
- const gchar *fmt,
- va_list args)
+g_string_printfa_internal (GString *string,
+ const gchar *fmt,
+ va_list args)
{
gchar *buffer;
}
void
-g_string_sprintf (GString *string,
- const gchar *fmt,
- ...)
+g_string_printf (GString *string,
+ const gchar *fmt,
+ ...)
{
va_list args;
g_string_truncate (string, 0);
va_start (args, fmt);
- g_string_sprintfa_int (string, fmt, args);
+ g_string_printfa_internal (string, fmt, args);
va_end (args);
}
void
-g_string_sprintfa (GString *string,
- const gchar *fmt,
- ...)
+g_string_printfa (GString *string,
+ const gchar *fmt,
+ ...)
{
va_list args;
va_start (args, fmt);
- g_string_sprintfa_int (string, fmt, args);
+ g_string_printfa_internal (string, fmt, args);
va_end (args);
}
gint len);
GString* g_string_down (GString *string);
GString* g_string_up (GString *string);
-void g_string_sprintf (GString *string,
+void g_string_printf (GString *string,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
-void g_string_sprintfa (GString *string,
+void g_string_printfa (GString *string,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
+/* compatibility */
+#define g_string_sprintf g_string_printf
+#define g_string_sprintfa g_string_printfa
G_END_DECLS
struct _GRealTree
{
GTreeNode *root;
- GCompareFuncData key_compare;
+ GCompareDataFunc key_compare;
gpointer key_compare_data;
};
gpointer value);
static void g_tree_node_destroy (GTreeNode *node);
static GTreeNode* g_tree_node_insert (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer comp_data,
gpointer key,
gpointer value,
gint *inserted);
static GTreeNode* g_tree_node_remove (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer comp_data,
gconstpointer key);
static GTreeNode* g_tree_node_balance (GTreeNode *node);
static GTreeNode* g_tree_node_restore_right_balance (GTreeNode *node,
gint old_balance);
static gpointer g_tree_node_lookup (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer comp_data,
gconstpointer key);
static gint g_tree_node_count (GTreeNode *node);
}
}
-GTree* g_tree_new_udata(GCompareFuncData key_compare_func,
+GTree* g_tree_new_udata(GCompareDataFunc key_compare_func,
gpointer key_compare_data)
{
GRealTree *rtree;
GTree*
g_tree_new (GCompareFunc key_compare_func)
{
- return g_tree_new_udata ((GCompareFuncData) key_compare_func, NULL);
+ return g_tree_new_udata ((GCompareDataFunc) key_compare_func, NULL);
}
static GTreeNode*
g_tree_node_insert (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer compare_data,
gpointer key,
gpointer value,
static GTreeNode*
g_tree_node_remove (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer compare_data,
gconstpointer key)
{
static gpointer
g_tree_node_lookup (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer compare_data,
gconstpointer key)
{
/* Balanced binary trees
*/
GTree* g_tree_new (GCompareFunc key_compare_func);
-GTree* g_tree_new_with_data (GCompareFuncData key_compare_func,
+GTree* g_tree_new_with_data (GCompareDataFunc key_compare_func,
gpointer user_data);
void g_tree_destroy (GTree *tree);
void g_tree_insert (GTree *tree,
typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b);
-typedef gint (*GCompareFuncData) (gconstpointer a,
+typedef gint (*GCompareDataFunc) (gconstpointer a,
gconstpointer b,
gpointer user_data);
typedef gboolean (*GEqualFunc) (gconstpointer a,
while (l1 && l2)
{
if (use_data)
- cmp = ((GCompareFuncData) compare_func) (l1->data, l2->data, user_data);
+ cmp = ((GCompareDataFunc) compare_func) (l1->data, l2->data, user_data);
else
cmp = ((GCompareFunc) compare_func) (l1->data, l2->data);
GList *
g_list_sort_with_data (GList *list,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
return g_list_sort_real (list, (GFunc) compare_func, TRUE, user_data);
GList* g_list_sort (GList *list,
GCompareFunc compare_func);
GList* g_list_sort_with_data (GList *list,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
gpointer g_list_nth_data (GList *list,
guint n);
* Makefile.am: Avoid rebuilding everything everytime.
-Mon Mar 5 15:26:30 2001 Jonathan Blandford <jrb@redhat.com>
+Wed Mar 7 09:36:33 2001 Tim Janik <timj@gtk.org>
- * gparamspecs.c (g_param_spec_interface): add a new param spec to
- handle interfaces.
+ * gboxed.[hc]: changed prototype of g_boxed_type_register_static()
+ to contain an optional init function and a hint at whether the
+ boxed structure uses ref counting internally.
+ added g_value_set_boxed_take_ownership().
+ made G_TYPE_BOXED an abstract value type.
+
+ * genums.[hc]: made G_TYPE_ENUM and G_TYPE_FLAGS abstract value
+ types.
+
+ * glib-genmarshal.c: argument type changes, preparation for third-party
+ arg specification.
+
+ * gobject.[hc]: cleaned up get/set property code.
+ added g_strdup_value_contents() to improve warnings.
+
+ * gparam.[hc]: added g_param_value_convert(), taking over responsibility
+ of the old g_value_convert(). added G_PARAM_LAX_VALIDATION flag so
+ validation alterations may be valid a part of the property setting
+ process.
+
+ * gparamspecs.[hc]: made value comparisons stable (for sort applications).
+ added GParamSpecValueArray, a param spec for value arrays and
+ GParamSpecClosure. nuked the value exchange functions and
+ GParamSpecCCallback.
+
+ * gtype.[hc]: catch unintialized usages of the type system with
+ g_return_val_if_uninitialized(). introduced G_TYPE_FLAG_VALUE_ABSTRACT
+ to flag types that introduce a value table, but can't be used for
+ g_value_init(). cleaned up reserved type ids.
+
+ * gvalue.[hc]: code cleanups and saner checking.
+ nuked the value exchange API. implemented value transformations, we
+ can't really "convert" values, rather transforms are an anylogy to
+ C casts, real conversions need a param spec for validation, which is
+ why g_param_value_convert() does real conversions now.
+
+ * gvaluearray.[hc]: new files that implement a GValueArray, a struct
+ that can hold inhomogeneous arrays of value (to that extend that it
+ also allowes undefined values, i.e. G_VALUE_TYPE(value)==0).
+ this is exposed to the type system as a boxed type.
+
+ * gvaluetransform.c: new file implementing most of the former value
+ exchange functions as single-sided transformations.
+
+ * gvaluetypes.[hc]: nuked G_TYPE_CCALLBACK, added
+ g_value_set_string_take_ownership().
+
+ * *.h: s/G_IS_VALUE_/G_VALUE_HOLDS_/.
+
+ * *.[hc]: many fixes and cleanups.
+
+ * many warning improvements.
+
+Tue Feb 27 18:35:15 2001 Tim Janik <timj@gtk.org>
+
+ * gobject.c (g_object_get_valist): urg, pass G_VALUE_NOCOPY_CONTENTS
+ into G_VALUE_LCOPY(), this needs proper documenting.
+
+ * gparam.c: fixed G_PARAM_USER_MASK.
+
+ * gtype.c (type_data_make_W):
+ (type_data_last_unref_Wm): fixed invalid memory freeing.
+
+ * gobject.c (g_object_last_unref): destroy signal handlers associated
+ with object, right before finalization.
+
+ * gsignal.c (g_signal_parse_name): catch destroyed nodes or signals
+ that don't actually support details.
+
+ * gobject.[hc]: got rid of property trailers. nuked GObject
+ properties "data" and the "signal" variants.
+ (g_object_connect): new convenience function to do multiple
+ signal connections at once.
+ (g_object_disconnect): likewise, for disconnections.
+
+ * gparam.[hc] (g_param_spec_pool_lookup): took out trailer support.
+
+ * gvalue.[hc]: marked g_value_fits_pointer() and g_value_peek_pointer()
+ as private (the latter got renamed from g_value_get_as_pointer()).
Wed Feb 21 18:31:46 2001 Jonathan Blandford <jrb@redhat.com>
-I$(top_srcdir) \
-I$(top_builddir) \
@GLIB_DEBUG_FLAGS@ \
+ -DG_DISABLE_CONST_RETURNS \
@STRIP_END@
# libraries to compile and install
gtypemodule.h \
gtypeplugin.h \
gvalue.h \
+ gvaluearray.h \
gvaluecollector.h \
gvaluetypes.h \
@STRIP_END@
gtypemodule.c \
gtypeplugin.c \
gvalue.c \
+ gvaluearray.c \
+ gvaluetransform.c \
gvaluetypes.c \
@STRIP_END@
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 2000-2001 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "gbsearcharray.h"
#include "gvalue.h"
+#include "gvaluearray.h"
+#include "gclosure.h"
#include "gvaluecollector.h"
#include <string.h>
typedef struct
{
GType type;
+ GBoxedInitFunc init;
GBoxedCopyFunc copy;
GBoxedFreeFunc free;
+ gboolean is_refcounted;
} BoxedNode;
return G_BSEARCH_ARRAY_CMP (node1->type, node2->type);
}
+static inline void /* keep this function in sync with gvalue.c */
+value_meminit (GValue *value,
+ GType value_type)
+{
+ value->g_type = value_type;
+ memset (value->data, 0, sizeof (value->data));
+}
+
+static gpointer
+value_array_init (void)
+{
+ return g_value_array_new (0);
+}
+
void
g_boxed_type_init (void) /* sync with gtype.c */
{
/* G_TYPE_BOXED
*/
- type = g_type_register_fundamental (G_TYPE_BOXED, "GBoxed", &info, &finfo, G_TYPE_FLAG_ABSTRACT);
+ type = g_type_register_fundamental (G_TYPE_BOXED, "GBoxed", &info, &finfo,
+ G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
g_assert (type == G_TYPE_BOXED);
+
+ /* boxed: G_TYPE_CLOSURE
+ */
+ type = g_boxed_type_register_static ("GClosure",
+ (GBoxedInitFunc) NULL,
+ (GBoxedCopyFunc) g_closure_ref,
+ (GBoxedFreeFunc) g_closure_unref,
+ TRUE);
+ g_assert (type == G_TYPE_CLOSURE);
+
+ /* boxed: G_TYPE_VALUE_ARRAY
+ */
+ type = g_boxed_type_register_static ("GValueArray",
+ value_array_init, /* don't allow NULL values */
+ (GBoxedCopyFunc) g_value_array_copy,
+ (GBoxedFreeFunc) g_value_array_free,
+ FALSE);
+ g_assert (type == G_TYPE_VALUE_ARRAY);
}
static void
boxed_proxy_value_init (GValue *value)
{
- value->data[0].v_pointer = 0;
+ BoxedNode key, *node;
+
+ key.type = G_VALUE_TYPE (value);
+ node = g_bsearch_array_lookup (&boxed_bsa, &key);
+ value->data[0].v_pointer = node->init ? node->init () : NULL;
}
static void
{
BoxedNode key, *node;
- key.type = value->g_type;
+ key.type = G_VALUE_TYPE (value);
node = g_bsearch_array_lookup (&boxed_bsa, &key);
node->free (value->data[0].v_pointer);
}
{
BoxedNode key, *node;
- key.type = src_value->g_type;
+ key.type = G_VALUE_TYPE (src_value);
node = g_bsearch_array_lookup (&boxed_bsa, &key);
dest_value->data[0].v_pointer = node->copy (src_value->data[0].v_pointer);
}
GTypeCValue *collect_values,
guint collect_flags)
{
+ BoxedNode key, *node;
+
+ key.type = G_VALUE_TYPE (value);
+ node = g_bsearch_array_lookup (&boxed_bsa, &key);
+
+ /* for NULL values, we have to call GBoxedInitFunc */
if (!collect_values[0].v_pointer)
- value->data[0].v_pointer = NULL;
- else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
- {
- value->data[0].v_pointer = collect_values[0].v_pointer;
- value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
- }
+ value->data[0].v_pointer = node->init ? node->init () : NULL;
else
{
- BoxedNode key, *node;
-
- key.type = value->g_type;
- node = g_bsearch_array_lookup (&boxed_bsa, &key);
- value->data[0].v_pointer = node->copy (collect_values[0].v_pointer);
+ /* never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types */
+ if (!node->is_refcounted && (collect_flags & G_VALUE_NOCOPY_CONTENTS))
+ {
+ value->data[0].v_pointer = collect_values[0].v_pointer;
+ value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
+ }
+ else
+ value->data[0].v_pointer = node->copy (collect_values[0].v_pointer);
}
return NULL;
{
BoxedNode key, *node;
- key.type = value->g_type;
+ key.type = G_VALUE_TYPE (value);
node = g_bsearch_array_lookup (&boxed_bsa, &key);
*boxed_p = node->copy (value->data[0].v_pointer);
}
GType
g_boxed_type_register_static (const gchar *name,
+ GBoxedInitFunc boxed_init,
GBoxedCopyFunc boxed_copy,
- GBoxedFreeFunc boxed_free)
+ GBoxedFreeFunc boxed_free,
+ gboolean is_refcounted)
{
static const GTypeValueTable vtable = {
boxed_proxy_value_init,
BoxedNode key;
key.type = type;
+ key.init = boxed_init;
key.copy = boxed_copy;
key.free = boxed_free;
+ key.is_refcounted = is_refcounted != FALSE;
g_bsearch_array_insert (&boxed_bsa, &key, TRUE);
}
{
GValue src_value, dest_value;
- /* we heavil rely on the gvalue.c implementation here */
-
- memset (&src_value.data, 0, sizeof (src_value.data));
- memset (&dest_value.data, 0, sizeof (dest_value.data));
- dest_value.g_type = boxed_type;
- src_value.g_type = boxed_type;
+ /* we heavil rely on third-party boxed type value vtable
+ * implementations to follow normal boxed value storage
+ * (data[0].v_pointer is the boxed struct, and
+ * data[1].v_uint holds the G_VALUE_NOCOPY_CONTENTS flag,
+ * rest zero).
+ * but then, we can expect that since we layed out the
+ * g_boxed_*() API.
+ * data[1].v_uint&G_VALUE_NOCOPY_CONTENTS shouldn't be set
+ * after a copy.
+ */
+ /* equiv. to g_value_set_static_boxed() */
+ value_meminit (&src_value, boxed_type);
src_value.data[0].v_pointer = (gpointer) src_boxed;
+ src_value.data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
+
+ /* call third-party code copy fucntion, fingers-crossed */
+ value_meminit (&dest_value, boxed_type);
value_table->value_copy (&src_value, &dest_value);
+
+ /* double check and grouse if things went wrong */
if (dest_value.data[1].v_ulong ||
dest_value.data[2].v_ulong ||
dest_value.data[3].v_ulong)
{
GValue value;
- /* we heavil rely on the gvalue.c implementation here */
- memset (&value.data, 0, sizeof (value.data));
- value.g_type = boxed_type;
+ /* see g_boxed_copy() on why we think we can do this */
+ value_meminit (&value, boxed_type);
value.data[0].v_pointer = boxed;
value_table->value_free (&value);
}
}
+gpointer
+g_value_get_boxed (const GValue *value)
+{
+ g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), NULL);
+ g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
+
+ return value->data[0].v_pointer;
+}
+
+gpointer
+g_value_dup_boxed (GValue *value)
+{
+ g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), NULL);
+ g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
+
+ return value->data[0].v_pointer ? g_boxed_copy (G_VALUE_TYPE (value), value->data[0].v_pointer) : NULL;
+}
+
+static inline void
+value_set_boxed_internal (GValue *value,
+ gconstpointer const_boxed,
+ gboolean need_copy,
+ gboolean need_free)
+{
+ BoxedNode key, *node;
+ gpointer boxed = (gpointer) const_boxed;
+
+ if (!boxed)
+ {
+ /* just resetting to NULL might not be desired, need to
+ * have value reinitialized also (for values defaulting
+ * to other default value states than a NULL data pointer),
+ * g_value_reset() will handle this
+ */
+ g_value_reset (value);
+ return;
+ }
+
+ key.type = G_VALUE_TYPE (value);
+ node = g_bsearch_array_lookup (&boxed_bsa, &key);
+
+ if (node)
+ {
+ /* we proxy this type, free contents and copy right away */
+ if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
+ node->free (value->data[0].v_pointer);
+ value->data[1].v_uint = need_free ? 0 : G_VALUE_NOCOPY_CONTENTS;
+ value->data[0].v_pointer = need_copy ? node->copy (boxed) : boxed;
+ }
+ else
+ {
+ /* we don't handle this type, free contents and let g_boxed_copy()
+ * figure what's required
+ */
+ if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
+ g_boxed_free (G_VALUE_TYPE (value), value->data[0].v_pointer);
+ value->data[1].v_uint = need_free ? 0 : G_VALUE_NOCOPY_CONTENTS;
+ value->data[0].v_pointer = need_copy ? g_boxed_copy (G_VALUE_TYPE (value), boxed) : boxed;
+ }
+}
+
void
g_value_set_boxed (GValue *value,
gconstpointer boxed)
{
- g_return_if_fail (G_IS_VALUE_BOXED (value));
+ g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
- if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
- g_boxed_free (G_VALUE_TYPE (value), value->data[0].v_pointer);
- value->data[0].v_pointer = boxed ? g_boxed_copy (G_VALUE_TYPE (value), boxed) : NULL;
- value->data[1].v_uint = 0;
+ value_set_boxed_internal (value, boxed, TRUE, TRUE);
}
void
g_value_set_static_boxed (GValue *value,
gconstpointer boxed)
{
- g_return_if_fail (G_IS_VALUE_BOXED (value));
+ g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
- if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
- g_boxed_free (G_VALUE_TYPE (value), value->data[0].v_pointer);
- value->data[0].v_pointer = (gpointer) boxed;
- value->data[1].v_uint = boxed ? G_VALUE_NOCOPY_CONTENTS : 0;
-}
-
-gpointer
-g_value_get_boxed (const GValue *value)
-{
- g_return_val_if_fail (G_IS_VALUE_BOXED (value), NULL);
- g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
-
- return value->data[0].v_pointer;
+ value_set_boxed_internal (value, boxed, FALSE, FALSE);
}
-gpointer
-g_value_dup_boxed (GValue *value)
+void
+g_value_set_boxed_take_ownership (GValue *value,
+ gconstpointer boxed)
{
- g_return_val_if_fail (G_IS_VALUE_BOXED (value), NULL);
- g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
+ g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
+ g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
- return value->data[0].v_pointer ? g_boxed_copy (G_VALUE_TYPE (value), value->data[0].v_pointer) : NULL;
+ value_set_boxed_internal (value, boxed, FALSE, TRUE);
}
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 2000-2001 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* --- type macros --- */
-#define G_TYPE_IS_BOXED(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED)
-#define G_IS_VALUE_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED))
+#define G_TYPE_IS_BOXED(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED)
+#define G_VALUE_HOLDS_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED))
/* --- typedefs --- */
typedef struct _GBoxed GBoxed;
+typedef gpointer (*GBoxedInitFunc) (void);
typedef gpointer (*GBoxedCopyFunc) (gpointer boxed);
typedef void (*GBoxedFreeFunc) (gpointer boxed);
gconstpointer src_boxed);
void g_boxed_free (GType boxed_type,
gpointer boxed);
-void g_value_set_boxed (GValue *value,
- gconstpointer boxed);
-void g_value_set_static_boxed (GValue *value,
- gconstpointer boxed);
-gpointer g_value_get_boxed (const GValue *value);
-gpointer g_value_dup_boxed (GValue *value);
+void g_value_set_boxed (GValue *value,
+ gconstpointer boxed);
+void g_value_set_static_boxed (GValue *value,
+ gconstpointer boxed);
+gpointer g_value_get_boxed (const GValue *value);
+gpointer g_value_dup_boxed (GValue *value);
/* --- convenience --- */
-GType g_boxed_type_register_static (const gchar *name,
- GBoxedCopyFunc boxed_copy,
- GBoxedFreeFunc boxed_free);
+GType g_boxed_type_register_static (const gchar *name,
+ GBoxedInitFunc boxed_init,
+ GBoxedCopyFunc boxed_copy,
+ GBoxedFreeFunc boxed_free,
+ gboolean is_refcounted);
+/* --- marshaller specific --- */
+void g_value_set_boxed_take_ownership (GValue *value,
+ gconstpointer boxed);
+
#ifdef __cplusplus
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Tim Janik
+ * Copyright (C) 2000-2001 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
}
else
barray->nodes = g_realloc (barray->nodes, barray->n_nodes * sizeof_node);
- check = (char *) barray->nodes + i * sizeof_node;
+ check = ((guint8*) barray->nodes) + i * sizeof_node;
g_memmove (check + sizeof_node, check, (n_nodes - i) * sizeof_node);
replace = TRUE;
SKIP_GROW:
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Tim Janik
+ * Copyright (C) 2000-2001 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
G_INLINE_FUNC
gpointer g_bsearch_array_get_nth (GBSearchArray *barray,
guint n);
+G_INLINE_FUNC
+guint g_bsearch_array_get_index (GBSearchArray *barray,
+ gpointer node_in_array);
/* --- implementation details --- */
{
if (n < barray->n_nodes)
{
- guint8 *nodes = (guint8 *) barray->nodes;
+ guint8 *nodes = (guint8*) barray->nodes;
return nodes + n * barray->sizeof_node;
}
else
return NULL;
}
-#endif /* G_CAN_INLINE && __G_BSEARCHARRAY_C__ */
+G_INLINE_FUNC
+guint
+g_bsearch_array_get_index (GBSearchArray *barray,
+ gpointer node_in_array)
+{
+ guint distance = ((guint8*) node_in_array) - ((guint8*) barray->nodes);
+
+ distance /= barray->sizeof_node;
+
+ return MIN (distance, barray->n_nodes);
+}
+#endif /* G_CAN_INLINE || __G_BSEARCHARRAY_C__ */
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 2000-2001 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
g_return_if_fail (meta_marshal != NULL);
g_return_if_fail (closure->is_invalid == FALSE);
g_return_if_fail (closure->in_marshal == FALSE);
- g_return_if_fail (closure->meta_marshal == FALSE);
+ g_return_if_fail (closure->meta_marshal == 0);
n = CLOSURE_N_NOTIFIERS (closure);
notifiers = closure->notifiers;
/* GType itype = GPOINTER_TO_UINT (closure->data); */
guint offset = GPOINTER_TO_UINT (marshal_data);
- class = G_TYPE_INSTANCE_GET_CLASS (g_value_get_as_pointer (param_values + 0), itype, GTypeClass);
+ class = G_TYPE_INSTANCE_GET_CLASS (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
callback = G_STRUCT_MEMBER (gpointer, class, offset);
if (callback)
closure->marshal (closure,
GType itype = GPOINTER_TO_UINT (closure->data);
guint offset = GPOINTER_TO_UINT (marshal_data);
- class = G_TYPE_INSTANCE_GET_INTERFACE (g_value_get_as_pointer (param_values + 0), itype, GTypeClass);
+ class = G_TYPE_INSTANCE_GET_INTERFACE (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
callback = G_STRUCT_MEMBER (gpointer, class, offset);
if (callback)
closure->marshal (closure,
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 2000-2001 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* -- typedefs --- */
typedef struct _GClosure GClosure;
typedef struct _GClosureNotifyData GClosureNotifyData;
-typedef gpointer GCallback;
+typedef gpointer GCallback;
typedef void (*GClosureNotify) (gpointer data,
GClosure *closure);
typedef void (*GClosureMarshal) (GClosure *closure,
* - order of inotifiers is random
* inotifiers may _not_ free/invalidate parameter values (e.g. ->data)
* - order of fnotifiers is random
- * - notifiers may only be removed before or during their invocation
+ * - each notifier may only be removed before or during its invocation
* - reference counting may only happen prior to fnotify invocation
* (in that sense, fnotifiers are really finalization handlers)
*/
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* G_TYPE_ENUM
*/
info.class_size = sizeof (GEnumClass);
- type = g_type_register_fundamental (G_TYPE_ENUM, "GEnum", &info, &finfo, G_TYPE_FLAG_ABSTRACT);
+ type = g_type_register_fundamental (G_TYPE_ENUM, "GEnum", &info, &finfo,
+ G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
g_assert (type == G_TYPE_ENUM);
/* G_TYPE_FLAGS
*/
info.class_size = sizeof (GFlagsClass);
- type = g_type_register_fundamental (G_TYPE_FLAGS, "GFlags", &info, &finfo, G_TYPE_FLAG_ABSTRACT);
+ type = g_type_register_fundamental (G_TYPE_FLAGS, "GFlags", &info, &finfo,
+ G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
g_assert (type == G_TYPE_FLAGS);
}
GFlagsValue *flags_value;
for (flags_value = flags_class->values; flags_value->value_name; flags_value++)
- if ((flags_value->value & value) > 0)
+ if ((flags_value->value & value) == flags_value->value)
return flags_value;
}
g_value_set_enum (GValue *value,
gint v_enum)
{
- g_return_if_fail (G_IS_VALUE_ENUM (value));
+ g_return_if_fail (G_VALUE_HOLDS_ENUM (value));
value->data[0].v_long = v_enum;
}
gint
g_value_get_enum (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_ENUM (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_ENUM (value), 0);
return value->data[0].v_long;
}
g_value_set_flags (GValue *value,
guint v_flags)
{
- g_return_if_fail (G_IS_VALUE_FLAGS (value));
+ g_return_if_fail (G_VALUE_HOLDS_FLAGS (value));
value->data[0].v_ulong = v_flags;
}
guint
g_value_get_flags (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_FLAGS (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_FLAGS (value), 0);
return value->data[0].v_ulong;
}
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS))
#define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
#define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_TYPE (class)))
-#define G_IS_VALUE_ENUM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM))
-#define G_IS_VALUE_FLAGS(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS))
+#define G_VALUE_HOLDS_ENUM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM))
+#define G_VALUE_HOLDS_FLAGS(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS))
/* --- enum/flag values & classes --- */
.TP 12
\fIPARAM
for GParamSpec or derived types (GParamSpec*)
+.TP 12
\fIPOINTER
for anonymous pointer types (gpointer)
.TP 12
/* GLIB-GenMarshal - Marshaller generator for GObject library
- * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 2000-2001 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* --- typedefs & structures --- */
-typedef struct _Argument Argument;
-typedef struct _Signature Signature;
-struct _Argument
+typedef struct
{
- gchar *pname; /* parsed name */
- const gchar *sname; /* signature name */
- const gchar *func; /* functional extension */
- const gchar *cname; /* C name */
-};
-struct _Signature
+ gchar *keyword; /* marhaller list keyword [MY_STRING] */
+ const gchar *sig_name; /* signature name [STRING] */
+ const gchar *ctype; /* C type name [gchar*] */
+ const gchar *getter; /* value getter function [g_value_get_string] */
+} InArgument;
+typedef struct
{
- gchar *ploc;
- Argument *rarg;
- GList *args; /* of type Argument* */
-};
+ gchar *keyword; /* marhaller list keyword [MY_STRING] */
+ const gchar *sig_name; /* signature name [STRING] */
+ const gchar *ctype; /* C type name [gchar*] */
+ const gchar *setter; /* value setter function [g_value_set_string] */
+ const gchar *release; /* value release function [g_free] */
+} OutArgument;
+typedef struct
+{
+ gchar *ploc;
+ OutArgument *rarg;
+ GList *args; /* of type InArgument* */
+} Signature;
/* --- prototypes --- */
/* --- functions --- */
static gboolean
-complete_arg (Argument *arg,
- gboolean is_return)
+complete_in_arg (InArgument *iarg)
{
- static const Argument inout_arguments[] = {
- /* pname, sname, func, cname */
- { "VOID", "VOID", NULL, "void", },
- { "BOOLEAN", "BOOLEAN", "boolean", "gboolean", },
- { "CHAR", "CHAR", "char", "gchar", },
- { "UCHAR", "UCHAR", "uchar", "guchar", },
- { "INT", "INT", "int", "gint", },
- { "UINT", "UINT", "uint", "guint", },
- { "LONG", "LONG", "long", "glong", },
- { "ULONG", "ULONG", "ulong", "gulong", },
- { "ENUM", "ENUM", "enum", "gint", },
- { "FLAGS", "FLAGS", "flags", "guint", },
- { "FLOAT", "FLOAT", "float", "gfloat", },
- { "DOUBLE", "DOUBLE", "double", "gdouble", },
+ static const InArgument args[] = {
+ /* keyword sig_name ctype getter */
+ { "VOID", "VOID", "void", NULL, },
+ { "BOOLEAN", "BOOLEAN", "gboolean", "g_value_get_boolean", },
+ { "CHAR", "CHAR", "gchar", "g_value_get_char", },
+ { "UCHAR", "UCHAR", "guchar", "g_value_get_uchar", },
+ { "INT", "INT", "gint", "g_value_get_int", },
+ { "UINT", "UINT", "guint", "g_value_get_uint", },
+ { "LONG", "LONG", "glong", "g_value_get_long", },
+ { "ULONG", "ULONG", "gulong", "g_value_get_ulong", },
+ { "ENUM", "ENUM", "gint", "g_value_get_enum", },
+ { "FLAGS", "FLAGS", "guint", "g_value_get_flags", },
+ { "FLOAT", "FLOAT", "gfloat", "g_value_get_float", },
+ { "DOUBLE", "DOUBLE", "gdouble", "g_value_get_double", },
+ { "STRING", "STRING", "gpointer", "(char*) g_value_get_string", },
+ { "PARAM", "PARAM", "gpointer", "g_value_get_param", },
+ { "BOXED", "BOXED", "gpointer", "g_value_get_boxed", },
+ { "POINTER", "POINTER", "gpointer", "g_value_get_pointer", },
+ { "OBJECT", "OBJECT", "gpointer", "g_value_get_object", },
/* deprecated: */
- { "NONE", "VOID", NULL, "void", },
- { "BOOL", "BOOLEAN", "boolean", "gboolean", },
+ { "NONE", "VOID", "void", NULL, },
+ { "BOOL", "BOOLEAN", "gboolean", "g_value_get_boolean", },
};
- static const Argument in_arguments[] = {
- { "STRING", "POINTER", "as_pointer", "gpointer", },
- { "BOXED", "POINTER", "as_pointer", "gpointer", },
- { "POINTER", "POINTER", "as_pointer", "gpointer", },
- { "PARAM", "POINTER", "as_pointer", "gpointer", },
- { "OBJECT", "POINTER", "as_pointer", "gpointer", },
- };
- static const Argument out_arguments[] = {
- { "STRING", "STRING", "string", "gchar*", },
- { "BOXED", "BOXED", "boxed", "gpointer", },
- { "POINTER", "POINTER", "pointer", "gpointer", },
- { "PARAM", "PARAM", "param", "GParamSpec*", },
- { "OBJECT", "OBJECT", "object", "GObject*", },
- };
- const guint n_inout_arguments = sizeof (inout_arguments) / sizeof (inout_arguments[0]);
- const guint n_out_arguments = sizeof (out_arguments) / sizeof (out_arguments[0]);
- const guint n_in_arguments = sizeof (in_arguments) / sizeof (in_arguments[0]);
- const Argument *arguments;
- guint i, n_arguments;
-
- g_return_val_if_fail (arg != NULL, FALSE);
-
- arguments = inout_arguments;
- n_arguments = n_inout_arguments;
- for (i = 0; i < n_arguments; i++)
- if (strcmp (arguments[i].pname, arg->pname) == 0)
+ const guint n_args = sizeof (args) / sizeof (args[0]);
+ guint i;
+
+ g_return_val_if_fail (iarg != NULL, FALSE);
+
+ for (i = 0; i < n_args; i++)
+ if (strcmp (args[i].keyword, iarg->keyword) == 0)
{
- arg->sname = arguments[i].sname;
- arg->func = arguments[i].func;
- arg->cname = arguments[i].cname;
+ iarg->sig_name = args[i].sig_name;
+ iarg->ctype = args[i].ctype;
+ iarg->getter = args[i].getter;
return TRUE;
}
- arguments = is_return ? out_arguments : in_arguments;
- n_arguments = is_return ? n_out_arguments : n_in_arguments;
- for (i = 0; i < n_arguments; i++)
- if (strcmp (arguments[i].pname, arg->pname) == 0)
+ return FALSE;
+}
+
+static gboolean
+complete_out_arg (OutArgument *oarg)
+{
+ static const OutArgument args[] = {
+ /* keyword sig_name ctype setter release */
+ { "VOID", "VOID", "void", NULL, NULL, },
+ { "BOOLEAN", "BOOLEAN", "gboolean", "g_value_set_boolean", NULL, },
+ { "CHAR", "CHAR", "gchar", "g_value_set_char", NULL, },
+ { "UCHAR", "UCHAR", "guchar", "g_value_set_uchar", NULL, },
+ { "INT", "INT", "gint", "g_value_set_int", NULL, },
+ { "UINT", "UINT", "guint", "g_value_set_uint", NULL, },
+ { "LONG", "LONG", "glong", "g_value_set_long", NULL, },
+ { "ULONG", "ULONG", "gulong", "g_value_set_ulong", NULL, },
+ { "ENUM", "ENUM", "gint", "g_value_set_enum", NULL, },
+ { "FLAGS", "FLAGS", "guint", "g_value_set_flags", NULL, },
+ { "FLOAT", "FLOAT", "gfloat", "g_value_set_float", NULL, },
+ { "DOUBLE", "DOUBLE", "gdouble", "g_value_set_double", NULL, },
+ { "STRING", "STRING", "gchar*", "g_value_set_string_take_ownership", NULL, },
+ { "PARAM", "PARAM", "GParamSpec*", "g_value_set_param", "g_param_spec_unref", },
+ { "BOXED", "BOXED", "gpointer", "g_value_set_boxed_take_ownership", NULL, },
+ { "POINTER", "POINTER", "gpointer", "g_value_set_pointer", NULL, },
+ { "OBJECT", "OBJECT", "GObject*", "g_value_set_object", "g_object_unref", },
+ /* deprecated: */
+ { "NONE", "VOID", "void", NULL, NULL, },
+ { "BOOL", "BOOLEAN", "gboolean", "g_value_set_boolean", NULL, },
+ };
+ const guint n_args = sizeof (args) / sizeof (args[0]);
+ guint i;
+
+ g_return_val_if_fail (oarg != NULL, FALSE);
+
+ for (i = 0; i < n_args; i++)
+ if (strcmp (args[i].keyword, oarg->keyword) == 0)
{
- arg->sname = arguments[i].sname;
- arg->func = arguments[i].func;
- arg->cname = arguments[i].cname;
+ oarg->sig_name = args[i].sig_name;
+ oarg->ctype = args[i].ctype;
+ oarg->setter = args[i].setter;
+ oarg->release = args[i].release;
return TRUE;
}
-
return FALSE;
}
static const gchar*
indent (guint n_spaces)
{
- static gchar *buffer;
+ static gchar *buffer = NULL;
static guint blength = 0;
if (blength <= n_spaces)
fprintf (fout, "%sgpointer marshal_data)\n", indent (ind));
fprintf (fout, "{\n");
- /* cfile GSignalFunc typedef */
- ind = fprintf (fout, " typedef %s (*GSignalFunc_%s) (", sig->rarg->cname, signame);
+ /* cfile GMarshalFunc typedef */
+ ind = fprintf (fout, " typedef %s (*GMarshalFunc_%s) (", sig->rarg->ctype, signame);
fprintf (fout, "%s data1,\n", pad ("gpointer"));
for (a = 1, node = sig->args; node; node = node->next)
{
- Argument *arg = node->data;
+ InArgument *iarg = node->data;
- if (arg->func)
- fprintf (fout, "%s%s arg_%d,\n", indent (ind), pad (arg->cname), a++);
+ if (iarg->getter)
+ fprintf (fout, "%s%s arg_%d,\n", indent (ind), pad (iarg->ctype), a++);
}
fprintf (fout, "%s%s data2);\n", indent (ind), pad ("gpointer"));
/* cfile marshal variables */
- fprintf (fout, " register GSignalFunc_%s callback;\n", signame);
+ fprintf (fout, " register GMarshalFunc_%s callback;\n", signame);
fprintf (fout, " register GCClosure *cc = (GCClosure*) closure;\n");
fprintf (fout, " register gpointer data1, data2;\n");
- if (sig->rarg->func)
- fprintf (fout, " %s v_return;\n", sig->rarg->cname);
+ if (sig->rarg->setter)
+ fprintf (fout, " %s v_return;\n", sig->rarg->ctype);
- if (sig->args || sig->rarg->func)
+ if (sig->args || sig->rarg->setter)
{
fprintf (fout, "\n");
- if (sig->rarg->func)
+ if (sig->rarg->setter)
fprintf (fout, " g_return_if_fail (return_value != NULL);\n");
if (sig->args)
{
for (a = 0, node = sig->args; node; node = node->next)
{
- Argument *arg = node->data;
+ InArgument *iarg = node->data;
- if (arg->func)
+ if (iarg->getter)
a++;
}
fprintf (fout, " g_return_if_fail (n_param_values >= %u);\n", 1 + a);
fprintf (fout, "\n");
fprintf (fout, " if (G_CCLOSURE_SWAP_DATA (closure))\n {\n");
fprintf (fout, " data1 = closure->data;\n");
- fprintf (fout, " data2 = g_value_get_as_pointer (param_values + 0);\n");
+ fprintf (fout, " data2 = g_value_peek_pointer (param_values + 0);\n");
fprintf (fout, " }\n else\n {\n");
- fprintf (fout, " data1 = g_value_get_as_pointer (param_values + 0);\n");
+ fprintf (fout, " data1 = g_value_peek_pointer (param_values + 0);\n");
fprintf (fout, " data2 = closure->data;\n");
fprintf (fout, " }\n");
- fprintf (fout, " callback = (GSignalFunc_%s) (marshal_data ? marshal_data : cc->callback);\n", signame);
+ fprintf (fout, " callback = (GMarshalFunc_%s) (marshal_data ? marshal_data : cc->callback);\n", signame);
/* cfile marshal callback action */
fprintf (fout, "\n");
- ind = fprintf (fout, " %s callback (", sig->rarg->func ? " v_return =" : "");
+ ind = fprintf (fout, " %s callback (", sig->rarg->setter ? " v_return =" : "");
fprintf (fout, "data1,\n");
for (a = 1, node = sig->args; node; node = node->next)
{
- Argument *arg = node->data;
+ InArgument *iarg = node->data;
- if (arg->func)
- fprintf (fout, "%sg_value_get_%s (param_values + %d),\n", indent (ind), arg->func, a++);
+ if (iarg->getter)
+ fprintf (fout, "%s%s (param_values + %d),\n", indent (ind), iarg->getter, a++);
}
fprintf (fout, "%sdata2);\n", indent (ind));
/* cfile marshal return value storage */
- if (sig->rarg->func)
+ if (sig->rarg->setter)
{
fprintf (fout, "\n");
- fprintf (fout, " g_value_set_%s (return_value, v_return);\n", sig->rarg->func);
+ fprintf (fout, " %s (return_value, v_return);\n", sig->rarg->setter);
+ if (sig->rarg->release)
+ fprintf (fout, " %s (v_return);\n", sig->rarg->release);
}
/* cfile marshal footer */
GList *node;
/* lookup and complete info on arguments */
- if (!complete_arg (sig->rarg, TRUE))
+ if (!complete_out_arg (sig->rarg))
{
- g_warning ("unknown type: %s", sig->rarg->pname);
+ g_warning ("unknown type: %s", sig->rarg->keyword);
return;
}
for (node = sig->args; node; node = node->next)
{
- Argument *arg = node->data;
+ InArgument *iarg = node->data;
- if (!complete_arg (arg, FALSE))
+ if (!complete_in_arg (iarg))
{
- g_warning ("unknown type: %s", arg->pname);
+ g_warning ("unknown type: %s", iarg->keyword);
return;
}
}
/* construct requested marshaller name and technical marshaller name */
- pname = g_strconcat (sig->rarg->pname, "_", NULL);
- sname = g_strconcat (sig->rarg->sname, "_", NULL);
+ pname = g_strconcat (sig->rarg->keyword, "_", NULL);
+ sname = g_strconcat (sig->rarg->sig_name, "_", NULL);
for (node = sig->args; node; node = node->next)
{
- Argument *arg = node->data;
+ InArgument *iarg = node->data;
gchar *tmp;
tmp = sname;
- sname = g_strconcat (tmp, "_", arg->sname, NULL);
+ sname = g_strconcat (tmp, "_", iarg->sig_name, NULL);
g_free (tmp);
tmp = pname;
- pname = g_strconcat (tmp, "_", arg->pname, NULL);
+ pname = g_strconcat (tmp, "_", iarg->keyword, NULL);
g_free (tmp);
}
/* introductionary comment */
- fprintf (fout, "\n/* %s", sig->rarg->pname);
+ fprintf (fout, "\n/* %s", sig->rarg->keyword);
for (node = sig->args; node; node = node->next)
{
- Argument *arg = node->data;
+ InArgument *iarg = node->data;
- fprintf (fout, "%c%s", node->prev ? ',' : ':', arg->pname);
+ fprintf (fout, "%c%s", node->prev ? ',' : ':', iarg->keyword);
}
if (!skip_ploc)
fprintf (fout, " (%s)", sig->ploc);
g_free (sname);
}
-static Argument*
-new_arg (const gchar *pname)
+static InArgument*
+new_in_arg (const gchar *pname)
+{
+ InArgument *iarg = g_new0 (InArgument, 1);
+
+ iarg->keyword = g_strdup (pname);
+
+ return iarg;
+}
+
+static OutArgument*
+new_out_arg (const gchar *pname)
{
- Argument *arg = g_new0 (Argument, 1);
+ OutArgument *oarg = g_new0 (OutArgument, 1);
- arg->pname = g_strdup (pname);
+ oarg->keyword = g_strdup (pname);
- return arg;
+ return oarg;
}
static guint
/* parse identifier for return value */
if (g_scanner_get_next_token (scanner) != G_TOKEN_IDENTIFIER)
return G_TOKEN_IDENTIFIER;
- sig->rarg = new_arg (scanner->value.v_identifier);
+ sig->rarg = new_out_arg (scanner->value.v_identifier);
/* keep a note on the location */
sig->ploc = g_strdup_printf ("%s:%u", scanner->input_name, scanner->line);
/* parse first argument */
if (g_scanner_get_next_token (scanner) != G_TOKEN_IDENTIFIER)
return G_TOKEN_IDENTIFIER;
- sig->args = g_list_append (sig->args, new_arg (scanner->value.v_identifier));
+ sig->args = g_list_append (sig->args, new_in_arg (scanner->value.v_identifier));
/* parse rest of argument list */
while (g_scanner_peek_next_token (scanner) == ',')
/* parse arg identifier */
if (g_scanner_get_next_token (scanner) != G_TOKEN_IDENTIFIER)
return G_TOKEN_IDENTIFIER;
- sig->args = g_list_append (sig->args, new_arg (scanner->value.v_identifier));
+ sig->args = g_list_append (sig->args, new_in_arg (scanner->value.v_identifier));
}
/* expect end of line, done */
/* clean up signature contents */
g_free (signature.ploc);
if (signature.rarg)
- g_free (signature.rarg->pname);
+ g_free (signature.rarg->keyword);
g_free (signature.rarg);
for (node = signature.args; node; node = node->next)
{
- Argument *arg = node->data;
+ InArgument *iarg = node->data;
- g_free (arg->pname);
- g_free (arg);
+ g_free (iarg->keyword);
+ g_free (iarg);
}
g_list_free (signature.args);
}
# FLOAT for single-precision float types (gfloat)
# DOUBLE for double-precision float types (gdouble)
# STRING for string types (gchar*)
+# PARAM for GParamSpec or derived types (GParamSpec*)
# BOXED for boxed (anonymous but reference counted) types (GBoxed*)
# POINTER for anonymous pointer types (gpointer)
-# PARAM for GParamSpec or derived types (GParamSpec*)
# OBJECT for GObject or derived types (GObject*)
# NONE deprecated alias for VOID
# BOOL deprecated alias for BOOLEAN
+# standard VOID return marshallers
VOID:VOID
-VOID:UINT,POINTER
-VOID:PARAM
+VOID:BOOLEAN
+VOID:CHAR
+VOID:UCHAR
VOID:INT
-VOID:OBJECT
-VOID:POINTER
-VOID:STRING
VOID:UINT
+VOID:LONG
+VOID:ULONG
+VOID:ENUM
+VOID:FLAGS
+VOID:FLOAT
+VOID:DOUBLE
+VOID:STRING
+VOID:PARAM
+VOID:BOXED
+VOID:POINTER
+VOID:OBJECT
+
+# GRuntime specific marshallers
+VOID:UINT,POINTER
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
main (gint argc,
gchar *argv[])
{
+ GLogLevelFlags fatal_mask;
gboolean gen_froots = 0;
gboolean gen_tree = 0;
guint i;
gchar *iindent = "";
-
+
f_out = stdout;
- g_type_init (0);
+ fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+ fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
+ g_log_set_always_fatal (fatal_mask);
root = G_TYPE_OBJECT;
+
+ g_type_init (0);
for (i = 1; i < argc; i++)
{
else
return help (argv[i]);
}
+
if (!gen_froots && !gen_tree)
return help (argv[i-1]);
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* --- properties --- */
enum {
- PROP_NONE,
- PROP_DATA,
- PROP_SIGNAL,
- PROP_SWAPPED_SIGNAL,
- PROP_SIGNAL_AFTER,
- PROP_SWAPPED_SIGNAL_AFTER
+ PROP_NONE
};
static void g_object_do_set_property (GObject *object,
guint property_id,
const GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
static void g_object_do_get_property (GObject *object,
guint property_id,
GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
static void g_value_object_init (GValue *value);
static void g_value_object_free_value (GValue *value);
static void g_value_object_copy_value (const GValue *src_value,
GValue *dest_value);
+static void g_value_object_transform_value (const GValue *src_value,
+ GValue *dest_value);
static gpointer g_value_object_peek_pointer (const GValue *value);
static gchar* g_value_object_collect_value (GValue *value,
guint n_collect_values,
static inline void object_thaw_notifies (GObject *object,
NotifyQueue *nqueue);
static inline void object_get_property (GObject *object,
- GValue *value,
GParamSpec *pspec,
- const gchar *trailer);
+ GValue *value);
static inline void object_set_property (GObject *object,
- GValue *value,
GParamSpec *pspec,
- const gchar *trailer,
+ const GValue *value,
NotifyQueue *nqueue);
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_OBJECT, "GObject", &info, &finfo, 0);
g_assert (type == G_TYPE_OBJECT);
+ g_value_register_transform_func (G_TYPE_OBJECT, G_TYPE_OBJECT, g_value_object_transform_value);
#ifdef G_ENABLE_DEBUG
IF_DEBUG (OBJECTS)
class->properties_changed = g_object_properties_changed;
class->notify = g_object_notify_property_changed;
- g_object_class_install_property (class,
- PROP_DATA,
- g_param_spec_pointer ("data", "Named Data",
- "Named anonymous pointers",
- G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_class_install_property (class,
- PROP_SIGNAL,
- g_param_spec_ccallback ("signal", "Signal Connection",
- "Signal connection consisting of a callback function "
- "and a data pointer",
- G_PARAM_WRITABLE));
- g_object_class_install_property (class,
- PROP_SWAPPED_SIGNAL,
- g_param_spec_ccallback ("swapped_signal", "Swapped Signal Connection",
- "Signal connection consisting of a callback function "
- "and a data pointer",
- G_PARAM_WRITABLE));
- g_object_class_install_property (class,
- PROP_SIGNAL_AFTER,
- g_param_spec_ccallback ("signal_after", "Signal After Connection",
- "Signal connection consisting of a callback function "
- "and a data pointer",
- G_PARAM_WRITABLE));
- g_object_class_install_property (class,
- PROP_SWAPPED_SIGNAL_AFTER,
- g_param_spec_ccallback ("swapped_signal_after", "Swapped Signal After Connection",
- "Signal connection consisting of a callback function "
- "and a data pointer",
- G_PARAM_WRITABLE));
gobject_signals[PROPERTIES_CHANGED] =
g_signal_newc ("properties_changed",
G_TYPE_FROM_CLASS (class),
pspec->name);
return;
}
- if (g_param_spec_pool_lookup (pspec_pool, pspec->name, G_OBJECT_CLASS_TYPE (class), FALSE, NULL))
+ if (g_param_spec_pool_lookup (pspec_pool, pspec->name, G_OBJECT_CLASS_TYPE (class), FALSE))
{
g_warning (G_STRLOC ": class `%s' already contains a property named `%s'",
G_OBJECT_CLASS_NAME (class),
/* for property overrides of construct poperties, we have to get rid
* of the overidden inherited construct property
*/
- pspec = g_param_spec_pool_lookup (pspec_pool, pspec->name, g_type_parent (G_OBJECT_CLASS_TYPE (class)), TRUE, NULL);
+ pspec = g_param_spec_pool_lookup (pspec_pool, pspec->name, g_type_parent (G_OBJECT_CLASS_TYPE (class)), TRUE);
if (pspec && pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
class->construct_properties = g_slist_remove (class->construct_properties, pspec);
}
return g_param_spec_pool_lookup (pspec_pool,
property_name,
G_OBJECT_CLASS_TYPE (class),
- TRUE, NULL);
+ TRUE);
}
static void
g_object_do_set_property (GObject *object,
guint property_id,
const GValue *value,
- GParamSpec *pspec,
- const gchar *trailer)
+ GParamSpec *pspec)
{
- guint i = 0;
-
switch (property_id)
{
- gboolean swapped, after;
- gpointer callback, data;
- case PROP_DATA:
- g_return_if_fail (trailer != NULL);
-
- g_object_set_data (object, trailer, g_value_get_pointer (value));
- break;
- case PROP_SWAPPED_SIGNAL_AFTER:
- i++;
- case PROP_SIGNAL_AFTER:
- i++;
- case PROP_SWAPPED_SIGNAL:
- i++;
- case PROP_SIGNAL:
- after = i > 2;
- swapped = i & 1;
- g_return_if_fail (trailer != NULL);
-
- g_value_get_ccallback (value, &callback, &data);
- g_signal_connect_data (object, trailer,
- callback, data, NULL,
- swapped, after);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
g_object_do_get_property (GObject *object,
guint property_id,
GValue *value,
- GParamSpec *pspec,
- const gchar *trailer)
+ GParamSpec *pspec)
{
switch (property_id)
{
- case PROP_DATA:
- g_return_if_fail (trailer != NULL);
-
- g_value_set_pointer (value, g_object_get_data (object, trailer));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
if (object->ref_count == 0) /* may have been re-referenced meanwhile */
{
+ g_signal_handlers_destroy (object);
+ g_object_set_qdata (object, quark_closure_array, NULL);
G_OBJECT_GET_CLASS (object)->finalize (object);
#ifdef G_ENABLE_DEBUG
IF_DEBUG (OBJECTS)
pspec = g_param_spec_pool_lookup (pspec_pool,
property_name,
G_OBJECT_TYPE (object),
- TRUE, NULL);
+ TRUE);
if (!pspec)
g_warning ("%s: object class `%s' has no property named `%s'",
G_STRLOC,
static inline void
object_get_property (GObject *object,
- GValue *value,
GParamSpec *pspec,
- const gchar *trailer)
+ GValue *value)
{
GObjectClass *class;
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), pspec->owner_type)); /* paranoid */
-
class = g_type_class_peek (pspec->owner_type);
- class->get_property (object, PARAM_SPEC_PARAM_ID (pspec), value, pspec, trailer);
+ class->get_property (object, PARAM_SPEC_PARAM_ID (pspec), value, pspec);
}
-static inline void
-object_set_property (GObject *object,
- GValue *value,
- GParamSpec *pspec,
- const gchar *trailer,
- NotifyQueue *nqueue)
+static gchar*
+g_strdup_value_contents (const GValue *value)
{
- GObjectClass *class;
-
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), pspec->owner_type)); /* paranoid */
-
- class = g_type_class_peek (pspec->owner_type);
+ const gchar *src;
+ gchar *contents;
+
+ g_return_val_if_fail (G_IS_VALUE (value), NULL);
- class->set_property (object, PARAM_SPEC_PARAM_ID (pspec), value, pspec, trailer);
- object_queue_property (object, pspec, nqueue);
+ if (G_VALUE_HOLDS_STRING (value))
+ {
+ src = g_value_get_string (value);
+
+ if (!src)
+ contents = g_strdup ("NULL");
+ else
+ {
+ gchar *s = g_strescape (src, NULL);
+
+ contents = g_strdup_printf ("\"%s\"", s);
+ g_free (s);
+ }
+ }
+ else if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING))
+ {
+ GValue tmp_value = { 0, };
+
+ g_value_init (&tmp_value, G_TYPE_STRING);
+ g_value_transform (value, &tmp_value);
+ if (G_VALUE_HOLDS_ENUM (value) || G_VALUE_HOLDS_FLAGS (value))
+ contents = g_strdup_printf ("((%s) %s)",
+ g_type_name (G_VALUE_TYPE (value)),
+ g_value_get_string (&tmp_value));
+ else
+ {
+ src = g_value_get_string (&tmp_value);
+ contents = g_strdup (src ? src : "NULL");
+ }
+ g_value_unset (&tmp_value);
+ }
+ else if (g_value_fits_pointer (value))
+ {
+ gpointer p = g_value_peek_pointer (value);
+
+ if (!p)
+ contents = g_strdup ("NULL");
+ else if (G_VALUE_HOLDS_OBJECT (value))
+ contents = g_strdup_printf ("((%s*) %p)", G_OBJECT_TYPE_NAME (p), p);
+ else if (G_VALUE_HOLDS_PARAM (value))
+ contents = g_strdup_printf ("((%s*) %p)", G_PARAM_SPEC_TYPE_NAME (p), p);
+ else if (G_VALUE_HOLDS_BOXED (value))
+ contents = g_strdup_printf ("((%s*) %p)", g_type_name (G_VALUE_TYPE (value)), p);
+ else if (G_VALUE_HOLDS_POINTER (value))
+ contents = g_strdup_printf ("((gpointer) %p)", p);
+ else
+ contents = g_strdup ("???");
+ }
+ else
+ contents = g_strdup ("???");
+ return contents;
+}
+
+static inline void
+object_set_property (GObject *object,
+ GParamSpec *pspec,
+ const GValue *value,
+ NotifyQueue *nqueue)
+{
+ GValue tmp_value = { 0, };
+ GObjectClass *class = g_type_class_peek (pspec->owner_type);
+
+ /* provide a copy to work from, convert (if necessary) and validate */
+ g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ if (!g_value_transform (value, &tmp_value))
+ g_warning ("unable to set property `%s' of type `%s' from value of type `%s'",
+ pspec->name,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+ G_VALUE_TYPE_NAME (value));
+ else if (g_param_value_validate (pspec, &tmp_value) && !(pspec->flags & G_PARAM_LAX_VALIDATION))
+ {
+ gchar *contents = g_strdup_value_contents (value);
+
+ g_warning ("value <%s> of type `%s' is invalid for property `%s' of type `%s'",
+ contents,
+ G_VALUE_TYPE_NAME (value),
+ pspec->name,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
+ g_free (contents);
+ }
+ else
+ {
+ class->set_property (object, PARAM_SPEC_PARAM_ID (pspec), &tmp_value, pspec);
+ object_queue_property (object, pspec, nqueue);
+ }
+ g_value_unset (&tmp_value);
}
gpointer
name = first_property_name;
while (name)
{
- const gchar *trailer = NULL;
GValue *value;
GParamSpec *pspec;
gchar *error = NULL;
pspec = g_param_spec_pool_lookup (pspec_pool,
name,
object_type,
- TRUE,
- &trailer);
+ TRUE);
if (!pspec)
{
g_warning ("%s: object class `%s' has no property named `%s'",
cparams = g_renew (GObjectConstructParam, cparams, MAX (n_cparams + 1, PREALLOC_CPARAMS));
cparams[n_cparams].pspec = pspec;
cparams[n_cparams].value = value;
- cparams[n_cparams].trailer = trailer;
for (i = 0; i < n_cparams; i++) /* picky, aren't we? ;) */
if (cparams[i].pspec == pspec)
g_warning (G_STRLOC ": construct property \"%s\" for object `%s' is being set twice",
nparams = g_renew (GObjectConstructParam, nparams, MAX (n_nparams + 1, PREALLOC_CPARAMS));
nparams[n_nparams].pspec = pspec;
nparams[n_nparams].value = value;
- nparams[n_nparams].trailer = trailer;
n_nparams++;
}
cparams = g_renew (GObjectConstructParam, cparams, MAX (n_cparams + 1, PREALLOC_CPARAMS));
cparams[n_cparams].pspec = pspec;
cparams[n_cparams].value = value;
- cparams[n_cparams].trailer = NULL;
n_cparams++;
g_slist_free_1 (clist);
{
GValue *value = nparams->value;
GParamSpec *pspec = nparams->pspec;
- const gchar *trailer = nparams++->trailer;
-
- /* convert if necessary */
- if (!g_type_is_a (G_VALUE_TYPE (value), G_PARAM_SPEC_VALUE_TYPE (pspec)))
- {
- GValue tmp_value = { 0, };
- g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- if (!g_value_convert (value, &tmp_value) ||
- g_param_value_validate (pspec, &tmp_value))
- g_warning ("%s: cannot convert `%s' value to property `%s' value of type `%s'",
- G_STRLOC,
- G_VALUE_TYPE_NAME (value),
- pspec->name,
- g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
- else
- object_set_property (object, &tmp_value, pspec, trailer, nqueue);
- g_value_unset (&tmp_value);
- }
- else
- object_set_property (object, value, pspec, trailer, nqueue);
-
+ nparams++;
+ object_set_property (object, pspec, value, nqueue);
g_value_unset (value);
g_free (value);
}
{
GValue *value = construct_params->value;
GParamSpec *pspec = construct_params->pspec;
- const gchar *trailer = construct_params++->trailer;
-
- /* convert if necessary */
- if (!g_type_is_a (G_VALUE_TYPE (value), G_PARAM_SPEC_VALUE_TYPE (pspec)))
- {
- GValue tmp_value = { 0, };
-
- g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- if (!g_value_convert (value, &tmp_value) ||
- g_param_value_validate (pspec, &tmp_value))
- g_warning ("%s: cannot convert `%s' value to property `%s' value of type `%s'",
- G_STRLOC,
- G_VALUE_TYPE_NAME (value),
- pspec->name,
- g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
- else
- object_set_property (object, &tmp_value, pspec, trailer, nqueue);
- g_value_unset (&tmp_value);
- }
- else
- object_set_property (object, value, pspec, trailer, nqueue);
+
+ construct_params++;
+ object_set_property (object, pspec, value, nqueue);
}
nqueue->freeze_count--;
/* the notification queue is still frozen from g_object_init(), so
name = first_property_name;
while (name)
{
- const gchar *trailer = NULL;
GValue value = { 0, };
GParamSpec *pspec;
gchar *error = NULL;
pspec = g_param_spec_pool_lookup (pspec_pool,
name,
G_OBJECT_TYPE (object),
- TRUE,
- &trailer);
+ TRUE);
if (!pspec)
{
g_warning ("%s: object class `%s' has no property named `%s'",
break;
}
- object_set_property (object, &value, pspec, trailer, nqueue);
-
+ object_set_property (object, pspec, &value, nqueue);
g_value_unset (&value);
name = va_arg (var_args, gchar*);
while (name)
{
- const gchar *trailer = NULL;
GValue value = { 0, };
GParamSpec *pspec;
gchar *error;
pspec = g_param_spec_pool_lookup (pspec_pool,
name,
G_OBJECT_TYPE (object),
- TRUE,
- &trailer);
+ TRUE);
if (!pspec)
{
g_warning ("%s: object class `%s' has no property named `%s'",
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- object_get_property (object, &value, pspec, trailer);
+ object_get_property (object, pspec, &value);
- G_VALUE_LCOPY (&value, var_args, 0, &error);
+ G_VALUE_LCOPY (&value, var_args, G_VALUE_NOCOPY_CONTENTS, &error);
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);
g_object_unref (object);
}
-void
+gpointer
g_object_set (gpointer _object,
const gchar *first_property_name,
...)
GObject *object = _object;
va_list var_args;
- g_return_if_fail (G_IS_OBJECT (object));
+ g_return_val_if_fail (G_IS_OBJECT (object), NULL);
va_start (var_args, first_property_name);
g_object_set_valist (object, first_property_name, var_args);
va_end (var_args);
+
+ return object;
}
void
{
NotifyQueue *nqueue;
GParamSpec *pspec;
- const gchar *trailer;
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (property_name != NULL);
pspec = g_param_spec_pool_lookup (pspec_pool,
property_name,
G_OBJECT_TYPE (object),
- TRUE,
- &trailer);
+ TRUE);
if (!pspec)
- g_warning ("%s: object class `%s' has no property named `%s'",
- G_STRLOC,
+ g_warning ("object class `%s' has no property named `%s'",
G_OBJECT_TYPE_NAME (object),
property_name);
else
- {
- GValue tmp_value = { 0, };
-
- /* provide a copy to work from and convert if necessary */
- g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
-
- if (!g_value_convert (value, &tmp_value) ||
- g_param_value_validate (pspec, &tmp_value))
- g_warning ("%s: cannot convert `%s' value to property `%s' value of type `%s'",
- G_STRLOC,
- G_VALUE_TYPE_NAME (value),
- pspec->name,
- g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
- else
- object_set_property (object, &tmp_value, pspec, trailer, nqueue);
-
- g_value_unset (&tmp_value);
- }
+ object_set_property (object, pspec, value, nqueue);
object_thaw_notifies (object, nqueue);
g_object_unref (object);
GValue *value)
{
GParamSpec *pspec;
- const gchar *trailer;
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (property_name != NULL);
pspec = g_param_spec_pool_lookup (pspec_pool,
property_name,
G_OBJECT_TYPE (object),
- TRUE,
- &trailer);
+ TRUE);
if (!pspec)
- g_warning ("%s: object class `%s' has no property named `%s'",
- G_STRLOC,
+ g_warning ("object class `%s' has no property named `%s'",
G_OBJECT_TYPE_NAME (object),
property_name);
else
{
- GValue tmp_value = { 0, };
+ GValue *prop_value, tmp_value = { 0, };
- /* provide a copy to work from and later convert if necessary, so
- * _get_property() implementations need *not* care about freeing values
- * that might be already set in the property to get.
- * (though, at this point, GValue should exclusively be modified
- * through the accessor functions anyways)
+ /* auto-conversion of the callers value type
*/
- g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
-
- if (!g_value_types_exchangable (G_VALUE_TYPE (value), G_PARAM_SPEC_VALUE_TYPE (pspec)))
- g_warning ("%s: can't retrive property `%s' value of type `%s' as value of type `%s'",
- G_STRLOC,
- pspec->name,
- g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
- G_VALUE_TYPE_NAME (value));
+ if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
+ {
+ g_value_reset (value);
+ prop_value = value;
+ }
+ else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
+ {
+ g_warning ("can't retrive property `%s' of type `%s' as value of type `%s'",
+ pspec->name,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+ G_VALUE_TYPE_NAME (value));
+ return;
+ }
else
{
- object_get_property (object, &tmp_value, pspec, trailer);
- g_value_convert (&tmp_value, value);
- /* g_value_validate (value, pspec); */
+ g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ prop_value = &tmp_value;
+ }
+ object_get_property (object, pspec, prop_value);
+ if (prop_value != value)
+ {
+ g_value_transform (prop_value, value);
+ g_value_unset (&tmp_value);
}
-
- g_value_unset (&tmp_value);
}
g_object_unref (object);
}
+gpointer
+g_object_connect (gpointer _object,
+ const gchar *signal_spec,
+ ...)
+{
+ GObject *object = _object;
+ va_list var_args;
+
+ g_return_val_if_fail (G_IS_OBJECT (object), NULL);
+ g_return_val_if_fail (object->ref_count > 0, object);
+
+ va_start (var_args, signal_spec);
+ while (signal_spec)
+ {
+ gpointer callback = va_arg (var_args, gpointer);
+ gpointer data = va_arg (var_args, gpointer);
+ guint sid;
+
+ if (strncmp (signal_spec, "signal::", 8) == 0)
+ sid = g_signal_connect_data (object, signal_spec + 8,
+ callback, data, NULL,
+ FALSE, FALSE);
+ else if (strncmp (signal_spec, "swapped_signal::", 16) == 0)
+ sid = g_signal_connect_data (object, signal_spec + 16,
+ callback, data, NULL,
+ TRUE, FALSE);
+ else if (strncmp (signal_spec, "signal_after::", 14) == 0)
+ sid = g_signal_connect_data (object, signal_spec + 14,
+ callback, data, NULL,
+ FALSE, TRUE);
+ else if (strncmp (signal_spec, "swapped_signal_after::", 22) == 0)
+ sid = g_signal_connect_data (object, signal_spec + 22,
+ callback, data, NULL,
+ TRUE, TRUE);
+ else
+ {
+ g_warning ("%s: invalid signal spec \"%s\"", G_STRLOC, signal_spec);
+ break;
+ }
+ signal_spec = va_arg (var_args, gchar*);
+ }
+ va_end (var_args);
+
+ return object;
+}
+
+gpointer
+g_object_disconnect (gpointer _object,
+ const gchar *signal_spec,
+ ...)
+{
+ GObject *object = _object;
+ va_list var_args;
+
+ g_return_val_if_fail (G_IS_OBJECT (object), NULL);
+ g_return_val_if_fail (object->ref_count > 0, object);
+
+ va_start (var_args, signal_spec);
+ while (signal_spec)
+ {
+ gpointer callback = va_arg (var_args, gpointer);
+ gpointer data = va_arg (var_args, gpointer);
+ guint sid = 0, detail = 0, mask = 0;
+
+ if (strncmp (signal_spec, "any_signal::", 12) == 0)
+ {
+ signal_spec += 12;
+ mask = G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA;
+ }
+ else if (strcmp (signal_spec, "any_signal") == 0)
+ {
+ signal_spec += 10;
+ mask = G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA;
+ }
+ else
+ {
+ g_warning ("%s: invalid signal spec \"%s\"", G_STRLOC, signal_spec);
+ break;
+ }
+
+ if ((mask & G_SIGNAL_MATCH_ID) &&
+ !g_signal_parse_name (signal_spec, G_OBJECT_TYPE (object), &sid, &detail, FALSE))
+ g_warning ("%s: invalid signal name \"%s\"", G_STRLOC, signal_spec);
+ else if (!g_signal_handlers_disconnect_matched (object, mask | (detail ? G_SIGNAL_MATCH_DETAIL : 0),
+ sid, detail,
+ NULL, callback, data))
+ g_warning (G_STRLOC ": signal handler %p(%p) is not connected", callback, data);
+ signal_spec = va_arg (var_args, gchar*);
+ }
+ va_end (var_args);
+
+ return object;
+}
+
gpointer
g_object_ref (gpointer _object)
{
dest_value->data[0].v_pointer = NULL;
}
+static void
+g_value_object_transform_value (const GValue *src_value,
+ GValue *dest_value)
+{
+ if (src_value->data[0].v_pointer && g_type_is_a (G_OBJECT_TYPE (src_value->data[0].v_pointer), G_VALUE_TYPE (dest_value)))
+ dest_value->data[0].v_pointer = g_object_ref (src_value->data[0].v_pointer);
+ else
+ dest_value->data[0].v_pointer = NULL;
+}
+
static gpointer
g_value_object_peek_pointer (const GValue *value)
{
G_VALUE_TYPE_NAME (value),
"'",
NULL);
- else if (!g_type_is_a (G_OBJECT_TYPE (object), G_VALUE_TYPE (value)))
+ else if (!g_value_type_compatible (G_OBJECT_TYPE (object), G_VALUE_TYPE (value)))
return g_strconcat ("invalid object type `",
G_OBJECT_TYPE_NAME (object),
"' for value type `",
G_VALUE_TYPE_NAME (value),
"'",
NULL);
+ /* never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types */
value->data[0].v_pointer = g_object_ref (object);
}
else
g_value_set_object (GValue *value,
GObject *v_object)
{
- g_return_if_fail (G_IS_VALUE_OBJECT (value));
+ g_return_if_fail (G_VALUE_HOLDS_OBJECT (value));
if (value->data[0].v_pointer)
{
if (v_object)
{
g_return_if_fail (G_IS_OBJECT (v_object));
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (v_object), G_VALUE_TYPE (value)));
+ g_return_if_fail (g_value_type_compatible (G_OBJECT_TYPE (v_object), G_VALUE_TYPE (value)));
value->data[0].v_pointer = v_object;
g_object_ref (value->data[0].v_pointer);
}
}
-GObject*
+gpointer
g_value_get_object (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_OBJECT (value), NULL);
+ g_return_val_if_fail (G_VALUE_HOLDS_OBJECT (value), NULL);
return value->data[0].v_pointer;
}
GObject*
g_value_dup_object (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_OBJECT (value), NULL);
+ g_return_val_if_fail (G_VALUE_HOLDS_OBJECT (value), NULL);
return value->data[0].v_pointer ? g_object_ref (value->data[0].v_pointer) : NULL;
}
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* --- type macros --- */
-#define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT)
-#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
-#define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))
-#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT))
-#define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT))
-#define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))
-#define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
-#define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object)))
-#define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
-#define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class)))
-#define G_IS_VALUE_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT))
+#define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT)
+#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
+#define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))
+#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT))
+#define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT))
+#define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))
+#define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
+#define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object)))
+#define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
+#define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class)))
+#define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT))
/* --- typedefs & structures --- */
typedef void (*GObjectGetPropertyFunc) (GObject *object,
guint property_id,
GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
typedef void (*GObjectSetPropertyFunc) (GObject *object,
guint property_id,
const GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
typedef void (*GObjectFinalizeFunc) (GObject *object);
struct _GObject
{
void (*set_property) (GObject *object,
guint property_id,
const GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
void (*get_property) (GObject *object,
guint property_id,
GValue *value,
- GParamSpec *pspec,
- const gchar *trailer);
+ GParamSpec *pspec);
void (*shutdown) (GObject *object);
void (*finalize) (GObject *object);
{
GParamSpec *pspec;
GValue *value;
- const gchar *trailer;
};
gpointer g_object_new_valist (GType object_type,
const gchar *first_property_name,
va_list var_args);
-void g_object_set (gpointer object,
+gpointer g_object_set (gpointer object,
const gchar *first_property_name,
...);
void g_object_get (gpointer object,
const gchar *first_property_name,
...);
+gpointer g_object_connect (gpointer object,
+ const gchar *signal_spec,
+ ...);
+gpointer g_object_disconnect (gpointer object,
+ const gchar *signal_spec,
+ ...);
void g_object_set_valist (GObject *object,
const gchar *first_property_name,
va_list var_args);
GObject *object);
void g_value_set_object (GValue *value,
GObject *v_object);
-GObject* g_value_get_object (const GValue *value);
+gpointer g_value_get_object (const GValue *value);
GObject* g_value_dup_object (const GValue *value);
guint g_signal_connect_object (gpointer instance,
const gchar *detailed_signal,
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* --- defines --- */
#define G_PARAM_SPEC_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_PARAM, GParamSpecClass))
-#define G_PARAM_USER_MASK ((1 << G_PARAM_USER_SHIFT) - 1)
+#define G_PARAM_USER_MASK (~0 << G_PARAM_USER_SHIFT)
#define PSPEC_APPLIES_TO_VALUE(pspec, value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_PARAM_SPEC_VALUE_TYPE (pspec)))
#define G_SLOCK(mutex) g_static_mutex_lock (mutex)
#define G_SUNLOCK(mutex) g_static_mutex_unlock (mutex)
static void value_param_free_value (GValue *value);
static void value_param_copy_value (const GValue *src_value,
GValue *dest_value);
+static void value_param_transform_value (const GValue *src_value,
+ GValue *dest_value);
static gpointer value_param_peek_pointer (const GValue *value);
static gchar* value_param_collect_value (GValue *value,
guint n_collect_values,
type = g_type_register_fundamental (G_TYPE_PARAM, "GParam", ¶m_spec_info, &finfo, G_TYPE_FLAG_ABSTRACT);
g_assert (type == G_TYPE_PARAM);
+ g_value_register_transform_func (G_TYPE_PARAM, G_TYPE_PARAM, value_param_transform_value);
}
static void
return FALSE;
}
+gboolean
+g_param_value_convert (GParamSpec *pspec,
+ const GValue *src_value,
+ GValue *dest_value,
+ gboolean strict_validation)
+{
+ GValue tmp_value = { 0, };
+
+ g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
+ g_return_val_if_fail (G_IS_VALUE (src_value), FALSE);
+ g_return_val_if_fail (G_IS_VALUE (dest_value), FALSE);
+ g_return_val_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, dest_value), FALSE);
+
+ /* better leave dest_value untouched when returning FALSE */
+
+ g_value_init (&tmp_value, G_VALUE_TYPE (dest_value));
+ if (g_value_transform (src_value, &tmp_value) &&
+ (!g_param_value_validate (pspec, &tmp_value) || !strict_validation))
+ {
+ g_value_unset (dest_value);
+
+ /* values are relocatable */
+ memcpy (dest_value, &tmp_value, sizeof (tmp_value));
+
+ return TRUE;
+ }
+ else
+ {
+ g_value_unset (&tmp_value);
+
+ return FALSE;
+ }
+}
+
gint
g_param_values_cmp (GParamSpec *pspec,
const GValue *value1,
value_param_copy_value (const GValue *src_value,
GValue *dest_value)
{
- dest_value->data[0].v_pointer = (src_value->data[0].v_pointer
- ? g_param_spec_ref (src_value->data[0].v_pointer)
- : NULL);
+ if (src_value->data[0].v_pointer)
+ dest_value->data[0].v_pointer = g_param_spec_ref (src_value->data[0].v_pointer);
+ else
+ dest_value->data[0].v_pointer = NULL;
+}
+
+static void
+value_param_transform_value (const GValue *src_value,
+ GValue *dest_value)
+{
+ if (src_value->data[0].v_pointer &&
+ g_type_is_a (G_PARAM_SPEC_TYPE (dest_value->data[0].v_pointer), G_VALUE_TYPE (dest_value)))
+ dest_value->data[0].v_pointer = g_param_spec_ref (src_value->data[0].v_pointer);
+ else
+ dest_value->data[0].v_pointer = NULL;
}
static gpointer
G_VALUE_TYPE_NAME (value),
"'",
NULL);
- else if (!g_type_is_a (G_PARAM_SPEC_TYPE (param), G_VALUE_TYPE (value)))
+ else if (!g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_VALUE_TYPE (value)))
return g_strconcat ("invalid param spec type `",
G_PARAM_SPEC_TYPE_NAME (param),
"' for value type `",
g_param_spec_pool_lookup (GParamSpecPool *pool,
const gchar *param_name,
GType owner_type,
- gboolean walk_ancestors,
- const gchar **trailer_p)
+ gboolean walk_ancestors)
{
GParamSpec *pspec;
gchar *delim;
G_SLOCK (&pool->smutex);
- delim = strchr (param_name, ':');
+ delim = pool->type_prefixing ? strchr (param_name, ':') : NULL;
- /* try quick and away, i.e. no prefix, no trailer */
+ /* try quick and away, i.e. without prefix */
if (!delim)
{
- if (trailer_p)
- *trailer_p = NULL;
pspec = param_spec_ht_lookup (pool->hash_table, param_name, owner_type, walk_ancestors);
G_SUNLOCK (&pool->smutex);
/* sanity check, these cases don't make a whole lot of sense */
if ((!walk_ancestors && type != owner_type) || !g_type_is_a (owner_type, type))
{
- if (trailer_p)
- *trailer_p = NULL;
G_SUNLOCK (&pool->smutex);
return NULL;
}
owner_type = type;
param_name += l + 2;
- delim = strchr (param_name, ':');
- if (!delim) /* good, can still forget about trailer */
- {
- if (trailer_p)
- *trailer_p = NULL;
- pspec = param_spec_ht_lookup (pool->hash_table, param_name, owner_type, walk_ancestors);
- G_SUNLOCK (&pool->smutex);
+ pspec = param_spec_ht_lookup (pool->hash_table, param_name, owner_type, walk_ancestors);
+ G_SUNLOCK (&pool->smutex);
- return pspec;
- }
+ return pspec;
}
}
-
- /* ok, no prefix, handle trailer */
- if (delim[1] == ':')
- {
- guint l = delim - param_name;
- gchar stack_buffer[32], *buffer = l < 32 ? stack_buffer : g_new (gchar, l + 1);
-
- strncpy (buffer, param_name, delim - param_name);
- buffer[l] = 0;
- pspec = param_spec_ht_lookup (pool->hash_table, buffer, owner_type, walk_ancestors);
- if (l >= 32)
- g_free (buffer);
- if (trailer_p)
- *trailer_p = pspec ? delim + 2 : NULL;
- G_SUNLOCK (&pool->smutex);
-
- return pspec;
- }
-
/* malformed param_name */
- if (trailer_p)
- *trailer_p = NULL;
+
G_SUNLOCK (&pool->smutex);
return NULL;
g_value_set_param (GValue *value,
GParamSpec *param)
{
- g_return_if_fail (G_IS_VALUE_PARAM (value));
+ g_return_if_fail (G_VALUE_HOLDS_PARAM (value));
if (param)
g_return_if_fail (G_IS_PARAM_SPEC (param));
GParamSpec*
g_value_get_param (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_PARAM (value), NULL);
+ g_return_val_if_fail (G_VALUE_HOLDS_PARAM (value), NULL);
return value->data[0].v_pointer;
}
GParamSpec*
g_value_dup_param (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_PARAM (value), NULL);
+ g_return_val_if_fail (G_VALUE_HOLDS_PARAM (value), NULL);
return value->data[0].v_pointer ? g_param_spec_ref (value->data[0].v_pointer) : NULL;
}
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#define G_IS_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM))
#define G_PARAM_SPEC_GET_CLASS(pspec) (G_TYPE_INSTANCE_GET_CLASS ((pspec), G_TYPE_PARAM, GParamSpecClass))
#define G_PARAM_SPEC_VALUE_TYPE(pspec) (G_PARAM_SPEC (pspec)->value_type)
-#define G_IS_VALUE_PARAM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_PARAM))
+#define G_VALUE_HOLDS_PARAM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_PARAM))
/* --- flags --- */
G_PARAM_WRITABLE = 1 << 1,
G_PARAM_CONSTRUCT = 1 << 2,
G_PARAM_CONSTRUCT_ONLY = 1 << 3,
- G_PARAM_PRIVATE = 1 << 4
+ G_PARAM_LAX_VALIDATION = 1 << 4,
+ G_PARAM_PRIVATE = 1 << 5
} GParamFlags;
#define G_PARAM_READWRITE (G_PARAM_READABLE | G_PARAM_WRITABLE)
#define G_PARAM_MASK (0x000000ff)
GValue *value);
gboolean g_param_value_validate (GParamSpec *pspec,
GValue *value);
+gboolean g_param_value_convert (GParamSpec *dest_value_spec,
+ const GValue *src_value,
+ GValue *dest_value,
+ gboolean strict_validation);
gint g_param_values_cmp (GParamSpec *pspec,
const GValue *value1,
const GValue *value2);
GParamSpec* g_param_spec_pool_lookup (GParamSpecPool *pool,
const gchar *param_name,
GType owner_type,
- gboolean walk_ancestors,
- const gchar **trailer_p);
+ gboolean walk_ancestors);
/* contracts:
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "gparamspecs.h"
#include "gvaluecollector.h"
+#include "gvaluearray.h"
#include <string.h>
#include "../config.h" /* for SIZEOF_LONG */
/* --- param spec functions --- */
static void
-param_spec_char_init (GParamSpec *pspec)
+param_char_init (GParamSpec *pspec)
{
GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
}
static void
-param_spec_uchar_init (GParamSpec *pspec)
+param_uchar_init (GParamSpec *pspec)
{
GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
}
static void
-param_spec_int_init (GParamSpec *pspec)
+param_int_init (GParamSpec *pspec)
{
GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
}
static void
-param_spec_uint_init (GParamSpec *pspec)
+param_uint_init (GParamSpec *pspec)
{
GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
}
static void
-param_spec_long_init (GParamSpec *pspec)
+param_long_init (GParamSpec *pspec)
{
GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
}
static void
-param_spec_ulong_init (GParamSpec *pspec)
+param_ulong_init (GParamSpec *pspec)
{
GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
}
static void
-param_spec_enum_init (GParamSpec *pspec)
+param_enum_init (GParamSpec *pspec)
{
GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
}
static void
-param_spec_enum_finalize (GParamSpec *pspec)
+param_enum_finalize (GParamSpec *pspec)
{
GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_ENUM));
}
static void
-param_spec_flags_init (GParamSpec *pspec)
+param_flags_init (GParamSpec *pspec)
{
GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
}
static void
-param_spec_flags_finalize (GParamSpec *pspec)
+param_flags_finalize (GParamSpec *pspec)
{
GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_FLAGS));
}
static void
-param_spec_float_init (GParamSpec *pspec)
+param_float_init (GParamSpec *pspec)
{
GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
}
static void
-param_spec_double_init (GParamSpec *pspec)
+param_double_init (GParamSpec *pspec)
{
GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
}
static void
-param_spec_string_init (GParamSpec *pspec)
+param_string_init (GParamSpec *pspec)
{
GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
}
static void
-param_spec_string_finalize (GParamSpec *pspec)
+param_string_finalize (GParamSpec *pspec)
{
GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_STRING));
}
static void
-param_spec_param_init (GParamSpec *pspec)
+param_param_init (GParamSpec *pspec)
{
/* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
}
GParamSpec *param = value->data[0].v_pointer;
guint changed = 0;
- if (param && !g_type_is_a (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec)))
+ if (param && !g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec)))
{
g_param_spec_unref (param);
value->data[0].v_pointer = NULL;
}
static void
-param_spec_pointer_init (GParamSpec *pspec)
+param_boxed_init (GParamSpec *pspec)
{
- /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
+ /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
}
static void
-param_pointer_set_default (GParamSpec *pspec,
- GValue *value)
+param_boxed_set_default (GParamSpec *pspec,
+ GValue *value)
{
value->data[0].v_pointer = NULL;
}
static gboolean
-param_pointer_validate (GParamSpec *pspec,
- GValue *value)
+param_boxed_validate (GParamSpec *pspec,
+ GValue *value)
{
- /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
+ /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
guint changed = 0;
+
+ /* can't do a whole lot here since we haven't even G_BOXED_TYPE() */
return changed;
}
static gint
-param_pointer_values_cmp (GParamSpec *pspec,
- const GValue *value1,
- const GValue *value2)
+param_boxed_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
{
- return value1->data[0].v_pointer != value2->data[0].v_pointer;
+ guint8 *p1 = value1->data[0].v_pointer;
+ guint8 *p2 = value2->data[0].v_pointer;
+
+ /* not much to compare here, try to at least provide stable lesser/greater result */
+
+ return p1 < p2 ? -1 : p1 > p2;
}
static void
-param_spec_ccallback_init (GParamSpec *pspec)
+param_pointer_init (GParamSpec *pspec)
{
- /* GParamSpecCCallback *spec = G_PARAM_SPEC_CCALLBACK (pspec); */
+ /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
}
static void
-param_ccallback_set_default (GParamSpec *pspec,
- GValue *value)
+param_pointer_set_default (GParamSpec *pspec,
+ GValue *value)
{
value->data[0].v_pointer = NULL;
- value->data[1].v_pointer = NULL;
}
static gboolean
-param_ccallback_validate (GParamSpec *pspec,
- GValue *value)
+param_pointer_validate (GParamSpec *pspec,
+ GValue *value)
{
- /* GParamSpecCCallback *spec = G_PARAM_SPEC_CCALLBACK (pspec); */
+ /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
guint changed = 0;
return changed;
}
static gint
-param_ccallback_values_cmp (GParamSpec *pspec,
- const GValue *value1,
- const GValue *value2)
+param_pointer_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
{
- return (value1->data[0].v_pointer != value2->data[0].v_pointer ||
- value1->data[1].v_pointer != value2->data[1].v_pointer);
+ guint8 *p1 = value1->data[0].v_pointer;
+ guint8 *p2 = value2->data[0].v_pointer;
+
+ /* not much to compare here, try to at least provide stable lesser/greater result */
+
+ return p1 < p2 ? -1 : p1 > p2;
}
static void
-param_spec_boxed_init (GParamSpec *pspec)
+param_closure_init (GParamSpec *pspec)
{
- /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
+ /* GParamSpecClosure *cspec = G_PARAM_SPEC_CLOSURE (pspec); */
}
static void
-param_boxed_set_default (GParamSpec *pspec,
- GValue *value)
+param_closure_set_default (GParamSpec *pspec,
+ GValue *value)
{
value->data[0].v_pointer = NULL;
}
static gboolean
-param_boxed_validate (GParamSpec *pspec,
- GValue *value)
+param_closure_validate (GParamSpec *pspec,
+ GValue *value)
{
- /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
+ /* GParamSpecClosure *cspec = G_PARAM_SPEC_CLOSURE (pspec); */
+ /* GClosure *closure = value->data[0].v_pointer; */
guint changed = 0;
- /* can't do a whole lot here since we haven't even G_BOXED_TYPE() */
-
+ /* we don't actually have necessary means to ensure closure validity */
+
return changed;
}
static gint
-param_boxed_values_cmp (GParamSpec *pspec,
- const GValue *value1,
- const GValue *value2)
+param_closure_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
{
- return value1->data[0].v_pointer != value2->data[0].v_pointer;
-}
+ guint8 *p1 = value1->data[0].v_pointer;
+ guint8 *p2 = value2->data[0].v_pointer;
-static void
-param_spec_object_init (GParamSpec *pspec)
-{
- /* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */
-}
+ /* not much to compare here, try to at least provide stable lesser/greater result */
-static void
-param_spec_interface_init (GParamSpec *pspec)
-{
- /* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */
+ return p1 < p2 ? -1 : p1 > p2;
}
static void
-param_object_set_default (GParamSpec *pspec,
- GValue *value)
+param_value_array_init (GParamSpec *pspec)
{
- value->data[0].v_pointer = NULL;
+ GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
+
+ aspec->element_spec = NULL;
+ aspec->fixed_n_elements = 0; /* disable */
}
-static gboolean
-param_object_validate (GParamSpec *pspec,
- GValue *value)
+static inline guint
+value_array_ensure_size (GValueArray *value_array,
+ guint fixed_n_elements)
{
- GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec);
- GObject *object = value->data[0].v_pointer;
guint changed = 0;
-
- if (object && !g_type_is_a (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec)))
+
+ if (fixed_n_elements)
{
- g_object_unref (object);
- value->data[0].v_pointer = NULL;
- changed++;
+ while (value_array->n_values < fixed_n_elements)
+ {
+ g_value_array_append (value_array, NULL);
+ changed++;
+ }
+ while (value_array->n_values > fixed_n_elements)
+ {
+ g_value_array_remove (value_array, value_array->n_values - 1);
+ changed++;
+ }
}
-
return changed;
}
-static gint
-param_object_values_cmp (GParamSpec *pspec,
- const GValue *value1,
- const GValue *value2)
+static void
+param_value_array_finalize (GParamSpec *pspec)
{
- return value1->data[0].v_pointer != value2->data[0].v_pointer;
+ GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
+ GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_VALUE_ARRAY));
+
+ if (aspec->element_spec)
+ {
+ g_param_spec_unref (aspec->element_spec);
+ aspec->element_spec = NULL;
+ }
+
+ parent_class->finalize (pspec);
}
static void
-param_interface_set_default (GParamSpec *pspec,
- GValue *value)
+param_value_array_set_default (GParamSpec *pspec,
+ GValue *value)
{
- value->data[0].v_pointer = NULL;
+ GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
+
+ g_return_if_fail (value->data[0].v_pointer != NULL); /* paranoid */
+
+ /* g_value_reset (value); already done */
+ value_array_ensure_size (value->data[0].v_pointer, aspec->fixed_n_elements);
}
static gboolean
-param_interface_validate (GParamSpec *pspec,
- GValue *value)
+param_value_array_validate (GParamSpec *pspec,
+ GValue *value)
{
+ GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
+ GValueArray *value_array = value->data[0].v_pointer;
guint changed = 0;
-
- if (value->data[0].v_pointer == NULL)
- changed++;
- return changed;
-}
+ g_return_val_if_fail (value->data[0].v_pointer != NULL, FALSE); /* paranoid */
-static gint
-param_interface_values_cmp (GParamSpec *pspec,
- const GValue *value1,
- const GValue *value2)
-{
- return value1->data[0].v_pointer != value2->data[0].v_pointer;
-}
+ /* ensure array size validity */
+ changed += value_array_ensure_size (value_array, aspec->fixed_n_elements);
-static void
-value_exch_memcpy (GValue *value1,
- GValue *value2)
-{
- GValue tmp_value;
- memcpy (&tmp_value.data, &value1->data, sizeof (value1->data));
- memcpy (&value1->data, &value2->data, sizeof (value1->data));
- memcpy (&value2->data, &tmp_value.data, sizeof (value2->data));
-}
+ /* ensure array values validity against a present element spec */
+ if (aspec->element_spec)
+ {
+ GParamSpec *element_spec = aspec->element_spec;
+ guint i;
-static void
-value_exch_long_int (GValue *value1,
- GValue *value2)
-{
- glong tmp = value1->data[0].v_long;
- value1->data[0].v_long = value2->data[0].v_int;
- value2->data[0].v_int = tmp;
-}
+ for (i = 0; i < value_array->n_values; i++)
+ {
+ GValue *element = value_array->values + i;
-static void
-value_exch_long_uint (GValue *value1,
- GValue *value2)
-{
- glong tmp = value1->data[0].v_long;
- value1->data[0].v_long = value2->data[0].v_uint;
- value2->data[0].v_uint = tmp;
-}
+ /* need to fixup value type, or ensure that the array value is initialized at all */
+ if (!g_value_type_compatible (G_VALUE_TYPE (element), G_PARAM_SPEC_VALUE_TYPE (element_spec)))
+ {
+ if (G_VALUE_TYPE (element) != 0)
+ g_value_unset (element);
+ g_value_init (element, G_PARAM_SPEC_VALUE_TYPE (element_spec));
+ g_param_value_set_default (element_spec, element);
+ changed++;
+ }
+ /* validate array value against element_spec */
+ changed += g_param_value_validate (element_spec, element);
+ }
+ }
-static void
-value_exch_ulong_int (GValue *value1,
- GValue *value2)
-{
- gulong tmp = value1->data[0].v_ulong;
- value1->data[0].v_ulong = value2->data[0].v_int;
- value2->data[0].v_int = tmp;
+ return changed;
}
-static void
-value_exch_ulong_uint (GValue *value1,
- GValue *value2)
+static gint
+param_value_array_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
{
- gulong tmp = value1->data[0].v_ulong;
- value1->data[0].v_ulong = value2->data[0].v_uint;
- value2->data[0].v_uint = tmp;
-}
+ GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
+ GValueArray *value_array1 = value1->data[0].v_pointer;
+ GValueArray *value_array2 = value2->data[0].v_pointer;
-static void
-value_exch_float_int (GValue *value1,
- GValue *value2)
-{
- gfloat tmp = value1->data[0].v_float;
- value1->data[0].v_float = value2->data[0].v_int;
- value2->data[0].v_int = 0.5 + tmp;
-}
+ g_return_val_if_fail (value1->data[0].v_pointer != NULL, -1); /* paranoid */
+ g_return_val_if_fail (value2->data[0].v_pointer != NULL, 1); /* paranoid */
-static void
-value_exch_float_uint (GValue *value1,
- GValue *value2)
-{
- gfloat tmp = value1->data[0].v_float;
- value1->data[0].v_float = value2->data[0].v_uint;
- value2->data[0].v_uint = 0.5 + tmp;
-}
+ if (value_array1->n_values != value_array2->n_values)
+ return value_array1->n_values < value_array2->n_values ? -1 : 1;
+ else if (!aspec->element_spec)
+ {
+ /* we need an element specification for comparisons, so there's not much
+ * to compare here, try to at least provide stable lesser/greater result
+ */
+ return value_array1->n_values < value_array2->n_values ? -1 : value_array1->n_values > value_array2->n_values;
+ }
+ else /* value_array1->n_values == value_array2->n_values */
+ {
+ guint i;
-static void
-value_exch_float_long (GValue *value1,
- GValue *value2)
-{
- gfloat tmp = value1->data[0].v_float;
- value1->data[0].v_float = value2->data[0].v_long;
- value2->data[0].v_long = 0.5 + tmp;
+ for (i = 0; i < value_array1->n_values; i++)
+ {
+ GValue *element1 = value_array1->values + i;
+ GValue *element2 = value_array2->values + i;
+ gint cmp;
+
+ /* need corresponding element types, provide stable result otherwise */
+ if (G_VALUE_TYPE (element1) != G_VALUE_TYPE (element2))
+ return G_VALUE_TYPE (element1) < G_VALUE_TYPE (element2) ? -1 : 1;
+ cmp = g_param_values_cmp (aspec->element_spec, element1, element2);
+ if (cmp)
+ return cmp;
+ }
+ return 0;
+ }
}
static void
-value_exch_float_ulong (GValue *value1,
- GValue *value2)
+param_object_init (GParamSpec *pspec)
{
- gfloat tmp = value1->data[0].v_float;
- value1->data[0].v_float = value2->data[0].v_ulong;
- value2->data[0].v_ulong = 0.5 + tmp;
+ /* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */
}
static void
-value_exch_double_int (GValue *value1,
- GValue *value2)
+param_object_set_default (GParamSpec *pspec,
+ GValue *value)
{
- gdouble tmp = value1->data[0].v_double;
- value1->data[0].v_double = value2->data[0].v_int;
- value2->data[0].v_int = 0.5 + tmp;
+ value->data[0].v_pointer = NULL;
}
-static void
-value_exch_double_uint (GValue *value1,
- GValue *value2)
+static gboolean
+param_object_validate (GParamSpec *pspec,
+ GValue *value)
{
- gdouble tmp = value1->data[0].v_double;
- value1->data[0].v_double = value2->data[0].v_uint;
- value2->data[0].v_uint = 0.5 + tmp;
+ GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec);
+ GObject *object = value->data[0].v_pointer;
+ guint changed = 0;
+
+ if (object && !g_value_type_compatible (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec)))
+ {
+ g_object_unref (object);
+ value->data[0].v_pointer = NULL;
+ changed++;
+ }
+
+ return changed;
}
-static void
-value_exch_double_long (GValue *value1,
- GValue *value2)
+static gint
+param_object_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
{
- gdouble tmp = value1->data[0].v_double;
- value1->data[0].v_double = value2->data[0].v_long;
- value2->data[0].v_long = 0.5 + tmp;
-}
+ guint8 *p1 = value1->data[0].v_pointer;
+ guint8 *p2 = value2->data[0].v_pointer;
-static void
-value_exch_double_ulong (GValue *value1,
- GValue *value2)
-{
- gdouble tmp = value1->data[0].v_double;
- value1->data[0].v_double = value2->data[0].v_ulong;
- value2->data[0].v_ulong = 0.5 + tmp;
-}
+ /* not much to compare here, try to at least provide stable lesser/greater result */
-static void
-value_exch_double_float (GValue *value1,
- GValue *value2)
-{
- gdouble tmp = value1->data[0].v_double;
- value1->data[0].v_double = value2->data[0].v_float;
- value2->data[0].v_float = tmp;
+ return p1 < p2 ? -1 : p1 > p2;
}
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecChar), /* instance_size */
16, /* n_preallocs */
- param_spec_char_init, /* instance_init */
+ param_char_init, /* instance_init */
G_TYPE_CHAR, /* value_type */
NULL, /* finalize */
param_char_set_default, /* value_set_default */
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecUChar), /* instance_size */
16, /* n_preallocs */
- param_spec_uchar_init, /* instance_init */
+ param_uchar_init, /* instance_init */
G_TYPE_UCHAR, /* value_type */
NULL, /* finalize */
param_uchar_set_default, /* value_set_default */
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecInt), /* instance_size */
16, /* n_preallocs */
- param_spec_int_init, /* instance_init */
+ param_int_init, /* instance_init */
G_TYPE_INT, /* value_type */
NULL, /* finalize */
param_int_set_default, /* value_set_default */
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecUInt), /* instance_size */
16, /* n_preallocs */
- param_spec_uint_init, /* instance_init */
+ param_uint_init, /* instance_init */
G_TYPE_UINT, /* value_type */
NULL, /* finalize */
param_uint_set_default, /* value_set_default */
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecLong), /* instance_size */
16, /* n_preallocs */
- param_spec_long_init, /* instance_init */
+ param_long_init, /* instance_init */
G_TYPE_LONG, /* value_type */
NULL, /* finalize */
param_long_set_default, /* value_set_default */
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecULong), /* instance_size */
16, /* n_preallocs */
- param_spec_ulong_init, /* instance_init */
+ param_ulong_init, /* instance_init */
G_TYPE_ULONG, /* value_type */
NULL, /* finalize */
param_ulong_set_default, /* value_set_default */
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecEnum), /* instance_size */
16, /* n_preallocs */
- param_spec_enum_init, /* instance_init */
+ param_enum_init, /* instance_init */
G_TYPE_ENUM, /* value_type */
- param_spec_enum_finalize, /* finalize */
+ param_enum_finalize, /* finalize */
param_enum_set_default, /* value_set_default */
param_enum_validate, /* value_validate */
param_long_values_cmp, /* values_cmp */
*/
{
static const GParamSpecTypeInfo pspec_info = {
- sizeof (GParamSpecFlags), /* instance_size */
- 16, /* n_preallocs */
- param_spec_flags_init, /* instance_init */
+ sizeof (GParamSpecFlags), /* instance_size */
+ 16, /* n_preallocs */
+ param_flags_init, /* instance_init */
G_TYPE_FLAGS, /* value_type */
- param_spec_flags_finalize,/* finalize */
+ param_flags_finalize, /* finalize */
param_flags_set_default, /* value_set_default */
param_flags_validate, /* value_validate */
param_ulong_values_cmp, /* values_cmp */
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecFloat), /* instance_size */
16, /* n_preallocs */
- param_spec_float_init, /* instance_init */
+ param_float_init, /* instance_init */
G_TYPE_FLOAT, /* value_type */
NULL, /* finalize */
param_float_set_default, /* value_set_default */
*/
{
static const GParamSpecTypeInfo pspec_info = {
- sizeof (GParamSpecDouble), /* instance_size */
- 16, /* n_preallocs */
- param_spec_double_init, /* instance_init */
- G_TYPE_DOUBLE, /* value_type */
- NULL, /* finalize */
- param_double_set_default, /* value_set_default */
- param_double_validate, /* value_validate */
- param_double_values_cmp, /* values_cmp */
+ sizeof (GParamSpecDouble), /* instance_size */
+ 16, /* n_preallocs */
+ param_double_init, /* instance_init */
+ G_TYPE_DOUBLE, /* value_type */
+ NULL, /* finalize */
+ param_double_set_default, /* value_set_default */
+ param_double_validate, /* value_validate */
+ param_double_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamDouble", &pspec_info);
g_assert (type == G_TYPE_PARAM_DOUBLE);
*/
{
static const GParamSpecTypeInfo pspec_info = {
- sizeof (GParamSpecString), /* instance_size */
- 16, /* n_preallocs */
- param_spec_string_init, /* instance_init */
- G_TYPE_STRING, /* value_type */
- param_spec_string_finalize, /* finalize */
- param_string_set_default, /* value_set_default */
- param_string_validate, /* value_validate */
- param_string_values_cmp, /* values_cmp */
+ sizeof (GParamSpecString), /* instance_size */
+ 16, /* n_preallocs */
+ param_string_init, /* instance_init */
+ G_TYPE_STRING, /* value_type */
+ param_string_finalize, /* finalize */
+ param_string_set_default, /* value_set_default */
+ param_string_validate, /* value_validate */
+ param_string_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamString", &pspec_info);
g_assert (type == G_TYPE_PARAM_STRING);
*/
{
static const GParamSpecTypeInfo pspec_info = {
- sizeof (GParamSpecParam), /* instance_size */
- 16, /* n_preallocs */
- param_spec_param_init, /* instance_init */
- G_TYPE_PARAM, /* value_type */
- NULL, /* finalize */
- param_param_set_default, /* value_set_default */
- param_param_validate, /* value_validate */
- param_pointer_values_cmp, /* values_cmp */
+ sizeof (GParamSpecParam), /* instance_size */
+ 16, /* n_preallocs */
+ param_param_init, /* instance_init */
+ G_TYPE_PARAM, /* value_type */
+ NULL, /* finalize */
+ param_param_set_default, /* value_set_default */
+ param_param_validate, /* value_validate */
+ param_pointer_values_cmp, /* values_cmp */
};
type = g_param_type_register_static ("GParamParam", &pspec_info);
g_assert (type == G_TYPE_PARAM_PARAM);
}
+ /* G_TYPE_PARAM_BOXED
+ */
+ {
+ static const GParamSpecTypeInfo pspec_info = {
+ sizeof (GParamSpecBoxed), /* instance_size */
+ 4, /* n_preallocs */
+ param_boxed_init, /* instance_init */
+ G_TYPE_BOXED, /* value_type */
+ NULL, /* finalize */
+ param_boxed_set_default, /* value_set_default */
+ param_boxed_validate, /* value_validate */
+ param_boxed_values_cmp, /* values_cmp */
+ };
+ type = g_param_type_register_static ("GParamBoxed", &pspec_info);
+ g_assert (type == G_TYPE_PARAM_BOXED);
+ }
+
/* G_TYPE_PARAM_POINTER
*/
{
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecPointer), /* instance_size */
0, /* n_preallocs */
- param_spec_pointer_init, /* instance_init */
+ param_pointer_init, /* instance_init */
G_TYPE_POINTER, /* value_type */
NULL, /* finalize */
param_pointer_set_default, /* value_set_default */
g_assert (type == G_TYPE_PARAM_POINTER);
}
- /* G_TYPE_PARAM_CCALLBACK
+ /* G_TYPE_PARAM_VALUE_ARRAY
*/
{
static const GParamSpecTypeInfo pspec_info = {
- sizeof (GParamSpecCCallback), /* instance_size */
- 0, /* n_preallocs */
- param_spec_ccallback_init, /* instance_init */
- G_TYPE_CCALLBACK, /* value_type */
- NULL, /* finalize */
- param_ccallback_set_default, /* value_set_default */
- param_ccallback_validate, /* value_validate */
- param_ccallback_values_cmp, /* values_cmp */
+ sizeof (GParamSpecValueArray), /* instance_size */
+ 0, /* n_preallocs */
+ param_value_array_init, /* instance_init */
+ G_TYPE_VALUE_ARRAY, /* value_type */
+ param_value_array_finalize, /* finalize */
+ param_value_array_set_default, /* value_set_default */
+ param_value_array_validate, /* value_validate */
+ param_value_array_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamCCallback", &pspec_info);
- g_assert (type == G_TYPE_PARAM_CCALLBACK);
+ type = g_param_type_register_static ("GParamValueArray", &pspec_info);
+ g_assert (type == G_TYPE_PARAM_VALUE_ARRAY);
}
-
- /* G_TYPE_PARAM_BOXED
+
+ /* G_TYPE_PARAM_CLOSURE
*/
{
static const GParamSpecTypeInfo pspec_info = {
- sizeof (GParamSpecBoxed), /* instance_size */
- 4, /* n_preallocs */
- param_spec_boxed_init, /* instance_init */
- G_TYPE_BOXED, /* value_type */
- NULL, /* finalize */
- param_boxed_set_default, /* value_set_default */
- param_boxed_validate, /* value_validate */
- param_boxed_values_cmp, /* values_cmp */
+ sizeof (GParamSpecClosure), /* instance_size */
+ 0, /* n_preallocs */
+ param_closure_init, /* instance_init */
+ G_TYPE_CLOSURE, /* value_type */
+ NULL, /* finalize */
+ param_closure_set_default, /* value_set_default */
+ param_closure_validate, /* value_validate */
+ param_closure_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamBoxed", &pspec_info);
- g_assert (type == G_TYPE_PARAM_BOXED);
+ type = g_param_type_register_static ("GParamClosure", &pspec_info);
+ g_assert (type == G_TYPE_PARAM_CLOSURE);
}
-
+
/* G_TYPE_PARAM_OBJECT
*/
{
static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecObject), /* instance_size */
16, /* n_preallocs */
- param_spec_object_init, /* instance_init */
+ param_object_init, /* instance_init */
G_TYPE_OBJECT, /* value_type */
NULL, /* finalize */
param_object_set_default, /* value_set_default */
type = g_param_type_register_static ("GParamObject", &pspec_info);
g_assert (type == G_TYPE_PARAM_OBJECT);
}
-
- /* G_TYPE_PARAM_INTERFACE
- */
- {
- static const GParamSpecTypeInfo pspec_info = {
- sizeof (GParamSpecInterface), /* instance_size */
- 4, /* n_preallocs */
- param_spec_interface_init, /* instance_init */
- G_TYPE_INTERFACE, /* value_type */
- NULL, /* finalize */
- param_interface_set_default, /* value_set_default */
- param_interface_validate, /* value_validate */
- param_interface_values_cmp, /* values_cmp */
- };
- type = g_param_type_register_static ("GParamInterface", &pspec_info);
- g_assert (type == G_TYPE_PARAM_INTERFACE);
- }
-
- g_value_register_exchange_func (G_TYPE_CHAR, G_TYPE_UCHAR, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_CHAR, G_TYPE_BOOLEAN, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_CHAR, G_TYPE_INT, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_CHAR, G_TYPE_UINT, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_CHAR, G_TYPE_ENUM, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_CHAR, G_TYPE_FLAGS, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_UCHAR, G_TYPE_BOOLEAN, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_UCHAR, G_TYPE_INT, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_UCHAR, G_TYPE_UINT, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_UCHAR, G_TYPE_ENUM, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_UCHAR, G_TYPE_FLAGS, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_BOOLEAN, G_TYPE_INT, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_BOOLEAN, G_TYPE_UINT, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_BOOLEAN, G_TYPE_ENUM, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_BOOLEAN, G_TYPE_FLAGS, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_INT, G_TYPE_UINT, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_INT, G_TYPE_ENUM, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_INT, G_TYPE_FLAGS, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_UINT, G_TYPE_ENUM, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_UINT, G_TYPE_FLAGS, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_LONG, G_TYPE_CHAR, value_exch_long_int);
- g_value_register_exchange_func (G_TYPE_LONG, G_TYPE_UCHAR, value_exch_long_uint);
- g_value_register_exchange_func (G_TYPE_LONG, G_TYPE_BOOLEAN, value_exch_long_int);
- g_value_register_exchange_func (G_TYPE_LONG, G_TYPE_INT, value_exch_long_int);
- g_value_register_exchange_func (G_TYPE_LONG, G_TYPE_UINT, value_exch_long_uint);
- g_value_register_exchange_func (G_TYPE_LONG, G_TYPE_ULONG, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_LONG, G_TYPE_ENUM, value_exch_long_int);
- g_value_register_exchange_func (G_TYPE_LONG, G_TYPE_FLAGS, value_exch_long_uint);
- g_value_register_exchange_func (G_TYPE_ULONG, G_TYPE_CHAR, value_exch_ulong_int);
- g_value_register_exchange_func (G_TYPE_ULONG, G_TYPE_UCHAR, value_exch_ulong_uint);
- g_value_register_exchange_func (G_TYPE_ULONG, G_TYPE_BOOLEAN, value_exch_ulong_int);
- g_value_register_exchange_func (G_TYPE_ULONG, G_TYPE_INT, value_exch_ulong_int);
- g_value_register_exchange_func (G_TYPE_ULONG, G_TYPE_UINT, value_exch_ulong_uint);
- g_value_register_exchange_func (G_TYPE_ULONG, G_TYPE_ENUM, value_exch_ulong_int);
- g_value_register_exchange_func (G_TYPE_ULONG, G_TYPE_FLAGS, value_exch_ulong_uint);
- g_value_register_exchange_func (G_TYPE_ENUM, G_TYPE_FLAGS, value_exch_memcpy);
- g_value_register_exchange_func (G_TYPE_FLOAT, G_TYPE_CHAR, value_exch_float_int);
- g_value_register_exchange_func (G_TYPE_FLOAT, G_TYPE_UCHAR, value_exch_float_uint);
- g_value_register_exchange_func (G_TYPE_FLOAT, G_TYPE_BOOLEAN, value_exch_float_int);
- g_value_register_exchange_func (G_TYPE_FLOAT, G_TYPE_INT, value_exch_float_int);
- g_value_register_exchange_func (G_TYPE_FLOAT, G_TYPE_UINT, value_exch_float_uint);
- g_value_register_exchange_func (G_TYPE_FLOAT, G_TYPE_LONG, value_exch_float_long);
- g_value_register_exchange_func (G_TYPE_FLOAT, G_TYPE_ULONG, value_exch_float_ulong);
- g_value_register_exchange_func (G_TYPE_FLOAT, G_TYPE_ENUM, value_exch_float_int);
- g_value_register_exchange_func (G_TYPE_FLOAT, G_TYPE_FLAGS, value_exch_float_uint);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_CHAR, value_exch_double_int);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_UCHAR, value_exch_double_uint);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_BOOLEAN, value_exch_double_int);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_INT, value_exch_double_int);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_UINT, value_exch_double_uint);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_LONG, value_exch_double_long);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_ULONG, value_exch_double_ulong);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_ENUM, value_exch_double_int);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_FLAGS, value_exch_double_uint);
- g_value_register_exchange_func (G_TYPE_DOUBLE, G_TYPE_FLOAT, value_exch_double_float);
}
return G_PARAM_SPEC (pspec);
}
+GParamSpec*
+g_param_spec_boxed (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GType boxed_type,
+ GParamFlags flags)
+{
+ GParamSpecBoxed *bspec;
+
+ g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
+ g_return_val_if_fail (G_TYPE_IS_DERIVED (boxed_type), NULL);
+
+ bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED,
+ name,
+ nick,
+ blurb,
+ flags);
+ G_PARAM_SPEC (bspec)->value_type = boxed_type;
+
+ return G_PARAM_SPEC (bspec);
+}
+
GParamSpec*
g_param_spec_pointer (const gchar *name,
const gchar *nick,
}
GParamSpec*
-g_param_spec_ccallback (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GParamFlags flags)
+g_param_spec_value_array (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GParamSpec *element_spec,
+ GParamFlags flags)
{
- GParamSpecCCallback *cspec;
+ GParamSpecValueArray *aspec;
+
+ if (element_spec)
+ g_return_val_if_fail (G_IS_PARAM_SPEC (element_spec), NULL);
- cspec = g_param_spec_internal (G_TYPE_PARAM_CCALLBACK,
+ aspec = g_param_spec_internal (G_TYPE_PARAM_VALUE_ARRAY,
name,
nick,
blurb,
flags);
- return G_PARAM_SPEC (cspec);
+ if (element_spec)
+ {
+ aspec->element_spec = g_param_spec_ref (element_spec);
+ g_param_spec_sink (element_spec);
+ }
+
+ return G_PARAM_SPEC (aspec);
}
GParamSpec*
-g_param_spec_boxed (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GType boxed_type,
- GParamFlags flags)
+g_param_spec_closure (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GParamFlags flags)
{
- GParamSpecBoxed *bspec;
-
- g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
- g_return_val_if_fail (G_TYPE_IS_DERIVED (boxed_type), NULL);
+ GParamSpecClosure *cspec;
- bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED,
+ cspec = g_param_spec_internal (G_TYPE_PARAM_CLOSURE,
name,
nick,
blurb,
flags);
- G_PARAM_SPEC (bspec)->value_type = boxed_type;
-
- return G_PARAM_SPEC (bspec);
+ return G_PARAM_SPEC (cspec);
}
GParamSpec*
return G_PARAM_SPEC (ospec);
}
-
-GParamSpec*
-g_param_spec_interface (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GType interface_type,
- GParamFlags flags)
-{
- GParamSpecInterface *ispec;
-
- g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface_type), NULL);
-
- ispec = g_param_spec_internal (G_TYPE_PARAM_INTERFACE,
- name,
- nick,
- blurb,
- flags);
- G_PARAM_SPEC (ispec)->value_type = interface_type;
-
- return G_PARAM_SPEC (ispec);
-}
-
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* --- type macros --- */
-#define G_IS_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_CHAR))
-#define G_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_CHAR, GParamSpecChar))
-#define G_IS_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UCHAR))
-#define G_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UCHAR, GParamSpecUChar))
-#define G_IS_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOOLEAN))
-#define G_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOOLEAN, GParamSpecBoolean))
-#define G_IS_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT))
-#define G_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT, GParamSpecInt))
-#define G_IS_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT))
-#define G_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT, GParamSpecUInt))
-#define G_IS_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_LONG))
-#define G_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_LONG, GParamSpecLong))
-#define G_IS_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ULONG))
-#define G_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ULONG, GParamSpecULong))
-#define G_IS_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM))
-#define G_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ENUM, GParamSpecEnum))
-#define G_IS_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLAGS))
-#define G_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLAGS, GParamSpecFlags))
-#define G_IS_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLOAT))
-#define G_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLOAT, GParamSpecFloat))
-#define G_IS_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_DOUBLE))
-#define G_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_DOUBLE, GParamSpecDouble))
-#define G_IS_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_STRING))
-#define G_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_STRING, GParamSpecString))
-#define G_IS_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_PARAM))
-#define G_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_PARAM, GParamSpecParam))
-#define G_IS_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_POINTER))
-#define G_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_POINTER, GParamSpecPointer))
-#define G_IS_PARAM_SPEC_CCALLBACK(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_CCALLBACK))
-#define G_PARAM_SPEC_CCALLBACK(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_CCALLBACK, GParamSpecCCallback))
-#define G_IS_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOXED))
-#define G_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOXED, GParamSpecBoxed))
-#define G_IS_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OBJECT))
-#define G_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OBJECT, GParamSpecObject))
-#define G_IS_PARAM_SPEC_INTERFACE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INTERFACE))
-#define G_PARAM_SPEC_INTERFACE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INTERFACE, GParamSpecInterface))
+#define G_IS_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_CHAR))
+#define G_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_CHAR, GParamSpecChar))
+#define G_IS_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UCHAR))
+#define G_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UCHAR, GParamSpecUChar))
+#define G_IS_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOOLEAN))
+#define G_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOOLEAN, GParamSpecBoolean))
+#define G_IS_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT))
+#define G_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT, GParamSpecInt))
+#define G_IS_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT))
+#define G_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT, GParamSpecUInt))
+#define G_IS_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_LONG))
+#define G_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_LONG, GParamSpecLong))
+#define G_IS_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ULONG))
+#define G_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ULONG, GParamSpecULong))
+#define G_IS_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM))
+#define G_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ENUM, GParamSpecEnum))
+#define G_IS_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLAGS))
+#define G_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLAGS, GParamSpecFlags))
+#define G_IS_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLOAT))
+#define G_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLOAT, GParamSpecFloat))
+#define G_IS_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_DOUBLE))
+#define G_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_DOUBLE, GParamSpecDouble))
+#define G_IS_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_STRING))
+#define G_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_STRING, GParamSpecString))
+#define G_IS_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_PARAM))
+#define G_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_PARAM, GParamSpecParam))
+#define G_IS_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOXED))
+#define G_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOXED, GParamSpecBoxed))
+#define G_IS_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_POINTER))
+#define G_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_POINTER, GParamSpecPointer))
+#define G_IS_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_VALUE_ARRAY))
+#define G_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_VALUE_ARRAY, GParamSpecValueArray))
+#define G_IS_PARAM_SPEC_CLOSURE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_CLOSURE))
+#define G_PARAM_SPEC_CLOSURE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_CLOSURE, GParamSpecClosure))
+#define G_IS_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OBJECT))
+#define G_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OBJECT, GParamSpecObject))
/* --- typedefs & structures --- */
-typedef struct _GParamSpecChar GParamSpecChar;
-typedef struct _GParamSpecUChar GParamSpecUChar;
-typedef struct _GParamSpecBoolean GParamSpecBoolean;
-typedef struct _GParamSpecInt GParamSpecInt;
-typedef struct _GParamSpecUInt GParamSpecUInt;
-typedef struct _GParamSpecLong GParamSpecLong;
-typedef struct _GParamSpecULong GParamSpecULong;
-typedef struct _GParamSpecEnum GParamSpecEnum;
-typedef struct _GParamSpecFlags GParamSpecFlags;
-typedef struct _GParamSpecFloat GParamSpecFloat;
-typedef struct _GParamSpecDouble GParamSpecDouble;
-typedef struct _GParamSpecString GParamSpecString;
-typedef struct _GParamSpecParam GParamSpecParam;
-typedef struct _GParamSpecPointer GParamSpecPointer;
-typedef struct _GParamSpecCCallback GParamSpecCCallback;
-typedef struct _GParamSpecBoxed GParamSpecBoxed;
-typedef struct _GParamSpecObject GParamSpecObject;
-typedef struct _GParamSpecInterface GParamSpecInterface;
+typedef struct _GParamSpecChar GParamSpecChar;
+typedef struct _GParamSpecUChar GParamSpecUChar;
+typedef struct _GParamSpecBoolean GParamSpecBoolean;
+typedef struct _GParamSpecInt GParamSpecInt;
+typedef struct _GParamSpecUInt GParamSpecUInt;
+typedef struct _GParamSpecLong GParamSpecLong;
+typedef struct _GParamSpecULong GParamSpecULong;
+typedef struct _GParamSpecEnum GParamSpecEnum;
+typedef struct _GParamSpecFlags GParamSpecFlags;
+typedef struct _GParamSpecFloat GParamSpecFloat;
+typedef struct _GParamSpecDouble GParamSpecDouble;
+typedef struct _GParamSpecString GParamSpecString;
+typedef struct _GParamSpecParam GParamSpecParam;
+typedef struct _GParamSpecBoxed GParamSpecBoxed;
+typedef struct _GParamSpecPointer GParamSpecPointer;
+typedef struct _GParamSpecValueArray GParamSpecValueArray;
+typedef struct _GParamSpecClosure GParamSpecClosure;
+typedef struct _GParamSpecObject GParamSpecObject;
struct _GParamSpecChar
{
GParamSpec parent_instance;
{
GParamSpec parent_instance;
};
-struct _GParamSpecPointer
+struct _GParamSpecBoxed
{
GParamSpec parent_instance;
};
-struct _GParamSpecCCallback
+struct _GParamSpecPointer
{
GParamSpec parent_instance;
};
-struct _GParamSpecBoxed
+struct _GParamSpecValueArray
{
GParamSpec parent_instance;
+ GParamSpec *element_spec;
+ guint fixed_n_elements;
};
-struct _GParamSpecObject
+struct _GParamSpecClosure
{
GParamSpec parent_instance;
};
-struct _GParamSpecInterface
+struct _GParamSpecObject
{
GParamSpec parent_instance;
};
/* --- GParamSpec prototypes --- */
-GParamSpec* g_param_spec_char (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- gint8 minimum,
- gint8 maximum,
- gint8 default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_uchar (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- guint8 minimum,
- guint8 maximum,
- guint8 default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_boolean (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- gboolean default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_int (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- gint minimum,
- gint maximum,
- gint default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_uint (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- guint minimum,
- guint maximum,
- guint default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_long (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- glong minimum,
- glong maximum,
- glong default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_ulong (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- gulong minimum,
- gulong maximum,
- gulong default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_enum (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GType enum_type,
- gint default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_flags (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GType flags_type,
- guint default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_float (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- gfloat minimum,
- gfloat maximum,
- gfloat default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_double (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- gdouble minimum,
- gdouble maximum,
- gdouble default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_string (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- const gchar *default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_string_c (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- const gchar *default_value,
- GParamFlags flags);
-GParamSpec* g_param_spec_param (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GType param_type,
- GParamFlags flags);
-GParamSpec* g_param_spec_pointer (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GParamFlags flags);
-GParamSpec* g_param_spec_ccallback (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GParamFlags flags);
-GParamSpec* g_param_spec_boxed (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GType boxed_type,
- GParamFlags flags);
-GParamSpec* g_param_spec_object (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GType object_type,
- GParamFlags flags);
-GParamSpec* g_param_spec_interface (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GType object_type,
- GParamFlags flags);
+GParamSpec* g_param_spec_char (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ gint8 minimum,
+ gint8 maximum,
+ gint8 default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_uchar (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ guint8 minimum,
+ guint8 maximum,
+ guint8 default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_boolean (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ gboolean default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_int (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ gint minimum,
+ gint maximum,
+ gint default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_uint (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ guint minimum,
+ guint maximum,
+ guint default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_long (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ glong minimum,
+ glong maximum,
+ glong default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_ulong (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ gulong minimum,
+ gulong maximum,
+ gulong default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_enum (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GType enum_type,
+ gint default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_flags (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GType flags_type,
+ guint default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_float (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ gfloat minimum,
+ gfloat maximum,
+ gfloat default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_double (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ gdouble minimum,
+ gdouble maximum,
+ gdouble default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_string (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ const gchar *default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_string_c (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ const gchar *default_value,
+ GParamFlags flags);
+GParamSpec* g_param_spec_param (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GType param_type,
+ GParamFlags flags);
+GParamSpec* g_param_spec_boxed (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GType boxed_type,
+ GParamFlags flags);
+GParamSpec* g_param_spec_pointer (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GParamFlags flags);
+GParamSpec* g_param_spec_value_array (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GParamSpec *element_spec,
+ GParamFlags flags);
+GParamSpec* g_param_spec_closure (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GParamFlags flags);
+GParamSpec* g_param_spec_object (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GType object_type,
+ GParamFlags flags);
#ifdef __cplusplus
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 2000-2001 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
GQuark *detail_p,
gboolean force_detail_quark)
{
+ SignalNode *node;
GQuark detail = 0;
guint signal_id;
G_LOCK (g_signal_mutex);
signal_id = signal_parse_name (detailed_signal, itype, &detail, force_detail_quark);
G_UNLOCK (g_signal_mutex);
-
- if (signal_id)
- {
- if (signal_id_p)
- *signal_id_p = signal_id;
- if (detail_p)
- *detail_p = detail;
-
- return TRUE;
- }
- else
+
+ node = signal_id ? LOOKUP_SIGNAL_NODE (signal_id) : NULL;
+ if (!node || node->destroyed ||
+ (detail && !(node->flags & G_SIGNAL_DETAILED)))
return FALSE;
+
+ if (signal_id_p)
+ *signal_id_p = signal_id;
+ if (detail_p)
+ *detail_p = detail;
+
+ return TRUE;
}
guint
return 0;
}
for (i = 0; i < n_params; i++)
- if (!G_TYPE_IS_VALUE (param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE) ||
- (param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE) == G_TYPE_ENUM ||
- (param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE) == G_TYPE_FLAGS) /* FIXME: kludge */
+ if (!G_TYPE_IS_VALUE (param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE))
{
g_warning (G_STRLOC ": parameter %d of type `%s' for signal \"%s::%s\" is not a value type",
i + 1, g_type_name (param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE), g_type_name (itype), name);
guint i;
g_return_if_fail (instance_and_params != NULL);
- instance = g_value_get_as_pointer (instance_and_params);
+ instance = g_value_peek_pointer (instance_and_params);
g_return_if_fail (G_TYPE_CHECK_INSTANCE (instance));
g_return_if_fail (signal_id > 0);
return;
}
for (i = 0; i < node->n_params; i++)
- if (!G_VALUE_HOLDS (param_values + i, node->param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE))
+ if (!G_TYPE_CHECK_VALUE_TYPE (param_values + i, node->param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE))
{
g_critical ("%s: value for `%s' parameter %u for signal \"%s\" is of type `%s'",
G_STRLOC,
G_UNLOCK (g_signal_mutex);
return;
}
- else if (!node->accumulator && !G_VALUE_HOLDS (return_value, node->return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE))
+ else if (!node->accumulator && !G_TYPE_CHECK_VALUE_TYPE (return_value, node->return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE))
{
g_critical ("%s: return value `%s' for signal \"%s\" is of type `%s'",
G_STRLOC,
/* --- compile standard marshallers --- */
#include "gvaluetypes.h"
+#include "gobject.h"
+#include "genums.h"
+#include "gboxed.h"
#include "gmarshal.c"
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 2000-2001 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
else \
g_error ("%s()%s`%s'", _fname, _action, _tname); \
}G_STMT_END
+#define g_return_val_if_uninitialized(condition, init_function, return_value) G_STMT_START{ \
+ if (!(condition)) \
+ { \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
+ "%s: initialization assertion failed, use %s() prior to this function", \
+ G_STRLOC, G_STRINGIFY (init_function)); \
+ return (return_value); \
+ } \
+}G_STMT_END
+
#ifdef G_ENABLE_DEBUG
#define DEBUG_CODE(debug_type, code_block) G_STMT_START { \
if (_g_type_debug_flags & G_TYPE_DEBUG_ ## debug_type) \
G_TYPE_FLAG_INSTANTIATABLE | \
G_TYPE_FLAG_DERIVABLE | \
G_TYPE_FLAG_DEEP_DERIVABLE)
-#define TYPE_FLAG_MASK (G_TYPE_FLAG_ABSTRACT)
+#define TYPE_FLAG_MASK (G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT)
/* --- typedefs --- */
}
}
if (value_table)
- vtable_size = sizeof (GTypeValueTable);
+ {
+ /* need to setup vtable_size since we have to allocate it with data in one chunk */
+ vtable_size = sizeof (GTypeValueTable);
+ if (value_table->collect_format)
+ vtable_size += strlen (value_table->collect_format);
+ if (value_table->lcopy_format)
+ vtable_size += strlen (value_table->lcopy_format);
+ vtable_size += 2;
+ }
if (node->is_instantiatable) /* carefull, is_instantiatable is also is_classed */
{
if (vtable_size)
{
+ gchar *p;
+
+ /* we allocate the vtable and its strings together with the type data, so
+ * children can take over their parent's vtable pointer, and we don't
+ * need to worry freeing it or not when the child data is destroyed
+ */
*vtable = *value_table;
- vtable->collect_format = g_strdup (value_table->collect_format ? value_table->collect_format : "");
- vtable->lcopy_format = g_strdup (value_table->lcopy_format ? value_table->lcopy_format : "");
+ p = G_STRUCT_MEMBER_P (vtable, sizeof (*vtable));
+ p[0] = 0;
+ vtable->collect_format = p;
+ if (value_table->collect_format)
+ {
+ strcat (p, value_table->collect_format);
+ p += strlen (value_table->collect_format);
+ }
+ p++;
+ p[0] = 0;
+ vtable->lcopy_format = p;
+ if (value_table->lcopy_format)
+ strcat (p, value_table->lcopy_format);
}
node->data->common.value_table = vtable;
g_assert (cdata->class && cdata->common.ref_count == 0);
- g_message ("finalizing %sClass `%s'",
- type_descriptive_name_U (G_TYPE_FUNDAMENTAL (NODE_TYPE (node))),
- type_descriptive_name_U (NODE_TYPE (node)));
-
if (cdata->class_finalize)
cdata->class_finalize (class, (gpointer) cdata->class_data);
else
node->data = NULL;
- if (tdata->common.value_table)
- {
- g_free (tdata->common.value_table->collect_format);
- g_free (tdata->common.value_table->lcopy_format);
- }
+ /* freeing tdata->common.value_table and its contents is taking care of
+ * by allocating it in one chunk with tdata
+ */
g_free (tdata);
if (ptype)
GTypeFundamentalInfo *node_finfo;
TypeNode *node;
+ g_return_val_if_uninitialized (static_last_fundamental_id, g_type_init, 0);
g_return_val_if_fail (type_id > 0, 0);
g_return_val_if_fail (type_name != NULL, 0);
g_return_val_if_fail (info != NULL, 0);
TypeNode *pnode, *node;
GType type = 0;
+ g_return_val_if_uninitialized (static_last_fundamental_id, g_type_init, 0);
g_return_val_if_fail (parent_type > 0, 0);
g_return_val_if_fail (type_name != NULL, 0);
g_return_val_if_fail (info != NULL, 0);
TypeNode *pnode, *node;
GType type;
+ g_return_val_if_uninitialized (static_last_fundamental_id, g_type_init, 0);
g_return_val_if_fail (parent_type > 0, 0);
g_return_val_if_fail (type_name != NULL, 0);
g_return_val_if_fail (plugin != NULL, 0);
return vtable;
}
-GTypeValueTable*
-g_type_value_table_peek (GType type)
-{
- TypeNode *node;
- GTypeValueTable *vtable = NULL;
-
- G_READ_LOCK (&type_rw_lock);
- node = lookup_type_node_L (type);
- if (node && node->data && node->data->common.ref_count > 0 &&
- node->data->common.value_table->value_init)
- vtable = node->data->common.value_table;
- G_READ_UNLOCK (&type_rw_lock);
-
- return vtable;
-}
-
G_CONST_RETURN gchar*
g_type_name (GType type)
{
TypeNode *node;
+ g_return_val_if_uninitialized (static_last_fundamental_id, g_type_init, NULL);
+
G_READ_LOCK (&type_rw_lock);
node = lookup_type_node_L (type);
G_READ_UNLOCK (&type_rw_lock);
g_return_if_fail ((flags & ~TYPE_FLAG_MASK) == 0);
g_return_if_fail (node != NULL);
- if ((flags & G_TYPE_FLAG_ABSTRACT) && node->is_classed && node->data && node->data->class.class)
+ if ((flags & TYPE_FLAG_MASK) && node->is_classed && node->data && node->data->class.class)
g_warning ("tagging type `%s' as abstract after class initialization", NODE_NAME (node));
dflags = GPOINTER_TO_UINT (type_get_qdata_L (node, static_quark_type_flags));
dflags |= flags;
g_type_is_a (type_class->g_type, is_a_type));
}
-gboolean
-g_type_value_is_a (GValue *value,
- GType type)
-{
- TypeNode *node;
-
- if (!value)
- return FALSE;
-
- G_READ_LOCK (&type_rw_lock);
- node = lookup_type_node_L (value->g_type);
-#if 0
- if (!G_TYPE_IS_FUNDAMENTAL (value->g_type) && !node || !node->data)
- node = lookup_type_node_L (G_TYPE_FUNDAMENTAL (value->g_type));
-#endif
- if (!node || !node->data || node->data->common.ref_count < 1 ||
- !node->data->common.value_table->value_init)
- {
- G_READ_UNLOCK (&type_rw_lock);
-
- return FALSE;
- }
- G_READ_UNLOCK (&type_rw_lock);
-
- return g_type_is_a (value->g_type, type);
-}
-
-gboolean
-g_type_check_value (GValue *value)
-{
- return value && g_type_value_is_a (value, value->g_type);
-}
-
GTypeInstance*
g_type_check_instance_cast (GTypeInstance *type_instance,
GType iface_type)
return TRUE;
}
+static inline gboolean
+type_check_is_value_type_U (GType type)
+{
+ GTypeFlags tflags = G_TYPE_FLAG_VALUE_ABSTRACT;
+ TypeNode *node;
+
+ G_READ_LOCK (&type_rw_lock);
+ node = lookup_type_node_L (type);
+ if (node && node->data && node->data->common.ref_count > 0 &&
+ node->data->common.value_table->value_init)
+ tflags = GPOINTER_TO_UINT (type_get_qdata_L (node, static_quark_type_flags));
+ G_READ_UNLOCK (&type_rw_lock);
+
+ return !(tflags & G_TYPE_FLAG_VALUE_ABSTRACT);
+}
+
+gboolean
+g_type_check_is_value_type (GType type)
+{
+ return type_check_is_value_type_U (type);
+}
+
+gboolean
+g_type_check_value (GValue *value)
+{
+ return value && type_check_is_value_type_U (value->g_type);
+}
+
+gboolean
+g_type_check_value_holds (GValue *value,
+ GType type)
+{
+ return value && type_check_is_value_type_U (value->g_type) && g_type_is_a (value->g_type, type);
+}
+
+GTypeValueTable*
+g_type_value_table_peek (GType type)
+{
+ TypeNode *node;
+ GTypeValueTable *vtable = NULL;
+
+ G_READ_LOCK (&type_rw_lock);
+ node = lookup_type_node_L (type);
+ if (node && node->data && node->data->common.ref_count > 0 &&
+ node->data->common.value_table->value_init)
+ vtable = node->data->common.value_table;
+ G_READ_UNLOCK (&type_rw_lock);
+
+ return vtable;
+}
+
/* --- foreign prototypes --- */
extern void g_value_types_init (void); /* sync with gvaluetypes.c */
extern void g_boxed_type_init (void); /* sync with gboxed.c */
extern void g_object_type_init (void); /* sync with gobject.c */
extern void g_param_spec_types_init (void); /* sync with gparamspecs.c */
+extern void g_value_transforms_init (void); /* sync with gvaluetransform.c */
extern void g_signal_init (void); /* sync with gsignal.c */
*/
g_enum_types_init ();
- /* G_TYPE_PARAM
+ /* G_TYPE_BOXED
*/
- g_param_type_init ();
+ g_boxed_type_init ();
/* G_TYPE_PARAM
*/
- g_boxed_type_init ();
+ g_param_type_init ();
/* G_TYPE_OBJECT
*/
*/
g_param_spec_types_init ();
+ /* Value Transformations
+ */
+ g_value_transforms_init ();
+
/* Signal system
*/
g_signal_init ();
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
G_TYPE_FLOAT,
G_TYPE_DOUBLE,
G_TYPE_STRING,
- G_TYPE_PARAM,
- G_TYPE_BOXED,
G_TYPE_POINTER,
- G_TYPE_CCALLBACK,
+ G_TYPE_BOXED,
+ G_TYPE_PARAM,
G_TYPE_OBJECT,
- /* the following reserved ids should vanish soon */
- G_TYPE_GTK_SIGNAL,
-
/* reserved fundamental type ids,
* mail gtk-devel-list@redhat.com for reservations
*/
- G_TYPE_BSE_PROCEDURE,
- G_TYPE_BSE_TIME,
- G_TYPE_BSE_NOTE,
- G_TYPE_BSE_DOTS,
- G_TYPE_GLE_GOBJECT,
-
- G_TYPE_LAST_RESERVED_FUNDAMENTAL,
+ G_TYPE_RESERVED_BSE_FIRST,
+ G_TYPE_RESERVED_BSE_LAST = G_TYPE_RESERVED_BSE_FIRST + 15,
+ G_TYPE_RESERVED_LAST_FUNDAMENTAL,
/* derived type ids */
- G_TYPE_PARAM_CHAR = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 1),
- G_TYPE_PARAM_UCHAR = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 2),
- G_TYPE_PARAM_BOOLEAN = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 3),
- G_TYPE_PARAM_INT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 4),
- G_TYPE_PARAM_UINT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 5),
- G_TYPE_PARAM_LONG = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 6),
- G_TYPE_PARAM_ULONG = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 7),
- G_TYPE_PARAM_ENUM = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 8),
- G_TYPE_PARAM_FLAGS = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 9),
- G_TYPE_PARAM_FLOAT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 10),
- G_TYPE_PARAM_DOUBLE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 11),
- G_TYPE_PARAM_STRING = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 12),
- G_TYPE_PARAM_PARAM = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 13),
- G_TYPE_PARAM_POINTER = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 14),
- G_TYPE_PARAM_CCALLBACK = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 15),
- G_TYPE_PARAM_BOXED = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 16),
- G_TYPE_PARAM_OBJECT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 17),
- G_TYPE_PARAM_INTERFACE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 18)
+ G_TYPE_CLOSURE = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 1),
+ G_TYPE_VALUE_ARRAY = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 2),
+ G_TYPE_PARAM_CHAR = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 1),
+ G_TYPE_PARAM_UCHAR = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 2),
+ G_TYPE_PARAM_BOOLEAN = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 3),
+ G_TYPE_PARAM_INT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 4),
+ G_TYPE_PARAM_UINT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 5),
+ G_TYPE_PARAM_LONG = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 6),
+ G_TYPE_PARAM_ULONG = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 7),
+ G_TYPE_PARAM_ENUM = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 8),
+ G_TYPE_PARAM_FLAGS = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 9),
+ G_TYPE_PARAM_FLOAT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 10),
+ G_TYPE_PARAM_DOUBLE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 11),
+ G_TYPE_PARAM_STRING = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 12),
+ G_TYPE_PARAM_PARAM = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 13),
+ G_TYPE_PARAM_BOXED = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 14),
+ G_TYPE_PARAM_POINTER = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 15),
+ G_TYPE_PARAM_VALUE_ARRAY = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 16),
+ G_TYPE_PARAM_CLOSURE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 17),
+ G_TYPE_PARAM_OBJECT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 18)
} GTypeFundamentals;
#define G_TYPE_IS_DERIVABLE(type) (g_type_check_flags ((type), G_TYPE_FLAG_DERIVABLE))
#define G_TYPE_IS_DEEP_DERIVABLE(type) (g_type_check_flags ((type), G_TYPE_FLAG_DEEP_DERIVABLE))
#define G_TYPE_IS_ABSTRACT(type) (g_type_check_flags ((type), G_TYPE_FLAG_ABSTRACT))
+#define G_TYPE_IS_VALUE_ABSTRACT(type) (g_type_check_flags ((type), G_TYPE_FLAG_VALUE_ABSTRACT))
#define G_TYPE_IS_PARAM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_PARAM)
-#define G_TYPE_IS_VALUE_TYPE(type) (g_type_value_table_peek (type) != NULL)
+#define G_TYPE_IS_VALUE_TYPE(type) (g_type_check_is_value_type (type))
+#define G_TYPE_HAS_VALUE_TABLE(type) (g_type_value_table_peek (type) != NULL)
/* Typedefs
/* Casts, checks and accessors for structured types
* usage of these macros is reserved to type implementations only
- *
*/
/*< protected >*/
#define G_TYPE_CHECK_INSTANCE(instance) (_G_TYPE_CHI ((GTypeInstance*) (instance)))
#define G_TYPE_CHECK_CLASS_CAST(g_class, g_type, c_type) (_G_TYPE_CCC ((g_class), (g_type), c_type))
#define G_TYPE_CHECK_CLASS_TYPE(g_class, g_type) (_G_TYPE_CCT ((g_class), (g_type)))
#define G_TYPE_CHECK_VALUE(value) (_G_TYPE_CHV ((value)))
-#define G_TYPE_CHECK_VALUE_TYPE(value, g_type) (_G_TYPE_CVT ((value), (g_type)))
+#define G_TYPE_CHECK_VALUE_TYPE(value, g_type) (_G_TYPE_CVH ((value), (g_type)))
#define G_TYPE_FROM_INSTANCE(instance) (G_TYPE_FROM_CLASS (((GTypeInstance*) (instance))->g_class))
#define G_TYPE_FROM_CLASS(g_class) (((GTypeClass*) (g_class))->g_type)
#define G_TYPE_FROM_INTERFACE(g_iface) (((GTypeInterface*) (g_iface))->g_type)
GQuark g_type_qname (GType type);
GType g_type_from_name (const gchar *name);
GType g_type_parent (GType type);
-GType g_type_next_base (GType type,
- GType base_type);
+GType g_type_next_base (GType leaf_type,
+ GType root_type);
gboolean g_type_is_a (GType type,
GType is_a_type);
guint g_type_fundamental_branch_last (GType type);
} GTypeFundamentalFlags;
typedef enum /*< skip >*/
{
- G_TYPE_FLAG_ABSTRACT = (1 << 4)
+ G_TYPE_FLAG_ABSTRACT = (1 << 4),
+ G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5)
} GTypeFlags;
struct _GTypeInfo
{
GType is_a_type);
gboolean g_type_class_is_a (GTypeClass *g_class,
GType is_a_type);
+gboolean g_type_check_is_value_type (GType type);
gboolean g_type_check_value (GValue *value);
-gboolean g_type_value_is_a (GValue *value,
+gboolean g_type_check_value_holds (GValue *value,
GType type);
GTypeValueTable* g_type_value_table_peek (GType type);
#define _G_TYPE_CHI(ip) (g_type_check_instance ((GTypeInstance*) ip))
#define _G_TYPE_CIT(ip, gt) (g_type_instance_is_a ((GTypeInstance*) ip, gt))
#define _G_TYPE_CCT(cp, gt) (g_type_class_is_a ((GTypeClass*) cp, gt))
-#define _G_TYPE_CVT(vl, gt) (g_type_value_is_a ((GValue*) vl, gt))
+#define _G_TYPE_CVH(vl, gt) (g_type_check_value_holds ((GValue*) vl, gt))
#define _G_TYPE_CHV(vl) (g_type_check_value ((GValue*) vl))
#define _G_TYPE_IGC(ip, gt, ct) ((ct*) (((GTypeInstance*) ip)->g_class))
#define _G_TYPE_IGI(ip, gt, ct) ((ct*) g_type_interface_peek (((GTypeInstance*) ip)->g_class, gt))
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "gvalue.h"
#include "gvaluecollector.h"
+#include "gbsearcharray.h"
/* --- typedefs & structures --- */
-typedef struct
-{
- GType value_type1;
- GType value_type2;
- GValueExchange func;
- GType first_type;
-} ExchangeEntry;
+typedef struct {
+ GType src_type;
+ GType dest_type;
+ GValueTransform func;
+} TransformEntry;
+
+
+/* --- prototypes --- */
+static gint transform_entries_cmp (gconstpointer bsearch_node1,
+ gconstpointer bsearch_node2);
/* --- variables --- */
-static GHashTable *param_exchange_ht = NULL;
+static GBSearchArray transform_array = {
+ transform_entries_cmp,
+ sizeof (TransformEntry),
+ 0, /* no flags */
+ 0, NULL,
+};
/* --- functions --- */
-void
+static inline void /* keep this function in sync with gvaluecollector.h and gboxed.c */
+value_meminit (GValue *value,
+ GType value_type)
+{
+ value->g_type = value_type;
+ memset (value->data, 0, sizeof (value->data));
+}
+
+GValue*
g_value_init (GValue *value,
GType g_type)
{
- GTypeValueTable *value_table = g_type_value_table_peek (g_type);
-
- g_return_if_fail (value != NULL);
- g_return_if_fail (G_VALUE_TYPE (value) == 0);
-
- if (value_table)
+ /* g_return_val_if_fail (G_TYPE_IS_VALUE (g_type), NULL); be more elaborate below */
+ g_return_val_if_fail (value != NULL, NULL);
+ /* g_return_val_if_fail (G_VALUE_TYPE (value) == 0, NULL); be more elaborate below */
+
+ if (G_TYPE_IS_VALUE (g_type) && G_VALUE_TYPE (value) == 0)
{
- memset (value, 0, sizeof (*value));
- value->g_type = g_type;
+ GTypeValueTable *value_table = g_type_value_table_peek (g_type);
+
+ /* setup and init */
+ value_meminit (value, g_type);
value_table->value_init (value);
}
- else
- g_warning (G_STRLOC ": cannot initialize value of type `%s' which has no GTypeValueTable",
- g_type_name (g_type));
+ else if (G_VALUE_TYPE (value))
+ g_warning ("%s: cannot initialize GValue with type `%s', the value has already been initialized as `%s'",
+ G_STRLOC,
+ g_type_name (g_type),
+ g_type_name (G_VALUE_TYPE (value)));
+ else /* !G_TYPE_IS_VALUE (g_type) */
+ g_warning ("%s: cannot initialize GValue with type `%s', %s",
+ G_STRLOC,
+ g_type_name (g_type),
+ g_type_value_table_peek (g_type) ?
+ "this type is abstract with regards to GValue use, use a more specific (derived) type" :
+ "this type has no GTypeValueTable implementation");
+ return value;
}
void
g_value_copy (const GValue *src_value,
GValue *dest_value)
{
- GTypeValueTable *value_table;
-
g_return_if_fail (G_IS_VALUE (src_value));
g_return_if_fail (G_IS_VALUE (dest_value));
- g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), G_VALUE_TYPE (dest_value)));
-
- value_table = g_type_value_table_peek (G_VALUE_TYPE (dest_value));
- if (!value_table)
- g_return_if_fail (g_type_value_table_peek (G_VALUE_TYPE (dest_value)) != NULL);
+ g_return_if_fail (g_value_type_compatible (G_VALUE_TYPE (src_value), G_VALUE_TYPE (dest_value)));
if (src_value != dest_value)
{
- /* make sure dest_value's value is free()d and zero initialized */
- g_value_reset (dest_value);
-
+ GType dest_type = G_VALUE_TYPE (dest_value);
+ GTypeValueTable *value_table = g_type_value_table_peek (dest_type);
+
+ /* make sure dest_value's value is free()d */
+ if (value_table->value_free)
+ value_table->value_free (dest_value);
+
+ /* setup and copy */
+ value_meminit (dest_value, dest_type);
value_table->value_copy (src_value, dest_value);
}
}
+GValue*
+g_value_reset (GValue *value)
+{
+ GTypeValueTable *value_table;
+ GType g_type;
+
+ g_return_val_if_fail (G_IS_VALUE (value), NULL);
+
+ g_type = G_VALUE_TYPE (value);
+ value_table = g_type_value_table_peek (g_type);
+
+ /* make sure value's value is free()d */
+ if (value_table->value_free)
+ value_table->value_free (value);
+
+ /* setup and init */
+ value_meminit (value, g_type);
+ value_table->value_init (value);
+
+ return value;
+}
+
+void
+g_value_unset (GValue *value)
+{
+ GTypeValueTable *value_table;
+
+ g_return_if_fail (G_IS_VALUE (value));
+
+ value_table = g_type_value_table_peek (G_VALUE_TYPE (value));
+
+ if (value_table->value_free)
+ value_table->value_free (value);
+ memset (value, 0, sizeof (*value));
+}
+
gboolean
g_value_fits_pointer (const GValue *value)
{
g_return_val_if_fail (G_IS_VALUE (value), FALSE);
value_table = g_type_value_table_peek (G_VALUE_TYPE (value));
- if (!value_table)
- g_return_val_if_fail (g_type_value_table_peek (G_VALUE_TYPE (value)) != NULL, FALSE);
return value_table->value_peek_pointer != NULL;
}
gpointer
-g_value_get_as_pointer (const GValue *value)
+g_value_peek_pointer (const GValue *value)
{
GTypeValueTable *value_table;
g_return_val_if_fail (G_IS_VALUE (value), NULL);
value_table = g_type_value_table_peek (G_VALUE_TYPE (value));
- if (!value_table)
- g_return_val_if_fail (g_type_value_table_peek (G_VALUE_TYPE (value)) != NULL, NULL);
if (!value_table->value_peek_pointer)
g_return_val_if_fail (g_value_fits_pointer (value) == TRUE, NULL);
g_value_set_instance (GValue *value,
gpointer instance)
{
- g_return_if_fail (G_IS_VALUE (value));
+ GType g_type;
+ GTypeValueTable *value_table;
+ GTypeCValue cvalue;
+ gchar *error_msg;
- g_value_reset (value);
+ g_return_if_fail (G_IS_VALUE (value));
if (instance)
{
- GType g_type = G_VALUE_TYPE (value);
- GTypeValueTable *value_table = g_type_value_table_peek (g_type);
- GTypeCValue cvalue = { 0, };
- gchar *error_msg;
-
g_return_if_fail (G_TYPE_CHECK_INSTANCE (instance));
- g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (instance), G_VALUE_TYPE (value)));
- g_return_if_fail (strcmp (value_table->collect_format, "p") == 0);
-
- cvalue.v_pointer = instance;
- error_msg = value_table->collect_value (value, 1, &cvalue, 0);
-
- if (error_msg)
- {
- g_warning ("%s: %s", G_STRLOC, error_msg);
- g_free (error_msg);
-
- /* we purposely leak the value here, it might not be
- * in a sane state if an error condition occoured
- */
- memset (value, 0, sizeof (*value));
- value->g_type = g_type;
- value_table->value_init (value);
- }
+ g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (instance), G_VALUE_TYPE (value)));
}
-}
-
-void
-g_value_unset (GValue *value)
-{
- GTypeValueTable *value_table = g_type_value_table_peek (G_VALUE_TYPE (value));
-
- g_return_if_fail (G_IS_VALUE (value));
- if (!value_table)
- g_return_if_fail (g_type_value_table_peek (G_VALUE_TYPE (value)) != NULL);
- if (value_table->value_free)
- value_table->value_free (value);
- memset (value, 0, sizeof (*value));
-}
-
-void
-g_value_reset (GValue *value)
-{
- GTypeValueTable *value_table;
- GType g_type;
+ g_type = G_VALUE_TYPE (value);
+ value_table = g_type_value_table_peek (g_type);
- g_return_if_fail (G_IS_VALUE (value));
+ g_return_if_fail (strcmp (value_table->collect_format, "p") == 0);
- value_table = g_type_value_table_peek (G_VALUE_TYPE (value));
- g_type = G_VALUE_TYPE (value);
+ memset (&cvalue, 0, sizeof (cvalue));
+ cvalue.v_pointer = instance;
+ /* make sure value's value is free()d */
if (value_table->value_free)
value_table->value_free (value);
- memset (value, 0, sizeof (*value));
-
- value->g_type = g_type;
- value_table->value_init (value);
-}
-
-static gboolean
-exchange_entries_equal (gconstpointer v1,
- gconstpointer v2)
-{
- const ExchangeEntry *entry1 = v1;
- const ExchangeEntry *entry2 = v2;
-
- return (entry1->value_type1 == entry2->value_type1 &&
- entry1->value_type2 == entry2->value_type2);
-}
-static guint
-exchange_entry_hash (gconstpointer key)
-{
- const ExchangeEntry *entry = key;
-
- return entry->value_type1 ^ entry->value_type2;
+ /* setup and collect */
+ value_meminit (value, g_type);
+ error_msg = value_table->collect_value (value, 1, &cvalue, 0);
+ if (error_msg)
+ {
+ g_warning ("%s: %s", G_STRLOC, error_msg);
+ g_free (error_msg);
+
+ /* we purposely leak the value here, it might not be
+ * in a sane state if an error condition occoured
+ */
+ value_meminit (value, g_type);
+ value_table->value_init (value);
+ }
}
-static void
-value_exchange_memcpy (GValue *value1,
- GValue *value2)
+static GValueTransform
+transform_func_lookup (GType src_type,
+ GType dest_type)
{
- GValue tmp_value;
-
- memcpy (&tmp_value.data, &value1->data, sizeof (value1->data));
- memcpy (&value1->data, &value2->data, sizeof (value1->data));
- memcpy (&value2->data, &tmp_value.data, sizeof (value2->data));
-}
+ TransformEntry entry;
-static inline GValueExchange
-exchange_func_lookup (GType value_type1,
- GType value_type2,
- gboolean *need_swap)
-{
- if (value_type1 == value_type2)
- return value_exchange_memcpy;
- else
+ entry.src_type = src_type;
+ do
{
- GType type1 = value_type1;
-
+ entry.dest_type = dest_type;
do
{
- GType type2 = value_type2;
+ TransformEntry *e;
- do
+ e = g_bsearch_array_lookup (&transform_array, &entry);
+ if (e)
{
- ExchangeEntry entry, *ret;
-
- entry.value_type1 = MIN (type1, type2);
- entry.value_type2 = MAX (type1, type2);
- ret = g_hash_table_lookup (param_exchange_ht, &entry);
- if (ret)
- {
- if (need_swap)
- *need_swap = ret->first_type == type2;
-
- return ret->func;
- }
-
- type2 = g_type_parent (type2);
+ /* need to check that there hasn't been a change in value handling */
+ if (g_type_value_table_peek (entry.dest_type) == g_type_value_table_peek (dest_type) &&
+ g_type_value_table_peek (entry.src_type) == g_type_value_table_peek (src_type))
+ return e->func;
}
- while (type2);
-
- type1 = g_type_parent (type1);
+ entry.dest_type = g_type_parent (entry.dest_type);
}
- while (type1);
+ while (entry.dest_type);
+
+ entry.src_type = g_type_parent (entry.src_type);
}
-
+ while (entry.src_type);
+
return NULL;
}
-void
-g_value_register_exchange_func (GType value_type1,
- GType value_type2,
- GValueExchange func)
+static gint
+transform_entries_cmp (gconstpointer bsearch_node1,
+ gconstpointer bsearch_node2)
{
- ExchangeEntry entry;
-
- g_return_if_fail (g_type_name (value_type1) != NULL);
- g_return_if_fail (g_type_name (value_type2) != NULL);
- g_return_if_fail (func != NULL);
-
- entry.value_type1 = MIN (value_type1, value_type2);
- entry.value_type2 = MAX (value_type1, value_type2);
- if (param_exchange_ht && g_hash_table_lookup (param_exchange_ht, &entry))
- g_warning (G_STRLOC ": cannot re-register param value exchange function "
- "for `%s' and `%s'",
- g_type_name (value_type1),
- g_type_name (value_type2));
+ const TransformEntry *e1 = bsearch_node1;
+ const TransformEntry *e2 = bsearch_node2;
+ gint cmp = G_BSEARCH_ARRAY_CMP (e1->src_type, e2->src_type);
+
+ if (cmp)
+ return cmp;
else
- {
- ExchangeEntry *entry = g_new (ExchangeEntry, 1);
-
- if (!param_exchange_ht)
- param_exchange_ht = g_hash_table_new (exchange_entry_hash, exchange_entries_equal);
- entry->value_type1 = MIN (value_type1, value_type2);
- entry->value_type2 = MAX (value_type1, value_type2);
- entry->func = func;
- entry->first_type = value_type1;
- g_hash_table_insert (param_exchange_ht, entry, entry);
- }
+ return G_BSEARCH_ARRAY_CMP (e1->dest_type, e2->dest_type);
+}
+
+void
+g_value_register_transform_func (GType src_type,
+ GType dest_type,
+ GValueTransform transform_func)
+{
+ TransformEntry entry;
+
+ g_return_if_fail (G_TYPE_HAS_VALUE_TABLE (src_type));
+ g_return_if_fail (G_TYPE_HAS_VALUE_TABLE (dest_type));
+ g_return_if_fail (transform_func != NULL);
+
+ if (transform_func_lookup (src_type, dest_type))
+ g_warning ("reregistering value transformation function (%p) for `%s' to `%s'",
+ transform_func,
+ g_type_name (src_type),
+ g_type_name (dest_type));
+ entry.src_type = src_type;
+ entry.dest_type = dest_type;
+ entry.func = transform_func;
+ g_bsearch_array_insert (&transform_array, &entry, TRUE);
}
gboolean
-g_value_types_exchangable (GType value_type1,
- GType value_type2)
+g_value_type_transformable (GType src_type,
+ GType dest_type)
{
- g_return_val_if_fail (G_TYPE_IS_VALUE (value_type1), FALSE); /* these might bite us, think G_TYPE_ENUM */
- g_return_val_if_fail (G_TYPE_IS_VALUE (value_type2), FALSE);
-
- return exchange_func_lookup (value_type1, value_type2, NULL) != NULL;
+ g_return_val_if_fail (G_TYPE_IS_VALUE (src_type), FALSE);
+ g_return_val_if_fail (G_TYPE_IS_VALUE (dest_type), FALSE);
+
+ return (g_value_type_compatible (src_type, dest_type) ||
+ transform_func_lookup (src_type, dest_type) != NULL);
}
gboolean
-g_values_exchange (GValue *value1,
- GValue *value2)
+g_value_type_compatible (GType src_type,
+ GType dest_type)
{
- g_return_val_if_fail (G_IS_VALUE (value1), FALSE);
- g_return_val_if_fail (G_IS_VALUE (value2), FALSE);
-
- if (value1 != value2)
- {
- gboolean need_swap;
- GValueExchange value_exchange = exchange_func_lookup (G_VALUE_TYPE (value1),
- G_VALUE_TYPE (value2),
- &need_swap);
- if (value_exchange)
- {
- if (need_swap)
- value_exchange (value2, value1);
- else
- value_exchange (value1, value2);
- }
-
- return value_exchange != NULL;
- }
-
- return TRUE;
+ g_return_val_if_fail (G_TYPE_IS_VALUE (src_type), FALSE);
+ g_return_val_if_fail (G_TYPE_IS_VALUE (dest_type), FALSE);
+
+ return (g_type_is_a (src_type, dest_type) &&
+ g_type_value_table_peek (dest_type) == g_type_value_table_peek (src_type));
}
gboolean
-g_value_convert (const GValue *src_value,
- GValue *dest_value)
+g_value_transform (const GValue *src_value,
+ GValue *dest_value)
{
- gboolean success = TRUE;
-
+ GType dest_type;
+
g_return_val_if_fail (G_IS_VALUE (src_value), FALSE);
g_return_val_if_fail (G_IS_VALUE (dest_value), FALSE);
-
- if (src_value != dest_value)
+
+ dest_type = G_VALUE_TYPE (dest_value);
+ if (g_value_type_compatible (G_VALUE_TYPE (src_value), dest_type))
{
- GValue tmp_value = { 0, };
+ g_value_copy (src_value, dest_value);
- g_value_init (&tmp_value, G_VALUE_TYPE (src_value));
- g_value_copy (src_value, &tmp_value);
-
- success = g_values_exchange (&tmp_value, dest_value);
- g_value_unset (&tmp_value);
+ return TRUE;
}
-
- return success;
+ else
+ {
+ GValueTransform transform = transform_func_lookup (G_VALUE_TYPE (src_value), dest_type);
+
+ if (transform)
+ {
+ g_value_unset (dest_value);
+
+ /* setup and transform */
+ value_meminit (dest_value, dest_type);
+ transform (src_value, dest_value);
+
+ return TRUE;
+ }
+ }
+ return FALSE;
}
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* --- type macros --- */
#define G_TYPE_IS_VALUE(type) (g_type_value_table_peek (type) != NULL)
#define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value))
-#define G_VALUE_HOLDS(value, g_type) (G_TYPE_CHECK_VALUE_TYPE ((value), (g_type)))
#define G_VALUE_TYPE(value) (((GValue*) (value))->g_type)
#define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value)))
+#define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type)))
/* --- typedefs & structures --- */
-typedef void (*GValueExchange) (GValue *value1,
- GValue *value2);
+typedef void (*GValueExchange) (GValue *value1,
+ GValue *value2);
+typedef void (*GValueTransform) (const GValue *src_value,
+ GValue *dest_value);
struct _GValue
{
/*< private >*/
/* --- prototypes --- */
-void g_value_init (GValue *value,
+GValue* g_value_init (GValue *value,
GType g_type);
void g_value_copy (const GValue *src_value,
GValue *dest_value);
gboolean g_value_convert (const GValue *src_value,
GValue *dest_value);
-void g_value_reset (GValue *value);
+GValue* g_value_reset (GValue *value);
void g_value_unset (GValue *value);
-gboolean g_value_fits_pointer (const GValue *value);
-gpointer g_value_get_as_pointer (const GValue *value);
void g_value_set_instance (GValue *value,
gpointer instance);
+/* --- private --- */
+gboolean g_value_fits_pointer (const GValue *value);
+gpointer g_value_peek_pointer (const GValue *value);
+
+
/* --- implementation details --- */
-gboolean g_values_exchange (GValue *value1,
- GValue *value2);
-gboolean g_value_types_exchangable (GType value_type1,
- GType value_type2);
-void g_value_register_exchange_func (GType value_type1,
- GType value_type2,
- GValueExchange func);
+gboolean g_value_type_compatible (GType src_type,
+ GType dest_type);
+gboolean g_value_type_transformable (GType src_type,
+ GType dest_type);
+gboolean g_value_transform (const GValue *src_value,
+ GValue *dest_value);
+void g_value_register_transform_func (GType src_type,
+ GType dest_type,
+ GValueTransform transform_func);
#define G_VALUE_NOCOPY_CONTENTS (1 << 27)
--- /dev/null
+/* GObject - GLib Type, Object, Parameter and Signal Library
+ * Copyright (C) 2001 Red Hat, Inc.
+ *
+ * This library 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 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * MT safe
+ */
+
+#include "gvaluearray.h"
+#include <string.h>
+#include <stdlib.h> /* qsort() */
+
+
+
+/* --- functions --- */
+GValue*
+g_value_array_get_nth (GValueArray *value_array,
+ guint index)
+{
+ g_return_val_if_fail (value_array != NULL, NULL);
+ g_return_val_if_fail (index < value_array->n_values, NULL);
+
+ return value_array->values + index;
+}
+
+GValueArray*
+g_value_array_new (guint n_prealloced)
+{
+ GValueArray *value_array = g_new0 (GValueArray, 1);
+
+ value_array->n_values = n_prealloced;
+ value_array->values = g_renew (GValue, value_array->values, value_array->n_values);
+ memset (value_array->values, 0, value_array->n_values * sizeof (value_array->values[0]));
+
+ return value_array;
+}
+
+void
+g_value_array_free (GValueArray *value_array)
+{
+ guint i;
+
+ g_return_if_fail (value_array != NULL);
+
+ for (i = 0; i < value_array->n_values; i++)
+ {
+ GValue *value = value_array->values + i;
+
+ if (G_VALUE_TYPE (value) != 0) /* we allow unset values in the array */
+ g_value_unset (value);
+ }
+ g_free (value_array->values);
+ g_free (value_array);
+}
+
+GValueArray*
+g_value_array_copy (const GValueArray *value_array)
+{
+ GValueArray *new_array;
+ guint i;
+
+ g_return_val_if_fail (value_array != NULL, NULL);
+
+ new_array = g_new0 (GValueArray, 1);
+ new_array->n_values = value_array->n_values;
+ new_array->values = g_renew (GValue, new_array->values, new_array->n_values);
+ memset (new_array->values, 0, new_array->n_values * sizeof (new_array->values[0]));
+ for (i = 0; i < new_array->n_values; i++)
+ if (G_VALUE_TYPE (value_array->values + i) != 0)
+ {
+ GValue *value = new_array->values + i;
+
+ g_value_init (value, G_VALUE_TYPE (value_array->values + i));
+ g_value_copy (value_array->values + i, value);
+ }
+ return new_array;
+}
+
+GValueArray*
+g_value_array_prepend (GValueArray *value_array,
+ const GValue *value)
+{
+ g_return_val_if_fail (value_array != NULL, NULL);
+
+ return g_value_array_insert (value_array, 0, value);
+}
+
+GValueArray*
+g_value_array_append (GValueArray *value_array,
+ const GValue *value)
+{
+ g_return_val_if_fail (value_array != NULL, NULL);
+
+ return g_value_array_insert (value_array, value_array->n_values, value);
+}
+
+GValueArray*
+g_value_array_insert (GValueArray *value_array,
+ guint index,
+ const GValue *value)
+{
+ guint i;
+
+ g_return_val_if_fail (value_array != NULL, NULL);
+ g_return_val_if_fail (index <= value_array->n_values, value_array);
+
+ /* we support NULL for "value" as a shortcut for an unset value */
+
+ i = value_array->n_values++;
+ value_array->values = g_renew (GValue, value_array->values, value_array->n_values);
+ if (index + 1 < value_array->n_values)
+ g_memmove (value_array->values + index + 1, value_array->values + index,
+ (i - index) * sizeof (value_array->values[0]));
+ memset (value_array->values + index, 0, sizeof (value_array->values[0]));
+ if (value)
+ {
+ g_value_init (value_array->values + index, G_VALUE_TYPE (value));
+ g_value_copy (value, value_array->values + index);
+ }
+ return value_array;
+}
+
+GValueArray*
+g_value_array_remove (GValueArray *value_array,
+ guint index)
+{
+ g_return_val_if_fail (value_array != NULL, NULL);
+ g_return_val_if_fail (index < value_array->n_values, value_array);
+
+ if (G_VALUE_TYPE (value_array->values + index) != 0)
+ g_value_unset (value_array->values + index);
+ value_array->n_values--;
+ if (index < value_array->n_values)
+ g_memmove (value_array->values + index, value_array->values + index + 1,
+ (value_array->n_values - index) * sizeof (value_array->values[0]));
+ value_array->values = g_renew (GValue, value_array->values, value_array->n_values);
+
+ return value_array;
+}
+
+GValueArray*
+g_value_array_sort (GValueArray *value_array,
+ GCompareFunc compare_func)
+{
+ g_return_val_if_fail (compare_func != NULL, NULL);
+
+ if (value_array->n_values)
+ qsort (value_array->values,
+ value_array->n_values,
+ sizeof (value_array->values[0]),
+ compare_func);
+ return value_array;
+}
+
+GValueArray*
+g_value_array_sort_with_data (GValueArray *value_array,
+ GCompareDataFunc compare_func,
+ gpointer user_data)
+{
+ g_return_val_if_fail (value_array != NULL, NULL);
+ g_return_val_if_fail (compare_func != NULL, NULL);
+
+ if (value_array->n_values)
+ g_qsort_with_data (value_array->values,
+ value_array->n_values,
+ sizeof (value_array->values[0]),
+ compare_func, user_data);
+ return value_array;
+}
--- /dev/null
+/* GObject - GLib Type, Object, Parameter and Signal Library
+ * Copyright (C) 2001 Red Hat, Inc.
+ *
+ * This library 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 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * gvaluearray.h: GLib array type holding GValues
+ */
+#ifndef __G_VALUE_ARRAY_H__
+#define __G_VALUE_ARRAY_H__
+
+
+#include <gobject/gvalue.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* --- typedefs & structs --- */
+typedef struct _GValueArray GValueArray;
+struct _GValueArray
+{
+ guint n_values;
+ GValue *values;
+};
+
+
+/* --- prototypes --- */
+GValue* g_value_array_get_nth (GValueArray *value_array,
+ guint index);
+GValueArray* g_value_array_new (guint n_prealloced);
+void g_value_array_free (GValueArray *value_array);
+GValueArray* g_value_array_copy (const GValueArray *value_array);
+GValueArray* g_value_array_prepend (GValueArray *value_array,
+ const GValue *value);
+GValueArray* g_value_array_append (GValueArray *value_array,
+ const GValue *value);
+GValueArray* g_value_array_insert (GValueArray *value_array,
+ guint index,
+ const GValue *value);
+GValueArray* g_value_array_remove (GValueArray *value_array,
+ guint index);
+GValueArray* g_value_array_sort (GValueArray *value_array,
+ GCompareFunc compare_func);
+GValueArray* g_value_array_sort_with_data (GValueArray *value_array,
+ GCompareDataFunc compare_func,
+ gpointer user_data);
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __G_VALUE_ARRAY_H__ */
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
G_STMT_START { \
GValue *_value = (value); \
guint _flags = (flags); \
- GTypeValueTable *_vtable = g_type_value_table_peek (G_VALUE_TYPE (_value)); \
+ GType _value_type = G_VALUE_TYPE (_value); \
+ GTypeValueTable *_vtable = g_type_value_table_peek (_value_type); \
gchar *_collect_format = _vtable->collect_format; \
GTypeCValue _cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \
guint _n_values = 0; \
\
- g_value_reset (_value); \
+ if (_vtable->value_free) \
+ _vtable->value_free (_value); \
+ _value->g_type = _value_type; /* value_meminit() from gvalue.c */ \
+ memset (_value->data, 0, sizeof (_value->data)); \
while (*_collect_format) \
{ \
GTypeCValue *_cvalue = _cvalues + _n_values++; \
G_STMT_START { \
GValue *_value = (value); \
guint _flags = (flags); \
- GTypeValueTable *_vtable = g_type_value_table_peek (G_VALUE_TYPE (_value)); \
+ GType _value_type = G_VALUE_TYPE (_value); \
+ GTypeValueTable *_vtable = g_type_value_table_peek (_value_type); \
gchar *_lcopy_format = _vtable->lcopy_format; \
GTypeCValue _cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \
guint _n_values = 0; \
--- /dev/null
+/* GObject - GLib Type, Object, Parameter and Signal Library
+ * Copyright (C) 2001 Red Hat, Inc.
+ *
+ * This library 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 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include "gvalue.h"
+#include "genums.h"
+
+
+/* same type transforms
+ */
+static void
+value_transform_memcpy_data0 (const GValue *src_value,
+ GValue *dest_value)
+{
+ memcpy (&dest_value->data[0], &src_value->data[0], sizeof (src_value->data[0]));
+}
+#define value_transform_int_int value_transform_memcpy_data0
+#define value_transform_uint_uint value_transform_memcpy_data0
+#define value_transform_long_long value_transform_memcpy_data0
+#define value_transform_ulong_ulong value_transform_memcpy_data0
+#define value_transform_float_float value_transform_memcpy_data0
+#define value_transform_double_double value_transform_memcpy_data0
+
+
+/* numeric casts
+ */
+#define DEFINE_CAST(func_name, from_member, ctype, to_member) \
+ static void \
+ value_transform_##func_name (const GValue *src_value, \
+ GValue *dest_value) \
+ { \
+ ctype c_value = src_value->data[0].##from_member; \
+ dest_value->data[0].##to_member = c_value; \
+ }
+DEFINE_CAST (int_s8, v_int, gint8, v_int);
+DEFINE_CAST (int_u8, v_int, guint8, v_uint);
+DEFINE_CAST (int_uint, v_int, guint, v_uint);
+DEFINE_CAST (int_long, v_int, glong, v_long);
+DEFINE_CAST (int_ulong, v_int, gulong, v_ulong);
+DEFINE_CAST (int_float, v_int, gfloat, v_float);
+DEFINE_CAST (int_double, v_int, gdouble, v_double);
+DEFINE_CAST (uint_s8, v_uint, gint8, v_int);
+DEFINE_CAST (uint_u8, v_uint, guint8, v_uint);
+DEFINE_CAST (uint_int, v_uint, gint, v_int);
+DEFINE_CAST (uint_long, v_uint, glong, v_long);
+DEFINE_CAST (uint_ulong, v_uint, gulong, v_ulong);
+DEFINE_CAST (uint_float, v_uint, gfloat, v_float);
+DEFINE_CAST (uint_double, v_uint, gdouble, v_double);
+DEFINE_CAST (long_s8, v_long, gint8, v_int);
+DEFINE_CAST (long_u8, v_long, guint8, v_uint);
+DEFINE_CAST (long_int, v_long, gint, v_int);
+DEFINE_CAST (long_uint, v_long, guint, v_uint);
+DEFINE_CAST (long_ulong, v_long, gulong, v_ulong);
+DEFINE_CAST (long_float, v_long, gfloat, v_float);
+DEFINE_CAST (long_double, v_long, gdouble, v_double);
+DEFINE_CAST (ulong_s8, v_ulong, gint8, v_int);
+DEFINE_CAST (ulong_u8, v_ulong, guint8, v_uint);
+DEFINE_CAST (ulong_int, v_ulong, gint, v_int);
+DEFINE_CAST (ulong_uint, v_ulong, guint, v_uint);
+DEFINE_CAST (ulong_long, v_ulong, glong, v_long);
+DEFINE_CAST (ulong_float, v_ulong, gfloat, v_float);
+DEFINE_CAST (ulong_double, v_ulong, gdouble, v_double);
+DEFINE_CAST (float_s8, v_float, gint8, v_int);
+DEFINE_CAST (float_u8, v_float, guint8, v_uint);
+DEFINE_CAST (float_int, v_float, gint, v_int);
+DEFINE_CAST (float_uint, v_float, guint, v_uint);
+DEFINE_CAST (float_long, v_float, glong, v_long);
+DEFINE_CAST (float_ulong, v_float, gulong, v_ulong);
+DEFINE_CAST (float_double, v_float, gdouble, v_double);
+DEFINE_CAST (double_s8, v_double, gint8, v_int);
+DEFINE_CAST (double_u8, v_double, guint8, v_uint);
+DEFINE_CAST (double_int, v_double, gint, v_int);
+DEFINE_CAST (double_uint, v_double, guint, v_uint);
+DEFINE_CAST (double_long, v_double, glong, v_long);
+DEFINE_CAST (double_ulong, v_double, gulong, v_ulong);
+DEFINE_CAST (double_float, v_double, gfloat, v_float);
+
+
+/* boolean assignments
+ */
+#define DEFINE_BOOL_CHECK(func_name, from_member) \
+ static void \
+ value_transform_##func_name (const GValue *src_value, \
+ GValue *dest_value) \
+ { \
+ dest_value->data[0].v_int = src_value->data[0].##from_member != 0; \
+ }
+DEFINE_BOOL_CHECK (int_bool, v_int);
+DEFINE_BOOL_CHECK (uint_bool, v_uint);
+DEFINE_BOOL_CHECK (long_bool, v_long);
+DEFINE_BOOL_CHECK (ulong_bool, v_uint);
+
+
+/* string printouts
+ */
+#define DEFINE_SPRINTF(func_name, from_member, format) \
+ static void \
+ value_transform_##func_name (const GValue *src_value, \
+ GValue *dest_value) \
+ { \
+ dest_value->data[0].v_pointer = \
+ g_strdup_printf ((format), src_value->data[0].##from_member); \
+ }
+DEFINE_SPRINTF (int_string, v_int, "%d");
+DEFINE_SPRINTF (uint_string, v_uint, "%u");
+DEFINE_SPRINTF (long_string, v_long, "%ld");
+DEFINE_SPRINTF (ulong_string, v_ulong, "%lu");
+DEFINE_SPRINTF (float_string, v_float, "%f");
+DEFINE_SPRINTF (double_string, v_double, "%f");
+
+
+/* special cases
+ */
+static void
+value_transform_bool_string (const GValue *src_value,
+ GValue *dest_value)
+{
+ dest_value->data[0].v_pointer = g_strdup_printf ("%s",
+ src_value->data[0].v_int ?
+ "TRUE" : "FALSE");
+}
+static void
+value_transform_string_string (const GValue *src_value,
+ GValue *dest_value)
+{
+ dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer);
+}
+static void
+value_transform_enum_string (const GValue *src_value,
+ GValue *dest_value)
+{
+ GEnumClass *class = g_type_class_ref (G_VALUE_TYPE (src_value));
+ GEnumValue *enum_value = g_enum_get_value (class, src_value->data[0].v_int);
+
+ if (enum_value)
+ dest_value->data[0].v_pointer = g_strdup (enum_value->value_name);
+ else
+ dest_value->data[0].v_pointer = g_strdup_printf ("%d", src_value->data[0].v_int);
+
+ g_type_class_unref (class);
+}
+static void
+value_transform_flags_string (const GValue *src_value,
+ GValue *dest_value)
+{
+ GFlagsClass *class = g_type_class_ref (G_VALUE_TYPE (src_value));
+ GFlagsValue *flags_value = g_flags_get_first_value (class, src_value->data[0].v_uint);
+
+ if (flags_value)
+ {
+ GString *gstring = g_string_new ("");
+ guint v_flags = src_value->data[0].v_uint;
+
+ do
+ {
+ v_flags &= ~flags_value->value;
+
+ if (gstring->str[0])
+ g_string_append (gstring, " | ");
+ g_string_append (gstring, flags_value->value_name);
+ flags_value = g_flags_get_first_value (class, v_flags);
+ }
+ while (flags_value);
+
+ if (v_flags)
+ dest_value->data[0].v_pointer = g_strdup_printf ("%s | %u",
+ gstring->str,
+ v_flags);
+ else
+ dest_value->data[0].v_pointer = g_strdup (gstring->str);
+ g_string_free (gstring, TRUE);
+ }
+ else
+ dest_value->data[0].v_pointer = g_strdup_printf ("%u", src_value->data[0].v_uint);
+
+ g_type_class_unref (class);
+}
+
+
+/* registration
+ */
+void
+g_value_transforms_init (void) /* sync with gtype.c */
+{
+ /* some transformations are a bit questionable,
+ * we currently skip those
+ */
+#define SKIP____register_transform_func(type1,type2,transform_func) /* skip questionable transforms */
+
+ /* numeric types (plus to string) */
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_CHAR, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_UCHAR, value_transform_int_u8);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_BOOLEAN, value_transform_int_bool);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_INT, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_UINT, value_transform_int_uint);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_LONG, value_transform_int_long);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_ULONG, value_transform_int_ulong);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_ENUM, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_FLAGS, value_transform_int_uint);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_FLOAT, value_transform_int_float);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_DOUBLE, value_transform_int_double);
+ g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_STRING, value_transform_int_string);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_CHAR, value_transform_uint_s8);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_UCHAR, value_transform_uint_uint);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_BOOLEAN, value_transform_uint_bool);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_INT, value_transform_uint_int);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_UINT, value_transform_uint_uint);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_LONG, value_transform_uint_long);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_ULONG, value_transform_uint_ulong);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_ENUM, value_transform_uint_int);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_FLAGS, value_transform_uint_uint);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_FLOAT, value_transform_uint_float);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_DOUBLE, value_transform_uint_double);
+ g_value_register_transform_func (G_TYPE_UCHAR, G_TYPE_STRING, value_transform_uint_string);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_CHAR, value_transform_int_s8);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_UCHAR, value_transform_int_u8);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_INT, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_UINT, value_transform_int_uint);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_LONG, value_transform_int_long);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_ULONG, value_transform_int_ulong);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_ENUM, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_FLAGS, value_transform_int_uint);
+ SKIP____register_transform_func (G_TYPE_BOOLEAN, G_TYPE_FLOAT, value_transform_int_float);
+ SKIP____register_transform_func (G_TYPE_BOOLEAN, G_TYPE_DOUBLE, value_transform_int_double);
+ g_value_register_transform_func (G_TYPE_BOOLEAN, G_TYPE_STRING, value_transform_bool_string);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_CHAR, value_transform_int_s8);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_UCHAR, value_transform_int_u8);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_BOOLEAN, value_transform_int_bool);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_INT, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_UINT, value_transform_int_uint);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_LONG, value_transform_int_long);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_ULONG, value_transform_int_ulong);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_ENUM, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_FLAGS, value_transform_int_uint);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_FLOAT, value_transform_int_float);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_DOUBLE, value_transform_int_double);
+ g_value_register_transform_func (G_TYPE_INT, G_TYPE_STRING, value_transform_int_string);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_CHAR, value_transform_uint_s8);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_UCHAR, value_transform_uint_u8);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_BOOLEAN, value_transform_uint_bool);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_INT, value_transform_uint_int);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_UINT, value_transform_uint_uint);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_LONG, value_transform_uint_long);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_ULONG, value_transform_uint_ulong);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_ENUM, value_transform_uint_int);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_FLAGS, value_transform_uint_uint);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_FLOAT, value_transform_uint_float);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_DOUBLE, value_transform_uint_double);
+ g_value_register_transform_func (G_TYPE_UINT, G_TYPE_STRING, value_transform_uint_string);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_CHAR, value_transform_long_s8);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_UCHAR, value_transform_long_u8);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_BOOLEAN, value_transform_long_bool);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_INT, value_transform_long_int);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_UINT, value_transform_long_uint);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_LONG, value_transform_long_long);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_ULONG, value_transform_long_ulong);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_ENUM, value_transform_long_int);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_FLAGS, value_transform_long_uint);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_FLOAT, value_transform_long_float);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_DOUBLE, value_transform_long_double);
+ g_value_register_transform_func (G_TYPE_LONG, G_TYPE_STRING, value_transform_long_string);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_CHAR, value_transform_ulong_s8);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_UCHAR, value_transform_ulong_u8);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_BOOLEAN, value_transform_ulong_bool);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_INT, value_transform_ulong_int);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_UINT, value_transform_ulong_uint);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_LONG, value_transform_ulong_long);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_ULONG, value_transform_ulong_ulong);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_ENUM, value_transform_ulong_int);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_FLAGS, value_transform_ulong_uint);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_FLOAT, value_transform_ulong_float);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_DOUBLE, value_transform_ulong_double);
+ g_value_register_transform_func (G_TYPE_ULONG, G_TYPE_STRING, value_transform_ulong_string);
+ g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_CHAR, value_transform_int_s8);
+ g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_UCHAR, value_transform_int_u8);
+ SKIP____register_transform_func (G_TYPE_ENUM, G_TYPE_BOOLEAN, value_transform_int_bool);
+ g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_INT, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_UINT, value_transform_int_uint);
+ g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_LONG, value_transform_int_long);
+ g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_ULONG, value_transform_int_ulong);
+ g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_ENUM, value_transform_int_int);
+ g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_FLAGS, value_transform_int_uint);
+ SKIP____register_transform_func (G_TYPE_ENUM, G_TYPE_FLOAT, value_transform_int_float);
+ SKIP____register_transform_func (G_TYPE_ENUM, G_TYPE_DOUBLE, value_transform_int_double);
+ g_value_register_transform_func (G_TYPE_ENUM, G_TYPE_STRING, value_transform_enum_string);
+ g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_CHAR, value_transform_uint_s8);
+ g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_UCHAR, value_transform_uint_u8);
+ SKIP____register_transform_func (G_TYPE_FLAGS, G_TYPE_BOOLEAN, value_transform_uint_bool);
+ g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_INT, value_transform_uint_int);
+ g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_UINT, value_transform_uint_uint);
+ g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_LONG, value_transform_uint_long);
+ g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_ULONG, value_transform_uint_ulong);
+ SKIP____register_transform_func (G_TYPE_FLAGS, G_TYPE_ENUM, value_transform_uint_int);
+ g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_FLAGS, value_transform_uint_uint);
+ SKIP____register_transform_func (G_TYPE_FLAGS, G_TYPE_FLOAT, value_transform_uint_float);
+ SKIP____register_transform_func (G_TYPE_FLAGS, G_TYPE_DOUBLE, value_transform_uint_double);
+ g_value_register_transform_func (G_TYPE_FLAGS, G_TYPE_STRING, value_transform_flags_string);
+ g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_CHAR, value_transform_float_s8);
+ g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_UCHAR, value_transform_float_u8);
+ SKIP____register_transform_func (G_TYPE_FLOAT, G_TYPE_BOOLEAN, value_transform_float_bool);
+ g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_INT, value_transform_float_int);
+ g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_UINT, value_transform_float_uint);
+ g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_LONG, value_transform_float_long);
+ g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_ULONG, value_transform_float_ulong);
+ SKIP____register_transform_func (G_TYPE_FLOAT, G_TYPE_ENUM, value_transform_float_int);
+ SKIP____register_transform_func (G_TYPE_FLOAT, G_TYPE_FLAGS, value_transform_float_uint);
+ g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_FLOAT, value_transform_float_float);
+ g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_DOUBLE, value_transform_float_double);
+ g_value_register_transform_func (G_TYPE_FLOAT, G_TYPE_STRING, value_transform_float_string);
+ g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_CHAR, value_transform_double_s8);
+ g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_UCHAR, value_transform_double_u8);
+ SKIP____register_transform_func (G_TYPE_DOUBLE, G_TYPE_BOOLEAN, value_transform_double_bool);
+ g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_INT, value_transform_double_int);
+ g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_UINT, value_transform_double_uint);
+ g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_LONG, value_transform_double_long);
+ g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_ULONG, value_transform_double_ulong);
+ SKIP____register_transform_func (G_TYPE_DOUBLE, G_TYPE_ENUM, value_transform_double_int);
+ SKIP____register_transform_func (G_TYPE_DOUBLE, G_TYPE_FLAGS, value_transform_double_uint);
+ g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_FLOAT, value_transform_double_float);
+ g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_DOUBLE, value_transform_double_double);
+ g_value_register_transform_func (G_TYPE_DOUBLE, G_TYPE_STRING, value_transform_double_string);
+ /* string types */
+ g_value_register_transform_func (G_TYPE_STRING, G_TYPE_STRING, value_transform_string_string);
+}
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "gvaluecollector.h"
#include <string.h>
+#include <stdlib.h> /* qsort() */
/* --- value functions --- */
static void
-value_long0_init (GValue *value)
+value_init_long0 (GValue *value)
{
value->data[0].v_long = 0;
}
static void
-value_long0_copy (const GValue *src_value,
+value_copy_long0 (const GValue *src_value,
GValue *dest_value)
{
dest_value->data[0].v_long = src_value->data[0].v_long;
}
static gchar*
-value_char_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_lcopy_char (const GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
gint8 *int8_p = collect_values[0].v_pointer;
}
static gchar*
-value_boolean_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_lcopy_boolean (const GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
gboolean *bool_p = collect_values[0].v_pointer;
}
static gchar*
-value_int_collect_value (GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_collect_int (GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
value->data[0].v_int = collect_values[0].v_int;
}
static gchar*
-value_int_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_lcopy_int (const GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
gint *int_p = collect_values[0].v_pointer;
}
static gchar*
-value_long_collect_value (GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_collect_long (GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
value->data[0].v_long = collect_values[0].v_long;
}
static gchar*
-value_long_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_lcopy_long (const GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
glong *long_p = collect_values[0].v_pointer;
}
static void
-value_float_init (GValue *value)
+value_init_float (GValue *value)
{
value->data[0].v_float = 0.0;
}
static void
-value_float_copy (const GValue *src_value,
+value_copy_float (const GValue *src_value,
GValue *dest_value)
{
dest_value->data[0].v_float = src_value->data[0].v_float;
}
static gchar*
-value_float_collect_value (GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_collect_float (GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
value->data[0].v_float = collect_values[0].v_double;
}
static gchar*
-value_float_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_lcopy_float (const GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
gfloat *float_p = collect_values[0].v_pointer;
}
static void
-value_double_init (GValue *value)
+value_init_double (GValue *value)
{
value->data[0].v_double = 0.0;
}
static void
-value_double_copy (const GValue *src_value,
+value_copy_double (const GValue *src_value,
GValue *dest_value)
{
dest_value->data[0].v_double = src_value->data[0].v_double;
}
static gchar*
-value_double_collect_value (GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_collect_double (GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
value->data[0].v_double = collect_values[0].v_double;
}
static gchar*
-value_double_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_lcopy_double (const GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
gdouble *double_p = collect_values[0].v_pointer;
}
static void
-value_string_init (GValue *value)
+value_init_string (GValue *value)
{
value->data[0].v_pointer = NULL;
}
static void
-value_string_free_value (GValue *value)
+value_free_string (GValue *value)
{
if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
g_free (value->data[0].v_pointer);
}
static void
-value_string_copy_value (const GValue *src_value,
- GValue *dest_value)
+value_copy_string (const GValue *src_value,
+ GValue *dest_value)
{
dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer);
}
static gchar*
-value_string_collect_value (GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_collect_string (GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
if (!collect_values[0].v_pointer)
value->data[0].v_pointer = NULL;
}
static gchar*
-value_string_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_lcopy_string (const GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
gchar **string_p = collect_values[0].v_pointer;
}
static void
-value_pointer_init (GValue *value)
+value_init_pointer (GValue *value)
{
value->data[0].v_pointer = NULL;
}
static void
-value_pointer_copy (const GValue *src_value,
+value_copy_pointer (const GValue *src_value,
GValue *dest_value)
{
dest_value->data[0].v_pointer = src_value->data[0].v_pointer;
}
static gpointer
-value_pointer_peek_pointer (const GValue *value)
+value_peek_pointer0 (const GValue *value)
{
return value->data[0].v_pointer;
}
static gchar*
-value_pointer_collect_value (GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_collect_pointer (GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
value->data[0].v_pointer = collect_values[0].v_pointer;
}
static gchar*
-value_pointer_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+value_lcopy_pointer (const GValue *value,
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
gpointer *pointer_p = collect_values[0].v_pointer;
return NULL;
}
-static void
-value_ccallback_init (GValue *value)
-{
- value->data[0].v_pointer = NULL;
- value->data[1].v_pointer = NULL;
-}
-
-static void
-value_ccallback_copy (const GValue *src_value,
- GValue *dest_value)
-{
- dest_value->data[0].v_pointer = src_value->data[0].v_pointer;
- dest_value->data[1].v_pointer = src_value->data[1].v_pointer;
-}
-
-static gchar*
-value_ccallback_collect_value (GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
-{
- gchar *error = NULL;
-
- if (!collect_values[0].v_pointer)
- error = g_strconcat ("invalid (NULL) pointer callback function for value type `",
- G_VALUE_TYPE_NAME (value),
- "'",
- NULL);
- value->data[0].v_pointer = collect_values[0].v_pointer;
- value->data[1].v_pointer = collect_values[1].v_pointer;
-
- return error;
-}
-
-static gchar*
-value_ccallback_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
-{
- gpointer *callback_p = collect_values[0].v_pointer;
- gpointer *data_p = collect_values[1].v_pointer;
-
- if (!callback_p || !data_p)
- return g_strdup_printf ("%s location for `%s' passed as NULL",
- callback_p ? "data" : "callback",
- G_VALUE_TYPE_NAME (value));
- *callback_p = value->data[0].v_pointer;
- *data_p = value->data[1].v_pointer;
-
- return NULL;
-}
-
/* --- type initialization --- */
void
*/
{
static const GTypeValueTable value_table = {
- value_long0_init, /* value_init */
+ value_init_long0, /* value_init */
NULL, /* value_free */
- value_long0_copy, /* value_copy */
+ value_copy_long0, /* value_copy */
NULL, /* value_peek_pointer */
"i", /* collect_format */
- value_int_collect_value, /* collect_value */
+ value_collect_int, /* collect_value */
"p", /* lcopy_format */
- value_char_lcopy_value, /* lcopy_value */
+ value_lcopy_char, /* lcopy_value */
};
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_CHAR, "gchar", &info, &finfo, 0);
*/
{
static const GTypeValueTable value_table = {
- value_long0_init, /* value_init */
+ value_init_long0, /* value_init */
NULL, /* value_free */
- value_long0_copy, /* value_copy */
+ value_copy_long0, /* value_copy */
NULL, /* value_peek_pointer */
"i", /* collect_format */
- value_int_collect_value, /* collect_value */
+ value_collect_int, /* collect_value */
"p", /* lcopy_format */
- value_boolean_lcopy_value, /* lcopy_value */
+ value_lcopy_boolean, /* lcopy_value */
};
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_BOOLEAN, "gboolean", &info, &finfo, 0);
*/
{
static const GTypeValueTable value_table = {
- value_long0_init, /* value_init */
+ value_init_long0, /* value_init */
NULL, /* value_free */
- value_long0_copy, /* value_copy */
+ value_copy_long0, /* value_copy */
NULL, /* value_peek_pointer */
"i", /* collect_format */
- value_int_collect_value, /* collect_value */
+ value_collect_int, /* collect_value */
"p", /* lcopy_format */
- value_int_lcopy_value, /* lcopy_value */
+ value_lcopy_int, /* lcopy_value */
};
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_INT, "gint", &info, &finfo, 0);
*/
{
static const GTypeValueTable value_table = {
- value_long0_init, /* value_init */
+ value_init_long0, /* value_init */
NULL, /* value_free */
- value_long0_copy, /* value_copy */
+ value_copy_long0, /* value_copy */
NULL, /* value_peek_pointer */
"l", /* collect_format */
- value_long_collect_value, /* collect_value */
+ value_collect_long, /* collect_value */
"p", /* lcopy_format */
- value_long_lcopy_value, /* lcopy_value */
+ value_lcopy_long, /* lcopy_value */
};
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_LONG, "glong", &info, &finfo, 0);
*/
{
static const GTypeValueTable value_table = {
- value_float_init, /* value_init */
+ value_init_float, /* value_init */
NULL, /* value_free */
- value_float_copy, /* value_copy */
+ value_copy_float, /* value_copy */
NULL, /* value_peek_pointer */
"d", /* collect_format */
- value_float_collect_value, /* collect_value */
+ value_collect_float, /* collect_value */
"p", /* lcopy_format */
- value_float_lcopy_value, /* lcopy_value */
+ value_lcopy_float, /* lcopy_value */
};
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_FLOAT, "gfloat", &info, &finfo, 0);
*/
{
static const GTypeValueTable value_table = {
- value_double_init, /* value_init */
- NULL, /* value_free */
- value_double_copy, /* value_copy */
- NULL, /* value_peek_pointer */
- "d", /* collect_format */
- value_double_collect_value, /* collect_value */
- "p", /* lcopy_format */
- value_double_lcopy_value, /* lcopy_value */
+ value_init_double, /* value_init */
+ NULL, /* value_free */
+ value_copy_double, /* value_copy */
+ NULL, /* value_peek_pointer */
+ "d", /* collect_format */
+ value_collect_double, /* collect_value */
+ "p", /* lcopy_format */
+ value_lcopy_double, /* lcopy_value */
};
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_DOUBLE, "gdouble", &info, &finfo, 0);
*/
{
static const GTypeValueTable value_table = {
- value_string_init, /* value_init */
- value_string_free_value, /* value_free */
- value_string_copy_value, /* value_copy */
- value_pointer_peek_pointer, /* value_peek_pointer */
- "p", /* collect_format */
- value_string_collect_value, /* collect_value */
- "p", /* lcopy_format */
- value_string_lcopy_value, /* lcopy_value */
+ value_init_string, /* value_init */
+ value_free_string, /* value_free */
+ value_copy_string, /* value_copy */
+ value_peek_pointer0, /* value_peek_pointer */
+ "p", /* collect_format */
+ value_collect_string, /* collect_value */
+ "p", /* lcopy_format */
+ value_lcopy_string, /* lcopy_value */
};
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_STRING, "gstring", &info, &finfo, 0);
*/
{
static const GTypeValueTable value_table = {
- value_pointer_init, /* value_init */
- NULL, /* value_free */
- value_pointer_copy, /* value_copy */
- value_pointer_peek_pointer, /* value_peek_pointer */
- "p", /* collect_format */
- value_pointer_collect_value, /* collect_value */
- "p", /* lcopy_format */
- value_pointer_lcopy_value, /* lcopy_value */
+ value_init_pointer, /* value_init */
+ NULL, /* value_free */
+ value_copy_pointer, /* value_copy */
+ value_peek_pointer0, /* value_peek_pointer */
+ "p", /* collect_format */
+ value_collect_pointer, /* collect_value */
+ "p", /* lcopy_format */
+ value_lcopy_pointer, /* lcopy_value */
};
info.value_table = &value_table;
type = g_type_register_fundamental (G_TYPE_POINTER, "gpointer", &info, &finfo, 0);
g_assert (type == G_TYPE_POINTER);
}
-
- /* G_TYPE_CCALLBACK
- */
- {
- static const GTypeValueTable value_table = {
- value_ccallback_init, /* value_init */
- NULL, /* value_free */
- value_ccallback_copy, /* value_copy */
- NULL, /* value_peek_pointer */
- "pp", /* collect_format */
- value_ccallback_collect_value, /* collect_value */
- "pp", /* lcopy_format */
- value_ccallback_lcopy_value, /* lcopy_value */
- };
- info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_CCALLBACK, "GCCallback", &info, &finfo, 0);
- g_assert (type == G_TYPE_CCALLBACK);
- }
}
/* --- GValue functions --- */
void
g_value_set_char (GValue *value,
- gint8 v_char)
+ gchar v_char)
{
- g_return_if_fail (G_IS_VALUE_CHAR (value));
+ g_return_if_fail (G_VALUE_HOLDS_CHAR (value));
value->data[0].v_int = v_char;
}
-gint8
+gchar
g_value_get_char (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_CHAR (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_CHAR (value), 0);
return value->data[0].v_int;
}
void
g_value_set_uchar (GValue *value,
- guint8 v_uchar)
+ guchar v_uchar)
{
- g_return_if_fail (G_IS_VALUE_UCHAR (value));
+ g_return_if_fail (G_VALUE_HOLDS_UCHAR (value));
value->data[0].v_uint = v_uchar;
}
-guint8
+guchar
g_value_get_uchar (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_UCHAR (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_UCHAR (value), 0);
return value->data[0].v_uint;
}
g_value_set_boolean (GValue *value,
gboolean v_boolean)
{
- g_return_if_fail (G_IS_VALUE_BOOLEAN (value));
+ g_return_if_fail (G_VALUE_HOLDS_BOOLEAN (value));
- value->data[0].v_int = v_boolean;
+ value->data[0].v_int = v_boolean != FALSE;
}
gboolean
g_value_get_boolean (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_BOOLEAN (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_BOOLEAN (value), 0);
return value->data[0].v_int;
}
g_value_set_int (GValue *value,
gint v_int)
{
- g_return_if_fail (G_IS_VALUE_INT (value));
+ g_return_if_fail (G_VALUE_HOLDS_INT (value));
value->data[0].v_int = v_int;
}
gint
g_value_get_int (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_INT (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_INT (value), 0);
return value->data[0].v_int;
}
g_value_set_uint (GValue *value,
guint v_uint)
{
- g_return_if_fail (G_IS_VALUE_UINT (value));
+ g_return_if_fail (G_VALUE_HOLDS_UINT (value));
value->data[0].v_uint = v_uint;
}
guint
g_value_get_uint (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_UINT (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_UINT (value), 0);
return value->data[0].v_uint;
}
g_value_set_long (GValue *value,
glong v_long)
{
- g_return_if_fail (G_IS_VALUE_LONG (value));
+ g_return_if_fail (G_VALUE_HOLDS_LONG (value));
value->data[0].v_long = v_long;
}
glong
g_value_get_long (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_LONG (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_LONG (value), 0);
return value->data[0].v_long;
}
g_value_set_ulong (GValue *value,
gulong v_ulong)
{
- g_return_if_fail (G_IS_VALUE_ULONG (value));
+ g_return_if_fail (G_VALUE_HOLDS_ULONG (value));
value->data[0].v_ulong = v_ulong;
}
gulong
g_value_get_ulong (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_ULONG (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_ULONG (value), 0);
return value->data[0].v_ulong;
}
g_value_set_float (GValue *value,
gfloat v_float)
{
- g_return_if_fail (G_IS_VALUE_FLOAT (value));
+ g_return_if_fail (G_VALUE_HOLDS_FLOAT (value));
value->data[0].v_float = v_float;
}
gfloat
g_value_get_float (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_FLOAT (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_FLOAT (value), 0);
return value->data[0].v_float;
}
g_value_set_double (GValue *value,
gdouble v_double)
{
- g_return_if_fail (G_IS_VALUE_DOUBLE (value));
+ g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value));
value->data[0].v_double = v_double;
}
gdouble
g_value_get_double (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_DOUBLE (value), 0);
+ g_return_val_if_fail (G_VALUE_HOLDS_DOUBLE (value), 0);
return value->data[0].v_double;
}
g_value_set_string (GValue *value,
const gchar *v_string)
{
- g_return_if_fail (G_IS_VALUE_STRING (value));
+ g_return_if_fail (G_VALUE_HOLDS_STRING (value));
if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
value->data[1].v_uint = 0;
g_value_set_static_string (GValue *value,
const gchar *v_string)
{
- g_return_if_fail (G_IS_VALUE_STRING (value));
+ g_return_if_fail (G_VALUE_HOLDS_STRING (value));
if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
g_free (value->data[0].v_pointer);
value->data[0].v_pointer = (gchar*) v_string;
}
+void
+g_value_set_string_take_ownership (GValue *value,
+ gchar *v_string)
+{
+ g_return_if_fail (G_VALUE_HOLDS_STRING (value));
+
+ if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
+ value->data[1].v_uint = 0;
+ else
+ g_free (value->data[0].v_pointer);
+ value->data[0].v_pointer = v_string;
+}
+
G_CONST_RETURN gchar*
g_value_get_string (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_STRING (value), NULL);
+ g_return_val_if_fail (G_VALUE_HOLDS_STRING (value), NULL);
return value->data[0].v_pointer;
}
gchar*
g_value_dup_string (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_STRING (value), NULL);
+ g_return_val_if_fail (G_VALUE_HOLDS_STRING (value), NULL);
return g_strdup (value->data[0].v_pointer);
}
g_value_set_pointer (GValue *value,
gpointer v_pointer)
{
- g_return_if_fail (G_IS_VALUE_POINTER (value));
+ g_return_if_fail (G_VALUE_HOLDS_POINTER (value));
value->data[0].v_pointer = v_pointer;
}
gpointer
g_value_get_pointer (const GValue *value)
{
- g_return_val_if_fail (G_IS_VALUE_POINTER (value), NULL);
+ g_return_val_if_fail (G_VALUE_HOLDS_POINTER (value), NULL);
return value->data[0].v_pointer;
}
-
-void
-g_value_set_ccallback (GValue *value,
- gpointer callback_func,
- gpointer callback_data)
-{
- g_return_if_fail (G_IS_VALUE_CCALLBACK (value));
-
- value->data[0].v_pointer = callback_func;
- value->data[1].v_pointer = callback_data;
-}
-
-void
-g_value_get_ccallback (const GValue *value,
- gpointer *callback_func,
- gpointer *callback_data)
-{
- g_return_if_fail (G_IS_VALUE_CCALLBACK (value));
-
- if (callback_func)
- *callback_func = value->data[0].v_pointer;
- if (callback_data)
- *callback_data = value->data[1].v_pointer;
-}
/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/* --- type macros --- */
-#define G_IS_VALUE_CHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR))
-#define G_IS_VALUE_UCHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR))
-#define G_IS_VALUE_BOOLEAN(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN))
-#define G_IS_VALUE_INT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT))
-#define G_IS_VALUE_UINT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT))
-#define G_IS_VALUE_LONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG))
-#define G_IS_VALUE_ULONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG))
-#define G_IS_VALUE_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
-#define G_IS_VALUE_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
-#define G_IS_VALUE_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
-#define G_IS_VALUE_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
-#define G_IS_VALUE_CCALLBACK(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CCALLBACK))
+#define G_VALUE_HOLDS_CHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR))
+#define G_VALUE_HOLDS_UCHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR))
+#define G_VALUE_HOLDS_BOOLEAN(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN))
+#define G_VALUE_HOLDS_INT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT))
+#define G_VALUE_HOLDS_UINT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT))
+#define G_VALUE_HOLDS_LONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG))
+#define G_VALUE_HOLDS_ULONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG))
+#define G_VALUE_HOLDS_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
+#define G_VALUE_HOLDS_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
+#define G_VALUE_HOLDS_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
+#define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
/* --- prototypes --- */
-void g_value_set_char (GValue *value,
- gint8 v_char);
-gint8 g_value_get_char (const GValue *value);
-void g_value_set_uchar (GValue *value,
- guint8 v_uchar);
-guint8 g_value_get_uchar (const GValue *value);
-void g_value_set_boolean (GValue *value,
+void g_value_set_char (GValue *value,
+ gchar v_char);
+gchar g_value_get_char (const GValue *value);
+void g_value_set_uchar (GValue *value,
+ guchar v_uchar);
+guchar g_value_get_uchar (const GValue *value);
+void g_value_set_boolean (GValue *value,
gboolean v_boolean);
-gboolean g_value_get_boolean (const GValue *value);
-void g_value_set_int (GValue *value,
- gint v_int);
-gint g_value_get_int (const GValue *value);
-void g_value_set_uint (GValue *value,
- guint v_uint);
-guint g_value_get_uint (const GValue *value);
-void g_value_set_long (GValue *value,
- glong v_long);
-glong g_value_get_long (const GValue *value);
-void g_value_set_ulong (GValue *value,
- gulong v_ulong);
-gulong g_value_get_ulong (const GValue *value);
-void g_value_set_float (GValue *value,
- gfloat v_float);
-gfloat g_value_get_float (const GValue *value);
-void g_value_set_double (GValue *value,
+gboolean g_value_get_boolean (const GValue *value);
+void g_value_set_int (GValue *value,
+ gint v_int);
+gint g_value_get_int (const GValue *value);
+void g_value_set_uint (GValue *value,
+ guint v_uint);
+guint g_value_get_uint (const GValue *value);
+void g_value_set_long (GValue *value,
+ glong v_long);
+glong g_value_get_long (const GValue *value);
+void g_value_set_ulong (GValue *value,
+ gulong v_ulong);
+gulong g_value_get_ulong (const GValue *value);
+void g_value_set_float (GValue *value,
+ gfloat v_float);
+gfloat g_value_get_float (const GValue *value);
+void g_value_set_double (GValue *value,
gdouble v_double);
-gdouble g_value_get_double (const GValue *value);
-void g_value_set_string (GValue *value,
+gdouble g_value_get_double (const GValue *value);
+void g_value_set_string (GValue *value,
const gchar *v_string);
-void g_value_set_static_string (GValue *value,
+void g_value_set_static_string (GValue *value,
const gchar *v_string);
-G_CONST_RETURN gchar* g_value_get_string (const GValue *value);
-gchar* g_value_dup_string (const GValue *value);
-void g_value_set_pointer (GValue *value,
+G_CONST_RETURN gchar* g_value_get_string (const GValue *value);
+gchar* g_value_dup_string (const GValue *value);
+void g_value_set_pointer (GValue *value,
gpointer v_pointer);
-gpointer g_value_get_pointer (const GValue *value);
-void g_value_set_ccallback (GValue *value,
- gpointer callback_func,
- gpointer callback_data);
-void g_value_get_ccallback (const GValue *value,
- gpointer *callback_func,
- gpointer *callback_data);
+gpointer g_value_get_pointer (const GValue *value);
+
+
+/* --- marshaller specific --- */
+void g_value_set_string_take_ownership (GValue *value,
+ gchar *v_string);
+
+
#ifdef __cplusplus
}
g_qsort_with_data (gconstpointer pbase,
gint total_elems,
size_t size,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
register char *base_ptr = (char *) pbase;
void g_qsort_with_data (gconstpointer pbase,
gint total_elems,
size_t size,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
G_END_DECLS
while (l1 && l2)
{
if (use_data)
- cmp = ((GCompareFuncData) compare_func) (l1->data, l2->data, user_data);
+ cmp = ((GCompareDataFunc) compare_func) (l1->data, l2->data, user_data);
else
cmp = ((GCompareFunc) compare_func) (l1->data, l2->data);
GSList *
g_slist_sort_with_data (GSList *list,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data)
{
return g_slist_sort_real (list, (GFunc) compare_func, TRUE, user_data);
GSList* g_slist_sort (GSList *list,
GCompareFunc compare_func);
GSList* g_slist_sort_with_data (GSList *list,
- GCompareFuncData compare_func,
+ GCompareDataFunc compare_func,
gpointer user_data);
gpointer g_slist_nth_data (GSList *list,
guint n);
}
static void
-g_string_sprintfa_int (GString *string,
- const gchar *fmt,
- va_list args)
+g_string_printfa_internal (GString *string,
+ const gchar *fmt,
+ va_list args)
{
gchar *buffer;
}
void
-g_string_sprintf (GString *string,
- const gchar *fmt,
- ...)
+g_string_printf (GString *string,
+ const gchar *fmt,
+ ...)
{
va_list args;
g_string_truncate (string, 0);
va_start (args, fmt);
- g_string_sprintfa_int (string, fmt, args);
+ g_string_printfa_internal (string, fmt, args);
va_end (args);
}
void
-g_string_sprintfa (GString *string,
- const gchar *fmt,
- ...)
+g_string_printfa (GString *string,
+ const gchar *fmt,
+ ...)
{
va_list args;
va_start (args, fmt);
- g_string_sprintfa_int (string, fmt, args);
+ g_string_printfa_internal (string, fmt, args);
va_end (args);
}
gint len);
GString* g_string_down (GString *string);
GString* g_string_up (GString *string);
-void g_string_sprintf (GString *string,
+void g_string_printf (GString *string,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
-void g_string_sprintfa (GString *string,
+void g_string_printfa (GString *string,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
+/* compatibility */
+#define g_string_sprintf g_string_printf
+#define g_string_sprintfa g_string_printfa
G_END_DECLS
struct _GRealTree
{
GTreeNode *root;
- GCompareFuncData key_compare;
+ GCompareDataFunc key_compare;
gpointer key_compare_data;
};
gpointer value);
static void g_tree_node_destroy (GTreeNode *node);
static GTreeNode* g_tree_node_insert (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer comp_data,
gpointer key,
gpointer value,
gint *inserted);
static GTreeNode* g_tree_node_remove (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer comp_data,
gconstpointer key);
static GTreeNode* g_tree_node_balance (GTreeNode *node);
static GTreeNode* g_tree_node_restore_right_balance (GTreeNode *node,
gint old_balance);
static gpointer g_tree_node_lookup (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer comp_data,
gconstpointer key);
static gint g_tree_node_count (GTreeNode *node);
}
}
-GTree* g_tree_new_udata(GCompareFuncData key_compare_func,
+GTree* g_tree_new_udata(GCompareDataFunc key_compare_func,
gpointer key_compare_data)
{
GRealTree *rtree;
GTree*
g_tree_new (GCompareFunc key_compare_func)
{
- return g_tree_new_udata ((GCompareFuncData) key_compare_func, NULL);
+ return g_tree_new_udata ((GCompareDataFunc) key_compare_func, NULL);
}
static GTreeNode*
g_tree_node_insert (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer compare_data,
gpointer key,
gpointer value,
static GTreeNode*
g_tree_node_remove (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer compare_data,
gconstpointer key)
{
static gpointer
g_tree_node_lookup (GTreeNode *node,
- GCompareFuncData compare,
+ GCompareDataFunc compare,
gpointer compare_data,
gconstpointer key)
{
/* Balanced binary trees
*/
GTree* g_tree_new (GCompareFunc key_compare_func);
-GTree* g_tree_new_with_data (GCompareFuncData key_compare_func,
+GTree* g_tree_new_with_data (GCompareDataFunc key_compare_func,
gpointer user_data);
void g_tree_destroy (GTree *tree);
void g_tree_insert (GTree *tree,
typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b);
-typedef gint (*GCompareFuncData) (gconstpointer a,
+typedef gint (*GCompareDataFunc) (gconstpointer a,
gconstpointer b,
gpointer user_data);
typedef gboolean (*GEqualFunc) (gconstpointer a,