[32598] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3871 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 28 21:09:19 2013

Date: Mon, 28 Jan 2013 18:09:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 28 Jan 2013     Volume: 11 Number: 3871

Today's topics:
    Re: Callback to Perl interpreter in C--something simple <kw@codebykevin.com>
    Re: Callback to Perl interpreter in C--something simple <greymausg@mail.com>
    Re: Callback to Perl interpreter in C--something simple <rweikusat@mssgmbh.com>
    Re: Callback to Perl interpreter in C--something simple <rweikusat@mssgmbh.com>
    Re: Trouble with embedded whitespace in filenames using <clint.olsen@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 27 Jan 2013 22:50:50 -0500
From: Kevin Walzer <kw@codebykevin.com>
Subject: Re: Callback to Perl interpreter in C--something simpler than XS?
Message-Id: <ke4sik$evi$1@dont-email.me>

On 1/26/13 9:20 AM, Ben Morrow wrote:
> I would recommend staying away from SWIG, at least for perl. I've never
> seen a SWIG-generated perl extension that was anything other than
> painful to use; IMHO it's trying too hard to provide a cross-interpreter
> interface, and the various interpreters' APIs aren't really compatible
> enough for that to work. A basic XS interface that doesn't do anything
> clever is just a matter of going through and listing the functions
> involved.

I think I'm going to take a different tack here: ActiveState's Tkx 
module, which allows you to put a Tk interface on a Perl app, also 
includes fairly complete integration with the Tcl interpreter. I have a 
working Tcl AppleEvent implementation in my apps written in Tcl, and I 
can probably access that from Perl, and even use Perl callbacks, via the 
Tkx module. I had thought this would involve a lot of overhead and 
wanted to see if I could get a Perl-native implementation going, but it 
seems too convoluted for me. Thanks for your time.

--Kevin

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com


------------------------------

Date: 28 Jan 2013 09:55:42 GMT
From: greymaus <greymausg@mail.com>
Subject: Re: Callback to Perl interpreter in C--something simpler than XS?
Message-Id: <slrnkgcgca.47h.greymausg@gmaus.org>

On 2013-01-28, Kevin Walzer <kw@codebykevin.com> wrote:
> On 1/26/13 9:20 AM, Ben Morrow wrote:
>> I would recommend staying away from SWIG, at least for perl. I've never
>> seen a SWIG-generated perl extension that was anything other than
>> painful to use; IMHO it's trying too hard to provide a cross-interpreter
>> interface, and the various interpreters' APIs aren't really compatible
>> enough for that to work. A basic XS interface that doesn't do anything
>> clever is just a matter of going through and listing the functions
>> involved.
>
> I think I'm going to take a different tack here: ActiveState's Tkx 
> module, which allows you to put a Tk interface on a Perl app, also 
> includes fairly complete integration with the Tcl interpreter. I have a 
> working Tcl AppleEvent implementation in my apps written in Tcl, and I 
> can probably access that from Perl, and even use Perl callbacks, via the 
> Tkx module. I had thought this would involve a lot of overhead and 
> wanted to see if I could get a Perl-native implementation going, but it 
> seems too convoluted for me. Thanks for your time.
>
> --Kevin
>

Man2Doctor "When I hold my arm this way, I get an incredible pain"
Doctor2Man "Well, dont hold your arm that way"


-- 
maus
 .
  .
 ...


------------------------------

Date: Mon, 28 Jan 2013 10:43:58 +0000
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Callback to Perl interpreter in C--something simpler than XS?
Message-Id: <87y5fdk2oh.fsf@sapphire.mobileactivedefense.com>

Kevin Walzer <kw@codebykevin.com> writes:
> On 1/26/13 9:20 AM, Ben Morrow wrote:
>> I would recommend staying away from SWIG, at least for perl. I've never
>> seen a SWIG-generated perl extension that was anything other than
>> painful to use; IMHO it's trying too hard to provide a cross-interpreter
>> interface, and the various interpreters' APIs aren't really compatible
>> enough for that to work. A basic XS interface that doesn't do anything
>> clever is just a matter of going through and listing the functions
>> involved.
>
> I think I'm going to take a different tack here: ActiveState's Tkx
> module, which allows you to put a Tk interface on a Perl app, also
> includes fairly complete integration with the Tcl interpreter. I have
> a working Tcl AppleEvent implementation in my apps written in Tcl, and
> I can probably access that from Perl, and even use Perl callbacks, via
> the Tkx module. I had thought this would involve a lot of overhead and
> wanted to see if I could get a Perl-native implementation going, but
> it seems too convoluted for me.

