pike.git / src / module.c

version» Context lines:

pike.git/src/module.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/ + #include "global.h"   #include "module.h"   #include "macros.h"   #include "error.h" -  + #include "builtin_functions.h" + #include "main.h" + #include "svalue.h" + #include "interpret.h" + #include "stralloc.h" + #include "object.h" + #include "mapping.h"    - #include "modlist.h" + #include "modules/modlist_headers.h"    - struct module *current_module=module_list; + typedef void (*modfun)(void);    - void init_modules_efuns() + struct static_module   { -  unsigned int e; -  for(e=0;e<NELEM(module_list);e++) -  { -  current_module=module_list+e; -  module_list[e].init_efuns(); -  } -  current_module=module_list; - } +  char *name; +  modfun init; +  modfun exit; + };    - void init_modules_programs() + static struct static_module module_list[] = { +  { "builtin", init_main, exit_main } + #include "modules/modlist.h" + }; +  + void init_modules(void)   {    unsigned int e; -  +  struct mapping *m = allocate_mapping(10); +  m->refs++; +  push_text("_static_modules"); +  push_mapping(m); +  f_add_constant(2); +     for(e=0;e<NELEM(module_list);e++)    { -  current_module=module_list+e; -  module_list[e].init_programs(); +  struct program *p; +  struct object *o; +  struct pike_string *s; +  start_new_program(); +  module_list[e].init(); +  p=end_program(); +  +  o=clone(p,0); +  free_program(p); +  +  push_text(module_list[e].name); +  push_object(o); +  mapping_insert(m, sp-2, sp-1); +  pop_n_elems(2);    } -  current_module=module_list; +    }    - void exit_modules() + void exit_modules(void)   {    int e; -  for(e=NELEM(module_list)-1;e>=0;e--) module_list[e].exit(); +  for(e=NELEM(module_list)-1;e>=0;e--) +  module_list[e].exit();   }