Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
104 lines (68 sloc) 2.14 KB
/*
Copyright (C) 2009, Jonathan Worthington and friends
This file is distributed under the same terms as Parrot itself; see the
file LICENSE in the source root for details.
=head1 NAME
src/pmc/p5invocation.pmc - Perl 5 method invocation helper
=head1 DESCRIPTION
This PMC is used to map the invocation of a Perl 5 method onto the Parrot
invocation model and calling conventions.
=cut
*/
#include "blizkost.h"
pmclass P5Invocation group blizkost_group dynpmc auto_attrs {
ATTR PMC *p5i;
ATTR STRING *name;
/*
=item C<void init()>
Set up P5Invocation PMC.
=cut
*/
VTABLE void init() {
PObj_custom_mark_SET(SELF);
}
/*
=item C<void mark()>
Mark GC-ables.
=cut
*/
VTABLE void mark() {
PMC *p5i;
STRING *name;
GET_ATTR_p5i(interp, SELF, p5i);
GET_ATTR_name(interp, SELF, name);
if (p5i)
Parrot_gc_mark_PObj_alive(interp, (PObj*)p5i);
if (name)
Parrot_gc_mark_PObj_alive(interp, (PObj*)name);
}
/*
=item C<void *invoke(void *next)>
Handles the actual invocation.
=cut
*/
VTABLE opcode_t *invoke(void *next) {
STRING *name;
char *c_name;
PMC *p5i, *results;
PMC *ctx = CURRENT_CONTEXT(interp);
PMC *call_object = Parrot_pcc_get_signature(interp, ctx);
PMC *positional, *named;
PerlInterpreter *my_perl;
SV *namesv;
Parrot_pcc_fill_params_from_c_args(interp, call_object, "PsPns",
&positional, &named);
/* Get the interpreter, SV and the name. */
GET_ATTR_p5i(interp, SELF, p5i);
GETATTR_P5Interpreter_my_perl(interp, p5i, my_perl);
GET_ATTR_name(interp, SELF, name);
c_name = Parrot_str_to_cstring(interp, name);
namesv = newSVpv(c_name, strlen(c_name));
blizkost_call_in(interp, p5i, namesv, G_METHOD | G_ARRAY, positional,
named, &results);
SvREFCNT_dec(namesv);
mem_sys_free(c_name);
Parrot_pcc_build_call_from_c_args(interp, call_object, "Pf", results);
return blizkost_return_from_invoke(interp, next);
}
}
Jump to Line
Something went wrong with that request. Please try again.