+(defun ez-get-obj-attr (obj attr)
+ (let* ((byte-num (/ attr 8))
+ (bit-num (mod attr 8))
+ (bit-mask (lsh 1 (- 7 bit-num))))
+ (if (> (logand bit-mask (ez-mem-ref-byte (+ (ez-get-obj-addr obj) byte-num))) 0)
+ 1
+ 0)))
+
+(defun ez-set-obj-attr (obj attr val)
+ (let* ((byte-num (/ attr 8))
+ (bit-num (mod attr 8))
+ (bit-mask (lsh 1 (- 7 bit-num)))
+ (byte-addr (+ (ez-get-obj-addr obj) byte-num))
+ (byte (ez-mem-ref-byte byte-addr))
+ (current-set (> (logand bit-mask byte) 0)))
+ (if (or (and current-set (= val 0))
+ (and (not current-set) (> val 0)))
+ (ez-mem-set-byte byte-addr (logxor byte bit-mask)))))
+
+
+(defun ez-remove-obj (obj)
+ (let ((parent (ez-get-obj-parent obj))
+ (sibling (ez-get-obj-sibling obj)))
+ (unless (= parent 0)
+ (let ((child (ez-get-obj-child parent)))
+ (if (= child obj)
+ (ez-set-obj-child parent sibling)
+ (while (not (= obj (ez-get-obj-sibling child)))
+ (setq child (ez-get-obj-sibling child)))
+ (ez-set-obj-sibling child (ez-get-obj-sibling obj))))
+ (ez-set-obj-parent obj 0))
+ (ez-set-obj-sibling obj 0)))
+
+(defun ez-insert-obj (obj new-parent)
+ (ez-remove-obj obj)
+ (unless (= new-parent 0)
+ (ez-set-obj-sibling obj (ez-get-obj-child new-parent))
+ (ez-set-obj-child new-parent obj)))
+