From 0cda04e9e304e409b7e6bc3c9644731b2a0163a6 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Mon, 31 Aug 2015 20:45:43 -0700 Subject: [PATCH] Starting MOP code. --- kmop/kmop.lisp | 42 ++++++++++++++++++++++++++++++++++++++++++ kmop/package.lisp | 4 ++++ kutils-mop.asd | 11 +++++++++++ 3 files changed, 57 insertions(+) create mode 100644 kmop/kmop.lisp create mode 100644 kmop/package.lisp create mode 100644 kutils-mop.asd diff --git a/kmop/kmop.lisp b/kmop/kmop.lisp new file mode 100644 index 0000000..99c1422 --- /dev/null +++ b/kmop/kmop.lisp @@ -0,0 +1,42 @@ +;;;; kmop.lisp + +(in-package #:kutils-mop) + +;;; metaobject interactions + +(defun get-class-initargs (slots) +) + + +(defun get-all-init-args (class-sym &optional (package *package*)) + (let ((class-val (find-class + (find-symbol + (mkstr class-sym) + package)))) + (when class-val + (closer-mop:ensure-finalized class-val) + (flatten + (remove-if (lambda (slot) + (null (closer-mop:slot-definition-initargs slot))) + (closer-mop:class-slots class-val)))))) + +(defun kw-key (kw) + (string-downcase + (mkstr kw))) + +(defun dispatch-get-value (value)) + + +(defun zip-initargs-hash-table (args ht) + (flatten + (mapcar (lambda (slot) + (list slot (gethash (kw-key slot) ht))) + args))) + +(defun make-instance-from-hash-table (class-type table &optional (package *package*)) + (let ((class-sym (find-class class-type))) + (when class-sym + (apply #'make-instance class-sym + (zip-initargs-hash-table + (get-all-init-args class-type package) + table))))) diff --git a/kmop/package.lisp b/kmop/package.lisp new file mode 100644 index 0000000..a94a2a5 --- /dev/null +++ b/kmop/package.lisp @@ -0,0 +1,4 @@ +;;;; package.lisp + +(defpackage #:kutils-mop + (:use #:cl #:kutils)) diff --git a/kutils-mop.asd b/kutils-mop.asd new file mode 100644 index 0000000..c3562fb --- /dev/null +++ b/kutils-mop.asd @@ -0,0 +1,11 @@ +;;;; kutils-mop.asd + +(asdf:defsystem #:kutils-mop + :description "Kyle's MOP utilities." + :author "K. Isom " + :license "MIT License" + :serial t + :depends-on (#:closer-mop #:kutils) + :components ((:file "kmop/package") + (:file "kmop/kmop"))) +