[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to add pseudo vector types
From: |
Eli Zaretskii |
Subject: |
Re: How to add pseudo vector types |
Date: |
Thu, 22 Jul 2021 11:23:07 +0300 |
> From: Yuan Fu <casouri@gmail.com>
> Date: Wed, 21 Jul 2021 23:10:14 -0400
> Cc: Clément Pit-Claudel <cpitclaudel@gmail.com>,
> emacs-devel <emacs-devel@gnu.org>
>
> Should I keep posting patches, or should I create a branch in /scratch?
The latter, I think.
> If the latter, how do I do it?
You need write access to the Emacs repository.
> @@ -96,33 +103,30 @@ ts_ensure_parsed (Lisp_Object parser)
> ts_read_buffer (void *buffer, uint32_t byte_index,
> TSPoint position, uint32_t *bytes_read)
> {
> - if (! BUFFER_LIVE_P ((struct buffer *) buffer))
> + if (!BUFFER_LIVE_P ((struct buffer *) buffer))
> error ("BUFFER is not live");
Is it really TRT to signal an error here? This is not code that would
run from a user command, so signaling an error is not necessarily the
useful response to this situation. Why not simply return without
doing anything?
> + // TODO BUF_ZV_BYTE?
Do you want to discuss this? I'd prefer to have it the other way
around: use BUF_ZV_BYTE by default. The callers could widen the
buffer if they needed to access outside of the narrowing.
> else
> {
> - beg = (char *) BYTE_POS_ADDR (byte_pos);
> + beg = (char *) BUF_BYTE_ADDRESS (buffer, byte_pos);
> len = next_char_len(byte_pos);
The last line is incorrect, as it assumes the current buffer. You
actually don't need that function, it's enough to use
BYTES_BY_CHAR_HEAD on the address in 'beg'.
> *bytes_read = (uint32_t) len;
Is using uint32_t the restriction of tree-sitter? Doesn't it support
reading more than 2 gigabytes?
> +DEFUN ("tree-sitter-node-type",
> + Ftree_sitter_node_type, Stree_sitter_node_type, 1, 1, 0,
> + doc: /* Return the NODE's type as a symbol. */)
> + (Lisp_Object node)
> +{
> + CHECK_TS_NODE (node);
> + TSNode ts_node = XTS_NODE (node)->node;
> + const char *type = ts_node_type(ts_node);
> + return intern_c_string (type);
Why do we need to intern the string each time? can't we store the
interned symbol there, instead of a C string, in the first place?
Thanks.
- Re: How to add pseudo vector types, (continued)
- Re: How to add pseudo vector types, Stefan Monnier, 2021/07/17
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/17
- Re: How to add pseudo vector types, Stefan Monnier, 2021/07/24
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/24
- Re: How to add pseudo vector types, Stefan Monnier, 2021/07/24
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/24
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/19
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/21
- Re: How to add pseudo vector types,
Eli Zaretskii <=
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/22
- Re: How to add pseudo vector types, Óscar Fuentes, 2021/07/22
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/22
- Re: How to add pseudo vector types, Óscar Fuentes, 2021/07/22
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/23
- Re: How to add pseudo vector types, Stephen Leake, 2021/07/24
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/22
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/22
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/22
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/23