-
Notifications
You must be signed in to change notification settings - Fork 138
/
PMC.pm
93 lines (57 loc) · 1.97 KB
/
PMC.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package Parrot::PMC;
# Copyright (C) 2006-2009, Parrot Foundation.
use strict;
use warnings;
our $VERSION = '20081006';
use Parrot::Embed;
1;
__END__
=head1 NAME
Parrot::PMC - access a Parrot PMC from Perl 5
=head1 VERSION
Version 20081006
=head1 SYNOPSIS
# find a subroutine to invoke
my $sub_pmc = $interp->find_global( 'some_parrot_sub' );
my $other_sub_pmc = $interp->find_global( 'another_sub', 'NameSpace' );
# invoke the subroutine
my $result_pmc = $sub_pmc->invoke( $signature, @args );
# get the values out of it
my $string_val = $result_pmc->get_string( $interp );
=head1 METHODS
This object provides several methods:
=over 4
=item * C<invoke( $signature, $argument )>
Given a Sub PMC or derivative, calls the appropriate Parrot function, parsing
the C<$signature> and passing a single string C<$argument>. The first
character of the C<$signature> string denotes the return value. The remaining
characters are the argument values, per the list:
=over 4
=item v void (return only)
=item I integer
=item N float
=item S string
=item P PMC
=back
In the future, this method may handle this translation for you automatically,
though it may I<not> deduce the return type correctly.
=item * C<get_string()>
Retrieves the string value of the PMC. Not all PMCs support this.
=back
=head1 AUTHOR
chromatic, C<< <chromatic at wgz.org> >>
=head1 BUGS
There are three known deficiencies. First, there should be separate classes
for separate Parrot PMC types. Second, there should be overloadings to handle
various types of getting and setting values on PMCs. Third, the C<invoke()>
methods do not handle enough signatures.
Patches welcome.
Please report any bugs or feature requests to the Parrot Porters mailing list.
Someday there may be a CPAN version of this code. Who knows?
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: