glibmm r527 - in trunk: glib glib/src tools/m4
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glibmm r527 - in trunk: glib glib/src tools/m4
- Date: Sun, 20 Jan 2008 17:52:05 +0000 (GMT)
Author: murrayc
Date: Sun Jan 20 17:52:05 2008
New Revision: 527
URL: http://svn.gnome.org/viewvc/glibmm?rev=527&view=rev
Log:
2008-01-20 Murray Cumming <murrayc murrayc com>
* gio/src/inputstream.hg: Ignore g_input_stream_clear_pending() as well as
the other implementation functions.
* gio/src/outputstream.hg: Ignore the equivalent functions here,
assuming that they are also only for implementations.
Added:
trunk/glib/src/checksum.ccg
trunk/glib/src/checksum.hg
Modified:
trunk/glib/Makefile.am
trunk/glib/src/Makefile_list_of_hg.am_fragment
trunk/glib/src/glib_enums.defs
trunk/glib/src/glib_functions.defs
trunk/tools/m4/convert_glib.m4
Modified: trunk/glib/Makefile.am
==============================================================================
--- trunk/glib/Makefile.am (original)
+++ trunk/glib/Makefile.am Sun Jan 20 17:52:05 2008
@@ -10,5 +10,3 @@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = glibmm-2.4.pc
-
-
\ No newline at end of file
Modified: trunk/glib/src/Makefile_list_of_hg.am_fragment
==============================================================================
--- trunk/glib/src/Makefile_list_of_hg.am_fragment (original)
+++ trunk/glib/src/Makefile_list_of_hg.am_fragment Sun Jan 20 17:52:05 2008
@@ -5,7 +5,7 @@
files_posix_hg =
files_win32_hg =
-files_general_hg = convert.hg date.hg fileutils.hg iochannel.hg keyfile.hg markup.hg \
+files_general_hg = checksum.hg convert.hg date.hg fileutils.hg iochannel.hg keyfile.hg markup.hg \
module.hg optioncontext.hg optionentry.hg optiongroup.hg regex.hg \
shell.hg spawn.hg thread.hg unicode.hg uriutils.hg
files_general_deprecated_hg =
Added: trunk/glib/src/checksum.ccg
==============================================================================
--- (empty file)
+++ trunk/glib/src/checksum.ccg Sun Jan 20 17:52:05 2008
@@ -0,0 +1,51 @@
+/* $Id$ */
+
+/* Copyright (C) 2002 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <glib/gchecksum.h>
+
+#include <glib.h>
+#include <glibmm/utility.h>
+#include <glibmm/checksum.h>
+
+namespace Glib
+{
+
+Checksum::Checksum(ChecksumType type)
+: gobject_(g_checksum_new((GChecksumType)type))
+{
+}
+
+
+gssize Checksum::get_length(ChecksumType type)
+{
+ return g_checksum_type_get_length((GChecksumType)type);
+}
+
+std::string Checksum::compute_checksum(ChecksumType type, const std::string& data)
+{
+ return Glib::convert_return_gchar_ptr_to_ustring(g_compute_checksum_for_string(((GChecksumType)type), data.c_str(), -1));
+}
+
+void Checksum::update(const std::string& data)
+{
+ g_checksum_update(gobj(), (const guchar*)data.c_str(), data.size());
+}
+
+} // Glib namespace
+
+
Added: trunk/glib/src/checksum.hg
==============================================================================
--- (empty file)
+++ trunk/glib/src/checksum.hg Sun Jan 20 17:52:05 2008
@@ -0,0 +1,98 @@
+/* $Id$ */
+
+/* Copyright (C) 2002 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+_DEFS(glibmm,glib)
+
+#include <glib/gtypes.h>
+#include <string>
+
+#ifndef DOXYGEN_SHOUD_SKIP_THIS
+extern "C" { typedef struct _GChecksum GChecksum; }
+#endif
+
+namespace Glib
+{
+
+class Checksum
+{
+ _CLASS_OPAQUE_COPYABLE(Checksum, GChecksum, NONE, g_checksum_copy, g_checksum_free)
+public:
+
+ /**
+ * ChecksumType:
+ * @CHECKSUM_MD5: Use the MD5 hashing algorithm
+ * @CHECKSUM_SHA1: Use the SHA-1 hashing algorithm
+ * @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.
+ *
+ * @newin2p16
+ */
+ _WRAP_ENUM(ChecksumType, GChecksumType, NO_GTYPE)
+
+#m4 _CONVERSION(`ChecksumType', `GChecksumType', `(($2)$3)')
+
+ /**
+ * Create a checksum object for a given checksum type.
+ *
+ * @param type checksum type, one of defined above.
+ *
+ * @return new checksum object.
+ */
+ Checksum(ChecksumType checksum_type);
+
+ _WRAP_METHOD(void update(const guchar* data, gsize length), g_checksum_update)
+
+ /** Feeds data into an existing Checksum.
+ * The checksum must still be open, that is get_string() or get_digest() must not have been called on the checksum.
+ *
+ * @param data Buffer used to compute the checksum
+ */
+ void update(const std::string& data);
+
+ _WRAP_METHOD(void get_digest(guint8 *buffer, gsize *digest_len) const, g_checksum_get_digest)
+
+ _WRAP_METHOD(std::string get_string() const, g_checksum_get_string)
+
+
+ _WRAP_METHOD(static std::string compute_checksum(ChecksumType type, const guchar* data, gsize length), g_compute_checksum_for_data)
+
+ /** Computes the checksum of a string.
+ *
+ * @param checksum_type A ChecksumType
+ * @param str The string to compute the checksum of.
+ * @result The checksum as a hexadecimal string.
+ *
+ * @newin2p16
+ */
+ static std::string compute_checksum(ChecksumType type, const std::string& str);
+ _IGNORE(g_compute_checksum_for_string)
+
+ /* TODO: Can not use _WRAP_METHOD because for some reason it takes ChecksumType
+ * as pointer, treating it as object. This problem is related to code
+ * generated from h2def, where def treat ChecksumType as object */
+ static gssize get_length(ChecksumType type);
+};
+
+} //namespace Glib
+
Modified: trunk/glib/src/glib_enums.defs
==============================================================================
--- trunk/glib/src/glib_enums.defs (original)
+++ trunk/glib/src/glib_enums.defs Sun Jan 20 17:52:05 2008
@@ -15,6 +15,18 @@
)
)
+;; From ../glibc/trunk/glib/gchecksum.h
+
+(define-enum-extended ChecksumType
+ (in-module "G")
+ (c-name "GChecksumType")
+ (values
+ '("md5" "G_CHECKSUM_MD5" "0")
+ '("sha1" "G_CHECKSUM_SHA1" "1")
+ '("sha256" "G_CHECKSUM_SHA256" "2")
+ )
+)
+
;; From /opt/gnome218/include/glib-2.0/glib/gconvert.h
(define-enum-extended ConvertError
Modified: trunk/glib/src/glib_functions.defs
==============================================================================
--- trunk/glib/src/glib_functions.defs (original)
+++ trunk/glib/src/glib_functions.defs Sun Jan 20 17:52:05 2008
@@ -752,6 +752,18 @@
)
+(define-enum Type
+ (in-module "GChecksum")
+ (c-name "GChecksumType")
+ (gtype-id "G_TYPE_CHECKSUM_TYPE")
+ (values
+ '("md5" "G_CHECKSUM_MD5")
+ '("sha1" "G_CHECKSUM_SHA1")
+ '("sha256" "G_CHECKSUM_SHA256")
+ )
+)
+
+
;; From galias.h
@@ -1911,6 +1923,82 @@
+;; From gchecksum.h
+
+(define-method get_length
+ (of-object "GChecksumType")
+ (c-name "g_checksum_type_get_length")
+ (return-type "gssize")
+)
+
+(define-function g_checksum_new
+ (c-name "g_checksum_new")
+ (is-constructor-of "GChecksum")
+ (return-type "GChecksum*")
+ (parameters
+ '("GChecksumType" "checksum_type")
+ )
+)
+
+(define-method copy
+ (of-object "GChecksum")
+ (c-name "g_checksum_copy")
+ (return-type "GChecksum*")
+)
+
+(define-method free
+ (of-object "GChecksum")
+ (c-name "g_checksum_free")
+ (return-type "none")
+)
+
+(define-method update
+ (of-object "GChecksum")
+ (c-name "g_checksum_update")
+ (return-type "none")
+ (parameters
+ '("const-guchar*" "data")
+ '("gsize" "length")
+ )
+)
+
+(define-method get_string
+ (of-object "GChecksum")
+ (c-name "g_checksum_get_string")
+ (return-type "const-gchar*")
+)
+
+(define-method get_digest
+ (of-object "GChecksum")
+ (c-name "g_checksum_get_digest")
+ (return-type "none")
+ (parameters
+ '("guint8*" "buffer")
+ '("gsize*" "digest_len")
+ )
+)
+
+(define-function g_compute_checksum_for_data
+ (c-name "g_compute_checksum_for_data")
+ (return-type "gchar*")
+ (parameters
+ '("GChecksumType" "checksum_type")
+ '("const-guchar*" "data")
+ '("gsize" "length")
+ )
+)
+
+(define-function g_compute_checksum_for_string
+ (c-name "g_compute_checksum_for_string")
+ (return-type "gchar*")
+ (parameters
+ '("GChecksumType" "checksum_type")
+ '("const-gchar*" "str")
+ '("gsize" "length")
+ )
+)
+
+
;; From gcompletion.h
(define-function g_completion_new
Modified: trunk/tools/m4/convert_glib.m4
==============================================================================
--- trunk/tools/m4/convert_glib.m4 (original)
+++ trunk/tools/m4/convert_glib.m4 Sun Jan 20 17:52:05 2008
@@ -36,14 +36,15 @@
define(`__GCHARP_TO_STDSTRING',`Glib::convert_const_gchar_ptr_to_stdstring($`'3)')
_CONVERSION(`const Glib::ustring&',`const char*',`$3.c_str()')
+_CONVERSION(`const Glib::ustring&', `const guchar*', `(($2)$3.c_str())')
_CONVERSION(`const std::string&',`const char*',`$3.c_str()')
_CONVERSION(`const Glib::ustring&',`gchar*',`const_cast<gchar*>($3.c_str())')
_CONVERSION(`gchar*',`Glib::ustring',__GCHARP_TO_USTRING)
_CONVERSION(`const-gchar*',`Glib::ustring',__GCHARP_TO_USTRING)
+_CONVERSION(`const-guchar*',`Glib::ustring',__GCHARP_TO_USTRING)
_CONVERSION(`const gchar*',`Glib::ustring',__GCHARP_TO_USTRING)
_CONVERSION(`const char*',`Glib::ustring',__GCHARP_TO_USTRING)
_CONVERSION(`const char*',`std::string',__GCHARP_TO_STDSTRING)
-_CONVERSION(`const gchar*',`const Glib::ustring&',__GCHARP_TO_USTRING)
_CONVERSION(`const char*',`const-gchar*',`$3')
_CONVERSION(`const-gchar*',`const char*',`$3')
_CONVERSION(`const char*',`const std::string&',__GCHARP_TO_STDSTRING)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]