226 | | Metahandlers are responsible for implementing the semantics of an HLL module for each Apache phase. If a module registers a hook with Apache, mod_parrot will call the metahandler for that hook during that phase. The metahandler then executes the actual HLL handler code specified in the configuration and returns the status. In this way, the metahandler acts as a proxy, hiding the implementation details of the HLL module from Apache and mod_parrot. For example, mod_perl6 passes an Apache::RequestRec object to response handlers, but mod_parrot doesn't know that -- it's up to the mod_perl6 metahandler to pass the Apache::RequestRec object to the handler code. |
| 226 | Metahandlers are responsible for implementing the semantics of an HLL module for each Apache phase. If a module registers a hook with Apache, mod_parrot will call the metahandler for that hook during that phase. The metahandler then executes the actual HLL handler code specified in the configuration and returns the status. In this way, the metahandler acts as a proxy, hiding the implementation details of the HLL module from Apache and mod_parrot. For example, mod_perl6 passes an {{{Apache::RequestRec}}} object to response handlers, but mod_parrot doesn't know that -- it's up to the mod_perl6 metahandler to pass the {{{Apache::RequestRec}}} object to the handler code. |
| 354 | Now that we have all of this information, we can finally register our HLL module. The only missing piece is the name of the module. The mod_parrot convention is {{{modparrot_hllname_module}}}, where {{{hllname}}} is the name of your language (e.g. {{{modparrot_perl6_module}}}). This will prevent name clashes with non-mod_parrot modules for the same language, which is likely for languages like PHP and Python that already have modules. |
| 355 | |
| 356 | With the name in hand, we can call {{{ModParrot;Apache;add_module}}} to register our module. Its prototype is as follows: |
| 357 | |
| 358 | {{{VOID add_module(STRING module_name, STRING hll_namespace, PMC command_array, PMC hook_array)}}} |
| 359 | |
| 360 | {{{hll_namespace}}} is the namespace of your module under {{{ModParrot;HLL}}}. |
| 361 | |
| 362 | There is no return value from this subroutine; errors that occur when registering a module are fatal and will print an error message and exit. |
| 363 | |
| 364 | ''Example: Registering the PIR HLL module'' |
| 365 | |
| 366 | {{{ |
| 367 | add_module = get_hll_global [ 'ModParrot'; 'Apache'; 'Module' ], 'add' |
| 368 | add_module("modparrot_pir_module", "PIR", cmds, hooks) |
| 369 | }}} |
| 370 | |
| 371 | HINT: If you are registering ALL hooks, use an array with the single value MP_HOOK_ALL, rather than populating the array with every hook constant. |
| 372 | |