From 837d3998a66201bd38a7f9f3e1a6bf1c4eeb7936 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Sun, 6 Sep 2020 23:47:58 -0700 Subject: [PATCH] Imported Upstream version 2.43.1 --- .gitignore | 3 + NEWS | 25 ++ configure.ac | 6 +- docs/reference/Doxyfile.in | 4 +- gio/src/gio_docs.xml | 337 +++++++++++++++++++++-- gio/src/gio_enums.defs | 16 +- gio/src/gio_methods.defs | 62 ++++- gio/src/gio_signals.defs | 2 +- gio/src/resource.ccg | 63 ++++- gio/src/resource.hg | 212 ++++++++++++++- glib/glibmm.h | 8 +- glib/glibmm/objectbase.h | 5 +- glib/glibmm/property.h | 32 ++- glib/glibmm/propertyproxy.h | 5 - glib/src/binding.ccg | 148 ++++++++++ glib/src/binding.hg | 423 +++++++++++++++++++++++++++++ glib/src/bytes.hg | 4 +- glib/src/checksum.hg | 16 +- glib/src/filelist.am | 2 + glib/src/glib.defs | 1 + glib/src/glib_docs.xml | 148 +++++++++- glib/src/glib_functions.defs | 24 ++ glib/src/glib_signals.defs | 78 ++++++ glib/src/gobject_enums.defs | 6 +- glib/src/gobject_functions.defs | 7 + tests/giomm_tls_client/main.cc | 12 +- tools/extra_defs_gen/generate_defs_glib.cc | 5 +- tools/generate_wrap_init.pl.in | 3 +- tools/gmmproc.in | 11 +- tools/m4/convert_gio.m4 | 5 + tools/m4/convert_glib.m4 | 1 + tools/m4/gerror.m4 | 7 +- tools/pm/DocsParser.pm | 15 +- tools/pm/Output.pm | 37 ++- tools/pm/WrapParser.pm | 14 +- 35 files changed, 1620 insertions(+), 127 deletions(-) create mode 100644 glib/src/binding.ccg create mode 100644 glib/src/binding.hg create mode 100644 glib/src/glib_signals.defs diff --git a/.gitignore b/.gitignore index d5a8d64..dc64b96 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ giommconfig.h /docs/doc-install.pl /docs/doc-postprocess.pl /docs/doxygen.css +/docs/doxygen-extra.css /docs/tagfile-to-devhelp2.xsl /docs/reference/Doxyfile /docs/reference/doxygen.log @@ -96,6 +97,8 @@ giommconfig.h /glib/glibmm-*.pc /glib/glibmm/balancedtree.cc /glib/glibmm/balancedtree.h +/glib/glibmm/binding.cc +/glib/glibmm/binding.h /glib/glibmm/bytearray.cc /glib/glibmm/bytearray.h /glib/glibmm/bytes.cc diff --git a/NEWS b/NEWS index 652d05a..616f720 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,28 @@ +2.43.1 (unstable): + +gmmproc: +* Tidy up the generation of enum docs + (Kjell Ahlstedt) +* _WRAP_GERROR: Add documentation to the generated enum Code. + (Kjell Ahlstedt) +* Change messages that MS Visual Studio can misunderstand. + (Kjell Ahlstedt) +* Warn when an ignored method or signal doesn't exist. + (Marcin Kolny) Bug #737212. + +Glib: +* Add Binding. + (Kjell Ahlstedt) Bug #738663. +* Checksum::ChecksumType: Remove erroneous documentation + (Kjell Ahlstedt) +* Property: Add some documentation. + (Kjell Ahlstedt) Bug #523043. + +Gio: + Add Resource. + (Kjell Ahlstedt) + + 2.42: API additions since 2.40: diff --git a/configure.ac b/configure.ac index 37f61a8..6a22c4e 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ ## You should have received a copy of the GNU Lesser General Public License ## along with this library. If not, see . -AC_INIT([glibmm], [2.42.0], +AC_INIT([glibmm], [2.43.1], [http://bugzilla.gnome.org/enter_bug.cgi?product=glibmm], [glibmm], [http://www.gtkmm.org/]) AC_PREREQ([2.59]) @@ -30,7 +30,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) AM_MAINTAINER_MODE AC_ARG_VAR([ACLOCAL_FLAGS], [aclocal flags, e.g. -I ]) -MM_PREREQ([0.9.6]) +MM_PREREQ([0.9.7]) MM_INIT_MODULE([glibmm-2.4]) MM_INIT_MODULE([giomm-2.4]) @@ -60,7 +60,7 @@ AS_IF([test "x$enable_static" = xyes], AC_DEFINE([GIOMM_STATIC_LIB], [1], [Define if giomm is built as a static library]) ]) -glibreq='2.0 >= 2.42.0' +glibreq='2.0 >= 2.43.1' GLIBMM_MODULES="sigc++-2.0 >= 2.2.10 glib-$glibreq gobject-$glibreq gmodule-$glibreq" GIOMM_MODULES="$GLIBMM_MODULES gio-$glibreq" diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index 2f5242b..55f7c97 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -168,8 +168,8 @@ HTML_OUTPUT = html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = -HTML_STYLESHEET = "@abs_top_srcdir@/docs/doxygen.css" -HTML_EXTRA_STYLESHEET = +HTML_STYLESHEET = +HTML_EXTRA_STYLESHEET = "$(MMDOCTOOLDIR)/doxygen-extra.css" HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 diff --git a/gio/src/gio_docs.xml b/gio/src/gio_docs.xml index e6a2b32..1ddcc56 100644 --- a/gio/src/gio_docs.xml +++ b/gio/src/gio_docs.xml @@ -1915,10 +1915,6 @@ Since: 2.26 The native credentials type is a <type>struct cmsgcred</type>. - - The native credentials type is a <type>struct unpcbid</type>. - - The native credentials type is a <type>struct sockpeercred</type>. Added in 2.30. @@ -1927,6 +1923,10 @@ Since: 2.26 The native credentials type is a <type>ucred_t</type>. Added in 2.40. + + The native credentials type is a <type>struct unpcbid</type>. + + @@ -3670,7 +3670,7 @@ Error codes returned by GIO functions. Note that this domain may be extended in future GLib releases. In general, new error codes either only apply to new APIs, or else -replace #G_IO_ERROR_FAILED in cases that were not explicitly +replace %G_IO_ERROR_FAILED in cases that were not explicitly distinguished before. You should therefore avoid writing code like |[<!-- language="C" --> if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED)) @@ -3873,6 +3873,18 @@ Since 2.26 Broken pipe. Since 2.36 + + Connection closed by peer. Note that this +is the same code as %G_IO_ERROR_BROKEN_PIPE; before 2.44 some +"connection closed" errors returned %G_IO_ERROR_BROKEN_PIPE, but others +returned %G_IO_ERROR_FAILED. Now they should all return the same +value, which has this more logical name. Since 2.44. + + + + Transport endpoint is not connected. Since 2.44 + + @@ -24309,6 +24321,13 @@ Resets @cancellable to its uncancelled state. If cancellable is currently in use by any cancellable operation then the behavior of this function is undefined. +Note that it is generally not a good idea to reuse an existing +cancellable for more operations after it has been cancelled once, +as this function might tempt you to do. The recommended practice +is to drop the reference to a cancellable after cancelling it, +and let it die with the outstanding async operations. You should +create a fresh cancellable for further async operations. + @@ -24350,6 +24369,8 @@ with g_source_add_child_source() to add cancellability to it. For convenience, you can call this with a %NULL #GCancellable, in which case the source will never trigger. +The new #GSource will hold a reference to the #GCancellable. + Since: 2.28 @@ -36184,7 +36205,7 @@ Sets the file enumerator as having pending operations. -Checks equality of two given #GFiles. +Checks if the two given #GFiles refer to the same file. Note that two #GFiles that differ can still refer to the same file on the filesystem due to various forms of filename @@ -36577,6 +36598,9 @@ pathname match @prefix. Only full pathname elements are matched, so a path like /foo is not considered a prefix of /foobar, only of /foo/bar. +A #GFile is not a prefix of itself. If you want to check for +equality, use g_file_equal(). + This call does no I/O, as it works purely on names. As such it can sometimes return %FALSE even if @file is inside a @prefix (from a filesystem point of view), because the prefix of @file is an alias @@ -40196,14 +40220,14 @@ by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. -If you pass in a non-%NULL @etag value, then this value is -compared to the current entity tag of the file, and if they differ -an %G_IO_ERROR_WRONG_ETAG error is returned. This generally means -that the file has been changed since you last read it. You can get -the new etag from g_file_output_stream_get_etag() after you've -finished writing and closed the #GFileOutputStream. When you load -a new file you can use g_file_input_stream_query_info() to get -the etag of the file. +If you pass in a non-%NULL @etag value and @file already exists, then +this value is compared to the current entity tag of the file, and if +they differ an %G_IO_ERROR_WRONG_ETAG error is returned. This +generally means that the file has been changed since you last read +it. You can get the new etag from g_file_output_stream_get_etag() +after you've finished writing and closed the #GFileOutputStream. When +you load a new file you can use g_file_input_stream_query_info() to +get the etag of the file. If @make_backup is %TRUE, this function will attempt to make a backup of the current file before overwriting it. If this fails @@ -43039,8 +43063,14 @@ stream, %TRUE is returned, and @bytes_read is set to the number of bytes read into @buffer. If there is an error during the operation %FALSE is returned and @error -is set to indicate the error status, @bytes_read is updated to contain -the number of bytes read into @buffer before the error occurred. +is set to indicate the error status. + +As a special exception to the normal conventions for functions that +use #GError, if this function returns %FALSE (and sets @error) then +@bytes_read will be set to the number of bytes that were successfully +read before the error was encountered. This functionality is only +available from C. If you need it from another language then you must +write your own loop around g_input_stream_read(). @@ -43075,6 +43105,94 @@ read data into (which should be at least count bytes long). + + +Request an asynchronous read of @count bytes from the stream into the +buffer starting at @buffer. + +This is the asynchronous equivalent of g_input_stream_read_all(). + +Call g_input_stream_read_all_finish() to collect the result. + +Any outstanding I/O request with higher priority (lower numerical +value) will be executed before an outstanding request with lower +priority. Default priority is %G_PRIORITY_DEFAULT. + +Since: 2.44 + + + + + A #GInputStream + + + + a buffer to +read data into (which should be at least count bytes long) + + + + the number of bytes that will be read from the stream + + + + the [I/O priority][io-priority] of the request + + + + optional #GCancellable object, %NULL to ignore + + + + callback to call when the request is satisfied + + + + the data to pass to callback function + + + + + + + + +Finishes an asynchronous stream read operation started with +g_input_stream_read_all_async(). + +As a special exception to the normal conventions for functions that +use #GError, if this function returns %FALSE (and sets @error) then +@bytes_read will be set to the number of bytes that were successfully +read before the error was encountered. This functionality is only +available from C. If you need it from another language then you must +write your own loop around g_input_stream_read_async(). + +Since: 2.44 + + + + + a #GInputStream + + + + a #GAsyncResult + + + + location to store the number of bytes that was read from the stream + + + + a #GError location to store the error occurring, or %NULL to ignore + + + + %TRUE on success, %FALSE if there was an error + + + + Request an asynchronous read of @count bytes from the stream into the buffer @@ -47414,6 +47532,12 @@ Since: 2.26 Creates a new #GSocketConnectable for connecting to the given @hostname and @port. +Note that depending on the configuration of the machine, a +@hostname of `localhost` may refer to the IPv4 loopback address +only, or to both IPv4 and IPv6; use +g_network_address_new_loopback() to create a #GNetworkAddress that +is guaranteed to resolve to both addresses. + Since: 2.22 @@ -47432,6 +47556,35 @@ Since: 2.22 + + +Creates a new #GSocketConnectable for connecting to the local host +over a loopback connection to the given @port. This is intended for +use in connecting to local services which may be running on IPv4 or +IPv6. + +The connectable will return IPv4 and IPv6 loopback addresses, +regardless of how the host resolves `localhost`. By contrast, +g_network_address_new() will often only return an IPv4 address when +resolving `localhost`, and an IPv6 address for `localhost6`. + +g_network_address_get_hostname() will always return `localhost` for +#GNetworkAddresses created with this constructor. + +Since: 2.44 + + + + + the port + + + + the new #GNetworkAddress + + + + Creates a new #GSocketConnectable for connecting to the given @@ -48784,8 +48937,15 @@ On a successful write of @count bytes, %TRUE is returned, and @bytes_written is set to @count. If there is an error during the operation %FALSE is returned and @error -is set to indicate the error status, @bytes_written is updated to contain -the number of bytes written into the stream before the error occurred. +is set to indicate the error status. + +As a special exception to the normal conventions for functions that +use #GError, if this function returns %FALSE (and sets @error) then +@bytes_written will be set to the number of bytes that were +successfully written before the error was encountered. This +functionality is only available from C. If you need it from another +language then you must write your own loop around +g_output_stream_write(). @@ -48820,6 +48980,99 @@ written to the stream + + +Request an asynchronous write of @count bytes from @buffer into +the stream. When the operation is finished @callback will be called. +You can then call g_output_stream_write_all_finish() to get the result of the +operation. + +This is the asynchronous version of g_output_stream_write_all(). + +Call g_output_stream_write_all_finish() to collect the result. + +Any outstanding I/O request with higher priority (lower numerical +value) will be executed before an outstanding request with lower +priority. Default priority is %G_PRIORITY_DEFAULT. + +Note that no copy of @buffer will be made, so it must stay valid +until @callback is called. + +Since: 2.44 + + + + + A #GOutputStream + + + + the buffer containing the data to write + + + + the number of bytes to write + + + + the io priority of the request + + + + optional #GCancellable object, %NULL to ignore + + + + callback to call when the request is satisfied + + + + the data to pass to callback function + + + + + + + + +Finishes an asynchronous stream write operation started with +g_output_stream_write_all_async(). + +As a special exception to the normal conventions for functions that +use #GError, if this function returns %FALSE (and sets @error) then +@bytes_written will be set to the number of bytes that were +successfully written before the error was encountered. This +functionality is only available from C. If you need it from another +language then you must write your own loop around +g_output_stream_write_async(). + +Since: 2.44 + + + + + a #GOutputStream + + + + a #GAsyncResult + + + + location to store the number of bytes that was written to the stream + + + + a #GError location to store the error occurring, or %NULL to ignore. + + + + %TRUE on success, %FALSE if there was an error + + + + Request an asynchronous write of @count bytes from @buffer into @@ -61005,7 +61258,7 @@ Since: 2.22 -This enabled graceful disconnects on close. A graceful disconnect +This enables graceful disconnects on close. A graceful disconnect means that we signal the receiving end that the connection is terminated and wait for it to close the connection before closing the connection. @@ -61561,8 +61814,17 @@ and its contents when you are done with it. -Creates a #GTlsCertificate from the PEM-encoded data in @file. If -@file cannot be read or parsed, the function will return %NULL and +Creates a #GTlsCertificate from the PEM-encoded data in @file. The +returned certificate will be the first certificate found in @file. As +of GLib 2.44, if @file contains more certificates it will try to load +a certificate chain. All certificates will be verified in the order +found (top-level certificate should be the last one in the file) and +the #GTlsCertificate:issuer property of each certificate will be set +accordingly if the verification succeeds. If any certificate in the +chain cannot be verified, the first certificate in the file will +still be returned. + +If @file cannot be read or parsed, the function will return %NULL and set @error. Otherwise, this behaves like g_tls_certificate_new_from_pem(). @@ -61587,16 +61849,27 @@ Since: 2.28 Creates a #GTlsCertificate from the PEM-encoded data in @cert_file -and @key_file. If either file cannot be read or parsed, the -function will return %NULL and set @error. Otherwise, this behaves -like g_tls_certificate_new_from_pem(). +and @key_file. The returned certificate will be the first certificate +found in @cert_file. As of GLib 2.44, if @cert_file contains more +certificates it will try to load a certificate chain. All +certificates will be verified in the order found (top-level +certificate should be the last one in the file) and the +#GTlsCertificate:issuer property of each certificate will be set +accordingly if the verification succeeds. If any certificate in the +chain cannot be verified, the first certificate in the file will +still be returned. + +If either file cannot be read or parsed, the function will return +%NULL and set @error. Otherwise, this behaves like +g_tls_certificate_new_from_pem(). Since: 2.28 - file containing a PEM-encoded certificate to import + file containing one or more PEM-encoded certificates to +import @@ -61615,14 +61888,20 @@ Since: 2.28 -Creates a new #GTlsCertificate from the PEM-encoded data in @data. -If @data includes both a certificate and a private key, then the +Creates a #GTlsCertificate from the PEM-encoded data in @data. If +@data includes both a certificate and a private key, then the returned certificate will include the private key data as well. (See the #GTlsCertificate:private-key-pem property for information about supported formats.) -If @data includes multiple certificates, only the first one will be -parsed. +The returned certificate will be the first certificate found in +@data. As of GLib 2.44, if @data contains more certificates it will +try to load a certificate chain. All certificates will be verified in +the order found (top-level certificate should be the last one in the +file) and the #GTlsCertificate:issuer property of each certificate +will be set accordingly if the verification succeeds. If any +certificate in the chain cannot be verified, the first certificate in +the file will still be returned. Since: 2.28 diff --git a/gio/src/gio_enums.defs b/gio/src/gio_enums.defs index 3e08b5f..141c1b6 100644 --- a/gio/src/gio_enums.defs +++ b/gio/src/gio_enums.defs @@ -451,7 +451,9 @@ ;; G_IO_ERROR_PROXY_AUTH_FAILED, ;; G_IO_ERROR_PROXY_NEED_AUTH, ;; G_IO_ERROR_PROXY_NOT_ALLOWED, -;; G_IO_ERROR_BROKEN_PIPE +;; G_IO_ERROR_BROKEN_PIPE, +;; G_IO_ERROR_CONNECTION_CLOSED = G_IO_ERROR_BROKEN_PIPE, +;; G_IO_ERROR_NOT_CONNECTED ;; } GIOErrorEnum; (define-enum-extended IOErrorEnum @@ -504,6 +506,8 @@ '("proxy-need-auth" "G_IO_ERROR_PROXY_NEED_AUTH" "42") '("proxy-not-allowed" "G_IO_ERROR_PROXY_NOT_ALLOWED" "43") '("broken-pipe" "G_IO_ERROR_BROKEN_PIPE" "44") + '("connection-closed" "G_IO_ERROR_CONNECTION_CLOSED" "44") + '("not-connected" "G_IO_ERROR_NOT_CONNECTED" "45") ) ) @@ -1213,9 +1217,9 @@ ;; G_CREDENTIALS_TYPE_INVALID, ;; G_CREDENTIALS_TYPE_LINUX_UCRED, ;; G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED, -;; G_CREDENTIALS_TYPE_NETBSD_UNPCBID, ;; G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED, -;; G_CREDENTIALS_TYPE_SOLARIS_UCRED +;; G_CREDENTIALS_TYPE_SOLARIS_UCRED, +;; G_CREDENTIALS_TYPE_NETBSD_UNPCBID ;; } GCredentialsType; (define-enum-extended CredentialsType @@ -1225,9 +1229,9 @@ '("invalid" "G_CREDENTIALS_TYPE_INVALID" "0") '("linux-ucred" "G_CREDENTIALS_TYPE_LINUX_UCRED" "1") '("freebsd-cmsgcred" "G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED" "2") - '("netbsd-unpcbid" "G_CREDENTIALS_TYPE_NETBSD_UNPCBID" "3") - '("openbsd-sockpeercred" "G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED" "4") - '("solaris-ucred" "G_CREDENTIALS_TYPE_SOLARIS_UCRED" "5") + '("openbsd-sockpeercred" "G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED" "3") + '("solaris-ucred" "G_CREDENTIALS_TYPE_SOLARIS_UCRED" "4") + '("netbsd-unpcbid" "G_CREDENTIALS_TYPE_NETBSD_UNPCBID" "5") ) ) diff --git a/gio/src/gio_methods.defs b/gio/src/gio_methods.defs index d8b3729..1f43a3a 100644 --- a/gio/src/gio_methods.defs +++ b/gio/src/gio_methods.defs @@ -1058,6 +1058,8 @@ '("proxy-need-auth" "G_IO_ERROR_PROXY_NEED_AUTH") '("proxy-not-allowed" "G_IO_ERROR_PROXY_NOT_ALLOWED") '("broken-pipe" "G_IO_ERROR_BROKEN_PIPE") + '("connection-closed" "G_IO_ERROR_CONNECTION_CLOSED") + '("not-connected" "G_IO_ERROR_NOT_CONNECTED") ) ) @@ -1495,9 +1497,9 @@ '("invalid" "G_CREDENTIALS_TYPE_INVALID") '("linux-ucred" "G_CREDENTIALS_TYPE_LINUX_UCRED") '("freebsd-cmsgcred" "G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED") - '("netbsd-unpcbid" "G_CREDENTIALS_TYPE_NETBSD_UNPCBID") '("openbsd-sockpeercred" "G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED") '("solaris-ucred" "G_CREDENTIALS_TYPE_SOLARIS_UCRED") + '("netbsd-unpcbid" "G_CREDENTIALS_TYPE_NETBSD_UNPCBID") ) ) @@ -9925,6 +9927,31 @@ ) ) +(define-method read_all_async + (of-object "GInputStream") + (c-name "g_input_stream_read_all_async") + (return-type "none") + (parameters + '("void*" "buffer") + '("gsize" "count") + '("int" "io_priority") + '("GCancellable*" "cancellable") + '("GAsyncReadyCallback" "callback") + '("gpointer" "user_data") + ) +) + +(define-method read_all_finish + (of-object "GInputStream") + (c-name "g_input_stream_read_all_finish") + (return-type "gboolean") + (parameters + '("GAsyncResult*" "result") + '("gsize*" "bytes_read") + '("GError**" "error") + ) +) + (define-method read_bytes_async (of-object "GInputStream") (c-name "g_input_stream_read_bytes_async") @@ -11896,6 +11923,14 @@ ) ) +(define-function g_network_address_new_loopback + (c-name "g_network_address_new_loopback") + (return-type "GSocketConnectable*") + (parameters + '("guint16" "port") + ) +) + (define-function g_network_address_parse (c-name "g_network_address_parse") (return-type "GSocketConnectable*") @@ -12477,6 +12512,31 @@ ) ) +(define-method write_all_async + (of-object "GOutputStream") + (c-name "g_output_stream_write_all_async") + (return-type "none") + (parameters + '("const-void*" "buffer") + '("gsize" "count") + '("int" "io_priority") + '("GCancellable*" "cancellable") + '("GAsyncReadyCallback" "callback") + '("gpointer" "user_data") + ) +) + +(define-method write_all_finish + (of-object "GOutputStream") + (c-name "g_output_stream_write_all_finish") + (return-type "gboolean") + (parameters + '("GAsyncResult*" "result") + '("gsize*" "bytes_written") + '("GError**" "error") + ) +) + (define-method write_bytes_async (of-object "GOutputStream") (c-name "g_output_stream_write_bytes_async") diff --git a/gio/src/gio_signals.defs b/gio/src/gio_signals.defs index 6209d02..114a01f 100644 --- a/gio/src/gio_signals.defs +++ b/gio/src/gio_signals.defs @@ -2044,7 +2044,7 @@ (define-property use-ssl3 (of-object "GTlsClientConnection") (prop-type "GParamBoolean") - (docs "Use SSL 3.0 rather than trying to use TLS 1.x") + (docs "Use fallback version of SSL/TLS rather than most recent version") (readable #t) (writable #t) (construct-only #f) diff --git a/gio/src/resource.ccg b/gio/src/resource.ccg index b80d676..4a4b716 100644 --- a/gio/src/resource.ccg +++ b/gio/src/resource.ccg @@ -1,5 +1,3 @@ -// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*- - /* Copyright (C) 2012 The giomm Development Team * * This library is free software; you can redistribute it and/or @@ -21,5 +19,66 @@ namespace Gio { +// Hand-coded because we want ResourceFlags& instead of guint32&. +void Resource::get_info(const std::string& path, gsize& size, + ResourceFlags& flags, ResourceLookupFlags lookup_flags) const +{ + guint32 file_flags = 0; + GError* gerror = 0; + // Ignore the gboolean return value from g_resource_get_info(). + // gerror is set if and only if the return value is FALSE. + g_resource_get_info(const_cast(gobj()), path.c_str(), + (GResourceLookupFlags)lookup_flags, &size, &file_flags, &gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); + flags = static_cast(file_flags); +} + +void Resource::get_file_exists(const std::string& path, ResourceLookupFlags lookup_flags) const +{ + GError* gerror = 0; + g_resource_get_info(const_cast(gobj()), path.c_str(), + (GResourceLookupFlags)lookup_flags, 0, 0, &gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); +} + +bool Resource::get_file_exists_nothrow(const std::string& path, ResourceLookupFlags lookup_flags) const +{ + return g_resource_get_info(const_cast(gobj()), path.c_str(), + (GResourceLookupFlags)lookup_flags, 0, 0, 0); +} + +// Hand-coded because we want ResourceFlags& instead of guint32&. +//static +void Resource::get_info_global(const std::string& path, gsize& size, + ResourceFlags& flags, ResourceLookupFlags lookup_flags) +{ + guint32 file_flags = 0; + GError* gerror = 0; + // Ignore the gboolean return value from g_resources_get_info(). + // gerror is set if and only if the return value is FALSE. + g_resources_get_info(path.c_str(), + (GResourceLookupFlags)lookup_flags, &size, &file_flags, &gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); + flags = static_cast(file_flags); +} + +//static +void Resource::get_file_exists_global(const std::string& path, ResourceLookupFlags lookup_flags) +{ + GError* gerror = 0; + g_resources_get_info(path.c_str(), + (GResourceLookupFlags)lookup_flags, 0, 0, &gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); +} + +//static +bool Resource::get_file_exists_global_nothrow(const std::string& path, ResourceLookupFlags lookup_flags) +{ + return g_resources_get_info(path.c_str(), (GResourceLookupFlags)lookup_flags, 0, 0, 0); +} } // namespace Gio diff --git a/gio/src/resource.hg b/gio/src/resource.hg index ad1ddd9..a74c469 100644 --- a/gio/src/resource.hg +++ b/gio/src/resource.hg @@ -1,5 +1,3 @@ -// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*- - /* Copyright (C) 2012 The gtkmm Development Team * * This library is free software; you can redistribute it and/or @@ -18,9 +16,18 @@ */ #include +#include +#include +#include +#include +#include _DEFS(giomm,gio) +#ifndef DOXYGEN_SHOULD_SKIP_THIS +typedef struct _GResource GResource; +#endif + namespace Gio { @@ -28,4 +35,205 @@ namespace Gio */ _WRAP_GERROR(ResourceError, GResourceError, G_RESOURCE_ERROR, NO_GTYPE) +_WRAP_ENUM(ResourceFlags, GResourceFlags) +_WRAP_ENUM(ResourceLookupFlags, GResourceLookupFlags) + +/** Resource framework. + * + * Applications and libraries often contain binary or textual data that is + * really part of the application, rather than user data. For instance + * Gtk::Builder .ui files, splashscreen images, Gio::Menu markup xml, CSS files, + * icons, etc. These are often shipped as files in `$datadir/appname`, or + * manually included as literal strings in the code. + * + * The Gio::Resource API and the glib-compile-resources program + * provide a convenient and efficient alternative to this which has some nice properties. You + * maintain the files as normal files, so its easy to edit them, but during the build the files + * are combined into a binary bundle that is linked into the executable. This means that loading + * the resource files is efficient (as they are already in memory, shared with other instances) and + * simple (no need to check for things like I/O errors or locate the files in the filesystem). It + * also makes it easier to create relocatable applications. + * + * Resource files can also be marked as compressed. Such files will be included in the resource bundle + * in a compressed form, but will be automatically uncompressed when the resource is used. This + * is very useful e.g. for larger text files that are parsed once (or rarely) and then thrown away. + * + * Resource files can also be marked to be preprocessed, by setting the value of the + * `preprocess` attribute to a comma-separated list of preprocessing options. + * The only options currently supported are: + * + *
+ *
xml-stripblanks
+ *
which will use the xmllint command + * to strip ignorable whitespace from the xml file. For this to work, + * the `XMLLINT` environment variable must be set to the full path to + * the xmllint executable, or xmllint must be in the `PATH`; otherwise + * the preprocessing step is skipped.
+ * + *
to-pixdata
+ *
which will use the gdk-pixbuf-pixdata command to convert + * images to the GdkPixdata format, which allows you to create pixbufs directly using the data inside + * the resource file, rather than an (uncompressed) copy of it. For this, the gdk-pixbuf-pixdata + * program must be in the PATH, or the `GDK_PIXBUF_PIXDATA` environment variable must be + * set to the full path to the gdk-pixbuf-pixdata executable; otherwise the resource compiler will + * abort.
+ *
+ * + * Resource bundles are created by the glib-compile-resources program + * which takes an xml file that describes the bundle, and a set of files that the xml references. These + * are combined into a binary resource bundle. + * + * An example resource description: + * @code + * + * + * + * data/splashscreen.png + * dialog.ui + * menumarkup.xml + * + * + * @endcode + * + * This will create a resource bundle with the following files: + * @code + * /org/gtk/Example/data/splashscreen.png + * /org/gtk/Example/dialog.ui + * /org/gtk/Example/menumarkup.xml + * @endcode + * + * Note that all resources in the process share the same namespace, so use java-style + * path prefixes (like in the above example) to avoid conflicts. + * + * You can then use glib-compile-resources to compile the xml to a binary bundle + * that you can load with Gio::Resource::create_from_file(). However, its more common to use the --generate-source and + * --generate-header arguments to create a source file and header to link directly into your application. + * + * Once a Gio::Resource has been created and registered all the data in it can be accessed globally in the process by + * using API calls like Gio::Resource::open_stream_from_global_resources() to stream the data + * or Gio::Resource::lookup_data_in_global_resources() to get a direct pointer + * to the data. You can also use uris like "resource:///org/gtk/Example/data/splashscreen.png" with Gio::File to access + * the resource data. + * + * There are two forms of the generated source, the default version uses the compiler support for constructor + * and destructor functions (where available) to automatically create and register the Gio::Resource on startup + * or library load time. If you pass --manual-register, two functions to register/unregister the resource is instead + * created. This requires an explicit initialization call in your application/library, but it works on all platforms, + * even on the minor ones where this is not available. (Constructor support is available for at least Win32, MacOS and Linux.) + * + * Note that resource data can point directly into the data segment of e.g. a library, so if you are unloading libraries + * during runtime you need to be very careful with keeping around pointers to data from a resource, as this goes away + * when the library is unloaded. However, in practice this is not generally a problem, since most resource accesses + * is for your own resources, and resource data is often used once, during parsing, and then released. + * + * @newin{2,44} + */ +class Resource +{ + _CLASS_OPAQUE_REFCOUNTED(Resource, GResource, NONE, g_resource_ref, g_resource_unref) + _IGNORE(g_resource_ref, g_resource_unref) + +public: + _WRAP_METHOD(static Glib::RefPtr create_from_data(const Glib::RefPtr& data), g_resource_new_from_data, errthrow) + _WRAP_METHOD(static Glib::RefPtr create_from_file(const std::string& filename), g_resource_load, errthrow) + _WRAP_METHOD(Glib::RefPtr open_stream(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const, g_resource_open_stream, errthrow) + _WRAP_METHOD(Glib::RefPtr lookup_data(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const, g_resource_lookup_data, errthrow) + +#m4 _CONVERSION(`char**',`std::vector',`Glib::ArrayHandler::array_to_vector($3, Glib::OWNERSHIP_DEEP)') + _WRAP_METHOD(std::vector enumerate_children(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const, g_resource_enumerate_children, errthrow) + + /** Looks for a file at the specified @a path in the resource and + * if found returns information about it. + * + * @a lookup_flags controls the behaviour of the lookup. + * + * @newin{2,44} + * + * @param path A pathname inside the resource. + * @param[out] size A location to place the length of the contents of the file. + * @param[out] flags A location to place the flags about the file. + * @param lookup_flags A ResourceLookupFlags. + * @throw Gio::ResourceError if the file was not found. + */ + void get_info(const std::string& path, gsize& size, ResourceFlags& flags, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const; + _IGNORE(g_resource_get_info) + + /** Looks for a file at the specified @a path in the resource. + * + * @a lookup_flags controls the behaviour of the lookup. + * + * @newin{2,44} + * + * @param path A pathname inside the resource. + * @param lookup_flags A ResourceLookupFlags. + * @throw Gio::ResourceError if the file was not found. + */ + void get_file_exists(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const; + + /** Looks for a file at the specified @a path in the resource. + * + * @a lookup_flags controls the behaviour of the lookup. + * This method returns a bool instead of throwing in exception in case of errors. + * + * @newin{2,44} + * + * @param path A pathname inside the resource. + * @param lookup_flags A ResourceLookupFlags. + * @return true if the file was found, false if there were errors. + */ + bool get_file_exists_nothrow(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE) const; + + // 'register' is a keyword. Can't be the name of a method. + _WRAP_METHOD(void register_global(), g_resources_register) + _WRAP_METHOD(void unregister_global(), g_resources_unregister) + _WRAP_METHOD(static Glib::RefPtr open_stream_global(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE), g_resources_open_stream, errthrow) + _WRAP_METHOD(static Glib::RefPtr lookup_data_global(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE), g_resources_lookup_data, errthrow) + _WRAP_METHOD(static std::vector enumerate_children_global(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE), g_resources_enumerate_children, errthrow) + + /** Looks for a file at the specified @a path in the set of + * globally registered resources and if found returns information about it. + * + * @a lookup_flags controls the behaviour of the lookup. + * + * @newin{2,44} + * + * @param path A pathname inside the resource. + * @param[out] size A location to place the length of the contents of the file. + * @param[out] flags A location to place the flags about the file. + * @param lookup_flags A ResourceLookupFlags. + * @throw Gio::ResourceError if the file was not found. + */ + static void get_info_global(const std::string& path, gsize& size, ResourceFlags& flags, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE); + _IGNORE(g_resources_get_info) + + /** Looks for a file at the specified @a path in the set of + * globally registered resources. + * + * @a lookup_flags controls the behaviour of the lookup. + * + * @newin{2,44} + * + * @param path A pathname inside the resource. + * @param lookup_flags A ResourceLookupFlags. + * @throw Gio::ResourceError if the file was not found. + */ + static void get_file_exists_global(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE); + + /** Looks for a file at the specified @a path in the set of + * globally registered resources. + * + * @a lookup_flags controls the behaviour of the lookup. + * This method returns a bool instead of throwing in exception in case of errors. + * + * @newin{2,44} + * + * @param path A pathname inside the resource. + * @param lookup_flags A ResourceLookupFlags. + * @return true if the file was found, false if there were errors. + */ + static bool get_file_exists_global_nothrow(const std::string& path, ResourceLookupFlags lookup_flags = RESOURCE_LOOKUP_FLAGS_NONE); + + _IGNORE(g_static_resource_init, g_static_resource_fini, g_static_resource_get_resource)dnl//Used only by the glib-compile-resources command +}; + } // namespace Gio diff --git a/glib/glibmm.h b/glib/glibmm.h index 296db7b..fb409f8 100644 --- a/glib/glibmm.h +++ b/glib/glibmm.h @@ -82,8 +82,8 @@ #include //#include //This must be included by the application, after system headers such as . -//Include this first because we need it to be the first thing to include , -//so we can do an undef trick to still use deprecated API in the header: +//Include this first because we need it to be the first thing to include , +//so we can do an undef trick to still use deprecated API in the header: #include #include @@ -91,6 +91,10 @@ #include #include #include +#ifndef GLIBMM_INCLUDED_FROM_WRAP_INIT_CC +// wrap_init.cc includes this file after it has cleared G_GNUC_CONST. +#include +#endif #include #include #include diff --git a/glib/glibmm/objectbase.h b/glib/glibmm/objectbase.h index 9c4c4e8..a3afd83 100644 --- a/glib/glibmm/objectbase.h +++ b/glib/glibmm/objectbase.h @@ -1,4 +1,3 @@ -// -*- c++ -*- #ifndef _GLIBMM_OBJECTBASE_H #define _GLIBMM_OBJECTBASE_H @@ -144,7 +143,9 @@ public: */ void thaw_notify(); - //TODO: Why are these virtual? + // Why are these virtual? + // Don't know why they were originally made virtual, but it came in handy when + // I wrapped GBinding in Glib::Binding. /Kjell /** Increment the reference count for this object. * You should never need to do this manually - use the object via a RefPtr instead. */ diff --git a/glib/glibmm/property.h b/glib/glibmm/property.h index 3b2b422..716d859 100644 --- a/glib/glibmm/property.h +++ b/glib/glibmm/property.h @@ -137,6 +137,36 @@ private: * A property can be used only as direct data member of a type, inheriting from * Glib::Object. A reference to the object must be passed to the constructor of * the property. + * + * You may register new properties for your class (actually for the underlying GType) + * simply by adding a Property instance as a class member. + * However, your constructor must call the Glib::ObjectBase constructor with a new GType name, + * in order to register a new GType. + * + * Example: + * @code + * class MyCellRenderer : public Gtk::CellRenderer + * { + * public: + * MyCellRenderer() + * : + * Glib::ObjectBase (typeid(MyCellRenderer)), + * Gtk::CellRenderer(), + * property_mybool (*this, "mybool", true), + * property_myint_ (*this, "myint", 42) + * {} + * + * virtual ~MyCellRenderer() {} + * + * // Glib::Property<> can be public, + * Glib::Property property_mybool; + * // or private, and combined with Glib::PropertyProxy<>. + * Glib::PropertyProxy property_myint() { return property_myint_.get_proxy(); } + * + * private: + * Glib::Property property_myint_; + * }; + * @endcode */ template class Property : public PropertyBase @@ -146,7 +176,7 @@ public: typedef Glib::Value ValueType; /** Constructs a property of the @a object with the specified @a name. - * For each instance of the object, the same property must be constructed with the same name + * For each instance of the object, the same property must be constructed with the same name. */ Property(Glib::Object& object, const Glib::ustring& name); diff --git a/glib/glibmm/propertyproxy.h b/glib/glibmm/propertyproxy.h index a41f549..5606503 100644 --- a/glib/glibmm/propertyproxy.h +++ b/glib/glibmm/propertyproxy.h @@ -38,11 +38,6 @@ namespace Glib * @endcode * * You may also receive notification when a property's value changes, by connecting to signal_changed(). - * - * You may register new properties for your class (actually for the underlying GType) - * simply by adding a PropertyProxy instance as a class member. - * However, your constructor must call the Glib::ObjectBase constructor with a new GType name, - * in order to register a new GType. */ template class PropertyProxy : public PropertyProxy_Base diff --git a/glib/src/binding.ccg b/glib/src/binding.ccg new file mode 100644 index 0000000..c9e839b --- /dev/null +++ b/glib/src/binding.ccg @@ -0,0 +1,148 @@ +/* Copyright (C) 2014 The glibmm Development Team + * + * 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.1 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, see . + */ + +#include +#include + +namespace +{ +struct BindingTransformSlots +{ + BindingTransformSlots( + const Glib::Binding::BindingTransformSlot& transform_to, + const Glib::Binding::BindingTransformSlot& transform_from) + : + from_source_to_target(transform_to), from_target_to_source(transform_from) + {} + + Glib::Binding::BindingTransformSlot from_source_to_target; + Glib::Binding::BindingTransformSlot from_target_to_source; +}; + +gboolean Binding_transform_callback_common(GBinding* binding, + const GValue* from_value, GValue* to_value, + Glib::Binding::BindingTransformSlot& the_slot) +{ + bool result = false; + try + { + Glib::RefPtr cpp_binding = Glib::wrap(binding, true); + result = the_slot(cpp_binding, from_value, to_value); + } + catch (...) + { + Glib::exception_handlers_invoke(); + } + return result; +} + +gboolean Binding_transform_to_callback(GBinding* binding, + const GValue* from_value, GValue* to_value, gpointer user_data) +{ + Glib::Binding::BindingTransformSlot& the_slot = + static_cast(user_data)->from_source_to_target; + + return Binding_transform_callback_common(binding, from_value, to_value, the_slot); +} + +gboolean Binding_transform_from_callback(GBinding* binding, + const GValue* from_value, GValue* to_value, gpointer user_data) +{ + Glib::Binding::BindingTransformSlot& the_slot = + static_cast(user_data)->from_target_to_source; + + return Binding_transform_callback_common(binding, from_value, to_value, the_slot); +} + +void Binding_transform_callback_destroy(gpointer user_data) +{ + delete static_cast(user_data); +} + +} // anonymous namespace + +namespace Glib +{ +//static +Glib::RefPtr Binding::bind_property_value( + const PropertyProxy_Base& source_property, + const PropertyProxy_Base& target_property, + BindingFlags flags, + const BindingTransformSlot& transform_to, + const BindingTransformSlot& transform_from) +{ + GBinding* binding = 0; + if (transform_to.empty() && transform_from.empty()) + { + // No user-supplied transformations. + binding = g_object_bind_property( + source_property.get_object()->gobj(), source_property.get_name(), + target_property.get_object()->gobj(), target_property.get_name(), + (GBindingFlags)flags); + } + else + { + // Create copies of the slots. A pointer to this will be passed + // through the callback's data parameter. It will be deleted + // when Binding_transform_callback_destroy() is called. + BindingTransformSlots* slots_copy = new BindingTransformSlots(transform_to, transform_from); + + binding = g_object_bind_property_full( + source_property.get_object()->gobj(), source_property.get_name(), + target_property.get_object()->gobj(), target_property.get_name(), + (GBindingFlags)flags, + transform_to.empty() ? 0 : &Binding_transform_to_callback, + transform_from.empty() ? 0 : &Binding_transform_from_callback, + slots_copy, &Binding_transform_callback_destroy); + } + + if (!binding) + return Glib::RefPtr(); + + // Take an extra ref. GBinding uses one ref itself, and drops it if + // either the source object or the target object is finalized. + // The GBinding object must not be destroyed while there are RefPtrs around. + g_object_ref(binding); + return Glib::RefPtr(new Binding(binding)); +} + +void Binding::unbind() +{ + // Call g_binding_unbind() only once. It always calls g_object_unref(). + if (g_binding_get_source(gobj())) + g_binding_unbind(gobj()); +} + +// Override unreference() from ObjectBase. +// +// Why is this necessary? Because GBinding is an unusual kind of GObject. +// It calls g_object_unref() itself, if either the source object or the +// target object is finalized, almost like g_binding_unbind(). +// But the GBinding object shall be destroyed when and only when the last +// reference from a Glib::RefPtr is dropped. +void Binding::unreference() const +{ + GBinding* const binding = const_cast(gobj()); + + // If the last Glib::RefPtr is being deleted, and the binding has not been unbound, + // then drop the extra reference that was added by bind_property_value(). + if (gobject_->ref_count == 2 && g_binding_get_source(binding)) + g_object_unref(binding); + + Object::unreference(); +} + +} // namespace Glib diff --git a/glib/src/binding.hg b/glib/src/binding.hg new file mode 100644 index 0000000..f776037 --- /dev/null +++ b/glib/src/binding.hg @@ -0,0 +1,423 @@ +/* Copyright (C) 2014 The glibmm Development Team + * + * 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.1 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, see . + */ + +#include +#include +#include +#include + +_DEFS(glibmm,glib) +_PINCLUDE(glibmm/private/object_p.h) + +namespace Glib +{ +_WRAP_ENUM(BindingFlags, GBindingFlags) + +/** Bind two object properties. + * + * Glib::Binding is the representation of a binding between a property on a + * Glib::ObjectBase instance (or source) and another property on another Glib::ObjectBase + * instance (or target). Whenever the source property changes, the same + * value is applied to the target property; for instance, the following binding: + * + * @code + * Glib::Binding::bind_property(object1->property_a(), object2->property_b()); + * @endcode + * + * will cause property_b() of @a object2 to be updated + * every time the value of property_a() of @a object1 changes. + * + * It is possible to create a bidirectional binding between two properties + * of two Glib::ObjectBase instances, so that if either property changes, the + * other is updated as well, for instance: + * + * @code + * Glib::Binding::bind_property(object1->property_a(), object2->property_b(), + * Glib::BINDING_BIDIRECTIONAL); + * @endcode + * + * will keep the two properties in sync. + * + * It is also possible to set a custom transformation function (in both + * directions, in case of a bidirectional binding) to apply a custom + * transformation from the source value to the target value before + * applying it; for instance, the following binding: + * + * @code + * bool celsius_to_fahrenheit(const Glib::RefPtr& binding, + * const double& celsius, double& fahrenheit); + * bool fahrenheit_to_celsius(const Glib::RefPtr& binding, + * const double& fahrenheit, double& celsius); + * Glib::Binding::bind_property(adjustment1->property_value(), + * adjustment2->property_value(), Glib::BINDING_BIDIRECTIONAL, + * sigc::ptr_fun(celsius_to_fahrenheit), sigc::ptr_fun(fahrenheit_to_celsius)); + * @endcode + * + * will keep property_value() of the two adjustments in sync; the + * celsius_to_fahrenheit() function will be called whenever + * property_value() of @a adjustment1 changes and will transform the current value + * of the property before applying it to property_value() of @a adjustment2. + * + * Vice versa, the fahrenheit_to_celsius() function will be called whenever + * property_value() of @a adjustment2 changes, and will transform the + * current value of the property before applying it to property_value() + * of @a adjustment1. + * + * Note that Glib::Binding does not resolve cycles by itself; a cycle like + * + * @code + * object1->property_A() -> object2->property_B() + * object2->property_B() -> object3->property_C() + * object3->property_C() -> object1->property_A() + * @endcode + * + * might lead to an infinite loop. The loop, in this particular case, + * can be avoided if the objects emit the GObject::notify signal only + * if the value has effectively been changed. A binding is implemented + * using the GObject::notify signal, so it is susceptible to all the + * various ways of blocking a signal emission, like Glib::SignalProxyNormal::emission_stop() + * or g_signal_handler_block(). + * + * A binding will be severed, and the resources it allocates freed, whenever + * either one of the Glib::ObjectBase instances it refers to is deleted, + * when unbind() is called, or when the Glib::Binding instance loses + * its last reference. + * + * @newin{2,44} + */ +class Binding : public Glib::Object +{ + _CLASS_GOBJECT(Binding, GBinding, G_BINDING, Glib::Object, GObject) + +public: + /** For instance,
+ * bool on_transform_to(const Glib::RefPtr& binding, const GValue* from_value, GValue* to_value); + * + * @return true if the transformation was successful, and false otherwise. + */ + typedef sigc::slot&, const GValue*, GValue*> BindingTransformSlot; + + /** Creates a binding between @a source_property and @a target_property, + * allowing you to set the transformation functions to be used by the binding. + * + * If @a flags contains Glib::BINDING_BIDIRECTIONAL then the binding will be mutual: + * if @a target_property changes then the @a source_property + * will be updated as well. The @a transform_from function is only used in case + * of bidirectional bindings, otherwise it will be ignored. + * + * The binding will automatically be removed when either the source or the + * target instance is deleted. To remove the binding without affecting the + * source and the target you can call unbind() on the returned Binding instance. + * + * A Glib::ObjectBase instance can have multiple bindings. + * + * If you supply transformation functions, it is usually easier to use one of the + * bind_property() overloads, to avoid the use of GValue in the transformation functions. + * + * @param source_property The source property to bind. + * @param target_property The target property to bind. + * @param flags Flags to pass to Binding. + * @param transform_to The transformation function from the source to the target, + * or an empty slot to use the default. + * @param transform_from The transformation function from the target to the source, + * or an empty slot to use the default. + * @return The Binding instance representing the binding between the two + * Glib::ObjectBase instances, or 0 in case of error. + * + * @newin{2,44} + */ + static Glib::RefPtr bind_property_value( + const PropertyProxy_Base& source_property, + const PropertyProxy_Base& target_property, + BindingFlags flags = BINDING_DEFAULT, + const BindingTransformSlot& transform_to = BindingTransformSlot(), + const BindingTransformSlot& transform_from = BindingTransformSlot()); + + _IGNORE(g_object_bind_property, g_object_bind_property_full, g_object_bind_property_with_closures) + + /** Creates a binding between @a source_property and @a target_property. + * + * @param source_property The source property to bind. + * @param target_property The target property to bind. + * @param flags Flags to pass to Binding. + * @return The Binding instance representing the binding between the two + * Glib::ObjectBase instances, or 0 in case of error. + * + * @see bind_property_value() + * + * @newin{2,44} + */ + static Glib::RefPtr bind_property( + const PropertyProxy_Base& source_property, + const PropertyProxy_Base& target_property, + BindingFlags flags = BINDING_DEFAULT) + { + return bind_property_value(source_property, target_property, flags); + } + + /** Creates a binding between @a source_property and @a target_property, + * allowing you to set a transformation function to be used by the binding. + * + * @param source_property The source property to bind. + * @param target_property The target property to bind. + * @param flags Flags to pass to Binding. + * @param transform_to The transformation function from the source to the target, + * or an empty slot to use the default. + * @return The Binding instance representing the binding between the two + * Glib::ObjectBase instances, or 0 in case of error. + * + * @tparam T_source Type of the source property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_target Type of the target property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_functor_to Type of functor that translates from the source to the target. + * Must be convertible to
+ * sigc::slot&, const T_source&, T_target&>. + * + * @see bind_property_value() + * + * @newin{2,44} + */ + template + static Glib::RefPtr bind_property( + const PropertyProxy& source_property, + const PropertyProxy& target_property, + BindingFlags flags, + const T_functor_to& transform_to) + { + sigc::slot&, const T_source&, T_target&> slot_transform_to = transform_to; + + return bind_property_value(source_property, target_property, flags, + slot_transform_to.empty() ? BindingTransformSlot() : TransformProp(slot_transform_to)); + } + + /** Creates a binding between @a source_property and @a target_property, + * allowing you to set a transformation function to be used by the binding. + * + * @param source_property The source property to bind. + * @param target_property The target property to bind. + * @param flags Flags to pass to Binding. + * @param transform_to The transformation function from the source to the target, + * or an empty slot to use the default. + * @return The Binding instance representing the binding between the two + * Glib::ObjectBase instances, or 0 in case of error. + * + * @tparam T_source Type of the source property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_target Type of the target property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_functor_to Type of functor that translates from the source to the target. + * Must be convertible to
+ * sigc::slot&, const T_source&, T_target&>. + * + * @see bind_property_value() + * + * @newin{2,44} + */ + template + static Glib::RefPtr bind_property( + const PropertyProxy& source_property, + const PropertyProxy_WriteOnly& target_property, + BindingFlags flags, + const T_functor_to& transform_to) + { + sigc::slot&, const T_source&, T_target&> slot_transform_to = transform_to; + + return bind_property_value(source_property, target_property, flags, + slot_transform_to.empty() ? BindingTransformSlot() : TransformProp(slot_transform_to)); + } + + /** Creates a binding between @a source_property and @a target_property, + * allowing you to set a transformation function to be used by the binding. + * + * @param source_property The source property to bind. + * @param target_property The target property to bind. + * @param flags Flags to pass to Binding. + * @param transform_to The transformation function from the source to the target, + * or an empty slot to use the default. + * @return The Binding instance representing the binding between the two + * Glib::ObjectBase instances, or 0 in case of error. + * + * @tparam T_source Type of the source property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_target Type of the target property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_functor_to Type of functor that translates from the source to the target. + * Must be convertible to
+ * sigc::slot&, const T_source&, T_target&>. + * + * @see bind_property_value() + * + * @newin{2,44} + */ + template + static Glib::RefPtr bind_property( + const PropertyProxy_ReadOnly& source_property, + const PropertyProxy& target_property, + BindingFlags flags, + const T_functor_to& transform_to) + { + sigc::slot&, const T_source&, T_target&> slot_transform_to = transform_to; + + return bind_property_value(source_property, target_property, flags, + slot_transform_to.empty() ? BindingTransformSlot() : TransformProp(slot_transform_to)); + } + + /** Creates a binding between @a source_property and @a target_property, + * allowing you to set a transformation function to be used by the binding. + * + * @param source_property The source property to bind. + * @param target_property The target property to bind. + * @param flags Flags to pass to Binding. + * @param transform_to The transformation function from the source to the target, + * or an empty slot to use the default. + * @return The Binding instance representing the binding between the two + * Glib::ObjectBase instances, or 0 in case of error. + * + * @tparam T_source Type of the source property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_target Type of the target property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_functor_to Type of functor that translates from the source to the target. + * Must be convertible to
+ * sigc::slot&, const T_source&, T_target&>. + * + * @see bind_property_value() + * + * @newin{2,44} + */ + template + static Glib::RefPtr bind_property( + const PropertyProxy_ReadOnly& source_property, + const PropertyProxy_WriteOnly& target_property, + BindingFlags flags, + const T_functor_to& transform_to) + { + sigc::slot&, const T_source&, T_target&> slot_transform_to = transform_to; + + return bind_property_value(source_property, target_property, flags, + slot_transform_to.empty() ? BindingTransformSlot() : TransformProp(slot_transform_to)); + } + + /** Creates a binding between @a source_property and @a target_property, + * allowing you to set the transformation functions to be used by the binding. + * + * @param source_property The source property to bind. + * @param target_property The target property to bind. + * @param flags Flags to pass to Binding. + * @param transform_to The transformation function from the source to the target, + * or an empty slot to use the default. + * @param transform_from The transformation function from the target to the source, + * or an empty slot to use the default. + * @return The Binding instance representing the binding between the two + * Glib::ObjectBase instances, or 0 in case of error. + * + * @tparam T_source Type of the source property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_target Type of the target property. Must be a type that can be + * stored in a Glib::Value object. + * @tparam T_functor_to Type of functor that translates from the source to the target. + * Must be convertible to
+ * sigc::slot&, const T_source&, T_target&>. + * @tparam T_functor_from Type of functor that translates from the target to the source. + * Must be convertible to
+ * sigc::slot&, const T_target&, T_source&>. + * + * @see bind_property_value() + * + * @newin{2,44} + */ + template + static Glib::RefPtr bind_property( + const PropertyProxy& source_property, + const PropertyProxy& target_property, + BindingFlags flags, + const T_functor_to& transform_to, + const T_functor_from& transform_from) + { + sigc::slot&, const T_source&, T_target&> slot_transform_to = transform_to; + sigc::slot&, const T_target&, T_source&> slot_transform_from = transform_from; + + return bind_property_value(source_property, target_property, flags, + slot_transform_to.empty() ? BindingTransformSlot() : TransformProp(slot_transform_to), + slot_transform_from.empty() ? BindingTransformSlot() : TransformProp(slot_transform_from)); + } + + _WRAP_METHOD(Glib::RefPtr get_source(), g_binding_get_source, refreturn) + _WRAP_METHOD(Glib::RefPtr get_source() const, g_binding_get_source, refreturn, constversion) + _WRAP_METHOD(Glib::ustring get_source_property() const, g_binding_get_source_property) + _WRAP_METHOD(Glib::RefPtr get_target(), g_binding_get_target, refreturn) + _WRAP_METHOD(Glib::RefPtr get_target() const, g_binding_get_target, refreturn, constversion) + _WRAP_METHOD(Glib::ustring get_target_property() const, g_binding_get_target_property) + _WRAP_METHOD(BindingFlags get_flags() const, g_binding_get_flags) + + /** Explicitly releases the binding between the source and the target + * property expressed by this Binding instance. + * + * The binding is also released if either the source object or the target + * object is deleted, or this Binding instance loses its last reference, + * i.e. there is no more Glib::RefPtr that holds a pointer to it. + * + * @newin{2,44} + */ + void unbind(); + _IGNORE(g_binding_unbind) + + _WRAP_PROPERTY("flags", Glib::BindingFlags) + _WRAP_PROPERTY("source", Glib::RefPtr) + _WRAP_PROPERTY("source-property", Glib::ustring) + _WRAP_PROPERTY("target", Glib::RefPtr) + _WRAP_PROPERTY("target-property", Glib::ustring) + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + /** Decrement the reference count for this object. + * You should never need to do this manually - use the object via a RefPtr instead. + */ + virtual void unreference() const; +#endif /* DOXYGEN_SHOULD_SKIP_THIS */ + +private: + // The functor TransformProp can be implicitly converted to a BindingTransformSlot + // and used in a call to bind_property_value(). + template + class TransformProp : public sigc::functor_base + { + public: + typedef bool result_type; + typedef sigc::slot&, const T_from&, T_to&> TypedBindingTransformSlot; + + TransformProp(const TypedBindingTransformSlot& slot) : typed_transform(slot) {} + + bool operator()(const Glib::RefPtr& binding, const GValue* from_value, GValue* to_value) + { + Glib::Value from_glib_value; + from_glib_value.init(from_value); + Glib::Value to_glib_value; + to_glib_value.init(to_value); + T_to to = to_glib_value.get(); + + const bool result = typed_transform(binding, from_glib_value.get(), to); + to_glib_value.set(to); + g_value_copy(to_glib_value.gobj(), to_value); + return result; + } + + private: + TypedBindingTransformSlot typed_transform; + }; +}; + +} // namespace Glib diff --git a/glib/src/bytes.hg b/glib/src/bytes.hg index 255c668..31f1fc9 100644 --- a/glib/src/bytes.hg +++ b/glib/src/bytes.hg @@ -30,11 +30,9 @@ typedef struct _GBytes GBytes; namespace Glib { - - //Note: The documentation is a reduced version of the C documentation, //because this class is only really useful with other C types that we don't bother to wrap. -//We only wrap it because it is used in the InputStream API. +//We only wrap it because it is used in the InputStream, OutputStream and Resource APIs. /** A simple refcounted data type representing an immutable byte sequence * from an unspecified origin. diff --git a/glib/src/checksum.hg b/glib/src/checksum.hg index ec1351f..84a7ba0 100644 --- a/glib/src/checksum.hg +++ b/glib/src/checksum.hg @@ -41,22 +41,8 @@ class Checksum { _CLASS_OPAQUE_COPYABLE(Checksum, GChecksum, NONE, g_checksum_copy, g_checksum_free) _IGNORE(g_checksum_copy, g_checksum_free) -public: - /** - * @class ChecksumType: - * @a CHECKSUM_MD5: Use the MD5 hashing algorithm - * @a CHECKSUM_SHA1: Use the SHA-1 hashing algorithm - * @a CHECKSUM_SHA256: Use the SHA-256 hashing algorithm - * - * The hashing algorithm to be used by Checksum when performing the - * digest of some data. - * - * Note that the ChecksumType enumeration may be extended at a later - * date to include new hashing algorithm types. - * - * @newin{2,16} - */ +public: _WRAP_ENUM(ChecksumType, GChecksumType, NO_GTYPE) #m4 _CONVERSION(`ChecksumType', `GChecksumType', `(($2)$3)') diff --git a/glib/src/filelist.am b/glib/src/filelist.am index d240146..c66e01b 100644 --- a/glib/src/filelist.am +++ b/glib/src/filelist.am @@ -6,6 +6,7 @@ glibmm_files_defs = \ glib_deprecated_enums.defs \ glib_functions.defs \ glib_extra_objects.defs \ + glib_signals.defs \ gmodule_enums.defs \ gmodule_functions.defs \ gobject.defs \ @@ -16,6 +17,7 @@ glibmm_files_defs = \ glibmm_files_any_hg = \ balancedtree.hg \ + binding.hg \ bytes.hg \ bytearray.hg \ checksum.hg \ diff --git a/glib/src/glib.defs b/glib/src/glib.defs index 1823191..e106d6b 100644 --- a/glib/src/glib.defs +++ b/glib/src/glib.defs @@ -3,6 +3,7 @@ (include glib_enums.defs) (include glib_deprecated_enums.defs) (include glib_extra_objects.defs) +(include glib_signals.defs) (include gobject_enums.defs) (include gobject_functions.defs) (include gmodule_functions.defs) diff --git a/glib/src/glib_docs.xml b/glib/src/glib_docs.xml index cba1b91..e0ff2b8 100644 --- a/glib/src/glib_docs.xml +++ b/glib/src/glib_docs.xml @@ -1284,7 +1284,7 @@ your direct control. Since 2.8. Through the #GParamFlags flag values, certain aspects of parameters -can be configured. See also #G_PARAM_READWRITE and #G_PARAM_STATIC_STRINGS. +can be configured. See also #G_PARAM_STATIC_STRINGS. @@ -1305,7 +1305,7 @@ can be configured. See also #G_PARAM_READWRITE and #G_PARAM_STATIC_STRINGS.
- the parameter will only be set upon object construction + the parameter can only be set upon object construction @@ -2558,6 +2558,10 @@ Deprecated: 2.36: g_type_init() is now done automatically Mask covering all debug flags + + Keep a count of instances of each type + +
@@ -17686,6 +17690,13 @@ count of 1 and allows to specify functions to free the memory allocated for the key and value that get called when removing the entry from the #GHashTable. +Since version 2.42 it is permissible for destroy notify functions to +recursively remove further items from the hash table. This is only +permissible if the application still holds a reference to the hash table. +This means that you may need to ensure that the hash table is empty by +calling g_hash_table_remove_all before releasing the last reference using +g_hash_table_unref(). +
@@ -28925,6 +28936,24 @@ not be modified or freed.
+ + +Returns whether strict POSIX code is enabled. + +See g_option_context_set_strict_posix() for more information. + +Since: 2.44 + + + + + a #GoptionContext + + + + + + Returns the summary. See g_option_context_set_summary(). @@ -29174,6 +29203,45 @@ Since: 2.6 + + +Sets strict POSIX mode. + +By default, this mode is disabled. + +In strict POSIX mode, the first non-argument parameter encountered +(eg: filename) terminates argument processing. Remaining arguments +are treated as non-options and are not attempted to be parsed. + +If strict POSIX mode is disabled then parsing is done in the GNU way +where option arguments can be freely mixed with non-options. + +As an example, consider "ls foo -l". With GNU style parsing, this +will list "foo" in long mode. In strict POSIX style, this will list +the files named "foo" and "-l". + +It may be useful to force strict POSIX mode when creating "verb +style" command line tools. For example, the "gsettings" command line +tool supports the global option "--schemadir" as well as many +subcommands ("get", "set", etc.) which each have their own set of +arguments. Using strict POSIX mode will allow parsing the global +options up to the verb name while leaving the remaining options to be +parsed by the relevant subcommand (which can be determined by +examining the verb name, which should be present in argv[1] after +parsing). + +Since: 2.44 + + + + + a #GoptionContext + + + + + + Adds a string to be displayed in `--help` output before the list @@ -31560,6 +31628,10 @@ the #GDestroyNotify for @key is not called on the old value. If @dest is %NULL, free @src; otherwise, moves @src into *@dest. The error variable @dest points to must be %NULL. +Note that @src is no longer valid after this call. If you want +to keep using the same GError*, you need to set it to %NULL +after calling this function on it. + @@ -32429,9 +32501,10 @@ Since: 2.14 -Inserts @data into @queue after @sibling +Inserts @data into @queue after @sibling. -@sibling must be part of @queue +@sibling must be part of @queue. Since GLib 2.44 a %NULL sibling pushes the +data at the head of the queue. Since: 2.4 @@ -32442,7 +32515,8 @@ Since: 2.4 - a #GList link that must be part of @queue + a #GList link that must be part of @queue, or %NULL to +push at the head of the queue. @@ -32457,7 +32531,8 @@ Since: 2.4 Inserts @data into @queue before @sibling. -@sibling must be part of @queue. +@sibling must be part of @queue. Since GLib 2.44 a %NULL sibling pushes the +data at the tail of the queue. Since: 2.4 @@ -32468,7 +32543,8 @@ Since: 2.4 - a #GList link that must be part of @queue + a #GList link that must be part of @queue, or %NULL to +push at the tail of the queue. @@ -37917,6 +37993,12 @@ and/or @data the handlers have to match. Returns whether there are any handlers connected to @instance for the given signal id and detail. +If @detail is 0 then it will only match handlers that were connected +without detail. If @detail is non-zero then it will match handlers +connected both without detail and with the given detail. This is +consistent with how a signal emitted with @detail would be delivered +to those handlers. + One example of when you might use this is when the arguments to the signal are difficult to compute. A class implementor may opt to not emit the signal if no one is attached anyway, thus saving the cost @@ -42231,8 +42313,10 @@ characters escaped. See above. -Frees a %NULL-terminated array of strings, and the array itself. -If called on a %NULL value, g_strfreev() simply returns. +Frees a %NULL-terminated array of strings, as well as each +string it contains. + +If @str_array is %NULL, this function simply returns. @@ -43775,6 +43859,28 @@ or g_utf8_strup() instead. + + +Checks if @strv contains @str. @strv must not be %NULL. + +Since: 2.44 + + + + + a %NULL-terminated array of strings + + + + a string + + + + %TRUE if @str is an element of @strv, according to g_str_equal(). + + + + Returns the length of the given %NULL-terminated @@ -45668,7 +45774,7 @@ global pool. @error can be %NULL to ignore errors, or non-%NULL to report errors. An error can only occur when @exclusive is set to %TRUE and not all @max_threads threads could be created. -See #GThreadError for possible errors that may occurr. +See #GThreadError for possible errors that may occur. Note, even in case of error a valid #GThreadPool is returned. @@ -48182,6 +48288,28 @@ or 0 if the type system ran out of fundamental type IDs + + +Returns the number of instances allocated of the particular type; +this is only available if GLib is built with debugging support and +the instance_count debug flag is set (by setting the GOBJECT_DEBUG +variable to include instance-count). + +Since: 2.44 + + + + + a #GType + + + + the number of instances allocated of the given type; +if instance counts are not available, returns 0. + + + + Returns the #GTypePlugin structure for @type. diff --git a/glib/src/glib_functions.defs b/glib/src/glib_functions.defs index f1ed7d8..9d5e4c3 100644 --- a/glib/src/glib_functions.defs +++ b/glib/src/glib_functions.defs @@ -8088,6 +8088,21 @@ (return-type "gboolean") ) +(define-method set_strict_posix + (of-object "GOptionContext") + (c-name "g_option_context_set_strict_posix") + (return-type "none") + (parameters + '("gboolean" "strict_posix") + ) +) + +(define-method get_strict_posix + (of-object "GOptionContext") + (c-name "g_option_context_get_strict_posix") + (return-type "gboolean") +) + (define-method add_main_entries (of-object "GOptionContext") (c-name "g_option_context_add_main_entries") @@ -10958,6 +10973,15 @@ ) ) +(define-function g_strv_contains + (c-name "g_strv_contains") + (return-type "gboolean") + (parameters + '("const-gchar*-const*" "strv") + '("const-gchar*" "str") + ) +) + ;; From gstringchunk.h diff --git a/glib/src/glib_signals.defs b/glib/src/glib_signals.defs new file mode 100644 index 0000000..d65d39e --- /dev/null +++ b/glib/src/glib_signals.defs @@ -0,0 +1,78 @@ +;; From GBinding + +(define-property source + (of-object "GBinding") + (prop-type "GParamObject") + (docs "The source of the binding") + (readable #t) + (writable #t) + (construct-only #t) +) + +(define-property target + (of-object "GBinding") + (prop-type "GParamObject") + (docs "The target of the binding") + (readable #t) + (writable #t) + (construct-only #t) +) + +(define-property source-property + (of-object "GBinding") + (prop-type "GParamString") + (docs "The property on the source to bind") + (readable #t) + (writable #t) + (construct-only #t) +) + +(define-property target-property + (of-object "GBinding") + (prop-type "GParamString") + (docs "The property on the target to bind") + (readable #t) + (writable #t) + (construct-only #t) +) + +(define-property flags + (of-object "GBinding") + (prop-type "GParamFlags") + (docs "The binding flags") + (readable #t) + (writable #t) + (construct-only #t) +) + +;; GBytes is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GChecksum is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GDate is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GDateTime is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GIOChannel is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GKeyFile is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GMainContext is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GMainLoop is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GMatchInfo is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GRegex is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GSource is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GThread is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GVariant is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GVariantBuilder is neither a GObject nor a GInterface. Not checked for signals and properties. + +;; GVariantDict is neither a GObject nor a GInterface. Not checked for signals and properties. + + diff --git a/glib/src/gobject_enums.defs b/glib/src/gobject_enums.defs index 2119077..7b64941 100644 --- a/glib/src/gobject_enums.defs +++ b/glib/src/gobject_enums.defs @@ -141,7 +141,8 @@ ;; G_TYPE_DEBUG_NONE = 0, ;; G_TYPE_DEBUG_OBJECTS = 1 << 0, ;; G_TYPE_DEBUG_SIGNALS = 1 << 1, -;; G_TYPE_DEBUG_MASK = 0x03 +;; G_TYPE_DEBUG_INSTANCE_COUNT = 1 << 2, +;; G_TYPE_DEBUG_MASK = 0x07 ;; } GTypeDebugFlags; (define-flags-extended TypeDebugFlags @@ -151,7 +152,8 @@ '("none" "G_TYPE_DEBUG_NONE" "0x0") '("objects" "G_TYPE_DEBUG_OBJECTS" "1 << 0") '("signals" "G_TYPE_DEBUG_SIGNALS" "1 << 1") - '("mask" "G_TYPE_DEBUG_MASK" "0x03") + '("instance-count" "G_TYPE_DEBUG_INSTANCE_COUNT" "1 << 2") + '("mask" "G_TYPE_DEBUG_MASK" "0x07") ) ) diff --git a/glib/src/gobject_functions.defs b/glib/src/gobject_functions.defs index 31c500e..7611a00 100644 --- a/glib/src/gobject_functions.defs +++ b/glib/src/gobject_functions.defs @@ -96,6 +96,7 @@ '("none" "G_TYPE_DEBUG_NONE") '("objects" "G_TYPE_DEBUG_OBJECTS") '("signals" "G_TYPE_DEBUG_SIGNALS") + '("instance-count" "G_TYPE_DEBUG_INSTANCE_COUNT") '("mask" "G_TYPE_DEBUG_MASK") ) ) @@ -3136,6 +3137,12 @@ ) ) +(define-method get_instance_count + (of-object "GType") + (c-name "g_type_get_instance_count") + (return-type "int") +) + (define-method register_static (of-object "GType") (c-name "g_type_register_static") diff --git a/tests/giomm_tls_client/main.cc b/tests/giomm_tls_client/main.cc index c76551a..a14fe9f 100644 --- a/tests/giomm_tls_client/main.cc +++ b/tests/giomm_tls_client/main.cc @@ -86,7 +86,17 @@ int main(int, char**) Glib::RefPtr address = Gio::InetSocketAddress::create(first_inet_address, 443); - socket->connect(address); + try + { + socket->connect(address); + } + catch(const Gio::Error& ex) + { + std::cout << "Could not connect socket to " << + address->get_address()->to_string() << ":" << address->get_port() << + ". Exception: " << ex.what() << std::endl; + return EXIT_FAILURE; + } if(!socket->is_connected()) { diff --git a/tools/extra_defs_gen/generate_defs_glib.cc b/tools/extra_defs_gen/generate_defs_glib.cc index 2ead0a0..1e32edb 100644 --- a/tools/extra_defs_gen/generate_defs_glib.cc +++ b/tools/extra_defs_gen/generate_defs_glib.cc @@ -1,5 +1,3 @@ -/* $Id$ */ - /* generate_defs_gtk.cc * * Copyright (C) 2001 The Free Software Foundation @@ -27,7 +25,8 @@ int main() // g_type_init() is deprecated as of 2.36. // g_type_init(); - std::cout << get_defs( G_TYPE_BYTES ) + std::cout << get_defs( G_TYPE_BINDING ) + << get_defs( G_TYPE_BYTES ) << get_defs( G_TYPE_CHECKSUM ) << get_defs( G_TYPE_DATE ) << get_defs( G_TYPE_DATE_TIME ) diff --git a/tools/generate_wrap_init.pl.in b/tools/generate_wrap_init.pl.in index 59cd654..1381dfe 100644 --- a/tools/generate_wrap_init.pl.in +++ b/tools/generate_wrap_init.pl.in @@ -192,7 +192,7 @@ while ($ARGV[0]) elsif (/\b_NO_WRAP_INIT_REGISTRATION\b/) { $exclude_from_wrap_init{$filename_header} = 1; - } + } } shift @ARGV; @@ -205,6 +205,7 @@ while ($ARGV[0]) print << "EOF"; // Generated by generate_wrap_init.pl -- DO NOT MODIFY! +#define GLIBMM_INCLUDED_FROM_WRAP_INIT_CC #include // Disable the 'const' function attribute of the get_type() functions. diff --git a/tools/gmmproc.in b/tools/gmmproc.in index 8b57653..e929503 100644 --- a/tools/gmmproc.in +++ b/tools/gmmproc.in @@ -123,22 +123,27 @@ if ($main::unwrapped) # Don't take non-readable construct-only properties into account. my @properties = grep { $$_{entity_type} eq 'property' and ( $$_{readable} or not $$_{construct_only} ) } @unwrapped; + # Don't print a name of any kind between the first and second colon on a line, + # if there is any chance that "error" is (part of) the name. + # MS Visual Studio will misunderstand. + # See https://mail.gnome.org/archives/gtkmm-list/2014-November/msg00044.html + local $, = "\ngmmproc: "; local $\ = "\n"; if (@methods) { - print STDERR ("gmmproc: $main::source: Unwrapped functions:", + print STDERR ("gmmproc, $main::source: Unwrapped functions:", map($$_{c_name}, @methods)); } if (@properties) { - print STDERR ("gmmproc: $main::source: Unwrapped properties:", + print STDERR ("gmmproc, $main::source: Unwrapped properties:", map($$_{class} . '::' . $$_{name}, @properties)); } if (@signals) { - print STDERR ("gmmproc: $main::source: Unwrapped signals:", + print STDERR ("gmmproc, $main::source: Unwrapped signals:", map($$_{class} . '::' . $$_{name}, @signals)); } } diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4 index 58d2a65..3d17066 100644 --- a/tools/m4/convert_gio.m4 +++ b/tools/m4/convert_gio.m4 @@ -35,6 +35,8 @@ _CONV_ENUM(G,MountUnmountFlags) _CONV_ENUM(G,OutputStreamSpliceFlags) _CONV_ENUM(G,PasswordSave) _CONV_ENUM(G,ResolverRecordType) +_CONV_ENUM(G,ResourceFlags) +_CONV_ENUM(G,ResourceLookupFlags) _CONV_ENUM(G,SettingsBindFlags) _CONV_ENUM(G,SocketClientEvent) _CONV_ENUM(G,SocketFamily) @@ -252,6 +254,9 @@ _CONVERSION(`GProxy*',`Glib::RefPtr',`Glib::wrap($3)') _CONVERSION(`const Glib::RefPtr&',`GProxyAddress*',__CONVERT_CONST_REFPTR_TO_P) +#Resource +_CONVERSION(`GResource*',`Glib::RefPtr',`Glib::wrap($3)') + #Settings _CONVERSION(`GSettings*',`Glib::RefPtr',`Glib::wrap($3)') _CONVERSION(`const Glib::StringArrayHandle&',`const gchar*-const*',`($3).data()') diff --git a/tools/m4/convert_glib.m4 b/tools/m4/convert_glib.m4 index f7e768c..0c70cdf 100644 --- a/tools/m4/convert_glib.m4 +++ b/tools/m4/convert_glib.m4 @@ -60,6 +60,7 @@ dnl dnl # These are for fixmegtkconst _CONVERSION(`const guchar*',`guchar*',`const_cast($3)',`$3') +_CONV_GLIB_ENUM(BindingFlags) _CONV_GLIB_ENUM(IOCondition) _CONV_GLIB_ENUM(IOFlags) _CONV_GLIB_ENUM(IOStatus) diff --git a/tools/m4/gerror.m4 b/tools/m4/gerror.m4 index f18109f..e48aef6 100644 --- a/tools/m4/gerror.m4 +++ b/tools/m4/gerror.m4 @@ -1,7 +1,6 @@ -dnl $Id$ - dnl -dnl _GERROR(PixbufError,GdkPixbufError,GDK_PIXBUF_ERROR,`',[NO_GTYPE]) +dnl _GERROR(PixbufError,GdkPixbufError,GDK_PIXBUF_ERROR,`',[NO_GTYPE], `') +dnl $1 $2 $3 $4 $5 $6 dnl m4_define(`_GERROR',`dnl @@ -16,6 +15,8 @@ _POP() class __CPPNAME__ : public Glib::Error { public: + /** $6 + */ enum Code { $4 diff --git a/tools/pm/DocsParser.pm b/tools/pm/DocsParser.pm index c771fc3..1997945 100644 --- a/tools/pm/DocsParser.pm +++ b/tools/pm/DocsParser.pm @@ -233,9 +233,9 @@ sub parse_on_cdata($$) } } -sub lookup_enum_documentation($$$) +sub lookup_enum_documentation($$$$) { - my ($c_enum_name, $cpp_enum_name, $ref_flags) = @_; + my ($c_enum_name, $cpp_enum_name, $indent, $ref_flags) = @_; my @subst_in = []; my @subst_out = []; @@ -305,9 +305,9 @@ sub lookup_enum_documentation($$$) remove_example_code($c_enum_name, \$docs); - # Convert to Doxygen-style comment. - $docs =~ s/\n/\n \* /g; - $docs = "\/\*\* " . $docs; + # Add indentation and an asterisk on all lines except the first. + # $docs does not contain leading "/**" and trailing "*/". + $docs =~ s/\n/\n${indent}\* /g; return $docs; } @@ -375,7 +375,8 @@ sub remove_example_code($$) ($$text =~ s".*?"\n[C example ellipted]"sg); $example_removals += ($$text =~ s"\|\[.*?]\|"\n[C example ellipted]"sg); - print STDERR "gmmproc: $main::source: $obj_name: Example code discarded.\n" + # See "MS Visual Studio" comment in gmmproc.in. + print STDERR "gmmproc, $main::source, $obj_name: Example code discarded.\n" if ($example_removals); } @@ -691,7 +692,7 @@ sub lookup_object_of_method($$) } else { - print "DocsParser.pm:lookup_object_of_method(): Warning: GtkDefs::lookup_object() failed for object name=" . $object . ", function name=" . $name . "\n"; + print "DocsParser.pm: lookup_object_of_method(): Warning: GtkDefs::lookup_object() failed for object name=" . $object . ", function name=" . $name . "\n"; print " This may be a missing define-object in a *.defs file.\n" } } diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm index 22af9ef..de13f5e 100644 --- a/tools/pm/Output.pm +++ b/tools/pm/Output.pm @@ -72,15 +72,16 @@ sub output_wrap_failed($$$) { my ($self, $cname, $error) = @_; + # See "MS Visual Studio" comment in gmmproc.in. my $str = sprintf("//gtkmmproc error: %s : %s", $cname, $error); - print STDERR "Output.pm: $main::source: $cname : $error\n"; + print STDERR "Output.pm, $main::source, $cname : $error\n"; $self->append($str); } sub error { my $format=shift @_; - printf STDERR "Output.pm: $main::source: $format",@_; + printf STDERR "Output.pm, $main::source: $format",@_; } sub ifdef($$) @@ -675,14 +676,7 @@ sub output_wrap_enum($$$$$$$) # Get the enum documentation from the parsed docs. my $enum_docs = - DocsParser::lookup_enum_documentation("$c_type", "$cpp_type", \@flags); - - # Remove initial Doxygen comment block start ('/**') from the enum docs - # to merge the passed in Doxygen comment block. - $enum_docs =~ s/\/\*\*\s+//g; - - # Make sure indentation of passed in comment is correct. - $comment =~ s/\n\s*\*/\n */g; + DocsParser::lookup_enum_documentation("$c_type", "$cpp_type", " ", \@flags); # Merge the passed in comment to the existing enum documentation. $comment = $comment . "\n * " . $enum_docs; @@ -706,7 +700,7 @@ sub output_wrap_enum_docs_only($$$$$$$) # Get the existing enum description from the parsed docs. my $enum_docs = - DocsParser::lookup_enum_documentation("$c_type", "$cpp_type", \@flags); + DocsParser::lookup_enum_documentation("$c_type", "$cpp_type", " ", \@flags); if($enum_docs eq "") { @@ -717,15 +711,8 @@ sub output_wrap_enum_docs_only($$$$$$$) # Include the enum docs in the module's enum docs group. $enum_docs .= "\n * \@ingroup ${module_canonical}Enums\n"; - # Remove initial Doxygen comment block start ('/**') from the enum docs - # to merge the passed in Doxygen comment block. - $enum_docs =~ s/\/\*\*\s+//g; - # Merge the passed in comment to the existing enum documentation. - $comment = "\/\*\* " . $comment . "\n * " . $enum_docs . "\n */\n"; - - # Make sure indentation of passed in comment is correct. - $comment =~ s/\n\s*\*/\n */g; + $comment = "/** " . $comment . "\n * " . $enum_docs . "\n */\n"; $self->append($comment); } @@ -759,12 +746,20 @@ sub output_wrap_gerror($$$$$$$) my $no_gtype = ""; my $elements = $objEnum->build_element_list(\@flags, \$no_gtype, " "); - my $str = sprintf("_GERROR(%s,%s,%s,\`%s\',%s)dnl\n", + # Get the enum documentation from the parsed docs. + my $enum_docs = + DocsParser::lookup_enum_documentation("$c_enum", "Code", " ", \@flags); + + # Prevent Doxygen from auto-linking to a class called Error. + $enum_docs =~ s/([^%])(Error code)/$1%$2/g; + + my $str = sprintf("_GERROR(%s,%s,%s,\`%s\',%s,\`%s\')dnl\n", $cpp_type, $c_enum, $domain, $elements, - $no_gtype + $no_gtype, + $enum_docs ); $self->append($str); diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm index a52769c..dc12eb4 100644 --- a/tools/pm/WrapParser.pm +++ b/tools/pm/WrapParser.pm @@ -457,18 +457,24 @@ sub on_namespace($) sub on_ignore($) { my ($self) = @_; + my $objOutputter = $$self{objOutputter}; my $str = $self->extract_bracketed_text(); my @args = split(/\s+|,/,$str); foreach (@args) { next if ($_ eq ""); - GtkDefs::lookup_function($_); #Pretend that we've used it. + my $objCfunc = GtkDefs::lookup_function($_); #Pretend that we've used it. + if(!$objCfunc) + { + $objOutputter->output_wrap_failed($_, "ignored method defs lookup failed"); + } } } sub on_ignore_signal($) { my ($self) = @_; + my $objOutputter = $$self{objOutputter}; my $str = $self->extract_bracketed_text(); $str = string_trim($str); $str = string_unquote($str); @@ -476,7 +482,11 @@ sub on_ignore_signal($) foreach (@args) { next if ($_ eq ""); - GtkDefs::lookup_signal($$self{c_class}, $_); #Pretend that we've used it. + my $objCsignal = GtkDefs::lookup_signal($$self{c_class}, $_); #Pretend that we've used it. + if(!$objCsignal) + { + $objOutputter->output_wrap_failed($_, "ignored signal defs lookup failed"); + } } } -- 2.7.4