Browse files

Return unicode strings to perl.

Define a new typedef, 'utf8', in perlglue.xs, and use a typemap that
indicates that values of type utf8* should be returned to perl as
Unicode strings.

There is no good reason that get_{data,config}_dir should not also
return unicode, except that making them do so crashes my barnowl in
some extremely strange and hard-to-debug manner.
  • Loading branch information...
1 parent 09ff1eb commit 39e81f799239d76e4d42870e6aabcb35d6e2c059 @nelhage committed Oct 2, 2009
Showing with 25 additions and 12 deletions.
  1. +4 −2 Makefile.am
  2. +13 −10 perlglue.xs
  3. +8 −0 typemap
View
6 Makefile.am
@@ -42,6 +42,8 @@ BASE_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
GEN_C = varstubs.c perlglue.c
GEN_H = owl_prototypes.h
+TYPEMAP = typemap
+
BUILT_SOURCES = $(GEN_C) $(GEN_H)
# Only copy file into place if file.new is different
@@ -53,8 +55,8 @@ BUILT_SOURCES = $(GEN_C) $(GEN_H)
proto: owl_prototypes.h
-perlglue.c: perlglue.xs
- $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs > perlglue.c
+perlglue.c: perlglue.xs $(TYPEMAP)
+ $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs -typemap $(TYPEMAP) > perlglue.c
varstubs.c: stubgen.pl variable.c
$(AM_V_GEN)perl $< $(filter-out $<,$+) > $@
View
23 perlglue.xs
@@ -9,6 +9,8 @@
#define SV_IS_CODEREF(sv) (SvROK((sv)) && SvTYPE(SvRV((sv))) == SVt_PVCV)
+typedef char utf8;
+
/*************************************************************
* NOTE
*************************************************************
@@ -28,7 +30,7 @@
MODULE = BarnOwl PACKAGE = BarnOwl
-const char *
+const utf8 *
command(cmd, ...)
const char *cmd
PREINIT:
@@ -76,14 +78,14 @@ getidletime()
OUTPUT:
RETVAL
-const char *
+const utf8 *
zephyr_getrealm()
CODE:
RETVAL = owl_zephyr_get_realm();
OUTPUT:
RETVAL
-const char *
+const utf8 *
zephyr_getsender()
CODE:
RETVAL = owl_zephyr_get_sender();
@@ -99,7 +101,7 @@ zephyr_zwrite(cmd,msg)
CODE:
i = owl_zwrite_create_and_send_from_line(cmd, msg);
-const char *
+const utf8 *
ztext_stylestrip(ztext)
const char *ztext
PREINIT:
@@ -112,7 +114,7 @@ ztext_stylestrip(ztext)
CLEANUP:
if (rv) owl_free(rv);
-const char *
+const utf8 *
zephyr_smartstrip_user(in)
const char *in
PREINIT:
@@ -127,7 +129,7 @@ zephyr_smartstrip_user(in)
CLEANUP:
owl_free(rv);
-const char *
+const utf8 *
zephyr_getsubs()
PREINIT:
char *rv = NULL;
@@ -308,7 +310,7 @@ _remove_filter(filterName)
}
}
-const char *
+const utf8 *
wordwrap(in, cols)
const char *in
int cols
@@ -320,7 +322,8 @@ wordwrap(in, cols)
OUTPUT:
RETVAL
CLEANUP:
- if (rv) owl_free(rv);
+ if (rv)
+ owl_free(rv);
void
add_dispatch(fd, cb)
@@ -423,7 +426,7 @@ get_zephyr_variable(name)
OUTPUT:
RETVAL
-const char *
+const utf8 *
skiptokens(str, n)
const char *str;
int n;
@@ -563,7 +566,7 @@ replace_region(string)
OUTPUT:
RETVAL
-const char *
+const utf8 *
get_region()
PREINIT:
char *region;
View
8 typemap
@@ -0,0 +1,8 @@
+TYPEMAP
+utf8 * T_PV_UTF8
+const utf8 * T_PV_UTF8
+
+OUTPUT
+T_PV_UTF8
+ sv_setpv((SV*)$arg, $var);
+ SvUTF8_on((SV*)$arg);

0 comments on commit 39e81f7

Please sign in to comment.