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 20:26:09 -0400 Message-ID: References: <84B70E9B-E1E5-40D3-AFBE-033CACF15914@gmail.com> <82443C84-A4C8-4FD2-AD08-C317416CA709@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_3BC680BF-6367-46CF-8806-5510288BF060" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36670"; 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 02:26:48 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 1m3pDE-0009Qc-Ef for ged-emacs-devel@m.gmane-mx.org; Thu, 15 Jul 2021 02:26:48 +0200 Original-Received: from localhost ([::1]:53476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3pDC-0004wb-Qh for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Jul 2021 20:26:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3pCe-0004Eq-VV for emacs-devel@gnu.org; Wed, 14 Jul 2021 20:26:12 -0400 Original-Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:44790) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3pCd-00059W-EM for emacs-devel@gnu.org; Wed, 14 Jul 2021 20:26:12 -0400 Original-Received: by mail-qk1-x72f.google.com with SMTP id 77so3497659qkk.11 for ; Wed, 14 Jul 2021 17:26:11 -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=TH5mrxpF7+nYYEmhWKwZFsrodybwMfUaz/Q3mr2UmgM=; b=avqpJbImNB6nLStB6eaaCGTPxzZRxJVnqMD9fQ1LR2Nl1qfoKaCK2M/uhiofhR6dvI 3oOl8lDbecksktcllwWcPX8AWwbGuCOfzmrA17qvdBOlL0pbubHDkN2hG3xyZp5hafrP xIAJevxUAgMo6ryKNmcG/4F1KUWzV8ME2fKtuyj9MngMM3CHrwnKfoBJ982Phn0RMGTI 1fxoM/VO/5KH/0Agwc27mBokf+OC9t97L7QPY5/vXjjUgYs7i+wKrMs5LTyi8AzDq5ik 5RJhzYOgN7BtGmtvv+km27EUKPdsIQvCocVZQ1Y5YoxKxZ3uOeRowJfu+Sc92SCvUUv9 tyyw== 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=TH5mrxpF7+nYYEmhWKwZFsrodybwMfUaz/Q3mr2UmgM=; b=WFuxl1+B2RLPSaU72ggZz9iUG9TisPkE/TcOVuXHLGLmGEb+T1PaLZ8H7Dy1zgQEUY Bj43melxbBnqyykgVOSjtXbn3yyMo8u8giuBM+DPSKh/p4BA6TG+vcVRHLomAknwEED8 sVz7mUki4NHxx6dYm450AbU1CZUnsIDEJBIF1SAzLEqroA/Y63UrBC3n+Ihf16fyVIT7 vBUOxp3omru66RMOkxYZ/Sz2kfpFrJcOMMT/cLhZbLo5J8PskZxSC36VIj51lh5mNSxf sM2r4TUKeUs9+FUnz3nEVGxvNUFmJ4sHr4ra9tB3NopU/gGJYXceaa1JH5mfCaT6MSif c2fA== X-Gm-Message-State: AOAM532BiMh07Y3Dz8HCtYBsEtVnD0plz/URPtCslVQSEf+/3svcRBF5 Ev7x85+eaEEcNaiWH8MTVqlbdEHkfBCJcw== X-Google-Smtp-Source: ABdhPJw1JZ0XFRnnO6tF8XcOORu/v0zDVkKqdL+PvyXjnY/QqMMTd4rP+SfyykE1K7XU2Za0S26wcg== X-Received: by 2002:a37:8f44:: with SMTP id r65mr724139qkd.20.1626308770525; Wed, 14 Jul 2021 17:26:10 -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 d24sm1780306qkk.61.2021.07.14.17.26.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jul 2021 17:26:10 -0700 (PDT) In-Reply-To: <82443C84-A4C8-4FD2-AD08-C317416CA709@gmail.com> 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:271230 Archived-At: --Apple-Mail=_3BC680BF-6367-46CF-8806-5510288BF060 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 14, 2021, at 7:48 PM, Yuan Fu wrote: >=20 >>>=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. >=20 >=20 > 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. >=20 > 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. I just realized that I can regard emacs_value just as Lisp_Object. Is = that right? Yuan --Apple-Mail=_3BC680BF-6367-46CF-8806-5510288BF060 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jul 14, 2021, at 7:48 PM, Yuan Fu <casouri@gmail.com> = wrote:


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.

I = just realized that I can regard emacs_value just as Lisp_Object. Is that = right?

Yuan

= --Apple-Mail=_3BC680BF-6367-46CF-8806-5510288BF060--