3 ;;; Main tables for the translator
5 ;;; (c) 2009 Straylight/Edgeware
8 ;;;----- Licensing notice ---------------------------------------------------
10 ;;; This file is part of the Simple Object Definition system.
12 ;;; SOD is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2 of the License, or
15 ;;; (at your option) any later version.
17 ;;; SOD is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with SOD; if not, write to the Free Software Foundation,
24 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 ;;;--------------------------------------------------------------------------
31 (defvar *module-map* (make-hash-table :test #'equal)
32 "A hash table mapping file truenames (pathnames) to modules.
34 This is used to prevent multiple inclusion of a single module, which would
35 be bad. Usually it maps pathnames to MODULE objects. As a special case,
36 the truename a module which is being parsed maps to :IN-PROGRESS, which
37 can be used to detect dependency cycles.")
39 (defvar *type-map* (make-hash-table :test #'equal)
40 "A hash table mapping type names to the C types they describe.
42 Since a class is a C type, it gets its own entry in here as a C-CLASS-TYPE
43 object. This is how we find classes by name: the C-CLASS-TYPE object has
44 a reference to the underlying SOD-CLASS instance.")
46 (defparameter *builtin-module* nil
47 "Built-in module; populated later.")
49 ;;;--------------------------------------------------------------------------
52 (defparameter *clear-the-decks-functions*
53 '(reset-type-and-module-map
54 reset-builtin-module))
56 (defun reset-type-and-module-map ()
57 "Reset the main hash tables, clearing the translator's state.
59 One of the *CLEAR-THE-DECKS-FUNCTIONS*."
61 (setf *module-map* (make-hash-table :test #'equal)
62 *type-map* (make-hash-table :test #'equal)))
64 (defun populate-type-map ()
65 "Store some important simple types in the type map."
66 (dolist (name '("va_list" "size_t" "ptrdiff_t"))
67 (setf (gethash name *type-map*)
68 (make-simple-type name))))
70 (defun clear-the-decks ()
71 "Reinitialize the translator's state.
73 This is mainly useful when testing the translator from a Lisp REPL."
74 (dolist (func *clear-the-decks-functions*)
80 ;;;----- That's all, folks --------------------------------------------------