-(defmacro get-rplist (key)
- `(resource-plist (gethash ,key resources-table)))
-
-(defmacro get-rconstructor (key)
- `(resource-constructor (gethash ,key resources-table)))
-
-(defmacro get-rdestructor (key)
- `(resource-destructor (gethash ,key resources-table)))
-
-(let ((resources-table (make-hash-table :test 'equal))
- (expiration-time 50000))
-
- (defun set-expiration-time (new-time)
- (setq expiration-time new-time))
-
- (defun set-resource (key plist constructor destructor &key static)
- (expire-resources)
- (setf (gethash key resources-table)
- (make-resource :plist plist
- :constructor constructor
- :destructor destructor
- :time (if static t (SDL_GetTicks)))))
-
- (defun get-resource (key)
- (cond ((null (gethash key resources-table)) nil)
- (t (let ((time (get-rtime key)))
- (cond ((null time) (funcall (get-rconstructor key)))
- ((numberp time) (setf (get-rtime key) (SDL_GetTicks))))
- (get-rplist key)))))
-
- (defun free-resource (key)
- (funcall (get-rdestructor key))
- (setf (get-rtime key) nil))