all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs modules 25.1
       [not found] <709716874.935191.1474913256978.ref@mail.yahoo.com>
@ 2016-09-26 18:07 ` Mambo Levis
  2016-09-27 12:23   ` Mambo Levis
  0 siblings, 1 reply; 4+ messages in thread
From: Mambo Levis @ 2016-09-26 18:07 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org, johnw@newartisans.com,
	bozhidar@batsov.com

Hi,
I tested (in Windows) the example from Aurélien Aptel (http://diobla.info/blog-archive/modules-tut.html) with gcc at it runs as expected.
Now, I would like to create a C++ wrapper, but I not quite sure if it is possible. Questions:
1. Is it possible to create a C++ wrapper around emacs_modules?2. I am trying to build the same example using g++ and the following error appears:
---------------------------------------------------------------------------------------------------------------$ make SO=dllg++ -ggdb3 -ID:\user\emacs-src\emacs-25-branch-src/src -c mymod.cmymod.c: In function 'int emacs_module_init(emacs_runtime*)':mymod.c:55:45: error: invalid conversion from 'emacs_value_tag* (*)(emacs_env*, int, emacs_value_tag**, void*) {aka emacs_value_tag* (*)(emacs_env_25*, int, emacs_value_tag**, void*)}' to 'emacs_value_tag* (*)(emacs_env*, ptrdiff_t, emacs_value_tag**, void*) {aka emacs_value_tag* (*)(emacs_env_25*, long long int, emacs_value_tag**, void*)}' [-fpermissive]                                         NULL);                                             ^Makefile:42: recipe for target 'mymod.o' failedmake: *** [mymod.o] Error 1
---------------------------------------------------------------------------------------------------------------
It corresponds to the following code (I remarked the part associated with the error)
-------------------------------------------------------------------------------------------------------intemacs_module_init (struct emacs_runtime *ert){  emacs_env *env = ert->get_environment (ert);
  /* create a lambda (returns an emacs_value) */  emacs_value fun = env->make_function (env,                                        0,                                        0,                                        Fmymod_test,                                        "doc",                                        NULL);  bind_function (env, "mymod-test", fun);  provide (env, "mymod");
/* loaded successfully */  return 0;}
-----------------------------------------------------------------------------------------------------------
Do you have any Idea or recommendation? 
Thanks,
Levis




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Emacs modules 25.1
  2016-09-26 18:07 ` Emacs modules 25.1 Mambo Levis
@ 2016-09-27 12:23   ` Mambo Levis
  2016-09-27 14:55     ` Eli Zaretskii
  2016-09-27 15:36     ` Philipp Stephani
  0 siblings, 2 replies; 4+ messages in thread
From: Mambo Levis @ 2016-09-27 12:23 UTC (permalink / raw)
  To: Mambo Levis, help-gnu-emacs@gnu.org, johnw@newartisans.com,
	bozhidar@batsov.com

Hi,
I found the problem and now I can build the emacs_module example using g++.
That's means that I eventually can create a c++ wrapper, but I would like to listen to your advice because I don't knowif there is a fundamental issue that I'm ignoring. So, only one question is still open?
1. Is it possible to create a C++ wrapper around emacs_modules and what are the implications?


Thanks,
Levis

 

    On Monday, September 26, 2016 8:07 PM, Mambo Levis <mambo.levis@gmail.com> wrote:
 

 Hi,
