Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Parrot as an extension language
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 45 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Colin Paul Adams  
View profile  
 More options May 17 2005, 10:00 am
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 17 May 2005 15:00:14 +0100
Local: Tues, May 17 2005 10:00 am
Subject: Parrot as an extension language
Hello,

I am writing an XSLT 2.0 processor, and I want to give users the
option to write their own message and error handling routines and the
like in their favourite scripting language. So I thought of using
parrot.

But when I look at http://www.parrotcode.org/docs/embed.html, I can
see no way of getting information back from the script - not even an
exit code. Is there anyway of doing this that I have missed?
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Autrijus Tang  
View profile  
 More options May 17 2005, 10:15 am
Newsgroups: perl.perl6.internals
From: autri...@autrijus.org (Autrijus Tang)
Date: Tue, 17 May 2005 22:15:32 +0800
Local: Tues, May 17 2005 10:15 am
Subject: Re: Parrot as an extension language

On Tue, May 17, 2005 at 03:00:14PM +0100, Colin Paul Adams wrote:
> But when I look at http://www.parrotcode.org/docs/embed.html, I can
> see no way of getting information back from the script - not even an
> exit code. Is there anyway of doing this that I have missed?

You may wish to use Parrot_call_sub's "SS" form, where you pass in a
string and get back a string.  Something like this:

    my $interp = Parrot_new(undef);

    # ... load a .pir file or some other code into $interp ...

    my $code_pmc = Parrot_find_global(
        $interp,
        const_string("Namespace"),
        const_string("sub_name"),
    );

    my $return_str = Parrot_call_sub(
        $interp,
        $code_pmc,
        const_string("SS"),
        const_string("Your_input_string_here"),
    );

Thanks,
/Autrijus/

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 17 2005, 10:40 am
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 17 May 2005 15:40:31 +0100
Local: Tues, May 17 2005 10:40 am
Subject: Re: Parrot as an extension language

>>>>> "Jeff" == Jeff Horwitz <j...@smashing.org> writes:

    Jeff> you'll probably want to use the Parrot_call_sub_* API to
    Jeff> call individual subroutines and get return values.  "perldoc
    Jeff> extend.c" in the parrot source for more info.  you might

