[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/aptel/dynamic-modules-rc3 8254721 16/25: make `loa
From: |
Teodor Zlatanov |
Subject: |
[Emacs-diffs] feature/aptel/dynamic-modules-rc3 8254721 16/25: make `load' look for and handle dynamic modules. |
Date: |
Wed, 04 Feb 2015 22:56:16 +0000 |
branch: feature/aptel/dynamic-modules-rc3
commit 8254721c162ba6d060cd7dedea075dc54668db27
Author: Aurélien Aptel <address@hidden>
Commit: Aurélien Aptel <address@hidden>
make `load' look for and handle dynamic modules.
When libltdl is available a new ".so" suffix is added to the
`load-suffixes' variable. The `load' function uses it and passes it to
openp() which does the actual search in `load-path'.
If the file found by openp() ends with ".so", then it is module and it
should be handled accordingly by calling `load-module'.
`require' calls `load' so nothing more is needed to make `require'
work. Modules should now be able to call `provide' at the end of
their init() function. `provide' runs eval-after-load code with no
additional work.
* Notes and potential problems
I have not payed too much attention to encoding problems: I only use
SDATA(filename). Does it need an ENCODE() call?
`load' is quite messy: big function, lots of side effets and spaghetti
code. I may have overlooked some things.
fix #3
fix #4
---
src/lread.c | 38 ++++++++++++++++++++++++++++++++++----
1 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/src/lread.c b/src/lread.c
index 2664766..ec3d58a 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1110,6 +1110,8 @@ Return t if the file exists and loads successfully. */)
bool newer = 0;
/* True means we are loading a compiled file. */
bool compiled = 0;
+ /* True means we are loading a dynamic module. */
+ bool module = 0;
Lisp_Object handler;
bool safe_p = 1;
const char *fmode = "r";
@@ -1163,6 +1165,9 @@ Return t if the file exists and loads successfully. */)
/* Don't insist on adding a suffix if FILE already ends with one. */
ptrdiff_t size = SBYTES (file);
if (size > 3
+ && !strcmp (SSDATA (file) + size - 3, ".so"))
+ must_suffix = Qnil;
+ if (size > 3
&& !strcmp (SSDATA (file) + size - 3, ".el"))
must_suffix = Qnil;
else if (size > 4
@@ -1344,6 +1349,12 @@ Return t if the file exists and loads successfully. */)
UNGCPRO;
}
}
+#ifdef HAVE_LTDL
+ else if (!memcmp (SDATA (found) + SBYTES (found) - 3, ".so", 3))
+ {
+ module = 1;
+ }
+#endif
else
{
/* We are loading a source file (*.el). */
@@ -1393,7 +1404,9 @@ Return t if the file exists and loads successfully. */)
if (NILP (nomessage) || force_load_messages)
{
- if (!safe_p)
+ if (module)
+ message_with_string ("Loading %s (dymamic module)...", file, 1);
+ else if (!safe_p)
message_with_string ("Loading %s (compiled; note unsafe, not compiled
in Emacs)...",
file, 1);
else if (!compiled)
@@ -1413,7 +1426,14 @@ Return t if the file exists and loads successfully. */)
if (lisp_file_lexically_bound_p (Qget_file_char))
Fset (Qlexical_binding, Qt);
- if (! version || version >= 22)
+#ifdef HAVE_LTDL
+ if (module)
+ {
+ /* XXX: should the fd/stream be closed before loading the module? */
+ Fload_module (found);
+ }
+#endif
+ else if (! version || version >= 22)
readevalloop (Qget_file_char, stream, hist_file_name,
0, Qnil, Qnil, Qnil, Qnil);
else
@@ -1442,7 +1462,9 @@ Return t if the file exists and loads successfully. */)
if (!noninteractive && (NILP (nomessage) || force_load_messages))
{
- if (!safe_p)
+ if (module)
+ message_with_string ("Loading %s (dymamic module)...done", file, 1);
+ else if (!safe_p)
message_with_string ("Loading %s (compiled; note unsafe, not compiled
in Emacs)...done",
file, 1);
else if (!compiled)
@@ -4605,8 +4627,16 @@ Initialized during startup as described in Info node
`(elisp)Library Search'. *
This list should not include the empty string.
`load' and related functions try to append these suffixes, in order,
to the specified file name if a Lisp suffix is allowed or required. */);
+
+#ifdef HAVE_LTDL
+ Vload_suffixes = list3 (build_pure_c_string (".so"),
+ build_pure_c_string (".elc"),
+ build_pure_c_string (".el"));
+#else
Vload_suffixes = list2 (build_pure_c_string (".elc"),
- build_pure_c_string (".el"));
+ build_pure_c_string (".el"));
+#endif
+
DEFVAR_LISP ("load-file-rep-suffixes", Vload_file_rep_suffixes,
doc: /* List of suffixes that indicate representations of \
the same file.
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 1b98be3 09/25: move fmod module in modules/fmod/., (continued)
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 1b98be3 09/25: move fmod module in modules/fmod/., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 772cb16 01/25: add libltdl configure option/dependency., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 bfe16af 10/25: new module: opaque, Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 89c8287 11/25: opaque: add comments., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 9330ca6 12/25: new module: elisp, Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 9da7346 13/25: new module: curl. basic URL fetcher working., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 582704c 14/25: curl: use url arg., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 8147699 15/25: fix docstring., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 a95e032 17/25: update modules examples with `provide' call., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 1959b65 18/25: use `load-module-suffixes' as a source of module suffixes., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 8254721 16/25: make `load' look for and handle dynamic modules.,
Teodor Zlatanov <=
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 4000103 20/25: yaml module: add `yaml-parse-string'., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 c7248ea 21/25: yaml module: rename `yaml-parse' to `yaml-parse-buffer'., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 092a6d2 22/25: configure.ac: dynamic modules off by default., Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 4e1ad37 19/25: new yaml parsing module using libyaml, Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 1da9b91 24/25: opaque module: rename Qc variable to Qc_ due to macro collision, Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 9a1d734 25/25: modules/: add proper testing, Teodor Zlatanov, 2015/02/04
- [Emacs-diffs] feature/aptel/dynamic-modules-rc3 41ec64b 23/25: Merge branch 'master' into dynamic-modules, Teodor Zlatanov, 2015/02/04