diff options
| author | Mattias EngdegÄrd | 2023-11-25 17:36:53 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2023-11-25 18:57:57 +0100 |
| commit | 278a6e1916cd78a405501ac0431f1b90cdb6cfaf (patch) | |
| tree | 2db0b0aa3993fa12dcec1dc990096e7b9b0e1df4 | |
| parent | f8fe0cf1bbc03889774741c622f8d768cbf431b8 (diff) | |
| download | emacs-278a6e1916cd78a405501ac0431f1b90cdb6cfaf.tar.gz emacs-278a6e1916cd78a405501ac0431f1b90cdb6cfaf.zip | |
Refactor pseudovector printing
* src/print.c (print_vectorlike): Split into...
(print_bignum, print_bool_vector, print_vectorlike_unreadable):
...these functions. Exhaustive switch on pseudovector type.
Remove unused return value.
(print_object): Use new functions and simplify.
| -rw-r--r-- | src/print.c | 269 |
1 files changed, 134 insertions, 135 deletions
diff --git a/src/print.c b/src/print.c index 4eee8319f65..a5d57adbd3b 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -1599,76 +1599,69 @@ print_pointer (Lisp_Object printcharfun, char *buf, const char *prefix, | |||
| 1599 | } | 1599 | } |
| 1600 | #endif | 1600 | #endif |
| 1601 | 1601 | ||
| 1602 | static bool | 1602 | static void |
| 1603 | print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | 1603 | print_bignum (Lisp_Object obj, Lisp_Object printcharfun) |
| 1604 | char *buf) | ||
| 1605 | { | 1604 | { |
| 1606 | /* First do all the vectorlike types that have a readable syntax. */ | 1605 | ptrdiff_t size = bignum_bufsize (obj, 10); |
| 1607 | switch (PSEUDOVECTOR_TYPE (XVECTOR (obj))) | 1606 | USE_SAFE_ALLOCA; |
| 1608 | { | 1607 | char *str = SAFE_ALLOCA (size); |
| 1609 | case PVEC_BIGNUM: | 1608 | ptrdiff_t len = bignum_to_c_string (str, size, obj, 10); |
| 1610 | { | 1609 | strout (str, len, len, printcharfun); |
| 1611 | ptrdiff_t size = bignum_bufsize (obj, 10); | 1610 | SAFE_FREE (); |
| 1612 | USE_SAFE_ALLOCA; | 1611 | } |
| 1613 | char *str = SAFE_ALLOCA (size); | ||
| 1614 | ptrdiff_t len = bignum_to_c_string (str, size, obj, 10); | ||
| 1615 | strout (str, len, len, printcharfun); | ||
| 1616 | SAFE_FREE (); | ||
| 1617 | } | ||
| 1618 | return true; | ||
| 1619 | |||
| 1620 | case PVEC_BOOL_VECTOR: | ||
| 1621 | { | ||
| 1622 | EMACS_INT size = bool_vector_size (obj); | ||
| 1623 | ptrdiff_t size_in_bytes = bool_vector_bytes (size); | ||
| 1624 | ptrdiff_t real_size_in_bytes = size_in_bytes; | ||
| 1625 | unsigned char *data = bool_vector_uchar_data (obj); | ||
| 1626 | |||
| 1627 | int len = sprintf (buf, "#&%"pI"d\"", size); | ||
| 1628 | strout (buf, len, len, printcharfun); | ||
| 1629 | 1612 | ||
| 1630 | /* Don't print more bytes than the specified maximum. | 1613 | static void |
| 1631 | Negative values of print-length are invalid. Treat them | 1614 | print_bool_vector (Lisp_Object obj, Lisp_Object printcharfun) |
| 1632 | like a print-length of nil. */ | 1615 | { |
| 1633 | if (FIXNATP (Vprint_length) | 1616 | EMACS_INT size = bool_vector_size (obj); |
| 1634 | && XFIXNAT (Vprint_length) < size_in_bytes) | 1617 | ptrdiff_t size_in_bytes = bool_vector_bytes (size); |
| 1635 | size_in_bytes = XFIXNAT (Vprint_length); | 1618 | ptrdiff_t real_size_in_bytes = size_in_bytes; |
| 1619 | unsigned char *data = bool_vector_uchar_data (obj); | ||
| 1636 | 1620 | ||
| 1637 | for (ptrdiff_t i = 0; i < size_in_bytes; i++) | 1621 | char buf[sizeof "#&" + INT_STRLEN_BOUND (ptrdiff_t)]; |
| 1638 | { | 1622 | int len = sprintf (buf, "#&%"pI"d\"", size); |
| 1639 | maybe_quit (); | 1623 | strout (buf, len, len, printcharfun); |
| 1640 | unsigned char c = data[i]; | ||
| 1641 | if (c == '\n' && print_escape_newlines) | ||
| 1642 | print_c_string ("\\n", printcharfun); | ||
| 1643 | else if (c == '\f' && print_escape_newlines) | ||
| 1644 | print_c_string ("\\f", printcharfun); | ||
| 1645 | else if (c > '\177' | ||
| 1646 | || (print_escape_control_characters && c_iscntrl (c))) | ||
| 1647 | { | ||
| 1648 | /* Use octal escapes to avoid encoding issues. */ | ||
| 1649 | octalout (c, data, i + 1, size_in_bytes, printcharfun); | ||
| 1650 | } | ||
| 1651 | else | ||
| 1652 | { | ||
| 1653 | if (c == '\"' || c == '\\') | ||
| 1654 | printchar ('\\', printcharfun); | ||
| 1655 | printchar (c, printcharfun); | ||
| 1656 | } | ||
| 1657 | } | ||
| 1658 | 1624 | ||
| 1659 | if (size_in_bytes < real_size_in_bytes) | 1625 | /* Don't print more bytes than the specified maximum. |
| 1660 | print_c_string (" ...", printcharfun); | 1626 | Negative values of print-length are invalid. Treat them |
| 1661 | printchar ('\"', printcharfun); | 1627 | like a print-length of nil. */ |
| 1662 | } | 1628 | if (FIXNATP (Vprint_length) |
| 1663 | return true; | 1629 | && XFIXNAT (Vprint_length) < size_in_bytes) |
| 1630 | size_in_bytes = XFIXNAT (Vprint_length); | ||
| 1664 | 1631 | ||
| 1665 | default: | 1632 | for (ptrdiff_t i = 0; i < size_in_bytes; i++) |
| 1666 | break; | 1633 | { |
| 1634 | maybe_quit (); | ||
| 1635 | unsigned char c = data[i]; | ||
| 1636 | if (c == '\n' && print_escape_newlines) | ||
| 1637 | print_c_string ("\\n", printcharfun); | ||
| 1638 | else if (c == '\f' && print_escape_newlines) | ||
| 1639 | print_c_string ("\\f", printcharfun); | ||
| 1640 | else if (c > '\177' | ||
| 1641 | || (print_escape_control_characters && c_iscntrl (c))) | ||
| 1642 | { | ||
| 1643 | /* Use octal escapes to avoid encoding issues. */ | ||
| 1644 | octalout (c, data, i + 1, size_in_bytes, printcharfun); | ||
| 1645 | } | ||
| 1646 | else | ||
| 1647 | { | ||
| 1648 | if (c == '\"' || c == '\\') | ||
| 1649 | printchar ('\\', printcharfun); | ||
| 1650 | printchar (c, printcharfun); | ||
| 1651 | } | ||
| 1667 | } | 1652 | } |
| 1668 | 1653 | ||
| 1669 | /* Then do all the pseudovector types that don't have a readable | 1654 | if (size_in_bytes < real_size_in_bytes) |
| 1670 | syntax. First check whether this is handled by | 1655 | print_c_string (" ...", printcharfun); |
| 1671 | `print-unreadable-function'. */ | 1656 | printchar ('\"', printcharfun); |
| 1657 | } | ||
| 1658 | |||
| 1659 | /* Print a pseudovector that has no readable syntax. */ | ||
| 1660 | static void | ||
| 1661 | print_vectorlike_unreadable (Lisp_Object obj, Lisp_Object printcharfun, | ||
| 1662 | bool escapeflag, char *buf) | ||
| 1663 | { | ||
| 1664 | /* First check whether this is handled by `print-unreadable-function'. */ | ||
| 1672 | if (!NILP (Vprint_unreadable_function) | 1665 | if (!NILP (Vprint_unreadable_function) |
| 1673 | && FUNCTIONP (Vprint_unreadable_function)) | 1666 | && FUNCTIONP (Vprint_unreadable_function)) |
| 1674 | { | 1667 | { |
| @@ -1697,7 +1690,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1697 | if (STRINGP (result)) | 1690 | if (STRINGP (result)) |
| 1698 | print_string (result, printcharfun); | 1691 | print_string (result, printcharfun); |
| 1699 | /* It's handled, so stop processing here. */ | 1692 | /* It's handled, so stop processing here. */ |
| 1700 | return true; | 1693 | return; |
| 1701 | } | 1694 | } |
| 1702 | } | 1695 | } |
| 1703 | 1696 | ||
| @@ -1718,7 +1711,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1718 | print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun); | 1711 | print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun); |
| 1719 | } | 1712 | } |
| 1720 | printchar ('>', printcharfun); | 1713 | printchar ('>', printcharfun); |
| 1721 | break; | 1714 | return; |
| 1722 | 1715 | ||
| 1723 | case PVEC_SYMBOL_WITH_POS: | 1716 | case PVEC_SYMBOL_WITH_POS: |
| 1724 | { | 1717 | { |
| @@ -1742,7 +1735,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1742 | printchar ('>', printcharfun); | 1735 | printchar ('>', printcharfun); |
| 1743 | } | 1736 | } |
| 1744 | } | 1737 | } |
| 1745 | break; | 1738 | return; |
| 1746 | 1739 | ||
| 1747 | case PVEC_OVERLAY: | 1740 | case PVEC_OVERLAY: |
| 1748 | print_c_string ("#<overlay ", printcharfun); | 1741 | print_c_string ("#<overlay ", printcharfun); |
| @@ -1758,7 +1751,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1758 | printcharfun); | 1751 | printcharfun); |
| 1759 | } | 1752 | } |
| 1760 | printchar ('>', printcharfun); | 1753 | printchar ('>', printcharfun); |
| 1761 | break; | 1754 | return; |
| 1762 | 1755 | ||
| 1763 | case PVEC_USER_PTR: | 1756 | case PVEC_USER_PTR: |
| 1764 | { | 1757 | { |
| @@ -1769,14 +1762,14 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1769 | strout (buf, i, i, printcharfun); | 1762 | strout (buf, i, i, printcharfun); |
| 1770 | printchar ('>', printcharfun); | 1763 | printchar ('>', printcharfun); |
| 1771 | } | 1764 | } |
| 1772 | break; | 1765 | return; |
| 1773 | 1766 | ||
| 1774 | case PVEC_FINALIZER: | 1767 | case PVEC_FINALIZER: |
| 1775 | print_c_string ("#<finalizer", printcharfun); | 1768 | print_c_string ("#<finalizer", printcharfun); |
| 1776 | if (NILP (XFINALIZER (obj)->function)) | 1769 | if (NILP (XFINALIZER (obj)->function)) |
| 1777 | print_c_string (" used", printcharfun); | 1770 | print_c_string (" used", printcharfun); |
| 1778 | printchar ('>', printcharfun); | 1771 | printchar ('>', printcharfun); |
| 1779 | break; | 1772 | return; |
| 1780 | 1773 | ||
| 1781 | case PVEC_MISC_PTR: | 1774 | case PVEC_MISC_PTR: |
| 1782 | { | 1775 | { |
| @@ -1785,7 +1778,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1785 | int i = sprintf (buf, "#<ptr %p>", xmint_pointer (obj)); | 1778 | int i = sprintf (buf, "#<ptr %p>", xmint_pointer (obj)); |
| 1786 | strout (buf, i, i, printcharfun); | 1779 | strout (buf, i, i, printcharfun); |
| 1787 | } | 1780 | } |
| 1788 | break; | 1781 | return; |
| 1789 | 1782 | ||
| 1790 | case PVEC_PROCESS: | 1783 | case PVEC_PROCESS: |
| 1791 | if (escapeflag) | 1784 | if (escapeflag) |
| @@ -1796,13 +1789,13 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1796 | } | 1789 | } |
| 1797 | else | 1790 | else |
| 1798 | print_string (XPROCESS (obj)->name, printcharfun); | 1791 | print_string (XPROCESS (obj)->name, printcharfun); |
| 1799 | break; | 1792 | return; |
| 1800 | 1793 | ||
| 1801 | case PVEC_SUBR: | 1794 | case PVEC_SUBR: |
| 1802 | print_c_string ("#<subr ", printcharfun); | 1795 | print_c_string ("#<subr ", printcharfun); |
| 1803 | print_c_string (XSUBR (obj)->symbol_name, printcharfun); | 1796 | print_c_string (XSUBR (obj)->symbol_name, printcharfun); |
| 1804 | printchar ('>', printcharfun); | 1797 | printchar ('>', printcharfun); |
| 1805 | break; | 1798 | return; |
| 1806 | 1799 | ||
| 1807 | case PVEC_XWIDGET: | 1800 | case PVEC_XWIDGET: |
| 1808 | #ifdef HAVE_XWIDGETS | 1801 | #ifdef HAVE_XWIDGETS |
| @@ -1822,15 +1815,15 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1822 | #endif | 1815 | #endif |
| 1823 | strout (buf, len, len, printcharfun); | 1816 | strout (buf, len, len, printcharfun); |
| 1824 | } | 1817 | } |
| 1825 | break; | 1818 | return; |
| 1826 | } | 1819 | } |
| 1827 | #else | ||
| 1828 | emacs_abort (); | ||
| 1829 | #endif | 1820 | #endif |
| 1821 | break; | ||
| 1822 | |||
| 1830 | case PVEC_XWIDGET_VIEW: | 1823 | case PVEC_XWIDGET_VIEW: |
| 1831 | print_c_string ("#<xwidget view", printcharfun); | 1824 | print_c_string ("#<xwidget view", printcharfun); |
| 1832 | printchar ('>', printcharfun); | 1825 | printchar ('>', printcharfun); |
| 1833 | break; | 1826 | return; |
| 1834 | 1827 | ||
| 1835 | case PVEC_WINDOW: | 1828 | case PVEC_WINDOW: |
| 1836 | { | 1829 | { |
| @@ -1845,7 +1838,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1845 | } | 1838 | } |
| 1846 | printchar ('>', printcharfun); | 1839 | printchar ('>', printcharfun); |
| 1847 | } | 1840 | } |
| 1848 | break; | 1841 | return; |
| 1849 | 1842 | ||
| 1850 | case PVEC_TERMINAL: | 1843 | case PVEC_TERMINAL: |
| 1851 | { | 1844 | { |
| @@ -1859,7 +1852,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1859 | } | 1852 | } |
| 1860 | printchar ('>', printcharfun); | 1853 | printchar ('>', printcharfun); |
| 1861 | } | 1854 | } |
| 1862 | break; | 1855 | return; |
| 1863 | 1856 | ||
| 1864 | case PVEC_BUFFER: | 1857 | case PVEC_BUFFER: |
| 1865 | if (!BUFFER_LIVE_P (XBUFFER (obj))) | 1858 | if (!BUFFER_LIVE_P (XBUFFER (obj))) |
| @@ -1872,11 +1865,11 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1872 | } | 1865 | } |
| 1873 | else | 1866 | else |
| 1874 | print_string (BVAR (XBUFFER (obj), name), printcharfun); | 1867 | print_string (BVAR (XBUFFER (obj), name), printcharfun); |
| 1875 | break; | 1868 | return; |
| 1876 | 1869 | ||
| 1877 | case PVEC_WINDOW_CONFIGURATION: | 1870 | case PVEC_WINDOW_CONFIGURATION: |
| 1878 | print_c_string ("#<window-configuration>", printcharfun); | 1871 | print_c_string ("#<window-configuration>", printcharfun); |
| 1879 | break; | 1872 | return; |
| 1880 | 1873 | ||
| 1881 | case PVEC_FRAME: | 1874 | case PVEC_FRAME: |
| 1882 | { | 1875 | { |
| @@ -1900,7 +1893,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1900 | int len = sprintf (buf, " %p>", ptr); | 1893 | int len = sprintf (buf, " %p>", ptr); |
| 1901 | strout (buf, len, len, printcharfun); | 1894 | strout (buf, len, len, printcharfun); |
| 1902 | } | 1895 | } |
| 1903 | break; | 1896 | return; |
| 1904 | 1897 | ||
| 1905 | case PVEC_FONT: | 1898 | case PVEC_FONT: |
| 1906 | { | 1899 | { |
| @@ -1933,7 +1926,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1933 | } | 1926 | } |
| 1934 | printchar ('>', printcharfun); | 1927 | printchar ('>', printcharfun); |
| 1935 | } | 1928 | } |
| 1936 | break; | 1929 | return; |
| 1937 | 1930 | ||
| 1938 | case PVEC_THREAD: | 1931 | case PVEC_THREAD: |
| 1939 | print_c_string ("#<thread ", printcharfun); | 1932 | print_c_string ("#<thread ", printcharfun); |
| @@ -1946,7 +1939,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1946 | strout (buf, len, len, printcharfun); | 1939 | strout (buf, len, len, printcharfun); |
| 1947 | } | 1940 | } |
| 1948 | printchar ('>', printcharfun); | 1941 | printchar ('>', printcharfun); |
| 1949 | break; | 1942 | return; |
| 1950 | 1943 | ||
| 1951 | case PVEC_MUTEX: | 1944 | case PVEC_MUTEX: |
| 1952 | print_c_string ("#<mutex ", printcharfun); | 1945 | print_c_string ("#<mutex ", printcharfun); |
| @@ -1959,7 +1952,7 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1959 | strout (buf, len, len, printcharfun); | 1952 | strout (buf, len, len, printcharfun); |
| 1960 | } | 1953 | } |
| 1961 | printchar ('>', printcharfun); | 1954 | printchar ('>', printcharfun); |
| 1962 | break; | 1955 | return; |
| 1963 | 1956 | ||
| 1964 | case PVEC_CONDVAR: | 1957 | case PVEC_CONDVAR: |
| 1965 | print_c_string ("#<condvar ", printcharfun); | 1958 | print_c_string ("#<condvar ", printcharfun); |
| @@ -1972,10 +1965,10 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 1972 | strout (buf, len, len, printcharfun); | 1965 | strout (buf, len, len, printcharfun); |
| 1973 | } | 1966 | } |
| 1974 | printchar ('>', printcharfun); | 1967 | printchar ('>', printcharfun); |
| 1975 | break; | 1968 | return; |
| 1976 | 1969 | ||
| 1977 | #ifdef HAVE_MODULES | ||
| 1978 | case PVEC_MODULE_FUNCTION: | 1970 | case PVEC_MODULE_FUNCTION: |
| 1971 | #ifdef HAVE_MODULES | ||
| 1979 | { | 1972 | { |
| 1980 | print_c_string ("#<module function ", printcharfun); | 1973 | print_c_string ("#<module function ", printcharfun); |
| 1981 | const struct Lisp_Module_Function *function = XMODULE_FUNCTION (obj); | 1974 | const struct Lisp_Module_Function *function = XMODULE_FUNCTION (obj); |
| @@ -2000,11 +1993,13 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 2000 | } | 1993 | } |
| 2001 | 1994 | ||
| 2002 | printchar ('>', printcharfun); | 1995 | printchar ('>', printcharfun); |
| 1996 | return; | ||
| 2003 | } | 1997 | } |
| 2004 | break; | ||
| 2005 | #endif | 1998 | #endif |
| 2006 | #ifdef HAVE_NATIVE_COMP | 1999 | break; |
| 2000 | |||
| 2007 | case PVEC_NATIVE_COMP_UNIT: | 2001 | case PVEC_NATIVE_COMP_UNIT: |
| 2002 | #ifdef HAVE_NATIVE_COMP | ||
| 2008 | { | 2003 | { |
| 2009 | struct Lisp_Native_Comp_Unit *cu = XNATIVE_COMP_UNIT (obj); | 2004 | struct Lisp_Native_Comp_Unit *cu = XNATIVE_COMP_UNIT (obj); |
| 2010 | print_c_string ("#<native compilation unit: ", printcharfun); | 2005 | print_c_string ("#<native compilation unit: ", printcharfun); |
| @@ -2012,27 +2007,32 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 2012 | printchar (' ', printcharfun); | 2007 | printchar (' ', printcharfun); |
| 2013 | print_object (cu->optimize_qualities, printcharfun, escapeflag); | 2008 | print_object (cu->optimize_qualities, printcharfun, escapeflag); |
| 2014 | printchar ('>', printcharfun); | 2009 | printchar ('>', printcharfun); |
| 2010 | return; | ||
| 2015 | } | 2011 | } |
| 2016 | break; | ||
| 2017 | #endif | 2012 | #endif |
| 2013 | break; | ||
| 2018 | 2014 | ||
| 2019 | #ifdef HAVE_TREE_SITTER | ||
| 2020 | case PVEC_TS_PARSER: | 2015 | case PVEC_TS_PARSER: |
| 2016 | #ifdef HAVE_TREE_SITTER | ||
| 2021 | print_c_string ("#<treesit-parser for ", printcharfun); | 2017 | print_c_string ("#<treesit-parser for ", printcharfun); |
| 2022 | Lisp_Object language = XTS_PARSER (obj)->language_symbol; | 2018 | Lisp_Object language = XTS_PARSER (obj)->language_symbol; |
| 2023 | /* No need to print the buffer because it's not that useful: we | 2019 | /* No need to print the buffer because it's not that useful: we |
| 2024 | usually know which buffer a parser belongs to. */ | 2020 | usually know which buffer a parser belongs to. */ |
| 2025 | print_string (Fsymbol_name (language), printcharfun); | 2021 | print_string (Fsymbol_name (language), printcharfun); |
| 2026 | printchar ('>', printcharfun); | 2022 | printchar ('>', printcharfun); |
| 2023 | return; | ||
| 2024 | #endif | ||
| 2027 | break; | 2025 | break; |
| 2026 | |||
| 2028 | case PVEC_TS_NODE: | 2027 | case PVEC_TS_NODE: |
| 2028 | #ifdef HAVE_TREE_SITTER | ||
| 2029 | /* Prints #<treesit-node (identifier) in 12-15> or | 2029 | /* Prints #<treesit-node (identifier) in 12-15> or |
| 2030 | #<treesit-node "keyword" in 28-31>. */ | 2030 | #<treesit-node "keyword" in 28-31>. */ |
| 2031 | print_c_string ("#<treesit-node", printcharfun); | 2031 | print_c_string ("#<treesit-node", printcharfun); |
| 2032 | if (!treesit_node_uptodate_p (obj)) | 2032 | if (!treesit_node_uptodate_p (obj)) |
| 2033 | { | 2033 | { |
| 2034 | print_c_string ("-outdated>", printcharfun); | 2034 | print_c_string ("-outdated>", printcharfun); |
| 2035 | break; | 2035 | return; |
| 2036 | } | 2036 | } |
| 2037 | printchar (' ', printcharfun); | 2037 | printchar (' ', printcharfun); |
| 2038 | /* Now the node must be up-to-date, and calling functions like | 2038 | /* Now the node must be up-to-date, and calling functions like |
| @@ -2053,11 +2053,16 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 2053 | printchar ('-', printcharfun); | 2053 | printchar ('-', printcharfun); |
| 2054 | print_object (Ftreesit_node_end (obj), printcharfun, escapeflag); | 2054 | print_object (Ftreesit_node_end (obj), printcharfun, escapeflag); |
| 2055 | printchar ('>', printcharfun); | 2055 | printchar ('>', printcharfun); |
| 2056 | return; | ||
| 2057 | #endif | ||
| 2056 | break; | 2058 | break; |
| 2059 | |||
| 2057 | case PVEC_TS_COMPILED_QUERY: | 2060 | case PVEC_TS_COMPILED_QUERY: |
| 2061 | #ifdef HAVE_TREE_SITTER | ||
| 2058 | print_c_string ("#<treesit-compiled-query>", printcharfun); | 2062 | print_c_string ("#<treesit-compiled-query>", printcharfun); |
| 2059 | break; | 2063 | return; |
| 2060 | #endif | 2064 | #endif |
| 2065 | break; | ||
| 2061 | 2066 | ||
| 2062 | case PVEC_SQLITE: | 2067 | case PVEC_SQLITE: |
| 2063 | { | 2068 | { |
| @@ -2073,13 +2078,23 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | |||
| 2073 | print_c_string (XSQLITE (obj)->name, printcharfun); | 2078 | print_c_string (XSQLITE (obj)->name, printcharfun); |
| 2074 | printchar ('>', printcharfun); | 2079 | printchar ('>', printcharfun); |
| 2075 | } | 2080 | } |
| 2076 | break; | 2081 | return; |
| 2077 | 2082 | ||
| 2078 | default: | 2083 | /* Types handled earlier. */ |
| 2079 | emacs_abort (); | 2084 | case PVEC_NORMAL_VECTOR: |
| 2085 | case PVEC_RECORD: | ||
| 2086 | case PVEC_COMPILED: | ||
| 2087 | case PVEC_CHAR_TABLE: | ||
| 2088 | case PVEC_SUB_CHAR_TABLE: | ||
| 2089 | case PVEC_HASH_TABLE: | ||
| 2090 | case PVEC_BIGNUM: | ||
| 2091 | case PVEC_BOOL_VECTOR: | ||
| 2092 | /* Impossible cases. */ | ||
| 2093 | case PVEC_FREE: | ||
| 2094 | case PVEC_OTHER: | ||
| 2095 | break; | ||
| 2080 | } | 2096 | } |
| 2081 | 2097 | emacs_abort (); | |
| 2082 | return true; | ||
| 2083 | } | 2098 | } |
| 2084 | 2099 | ||
| 2085 | static char | 2100 | static char |
| @@ -2523,29 +2538,21 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 2523 | switch (PSEUDOVECTOR_TYPE (XVECTOR (obj))) | 2538 | switch (PSEUDOVECTOR_TYPE (XVECTOR (obj))) |
| 2524 | { | 2539 | { |
| 2525 | case PVEC_NORMAL_VECTOR: | 2540 | case PVEC_NORMAL_VECTOR: |
| 2526 | { | 2541 | print_stack_push_vector ("[", "]", obj, 0, ASIZE (obj), |
| 2527 | print_stack_push_vector ("[", "]", obj, 0, ASIZE (obj), | 2542 | printcharfun); |
| 2528 | printcharfun); | 2543 | goto next_obj; |
| 2529 | goto next_obj; | ||
| 2530 | } | ||
| 2531 | case PVEC_RECORD: | 2544 | case PVEC_RECORD: |
| 2532 | { | 2545 | print_stack_push_vector ("#s(", ")", obj, 0, PVSIZE (obj), |
| 2533 | print_stack_push_vector ("#s(", ")", obj, 0, PVSIZE (obj), | 2546 | printcharfun); |
| 2534 | printcharfun); | 2547 | goto next_obj; |
| 2535 | goto next_obj; | ||
| 2536 | } | ||
| 2537 | case PVEC_COMPILED: | 2548 | case PVEC_COMPILED: |
| 2538 | { | 2549 | print_stack_push_vector ("#[", "]", obj, 0, PVSIZE (obj), |
| 2539 | print_stack_push_vector ("#[", "]", obj, 0, PVSIZE (obj), | 2550 | printcharfun); |
| 2540 | printcharfun); | 2551 | goto next_obj; |
| 2541 | goto next_obj; | ||
| 2542 | } | ||
| 2543 | case PVEC_CHAR_TABLE: | 2552 | case PVEC_CHAR_TABLE: |
| 2544 | { | 2553 | print_stack_push_vector ("#^[", "]", obj, 0, PVSIZE (obj), |
| 2545 | print_stack_push_vector ("#^[", "]", obj, 0, PVSIZE (obj), | 2554 | printcharfun); |
| 2546 | printcharfun); | 2555 | goto next_obj; |
| 2547 | goto next_obj; | ||
| 2548 | } | ||
| 2549 | case PVEC_SUB_CHAR_TABLE: | 2556 | case PVEC_SUB_CHAR_TABLE: |
| 2550 | { | 2557 | { |
| 2551 | /* Make each lowest sub_char_table start a new line. | 2558 | /* Make each lowest sub_char_table start a new line. |
| @@ -2614,30 +2621,22 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 2614 | goto next_obj; | 2621 | goto next_obj; |
| 2615 | } | 2622 | } |
| 2616 | 2623 | ||
| 2624 | case PVEC_BIGNUM: | ||
| 2625 | print_bignum (obj, printcharfun); | ||
| 2626 | break; | ||
| 2627 | |||
| 2628 | case PVEC_BOOL_VECTOR: | ||
| 2629 | print_bool_vector (obj, printcharfun); | ||
| 2630 | break; | ||
| 2631 | |||
| 2617 | default: | 2632 | default: |
| 2633 | print_vectorlike_unreadable (obj, printcharfun, escapeflag, buf); | ||
| 2618 | break; | 2634 | break; |
| 2619 | } | 2635 | } |
| 2620 | |||
| 2621 | if (print_vectorlike (obj, printcharfun, escapeflag, buf)) | ||
| 2622 | break; | 2636 | break; |
| 2623 | FALLTHROUGH; | ||
| 2624 | 2637 | ||
| 2625 | default: | 2638 | default: |
| 2626 | { | 2639 | emacs_abort (); |
| 2627 | int len; | ||
| 2628 | /* We're in trouble if this happens! | ||
| 2629 | Probably should just emacs_abort (). */ | ||
| 2630 | print_c_string ("#<EMACS BUG: INVALID DATATYPE ", printcharfun); | ||
| 2631 | if (VECTORLIKEP (obj)) | ||
| 2632 | len = sprintf (buf, "(PVEC 0x%08zx)", (size_t) ASIZE (obj)); | ||
| 2633 | else | ||
| 2634 | len = sprintf (buf, "(0x%02x)", (unsigned) XTYPE (obj)); | ||
| 2635 | strout (buf, len, len, printcharfun); | ||
| 2636 | print_c_string ((" Save your buffers immediately" | ||
| 2637 | " and please report this bug>"), | ||
| 2638 | printcharfun); | ||
| 2639 | break; | ||
| 2640 | } | ||
| 2641 | } | 2640 | } |
| 2642 | print_depth--; | 2641 | print_depth--; |
| 2643 | 2642 | ||