diff options
| author | Eli Zaretskii | 2015-12-05 13:51:09 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-12-05 13:51:09 +0200 |
| commit | 52781882859ded459b97bcc83c8548d8cb67a30f (patch) | |
| tree | d02f7cbf909d9cfcea94a8a423a1eede75d588db | |
| parent | 8ebd0a08f3392e687c12a4491462c1d8caf16e76 (diff) | |
| download | emacs-52781882859ded459b97bcc83c8548d8cb67a30f.tar.gz emacs-52781882859ded459b97bcc83c8548d8cb67a30f.zip | |
Initial documentation of dynamic modules
* doc/lispref/loading.texi (Dynamic Modules): New section with
initial documentation for dynamic modules.
* doc/lispref/elisp.texi (Top): Add "Dynamic Modules" to the
detailed menu
* etc/NEWS: Fix typos in dynamic modules' entry.
| -rw-r--r-- | doc/lispref/elisp.texi | 1 | ||||
| -rw-r--r-- | doc/lispref/loading.texi | 61 | ||||
| -rw-r--r-- | etc/NEWS | 2 |
3 files changed, 62 insertions, 2 deletions
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index 2d3548f65ba..dedb0a5e40e 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi | |||
| @@ -602,6 +602,7 @@ Loading | |||
| 602 | * Unloading:: How to unload a library that was loaded. | 602 | * Unloading:: How to unload a library that was loaded. |
| 603 | * Hooks for Loading:: Providing code to be run when | 603 | * Hooks for Loading:: Providing code to be run when |
| 604 | particular libraries are loaded. | 604 | particular libraries are loaded. |
| 605 | * Dynamic Modules:: Modules provide additional Lisp primitives. | ||
| 605 | 606 | ||
| 606 | Byte Compilation | 607 | Byte Compilation |
| 607 | 608 | ||
diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 82de765876e..e01f3161731 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi | |||
| @@ -29,7 +29,15 @@ into a buffer and evaluated there. (Indeed, most code is tested this | |||
| 29 | way.) Most often, the forms are function definitions and variable | 29 | way.) Most often, the forms are function definitions and variable |
| 30 | definitions. | 30 | definitions. |
| 31 | 31 | ||
| 32 | For on-demand loading of external libraries, @pxref{Dynamic Libraries}. | 32 | Emacs can also load compiled dynamic modules: shared libraries that |
| 33 | provide additional functionality for use in Emacs Lisp programs, just | ||
| 34 | like a package written in Emacs Lisp would. When a dynamic module is | ||
| 35 | loaded, Emacs calls a specially-named initialization function which | ||
| 36 | the module needs to implement, and which exposes the additional | ||
| 37 | functions and variables to Emacs Lisp programs. | ||
| 38 | |||
| 39 | For on-demand loading of external libraries which are known in advance | ||
| 40 | to be required by certain Emacs primitives, @pxref{Dynamic Libraries}. | ||
| 33 | 41 | ||
| 34 | @menu | 42 | @menu |
| 35 | * How Programs Do Loading:: The @code{load} function and others. | 43 | * How Programs Do Loading:: The @code{load} function and others. |
| @@ -43,6 +51,7 @@ For on-demand loading of external libraries, @pxref{Dynamic Libraries}. | |||
| 43 | * Unloading:: How to unload a library that was loaded. | 51 | * Unloading:: How to unload a library that was loaded. |
| 44 | * Hooks for Loading:: Providing code to be run when | 52 | * Hooks for Loading:: Providing code to be run when |
| 45 | particular libraries are loaded. | 53 | particular libraries are loaded. |
| 54 | * Dynamic Modules:: Modules provide additional Lisp primitives. | ||
| 46 | @end menu | 55 | @end menu |
| 47 | 56 | ||
| 48 | @node How Programs Do Loading | 57 | @node How Programs Do Loading |
| @@ -1076,3 +1085,53 @@ defined in another library (those meant for outside use), you can do | |||
| 1076 | it immediately---there is no need to wait until the library is loaded. | 1085 | it immediately---there is no need to wait until the library is loaded. |
| 1077 | If you need to call functions defined by that library, you should load | 1086 | If you need to call functions defined by that library, you should load |
| 1078 | the library, preferably with @code{require} (@pxref{Named Features}). | 1087 | the library, preferably with @code{require} (@pxref{Named Features}). |
| 1088 | |||
| 1089 | @node Dynamic Modules | ||
| 1090 | @section Emacs Dynamic Modules | ||
| 1091 | @cindex dynamic modules | ||
| 1092 | |||
| 1093 | @c FIXME: This is intentionally incomplete, as the module integration | ||
| 1094 | @c is not yet finished. To be refined later. | ||
| 1095 | A @dfn{dynamic Emacs module} is a shared library that provides | ||
| 1096 | additional functionality for use in Emacs Lisp programs, just like a | ||
| 1097 | package written in Emacs Lisp would. | ||
| 1098 | |||
| 1099 | Functions that load Emacs Lisp packages can also load dynamic | ||
| 1100 | modules. They recognize dynamic modules by looking at their file-name | ||
| 1101 | extension, a.k.a.@: ``suffix''. This suffix is platform-dependent. | ||
| 1102 | |||
| 1103 | @defvar module-file-suffix | ||
| 1104 | This variable holds the system-dependent value of the file-name | ||
| 1105 | extension of the module files. Its value is @file{.so} on Posix hosts | ||
| 1106 | and @file{.dll} on MS-Windows. | ||
| 1107 | @end defvar | ||
| 1108 | |||
| 1109 | @findex emacs_module_init | ||
| 1110 | @vindex plugin_is_GPL_compatible | ||
| 1111 | Every dynamic module should export a C-callable function named | ||
| 1112 | @code{emacs_module_init}, which Emacs will call as part of the call to | ||
| 1113 | @code{load} or @code{require} which loads the module. It should also | ||
| 1114 | export a symbol named @code{plugin_is_GPL_compatible} to indicate that | ||
| 1115 | its code is released under the GPL or compatible license; Emacs will | ||
| 1116 | refuse to load modules that don't export such a symbol. | ||
| 1117 | |||
| 1118 | If a module needs to call Emacs functions, it should do so through the | ||
| 1119 | API defined and documented in the header file @file{emacs-module.h} | ||
| 1120 | that is part of the Emacs distribution. | ||
| 1121 | |||
| 1122 | @cindex user-ptr object | ||
| 1123 | Modules can create @code{user-ptr} Lisp objects that embed pointers to | ||
| 1124 | C struct's defined by the module. This is useful for keeping around | ||
| 1125 | complex data structures created by a module, to be passed back to the | ||
| 1126 | module's functions. User-ptr objects can also have associated | ||
| 1127 | @dfn{finalizers} -- functions to be run when the object is GC'ed; this | ||
| 1128 | is useful for freeing any resources allocated for the underlying data | ||
| 1129 | structure, such as memory, open file descriptors, etc. | ||
| 1130 | |||
| 1131 | @defun user-ptrp object | ||
| 1132 | This function returns @code{t} if its argument is a @code{user-ptr} | ||
| 1133 | object. | ||
| 1134 | @end defun | ||
| 1135 | |||
| 1136 | Loadable modules in Emacs are enabled by using the | ||
| 1137 | @kbd{--with-modules} option at configure time. | ||
| @@ -210,7 +210,7 @@ module's functions. User-ptr objects can also have associated | |||
| 210 | "finalizers" -- functions to be run when the object is GC'ed; this is | 210 | "finalizers" -- functions to be run when the object is GC'ed; this is |
| 211 | useful for freeing any resources allocated for the underlying data | 211 | useful for freeing any resources allocated for the underlying data |
| 212 | structure, such as memory, open file descriptors, etc. A new | 212 | structure, such as memory, open file descriptors, etc. A new |
| 213 | predicate `user-ptr-p' returns non-nil if its argument is a `usr-ptr' | 213 | predicate `user-ptrp' returns non-nil if its argument is a `user-ptr' |
| 214 | object. | 214 | object. |
| 215 | 215 | ||
| 216 | Loadable modules in Emacs are an experimental feature, and subject to | 216 | Loadable modules in Emacs are an experimental feature, and subject to |