diff options
| author | Stefan Monnier | 2012-10-13 21:42:48 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-10-13 21:42:48 -0400 |
| commit | 9760c73c668269cd8de4625b0137d574551c98e5 (patch) | |
| tree | 92954c90ee6ad0462a88dda4f0da7c0f5f509ef1 | |
| parent | 5046ef67ca8b5a2eab769b4a6e486ae060b5df13 (diff) | |
| download | emacs-9760c73c668269cd8de4625b0137d574551c98e5.tar.gz emacs-9760c73c668269cd8de4625b0137d574551c98e5.zip | |
* lisp/emacs-lisp/eieio.el (eieio-oset-default, eieio-oset, oset-default)
(oset): Move uses of object-class-fast macro after its definition.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eieio.el | 130 |
2 files changed, 68 insertions, 65 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6c9fe7c4b47..a31d474d8a3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2012-10-14 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2012-10-14 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/eieio.el (eieio-oset-default, eieio-oset, oset-default) | ||
| 4 | (oset): Move uses of object-class-fast macro after its definition. | ||
| 5 | |||
| 3 | * emacs-lisp/gv.el (if): Don't use closures in non-lexical-binding code. | 6 | * emacs-lisp/gv.el (if): Don't use closures in non-lexical-binding code. |
| 4 | 7 | ||
| 5 | 2012-10-13 Chong Yidong <cyd@gnu.org> | 8 | 2012-10-13 Chong Yidong <cyd@gnu.org> |
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 9bbb149177f..5f8cbea7c27 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el | |||
| @@ -1556,71 +1556,6 @@ Fills in OBJ's SLOT with its default value." | |||
| 1556 | ;; return it verbatim | 1556 | ;; return it verbatim |
| 1557 | (t val))) | 1557 | (t val))) |
| 1558 | 1558 | ||
| 1559 | ;;; Object Set macros | ||
| 1560 | ;; | ||
| 1561 | (defmacro oset (obj slot value) | ||
| 1562 | "Set the value in OBJ for slot SLOT to VALUE. | ||
| 1563 | SLOT is the slot name as specified in `defclass' or the tag created | ||
| 1564 | with in the :initarg slot. VALUE can be any Lisp object." | ||
| 1565 | `(eieio-oset ,obj (quote ,slot) ,value)) | ||
| 1566 | |||
| 1567 | (defun eieio-oset (obj slot value) | ||
| 1568 | "Do the work for the macro `oset'. | ||
| 1569 | Fills in OBJ's SLOT with VALUE." | ||
| 1570 | (if (not (eieio-object-p obj)) (signal 'wrong-type-argument (list 'eieio-object-p obj))) | ||
| 1571 | (if (not (symbolp slot)) (signal 'wrong-type-argument (list 'symbolp slot))) | ||
| 1572 | (let ((c (eieio-slot-name-index (object-class-fast obj) obj slot))) | ||
| 1573 | (if (not c) | ||
| 1574 | ;; It might be missing because it is a :class allocated slot. | ||
| 1575 | ;; Let's check that info out. | ||
| 1576 | (if (setq c | ||
| 1577 | (eieio-class-slot-name-index (aref obj object-class) slot)) | ||
| 1578 | ;; Oset that slot. | ||
| 1579 | (progn | ||
| 1580 | (eieio-validate-class-slot-value (object-class-fast obj) c value slot) | ||
| 1581 | (aset (aref (class-v (aref obj object-class)) | ||
| 1582 | class-class-allocation-values) | ||
| 1583 | c value)) | ||
| 1584 | ;; See oref for comment on `slot-missing' | ||
| 1585 | (slot-missing obj slot 'oset value) | ||
| 1586 | ;;(signal 'invalid-slot-name (list (object-name obj) slot)) | ||
| 1587 | ) | ||
| 1588 | (eieio-validate-slot-value (object-class-fast obj) c value slot) | ||
| 1589 | (aset obj c value)))) | ||
| 1590 | |||
| 1591 | (defmacro oset-default (class slot value) | ||
| 1592 | "Set the default slot in CLASS for SLOT to VALUE. | ||
| 1593 | The default value is usually set with the :initform tag during class | ||
| 1594 | creation. This allows users to change the default behavior of classes | ||
| 1595 | after they are created." | ||
| 1596 | `(eieio-oset-default ,class (quote ,slot) ,value)) | ||
| 1597 | |||
| 1598 | (defun eieio-oset-default (class slot value) | ||
| 1599 | "Do the work for the macro `oset-default'. | ||
| 1600 | Fills in the default value in CLASS' in SLOT with VALUE." | ||
| 1601 | (if (not (class-p class)) (signal 'wrong-type-argument (list 'class-p class))) | ||
| 1602 | (if (not (symbolp slot)) (signal 'wrong-type-argument (list 'symbolp slot))) | ||
| 1603 | (let* ((scoped-class class) | ||
| 1604 | (c (eieio-slot-name-index class nil slot))) | ||
| 1605 | (if (not c) | ||
| 1606 | ;; It might be missing because it is a :class allocated slot. | ||
| 1607 | ;; Let's check that info out. | ||
| 1608 | (if (setq c (eieio-class-slot-name-index class slot)) | ||
| 1609 | (progn | ||
| 1610 | ;; Oref that slot. | ||
| 1611 | (eieio-validate-class-slot-value class c value slot) | ||
| 1612 | (aset (aref (class-v class) class-class-allocation-values) c | ||
| 1613 | value)) | ||
| 1614 | (signal 'invalid-slot-name (list (class-name class) slot))) | ||
| 1615 | (eieio-validate-slot-value class c value slot) | ||
| 1616 | ;; Set this into the storage for defaults. | ||
| 1617 | (setcar (nthcdr (- c 3) (aref (class-v class) class-public-d)) | ||
| 1618 | value) | ||
| 1619 | ;; Take the value, and put it into our cache object. | ||
| 1620 | (eieio-oset (aref (class-v class) class-default-object-cache) | ||
| 1621 | slot value) | ||
| 1622 | ))) | ||
| 1623 | |||
| 1624 | ;;; Handy CLOS macros | 1559 | ;;; Handy CLOS macros |
| 1625 | ;; | 1560 | ;; |
| 1626 | (defmacro with-slots (spec-list object &rest body) | 1561 | (defmacro with-slots (spec-list object &rest body) |
| @@ -1871,6 +1806,71 @@ method invocation orders of the involved classes." | |||
| 1871 | (setq ia (cdr ia))) | 1806 | (setq ia (cdr ia))) |
| 1872 | f)) | 1807 | f)) |
| 1873 | 1808 | ||
| 1809 | ;;; Object Set macros | ||
| 1810 | ;; | ||
| 1811 | (defmacro oset (obj slot value) | ||
| 1812 | "Set the value in OBJ for slot SLOT to VALUE. | ||
| 1813 | SLOT is the slot name as specified in `defclass' or the tag created | ||
| 1814 | with in the :initarg slot. VALUE can be any Lisp object." | ||
| 1815 | `(eieio-oset ,obj (quote ,slot) ,value)) | ||
| 1816 | |||
| 1817 | (defun eieio-oset (obj slot value) | ||
| 1818 | "Do the work for the macro `oset'. | ||
| 1819 | Fills in OBJ's SLOT with VALUE." | ||
| 1820 | (if (not (eieio-object-p obj)) (signal 'wrong-type-argument (list 'eieio-object-p obj))) | ||
| 1821 | (if (not (symbolp slot)) (signal 'wrong-type-argument (list 'symbolp slot))) | ||
| 1822 | (let ((c (eieio-slot-name-index (object-class-fast obj) obj slot))) | ||
| 1823 | (if (not c) | ||
| 1824 | ;; It might be missing because it is a :class allocated slot. | ||
| 1825 | ;; Let's check that info out. | ||
| 1826 | (if (setq c | ||
| 1827 | (eieio-class-slot-name-index (aref obj object-class) slot)) | ||
| 1828 | ;; Oset that slot. | ||
| 1829 | (progn | ||
| 1830 | (eieio-validate-class-slot-value (object-class-fast obj) c value slot) | ||
| 1831 | (aset (aref (class-v (aref obj object-class)) | ||
| 1832 | class-class-allocation-values) | ||
| 1833 | c value)) | ||
| 1834 | ;; See oref for comment on `slot-missing' | ||
| 1835 | (slot-missing obj slot 'oset value) | ||
| 1836 | ;;(signal 'invalid-slot-name (list (object-name obj) slot)) | ||
| 1837 | ) | ||
| 1838 | (eieio-validate-slot-value (object-class-fast obj) c value slot) | ||
| 1839 | (aset obj c value)))) | ||
| 1840 | |||
| 1841 | (defmacro oset-default (class slot value) | ||
| 1842 | "Set the default slot in CLASS for SLOT to VALUE. | ||
| 1843 | The default value is usually set with the :initform tag during class | ||
| 1844 | creation. This allows users to change the default behavior of classes | ||
| 1845 | after they are created." | ||
| 1846 | `(eieio-oset-default ,class (quote ,slot) ,value)) | ||
| 1847 | |||
| 1848 | (defun eieio-oset-default (class slot value) | ||
| 1849 | "Do the work for the macro `oset-default'. | ||
| 1850 | Fills in the default value in CLASS' in SLOT with VALUE." | ||
| 1851 | (if (not (class-p class)) (signal 'wrong-type-argument (list 'class-p class))) | ||
| 1852 | (if (not (symbolp slot)) (signal 'wrong-type-argument (list 'symbolp slot))) | ||
| 1853 | (let* ((scoped-class class) | ||
| 1854 | (c (eieio-slot-name-index class nil slot))) | ||
| 1855 | (if (not c) | ||
| 1856 | ;; It might be missing because it is a :class allocated slot. | ||
| 1857 | ;; Let's check that info out. | ||
| 1858 | (if (setq c (eieio-class-slot-name-index class slot)) | ||
| 1859 | (progn | ||
| 1860 | ;; Oref that slot. | ||
| 1861 | (eieio-validate-class-slot-value class c value slot) | ||
| 1862 | (aset (aref (class-v class) class-class-allocation-values) c | ||
| 1863 | value)) | ||
| 1864 | (signal 'invalid-slot-name (list (class-name class) slot))) | ||
| 1865 | (eieio-validate-slot-value class c value slot) | ||
| 1866 | ;; Set this into the storage for defaults. | ||
| 1867 | (setcar (nthcdr (- c 3) (aref (class-v class) class-public-d)) | ||
| 1868 | value) | ||
| 1869 | ;; Take the value, and put it into our cache object. | ||
| 1870 | (eieio-oset (aref (class-v class) class-default-object-cache) | ||
| 1871 | slot value) | ||
| 1872 | ))) | ||
| 1873 | |||
| 1874 | ;;; CLOS queries into classes and slots | 1874 | ;;; CLOS queries into classes and slots |
| 1875 | ;; | 1875 | ;; |
| 1876 | (defun slot-boundp (object slot) | 1876 | (defun slot-boundp (object slot) |