PageRenderTime 50ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Source/Modules/module.cxx

#
C++ | 57 lines | 29 code | 8 blank | 20 comment | 3 complexity | 4cdfc87991d48bec9b3d0aa9b279eaeb MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * module.cxx
  3. *
  4. * This file is responsible for the module system.
  5. *
  6. * Author(s) : David Beazley (beazley@cs.uchicago.edu)
  7. *
  8. * Copyright (C) 1999-2000. The University of Chicago
  9. * See the file LICENSE for information on usage and redistribution.
  10. * ----------------------------------------------------------------------------- */
  11. char cvsroot_module_cxx[] = "$Header$";
  12. #include "swigmod.h"
  13. struct Module {
  14. ModuleFactory fac;
  15. char *name;
  16. Module *next;
  17. Module(const char *n, ModuleFactory f) {
  18. fac = f;
  19. name = new char[strlen(n)+1];
  20. strcpy(name, n);
  21. next = 0;
  22. }
  23. };
  24. static Module *modules = 0;
  25. /* -----------------------------------------------------------------------------
  26. * void Swig_register_module()
  27. *
  28. * Register a module.
  29. * ----------------------------------------------------------------------------- */
  30. void Swig_register_module(const char *n, ModuleFactory f) {
  31. Module *m = new Module(n,f);
  32. m->next = modules;
  33. modules = m;
  34. }
  35. /* -----------------------------------------------------------------------------
  36. * Language *Swig_find_module()
  37. *
  38. * Given a command line option, locates the factory function.
  39. * ----------------------------------------------------------------------------- */
  40. ModuleFactory Swig_find_module(const char *name) {
  41. Module *m = modules;
  42. while (m) {
  43. if (strcmp(m->name,name) == 0) {
  44. return m->fac;
  45. }
  46. m = m->next;
  47. }
  48. return 0;
  49. }