named-object/superhero [ Classes ]

[ Top ] [ named-object ] [ Classes ]

Name

 superhero

File

 superhero.lsp

Description

 A superhero is an object that holds code (and variable names
 and definitions) to be run once for each event in a comic.
 It can be defined using make-superhero and executed using
 call-superhero. It can be used to capture an iterative
 algorithmic process, that will be usefull to apply on a
 comic in different situations and projects, e.g. an
 auto-completion algorithm for specific slots of the events.

Slots

 outer-loop, locals, code, event-var, parent-var,
 return-var
 For more info, see make-superhero.

Synopsis

(defclass superhero (named-object)
  (;; outer-loop, controlling amount
   ;; of times the superhero iterates
   ;; through the entire comic
   (outer-loop
    :initarg :outer-loop
    :initform '(repeat 1))
   ;; additional locals, defined in a let-manner
   (locals
    :initarg :locals
    :initform nil)
   ;; code to run once for each event
   (code
    :initarg :code
    :initform nil)
   ;; variable holding current event 
   (event-var
    :initarg :event-var
    :initform 'e)
   ;; variable holding current-events parent
   (parent-var
    :initarg :parent-var
    :initform 'p)
   ;; variable to return at the very end
   (return-var
    :initarg :return-var
    :initform 'r)))

placed-object/get-space [ Functions ]

[ Top ] [ placed-object ] [ Functions ]

Name

 get-space

File

 superhero.lsp

Description

 Returns a placed-objects with location and expansion slots set.
 It represents the total space that all given placed-objects
 fill. 

Arguments

 - placed-objects: a flat list of placed-objects

 Optional Arguments (&key)
 - ensure-equal-dimensions: Should all given objects be set to
   the maximum amount of dimensions first? Default: t.
   When calling this function lots of times in iterations,
   it may make sense to set this to nil.
   When equal dimensions are set, the given objects are directly
   modified.

Return Value

 placed-object

Synopsis

(defun get-space (placed-objects
                  &key
                    (ensure-equal-dimensions t))

Example

(get-space (list (make-protagonist :sound :location '(1 2)
                                   :expansion '( 8 2)) 
                 (make-event :location 1 :expansion 2)))
--> placed-object, EXPANSION = (8 3), LOCATION = (1 3/2)

superhero/call-superhero [ Functions ]

[ Top ] [ superhero ] [ Functions ]

Name

 call-superhero

File

 superhero.lsp

Description

 Calls a superhero to modify the given comic.

Arguments

 N.B.: call-superhero is a macro, so all args without quotes!
 - superhero (superhero-instance or its name as symbol)
 - comic

Optional Arguments

 All key-args specified in the lambda-list slot of the superhero.

Return Value

 return-var of the superhero

Synopsis

(defmacro call-superhero (superhero comic)

superhero/make-superhero [ Functions ]

[ Top ] [ superhero ] [ Functions ]

Name

 make-superhero

File

 superhero.lsp

Description

 Creates an instance of the superhero-class.
 Adds the object to +cc-data+ / :superheros,
 accessible by its name.

Arguments

 N.B.: make-superhero is a macro, so all args without quotes!
 - name (symbol)
 - code: Lisp-form to evaluate once per event per iteration.

Optional Arguments

 - outer-loop: One or more loop forms, controlling the amount
   of iterations through the entire comic. Can be set to nil,
   which will result in (loop do ...), which is quite dangerous.
   Default: (repeat 1), for 1 iteration only.
 - locals: A set of local variables for any purpose, defined in
   a let-manner.
 - event-var: Variable to hold current event, default: e.
 - parent-var: Variable to hold current events parent, default: p.
 - return-var: Variable to return at the end of all iterations,
   default: r.

Return Value

 Superhero

Synopsis

(defmacro make-superhero (name
                          code
                          &key
                            (outer-loop '(repeat 1))
                            locals
                            (event-var 'e)
                            (parent-var 'p)
                            (return-var 'r))

superhero/space-superhero [ Superheros ]

[ Top ] [ superhero ] [ Superheros ]

Name

 space-superhero

File

 superhero.lsp

Description

 The space-superhero sets location- and expansion-slots of all
 events without further subevents. If no locations and expansions
 are set at all, all values will default to '(0). Otherwise, the
 superhero calculates values by looking at the total space given,
 as well as values already set.

Return Value

 boolean, indicating if all location and expansion slots
 of events without subevents are set.

Example

(call-superhero space-superhero my-comic) --> t