[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: |
Wed, 14 Jul 2021 20:44:21 +0300 |
> From: Yuan Fu <casouri@gmail.com>
> Date: Wed, 14 Jul 2021 13:37:47 -0400
>
> Say I want to expose tree-sitter’s parser to lisp, and I define it as a new
> pseudo vector.
>
> struct Lisp_TS_Parser
> {
> union vectorlike_header header;
> Lisp_Object buffer;
> TSParser *parser;
> TSTree *tree;
> TSInput input;
> };
Inside Emacs, or in a module? I assume the former.
> Now if I want to return a Lisp_Object, do I initialize this struct and cast
> it into a Lisp_Object and return it? Like:
>
> Lisp_TS_parser lisp_parser;
> ...
> return (Lisp_Object)lisp_parser;
No, you need to define a proper Lisp_Object, and then define
functions/macros to make a Lisp_Object that represents the struct, and
vice versa.
> And how do I use a USER_PTR? Do I cast it into (struct Lisp_User_Ptr) and use
> it normally, or is there some helper function that I should use?
Look in lisp.h, you will find some infrastructure there.
> Are there examples of using pseudo vectors?
Every buffer, window, frame, and overlay is a pseudo vector. Look how
these are handled in lisp.h and in the rest of the code, and you will
find a lot of examples.
- How to add pseudo vector types, Yuan Fu, 2021/07/14
- Re: How to add pseudo vector types,
Eli Zaretskii <=
- Re: How to add pseudo vector types, Stefan Monnier, 2021/07/14
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/14
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/14
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/14
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/15
- Re: How to add pseudo vector types, Fu Yuan, 2021/07/15
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/15
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/15
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/15
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/15