+
+(declaim (inline delistify))
+(defun delistify (list)
+ "Some MOPs, like openmcl 0.14.2, cons attribute values in a list."
+ (if (listp list)
+ (car list)
+ list))
+
+(defun remove-keyword-arg (arglist akey)
+ (let ((mylist arglist)
+ (newlist ()))
+ (labels ((pop-arg (alist)
+ (let ((arg (pop alist))
+ (val (pop alist)))
+ (unless (equal arg akey)
+ (setf newlist (append (list arg val) newlist)))
+ (when alist (pop-arg alist)))))
+ (pop-arg mylist))
+ newlist))
+
+(defun remove-keyword-args (arglist akeys)
+ (let ((mylist arglist)
+ (newlist ()))
+ (labels ((pop-arg (alist)
+ (let ((arg (pop alist))
+ (val (pop alist)))
+ (unless (find arg akeys)
+ (setf newlist (append (list arg val) newlist)))
+ (when alist (pop-arg alist)))))
+ (pop-arg mylist))
+ newlist))
+
+
+(defmethod shared-initialize :around ((class hyperobject-class) slot-names
+ &rest initargs
+ &key direct-superclasses
+ user-name sql-name name description
+ &allow-other-keys)
+ ;(format t "ii ~S ~S ~S ~S ~S~%" initargs base-table direct-superclasses user-name sql-name)
+ (let ((root-class (find-class 'hyperobject nil))
+ (vmc 'hyperobject-class)
+ user-name-plural user-name-str sql-name-str)
+ ;; when does CLSQL pass :qualifier to initialize instance?
+ (setq user-name-str
+ (if user-name
+ (delistify user-name)
+ (and name (format nil "~:(~A~)" name))))
+
+ (setq sql-name-str
+ (if sql-name
+ (delistify sql-name)
+ (and name (lisp-name-to-sql-name name))))
+
+ (if sql-name
+ (delistify sql-name)
+ (and name (lisp-name-to-sql-name name)))
+
+ (setq description (delistify description))
+
+ (setq user-name-plural
+ (if (and (consp user-name) (second user-name))
+ (second user-name)
+ (and user-name-str (format nil "~A~P" user-name-str 2))))
+
+ (flet ((do-call-next-method (direct-superclasses)
+ (let ((fn-args (list class slot-names :direct-superclasses direct-superclasses))
+ (rm-args '(:direct-superclasses)))
+ (when user-name-str
+ (setq fn-args (nconc fn-args (list :user-name user-name-str)))
+ (push :user-name rm-args))
+ (when user-name-plural
+ (setq fn-args (nconc fn-args (list :user-name-plural user-name-plural)))
+ (push :user-name-plural rm-args))
+ (when sql-name-str
+ (setq fn-args (nconc fn-args (list :sql-name sql-name-str)))
+ (push :sql-name rm-args))
+ (when description
+ (setq fn-args (nconc fn-args (list :description description)))
+ (push :description rm-args))
+ (setq fn-args (nconc fn-args (remove-keyword-args initargs rm-args)))
+ (apply #'call-next-method fn-args))))
+ (if root-class
+ (if (some #'(lambda (super) (typep super vmc))
+ direct-superclasses)
+ (do-call-next-method direct-superclasses)
+ (do-call-next-method direct-superclasses #+nil (append (list root-class)
+ direct-superclasses)))
+ (do-call-next-method direct-superclasses)))))
+
+