Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Provide a way for libs to register containers.
This means that Rakudo will be able to set up its scalar handling.
  • Loading branch information
jnthn committed Mar 19, 2013
1 parent 92f47c4 commit 80f6d1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/6model/containers.c
Expand Up @@ -130,6 +130,12 @@ ContainerConfigurer * SixModelObject_get_container_config(PARROT_INTERP, STRING
/* Does initial setup work of the container registry, including registering
* the various built-in container types. */
void SixModelObject_containers_setup(PARROT_INTERP) {
/* Set up object for dynamically registering extra configurers. */
PMC *dyn_reg_func = Parrot_pmc_new(interp, enum_class_Pointer);
VTABLE_set_pointer(interp, dyn_reg_func, SixModelObject_add_container_config);
VTABLE_set_pmc_keyed_str(interp, interp->root_namespace,
Parrot_str_new_constant(interp, "_REGISTER_CONTCONF"), dyn_reg_func);

/* Initialize registry. */
container_registry = Parrot_pmc_new(interp, enum_class_Hash);
Parrot_pmc_gc_register(interp, container_registry);
Expand Down
8 changes: 8 additions & 0 deletions src/6model/sixmodelobject.h
Expand Up @@ -476,4 +476,12 @@ typedef INTVAL (* rf) (PARROT_INTERP, STRING *name, REPROps * (*reg) (PARROT_INT
VTABLE_get_pmc_keyed_str(interp, interp->root_namespace, \
Parrot_str_new_constant(interp, "_REGISTER_REPR"))))(interp, name, reg_func)

/* Dynamic container configuration registration. */
typedef void (*cspec_conf) (PARROT_INTERP, STRING *name, ContainerConfigurer *configurer);
#define REGISTER_DYNAMIC_CONTAINER_CONFIG(interp, name, configurer) \
((cspec_conf) \
VTABLE_get_pointer(interp, \
VTABLE_get_pmc_keyed_str(interp, interp->root_namespace, \
Parrot_str_new_constant(interp, "_REGISTER_CONTCONF"))))(interp, name, configurer)

#endif

0 comments on commit 80f6d1a

Please sign in to comment.