From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: hx Newsgroups: gmane.emacs.devel Subject: Re: how to keep a copy of emacs_env or ert in module ? Date: Tue, 13 Sep 2016 08:02:49 +0800 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e013d167084fb09053c5855cd X-Trace: blaine.gmane.org 1473725076 3770 195.159.176.226 (13 Sep 2016 00:04:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 13 Sep 2016 00:04:36 +0000 (UTC) To: Philipp Stephani , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 13 02:04:33 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjbDB-000058-Ep for ged-emacs-devel@m.gmane.org; Tue, 13 Sep 2016 02:04:29 +0200 Original-Received: from localhost ([::1]:45786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjbD9-0006PO-II for ged-emacs-devel@m.gmane.org; Mon, 12 Sep 2016 20:04:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjbD0-0006O3-Hz for emacs-devel@gnu.org; Mon, 12 Sep 2016 20:04:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjbCx-0008GF-Ak for emacs-devel@gnu.org; Mon, 12 Sep 2016 20:04:18 -0400 Original-Received: from mail-wm0-f43.google.com ([74.125.82.43]:37835) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjbCx-0008AH-55 for emacs-devel@gnu.org; Mon, 12 Sep 2016 20:04:15 -0400 Original-Received: by mail-wm0-f43.google.com with SMTP id c131so84430706wmh.0 for ; Mon, 12 Sep 2016 17:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=QAWupAzAP9WidbH/mCLdxrm2MAK5IueBNTAMWbLFrAc=; b=YST3CAVo082BMA/tRaC2ZOqWUvhG9ovWHmNsuHdWBWVZXElaswVlOviTP8id8ENfKl sDmy5U6Wj+fGwwRDN/5GptDRHcje/6SiBzlYFS0yhRtgmmlwF48k59z90jV26XTI98Wb uMGHVPA5J22w5OrLtxsIgqWRS7Aq7KKTI3xXLnLtAedgwcjNalq5DK4iyUyDEw1JpdJb lgGTtQJIvq06LF1jMpMeLg1VScBY8+iEYBjYmRvTehQJ8z9gdwzs4+zAitXpswKMgByI hDnMwdiru7W+IFQrtH2IhlES2jze7nyyvCHUnRX3AOxJX4dakzcdq3xdxkHRuQsw1hXQ hIkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=QAWupAzAP9WidbH/mCLdxrm2MAK5IueBNTAMWbLFrAc=; b=ToOmiETVgTCBSFZed1l9d22xHyIpNgDFmmFF8yqO3QdcbFMMVudxC0mrwEUREZSza2 GlfeU/U8N6lx/TvZGIyUmSZPSLezjaeFEmLNZrYwLY9XglJhU9pmnL580ezYtKXJrORE 9QwbD2LffE315uhRASpV1p/0epUmWpIxvPzu7QLYi+gHa0Yu8iCU/gCI6XuMnkuFLfuL /mfWeSHK7VlMl/xuqz3/Ki1/5Wbg1VzRQd7GiBRKTOC6KZzM6jpH2zc5ViVHlbgXPedE Evs2eK9quxOMTEKosQ508OiUnRkjq7ylpFg/PwPLeH5w1ZdNodT3MoTR3SeYhuj7e3rZ wQsw== X-Gm-Message-State: AE9vXwOQHGMqVmGKYHarY1LF7oBkyTLZFgwhxwJyHWPafRGStXoUYBsYcJGnD2hg7ddVAga0YFE1V9EMwLJo3A== X-Received: by 10.194.178.165 with SMTP id cz5mr16379448wjc.57.1473724973118; Mon, 12 Sep 2016 17:02:53 -0700 (PDT) Original-Received: by 10.28.38.70 with HTTP; Mon, 12 Sep 2016 17:02:49 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.43 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207406 Archived-At: --089e013d167084fb09053c5855cd Content-Type: text/plain; charset=UTF-8 On Sun, Sep 11, 2016 at 4:02 PM, Philipp Stephani wrote: > > > hx schrieb am So., 11. Sep. 2016 um 06:30 Uhr: > >> is it possible to keep a copy of the *env in module ? >> >> > No. emacs_env, emacs_runtime, and emacs_value objects are only valid > within the dynamic extent of the function they are created/passed in. You > can't keep them around. The only exception are global references, created > by make_global_ref. > instead of copy the pointer, I copy the struct content: emacs_env genvo; emacs_env *genv = &genvo; int emacs_module_init(struct emacs_runtime *ert) { emacs_env *env = ert->get_environment(ert); genvo = *env; ... } it is working. --089e013d167084fb09053c5855cd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Sun, Sep 11, 2016 at 4:02 PM, Philipp Stephani <= ;p.stephani2@gma= il.com> wrote:


hx <silent2600@gmail.com> schrieb am So., 11. Sep. 2016 um= 06:30=C2=A0Uhr:
is it possible to keep a copy of the *env in module = ?


No. ema= cs_env, emacs_runtime, and emacs_value objects are only valid within the dy= namic extent of the function they are created/passed in. You can't keep= them around. The only exception are global references, created by make_glo= bal_ref.

instead of copy the= pointer, I copy the struct content:

emacs_env genvo;<= /div>
emacs_env *genv =3D &genvo;

int
emacs_module_init(struct emac= s_runtime *ert)
{
=C2=A0 emacs_env *env =3D ert->get_environment(ert);
=C2=A0 genvo =3D *env;
...
}

it is working.=C2=A0
--089e013d167084fb09053c5855cd--