1 ;;; Copyright 2009 Christoph Senjak
3 (in-package :uxul-world)
5 (declaim (inline get-by-index))
7 (defun get-by-index (index array)
10 (defun create-object-array ()
11 (make-array (list (length +class-indices+))
16 (defun add-object-of-class (object array)
17 (dolist (class (c2mop:class-precedence-list (class-of object)))
18 (let ((index (position (class-name class) +class-indices+)))
20 (pushnew object (svref array index))))))
22 (defun get-objects-of-class (class-name array)
23 (get-by-index (position class-name +class-indices+) array))
26 (define-compiler-macro get-objects-of-class (&whole form class-name array)
27 (if (constantp class-name)
28 `(get-by-index ,(position (eval class-name) +class-indices+) ,array)
33 (defmethod add-object ((room room) (object t))
34 (add-object-of-class object (object-array room)))
36 (defun get-objects (room class)
37 (get-objects-of-class class (object-array room)))
39 (define-compiler-macro get-objects (&whole form room class-name)
40 (format t "Compiler Macro for get-objects...")
41 (print (if (constantp class-name)
42 `(get-by-index ,(position (eval class-name) +class-indices+) (object-array ,room))