From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: How to add pseudo vector types Date: Wed, 14 Jul 2021 19:48:07 -0400 Message-ID: <82443C84-A4C8-4FD2-AD08-C317416CA709@gmail.com> References: <84B70E9B-E1E5-40D3-AFBE-033CACF15914@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_03B14999-EE36-4507-B492-47B03022C58C" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24211"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jul 15 01:48:55 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3ocY-0006BJ-Ut for ged-emacs-devel@m.gmane-mx.org; Thu, 15 Jul 2021 01:48:55 +0200 Original-Received: from localhost ([::1]:43934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3ocX-00053P-W4 for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Jul 2021 19:48:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3obr-0004Ka-QL for emacs-devel@gnu.org; Wed, 14 Jul 2021 19:48:11 -0400 Original-Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:40803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3obq-00052A-1q for emacs-devel@gnu.org; Wed, 14 Jul 2021 19:48:11 -0400 Original-Received: by mail-qk1-x72f.google.com with SMTP id m68so3441299qke.7 for ; Wed, 14 Jul 2021 16:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=jctAykwdoudu7XxVAyErLi4JchxqTgpABnsu1g1eGCM=; b=teM1v53GXujOFnAI2ckbh26Ph67VbkNs4H+fQ/MGq5ZJPKvKtwVGOHoFOT0i1iho1A +rpYWIvIUipqg3hEiay1YOv7HXF+rrudpnAxk8QZTkcB5/gIN2TmSCle0TAWZHHNxexj xxUmIgfZXnxMnvwoAkPAJ+wJFYzDf1/zFMsKZUqBQr5yFfjXIGSVau7Qv+V1agAhXjCE 8oSDfJcWEHN+EIg69CvzCODJzXA1NhBjABvq3cBHYlv8zyQ9aCBemioIDtuOpeMLoGRT KsbVa/7eYnzIb383RT4EDjEBxOu24rAm5LaAA5v38+4TIkNfz9rVfGL55fPoXzHZUcle HOMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=jctAykwdoudu7XxVAyErLi4JchxqTgpABnsu1g1eGCM=; b=S0bYUy2fGuUN5LC+XTFy3upO2H854o4RSwmvf8l/qk7NDbpgiWQLtb3k0ORjAztRw0 n7Isw527+31BvOsPmJrdd0ZvMfz4unX6prr/wnnpn4CAc5abRjPyg7ZxTsrqPNYt5Pv3 0dP7ATlhxbRLlU4b96GRIS4SNF2QZm4r85CHWKHW0aE1VQpzHD9uGL6jycnaNsrqTmoA lFz3AulZw9hM/z/wvnmZDXo/anK0/LlPoJdZPjW8ymZRRBmQZyGnwiYgLgZWVEyHm54h uuuLSF/Mgtv4PZpSe/N45SinDHtRTqUAWgRXv488+tSVEYSw5LxrrtLJ9uYeq0w7iIFh 7anA== X-Gm-Message-State: AOAM531xhYSJTVX66HmKCveyGGdaSmyPClGC719SCBzePEu4QzcGa0vG J5nMpNCVfs37fnXYp7wlH6E= X-Google-Smtp-Source: ABdhPJygeJGAUdKmfe/Wq4+iL2VlX5USnpbzq4FB3JhWpVxxb1JYmWule04WoGUuXzt9GoBDWqFvqQ== X-Received: by 2002:a37:2d04:: with SMTP id t4mr509136qkh.463.1626306488568; Wed, 14 Jul 2021 16:48:08 -0700 (PDT) Original-Received: from ?IPv6:2601:98a:4102:3d80:86f:d40e:402b:2fc7? ([2601:98a:4102:3d80:86f:d40e:402b:2fc7]) by smtp.gmail.com with ESMTPSA id t74sm1746803qka.56.2021.07.14.16.48.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jul 2021 16:48:08 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.60.0.2.21) Received-SPF: pass client-ip=2607:f8b0:4864:20::72f; envelope-from=casouri@gmail.com; helo=mail-qk1-x72f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271228 Archived-At: --Apple-Mail=_03B14999-EE36-4507-B492-47B03022C58C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >>=20 >> 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? >=20 > Most likely you'll want some of your functions to take objects that > should be "tree sitter parsers", but you'll only receive a Lisp_Object > so you'll need to be able to *test* that the object you received is > indeed a "tree sitter parser". >=20 > For that reason you'll probably want to add a new entry to `pvec_type` > rather than use a USER_PTR. Actually, what is the correct way to provide a pointer from a dynamic = module to Emacs core? I tried to use USER_PTR, but the dynamic module = can only return an emacs_value, and to convert an emacs_value to a = Lisp_Object, I need to use value_to_lisp, which is not exposed by = emacs-module.c. I want to provide individual tree-sitter language definitions from = dynamic modules so that one don=E2=80=99t need to compile Emacs with = language definitions. Yuan= --Apple-Mail=_03B14999-EE36-4507-B492-47B03022C58C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

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?

Most likely = you'll want some of your functions to take objects that
should be = "tree sitter parsers", but you'll only receive a Lisp_Object
so you'll = need to be able to *test* that the object you received is
indeed a = "tree sitter parser".

For that reason you'll probably want to add a new entry to = `pvec_type`
rather than = use a USER_PTR.

Actually, what is the = correct way to provide a pointer from a dynamic module to Emacs core? I = tried to use USER_PTR, but the dynamic module can only return an = emacs_value, and to convert an emacs_value to a Lisp_Object, I need to = use value_to_lisp, which is not exposed by emacs-module.c.

I want to provide = individual tree-sitter language definitions from dynamic modules so that = one don=E2=80=99t need to compile Emacs with language = definitions.

Yuan
= --Apple-Mail=_03B14999-EE36-4507-B492-47B03022C58C--