3 ;;; Implementation for property sets
5 ;;; (c) 2009 Straylight/Edgeware
8 ;;;----- Licensing notice ---------------------------------------------------
10 ;;; This file is part of the Sensible Object Design, an object system for C.
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 ;;;--------------------------------------------------------------------------
29 ;;; Property representation.
31 (defmethod file-location ((prop property))
32 (file-location (p-location prop)))
36 (defmethod coerce-property-value
37 ((value symbol) (type (eql :symbol)) (wanted (eql :keyword)))
40 (defmethod coerce-property-value
41 ((value string) (type (eql :id)) (wanted (eql :keyword)))
42 (string-to-symbol value :package :keyword))
44 (defmethod coerce-property-value
45 ((value string) (type (eql :string)) (wanted (eql :keyword)))
46 (string-to-symbol value :package :keyword :swap-hyphen nil))
50 (defmethod coerce-property-value
51 ((value string) (type (eql :id)) (wanted (eql :symbol)))
52 (string-to-symbol value))
54 (defmethod coerce-property-value
55 ((value string) (type (eql :string)) (wanted (eql :symbol)))
56 (string-to-symbol value :swap-hyphen nil))
60 (defmethod coerce-property-value
61 ((value string) (type (eql :string)) (wanted (eql :id)))
64 (defmethod coerce-property-value
65 ((value symbol) (type (eql :symbol)) (wanted (eql :id)))
66 (frob-identifier (symbol-name value)))
70 (defmethod coerce-property-value
71 ((value string) (type (eql :id)) (wanted (eql :type)))
72 (or (gethash value *module-type-map*)
73 (gethash value *declspec-map*)
74 (error "Unknown type `~A'." value)))
76 ;;;--------------------------------------------------------------------------
79 (defmethod print-object ((pset pset) stream)
80 (print-unreadable-object (pset stream :type t)
81 (pprint-logical-block (stream nil)
83 (pset-map (lambda (prop)
84 (cond (firstp (setf firstp nil))
85 (t (write-char #\space stream)
86 (pprint-newline :linear stream)))
87 (format stream "~:@<~S ~@_~S ~@_~S~:>"
88 (p-name prop) (p-type prop) (p-value prop)))
91 ;;;----- That's all, folks --------------------------------------------------