Skip to content

Commit 80f6d1a

Browse files
committed
Provide a way for libs to register containers.
This means that Rakudo will be able to set up its scalar handling.
1 parent 92f47c4 commit 80f6d1a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/6model/containers.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ ContainerConfigurer * SixModelObject_get_container_config(PARROT_INTERP, STRING
130130
/* Does initial setup work of the container registry, including registering
131131
* the various built-in container types. */
132132
void SixModelObject_containers_setup(PARROT_INTERP) {
133+
/* Set up object for dynamically registering extra configurers. */
134+
PMC *dyn_reg_func = Parrot_pmc_new(interp, enum_class_Pointer);
135+
VTABLE_set_pointer(interp, dyn_reg_func, SixModelObject_add_container_config);
136+
VTABLE_set_pmc_keyed_str(interp, interp->root_namespace,
137+
Parrot_str_new_constant(interp, "_REGISTER_CONTCONF"), dyn_reg_func);
138+
133139
/* Initialize registry. */
134140
container_registry = Parrot_pmc_new(interp, enum_class_Hash);
135141
Parrot_pmc_gc_register(interp, container_registry);

src/6model/sixmodelobject.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,12 @@ typedef INTVAL (* rf) (PARROT_INTERP, STRING *name, REPROps * (*reg) (PARROT_INT
476476
VTABLE_get_pmc_keyed_str(interp, interp->root_namespace, \
477477
Parrot_str_new_constant(interp, "_REGISTER_REPR"))))(interp, name, reg_func)
478478

479+
/* Dynamic container configuration registration. */
480+
typedef void (*cspec_conf) (PARROT_INTERP, STRING *name, ContainerConfigurer *configurer);
481+
#define REGISTER_DYNAMIC_CONTAINER_CONFIG(interp, name, configurer) \
482+
((cspec_conf) \
483+
VTABLE_get_pointer(interp, \
484+
VTABLE_get_pmc_keyed_str(interp, interp->root_namespace, \
485+
Parrot_str_new_constant(interp, "_REGISTER_CONTCONF"))))(interp, name, configurer)
486+
479487
#endif

0 commit comments

Comments
 (0)