;;; -*-lisp-*- ;;; ;;; Main tables for the translator ;;; ;;; (c) 2009 Straylight/Edgeware ;;; ;;;----- Licensing notice --------------------------------------------------- ;;; ;;; This file is part of the Simple Object Definition system. ;;; ;;; SOD is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. ;;; ;;; SOD is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with SOD; if not, write to the Free Software Foundation, ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. (cl:in-package #:sod) ;;;-------------------------------------------------------------------------- ;;; Main tables. (defvar *module-map* (make-hash-table :test #'equal) "A hash table mapping file truenames (pathnames) to modules. This is used to prevent multiple inclusion of a single module, which would be bad. Usually it maps pathnames to MODULE objects. As a special case, the truename a module which is being parsed maps to :IN-PROGRESS, which can be used to detect dependency cycles.") (defvar *type-map* (make-hash-table :test #'equal) "A hash table mapping type names to the C types they describe. Since a class is a C type, it gets its own entry in here as a C-CLASS-TYPE object. This is how we find classes by name: the C-CLASS-TYPE object has a reference to the underlying SOD-CLASS instance.") ;;;-------------------------------------------------------------------------- ;;; Utilities. (defparameter *clear-the-decks-functions* '(reset-type-and-module-map populate-type-map bootstrap-classes)) (defun reset-type-and-module-map () "Reset the main hash tables, clearing the translator's state. One of the *CLEAR-THE-DECKS-FUNCTIONS*." (setf *module-map* (make-hash-table :test #'equal) *type-map* (make-hash-table :test #'equal))) (defun populate-type-map () "Store some important simple types in the type map." (dolist (name '("va_list" "size_t" "ptrdiff_t")) (setf (gethash name *type-map*) (make-simple-type name)))) (defun clear-the-decks () "Reinitialize the translator's state. This is mainly useful when testing the translator from a Lisp REPL." (dolist (func *clear-the-decks-functions*) (funcall func))) #+test (clear-the-decks) ;;;----- That's all, folks --------------------------------------------------