Dan Kogai <[EMAIL PROTECTED]> writes:
>On Saturday, Aug 9, 2003, at 00:08 Asia/Tokyo, Simon Cozens wrote:
>> This is sad and I ought to know the answer, but...
>>
>> Can someone give me a few quick examples of creating Encode::XS objects
>> to do simple transcoding, from XS?
>
>You should check the source of PerlIO::encoding 
>(ext/PerlIO/encoding/encoding.xs) to see how to do so via XS.  But I 
>don't think you'd call it simple.  Let me quote a few lines from there;
>
>         PUSHMARK(sp);
>         XPUSHs(e->enc);
>         XPUSHs(e->dataSV);
>         XPUSHs(e->chk);
>         PUTBACK;
>         if (call_method("decode", G_SCALAR) != 1) {
>             Perl_die(aTHX_ "panic: decode did not return a value");
>         }
>         SPAGAIN;
>         uni = POPs;
>
>See?  It does exactly what you would call an ordinary perl 
>(sub|method)s from XS; you push arguments into the stack, call_method() 
>and pop the result.  In other words, there is no shortcut -- yet.

The 'yet' is signifcant. One of motivations for the "compiled" .ucm 
form so that transcoder was all in C was to allow a short-cut.
However Tk804 is essentially using the above and works reasonably well.




>
>Dan the Encode Maintainer

Reply via email to