I tested (in Windows) the example from Aurélien Aptel (http://diobla.info/blog-archive/modules-tut.html) with gcc at it runs as expected.
Now, I would like to create a C++ wrapper, but I not quite sure if it is possible. Questions:
1. Is it possible to create a C++ wrapper around emacs_modules?2. I am trying to build the same example using g++ and the following error appears:
---------------------------------------------------------------------------------------------------------------$ make SO=dllg++ -ggdb3 -ID:\user\emacs-src\emacs-25-branch-src/src -c mymod.cmymod.c: In function 'int emacs_module_init(emacs_runtime*)':mymod.c:55:45: error: invalid conversion from 'emacs_value_tag* (*)(emacs_env*, int, emacs_value_tag**, void*) {aka emacs_value_tag* (*)(emacs_env_25*, int, emacs_value_tag**, void*)}' to 'emacs_value_tag* (*)(emacs_env*, ptrdiff_t, emacs_value_tag**, void*) {aka emacs_value_tag* (*)(emacs_env_25*, long long int, emacs_value_tag**, void*)}' [-fpermissive]                                         NULL);                                             ^Makefile:42: recipe for target 'mymod.o' failedmake: *** [mymod.o] Error 1
---------------------------------------------------------------------------------------------------------------
It corresponds to the following code (I remarked the part associated with the error)
-------------------------------------------------------------------------------------------------------intemacs_module_init (struct emacs_runtime *ert){  emacs_env *env = ert->get_environment (ert);
  /* create a lambda (returns an emacs_value) */  emacs_value fun = env->make_function (env,                                        0,                                        0,                                        Fmymod_test,                                        "doc",                                        NULL);  bind_function (env, "mymod-test", fun);  provide (env, "mymod");
/* loaded successfully */  return 0;}
-----------------------------------------------------------------------------------------------------------
Do you have any Idea or recommendation? 
Thanks,
Levis




   


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Emacs modules 25.1
  2016-09-27 12:23   ` Mambo Levis
@ 2016-09-27 14:55     ` Eli Zaretskii
  2016-09-27 15:36     ` Philipp Stephani
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2016-09-27 14:55 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 27 Sep 2016 12:23:08 +0000 (UTC)
> From: Mambo Levis <mambo.levis@gmail.com>
> 
> 1. Is it possible to create a C++ wrapper around emacs_modules and what are the implications?

I don't think I understand what you are asking, since C++ is a
superset of C.

Or maybe I don't understand what is a "C++ wrapper around
emacs_modules", in this context.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Emacs modules 25.1
  2016-09-27 12:23   ` Mambo Levis
  2016-09-27 14:55     ` Eli Zaretskii
@ 2016-09-27 15:36     ` Philipp Stephani
  1 sibling, 0 replies; 4+ messages in thread
From: Philipp Stephani @ 2016-09-27 15:36 UTC (permalink / raw)
  To: Mambo Levis, help-gnu-emacs@gnu.org, johnw@newartisans.com,
	bozhidar@batsov.com

Mambo Levis <mambo.levis@gmail.com> schrieb am Di., 27. Sep. 2016 um
14:26 Uhr:

> Hi,
> I found the problem and now I can build the emacs_module example using g++.
> That's means that I eventually can create a c++ wrapper, but I would like
> to listen to your advice because I don't knowif there is a fundamental
> issue that I'm ignoring. So, only one question is still open?
> 1. Is it possible to create a C++ wrapper around emacs_modules and what
> are the implications?
>

Yes, it's possible. The main implication is that you need to translate
between C++ exceptions and Lisp signals. In particular, any function called
from Emacs (emacs_module_init, functions registered via make_function) need
to surround their body with

try {
   // ...
} catch (...) {
   // ...
}

The module API makes an attempt to prevent leaking exceptions out of C++
code by forcing module functions to be declared noexcept, however this
causes any uncaught exception to crash Emacs, so you'll probably want to
catch and handle them.
Not required, but probably useful, is to also perform the translation in
the opposite direction: When a non-local Lisp exit happens, throw a C++
exception.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-27 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <709716874.935191.1474913256978.ref@mail.yahoo.com>
2016-09-26 18:07 ` Emacs modules 25.1 Mambo Levis
2016-09-27 12:23   ` Mambo Levis
2016-09-27 14:55     ` Eli Zaretskii
2016-09-27 15:36     ` Philipp Stephani

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.