chiark / gitweb /
Mapped NIL type to "void"
[clg] / glib / gobject.lisp
index 01f3998dd0a4d29af772d82055fc33b5ad234235..c6bfe269a71f2eb042588c3a6f7552b53cdf84c3 100644 (file)
@@ -15,7 +15,7 @@
 ;; License along with this library; if not, write to the Free Software
 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-;; $Id: gobject.lisp,v 1.26 2004-12-29 21:07:46 espen Exp $
+;; $Id: gobject.lisp,v 1.28 2005-01-12 13:26:03 espen Exp $
 
 (in-package "GLIB")
 
@@ -136,18 +136,21 @@ (defmethod initialize-internal-slot-functions ((slotd effective-property-slot-de
 
 (defmethod initialize-internal-slot-functions ((slotd effective-user-data-slot-definition))
   (let ((slot-name (slot-definition-name slotd)))
-    (setf 
-     (slot-value slotd 'getter)
-     #'(lambda (object)
-        (prog1 (user-data object slot-name))))
-    (setf 
-     (slot-value slotd 'setter)
-     #'(lambda (value object)
-        (setf (user-data object slot-name) value)))
-    (setf 
-     (slot-value slotd 'boundp)
-     #'(lambda (object)
-        (user-data-p object slot-name))))
+    (unless (slot-boundp slotd 'getter)
+      (setf 
+       (slot-value slotd 'getter)
+       #'(lambda (object)
+          (prog1 (user-data object slot-name)))))
+    (unless (slot-boundp slotd 'setter)
+      (setf 
+       (slot-value slotd 'setter)
+       #'(lambda (value object)
+          (setf (user-data object slot-name) value))))
+    (unless (slot-boundp slotd 'boundp)
+      (setf 
+       (slot-value slotd 'boundp)
+       #'(lambda (object)
+          (user-data-p object slot-name)))))
   (call-next-method))
 
 
@@ -342,9 +345,9 @@ (defun default-slot-accessor (class-name slot-name type)
     (if (eq type 'boolean) "-P" ""))))
 
 
-(defun slot-definition-from-property (class property &optional args)
+(defun slot-definition-from-property (class property &optional slot-name args)
   (with-slots (name flags value-type documentation) property
-    (let* ((slot-name (default-slot-name name))
+    (let* ((slot-name (or slot-name (default-slot-name name)))
           (slot-type (or (getf args :type) (type-from-number value-type) value-type))
           (accessor (default-slot-accessor class slot-name slot-type)))
       
@@ -380,6 +383,8 @@ (defun slot-definition-from-property (class property &optional args)
                    (member :construct-only flags)
                    (member :writable flags))
            (list :initarg (intern (string slot-name) "KEYWORD")))
+       ,@(cond
+          ((find :initarg args) (list :initarg (getf args :initarg))))
        
        :type ,slot-type
        :documentation ,documentation))))
@@ -400,7 +405,7 @@ (defun slot-definitions (class properties slots)
        ((getf (rest slot) :merge)
        (setf 
         (rest slot) 
-        (rest (slot-definition-from-property class property (rest slot)))))))
+        (rest (slot-definition-from-property class property (first slot) (rest slot)))))))
   (delete-if #'(lambda (slot) (getf (rest slot) :ignore)) slots))