Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Add .^compose for KnowHOWs.
  • Loading branch information
jnthn committed Sep 18, 2010
1 parent af90644 commit f13c33a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/metamodel/knowhow_bootstrapper.c
Expand Up @@ -68,6 +68,13 @@ static void find_method(PARROT_INTERP, PMC *nci) {
Parrot_pcc_build_call_from_c_args(interp, capture, "P", method);
}

/* Composes the meta-object. */
static void compose(PARROT_INTERP, PMC *nci) {
PMC *capture = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
PMC *obj = VTABLE_get_pmc_keyed_int(interp, capture, 1);
Parrot_pcc_build_call_from_c_args(interp, capture, "P", obj);
}

/* Wraps up a C function as a raw NCI method. */
static PMC * wrap_c(PARROT_INTERP, void *func) {
PMC * const wrapped = Parrot_pmc_new(interp, enum_class_NCI);
Expand Down Expand Up @@ -118,6 +125,9 @@ void RakudoObject_bootstrap_knowhow(PARROT_INTERP) {
VTABLE_set_pmc_keyed_str(interp, knowhow_how->methods,
Parrot_str_new_constant(interp, "add_method"),
wrap_c(interp, F2DPTR(add_method)));
VTABLE_set_pmc_keyed_str(interp, knowhow_how->methods,
Parrot_str_new_constant(interp, "compose"),
wrap_c(interp, F2DPTR(compose)));

/* Set this built up HOW as the KnowHOW's HOW. */
STABLE(knowhow_pmc)->HOW = knowhow_how_pmc;
Expand Down

0 comments on commit f13c33a

Please sign in to comment.