diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/src/lread.c b/src/lread.c index e29d46dccdb..72283bde8ab 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1770,57 +1770,61 @@ defalias (sname, string) | |||
| 1770 | #endif /* NOTDEF */ | 1770 | #endif /* NOTDEF */ |
| 1771 | 1771 | ||
| 1772 | /* Define an "integer variable"; a symbol whose value is forwarded | 1772 | /* Define an "integer variable"; a symbol whose value is forwarded |
| 1773 | to a C variable of type int. Sample call: */ | 1773 | to a C variable of type int. Sample call: */ |
| 1774 | /* DEFVARINT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */ | 1774 | /* DEFVARINT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */ |
| 1775 | |||
| 1776 | void | 1775 | void |
| 1777 | defvar_int (namestring, address) | 1776 | defvar_int (namestring, address) |
| 1778 | char *namestring; | 1777 | char *namestring; |
| 1779 | int *address; | 1778 | int *address; |
| 1780 | { | 1779 | { |
| 1781 | Lisp_Object sym; | 1780 | Lisp_Object sym, val; |
| 1782 | sym = intern (namestring); | 1781 | sym = intern (namestring); |
| 1783 | XSETINTFWD (XSYMBOL (sym)->value, address); | 1782 | val = allocate_misc (); |
| 1783 | XMISC (val)->type = Lisp_Misc_Intfwd; | ||
| 1784 | XMISC (val)->u_intfwd.intvar = address; | ||
| 1785 | XSYMBOL (sym)->value = val; | ||
| 1784 | } | 1786 | } |
| 1785 | 1787 | ||
| 1786 | /* Similar but define a variable whose value is T if address contains 1, | 1788 | /* Similar but define a variable whose value is T if address contains 1, |
| 1787 | NIL if address contains 0 */ | 1789 | NIL if address contains 0 */ |
| 1788 | |||
| 1789 | void | 1790 | void |
| 1790 | defvar_bool (namestring, address) | 1791 | defvar_bool (namestring, address) |
| 1791 | char *namestring; | 1792 | char *namestring; |
| 1792 | int *address; | 1793 | int *address; |
| 1793 | { | 1794 | { |
| 1794 | Lisp_Object sym; | 1795 | Lisp_Object sym, val; |
| 1795 | sym = intern (namestring); | 1796 | sym = intern (namestring); |
| 1796 | XSETBOOLFWD (XSYMBOL (sym)->value, address); | 1797 | val = allocate_misc (); |
| 1798 | XMISC (val)->type = Lisp_Misc_Boolfwd; | ||
| 1799 | XMISC (val)->u_boolfwd.boolvar = address; | ||
| 1800 | XSYMBOL (sym)->value = val; | ||
| 1797 | } | 1801 | } |
| 1798 | 1802 | ||
| 1799 | /* Similar but define a variable whose value is the Lisp Object stored at address. */ | 1803 | /* Similar but define a variable whose value is the Lisp Object stored |
| 1800 | 1804 | at address. Two versions: with and without gc-marking of the C | |
| 1805 | variable. The nopro version is used when that variable will be | ||
| 1806 | gc-marked for some other reason, since marking the same slot twice | ||
| 1807 | can cause trouble with strings. */ | ||
| 1801 | void | 1808 | void |
| 1802 | defvar_lisp (namestring, address) | 1809 | defvar_lisp_nopro (namestring, address) |
| 1803 | char *namestring; | 1810 | char *namestring; |
| 1804 | Lisp_Object *address; | 1811 | Lisp_Object *address; |
| 1805 | { | 1812 | { |
| 1806 | Lisp_Object sym; | 1813 | Lisp_Object sym, val; |
| 1807 | sym = intern (namestring); | 1814 | sym = intern (namestring); |
| 1808 | XSETOBJFWD (XSYMBOL (sym)->value, address); | 1815 | val = allocate_misc (); |
| 1809 | staticpro (address); | 1816 | XMISC (val)->type = Lisp_Misc_Objfwd; |
| 1817 | XMISC (val)->u_objfwd.objvar = address; | ||
| 1818 | XSYMBOL (sym)->value = val; | ||
| 1810 | } | 1819 | } |
| 1811 | 1820 | ||
| 1812 | /* Similar but don't request gc-marking of the C variable. | ||
| 1813 | Used when that variable will be gc-marked for some other reason, | ||
| 1814 | since marking the same slot twice can cause trouble with strings. */ | ||
| 1815 | |||
| 1816 | void | 1821 | void |
| 1817 | defvar_lisp_nopro (namestring, address) | 1822 | defvar_lisp (namestring, address) |
| 1818 | char *namestring; | 1823 | char *namestring; |
| 1819 | Lisp_Object *address; | 1824 | Lisp_Object *address; |
| 1820 | { | 1825 | { |
| 1821 | Lisp_Object sym; | 1826 | defvar_lisp_nopro (namestring, address); |
| 1822 | sym = intern (namestring); | 1827 | staticpro (address); |
| 1823 | XSETOBJFWD (XSYMBOL (sym)->value, address); | ||
| 1824 | } | 1828 | } |
| 1825 | 1829 | ||
| 1826 | #ifndef standalone | 1830 | #ifndef standalone |
| @@ -1836,14 +1840,17 @@ defvar_per_buffer (namestring, address, type, doc) | |||
| 1836 | Lisp_Object type; | 1840 | Lisp_Object type; |
| 1837 | char *doc; | 1841 | char *doc; |
| 1838 | { | 1842 | { |
| 1839 | Lisp_Object sym; | 1843 | Lisp_Object sym, val; |
| 1840 | int offset; | 1844 | int offset; |
| 1841 | extern struct buffer buffer_local_symbols; | 1845 | extern struct buffer buffer_local_symbols; |
| 1842 | 1846 | ||
| 1843 | sym = intern (namestring); | 1847 | sym = intern (namestring); |
| 1848 | val = allocate_misc (); | ||
| 1844 | offset = (char *)address - (char *)current_buffer; | 1849 | offset = (char *)address - (char *)current_buffer; |
| 1845 | 1850 | ||
| 1846 | XSETBUFFER_OBJFWD (XSYMBOL (sym)->value, offset); | 1851 | XMISC (val)->type = Lisp_Misc_Buffer_Objfwd; |
| 1852 | XMISC (val)->u_buffer_objfwd.offset = offset; | ||
| 1853 | XSYMBOL (sym)->value = val; | ||
| 1847 | *(Lisp_Object *)(offset + (char *)&buffer_local_symbols) = sym; | 1854 | *(Lisp_Object *)(offset + (char *)&buffer_local_symbols) = sym; |
| 1848 | *(Lisp_Object *)(offset + (char *)&buffer_local_types) = type; | 1855 | *(Lisp_Object *)(offset + (char *)&buffer_local_types) = type; |
| 1849 | if (XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_flags)) == 0) | 1856 | if (XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_flags)) == 0) |