home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / src / module.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-19  |  2.0 KB  |  64 lines

  1. // This is C++ code.
  2.  
  3. // For each module this file is to be compiled with -DMODULE=modulename
  4. // and linked to the code of the module proper.
  5.  
  6. // This file provides an initializer which gets called by __main when the
  7. // program starts up - in case of statically linked modules - or when the
  8. // module gets loaded - in case of dynamically loaded modules.
  9.  
  10. // Idea by Marcus Daniels.
  11. // Bruno Haible 18.12.1994
  12.  
  13. #ifdef NO_CLISP_H
  14. #include "lispbibl.c"
  15. #else
  16. #include "clisp.h"
  17. #endif
  18.  
  19. #ifdef DYNAMIC_MODULES
  20.  
  21. extern "C" subr_ CONCAT3(module__,MODULE,__subr_tab)[];
  22. extern "C" uintC CONCAT3(module__,MODULE,__subr_tab_size);
  23.  
  24. // Assume a struct consisting of objects has the same shape than an array of objects.
  25. extern "C" object CONCAT3(module__,MODULE,__object_tab)[];
  26. extern "C" uintC CONCAT3(module__,MODULE,__object_tab_size);
  27.  
  28. extern "C" subr_initdata CONCAT3(module__,MODULE,__subr_tab_initdata)[];
  29. extern "C" void CONCAT3(module__,MODULE,__init_function) (module_ * module);
  30.  
  31. static module_ this_module = {
  32.   /* name */           STRINGIFY(MODULE),
  33.   /* stab */           & CONCAT3(module__,MODULE,__subr_tab) [0],
  34.   /* stab_size */      & CONCAT3(module__,MODULE,__subr_tab_size),
  35.   /* otab */           & CONCAT3(module__,MODULE,__object_tab) [0],
  36.   /* otab_size */      & CONCAT3(module__,MODULE,__object_tab_size),
  37.   /* initialized */    FALSE,
  38.   /* stab_initdata */  & CONCAT3(module__,MODULE,__subr_tab_initdata) [0],
  39.   /* initfunction */   & CONCAT3(module__,MODULE,__init_function),
  40.   /* next */           NULL
  41. };
  42.  
  43. // Now this is really getting C++.
  44. // The only effect of this is to achieve that
  45. //   add_module(&this_module);
  46. // gets called at startup time or load time.
  47.  
  48. #define CLASSNAME  CONCAT3(module__,MODULE,__initializer_class)
  49.  
  50. class CLASSNAME
  51.   { public:
  52.       // Constructor, must have the same name as the class.
  53.       // Its return type defaults to the class, not `int' or `void'.
  54.       CLASSNAME (void);
  55.   };
  56.  
  57. CLASSNAME::CLASSNAME (void)
  58. { add_module(&this_module); }
  59.  
  60. static CLASSNAME CONCAT3(module__,MODULE,__initializer_dummy);
  61.  
  62. #endif
  63.  
  64.