unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: hx <silent2600@gmail.com>
To: Philipp Stephani <p.stephani2@gmail.com>, emacs-devel@gnu.org
Subject: Re: how to keep a copy of emacs_env or ert in module ?
Date: Tue, 13 Sep 2016 08:02:49 +0800	[thread overview]
Message-ID: <CAALPCHsHEbvt68CCP1nmHwQoC24pzoGRDvMuOAD65mAbzkdv0w@mail.gmail.com> (raw)
In-Reply-To: <CAArVCkRnXwKhpEDQQX-djEecuv=GwK6nv5r6JgSPwnMrLniXBA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

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

>
>
> hx <silent2600@gmail.com> 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.

[-- Attachment #2: Type: text/html, Size: 1857 bytes --]

  reply	other threads:[~2016-09-13  0:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-11  4:28 how to keep a copy of emacs_env or ert in module ? hx
2016-09-11  6:41 ` Andreas Schwab
2016-09-11  8:02 ` Philipp Stephani
2016-09-13  0:02   ` hx [this message]
2016-09-13  6:18     ` Philipp Stephani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAALPCHsHEbvt68CCP1nmHwQoC24pzoGRDvMuOAD65mAbzkdv0w@mail.gmail.com \
    --to=silent2600@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=p.stephani2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).