/* Creates a Perl 6 object of the type given by C<classname> */ static PMC * Rakudo_binding_create(PARROT_INTERP, STRING *classname) { PMC *ns = Parrot_get_ctx_HLL_namespace(interp); PMC *class_ns = Parrot_ns_get_namespace_keyed_str(interp, ns, classname); PMC *class_obj = VTABLE_get_class(interp, class_ns); PMC *result = VTABLE_instantiate(interp, class_obj, PMCNULL); return result; }
PARROT_API Parrot_Int Parrot_api_pmc_new_from_class(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC class_pmc), ARGIN_NULLOK(Parrot_PMC init), ARGOUT(Parrot_PMC * pmc)) { ASSERT_ARGS(Parrot_api_pmc_new_from_class) EMBED_API_CALLIN(interp_pmc, interp) Parrot_PMC initializer = init ? init : PMCNULL; *pmc = VTABLE_instantiate(interp, class_pmc, initializer); EMBED_API_CALLOUT(interp_pmc, interp) }
/* Creates a Perl 6 Array. */ static PMC * Rakudo_binding_create_positional(PARROT_INTERP, PMC *rest, STRING *type_str) { static PMC *truepmc = NULL; PMC *hll_ns = Parrot_get_ctx_HLL_namespace(interp); PMC *arr_ns = Parrot_ns_get_namespace_keyed_str(interp, hll_ns, type_str); PMC *arr_class = VTABLE_get_class(interp, arr_ns); PMC *result = VTABLE_instantiate(interp, arr_class, PMCNULL); INTVAL type_id = pmc_type(interp, Parrot_str_new(interp, "P6opaque", 0)); result->vtable = interp->vtables[type_id]; if (!truepmc) truepmc = VTABLE_get_pmc_keyed_str(interp, hll_ns, Parrot_str_new(interp, "True", 0)); VTABLE_set_attr_str(interp, result, Parrot_str_new(interp, "$!flat", 0), truepmc); VTABLE_set_attr_str(interp, result, Parrot_str_new(interp, "@!rest", 0), rest); return result; }