Sorry it says, typemap not defined. Could the typemap be the same as
wchar_t* ?
-----Original Message-----
From: Soumen Das [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 14, 2000 4:06 PM
To: Nick Ing-Simmons
Cc: [EMAIL PROTECTED]
Subject: RE: Return Value : Constants
wchar_t **
===========
One of the C++ API has it's prototype as..
long ConfirmAdd(void * pvChild, wchar_t* *psError=NULL);
I tried to follow your suggestion but it says wchar_t** prototype not
defined. Do I have to define a prototype for the same ?
-----Original Message-----
From: Nick Ing-Simmons [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 12, 2000 3:28 PM
To: [EMAIL PROTECTED]
Cc: Nick Ing-Simmons; [EMAIL PROTECTED]
Subject: RE: Return Value : Constants
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