wchar_t and XS

[email protected] (Alberto Simões)
Newsgroups perl.xs
Organization Departamento de Informática - Univer sidade do Minho
Message-ID <[email protected]>
Hello

I really need to make my code work with XS and wchar_t.
As far as I can tell there is no typemap for that in the core:

xs/NATools.c:733: warning: passing argument 3 of ‘Perl_sv_setpv’ from 
incompatible pointer type

I googled for that, and found a typemap, but I do not understand how 
typemaps work. My typemap looks like:

------ 8< ----------


TYPEMAP
wchar_t

INPUT
T_WCHAR
    {
    // Alloc memory for wide char string. This could be a bit more
    // then necessary.
    Newz(0, $var, SvLEN($arg), wchar_t);

    U8* src = (U8*) SvPV_nolen($arg);
    wchar_t* dst = (wchar_t*) $var;

    if (SvUTF8($arg)) {
       // UTF8 to wide char mapping
       STRLEN len;
       while (*src) {
           *dst++ = utf8_to_uvuni(src, &len);
           src += len;
       }
    } else {
        // char to wide char mapping
        while (*src) {
            *dst++ = (wchar_t) *src++;
        }
    }
    *dst = 0;
    SAVEFREEPV($var);
    }
------ 8< -------------

But then, this seems to be a Perl => wchar only. I would need the other 
way around too.

Any help?

Thanks
Ambs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.