Thanks - I'll take a look at that.

    Jeff> also have a look at the mod_parrot source
    Jeff> (http://www.smashing.org/mod_parrot), which is one of the
    Jeff> few apps embedding parrot at the moment.  the other is pugs
    Jeff> (http://www.pugscode.org), but it's written in haskell.

Why's that a but? Haskell's a good language.
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Horwitz  
View profile  
 More options May 17 2005, 10:44 am
Newsgroups: perl.perl6.internals
From: j...@smashing.org (Jeff Horwitz)
Date: Tue, 17 May 2005 10:44:40 -0400 (EDT)
Local: Tues, May 17 2005 10:44 am
Subject: Re: Parrot as an extension language
On 17 May 2005, Colin Paul Adams wrote:

>     Jeff> also have a look at the mod_parrot source
>     Jeff> (http://www.smashing.org/mod_parrot), which is one of the
>     Jeff> few apps embedding parrot at the moment.  the other is pugs
>     Jeff> (http://www.pugscode.org), but it's written in haskell.

> Why's that a but? Haskell's a good language.

no argument there -- just assumed you were looking for examples in C!  :)

-jeff


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Horwitz  
View profile  
 More options May 17 2005, 10:13 am
Newsgroups: perl.perl6.internals
From: j...@smashing.org (Jeff Horwitz)
Date: Tue, 17 May 2005 10:13:21 -0400 (EDT)
Local: Tues, May 17 2005 10:13 am
Subject: Re: Parrot as an extension language
you'll probably want to use the Parrot_call_sub_* API to call individual
subroutines and get return values.  "perldoc extend.c" in the parrot
source for more info.  you might also have a look at the mod_parrot source
(http://www.smashing.org/mod_parrot), which is one of the few apps
embedding parrot at the moment.  the other is pugs (http://www.pugscode.org),
but it's written in haskell.

-jeff

On 17 May 2005, Colin Paul Adams wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 17 2005, 12:31 pm
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 17 May 2005 17:31:32 +0100
Local: Tues, May 17 2005 12:31 pm
Subject: Re: Parrot as an extension language

>>>>> "Autrijus" == Autrijus Tang <autri...@autrijus.org> writes:

    Autrijus> You may wish to use Parrot_call_sub's "SS" form, where
    Autrijus> you pass in a string and get back a string.

I take it SS stands for String-to-String?

Which section within http://www.parrotcode.org/docs/ covers this sort
of thing?
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 17 2005, 12:34 pm
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 17 May 2005 17:34:36 +0100
Local: Tues, May 17 2005 12:34 pm
Subject: Re: Parrot as an extension language

>>>>> "Jeff" == Jeff Horwitz <j...@smashing.org> writes:

    >>  Why's that a but? Haskell's a good language.

    Jeff> no argument there -- just assumed you were looking for
    Jeff> examples in C!  :)

Actually, examples in any language are fine.
I'm actually writing in Eiffel, but I shall use an interface generator
to automatically build low-level bridging classes from the C header
files.
I intend to make it available as a general extension mechanism for
Eiffel via parrot, as that will be almost zero effort after
implementing what I need for my program.
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Horwitz  
View profile  
 More options May 17 2005, 1:17 pm
Newsgroups: perl.perl6.internals
From: j...@smashing.org (Jeff Horwitz)
Date: Tue, 17 May 2005 13:17:59 -0400 (EDT)
Local: Tues, May 17 2005 1:17 pm
Subject: Re: Parrot as an extension language
On 17 May 2005, Colin Paul Adams wrote:

> Actually, examples in any language are fine.
> I'm actually writing in Eiffel, but I shall use an interface generator
> to automatically build low-level bridging classes from the C header
> files.
> I intend to make it available as a general extension mechanism for
> Eiffel via parrot, as that will be almost zero effort after
> implementing what I need for my program.

this is similar to what we did with pugs, except we used haskell's FFI
(foreign function interface) to call out to Parrot's API.  see
src/Pugs/Embed/Parrot.hsc in the pugs source.

> --
> Colin Adams
> Preston Lancashire

-jeff

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Autrijus Tang  
View profile  
 More options May 17 2005, 4:13 pm
Newsgroups: perl.perl6.internals
From: autri...@autrijus.org (Autrijus Tang)
Date: Wed, 18 May 2005 04:13:06 +0800
Local: Tues, May 17 2005 4:13 pm
Subject: Re: Parrot as an extension language

On Tue, May 17, 2005 at 05:31:32PM +0100, Colin Paul Adams wrote:
> I take it SS stands for String-to-String?

Yes.  "PPC" would stand for PMC -> PMC -> String, i.e. take two PMCs
and returns a String.

> Which section within http://www.parrotcode.org/docs/ covers this sort
> of thing?

`perldoc extend.c` as jhorwitz mentioned.  I'm not sure it's webified
in /docs/ -- if not, maybe it should be?

Thanks,
/Autrijus/

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jerry Gay  
View profile  
 More options May 17 2005, 4:45 pm
Newsgroups: perl.perl6.internals
From: jerry....@gmail.com (Jerry Gay)
Date: Tue, 17 May 2005 13:45:54 -0700
Local: Tues, May 17 2005 4:45 pm
Subject: Re: Parrot as an extension language
On 5/17/05, Autrijus Tang <autri...@autrijus.org> wrote:
> On Tue, May 17, 2005 at 05:31:32PM +0100, Colin Paul Adams wrote:
> > I take it SS stands for String-to-String?

> Yes.  "PPC" would stand for PMC -> PMC -> String, i.e. take two PMCs
> and returns a String.

of course, you meant PPS here, but i can't take credit for the catch :)

from #parrot:
[13:35] Coke: autrijus - did you mean PPS, not PPC ?
[13:35] Coke: (email)
[13:36] autrijus: I meant PPS. ;)
[13:36] autrijus: please reply me to correct my mistake :)
[13:36] autrijus: <- brain autocompletion
[13:37] Coke: I can't easily reply ATM
[13:44] particle: i'll do it

~jerry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 18 2005, 6:21 am
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 18 May 2005 11:21:29 +0100
Local: Wed, May 18 2005 6:21 am
Subject: Re: Parrot as an extension language

>>>>> "Autrijus" == Autrijus Tang <autri...@autrijus.org> writes:

    Autrijus> On Tue, May 17, 2005 at 03:00:14PM +0100, Colin Paul
    Autrijus> Adams wrote:
    >> But when I look at http://www.parrotcode.org/docs/embed.html, I
    >> can see no way of getting information back from the script -
    >> not even an exit code. Is there anyway of doing this that I
    >> have missed?

    Autrijus> You may wish to use Parrot_call_sub's "SS" form, where
    Autrijus> you pass in a string and get back a string.  Something
    Autrijus> like this:

    Autrijus>     my $interp = Parrot_new(undef);

    Autrijus>     # ... load a .pir file or some other code into
    Autrijus> $interp ...

    Autrijus>     my $code_pmc = Parrot_find_global( $interp,
    Autrijus> const_string("Namespace"), const_string("sub_name"), );

    Autrijus>     my $return_str = Parrot_call_sub( $interp,
    Autrijus> $code_pmc, const_string("SS"),
    Autrijus> const_string("Your_input_string_here"), );

I'm confused by this - what language is it written in? Perl?

And will:

Parrot_PackFile Parrot_readbc(Parrot_Interp, char *filename)

    Reads in a bytecode file and returns a packfile structure for it.

accept a .pir file?
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options May 18 2005, 7:05 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Wed, 18 May 2005 13:05:32 +0200
Local: Wed, May 18 2005 7:05 am
Subject: Re: Parrot as an extension language

Colin Paul Adams wrote:
>     Autrijus>     my $return_str = Parrot_call_sub( $interp,
>     Autrijus> $code_pmc, const_string("SS"),
>     Autrijus> const_string("Your_input_string_here"), );

> I'm confused by this - what language is it written in? Perl?

APL: Autrijus' Pseudocde Language

> And will:

> Parrot_PackFile Parrot_readbc(Parrot_Interp, char *filename)

>     Reads in a bytecode file and returns a packfile structure for it.

> accept a .pir file?

No, but Parrot_load_bytecode(Interp*, const char*) will do, see the
C<load_bytecode> opcode.

leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 19 2005, 10:37 am
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 19 May 2005 15:37:31 +0100
Local: Thurs, May 19 2005 10:37 am
Subject: Re: Parrot as an extension language

>>>>> "Autrijus" == Autrijus Tang <autri...@autrijus.org> writes:

    Autrijus> You may wish to use Parrot_call_sub's "SS" form, where
    Autrijus> you pass in a string and get back a string.  Something
    Autrijus> like this:

    Autrijus>     my $interp = Parrot_new(undef);

    Autrijus>     # ... load a .pir file or some other code into
    Autrijus> $interp ...

    Autrijus>     my $code_pmc = Parrot_find_global( $interp,
    Autrijus> const_string("Namespace"), const_string("sub_name"), );

I'm having a problem with this.
For Parrot_find_global, I'm specifying global.h as one of the header
files which must be read to generate definitions from.
But this is failing, apparently because PMC isn't defined.

So I tried to find where PMC was defined - it looked like pobj.h to
me, but if I include that, I run into trouble with size_t (?!) and
DPOINTER (at least).

What headers do I need to read for the parrot_find_global call?
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 19 2005, 11:21 am
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 19 May 2005 16:21:48 +0100
Local: Thurs, May 19 2005 11:21 am
Subject: Re: Parrot as an extension language

>>>>> "Jeff" == Jeff Horwitz <j...@smashing.org> writes:

    >> What headers do I need to read for the parrot_find_global call?

    Jeff> Parrot_PMC is the public type, and behind the scenes it's
    Jeff> defined as PMC *.

    Jeff> all you should need to include is embed.h, extend.h and for
    Jeff> now, resources.h.  i'm actually working on fleshing these
    Jeff> files out to be more consistent wrt the public API.

    Jeff> see trunk/src/parrot_util.c in the mod_parrot source for a
    Jeff> working example of all this.

Thanks. That reference was useful, as they have to be in that order
(resources.h first). it compiles now.
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Horwitz  
View profile  
 More options May 19 2005, 11:00 am
Newsgroups: perl.perl6.internals
From: j...@smashing.org (Jeff Horwitz)
Date: Thu, 19 May 2005 11:00:51 -0400 (EDT)
Local: Thurs, May 19 2005 11:00 am
Subject: Re: Parrot as an extension language
On 19 May 2005, Colin Paul Adams wrote:

[snip]

> I'm having a problem with this.
> For Parrot_find_global, I'm specifying global.h as one of the header
> files which must be read to generate definitions from.
> But this is failing, apparently because PMC isn't defined.

> So I tried to find where PMC was defined - it looked like pobj.h to
> me, but if I include that, I run into trouble with size_t (?!) and
> DPOINTER (at least).

> What headers do I need to read for the parrot_find_global call?

Parrot_PMC is the public type, and behind the scenes it's defined as PMC *.

all you should need to include is embed.h, extend.h and for now,
resources.h.  i'm actually working on fleshing these files out to be more
consistent wrt the public API.

see trunk/src/parrot_util.c in the mod_parrot source for a working
example of all this.

> --
> Colin Adams
> Preston Lancashire

-jeff

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 19 2005, 12:32 pm
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 19 May 2005 17:32:02 +0100
Local: Thurs, May 19 2005 12:32 pm
Subject: Re: Parrot as an extension language

>>>>> "Jeff" == Jeff Horwitz <j...@smashing.org> writes:

    Jeff> all you should need to include is embed.h, extend.h and for
    Jeff> now, resources.h.  i'm actually working on fleshing these
    Jeff> files out to be more consistent wrt the public API.

I'm getting real close now.

But I'm having problems creating the parrot strings. I'm using

Parrot_new_string

and I'm passing "UTF-8" as the encoding name.

I get back:

Can't make 'UTF-8' charset strings

Despite what the documentation says:

encoding

This specifies the encoding used to encode the characters in the
data. There are currently four character encodings used in Parrot:
singlebyte, UTF-8, UTF-16 and UTF-32. UTF-16 and UTF-32 should use the
native endianness of the machine.

So does that mean I'm limited to singlebyte strings? If so, how do I
specify this encoding, and what is the character set that is used?
(US-ASCII ?)
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 19 2005, 1:18 pm
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 19 May 2005 18:18:12 +0100
Local: Thurs, May 19 2005 1:18 pm
Subject: Re: Parrot as an extension language

>>>>> "Colin" == Colin Paul Adams <co...@colina.demon.co.uk> writes:
>>>>> "Jeff" == Jeff Horwitz <j...@smashing.org> writes:

    Colin> Can't make 'UTF-8' charset strings

    Colin> Despite what the documentation says:

    Colin> encoding

    Colin> This specifies the encoding used to encode the characters
    Colin> in the data. There are currently four character encodings
    Colin> used in Parrot: singlebyte, UTF-8, UTF-16 and
    Colin> UTF-32. UTF-16 and UTF-32 should use the native endianness
    Colin> of the machine.

Well, I found in the code what is actually accepted (iso-8859-1, for
instance, but that is hardly acceptable).

--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options May 19 2005, 3:48 pm
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Thu, 19 May 2005 21:48:10 +0200
Local: Thurs, May 19 2005 3:48 pm
Subject: Re: Parrot as an extension language

Colin Paul Adams wrote:
> Parrot_new_string

> and I'm passing "UTF-8" as the encoding name.

> I get back:

> Can't make 'UTF-8' charset strings

                      ^^^^^^^

> Despite what the documentation says:

> encoding

Yeah. I'm sorry to say that: you are just hitting a part of Parrot
labeled "under (re)construction" and the docs aren't all up to date.

If you are using vim, "make tags" [1] in the parrot directory, follow
"string_make", which is called from Parrot_new_string() and you'll see a
more but still not complete listing of *charset*s that are supplied
currently. The ultimate list of charsets can be found in charset/*.c or
src/charset.c.

Additionally the interface doc is talking about an encoding, which is
pretty misleading:

   fixed_8 - iso_8859_xxx

   encoding - charset which one

You currently can just pass a charset, but the default encoding for the
charset "unicode" is "utf8" (now).

> This specifies the encoding used to encode the characters in the
> data. There are currently four character encodings used in Parrot:
> singlebyte, UTF-8, UTF-16 and UTF-32. UTF-16 and UTF-32 should use the
> native endianness of the machine.

That is outdated and future as well. Currently only utf8 encoding is
working (for some degree of working)

> So does that mean I'm limited to singlebyte strings?

No, pass charset "unicode",  which defaults to encoding "utf8"

leo

[1] patches for other editors very welcome


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 20 2005, 1:22 am
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 20 May 2005 06:22:04 +0100
Local: Fri, May 20 2005 1:22 am
Subject: Re: Parrot as an extension language

>>>>> "Leopold" == Leopold Toetsch <l...@toetsch.at> writes:

    Leopold> Yeah. I'm sorry to say that: you are just hitting a part
    Leopold> of Parrot labeled "under (re)construction" and the docs
    Leopold> aren't all up to date.

<snip>

    >> So does that mean I'm limited to singlebyte strings?

    Leopold> No, pass charset "unicode", which defaults to encoding
    Leopold> "utf8"

OK. Thanks for that.
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Autrijus Tang  
View profile  
 More options May 20 2005, 5:43 am
Newsgroups: perl.perl6.internals
From: autri...@autrijus.org (Autrijus Tang)
Date: Fri, 20 May 2005 17:43:47 +0800
Local: Fri, May 20 2005 5:43 am
Subject: Re: Parrot as an extension language

On Fri, May 20, 2005 at 10:34:39AM +0100, Colin Paul Adams wrote:
> I have a problem with this - namely that the function is variadic, and
> the interface generator can't cope with this.

Hmm, in Haskell FFI, we hard-coded two cases of invocation, treating
the function as two distinct, non-variadic forms:

    -- From http://svn.openfoundry.org/pugs/src/Pugs/Embed/Parrot.hsc

    -- This is the (() returns Void) form
    foreign import ccall "Parrot_call_sub"
        parrot_call_sub_vv :: ParrotInterp -> ParrotPMC -> CString -> IO ()

    -- This is the ((String, String) returns String) form
    foreign import ccall "Parrot_call_sub"
        parrot_call_sub_SSS :: ParrotInterp -> ParrotPMC -> CString -> ParrotString -> ParrotString -> IO ParrotString

Surely you can do the same with Eiffel?

Thanks,
/Autrijus/

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 20 2005, 5:34 am
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 20 May 2005 10:34:39 +0100
Local: Fri, May 20 2005 5:34 am
Subject: Re: Parrot as an extension language

>>>>> "Autrijus" == Autrijus Tang <autri...@autrijus.org> writes:

    Autrijus> On Tue, May 17, 2005 at 03:00:14PM +0100, Colin Paul
    Autrijus> Adams wrote:
    >> But when I look at http://www.parrotcode.org/docs/embed.html, I
    >> can see no way of getting information back from the script -
    >> not even an exit code. Is there anyway of doing this that I
    >> have missed?

    Autrijus> You may wish to use Parrot_call_sub's "SS" form, where
    Autrijus> you pass in a string and get back a string.  Something
    Autrijus> like this:

I have a problem with this - namely that the function is variadic, and
the interface generator can't cope with this.

So I'm going to have to do a lot of hand-coding to get round this
problem.

This is a general problem for interface generators, I believe. Would
it be possible to have more friendly functions in embed.h/c for use by
interface generators?
(By more friendly, I mean instead of ..., a single argument of some
list or array type.)
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options May 20 2005, 5:48 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Fri, 20 May 2005 11:48:17 +0200
Local: Fri, May 20 2005 5:48 am
Subject: Re: Parrot as an extension language
Colin Paul Adams <co...@colina.demon.co.uk> wrote:

> I have a problem with this - namely that the function is variadic, and
> the interface generator can't cope with this.

Have a look at src/inter_run.c e.g.

<void *
Parrot_runops_fromc_arglist(Parrot_Interp interpreter, PMC *sub,
        const char *sig, va_list args)>

leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 20 2005, 6:03 am
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 20 May 2005 11:03:49 +0100
Local: Fri, May 20 2005 6:03 am
Subject: Re: Parrot as an extension language

>>>>> "Leopold" == Leopold Toetsch <l...@toetsch.at> writes:

    Leopold> Colin Paul Adams <co...@colina.demon.co.uk> wrote:
    >> I have a problem with this - namely that the function is
    >> variadic, and the interface generator can't cope with this.

    Leopold> Have a look at src/inter_run.c e.g.

    Leopold> <void * Parrot_runops_fromc_arglist(Parrot_Interp
    Leopold> interpreter, PMC *sub, const char *sig, va_list args)>

That sounds like just the thing!
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 20 2005, 6:00 am
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 20 May 2005 11:00:25 +0100
Local: Fri, May 20 2005 6:00 am
Subject: Re: Parrot as an extension language

>>>>> "Autrijus" == Autrijus Tang <autri...@autrijus.org> writes:

    Autrijus> On Fri, May 20, 2005 at 10:34:39AM +0100, Colin Paul
    Autrijus> Adams wrote:
    >> I have a problem with this - namely that the function is
    >> variadic, and the interface generator can't cope with this.

    Autrijus> Hmm, in Haskell FFI, we hard-coded two cases of
    Autrijus> invocation, treating the function as two distinct,
    Autrijus> non-variadic forms:

    Autrijus>     -- From
    Autrijus> http://svn.openfoundry.org/pugs/src/Pugs/Embed/Parrot.hsc

    Autrijus>     -- This is the (() returns Void) form foreign import
    Autrijus> ccall "Parrot_call_sub" parrot_call_sub_vv ::
    Autrijus> ParrotInterp -> ParrotPMC -> CString -> IO ()

    Autrijus>     -- This is the ((String, String) returns String)
    Autrijus> form foreign import ccall "Parrot_call_sub"
    Autrijus> parrot_call_sub_SSS :: ParrotInterp -> ParrotPMC ->
    Autrijus> CString -> ParrotString -> ParrotString -> IO
    Autrijus> ParrotString

    Autrijus> Surely you can do the same with Eiffel?

Yes, I can, but that only copes with a single string parameter - there
are very many possibilities (strictly, infinite, though obviously not
in practice).
Also, I shall want to use the object/method calls, which adds further
to the burden.

And I'm not just coding this for my XSLT processor - I am going to
make the Eiffel library freely available to all Eiffel programmers.
That way, any Eiffel program can use any Parrot-targetted scripting
language as an extension language (and the language can be chosen by
the user of the application who wants to do the scripting, not imposed
by the developer of the application).
So this requires a lot of flexibility.

I can easily code by hand (and will, for now) just those subroutines
and methods I shall require for use within my XSLT processor, but to
do them all in general will be too much (so I shall have to request
each application deleoper to add the code necessary that they want).

And this applies to anyone else who wants to use Parrot as a
multi-lingual extension mechanism for another language.
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin Paul Adams  
View profile  
 More options May 20 2005, 12:42 pm
Newsgroups: perl.perl6.internals
From: co...@colina.demon.co.uk (Colin Paul Adams)
Date: 20 May 2005 17:42:48 +0100
Local: Fri, May 20 2005 12:42 pm
Subject: Re: Parrot as an extension language

>>>>> "Autrijus" == Autrijus Tang <autri...@autrijus.org> writes:

    Autrijus> You may wish to use Parrot_call_sub's "SS" form, where
    Autrijus> you pass in a string and get back a string.  Something
    Autrijus> like this:

    Autrijus>     my $interp = Parrot_new(undef);

    Autrijus>     # ... load a .pir file or some other code into
    Autrijus> $interp ...

    Autrijus>     my $code_pmc = Parrot_find_global( $interp,
    Autrijus> const_string("Namespace"), const_string("sub_name"), );

    Autrijus>     my $return_str = Parrot_call_sub( $interp,
    Autrijus> $code_pmc, const_string("SS"),
    Autrijus> const_string("Your_input_string_here"), );

The problem I'm finding with this, is getting back the returned string
characters.
I assume the void * returned is pointing to a Parrot String.
Certainly it's not a const char *.

There is a function declaration

Parrot_string_cstring

in string_funcs.h, but it appears to have no definitoon anywhere, so
that's not much use to me.
--
Colin Adams
Preston Lancashire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 45   Newer >
« Back to Discussions « Newer topic     Older topic »