Soumen Das <[EMAIL PROTECTED]> writes:
>Thanks. I have perl 5.6 installed. I looked at the typemap and i find both
>mapped as follows..
>char * T_PV
>wchar_t * T_PV
>Is there something wrong here ?
That is ok as an INPUT ( perl -> lib ) typemap but no good
for the other direction.
>
>The other thing if I had to map const wchar_t**, how would I do it ? I also
>have API's with such return types.
Generally speaking SomeType ** is normally passing/returning a list.
IMHO it is better to do such things long-hand in the CODE/PPCODE
section so that you can use perl list idiom.
e.g. (very skeletal!)
YourFunction(...,@list);
becomes something like:
YourFunction(...,@list)
CODE:
{
wchar_t **list;
Newz('X',list,items-start,wchar_t *);
for (i=start; i < items; i++)
list[i] = sv_to_wchar_converter_you_devise(ST(i));
YourFuntion(...,list,...);
Safefree(list);
}
and
@list = YourFunction();
becomes
void
PPCODE:
{
wchar_t *list[SIZE];
int n = 0;
YourFunction(...,list,...);
while (*list) /* or whatever indicates number */
{
XPUSHs(sv_2mortal(your_wchar_to_sv_converter(list[n++]));
}
XSRETURN(n);
}
But you are still going to have to UTF-8 map the wide chars somehow.
And no perl has that yet. In development track there are parts
of it _if_ you know wchar_t is holding Unicode then
you could do use uv_to_utf8() char at a time.
If wchar_t is in some other encoding then Encode.pm may help.
>But if you want perl to see a sane string you need
> (a) perl5.6.0 or later
> (b) something to translate wchar_t * into UTF-8 encoded Unicode.
> This is still work-in-progress
--
Nick Ing-Simmons