Changes between Version 21 and Version 22 of ModParrotHLLDocs

Show
Ignore:
Timestamp:
12/25/08 22:17:48 (6 years ago)
Author:
jhorwitz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ModParrotHLLDocs

    v21 v22  
    224224== Metahandlers == 
    225225 
    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. 
     226Metahandlers 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. 
    227227 
    228228=== Apache Hooks === 
     
    352352== Registering the HLL Apache Module == 
    353353 
     354Now 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 
     356With 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 
     362There 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 
     371HINT: 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 
    354373== Miscellany == 
    355374