Mercurial > hg > xemacs-beta
comparison src/dll.c @ 276:6330739388db r21-0b36
Import from CVS: tag r21-0b36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:30:37 +0200 |
parents | c5d627a313b1 |
children | 8626e4521993 |
comparison
equal
deleted
inserted
replaced
275:a68ae4439f57 | 276:6330739388db |
---|---|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 Boston, MA 02111-1307, USA. */ | 20 Boston, MA 02111-1307, USA. */ |
21 | 21 |
22 /* Synched up with: Not in FSF. */ | 22 /* Synched up with: Not in FSF. */ |
23 | 23 |
24 /* A shared object may have the following symbols defined: | 24 /* A shared object must have the symbol `emacs_initialize' defined. |
25 syms_of | 25 It should contain initialization of functions, symbols, etc. and |
26 vars_of | 26 their loading into Lisp-land. The function will be called without |
27 complex_vars_of | 27 arguments and is not expected to return any. |
28 They are called in that order. Each takes and returns void | |
29 arguments. | |
30 | 28 |
31 All of this needs lots and LOTS of work. Some things to work on: | 29 All of this needs lots and LOTS of work. Some things to work on: |
32 | 30 |
33 1) A good foreign interface. We probably need to get rid of | 31 1) A good foreign interface. This is probably tough, because it |
34 syms_of and similar junk, and define a more normal interfacing to | 32 implies drawing a new border between "external" and "internal" |
35 the outside world, e.g. an init_emacs_module() function. See below | 33 stuff (traditionally, Lisp code was external, while C was |
36 for more discussion about it. Also, we need a modules/ directory | 34 internal). Also, we need a modules/ directory with a few nice |
37 with a few nice sample modules, a sample Makefile, etc. so people | 35 sample modules, a sample Makefile, etc. so people can start |
38 can start hacking. | 36 hacking. |
39 | 37 |
40 2) I'm getting coredumps very often -- practically every time I | 38 2) All of this is sooo simple-minded. As it gets more complex, |
41 compile without USE_MINIMAL_TAGBITS, and even with it sometimes. I | |
42 wasn't able to resolve these. | |
43 | |
44 3) All of this is sooo simple-minded. As it gets more complex, | |
45 we'll have to look at how others have done similar things | 39 we'll have to look at how others have done similar things |
46 (e.g. Perl and Zsh 3.1), to avoid botching it up. */ | 40 (e.g. Perl 5 and Zsh 3.1), to avoid botching it up. */ |
47 | 41 |
48 #include <config.h> | 42 #include <config.h> |
49 #include "lisp.h" | 43 #include "lisp.h" |
50 #include "buffer.h" | 44 #include "buffer.h" |
51 #include "sysdll.h" | 45 #include "sysdll.h" |
52 #include <errno.h> | 46 #include <errno.h> |
53 | 47 |
54 static void | |
55 maybe_call_library_function (dll_handle *handle, CONST char *funcname) | |
56 { | |
57 void (*function)(void) = (void (*)(void)) dll_function (handle, funcname); | |
58 if (function) | |
59 (*function) (); | |
60 } | |
61 | |
62 DEFUN ("dll-open", Fdll_open, 1, 1, "FShared object: ", /* | 48 DEFUN ("dll-open", Fdll_open, 1, 1, "FShared object: ", /* |
63 Load LIBRARY as a shared object file. | 49 Load LIBRARY as a shared object file. |
64 | 50 |
65 After the LIBRARY is dynamically linked with the executable, the | 51 After the LIBRARY is dynamically linked with the executable, the |
66 following functions are called: | 52 `emacs_initialize' function will be called without arguments. It |
67 | 53 should define all the symbols, subr's and variables the module |
68 syms_of(), containing definitions of symbols and subr's; | 54 introduces. |
69 vars_of(), containing definitions of variables; | |
70 complex_vars_of(), containing complex definitions of variables. | |
71 | 55 |
72 After this point, any lisp symbols defined in the shared object are | 56 After this point, any lisp symbols defined in the shared object are |
73 available for use. | 57 available for use. |
74 */ | 58 */ |
75 (library)) | 59 (library)) |
76 { | 60 { |
77 /* This function can GC */ | 61 /* This function can GC */ |
78 dll_handle *handle; | 62 dll_handle *handle; |
63 void (*function) (void); | |
79 CONST char *filename; | 64 CONST char *filename; |
80 | 65 |
81 CHECK_STRING (library); | 66 CHECK_STRING (library); |
82 library = Fexpand_file_name (library, Qnil); | 67 library = Fexpand_file_name (library, Qnil); |
83 | 68 |
89 signal_error (Qerror, | 74 signal_error (Qerror, |
90 list3 (build_translated_string ("Cannot load shared library"), | 75 list3 (build_translated_string ("Cannot load shared library"), |
91 library, build_translated_string (dll_error (handle)))); | 76 library, build_translated_string (dll_error (handle)))); |
92 } | 77 } |
93 | 78 |
94 /* #### This looks unnecessary here, because at this time one | 79 /* #### Perhaps emacs_initialize() should return a Lisp_Object, so |
95 initialization function is fully sufficient. However, I am not | 80 we can return it? */ |
96 removing this support, since we may wish to add mechanisms for | |
97 static linking, which would have invoke these function via normal | |
98 paths. | |
99 | 81 |
100 #### But then this is not sufficient, because one could as well | 82 function = (void (*)(void)) dll_function (handle, "emacs_initialize"); |
101 honor specifier_vars_of_foo(), etc. Maybe we should scrap it | 83 if (!function) |
102 after all. | 84 signal_simple_error ("Shared library does not define `emacs_initialize'", |
103 | 85 library); |
104 #### What if one of the first two functions signal an error? | 86 (*function) (); |
105 Should we take care to execute the other two? My fingers are | |
106 getting itchy! */ | |
107 | |
108 maybe_call_library_function (handle, "syms_of"); | |
109 maybe_call_library_function (handle, "vars_of"); | |
110 maybe_call_library_function (handle, "complex_vars_of"); | |
111 | 87 |
112 return Qnil; | 88 return Qnil; |
113 } | 89 } |
114 | 90 |
115 void syms_of_dll () | 91 void syms_of_dll () |