develooper Front page | perl.perl5.porters | Postings from January 2003

Re: Checking if regex matches from XS

Thread Previous
From:
Nick Ing-Simmons
Date:
January 19, 2003 09:56
Subject:
Re: Checking if regex matches from XS
Message ID:
20030119175553.5159.12@bactrian.ni-s.u-net.com
Dave Rolsky <autarch@urth.org> writes:
>On Sun, 19 Jan 2003, Nick Ing-Simmons wrote:
>
>> Dave Rolsky <autarch@urth.org> writes:
>> >I've read the Jenness/Cozens book and the various perldocs on XS, but I
>> >can find no hint of how to use the regex engine from XS.
>>
>> It is tricky and risky - trying to use perl's regex engine
>> to subsitute for Tcl's is one of the recurring porting issues
>> with perl/Tk.
>>
>> The main snag (as I recall) is that in perl you need an "OP" in order
>> to call some of regex engine.
>
>Sigh ...
>
>I was afraid someone would say something like that.

It does not have to be an OP that is linked anywhere - tkGlue.c
does do that, and it worked fine till UTF-8 stuff came along.
Now something is not-quite-right :-( 

>
>> Unless you _really_ need this I strongly recommend writing the
>> "leaf" functions for this in perl and perl_call_sv()-ing them from your
>> XS code.
>
>Well, the main reason Ilya and I are working on this XS code (for
>Params::Validate) is to speed it up.  Calling back and forth to Perl
>unnecessarily somewhat defeats the purpose.
>
>> Unless Hugo wants to give us a clean interface?
>
>That'd be cool for the future.
>
>One thing I'd say in general about XS is that it just doesn't expose
>enough of Perl's functionality, at least not in what's documented.  

Depends what you consider documented :-)
XS pods document what "we" are reasonably happy maintaining as an 
interface.

If you want to you can get at _anything_ via an XS hook.

>And I
>include the Jenness/Cozens book in that documentation (good book, but it
>doesn't cover everthing I _want_ to do with XS).
>
>For example, in the Params::Validate XS code we need to find out what
>package the caller is in.  Now, obviously Perl can do this, because we
>have the caller() function.  Ilya somehow found the CopSTASHPV macro, and
>then I found an equivalent way to do this for Perl 5.00503, but it's all a
>nasty hack since this isn't a documented interface.

I agree caller() is one of several things that are easy in perl, but 
code that implements them is "inline" in some pp_xxxx() and not 
easy to re-use from C/XS. 

>
>It seems to me that ideally you could call any Perl function from XS.  I
>realize that's extremely difficult, but there must be some subset of
>Perl's functionality easily available from XS that isn't documented (like
>CopSTASHPV).

You can get at anything - but calling pp_caller() for example effectively 
calls back into perl with associated stack twiddling.


>
>
>-dave
>
>/*=======================
>House Absolute Consulting
>www.houseabsolute.com
>=======================*/
-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About