PageRenderTime 22ms CodeModel.GetById 6ms app.highlight 11ms 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
12char cvsroot_module_cxx[] = "$Header$";
13
14#include "swigmod.h"
15
16struct Module {
17  ModuleFactory   fac;
18  char            *name;
19  Module          *next;
20  Module(const char *n, ModuleFactory f) {
21    fac = f;
22    name = new char[strlen(n)+1];
23    strcpy(name, n);
24    next = 0;
25  }
26};
27
28static Module *modules = 0;
29
30/* -----------------------------------------------------------------------------
31 * void Swig_register_module()
32 *
33 * Register a module.
34 * ----------------------------------------------------------------------------- */
35
36void Swig_register_module(const char *n, ModuleFactory f) {
37  Module *m = new Module(n,f);
38  m->next = modules;
39  modules = m;
40}
41
42/* -----------------------------------------------------------------------------
43 * Language *Swig_find_module()
44 *
45 * Given a command line option, locates the factory function.
46 * ----------------------------------------------------------------------------- */
47
48ModuleFactory Swig_find_module(const char *name) {
49  Module *m = modules;
50  while (m) {
51    if (strcmp(m->name,name) == 0) {
52      return m->fac;
53    }
54    m = m->next;
55  }
56  return 0;
57}