[perl-Glib] Add a gchar_utf8_length typemap
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Glib] Add a gchar_utf8_length typemap
- Date: Wed, 29 Dec 2010 21:48:59 +0000 (UTC)
commit a39cf28cf8a536c0dc20bb2e34fac471c07b0c8f
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Wed Dec 29 22:48:04 2010 +0100
Add a gchar_utf8_length typemap
This gives the length of the string in terms of characters, as opposed
to gchar_length which gives bytes.
gperl.h | 3 ++-
lib/Glib/GenPod.pm | 1 +
typemap | 7 +++++++
3 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gperl.h b/gperl.h
index 0028d71..5737a49 100644
--- a/gperl.h
+++ b/gperl.h
@@ -203,7 +203,8 @@ MAGIC * _gperl_find_mg (SV * sv);
void _gperl_remove_mg (SV * sv);
/* typedefs and macros for use with the typemap */
-typedef gchar gchar_length;
+typedef gchar gchar_length; /* length in bytes */
+typedef gchar gchar_utf8_length; /* length in characters */
typedef gchar gchar_own;
typedef gchar gchar_ornull;
typedef gchar gchar_own_ornull;
diff --git a/lib/Glib/GenPod.pm b/lib/Glib/GenPod.pm
index b7053c7..f884ffe 100644
--- a/lib/Glib/GenPod.pm
+++ b/lib/Glib/GenPod.pm
@@ -440,6 +440,7 @@ our %basic_types = (
AV => 'arrayref',
gchar_length => 'string',
+ gchar_utf8_length => 'string',
FILE => 'file handle',
time_t => 'unix timestamp',
diff --git a/typemap b/typemap
index 5121a7a..d2e17a4 100644
--- a/typemap
+++ b/typemap
@@ -42,6 +42,8 @@ const gchar * T_GCHAR
gchar_own * T_GCHAR_OWN
gchar_length * T_GCHAR_LEN
const gchar_length * T_GCHAR_LEN
+gchar_utf8_length * T_GCHAR_UTF8_LEN
+const gchar_utf8_length * T_GCHAR_UTF8_LEN
gchar_ornull * T_GCHAR_ORNULL
gchar_own_ornull * T_GCHAR_OWN_ORNULL
const gchar_ornull * T_GCHAR_ORNULL
@@ -129,6 +131,11 @@ T_GCHAR_LEN
$var = ($type)SvPV ($arg, STRLEN_length_of_$var);
XSauto_length_of_$var = STRLEN_length_of_$var;
+T_GCHAR_UTF8_LEN
+ sv_utf8_upgrade ($arg);
+ $var = ($type)SvPV ($arg, STRLEN_length_of_$var);
+ XSauto_length_of_$var = g_utf8_strlen ($var, STRLEN_length_of_$var);
+
T_GUCHAR
$var = ($type)SvPV_nolen ($arg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]