That's IMHO an impression you mostly got because you were seeking for
the Tcl-interface you're familiar with in Perl --- but the Perl
interface is different. In the following, I'm going to assume that the
AppleScript event handler is registered with some Apple library and
then called from the library as part of some kind of 'event loop'
processing. If this is so, the way to integrate this with perl would
involve:

	- provide an initialization function callable from perl via
          XS which performs any initialization which may be necessary
          and enables the caller to register a Perl subroutine
          supposed to handle the events

	- provide a second perl-callable function which enters the
          event loop

The C event handler routine would then need to invoke the Perl
callback (=> perlcall) and pass the results back to the library after
the Perl program called the init rouine and entered the event loop.

That's not really difficult and while XS seems somewhat dauting at a
first glance, for simple cases, like the one you have here, declaring
the signatures of the Perl entry points should be sufficient. As a
contrived example and without the boilerplate, for the init routine,
this could look like this:

int
event_library_init(subref)
	SV * subref

which declares an XS routine returning an int to Perl and taking a
single argument which will be a pointer to a 'scalar value' (SV). The
actual code will then be generated by the xsubpp preprocessor. The
h2xs program is also very helpful to 'jumpstart' a new extension
module.


------------------------------

Date: Mon, 28 Jan 2013 10:45:47 +0000
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Callback to Perl interpreter in C--something simpler than XS?
Message-Id: <87txq1k2lg.fsf@sapphire.mobileactivedefense.com>

greymaus <greymausg@mail.com> writes:
> On 2013-01-28, Kevin Walzer <kw@codebykevin.com> wrote:
>> On 1/26/13 9:20 AM, Ben Morrow wrote:
>>> I would recommend staying away from SWIG, at least for perl. I've never
>>> seen a SWIG-generated perl extension that was anything other than
>>> painful to use; IMHO it's trying too hard to provide a cross-interpreter
>>> interface, and the various interpreters' APIs aren't really compatible
>>> enough for that to work. A basic XS interface that doesn't do anything
>>> clever is just a matter of going through and listing the functions
>>> involved.
>>
>> I think I'm going to take a different tack here: ActiveState's Tkx 
>> module, which allows you to put a Tk interface on a Perl app, also 
>> includes fairly complete integration with the Tcl interpreter. I have a 
>> working Tcl AppleEvent implementation in my apps written in Tcl, and I 
>> can probably access that from Perl, and even use Perl callbacks, via the 
>> Tkx module. I had thought this would involve a lot of overhead and 
>> wanted to see if I could get a Perl-native implementation going, but it 
>> seems too convoluted for me. Thanks for your time.
>>
>> --Kevin
>>
>
> Man2Doctor "When I hold my arm this way, I get an incredible pain"
> Doctor2Man "Well, dont hold your arm that way"

Son2Father: Whenever I try to stand up and walk, I fall down!
Father2Son: You're only seventeen, kid, and should really stay away
from this adult stuff for somewhat longer. While it won't help you
stay young, it might even make you feel as if you remained a happy
toddler for some years to come!


------------------------------

Date: Sun, 27 Jan 2013 19:40:17 -0800 (PST)
From: Clint O <clint.olsen@gmail.com>
Subject: Re: Trouble with embedded whitespace in filenames using File::Find
Message-Id: <b8386a21-4b2a-48e5-8e04-9b868768dbe1@googlegroups.com>

On Monday, January 21, 2013 10:26:02 PM UTC-8, Ben Morrow wrote: 
> 
> That's easy. Step one: find a real news client. Step two: find a real
> news server.
> 
> Google Groups is unusable as a posting interface to Usenet.

I used to use slrn. Is there anything better than that these days? I do have a subscription to Supernews.

Thanks,

-Clint


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 3871
***************************************


home help back first fref pref prev next nref lref last post