Mercurial > hg > xemacs-beta
comparison man/internals/internals.texi @ 380:8626e4521993 r21-2-5
Import from CVS: tag r21-2-5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:07:10 +0200 |
parents | d883f39b8495 |
children | aabb7f5b1c81 |
comparison
equal
deleted
inserted
replaced
379:76b7d63099ad | 380:8626e4521993 |
---|---|
6 | 6 |
7 @ifinfo | 7 @ifinfo |
8 | 8 |
9 Copyright @copyright{} 1992 - 1996 Ben Wing. | 9 Copyright @copyright{} 1992 - 1996 Ben Wing. |
10 Copyright @copyright{} 1996, 1997 Sun Microsystems. | 10 Copyright @copyright{} 1996, 1997 Sun Microsystems. |
11 Copyright @copyright{} 1994, 1995 Free Software Foundation. | 11 Copyright @copyright{} 1994 - 1998 Free Software Foundation. |
12 Copyright @copyright{} 1994, 1995 Board of Trustees, University of Illinois. | 12 Copyright @copyright{} 1994, 1995 Board of Trustees, University of Illinois. |
13 | 13 |
14 | 14 |
15 Permission is granted to make and distribute verbatim copies of this | 15 Permission is granted to make and distribute verbatim copies of this |
16 manual provided the copyright notice and this permission notice are | 16 manual provided the copyright notice and this permission notice are |
57 @setchapternewpage odd | 57 @setchapternewpage odd |
58 @finalout | 58 @finalout |
59 | 59 |
60 @titlepage | 60 @titlepage |
61 @title XEmacs Internals Manual | 61 @title XEmacs Internals Manual |
62 @subtitle Version 1.1, March 1997 | 62 @subtitle Version 1.2, October 1998 |
63 | 63 |
64 @author Ben Wing | 64 @author Ben Wing |
65 @author Martin Buchholz | 65 @author Martin Buchholz |
66 @author Hrvoje Niksic | |
66 @page | 67 @page |
67 @vskip 0pt plus 1fill | 68 @vskip 0pt plus 1fill |
68 | 69 |
69 @noindent | 70 @noindent |
70 Copyright @copyright{} 1992 - 1996 Ben Wing. @* | 71 Copyright @copyright{} 1992 - 1996 Ben Wing. @* |
71 Copyright @copyright{} 1996 Sun Microsystems, Inc. @* | 72 Copyright @copyright{} 1996, 1997 Sun Microsystems, Inc. @* |
72 Copyright @copyright{} 1994 Free Software Foundation. @* | 73 Copyright @copyright{} 1994 - 1998 Free Software Foundation. @* |
73 Copyright @copyright{} 1994, 1995 Board of Trustees, University of Illinois. | 74 Copyright @copyright{} 1994, 1995 Board of Trustees, University of Illinois. |
74 | 75 |
75 @sp 2 | 76 @sp 2 |
76 Version 1.1 @* | 77 Version 1.2 @* |
77 March, 1997.@* | 78 October 1998.@* |
78 | 79 |
79 Permission is granted to make and distribute verbatim copies of this | 80 Permission is granted to make and distribute verbatim copies of this |
80 manual provided the copyright notice and this permission notice are | 81 manual provided the copyright notice and this permission notice are |
81 preserved on all copies. | 82 preserved on all copies. |
82 | 83 |
178 * Vector:: | 179 * Vector:: |
179 * Bit Vector:: | 180 * Bit Vector:: |
180 * Symbol:: | 181 * Symbol:: |
181 * Marker:: | 182 * Marker:: |
182 * String:: | 183 * String:: |
183 * Bytecode:: | 184 * Compiled Function:: |
184 | 185 |
185 Events and the Event Loop | 186 Events and the Event Loop |
186 | 187 |
187 * Introduction to Events:: | 188 * Introduction to Events:: |
188 * Main Loop:: | 189 * Main Loop:: |
906 marked with their type, as in dynamic typing; but there is a hierarchy | 907 marked with their type, as in dynamic typing; but there is a hierarchy |
907 of types and functions are declared to accept only certain types, thus | 908 of types and functions are declared to accept only certain types, thus |
908 providing the increased compile-time error-checking of static typing. | 909 providing the increased compile-time error-checking of static typing. |
909 @end enumerate | 910 @end enumerate |
910 | 911 |
912 The Java language also has some negative attributes: | |
913 | |
914 @enumerate | |
915 @item | |
916 Java uses the edit/compile/run model of software development. This | |
917 makes it hard to use interactively. For example, to use Java like | |
918 @code{bc} it is necessary to write a special purpose, albeit tiny, | |
919 application. In Emacs Lisp, a calculator comes built-in without any | |
920 effort - one can always just type an expression in the @code{*scratch*} | |
921 buffer. | |
922 @item | |
923 Java tries too hard to enforce, not merely enable, portability, making | |
924 ordinary access to standard OS facilities painful. Java has an | |
925 @dfn{agenda}. I think this is why @code{chdir} is not part of standard | |
926 Java, which is inexcusable. | |
927 @end enumerate | |
928 | |
929 Unfortunately, there is no perfect language. Static typing allows a | |
930 compiler to catch programmer errors and produce more efficient code, but | |
931 makes programming more tedious and less fun. For the forseeable future, | |
932 an Ideal Editing and Programming Environment (and that is what XEmacs | |
933 aspires to) will be programmable in multiple languages: high level ones | |
934 like Lisp for user customization and prototyping, and lower level ones | |
935 for infrastructure and industrial strength applications. If I had my | |
936 way, XEmacs would be friendly towards the Python, Scheme, C++, ML, | |
937 etc... communities. But there are serious technical difficulties to | |
938 achieving that goal. | |
939 | |
940 The word @dfn{application} in the previous paragraph was used | |
941 intentionally. XEmacs implements an API for programs written in Lisp | |
942 that makes it a full-fledged application platform, very much like an OS | |
943 inside the real OS. | |
944 | |
911 @node XEmacs From the Perspective of Building, XEmacs From the Inside, The Lisp Language, Top | 945 @node XEmacs From the Perspective of Building, XEmacs From the Inside, The Lisp Language, Top |
912 @chapter XEmacs From the Perspective of Building | 946 @chapter XEmacs From the Perspective of Building |
913 | 947 |
914 The heart of XEmacs is the Lisp environment, which is written in C. | 948 The heart of XEmacs is the Lisp environment, which is written in C. |
915 This is contained in the @file{src/} subdirectory. Underneath | 949 This is contained in the @file{src/} subdirectory. Underneath |
916 @file{src/} are two subdirectories of header files: @file{s/} (header | 950 @file{src/} are two subdirectories of header files: @file{s/} (header |
917 files for particular operating systems) and @file{m/} (header files for | 951 files for particular operating systems) and @file{m/} (header files for |
918 particular machine types). In practice the distinction between the two | 952 particular machine types). In practice the distinction between the two |
919 types of header files is blurred. These header files define or undefine | 953 types of header files is blurred. These header files define or undefine |
921 characteristics of the associated machine or operating system. As part | 955 characteristics of the associated machine or operating system. As part |
922 of the configure process, one @file{s/} file and one @file{m/} file is | 956 of the configure process, one @file{s/} file and one @file{m/} file is |
923 identified for the particular environment in which XEmacs is being | 957 identified for the particular environment in which XEmacs is being |
924 built. | 958 built. |
925 | 959 |
926 XEmacs also contains a great deal of Lisp code. This implements the | 960 XEmacs also contains a great deal of Lisp code. This implements the |
927 operations that make XEmacs useful as an editor as well as just a | 961 operations that make XEmacs useful as an editor as well as just a Lisp |
928 Lisp environment, and also contains many add-on packages that allow | 962 environment, and also contains many add-on packages that allow XEmacs to |
929 XEmacs to browse directories, act as a mail and Usenet news reader, | 963 browse directories, act as a mail and Usenet news reader, compile Lisp |
930 compile Lisp code, etc. There is actually more Lisp code than | 964 code, etc. There is actually more Lisp code than C code associated with |
931 C code associated with XEmacs, but much of the Lisp code is | 965 XEmacs, but much of the Lisp code is peripheral to the actual operation |
932 peripheral to the actual operation of the editor. The Lisp code | 966 of the editor. The Lisp code all lies in subdirectories underneath the |
933 all lies in subdirectories underneath the @file{lisp/} directory. | 967 @file{lisp/} directory. |
934 | 968 |
935 The @file{lwlib/} directory contains C code that implements a | 969 The @file{lwlib/} directory contains C code that implements a |
936 generalized interface onto different X widget toolkits and also | 970 generalized interface onto different X widget toolkits and also |
937 implements some widgets of its own that behave like Motif widgets but | 971 implements some widgets of its own that behave like Motif widgets but |
938 are faster, free, and in some cases more powerful. The code in this | 972 are faster, free, and in some cases more powerful. The code in this |
939 directory compiles into a library and is mostly independent from XEmacs. | 973 directory compiles into a library and is mostly independent from XEmacs. |
940 | 974 |
941 The @file{etc/} directory contains various data files associated with | 975 The @file{etc/} directory contains various data files associated with |
942 XEmacs. Some of them are actually read by XEmacs at startup; others | 976 XEmacs. Some of them are actually read by XEmacs at startup; others |
943 merely contain useful information of various sorts. | 977 merely contain useful information of various sorts. |
944 | 978 |
945 The @file{lib-src/} directory contains C code for various auxiliary | 979 The @file{lib-src/} directory contains C code for various auxiliary |
946 programs that are used in connection with XEmacs. Some of them are used | 980 programs that are used in connection with XEmacs. Some of them are used |
947 during the build process; others are used to perform certain functions | 981 during the build process; others are used to perform certain functions |
948 that cannot conveniently be placed in the XEmacs executable (e.g. the | 982 that cannot conveniently be placed in the XEmacs executable (e.g. the |
949 @file{movemail} program for fetching mail out of @file{/var/spool/mail}, | 983 @file{movemail} program for fetching mail out of @file{/var/spool/mail}, |
950 which must be setgid to @file{mail} on many systems; and the | 984 which must be setgid to @file{mail} on many systems; and the |
951 @file{gnuclient} program, which allows an external script to communicate | 985 @file{gnuclient} program, which allows an external script to communicate |
952 with a running XEmacs process). | 986 with a running XEmacs process). |
953 | 987 |
954 The @file{man/} directory contains the sources for the XEmacs | 988 The @file{man/} directory contains the sources for the XEmacs |
955 documentation. It is mostly in a form called Texinfo, which can be | 989 documentation. It is mostly in a form called Texinfo, which can be |
956 converted into either a printed document (by passing it through @TeX{}) | 990 converted into either a printed document (by passing it through @TeX{}) |
957 or into on-line documentation called @dfn{info files}. | 991 or into on-line documentation called @dfn{info files}. |
958 | 992 |
959 The @file{info/} directory contains the results of formatting the | 993 The @file{info/} directory contains the results of formatting the XEmacs |
960 XEmacs documentation as @dfn{info files}, for on-line use. These files | 994 documentation as @dfn{info files}, for on-line use. These files are |
961 are used when you enter the Info system using @kbd{C-h i} or through the | 995 used when you enter the Info system using @kbd{C-h i} or through the |
962 Help menu. | 996 Help menu. |
963 | 997 |
964 The @file{dynodump/} directory contains auxiliary code used to build | 998 The @file{dynodump/} directory contains auxiliary code used to build |
965 XEmacs on Solaris platforms. | 999 XEmacs on Solaris platforms. |
966 | 1000 |
967 The other directories contain various miscellaneous code and | 1001 The other directories contain various miscellaneous code and information |
968 information that is not normally used or needed. | 1002 that is not normally used or needed. |
969 | 1003 |
970 The first step of building involves running the @file{configure} | 1004 The first step of building involves running the @file{configure} program |
971 program and passing it various parameters to specify any optional | 1005 and passing it various parameters to specify any optional features you |
972 features you want and compiler arguments and such, as described in the | 1006 want and compiler arguments and such, as described in the @file{INSTALL} |
973 @file{INSTALL} file. This determines what the build environment is, | 1007 file. This determines what the build environment is, chooses the |
974 chooses the appropriate @file{s/} and @file{m/} file, and runs a series | 1008 appropriate @file{s/} and @file{m/} file, and runs a series of tests to |
975 of tests to determine many details about your environment, such as which | 1009 determine many details about your environment, such as which library |
976 library functions are available and exactly how they work. (The | 1010 functions are available and exactly how they work. The reason for |
977 @file{s/} and @file{m/} files only contain information that cannot be | 1011 running these tests is that it allows XEmacs to be compiled on a much |
978 conveniently detected in this fashion.) The reason for running these | 1012 wider variety of platforms than those that the XEmacs developers happen |
979 tests is that it allows XEmacs to be compiled on a much wider variety of | 1013 to be familiar with, including various sorts of hybrid platforms. This |
980 platforms than those that the XEmacs developers happen to be familiar | 1014 is especially important now that many operating systems give you a great |
981 with, including various sorts of hybrid platforms. This is especially | 1015 deal of control over exactly what features you want installed, and allow |
982 important now that many operating systems give you a great deal of | 1016 for easy upgrading of parts of a system without upgrading the rest. It |
983 control over exactly what features you want installed, and allow for | |
984 easy upgrading of parts of a system without upgrading the rest. It | |
985 would be impossible to pre-determine and pre-specify the information for | 1017 would be impossible to pre-determine and pre-specify the information for |
986 all possible configurations. | 1018 all possible configurations. |
987 | 1019 |
988 When configure is done running, it generates @file{Makefile}s and the | 1020 In fact, the @file{s/} and @file{m/} files are basically @emph{evil}, |
989 file @file{src/config.h} (which describes the features of your system) | 1021 since they contain unmaintainable platform-specific hard-coded |
990 from template files. You then run @file{make}, which compiles the | 1022 information. XEmacs has been moving in the direction of having all |
991 auxiliary code and programs in @file{lib-src/} and @file{lwlib/} and the | 1023 system-specific information be determined dynamically by |
992 main XEmacs executable in @file{src/}. The result of compiling and | 1024 @file{configure}. Perhaps someday we can @code{rm -rf src/s src/m}. |
993 linking is an executable called @file{temacs}, which is @emph{not} the | 1025 |
994 final XEmacs executable. @file{temacs} by itself is not intended to | 1026 When configure is done running, it generates @file{Makefile}s and |
995 function as an editor or even display any windows on the screen, and if | 1027 @file{GNUmakefile}s and the file @file{src/config.h} (which describes |
996 you simply run it, it will exit immediately. The @file{Makefile} runs | 1028 the features of your system) from template files. You then run |
997 @file{temacs} with certain options that cause it to initialize itself, | 1029 @file{make}, which compiles the auxiliary code and programs in |
998 read in a number of basic Lisp files, and then dump itself out into a | 1030 @file{lib-src/} and @file{lwlib/} and the main XEmacs executable in |
999 new executable called @file{xemacs}. This new executable has been | 1031 @file{src/}. The result of compiling and linking is an executable |
1000 pre-initialized and contains pre-digested Lisp code that is necessary | 1032 called @file{temacs}, which is @emph{not} the final XEmacs executable. |
1001 for the editor to function (this includes most basic Lisp functions, | 1033 @file{temacs} by itself is not intended to function as an editor or even |
1002 e.g. @code{not}, that can be defined in terms of other Lisp primitives; | 1034 display any windows on the screen, and if you simply run it, it will |
1003 some initialization code that is called when certain objects, such as | 1035 exit immediately. The @file{Makefile} runs @file{temacs} with certain |
1004 frames, are created; and all of the standard keybindings and code for | 1036 options that cause it to initialize itself, read in a number of basic |
1005 the actions they result in). This executable, @file{xemacs}, is the | 1037 Lisp files, and then dump itself out into a new executable called |
1006 executable that you run to use the XEmacs editor. | 1038 @file{xemacs}. This new executable has been pre-initialized and |
1039 contains pre-digested Lisp code that is necessary for the editor to | |
1040 function (this includes most basic editing functions, | |
1041 e.g. @code{kill-line}, that can be defined in terms of other Lisp | |
1042 primitives; some initialization code that is called when certain | |
1043 objects, such as frames, are created; and all of the standard | |
1044 keybindings and code for the actions they result in). This executable, | |
1045 @file{xemacs}, is the executable that you run to use the XEmacs editor. | |
1007 | 1046 |
1008 Although @file{temacs} is not intended to be run as an editor, it can, | 1047 Although @file{temacs} is not intended to be run as an editor, it can, |
1009 by using the incantation @code{temacs -batch -l loadup.el run-temacs}. | 1048 by using the incantation @code{temacs -batch -l loadup.el run-temacs}. |
1010 This is useful when the dumping procedure described above is broken, or | 1049 This is useful when the dumping procedure described above is broken, or |
1011 when using certain program debugging tools such as Purify. These tools | 1050 when using certain program debugging tools such as Purify. These tools |
1013 such as allocation memory in one process, and freeing it in the next. | 1052 such as allocation memory in one process, and freeing it in the next. |
1014 | 1053 |
1015 @node XEmacs From the Inside, The XEmacs Object System (Abstractly Speaking), XEmacs From the Perspective of Building, Top | 1054 @node XEmacs From the Inside, The XEmacs Object System (Abstractly Speaking), XEmacs From the Perspective of Building, Top |
1016 @chapter XEmacs From the Inside | 1055 @chapter XEmacs From the Inside |
1017 | 1056 |
1018 Internally, XEmacs is quite complex, and can be very confusing. To | 1057 Internally, XEmacs is quite complex, and can be very confusing. To |
1019 simplify things, it can be useful to think of XEmacs as containing an | 1058 simplify things, it can be useful to think of XEmacs as containing an |
1020 event loop that ``drives'' everything, and a number of other subsystems, | 1059 event loop that ``drives'' everything, and a number of other subsystems, |
1021 such as a Lisp engine and a redisplay mechanism. Each of these other | 1060 such as a Lisp engine and a redisplay mechanism. Each of these other |
1022 subsystems exists simultaneously in XEmacs, and each has a certain | 1061 subsystems exists simultaneously in XEmacs, and each has a certain |
1023 state. The flow of control continually passes in and out of these | 1062 state. The flow of control continually passes in and out of these |
1024 different subsystems in the course of normal operation of the editor. | 1063 different subsystems in the course of normal operation of the editor. |
1025 | 1064 |
1026 It is important to keep in mind that, most of the time, the editor is | 1065 It is important to keep in mind that, most of the time, the editor is |
1027 ``driven'' by the event loop. Except during initialization and batch | 1066 ``driven'' by the event loop. Except during initialization and batch |
1028 mode, all subsystems are entered directly or indirectly through the | 1067 mode, all subsystems are entered directly or indirectly through the |
1029 event loop, and ultimately, control exits out of all subsystems back up | 1068 event loop, and ultimately, control exits out of all subsystems back up |
1030 to the event loop. This cycle of entering a subsystem, exiting back out | 1069 to the event loop. This cycle of entering a subsystem, exiting back out |
1031 to the event loop, and starting another iteration of the event loop | 1070 to the event loop, and starting another iteration of the event loop |
1032 occurs once each keystroke, mouse motion, etc. | 1071 occurs once each keystroke, mouse motion, etc. |
1033 | 1072 |
1034 If you're trying to understand a particular subsystem (other than the | 1073 If you're trying to understand a particular subsystem (other than the |
1035 event loop), think of it as a ``daemon'' process or ``servant'' that is | 1074 event loop), think of it as a ``daemon'' process or ``servant'' that is |
1036 responsible for one particular aspect of a larger system, and | 1075 responsible for one particular aspect of a larger system, and |
1037 periodically receives commands or environment changes that cause it to | 1076 periodically receives commands or environment changes that cause it to |
1038 do something. Ultimately, these commands and environment changes are | 1077 do something. Ultimately, these commands and environment changes are |
1039 always triggered by the event loop. For example: | 1078 always triggered by the event loop. For example: |
1185 | 1224 |
1186 The basic Lisp objects are | 1225 The basic Lisp objects are |
1187 | 1226 |
1188 @table @code | 1227 @table @code |
1189 @item integer | 1228 @item integer |
1190 28 bits of precision, or 60 bits on 64-bit machines; the reason for this | 1229 28 or 31 bits of precision, or 60 or 63 bits on 64-bit machines; the |
1191 is described below when the internal Lisp object representation is | 1230 reason for this is described below when the internal Lisp object |
1192 described. | 1231 representation is described. |
1193 @item float | 1232 @item float |
1194 Same precision as a double in C. | 1233 Same precision as a double in C. |
1195 @item cons | 1234 @item cons |
1196 A simple container for two Lisp objects, used to implement lists and | 1235 A simple container for two Lisp objects, used to implement lists and |
1197 most other data structures in Lisp. | 1236 most other data structures in Lisp. |
1221 faster than for lists, but the operations that can be done on a vector | 1260 faster than for lists, but the operations that can be done on a vector |
1222 are more limited. | 1261 are more limited. |
1223 @item string | 1262 @item string |
1224 Self-explanatory; behaves much like a vector of chars | 1263 Self-explanatory; behaves much like a vector of chars |
1225 but has a different read syntax and is stored and manipulated | 1264 but has a different read syntax and is stored and manipulated |
1226 more compactly and efficiently. | 1265 more compactly. |
1227 @item bit-vector | 1266 @item bit-vector |
1228 A vector of bits; similar to a string in spirit. | 1267 A vector of bits; similar to a string in spirit. |
1229 @item compiled-function | 1268 @item compiled-function |
1230 An object describing compiled Lisp code, known as @dfn{byte code}. | 1269 An object containing compiled Lisp code, known as @dfn{byte code}. |
1231 @item subr | 1270 @item subr |
1232 An object describing a Lisp primitive. | 1271 A Lisp primitive, i.e. a Lisp-callable function implemented in C. |
1233 @end table | 1272 @end table |
1234 | 1273 |
1235 @cindex closure | 1274 @cindex closure |
1236 Note that there is no basic ``function'' type, as in more powerful | 1275 Note that there is no basic ``function'' type, as in more powerful |
1237 versions of Lisp (where it's called a @dfn{closure}). XEmacs Lisp does | 1276 versions of Lisp (where it's called a @dfn{closure}). XEmacs Lisp does |
1238 not provide the closure semantics implemented by Common Lisp and Scheme. | 1277 not provide the closure semantics implemented by Common Lisp and Scheme. |
1239 The guts of a function in XEmacs Lisp are represented in one of four | 1278 The guts of a function in XEmacs Lisp are represented in one of four |
1240 ways: a symbol specifying another function (when one function is an | 1279 ways: a symbol specifying another function (when one function is an |
1241 alias for another), a list containing the function's source code, a | 1280 alias for another), a list (whose first element must be the symbol |
1242 bytecode object, or a subr object. (In other words, given a symbol | 1281 @code{lambda}) containing the function's source code, a |
1243 specifying the name of a function, calling @code{symbol-function} to | 1282 compiled-function object, or a subr object. (In other words, given a |
1244 retrieve the contents of the symbol's function cell will return one of | 1283 symbol specifying the name of a function, calling @code{symbol-function} |
1245 these types of objects.) | 1284 to retrieve the contents of the symbol's function cell will return one |
1246 | 1285 of these types of objects.) |
1247 XEmacs Lisp also contains numerous specialized objects used to | 1286 |
1248 implement the editor: | 1287 XEmacs Lisp also contains numerous specialized objects used to implement |
1288 the editor: | |
1249 | 1289 |
1250 @table @code | 1290 @table @code |
1251 @item buffer | 1291 @item buffer |
1252 Stores text like a string, but is optimized for insertion and deletion | 1292 Stores text like a string, but is optimized for insertion and deletion |
1253 and has certain other properties that can be set. | 1293 and has certain other properties that can be set. |
1262 @item device | 1302 @item device |
1263 An object representing a screen on which frames can be displayed; | 1303 An object representing a screen on which frames can be displayed; |
1264 equivalent to a @dfn{display} in the X Window System and a @dfn{TTY} in | 1304 equivalent to a @dfn{display} in the X Window System and a @dfn{TTY} in |
1265 character mode. | 1305 character mode. |
1266 @item face | 1306 @item face |
1267 An object specifying the appearance of text or graphics; it contains | 1307 An object specifying the appearance of text or graphics; it has |
1268 characteristics such as font, foreground color, and background color. | 1308 properties such as font, foreground color, and background color. |
1269 @item marker | 1309 @item marker |
1270 An object that refers to a particular position in a buffer and moves | 1310 An object that refers to a particular position in a buffer and moves |
1271 around as text is inserted and deleted to stay in the same relative | 1311 around as text is inserted and deleted to stay in the same relative |
1272 position to the text around it. | 1312 position to the text around it. |
1273 @item extent | 1313 @item extent |
1295 @end table | 1335 @end table |
1296 | 1336 |
1297 There are some other, less-commonly-encountered general objects: | 1337 There are some other, less-commonly-encountered general objects: |
1298 | 1338 |
1299 @table @code | 1339 @table @code |
1300 @item hashtable | 1340 @item hash-table |
1301 An object that maps from an arbitrary Lisp object to another arbitrary | 1341 An object that maps from an arbitrary Lisp object to another arbitrary |
1302 Lisp object, using hashing for fast lookup. | 1342 Lisp object, using hashing for fast lookup. |
1303 @item obarray | 1343 @item obarray |
1304 A limited form of hashtable that maps from strings to symbols; obarrays | 1344 A limited form of hash-table that maps from strings to symbols; obarrays |
1305 are used to look up a symbol given its name and are not actually their | 1345 are used to look up a symbol given its name and are not actually their |
1306 own object type but are kludgily represented using vectors with hidden | 1346 own object type but are kludgily represented using vectors with hidden |
1307 fields (this representation derives from GNU Emacs). | 1347 fields (this representation derives from GNU Emacs). |
1308 @item specifier | 1348 @item specifier |
1309 A complex object used to specify the value of a display property; a | 1349 A complex object used to specify the value of a display property; a |
1341 @itemx tooltalk-pattern | 1381 @itemx tooltalk-pattern |
1342 Objects that represent resources used in the ToolTalk interprocess | 1382 Objects that represent resources used in the ToolTalk interprocess |
1343 communication protocol. | 1383 communication protocol. |
1344 @item toolbar-button | 1384 @item toolbar-button |
1345 An object used in conjunction with the toolbar. | 1385 An object used in conjunction with the toolbar. |
1346 @item x-resource | |
1347 An object that encapsulates certain miscellaneous resources in the X | |
1348 window system, used only when Epoch support is enabled. | |
1349 @end table | 1386 @end table |
1350 | 1387 |
1351 And objects that are only used internally: | 1388 And objects that are only used internally: |
1352 | 1389 |
1353 @table @asis | 1390 @table @code |
1354 @item opaque | 1391 @item opaque |
1355 A generic object for encapsulating arbitrary memory; this allows you the | 1392 A generic object for encapsulating arbitrary memory; this allows you the |
1356 generality of @code{malloc()} and the convenience of the Lisp object | 1393 generality of @code{malloc()} and the convenience of the Lisp object |
1357 system. | 1394 system. |
1358 @item lstream | 1395 @item lstream |
1433 ?^[$(B#&^[(B | 1470 ?^[$(B#&^[(B |
1434 @end example | 1471 @end example |
1435 | 1472 |
1436 (where @samp{^[} actually is an @samp{ESC} character) converts to a | 1473 (where @samp{^[} actually is an @samp{ESC} character) converts to a |
1437 particular Kanji character when using an ISO2022-based coding system for | 1474 particular Kanji character when using an ISO2022-based coding system for |
1438 input. (To decode this gook: @samp{ESC} begins an escape sequence; | 1475 input. (To decode this goo: @samp{ESC} begins an escape sequence; |
1439 @samp{ESC $ (} is a class of escape sequences meaning ``switch to a | 1476 @samp{ESC $ (} is a class of escape sequences meaning ``switch to a |
1440 94x94 character set''; @samp{ESC $ ( B} means ``switch to Japanese | 1477 94x94 character set''; @samp{ESC $ ( B} means ``switch to Japanese |
1441 Kanji''; @samp{#} and @samp{&} collectively index into a 94-by-94 array | 1478 Kanji''; @samp{#} and @samp{&} collectively index into a 94-by-94 array |
1442 of characters [subtract 33 from the ASCII value of each character to get | 1479 of characters [subtract 33 from the ASCII value of each character to get |
1443 the corresponding index]; @samp{ESC (} is a class of escape sequences | 1480 the corresponding index]; @samp{ESC (} is a class of escape sequences |
1460 converts to a symbol whose name is @code{"foobar"}. This is done by | 1497 converts to a symbol whose name is @code{"foobar"}. This is done by |
1461 looking up the string equivalent in the global variable | 1498 looking up the string equivalent in the global variable |
1462 @code{obarray}, whose contents should be an obarray. If no symbol | 1499 @code{obarray}, whose contents should be an obarray. If no symbol |
1463 is found, a new symbol with the name @code{"foobar"} is automatically | 1500 is found, a new symbol with the name @code{"foobar"} is automatically |
1464 created and added to @code{obarray}; this process is called | 1501 created and added to @code{obarray}; this process is called |
1465 @dfn{interning} the symbol. | 1502 @dfn{interning} the symbol. |
1466 @cindex interning | 1503 @cindex interning |
1467 | 1504 |
1468 @example | 1505 @example |
1469 (foo . bar) | 1506 (foo . bar) |
1470 @end example | 1507 @end example |
1498 @end example | 1535 @end example |
1499 | 1536 |
1500 converts to a bit-vector. | 1537 converts to a bit-vector. |
1501 | 1538 |
1502 @example | 1539 @example |
1540 #s(hash-table ... ...) | |
1541 @end example | |
1542 | |
1543 converts to a hash table (the actual contents are not shown). | |
1544 | |
1545 @example | |
1503 #s(range-table ... ...) | 1546 #s(range-table ... ...) |
1504 @end example | 1547 @end example |
1505 | 1548 |
1506 converts to a range table (the actual contents are not shown). | 1549 converts to a range table (the actual contents are not shown). |
1507 | 1550 |
1508 @example | 1551 @example |
1509 #s(char-table ... ...) | 1552 #s(char-table ... ...) |
1510 @end example | 1553 @end example |
1511 | 1554 |
1512 converts to a char table (the actual contents are not shown). | 1555 converts to a char table (the actual contents are not shown). |
1513 (Note that the #s syntax is the general syntax for structures, | 1556 |
1514 which are not really implemented in XEmacs Lisp but should be.) | 1557 Note that the @code{#s()} syntax is the general syntax for structures, |
1515 | 1558 which are not really implemented in XEmacs Lisp but should be. |
1516 When an object is printed out (using @code{print} or a related | 1559 |
1560 When an object is printed out (using @code{print} or a related | |
1517 function), the read syntax is used, so that the same object can be read | 1561 function), the read syntax is used, so that the same object can be read |
1518 in again. | 1562 in again. |
1519 | 1563 |
1520 The other objects do not have read syntaxes, usually because it does | 1564 The other objects do not have read syntaxes, usually because it does not |
1521 not really make sense to create them in this fashion (i.e. processes, | 1565 really make sense to create them in this fashion (i.e. processes, where |
1522 where it doesn't make sense to have a subprocess created as a side | 1566 it doesn't make sense to have a subprocess created as a side effect of |
1523 effect of reading some Lisp code), or because they can't be created at | 1567 reading some Lisp code), or because they can't be created at all |
1524 all (e.g. subrs). Permanent objects, as a rule, do not have a read | 1568 (e.g. subrs). Permanent objects, as a rule, do not have a read syntax; |
1525 syntax; nor do most complex objects, which contain too much state to be | 1569 nor do most complex objects, which contain too much state to be easily |
1526 easily initialized through a read syntax. | 1570 initialized through a read syntax. |
1527 | 1571 |
1528 @node How Lisp Objects Are Represented in C, Rules When Writing New C Code, The XEmacs Object System (Abstractly Speaking), Top | 1572 @node How Lisp Objects Are Represented in C, Rules When Writing New C Code, The XEmacs Object System (Abstractly Speaking), Top |
1529 @chapter How Lisp Objects Are Represented in C | 1573 @chapter How Lisp Objects Are Represented in C |
1530 | 1574 |
1531 Lisp objects are represented in C using a 32- or 64-bit machine word | 1575 Lisp objects are represented in C using a 32-bit or 64-bit machine word |
1532 (depending on the processor; i.e. DEC Alphas use 64-bit Lisp objects and | 1576 (depending on the processor; i.e. DEC Alphas use 64-bit Lisp objects and |
1533 most other processors use 32-bit Lisp objects). The representation | 1577 most other processors use 32-bit Lisp objects). The representation |
1534 stuffs a pointer together with a tag, as follows: | 1578 stuffs a pointer together with a tag, as follows: |
1535 | 1579 |
1536 @example | 1580 @example |
1537 [ 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ] | 1581 [ 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ] |
1538 [ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 ] | 1582 [ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 ] |
1539 | 1583 |
1540 ^ <---> <------------------------------------------------------> | 1584 <---> ^ <------------------------------------------------------> |
1541 | tag a pointer to a structure, or an integer | 1585 tag | a pointer to a structure, or an integer |
1542 | | 1586 | |
1543 `---> mark bit | 1587 mark bit |
1544 @end example | 1588 @end example |
1545 | 1589 |
1546 The tag describes the type of the Lisp object. For integers and | 1590 The tag describes the type of the Lisp object. For integers and chars, |
1547 chars, the lower 28 bits contain the value of the integer or char; for | 1591 the lower 28 bits contain the value of the integer or char; for all |
1548 all others, the lower 28 bits contain a pointer. The mark bit is used | 1592 others, the lower 28 bits contain a pointer. The mark bit is used |
1549 during garbage-collection, and is always 0 when garbage collection is | 1593 during garbage-collection, and is always 0 when garbage collection is |
1550 not happening. Many macros that extract out parts of a Lisp object | 1594 not happening. (The way that garbage collection works, basically, is that it |
1551 expect that the mark bit is 0, and will produce incorrect results if | |
1552 it's not. (The way that garbage collection works, basically, is that it | |
1553 loops over all places where Lisp objects could exist -- this includes | 1595 loops over all places where Lisp objects could exist -- this includes |
1554 all global variables in C that contain Lisp objects [including | 1596 all global variables in C that contain Lisp objects [including |
1555 @code{Vobarray}, the C equivalent of @code{obarray}; through this, all | 1597 @code{Vobarray}, the C equivalent of @code{obarray}; through this, all |
1556 Lisp variables will get marked], plus various other places -- and | 1598 Lisp variables will get marked], plus various other places -- and |
1557 recursively scans through the Lisp objects, marking each object it finds | 1599 recursively scans through the Lisp objects, marking each object it finds |
1558 by setting the mark bit. Then it goes through the lists of all objects | 1600 by setting the mark bit. Then it goes through the lists of all objects |
1559 allocated, freeing the ones that are not marked and turning off the | 1601 allocated, freeing the ones that are not marked and turning off the mark |
1560 mark bit of the ones that are marked.) | 1602 bit of the ones that are marked.) |
1561 | 1603 |
1562 Lisp objects use the typedef @code{Lisp_Object}, but the actual C type | 1604 Lisp objects use the typedef @code{Lisp_Object}, but the actual C type |
1563 used for the Lisp object can vary. It can be either a simple type | 1605 used for the Lisp object can vary. It can be either a simple type |
1564 (@code{long} on the DEC Alpha, @code{int} on other machines) or a | 1606 (@code{long} on the DEC Alpha, @code{int} on other machines) or a |
1565 structure whose fields are bit fields that line up properly (actually, a | 1607 structure whose fields are bit fields that line up properly (actually, a |
1566 union of structures that's used). Generally the simple integral type is | 1608 union of structures is used). Generally the simple integral type is |
1567 preferable because it ensures that the compiler will actually use a | 1609 preferable because it ensures that the compiler will actually use a |
1568 machine word to represent the object (some compilers will use more | 1610 machine word to represent the object (some compilers will use more |
1569 general and less efficient code for unions and structs even if they can | 1611 general and less efficient code for unions and structs even if they can |
1570 fit in a machine word). The union type, however, has the advantage of | 1612 fit in a machine word). The union type, however, has the advantage of |
1571 stricter type checking (if you accidentally pass an integer where a Lisp | 1613 stricter type checking (if you accidentally pass an integer where a Lisp |
1572 object is desired, you get a compile error), and it makes it easier to | 1614 object is desired, you get a compile error), and it makes it easier to |
1573 decode Lisp objects when debugging. The choice of which type to use is | 1615 decode Lisp objects when debugging. The choice of which type to use is |
1574 determined by the presence or absence of the preprocessor constant | 1616 determined by the preprocessor constant @code{USE_UNION_TYPE} which is |
1575 @code{USE_UNION_TYPE}. | 1617 defined via the @code{--use-union-type} option to @code{configure}. |
1576 | 1618 |
1577 @cindex record type | 1619 @cindex record type |
1578 Note that there are only eight types that the tag can represent, | 1620 |
1579 but many more actual types than this. This is handled by having | 1621 Note that there are only eight types that the tag can represent, but |
1580 one of the tag types specify a meta-type called a @dfn{record}; | 1622 many more actual types than this. This is handled by having one of the |
1581 for all such objects, the first four bytes of the pointed-to | 1623 tag types specify a meta-type called a @dfn{record}; for all such |
1582 structure indicate what the actual type is. | 1624 objects, the first four bytes of the pointed-to structure indicate what |
1583 | 1625 the actual type is. |
1584 Note also that having 28 bits for pointers and integers restricts a | 1626 |
1585 lot of things to 256 megabytes of memory. (Basically, enough pointers | 1627 Note also that having 28 bits for pointers and integers restricts a lot |
1586 and indices and whatnot get stuffed into Lisp objects that the total | 1628 of things to 256 megabytes of memory. (Basically, enough pointers and |
1587 amount of memory used by XEmacs can't grow above 256 megabytes. In | 1629 indices and whatnot get stuffed into Lisp objects that the total amount |
1588 older versions of XEmacs and GNU Emacs, the tag was 5 bits wide, | 1630 of memory used by XEmacs can't grow above 256 megabytes. In older |
1589 allowing for 32 types, which was more than the actual number of types | 1631 versions of XEmacs and GNU Emacs, the tag was 5 bits wide, allowing for |
1590 that existed at the time, and no ``record'' type was necessary. | 1632 32 types, which was more than the actual number of types that existed at |
1591 However, this limited the editor to 64 megabytes total, which some users | 1633 the time, and no ``record'' type was necessary. However, this limited |
1592 who edited large files might conceivably exceed.) | 1634 the editor to 64 megabytes total, which some users who edited large |
1593 | 1635 files might conceivably exceed.) |
1594 Also, note that there is an implicit assumption here that all pointers | 1636 |
1637 Also, note that there is an implicit assumption here that all pointers | |
1595 are low enough that the top bits are all zero and can just be chopped | 1638 are low enough that the top bits are all zero and can just be chopped |
1596 off. On standard machines that allocate memory from the bottom up (and | 1639 off. On standard machines that allocate memory from the bottom up (and |
1597 give each process its own address space), this works fine. Some | 1640 give each process its own address space), this works fine. Some |
1598 machines, however, put the data space somewhere else in memory | 1641 machines, however, put the data space somewhere else in memory |
1599 (e.g. beginning at 0x80000000). Those machines cope by defining | 1642 (e.g. beginning at 0x80000000). Those machines cope by defining |
1600 @code{DATA_SEG_BITS} in the corresponding @file{m/} or @file{s/} file to | 1643 @code{DATA_SEG_BITS} in the corresponding @file{m/} or @file{s/} file to |
1601 the proper mask. Then, pointers retrieved from Lisp objects are | 1644 the proper mask. Then, pointers retrieved from Lisp objects are |
1602 automatically OR'ed with this value prior to being used. | 1645 automatically OR'ed with this value prior to being used. |
1603 | 1646 |
1604 A corollary of the previous paragraph is that @strong{(pointers to) | 1647 A corollary of the previous paragraph is that @strong{(pointers to) |
1605 stack-allocated structures cannot be put into Lisp objects}. The stack | 1648 stack-allocated structures cannot be put into Lisp objects}. The stack |
1606 is generally located near the top of memory; if you put such a pointer | 1649 is generally located near the top of memory; if you put such a pointer |
1607 into a Lisp object, it will get its top bits chopped off, and you will | 1650 into a Lisp object, it will get its top bits chopped off, and you will |
1608 lose. | 1651 lose. |
1609 | 1652 |
1610 Various macros are used to construct Lisp objects and extract the | 1653 Actually, there's an alternative representation of a @code{Lisp_Object}, |
1654 invented by Kyle Jones, that is used when the | |
1655 @code{--use-minimal-tagbits} option to @code{configure} is used. In | |
1656 this case the 2 lower bits are used for the tag bits. This | |
1657 representation assumes that pointers to structs are always aligned to | |
1658 multiples of 4, so the lower 2 bits are always zero. | |
1659 | |
1660 @example | |
1661 [ 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ] | |
1662 [ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 ] | |
1663 | |
1664 <---------------------------------------------------------> <-> | |
1665 a pointer to a structure, or an integer tag | |
1666 @end example | |
1667 | |
1668 A tag of 00 is used for all pointer object types, a tag of 10 is used | |
1669 for characters, and the other two tags 01 and 11 are joined together to | |
1670 form the integer object type. The markbit is moved to part of the | |
1671 structure being pointed at (integers and chars do not need to be marked, | |
1672 since no memory is allocated). This representation has these | |
1673 advantages: | |
1674 | |
1675 @enumerate | |
1676 @item | |
1677 31 bits can be used for Lisp Integers. | |
1678 @item | |
1679 @emph{Any} pointer can be represented directly, and no bit masking | |
1680 operations are necessary. | |
1681 @end enumerate | |
1682 | |
1683 The disadvantages are: | |
1684 | |
1685 @enumerate | |
1686 @item | |
1687 An extra level of indirection is needed when accessing the object types | |
1688 that were not record types. So checking whether a Lisp object is a cons | |
1689 cell becomes a slower operation. | |
1690 @item | |
1691 Mark bits can no longer be stored directly in Lisp objects, so another | |
1692 place for them must be found. This means that a cons cell requires more | |
1693 memory than merely room for 2 lisp objects, leading to extra memory use. | |
1694 @end enumerate | |
1695 | |
1696 Various macros are used to construct Lisp objects and extract the | |
1611 components. Macros of the form @code{XINT()}, @code{XCHAR()}, | 1697 components. Macros of the form @code{XINT()}, @code{XCHAR()}, |
1612 @code{XSTRING()}, @code{XSYMBOL()}, etc. mask out the pointer/integer | 1698 @code{XSTRING()}, @code{XSYMBOL()}, etc. mask out the pointer/integer |
1613 field and cast it to the appropriate type. All of the macros that | 1699 field and cast it to the appropriate type. All of the macros that |
1614 construct pointers will @code{OR} with @code{DATA_SEG_BITS} if | 1700 construct pointers will @code{OR} with @code{DATA_SEG_BITS} if |
1615 necessary. @code{XINT()} needs to be a bit tricky so that negative | 1701 necessary. @code{XINT()} needs to be a bit tricky so that negative |
1620 that it mimics a divide-by-two even for negative numbers). Not all | 1706 that it mimics a divide-by-two even for negative numbers). Not all |
1621 machines/compilers do this, and on the ones that don't, a more | 1707 machines/compilers do this, and on the ones that don't, a more |
1622 complicated definition is selected by defining | 1708 complicated definition is selected by defining |
1623 @code{EXPLICIT_SIGN_EXTEND}. | 1709 @code{EXPLICIT_SIGN_EXTEND}. |
1624 | 1710 |
1625 Note that when @code{ERROR_CHECK_TYPECHECK} is defined, the extractor | 1711 Note that when @code{ERROR_CHECK_TYPECHECK} is defined, the extractor |
1626 macros become more complicated -- they check the tag bits and/or the | 1712 macros become more complicated -- they check the tag bits and/or the |
1627 type field in the first four bytes of a record type to ensure that the | 1713 type field in the first four bytes of a record type to ensure that the |
1628 object is really of the correct type. This is great for catching places | 1714 object is really of the correct type. This is great for catching places |
1629 where an incorrect type is being dereferenced -- this typically results | 1715 where an incorrect type is being dereferenced -- this typically results |
1630 in a pointer being dereferenced as the wrong type of structure, with | 1716 in a pointer being dereferenced as the wrong type of structure, with |
1631 unpredictable (and sometimes not easily traceable) results. | 1717 unpredictable (and sometimes not easily traceable) results. |
1632 | 1718 |
1633 There are similar @code{XSET@var{TYPE}()} macros that construct a Lisp object. | 1719 There are similar @code{XSET@var{TYPE}()} macros that construct a Lisp |
1634 These macros are of the form @code{XSET@var{TYPE} (@var{lvalue}, @var{result})}, | 1720 object. These macros are of the form @code{XSET@var{TYPE} |
1721 (@var{lvalue}, @var{result})}, | |
1635 i.e. they have to be a statement rather than just used in an expression. | 1722 i.e. they have to be a statement rather than just used in an expression. |
1636 The reason for this is that standard C doesn't let you ``construct'' a | 1723 The reason for this is that standard C doesn't let you ``construct'' a |
1637 structure (but GCC does). Granted, this sometimes isn't too convenient; | 1724 structure (but GCC does). Granted, this sometimes isn't too convenient; |
1638 for the case of integers, at least, you can use the function | 1725 for the case of integers, at least, you can use the function |
1639 @code{make_int()}, which constructs and @emph{returns} an integer | 1726 @code{make_int()}, which constructs and @emph{returns} an integer |
1640 Lisp object. Note that the @code{XSET@var{TYPE}()} macros are also | 1727 Lisp object. Note that the @code{XSET@var{TYPE}()} macros are also |
1641 affected by @code{ERROR_CHECK_TYPECHECK} and make sure that the | 1728 affected by @code{ERROR_CHECK_TYPECHECK} and make sure that the |
1642 structure is of the right type in the case of record types, where the | 1729 structure is of the right type in the case of record types, where the |
1643 type is contained in the structure. | 1730 type is contained in the structure. |
1644 | 1731 |
1732 The C programmer is responsible for @strong{guaranteeing} that a | |
1733 Lisp_Object is is the correct type before using the @code{X@var{TYPE}} | |
1734 macros. This is especially important in the case of lists. Use | |
1735 @code{XCAR} and @code{XCDR} if a Lisp_Object is certainly a cons cell, | |
1736 else use @code{Fcar()} and @code{Fcdr()}. Trust other C code, but not | |
1737 Lisp code. On the other hand, if XEmacs has an internal logic error, | |
1738 it's better to crash immediately, so sprinkle ``unreachable'' | |
1739 @code{abort()}s liberally about the source code. | |
1740 | |
1645 @node Rules When Writing New C Code, A Summary of the Various XEmacs Modules, How Lisp Objects Are Represented in C, Top | 1741 @node Rules When Writing New C Code, A Summary of the Various XEmacs Modules, How Lisp Objects Are Represented in C, Top |
1646 @chapter Rules When Writing New C Code | 1742 @chapter Rules When Writing New C Code |
1647 | 1743 |
1648 The XEmacs C Code is extremely complex and intricate, and there are | 1744 The XEmacs C Code is extremely complex and intricate, and there are many |
1649 many rules that are more or less consistently followed throughout the code. | 1745 rules that are more or less consistently followed throughout the code. |
1650 Many of these rules are not obvious, so they are explained here. It is | 1746 Many of these rules are not obvious, so they are explained here. It is |
1651 of the utmost importance that you follow them. If you don't, you may get | 1747 of the utmost importance that you follow them. If you don't, you may |
1652 something that appears to work, but which will crash in odd situations, | 1748 get something that appears to work, but which will crash in odd |
1653 often in code far away from where the actual breakage is. | 1749 situations, often in code far away from where the actual breakage is. |
1654 | 1750 |
1655 @menu | 1751 @menu |
1656 * General Coding Rules:: | 1752 * General Coding Rules:: |
1657 * Writing Lisp Primitives:: | 1753 * Writing Lisp Primitives:: |
1658 * Adding Global Lisp Variables:: | 1754 * Adding Global Lisp Variables:: |
1661 @end menu | 1757 @end menu |
1662 | 1758 |
1663 @node General Coding Rules | 1759 @node General Coding Rules |
1664 @section General Coding Rules | 1760 @section General Coding Rules |
1665 | 1761 |
1666 Almost every module contains a @code{syms_of_*()} function and a | 1762 The C code is actually written in a dialect of C called @dfn{Clean C}, |
1763 meaning that it can be compiled, mostly warning-free, with either a C or | |
1764 C++ compiler. Coding in Clean C has several advantages over plain C. | |
1765 C++ compilers are more nit-picking, and a number of coding errors have | |
1766 been found by compiling with C++. The ability to use both C and C++ | |
1767 tools means that a greater variety of development tools are available to | |
1768 the developer. | |
1769 | |
1770 Almost every module contains a @code{syms_of_*()} function and a | |
1667 @code{vars_of_*()} function. The former declares any Lisp primitives | 1771 @code{vars_of_*()} function. The former declares any Lisp primitives |
1668 you have defined and defines any symbols you will be using. The latter | 1772 you have defined and defines any symbols you will be using. The latter |
1669 declares any global Lisp variables you have added and initializes global | 1773 declares any global Lisp variables you have added and initializes global |
1670 C variables in the module. For each such function, declare it in | 1774 C variables in the module. For each such function, declare it in |
1671 @file{symsinit.h} and make sure it's called in the appropriate place in | 1775 @file{symsinit.h} and make sure it's called in the appropriate place in |
1676 you'll be sorry! If you want to do anything that isn't allowed, create | 1780 you'll be sorry! If you want to do anything that isn't allowed, create |
1677 a @code{complex_vars_of_*()} function for it. Doing this is tricky, | 1781 a @code{complex_vars_of_*()} function for it. Doing this is tricky, |
1678 though: You have to make sure your function is called at the right time | 1782 though: You have to make sure your function is called at the right time |
1679 so that all the initialization dependencies work out. | 1783 so that all the initialization dependencies work out. |
1680 | 1784 |
1681 Every module includes @file{<config.h>} (angle brackets so that | 1785 Every module includes @file{<config.h>} (angle brackets so that |
1682 @samp{--srcdir} works correctly; @file{config.h} may or may not be in | 1786 @samp{--srcdir} works correctly; @file{config.h} may or may not be in |
1683 the same directory as the C sources) and @file{lisp.h}. @file{config.h} | 1787 the same directory as the C sources) and @file{lisp.h}. @file{config.h} |
1684 should always be included before any other header files (including | 1788 must always be included before any other header files (including |
1685 system header files) to ensure that certain tricks played by various | 1789 system header files) to ensure that certain tricks played by various |
1686 @file{s/} and @file{m/} files work out correctly. | 1790 @file{s/} and @file{m/} files work out correctly. |
1687 | 1791 |
1688 @strong{All global and static variables that are to be modifiable must | 1792 @strong{All global and static variables that are to be modifiable must |
1689 be declared uninitialized.} This means that you may not use the ``declare | 1793 be declared uninitialized.} This means that you may not use the |
1690 with initializer'' form for these variables, such as @code{int | 1794 ``declare with initializer'' form for these variables, such as @code{int |
1691 some_variable = 0;}. The reason for this has to do with some kludges | 1795 some_variable = 0;}. The reason for this has to do with some kludges |
1692 done during the dumping process: If possible, the initialized data | 1796 done during the dumping process: If possible, the initialized data |
1693 segment is re-mapped so that it becomes part of the (unmodifiable) code | 1797 segment is re-mapped so that it becomes part of the (unmodifiable) code |
1694 segment in the dumped executable. This allows this memory to be shared | 1798 segment in the dumped executable. This allows this memory to be shared |
1695 among multiple running XEmacs processes. XEmacs is careful to place as | 1799 among multiple running XEmacs processes. XEmacs is careful to place as |
1696 much constant data as possible into initialized variables (in | 1800 much constant data as possible into initialized variables (in |
1697 particular, into what's called the @dfn{pure space} -- see below) during | 1801 particular, into what's called the @dfn{pure space} -- see below) during |
1698 the @file{temacs} phase. | 1802 the @file{temacs} phase. |
1699 | 1803 |
1700 @cindex copy-on-write | 1804 @cindex copy-on-write |
1701 @strong{Please note:} This kludge only works on a few systems | 1805 @strong{Please note:} This kludge only works on a few systems nowadays, |
1702 nowadays, and is rapidly becoming irrelevant because most modern | 1806 and is rapidly becoming irrelevant because most modern operating systems |
1703 operating systems provide @dfn{copy-on-write} semantics. All data is | 1807 provide @dfn{copy-on-write} semantics. All data is initially shared |
1704 initially shared between processes, and a private copy is automatically | 1808 between processes, and a private copy is automatically made (on a |
1705 made (on a page-by-page basis) when a process first attempts to write to | 1809 page-by-page basis) when a process first attempts to write to a page of |
1706 a page of memory. | 1810 memory. |
1707 | 1811 |
1708 Formerly, there was a requirement that static variables not be | 1812 Formerly, there was a requirement that static variables not be declared |
1709 declared inside of functions. This had to do with another hack along | 1813 inside of functions. This had to do with another hack along the same |
1710 the same vein as what was just described: old USG systems put | 1814 vein as what was just described: old USG systems put statically-declared |
1711 statically-declared variables in the initialized data space, so those | 1815 variables in the initialized data space, so those header files had a |
1712 header files had a @code{#define static} declaration. (That way, the | 1816 @code{#define static} declaration. (That way, the data-segment remapping |
1713 data-segment remapping described above could still work.) This fails | 1817 described above could still work.) This fails badly on static variables |
1714 badly on static variables inside of functions, which suddenly become | 1818 inside of functions, which suddenly become automatic variables; |
1715 automatic variables; therefore, you weren't supposed to have any of | 1819 therefore, you weren't supposed to have any of them. This awful kludge |
1716 them. This awful kludge has been removed in XEmacs because | 1820 has been removed in XEmacs because |
1717 | 1821 |
1718 @enumerate | 1822 @enumerate |
1719 @item | 1823 @item |
1720 almost all of the systems that used this kludge ended up having | 1824 almost all of the systems that used this kludge ended up having |
1721 to disable the data-segment remapping anyway; | 1825 to disable the data-segment remapping anyway; |
1723 the only systems that didn't were extremely outdated ones; | 1827 the only systems that didn't were extremely outdated ones; |
1724 @item | 1828 @item |
1725 this hack completely messed up inline functions. | 1829 this hack completely messed up inline functions. |
1726 @end enumerate | 1830 @end enumerate |
1727 | 1831 |
1832 The C source code makes heavy use of C preprocessor macros. One popular | |
1833 macro style is: | |
1834 | |
1835 @example | |
1836 #define FOO(var, value) do @{ \ | |
1837 Lisp_Object FOO_value = (value); \ | |
1838 ... /* compute using FOO_value */ \ | |
1839 (var) = bar; \ | |
1840 @} while (0) | |
1841 @end example | |
1842 | |
1843 The @code{do @{...@} while (0)} is a standard trick to allow FOO to have | |
1844 statement semantics, so that it can safely be used within an @code{if} | |
1845 statement in C, for example. Multiple evaluation is prevented by | |
1846 copying a supplied argument into a local variable, so that | |
1847 @code{FOO(var,fun(1))} only calls @code{fun} once. | |
1848 | |
1849 Lisp lists are popular data structures in the C code as well as in | |
1850 Elisp. There are two sets of macros that iterate over lists. | |
1851 @code{EXTERNAL_LIST_LOOP_@var{n}} should be used when the list has been | |
1852 supplied by the user, and cannot be trusted to be acyclic and | |
1853 nil-terminated. A @code{malformed-list} or @code{circular-list} error | |
1854 will be generated if the list being iterated over is not entirely | |
1855 kosher. @code{LIST_LOOP_@var{n}}, on the other hand, is faster and less | |
1856 safe, and can be used only on trusted lists. | |
1857 | |
1858 Related macros are @code{GET_EXTERNAL_LIST_LENGTH} and | |
1859 @code{GET_LIST_LENGTH}, which calculate the length of a list, and in the | |
1860 case of @code{GET_EXTERNAL_LIST_LENGTH}, validating the properness of | |
1861 the list. The macros @code{EXTERNAL_LIST_LOOP_DELETE_IF} and | |
1862 @code{LIST_LOOP_DELETE_IF} delete elements from a lisp list satisfying some | |
1863 predicate. | |
1864 | |
1728 @node Writing Lisp Primitives | 1865 @node Writing Lisp Primitives |
1729 @section Writing Lisp Primitives | 1866 @section Writing Lisp Primitives |
1730 | 1867 |
1731 Lisp primitives are Lisp functions implemented in C. The details of | 1868 Lisp primitives are Lisp functions implemented in C. The details of |
1732 interfacing the C function so that Lisp can call it are handled by a few | 1869 interfacing the C function so that Lisp can call it are handled by a few |
1733 C macros. The only way to really understand how to write new C code is | 1870 C macros. The only way to really understand how to write new C code is |
1734 to read the source, but we can explain some things here. | 1871 to read the source, but we can explain some things here. |
1735 | 1872 |
1736 An example of a special form is the definition of @code{or}, from | 1873 An example of a special form is the definition of @code{prog1}, from |
1737 @file{eval.c}. (An ordinary function would have the same general | 1874 @file{eval.c}. (An ordinary function would have the same general |
1738 appearance.) | 1875 appearance.) |
1739 | 1876 |
1740 @cindex garbage collection protection | 1877 @cindex garbage collection protection |
1741 @smallexample | 1878 @smallexample |
1742 @group | 1879 @group |
1743 DEFUN ("or", For, 0, UNEVALLED, 0, /* | 1880 DEFUN ("prog1", Fprog1, 1, UNEVALLED, 0, /* |
1744 Eval args until one of them yields non-nil, then return that value. | 1881 Similar to `progn', but the value of the first form is returned. |
1745 The remaining args are not evalled at all. | 1882 \(prog1 FIRST BODY...): All the arguments are evaluated sequentially. |
1746 If all args return nil, return nil. | 1883 The value of FIRST is saved during evaluation of the remaining args, |
1884 whose values are discarded. | |
1747 */ | 1885 */ |
1748 (args)) | 1886 (args)) |
1749 @{ | 1887 @{ |
1750 /* This function can GC */ | 1888 /* This function can GC */ |
1751 Lisp_Object val = Qnil; | 1889 REGISTER Lisp_Object val, form, tail; |
1752 struct gcpro gcpro1; | 1890 struct gcpro gcpro1; |
1753 | 1891 |
1754 GCPRO1 (args); | 1892 val = Feval (XCAR (args)); |
1755 | 1893 |
1756 while (!NILP (args)) | 1894 GCPRO1 (val); |
1757 @{ | 1895 |
1758 val = Feval (XCAR (args)); | 1896 LIST_LOOP_3 (form, XCDR (args), tail) |
1759 if (!NILP (val)) | 1897 Feval (form); |
1760 break; | |
1761 args = XCDR (args); | |
1762 @} | |
1763 | 1898 |
1764 UNGCPRO; | 1899 UNGCPRO; |
1765 return val; | 1900 return val; |
1766 @} | 1901 @} |
1767 @end group | 1902 @end group |
1769 | 1904 |
1770 Let's start with a precise explanation of the arguments to the | 1905 Let's start with a precise explanation of the arguments to the |
1771 @code{DEFUN} macro. Here is a template for them: | 1906 @code{DEFUN} macro. Here is a template for them: |
1772 | 1907 |
1773 @example | 1908 @example |
1774 DEFUN (@var{lname}, @var{fname}, @var{min}, @var{max}, @var{interactive}, /* | 1909 @group |
1775 @var{docstring} | 1910 DEFUN (@var{lname}, @var{fname}, @var{min_args}, @var{max_args}, @var{interactive}, /* |
1776 */ | 1911 @var{docstring} |
1777 (@var{arglist}) ) | 1912 */ |
1913 (@var{arglist})) | |
1914 @end group | |
1778 @end example | 1915 @end example |
1779 | 1916 |
1780 @table @var | 1917 @table @var |
1781 @item lname | 1918 @item lname |
1782 This string is the name of the Lisp symbol to define as the function | 1919 This string is the name of the Lisp symbol to define as the function |
1783 name; in the example above, it is @code{"or"}. | 1920 name; in the example above, it is @code{"prog1"}. |
1784 | 1921 |
1785 @item fname | 1922 @item fname |
1786 This is the C function name for this function. This is the name that is | 1923 This is the C function name for this function. This is the name that is |
1787 used in C code for calling the function. The name is, by convention, | 1924 used in C code for calling the function. The name is, by convention, |
1788 @samp{F} prepended to the Lisp name, with all dashes (@samp{-}) in the | 1925 @samp{F} prepended to the Lisp name, with all dashes (@samp{-}) in the |
1789 Lisp name changed to underscores. Thus, to call this function from C | 1926 Lisp name changed to underscores. Thus, to call this function from C |
1790 code, call @code{For}. Remember that the arguments are of type | 1927 code, call @code{Fprog1}. Remember that the arguments are of type |
1791 @code{Lisp_Object}; various macros and functions for creating values of | 1928 @code{Lisp_Object}; various macros and functions for creating values of |
1792 type @code{Lisp_Object} are declared in the file @file{lisp.h}. | 1929 type @code{Lisp_Object} are declared in the file @file{lisp.h}. |
1793 | 1930 |
1794 Primitives whose names are special characters (e.g. @code{+} or | 1931 Primitives whose names are special characters (e.g. @code{+} or |
1795 @code{<}) are named by spelling out, in some fashion, the special | 1932 @code{<}) are named by spelling out, in some fashion, the special |
1802 the subr object that represents the function in Lisp. This structure | 1939 the subr object that represents the function in Lisp. This structure |
1803 conveys the Lisp symbol name to the initialization routine that will | 1940 conveys the Lisp symbol name to the initialization routine that will |
1804 create the symbol and store the subr object as its definition. The C | 1941 create the symbol and store the subr object as its definition. The C |
1805 variable name of this structure is always @samp{S} prepended to the | 1942 variable name of this structure is always @samp{S} prepended to the |
1806 @var{fname}. You hardly ever need to be aware of the existence of this | 1943 @var{fname}. You hardly ever need to be aware of the existence of this |
1807 structure. | 1944 structure, since @code{DEFUN} plus @code{DEFSUBR} takes care of all the |
1808 | 1945 details. |
1809 @item min | 1946 |
1947 @item min_args | |
1810 This is the minimum number of arguments that the function requires. The | 1948 This is the minimum number of arguments that the function requires. The |
1811 function @code{or} allows a minimum of zero arguments. | 1949 function @code{prog1} allows a minimum of one argument. |
1812 | 1950 |
1813 @item max | 1951 @item max_args |
1814 This is the maximum number of arguments that the function accepts, if | 1952 This is the maximum number of arguments that the function accepts, if |
1815 there is a fixed maximum. Alternatively, it can be @code{UNEVALLED}, | 1953 there is a fixed maximum. Alternatively, it can be @code{UNEVALLED}, |
1816 indicating a special form that receives unevaluated arguments, or | 1954 indicating a special form that receives unevaluated arguments, or |
1817 @code{MANY}, indicating an unlimited number of evaluated arguments (the | 1955 @code{MANY}, indicating an unlimited number of evaluated arguments (the |
1818 equivalent of @code{&rest}). Both @code{UNEVALLED} and @code{MANY} are | 1956 C equivalent of @code{&rest}). Both @code{UNEVALLED} and @code{MANY} |
1819 macros. If @var{max} is a number, it may not be less than @var{min} and | 1957 are macros. If @var{max_args} is a number, it may not be less than |
1820 it may not be greater than 8. (If you need to add a function with | 1958 @var{min_args} and it may not be greater than 8. (If you need to add a |
1821 more than 8 arguments, either use the @code{MANY} form or edit the | 1959 function with more than 8 arguments, use the @code{MANY} form. Resist |
1822 definition of @code{DEFUN} in @file{lisp.h}. If you do the latter, | 1960 the urge to edit the definition of @code{DEFUN} in @file{lisp.h}. If |
1823 make sure to also add another clause to the switch statement in | 1961 you do it anyways, make sure to also add another clause to the switch |
1824 @code{primitive_funcall().}) | 1962 statement in @code{primitive_funcall().}) |
1825 | 1963 |
1826 @item interactive | 1964 @item interactive |
1827 This is an interactive specification, a string such as might be used as | 1965 This is an interactive specification, a string such as might be used as |
1828 the argument of @code{interactive} in a Lisp function. In the case of | 1966 the argument of @code{interactive} in a Lisp function. In the case of |
1829 @code{or}, it is 0 (a null pointer), indicating that @code{or} cannot be | 1967 @code{prog1}, it is 0 (a null pointer), indicating that @code{prog1} |
1830 called interactively. A value of @code{""} indicates a function that | 1968 cannot be called interactively. A value of @code{""} indicates a |
1831 should receive no arguments when called interactively. | 1969 function that should receive no arguments when called interactively. |
1832 | 1970 |
1833 @item docstring | 1971 @item docstring |
1834 This is the documentation string. It is written just like a | 1972 This is the documentation string. It is written just like a |
1835 documentation string for a function defined in Lisp; in particular, the | 1973 documentation string for a function defined in Lisp; in particular, the |
1836 first line should be a single sentence. Note how the documentation | 1974 first line should be a single sentence. Note how the documentation |
1839 comment-start characters are on the same line as the interactive | 1977 comment-start characters are on the same line as the interactive |
1840 specification. @file{make-docfile}, which scans the C files for | 1978 specification. @file{make-docfile}, which scans the C files for |
1841 documentation strings, is very particular about what it looks for, and | 1979 documentation strings, is very particular about what it looks for, and |
1842 will not properly extract the doc string if it's not in this exact format. | 1980 will not properly extract the doc string if it's not in this exact format. |
1843 | 1981 |
1844 You are free to put the various arguments to @code{DEFUN} on separate | 1982 In order to make both @file{etags} and @file{make-docfile} happy, make |
1845 lines to avoid overly long lines. However, make sure to put the | 1983 sure that the @code{DEFUN} line contains the @var{lname} and |
1846 comment-start characters for the doc string on the same line as the | 1984 @var{fname}, and that the comment-start characters for the doc string |
1847 interactive specification, and put a newline directly after them (and | 1985 are on the same line as the interactive specification, and put a newline |
1848 before the comment-end characters). | 1986 directly after them (and before the comment-end characters). |
1849 | 1987 |
1850 @item arglist | 1988 @item arglist |
1851 This is the comma-separated list of arguments to the C function. For a | 1989 This is the comma-separated list of arguments to the C function. For a |
1852 function with a fixed maximum number of arguments, provide a C argument | 1990 function with a fixed maximum number of arguments, provide a C argument |
1853 for each Lisp argument. In this case, unlike regular C functions, the | 1991 for each Lisp argument. In this case, unlike regular C functions, the |
1854 types of the arguments are not declared; they are simply always of type | 1992 types of the arguments are not declared; they are simply always of type |
1855 @code{Lisp_Object}. | 1993 @code{Lisp_Object}. |
1856 | 1994 |
1857 The names of the C arguments will be used as the names of the arguments | 1995 The names of the C arguments will be used as the names of the arguments |
1858 to the Lisp primitive as displayed in its documentation, modulo the same | 1996 to the Lisp primitive as displayed in its documentation, modulo the same |
1859 concerns described above for @code{F...} names (in particular, | 1997 concerns described above for @code{F...} names (in particular, |
1860 underscores in the C arguments become dashes in the Lisp arguments). | 1998 underscores in the C arguments become dashes in the Lisp arguments). |
1863 discarded when forming the Lisp argument. This allows C language | 2001 discarded when forming the Lisp argument. This allows C language |
1864 reserved words (like @code{default}) or global symbols (like | 2002 reserved words (like @code{default}) or global symbols (like |
1865 @code{dirname}) to be used as argument names without compiler warnings | 2003 @code{dirname}) to be used as argument names without compiler warnings |
1866 or errors. | 2004 or errors. |
1867 | 2005 |
1868 A Lisp function with @w{@var{max} = @code{UNEVALLED}} is a | 2006 A Lisp function with @w{@var{max_args} = @code{UNEVALLED}} is a |
1869 @w{@dfn{special form}}; its arguments are not evaluated. Instead it | 2007 @w{@dfn{special form}}; its arguments are not evaluated. Instead it |
1870 receives one argument of type @code{Lisp_Object}, a (Lisp) list of the | 2008 receives one argument of type @code{Lisp_Object}, a (Lisp) list of the |
1871 unevaluated arguments, conventionally named @code{(args)}. | 2009 unevaluated arguments, conventionally named @code{(args)}. |
1872 | 2010 |
1873 When a Lisp function has no upper limit on the number of arguments, | 2011 When a Lisp function has no upper limit on the number of arguments, |
1874 specify @w{@var{max} = @code{MANY}}. In this case its implementation in | 2012 specify @w{@var{max_args} = @code{MANY}}. In this case its implementation in |
1875 C actually receives exactly two arguments: the number of Lisp arguments | 2013 C actually receives exactly two arguments: the number of Lisp arguments |
1876 (an @code{int}) and the address of a block containing their values (a | 2014 (an @code{int}) and the address of a block containing their values (a |
1877 @w{@code{Lisp_Object *}}). In this case only are the C types specified | 2015 @w{@code{Lisp_Object *}}). In this case only are the C types specified |
1878 in the @var{arglist}: @w{@code{(int nargs, Lisp_Object *args)}}. | 2016 in the @var{arglist}: @w{@code{(int nargs, Lisp_Object *args)}}. |
1879 | 2017 |
1880 @end table | 2018 @end table |
1881 | 2019 |
1882 Within the function @code{For} itself, note the use of the macros | 2020 Within the function @code{Fprog1} itself, note the use of the macros |
1883 @code{GCPRO1} and @code{UNGCPRO}. @code{GCPRO1} is used to ``protect'' | 2021 @code{GCPRO1} and @code{UNGCPRO}. @code{GCPRO1} is used to ``protect'' |
1884 a variable from garbage collection---to inform the garbage collector | 2022 a variable from garbage collection---to inform the garbage collector |
1885 that it must look in that variable and regard its contents as an | 2023 that it must look in that variable and regard the object pointed at by |
1886 accessible object. This is necessary whenever you call @code{Feval} or | 2024 its contents as an accessible object. This is necessary whenever you |
1887 anything that can directly or indirectly call @code{Feval} (this | 2025 call @code{Feval} or anything that can directly or indirectly call |
1888 includes the @code{QUIT} macro!). At such a time, any Lisp object that | 2026 @code{Feval} (this includes the @code{QUIT} macro!). At such a time, |
1889 you intend to refer to again must be protected somehow. @code{UNGCPRO} | 2027 any Lisp object that you intend to refer to again must be protected |
1890 cancels the protection of the variables that are protected in the | 2028 somehow. @code{UNGCPRO} cancels the protection of the variables that |
1891 current function. It is necessary to do this explicitly. | 2029 are protected in the current function. It is necessary to do this |
1892 | 2030 explicitly. |
1893 The macro @code{GCPRO1} protects just one local variable. If you want | 2031 |
2032 The macro @code{GCPRO1} protects just one local variable. If you want | |
1894 to protect two, use @code{GCPRO2} instead; repeating @code{GCPRO1} will | 2033 to protect two, use @code{GCPRO2} instead; repeating @code{GCPRO1} will |
1895 not work. Macros @code{GCPRO3} and @code{GCPRO4} also exist. | 2034 not work. Macros @code{GCPRO3} and @code{GCPRO4} also exist. |
1896 | 2035 |
1897 These macros implicitly use local variables such as @code{gcpro1}; you | 2036 These macros implicitly use local variables such as @code{gcpro1}; you |
1898 must declare these explicitly, with type @code{struct gcpro}. Thus, if | 2037 must declare these explicitly, with type @code{struct gcpro}. Thus, if |
1899 you use @code{GCPRO2}, you must declare @code{gcpro1} and @code{gcpro2}. | 2038 you use @code{GCPRO2}, you must declare @code{gcpro1} and @code{gcpro2}. |
1900 | 2039 |
1901 @cindex caller-protects (@code{GCPRO} rule) | 2040 @cindex caller-protects (@code{GCPRO} rule) |
1902 Note also that the general rule is @dfn{caller-protects}; i.e. you | 2041 Note also that the general rule is @dfn{caller-protects}; i.e. you are |
1903 are only responsible for protecting those Lisp objects that you create. | 2042 only responsible for protecting those Lisp objects that you create. Any |
1904 Any objects passed to you as parameters should have been protected | 2043 objects passed to you as arguments should have been protected by whoever |
1905 by whoever created them, so you don't in general have to protect them. | 2044 created them, so you don't in general have to protect them. |
1906 @code{For} is an exception; it protects its parameters to provide | 2045 |
1907 extra assurance against Lisp primitives elsewhere that are incorrectly | 2046 In particular, the arguments to any Lisp primitive are always |
1908 written, and against malicious self-modifying code. There are a few | 2047 automatically @code{GCPRO}ed, when called ``normally'' from Lisp code or |
1909 other standard functions that also do this. | 2048 bytecode. So only a few Lisp primitives that are called frequently from |
1910 | 2049 C code, such as @code{Fprogn} protect their arguments as a service to |
1911 @code{GCPRO}ing is perhaps the trickiest and most error-prone part | 2050 their caller. You don't need to protect your arguments when writing a |
1912 of XEmacs coding. It is @strong{extremely} important that you get this | 2051 new @code{DEFUN}. |
2052 | |
2053 @code{GCPRO}ing is perhaps the trickiest and most error-prone part of | |
2054 XEmacs coding. It is @strong{extremely} important that you get this | |
1913 right and use a great deal of discipline when writing this code. | 2055 right and use a great deal of discipline when writing this code. |
1914 @xref{GCPROing, ,@code{GCPRO}ing}, for full details on how to do this. | 2056 @xref{GCPROing, ,@code{GCPRO}ing}, for full details on how to do this. |
1915 | 2057 |
1916 What @code{DEFUN} actually does is declare a global structure of | 2058 What @code{DEFUN} actually does is declare a global structure of type |
1917 type @code{Lisp_Subr} whose name begins with capital @samp{SF} and | 2059 @code{Lisp_Subr} whose name begins with capital @samp{SF} and which |
1918 which contains information about the primitive (e.g. a pointer to the | 2060 contains information about the primitive (e.g. a pointer to the |
1919 function, its minimum and maximum allowed arguments, a string describing | 2061 function, its minimum and maximum allowed arguments, a string describing |
1920 its Lisp name); @code{DEFUN} then begins a normal C function | 2062 its Lisp name); @code{DEFUN} then begins a normal C function declaration |
1921 declaration using the @code{F...} name. The Lisp subr object that is | 2063 using the @code{F...} name. The Lisp subr object that is the function |
1922 the function definition of a primitive (i.e. the object in the function | 2064 definition of a primitive (i.e. the object in the function slot of the |
1923 slot of the symbol that names the primitive) actually points to this | 2065 symbol that names the primitive) actually points to this @samp{SF} |
1924 @samp{SF} structure; when @code{Feval} encounters a subr, it looks in the | 2066 structure; when @code{Feval} encounters a subr, it looks in the |
1925 structure to find out how to call the C function. | 2067 structure to find out how to call the C function. |
1926 | 2068 |
1927 Defining the C function is not enough to make a Lisp primitive | 2069 Defining the C function is not enough to make a Lisp primitive |
1928 available; you must also create the Lisp symbol for the primitive (the | 2070 available; you must also create the Lisp symbol for the primitive (the |
1929 symbol is @dfn{interned}; @pxref{Obarrays}) and store a suitable subr | 2071 symbol is @dfn{interned}; @pxref{Obarrays}) and store a suitable subr |
1930 object in its function cell. (If you don't do this, the primitive won't | 2072 object in its function cell. (If you don't do this, the primitive won't |
1931 be seen by Lisp code.) The code looks like this: | 2073 be seen by Lisp code.) The code looks like this: |
1932 | 2074 |
1933 @example | 2075 @example |
1934 DEFSUBR (@var{fname}); | 2076 DEFSUBR (@var{fname}); |
1935 @end example | 2077 @end example |
1936 | 2078 |
1937 @noindent | 2079 @noindent |
1938 Here @var{fname} is the name you used as the second argument to | 2080 Here @var{fname} is the same name you used as the second argument to |
1939 @code{DEFUN}. | 2081 @code{DEFUN}. |
1940 | 2082 |
1941 This call to @code{DEFSUBR} should go in the @code{syms_of_*()} | 2083 This call to @code{DEFSUBR} should go in the @code{syms_of_*()} function |
1942 function at the end of the module. If no such function exists, create | 2084 at the end of the module. If no such function exists, create it and |
1943 it and make sure to also declare it in @file{symsinit.h} and call it | 2085 make sure to also declare it in @file{symsinit.h} and call it from the |
1944 from the appropriate spot in @code{main()}. @xref{General Coding | 2086 appropriate spot in @code{main()}. @xref{General Coding Rules}. |
1945 Rules}. | 2087 |
1946 | 2088 Note that C code cannot call functions by name unless they are defined |
1947 Note that C code cannot call functions by name unless they are defined | |
1948 in C. The way to call a function written in Lisp from C is to use | 2089 in C. The way to call a function written in Lisp from C is to use |
1949 @code{Ffuncall}, which embodies the Lisp function @code{funcall}. Since | 2090 @code{Ffuncall}, which embodies the Lisp function @code{funcall}. Since |
1950 the Lisp function @code{funcall} accepts an unlimited number of | 2091 the Lisp function @code{funcall} accepts an unlimited number of |
1951 arguments, in C it takes two: the number of Lisp-level arguments, and a | 2092 arguments, in C it takes two: the number of Lisp-level arguments, and a |
1952 one-dimensional array containing their values. The first Lisp-level | 2093 one-dimensional array containing their values. The first Lisp-level |
1953 argument is the Lisp function to call, and the rest are the arguments to | 2094 argument is the Lisp function to call, and the rest are the arguments to |
1954 pass to it. Since @code{Ffuncall} can call the evaluator, you must | 2095 pass to it. Since @code{Ffuncall} can call the evaluator, you must |
1955 protect pointers from garbage collection around the call to | 2096 protect pointers from garbage collection around the call to |
1956 @code{Ffuncall}. (However, @code{Ffuncall} explicitly protects all of | 2097 @code{Ffuncall}. (However, @code{Ffuncall} explicitly protects all of |
1957 its parameters, so you don't have to protect any pointers passed | 2098 its parameters, so you don't have to protect any pointers passed as |
1958 as parameters to it.) | 2099 parameters to it.) |
1959 | 2100 |
1960 The C functions @code{call0}, @code{call1}, @code{call2}, and so on, | 2101 The C functions @code{call0}, @code{call1}, @code{call2}, and so on, |
1961 provide handy ways to call a Lisp function conveniently with a fixed | 2102 provide handy ways to call a Lisp function conveniently with a fixed |
1962 number of arguments. They work by calling @code{Ffuncall}. | 2103 number of arguments. They work by calling @code{Ffuncall}. |
1963 | 2104 |
1964 @file{eval.c} is a very good file to look through for examples; | 2105 @file{eval.c} is a very good file to look through for examples; |
1965 @file{lisp.h} contains the definitions for some important macros and | 2106 @file{lisp.h} contains the definitions for important macros and |
1966 functions. | 2107 functions. |
1967 | 2108 |
1968 @node Adding Global Lisp Variables | 2109 @node Adding Global Lisp Variables |
1969 @section Adding Global Lisp Variables | 2110 @section Adding Global Lisp Variables |
1970 | 2111 |
1971 Global variables whose names begin with @samp{Q} are constants whose | 2112 Global variables whose names begin with @samp{Q} are constants whose |
1972 value is a symbol of a particular name. The name of the variable should | 2113 value is a symbol of a particular name. The name of the variable should |
1973 be derived from the name of the symbol using the same rules as for Lisp | 2114 be derived from the name of the symbol using the same rules as for Lisp |
1974 primitives. These variables are initialized using a call to | 2115 primitives. These variables are initialized using a call to |
1975 @code{defsymbol()} in the @code{syms_of_*()} function. (This call | 2116 @code{defsymbol()} in the @code{syms_of_*()} function. (This call |
1976 interns a symbol, sets the C variable to the resulting Lisp object, and | 2117 interns a symbol, sets the C variable to the resulting Lisp object, and |
2147 @{ | 2288 @{ |
2148 Charcount cclen; | 2289 Charcount cclen; |
2149 ... | 2290 ... |
2150 @{ | 2291 @{ |
2151 /* Allocate place for @var{cclen} characters. */ | 2292 /* Allocate place for @var{cclen} characters. */ |
2152 Bufbyte *tmp_buf = (Bufbyte *)alloca (cclen * MAX_EMCHAR_LEN); | 2293 Bufbyte *buf = (Bufbyte *)alloca (cclen * MAX_EMCHAR_LEN); |
2153 ... | 2294 ... |
2154 @end group | 2295 @end group |
2155 @end example | 2296 @end example |
2156 | 2297 |
2157 If you followed the previous section, you can guess that, logically, | 2298 If you followed the previous section, you can guess that, logically, |
2158 multiplying a @code{Charcount} value with @code{MAX_EMCHAR_LEN} produces | 2299 multiplying a @code{Charcount} value with @code{MAX_EMCHAR_LEN} produces |
2159 a @code{Bytecount} value. | 2300 a @code{Bytecount} value. |
2160 | 2301 |
2161 In the current Mule implementation, @code{MAX_EMCHAR_LEN} equals 4. | 2302 In the current Mule implementation, @code{MAX_EMCHAR_LEN} equals 4. |
2162 Without Mule, it is 1. | 2303 Without Mule, it is 1. |
2163 | 2304 |
2254 When an external function, such as a C library function, returns a | 2395 When an external function, such as a C library function, returns a |
2255 @code{char} pointer, you should almost never treat it as @code{Bufbyte}. | 2396 @code{char} pointer, you should almost never treat it as @code{Bufbyte}. |
2256 This is because these returned strings may contain 8bit characters which | 2397 This is because these returned strings may contain 8bit characters which |
2257 can be misinterpreted by XEmacs, and cause a crash. Likewise, when | 2398 can be misinterpreted by XEmacs, and cause a crash. Likewise, when |
2258 exporting a piece of internal text to the outside world, you should | 2399 exporting a piece of internal text to the outside world, you should |
2259 always convert it to an appropriate external encoding, lest the internal | 2400 always convert it to an appropriate external encoding, lest the internal |
2260 stuff (such as the infamous \201 characters) leak out. | 2401 stuff (such as the infamous \201 characters) leak out. |
2261 | 2402 |
2262 The interface to conversion between the internal and external | 2403 The interface to conversion between the internal and external |
2263 representations of text are the numerous conversion macros defined in | 2404 representations of text are the numerous conversion macros defined in |
2264 @file{buffer.h}. Before looking at them, we'll look at the external | 2405 @file{buffer.h}. Before looking at them, we'll look at the external |
2265 formats supported by these macros. | 2406 formats supported by these macros. |
2266 | 2407 |
2267 Currently meaningful formats are @code{FORMAT_BINARY}, | 2408 Currently meaningful formats are @code{FORMAT_BINARY}, |
2268 @code{FORMAT_FILENAME}, @code{FORMAT_OS}, and @code{FORMAT_CTEXT}. Here | 2409 @code{FORMAT_FILENAME}, @code{FORMAT_OS}, and @code{FORMAT_CTEXT}. Here |
2269 is a description of these. | 2410 is a description of these. |
2270 | 2411 |
2271 @table @code | 2412 @table @code |
2272 @item FORMAT_BINARY | 2413 @item FORMAT_BINARY |
2273 Binary format. This is the simplest format and is what we use in the | 2414 Binary format. This is the simplest format and is what we use in the |
2297 Compound--text format. This is the standard X format used for data | 2438 Compound--text format. This is the standard X format used for data |
2298 stored in properties, selections, and the like. This is an 8-bit | 2439 stored in properties, selections, and the like. This is an 8-bit |
2299 no-lock-shift ISO2022 coding system. | 2440 no-lock-shift ISO2022 coding system. |
2300 @end table | 2441 @end table |
2301 | 2442 |
2302 The macros to convert between these formats and the internal format, and | 2443 The macros to convert between these formats and the internal format, and |
2303 vice versa, follow. | 2444 vice versa, follow. |
2304 | 2445 |
2305 @table @code | 2446 @table @code |
2306 @item GET_CHARPTR_INT_DATA_ALLOCA | 2447 @item GET_CHARPTR_INT_DATA_ALLOCA |
2307 @itemx GET_CHARPTR_EXT_DATA_ALLOCA | 2448 @itemx GET_CHARPTR_EXT_DATA_ALLOCA |
2377 @code{Lisp_Object} and @code{make_char}. If you want a pointer to move | 2518 @code{Lisp_Object} and @code{make_char}. If you want a pointer to move |
2378 through the internal text, use @code{Bufbyte *}. Also note that you | 2519 through the internal text, use @code{Bufbyte *}. Also note that you |
2379 almost certainly do not need @code{Emchar *}. | 2520 almost certainly do not need @code{Emchar *}. |
2380 | 2521 |
2381 @item Be careful not to confuse @code{Charcount}, @code{Bytecount}, and @code{Bufpos}. | 2522 @item Be careful not to confuse @code{Charcount}, @code{Bytecount}, and @code{Bufpos}. |
2382 The whole point of using different types is to avoid confusion about the | 2523 The whole point of using different types is to avoid confusion about the |
2383 use of certain variables. Lest this effect be nullified, you need to be | 2524 use of certain variables. Lest this effect be nullified, you need to be |
2384 careful about using the right types. | 2525 careful about using the right types. |
2385 | 2526 |
2386 @item Always convert external data | 2527 @item Always convert external data |
2387 It is extremely important to always convert external data, because | 2528 It is extremely important to always convert external data, because |
2388 XEmacs can crash if unexpected 8bit sequences are copied to its internal | 2529 XEmacs can crash if unexpected 8bit sequences are copied to its internal |
2389 buffers literally. | 2530 buffers literally. |
2390 | 2531 |
2391 This means that when a system function, such as @code{readdir}, returns | 2532 This means that when a system function, such as @code{readdir}, returns |
2392 a string, you need to convert it using one of the conversion macros | 2533 a string, you need to convert it using one of the conversion macros |
2393 described in the previous chapter, before passing it further to Lisp. | 2534 described in the previous chapter, before passing it further to Lisp. |
2444 doing, @code{CHECK_CHAR} will also suffice. @code{XCHAR (lisp_char)} | 2585 doing, @code{CHECK_CHAR} will also suffice. @code{XCHAR (lisp_char)} |
2445 extracts the @code{Emchar} from the @code{Lisp_Object}, and | 2586 extracts the @code{Emchar} from the @code{Lisp_Object}, and |
2446 @code{set_charptr_emchar} stores it to storage, increasing @code{p} in | 2587 @code{set_charptr_emchar} stores it to storage, increasing @code{p} in |
2447 the process. | 2588 the process. |
2448 | 2589 |
2449 Other instructing examples of correct coding under Mule can be found all | 2590 Other instructive examples of correct coding under Mule can be found all |
2450 over XEmacs code. For starters, I recommend | 2591 over the XEmacs code. For starters, I recommend |
2451 @code{Fnormalize_menu_item_name} in @file{menubar.c}. After you have | 2592 @code{Fnormalize_menu_item_name} in @file{menubar.c}. After you have |
2452 understood this section of the manual and studied the examples, you can | 2593 understood this section of the manual and studied the examples, you can |
2453 proceed writing new Mule-aware code. | 2594 proceed writing new Mule-aware code. |
2454 | 2595 |
2455 @node Techniques for XEmacs Developers | 2596 @node Techniques for XEmacs Developers |
2456 @section Techniques for XEmacs Developers | 2597 @section Techniques for XEmacs Developers |
2457 | 2598 |
2458 To make a quantified XEmacs, do: @code{make quantmacs}. | 2599 To make a quantified XEmacs, do: @code{make quantmacs}. |
2459 | 2600 |
2460 You simply can't dump Quantified and Purified images. Run the image | 2601 You simply can't dump Quantified and Purified images. Run the image |
2461 like so: @code{quantmacs -batch -l loadup.el run-temacs -q}. | 2602 like so: @code{quantmacs -batch -l loadup.el run-temacs @var{xemacs-args...}}. |
2462 | 2603 |
2463 Before you go through the trouble, are you compiling with all | 2604 Before you go through the trouble, are you compiling with all |
2464 debugging and error-checking off? If not try that first. Be warned | 2605 debugging and error-checking off? If not try that first. Be warned |
2465 that while Quantify is directly responsible for quite a few | 2606 that while Quantify is directly responsible for quite a few |
2466 optimizations which have been made to XEmacs, doing a run which | 2607 optimizations which have been made to XEmacs, doing a run which |
2473 recording right before it shuts down (which generates enough bogus data | 2614 recording right before it shuts down (which generates enough bogus data |
2474 to throw most results off). It also enables three additional elisp | 2615 to throw most results off). It also enables three additional elisp |
2475 commands: @code{quantify-start-recording-data}, | 2616 commands: @code{quantify-start-recording-data}, |
2476 @code{quantify-stop-recording-data} and @code{quantify-clear-data}. | 2617 @code{quantify-stop-recording-data} and @code{quantify-clear-data}. |
2477 | 2618 |
2619 If you want to make XEmacs faster, target your favorite slow benchmark, | |
2620 run a profiler like Quantify, @code{gprof}, or @code{tcov}, and figure | |
2621 out where the cycles are going. Specific projects: | |
2622 | |
2623 @itemize @bullet | |
2624 @item | |
2625 Make the garbage collector faster. Figure out how to write an | |
2626 incremental garbage collector. | |
2627 @item | |
2628 Write a compiler that takes bytecode and spits out C code. | |
2629 Unfortunately, you will then need a C compiler and a more fully | |
2630 developed module system. | |
2631 @item | |
2632 Speed up redisplay. | |
2633 @item | |
2634 Speed up syntax highlighting. Maybe moving some of the syntax | |
2635 highlighting capabilities into C would make a difference. | |
2636 @item | |
2637 Implement tail recursion in Emacs Lisp (hard!). | |
2638 @end itemize | |
2639 | |
2640 Unfortunately, Emacs Lisp is slow, and is going to stay slow. Function | |
2641 calls in elisp are especially expensive. Iterating over a long list is | |
2642 going to be 30 times faster implemented in C than in Elisp. | |
2643 | |
2478 To get started debugging XEmacs, take a look at the @file{gdbinit} and | 2644 To get started debugging XEmacs, take a look at the @file{gdbinit} and |
2479 @file{dbxrc} files in the @file{src} directory. | 2645 @file{dbxrc} files in the @file{src} directory. |
2480 @xref{Q2.1.15 - How to Debug an XEmacs problem with a debugger,,, | 2646 @xref{Q2.1.15 - How to Debug an XEmacs problem with a debugger,,, |
2481 xemacs-faq, XEmacs FAQ}. | 2647 xemacs-faq, XEmacs FAQ}. |
2482 | 2648 |
2649 After making source code changes, run @code{make check} to ensure that | |
2650 you haven't introduced any regressions. If you're feeling ambitious, | |
2651 you can try to improve the test suite in @file{tests/automated}. | |
2483 | 2652 |
2484 Here are things to know when you create a new source file: | 2653 Here are things to know when you create a new source file: |
2485 | 2654 |
2486 @itemize @bullet | 2655 @itemize @bullet |
2487 @item | 2656 @item |
2488 All .c files should @code{#include <config.h>} first. Almost all .c | 2657 All @file{.c} files should @code{#include <config.h>} first. Almost all |
2489 files should @code{#include "lisp.h"} second. | 2658 @file{.c} files should @code{#include "lisp.h"} second. |
2490 | 2659 |
2491 @item | 2660 @item |
2492 Generated header files should be included using the @code{<>} syntax, | 2661 Generated header files should be included using the @code{#include <...>} syntax, |
2493 not the @code{""} syntax. The generated headers are: | 2662 not the @code{#include "..."} syntax. The generated headers are: |
2494 | 2663 |
2495 config.h puresize-adjust.h sheap-adjust.h paths.h Emacs.ad.h | 2664 @file{config.h puresize-adjust.h sheap-adjust.h paths.h Emacs.ad.h} |
2496 | 2665 |
2497 The basic rule is that you should assume builds using @code{--srcdir} | 2666 The basic rule is that you should assume builds using @code{--srcdir} |
2498 and the @code{<>} syntax needs to be used when the to-be-included | 2667 and the @code{#include <...>} syntax needs to be used when the |
2499 generated file is in a potentially different directory | 2668 to-be-included generated file is in a potentially different directory |
2500 @emph{at compile time}. | 2669 @emph{at compile time}. The non-obvious C rule is that @code{#include "..."} |
2501 | 2670 means to search for the included file in the same directory as the |
2502 @item | 2671 including file, @emph{not} in the current directory. |
2503 Header files should not include <config.h> and "lisp.h". It is the | 2672 |
2504 responsibility of the .c files that use it to do so. | 2673 @item |
2505 | 2674 Header files should @emph{not} include @code{<config.h>} and |
2506 @item | 2675 @code{"lisp.h"}. It is the responsibility of the @file{.c} files that |
2507 If the header uses INLINE, either directly or though DECLARE_LRECORD, | 2676 use it to do so. |
2508 then it must be added to inline.c's includes. | 2677 |
2509 | 2678 @item |
2510 @item | 2679 If the header uses @code{INLINE}, either directly or though |
2511 Try compiling at least once with | 2680 @code{DECLARE_LRECORD}, then it must be added to @file{inline.c}'s |
2681 includes. | |
2682 | |
2683 @item | |
2684 Try compiling at least once with | |
2512 | 2685 |
2513 @example | 2686 @example |
2514 gcc --with-mule --with-union-type --error-checking=all | 2687 gcc --with-mule --with-union-type --error-checking=all |
2515 @end example | 2688 @end example |
2689 | |
2690 @item | |
2691 Did I mention that you should run the test suite? | |
2692 @example | |
2693 make check | |
2694 @end example | |
2516 @end itemize | 2695 @end itemize |
2696 | |
2517 | 2697 |
2518 @node A Summary of the Various XEmacs Modules, Allocation of Objects in XEmacs Lisp, Rules When Writing New C Code, Top | 2698 @node A Summary of the Various XEmacs Modules, Allocation of Objects in XEmacs Lisp, Rules When Writing New C Code, Top |
2519 @chapter A Summary of the Various XEmacs Modules | 2699 @chapter A Summary of the Various XEmacs Modules |
2520 | 2700 |
2521 This is accurate as of XEmacs 20.0. | 2701 This is accurate as of XEmacs 20.0. |
2537 | 2717 |
2538 @node Low-Level Modules | 2718 @node Low-Level Modules |
2539 @section Low-Level Modules | 2719 @section Low-Level Modules |
2540 | 2720 |
2541 @example | 2721 @example |
2542 size name | 2722 config.h |
2543 ------- --------------------- | |
2544 18150 config.h | |
2545 @end example | 2723 @end example |
2546 | 2724 |
2547 This is automatically generated from @file{config.h.in} based on the | 2725 This is automatically generated from @file{config.h.in} based on the |
2548 results of configure tests and user-selected optional features and | 2726 results of configure tests and user-selected optional features and |
2549 contains preprocessor definitions specifying the nature of the | 2727 contains preprocessor definitions specifying the nature of the |
2550 environment in which XEmacs is being compiled. | 2728 environment in which XEmacs is being compiled. |
2551 | 2729 |
2552 | 2730 |
2553 | 2731 |
2554 @example | 2732 @example |
2555 2347 paths.h | 2733 paths.h |
2556 @end example | 2734 @end example |
2557 | 2735 |
2558 This is automatically generated from @file{paths.h.in} based on supplied | 2736 This is automatically generated from @file{paths.h.in} based on supplied |
2559 configure values, and allows for non-standard installed configurations | 2737 configure values, and allows for non-standard installed configurations |
2560 of the XEmacs directories. It's currently broken, though. | 2738 of the XEmacs directories. It's currently broken, though. |
2561 | 2739 |
2562 | 2740 |
2563 | 2741 |
2564 @example | 2742 @example |
2565 47878 emacs.c | 2743 emacs.c |
2566 20239 signal.c | 2744 signal.c |
2567 @end example | 2745 @end example |
2568 | 2746 |
2569 @file{emacs.c} contains @code{main()} and other code that performs the most | 2747 @file{emacs.c} contains @code{main()} and other code that performs the most |
2570 basic environment initializations and handles shutting down the XEmacs | 2748 basic environment initializations and handles shutting down the XEmacs |
2571 process (this includes @code{kill-emacs}, the normal way that XEmacs is | 2749 process (this includes @code{kill-emacs}, the normal way that XEmacs is |
2581 @file{syssignal.h} header file, described in section J below. | 2759 @file{syssignal.h} header file, described in section J below. |
2582 | 2760 |
2583 | 2761 |
2584 | 2762 |
2585 @example | 2763 @example |
2586 23458 unexaix.c | 2764 unexaix.c |
2587 9893 unexalpha.c | 2765 unexalpha.c |
2588 11302 unexapollo.c | 2766 unexapollo.c |
2589 16544 unexconvex.c | 2767 unexconvex.c |
2590 31967 unexec.c | 2768 unexec.c |
2591 30959 unexelf.c | 2769 unexelf.c |
2592 35791 unexelfsgi.c | 2770 unexelfsgi.c |
2593 3207 unexencap.c | 2771 unexencap.c |
2594 7276 unexenix.c | 2772 unexenix.c |
2595 20539 unexfreebsd.c | 2773 unexfreebsd.c |
2596 1153 unexfx2800.c | 2774 unexfx2800.c |
2597 13432 unexhp9k3.c | 2775 unexhp9k3.c |
2598 11049 unexhp9k800.c | 2776 unexhp9k800.c |
2599 9165 unexmips.c | 2777 unexmips.c |
2600 8981 unexnext.c | 2778 unexnext.c |
2601 1673 unexsol2.c | 2779 unexsol2.c |
2602 19261 unexsunos4.c | 2780 unexsunos4.c |
2603 @end example | 2781 @end example |
2604 | 2782 |
2605 These modules contain code dumping out the XEmacs executable on various | 2783 These modules contain code dumping out the XEmacs executable on various |
2606 different systems. (This process is highly machine-specific and | 2784 different systems. (This process is highly machine-specific and |
2607 requires intimate knowledge of the executable format and the memory map | 2785 requires intimate knowledge of the executable format and the memory map |
2609 chosen by @file{configure}. | 2787 chosen by @file{configure}. |
2610 | 2788 |
2611 | 2789 |
2612 | 2790 |
2613 @example | 2791 @example |
2614 15715 crt0.c | 2792 crt0.c |
2615 1484 lastfile.c | 2793 lastfile.c |
2616 1115 pre-crt0.c | 2794 pre-crt0.c |
2617 @end example | 2795 @end example |
2618 | 2796 |
2619 These modules are used in conjunction with the dump mechanism. On some | 2797 These modules are used in conjunction with the dump mechanism. On some |
2620 systems, an alternative version of the C startup code (the actual code | 2798 systems, an alternative version of the C startup code (the actual code |
2621 that receives control from the operating system when the process is | 2799 that receives control from the operating system when the process is |
2636 data space when dumping. | 2814 data space when dumping. |
2637 | 2815 |
2638 | 2816 |
2639 | 2817 |
2640 @example | 2818 @example |
2641 14786 alloca.c | 2819 alloca.c |
2642 16678 free-hook.c | 2820 free-hook.c |
2643 1692 getpagesize.h | 2821 getpagesize.h |
2644 41936 gmalloc.c | 2822 gmalloc.c |
2645 25141 malloc.c | 2823 malloc.c |
2646 3802 mem-limits.h | 2824 mem-limits.h |
2647 39011 ralloc.c | 2825 ralloc.c |
2648 3436 vm-limit.c | 2826 vm-limit.c |
2649 @end example | 2827 @end example |
2650 | 2828 |
2651 These handle basic C allocation of memory. @file{alloca.c} is an emulation of | 2829 These handle basic C allocation of memory. @file{alloca.c} is an emulation of |
2652 the stack allocation function @code{alloca()} on machines that lack | 2830 the stack allocation function @code{alloca()} on machines that lack |
2653 this. (XEmacs makes extensive use of @code{alloca()} in its code.) | 2831 this. (XEmacs makes extensive use of @code{alloca()} in its code.) |
2661 and should always be preferred if it works. (At one point, @file{gmalloc.c} | 2839 and should always be preferred if it works. (At one point, @file{gmalloc.c} |
2662 didn't work on some systems where @file{malloc.c} worked; but this should be | 2840 didn't work on some systems where @file{malloc.c} worked; but this should be |
2663 fixed now.) | 2841 fixed now.) |
2664 | 2842 |
2665 @cindex relocating allocator | 2843 @cindex relocating allocator |
2666 @file{ralloc.c} is the @dfn{relocating allocator}. It provides functions | 2844 @file{ralloc.c} is the @dfn{relocating allocator}. It provides |
2667 similar to @code{malloc()}, @code{realloc()} and @code{free()} that allocate | 2845 functions similar to @code{malloc()}, @code{realloc()} and @code{free()} |
2668 memory that can be dynamically relocated in memory. The advantage of | 2846 that allocate memory that can be dynamically relocated in memory. The |
2669 this is that allocated memory can be shuffled around to place all the | 2847 advantage of this is that allocated memory can be shuffled around to |
2670 free memory at the end of the heap, and the heap can then be shrunk, | 2848 place all the free memory at the end of the heap, and the heap can then |
2671 releasing the memory back to the operating system. The use of this can | 2849 be shrunk, releasing the memory back to the operating system. The use |
2672 be controlled with the configure option @code{--rel-alloc}; if enabled, memory allocated for | 2850 of this can be controlled with the configure option @code{--rel-alloc}; |
2673 buffers will be relocatable, so that if a very large file is visited and | 2851 if enabled, memory allocated for buffers will be relocatable, so that if |
2674 the buffer is later killed, the memory can be released to the operating | 2852 a very large file is visited and the buffer is later killed, the memory |
2675 system. (The disadvantage of this mechanism is that it can be very | 2853 can be released to the operating system. (The disadvantage of this |
2676 slow. On systems with the @code{mmap()} system call, the XEmacs version | 2854 mechanism is that it can be very slow. On systems with the |
2677 of @file{ralloc.c} uses this to move memory around without actually having to | 2855 @code{mmap()} system call, the XEmacs version of @file{ralloc.c} uses |
2678 block-copy it, which can speed things up; but it can still cause | 2856 this to move memory around without actually having to block-copy it, |
2679 noticeable performance degradation.) | 2857 which can speed things up; but it can still cause noticeable performance |
2858 degradation.) | |
2680 | 2859 |
2681 @file{free-hook.c} contains some debugging functions for checking for invalid | 2860 @file{free-hook.c} contains some debugging functions for checking for invalid |
2682 arguments to @code{free()}. | 2861 arguments to @code{free()}. |
2683 | 2862 |
2684 @file{vm-limit.c} contains some functions that warn the user when memory is | 2863 @file{vm-limit.c} contains some functions that warn the user when memory is |
2691 similar in spirit to the @file{sys*.h} files described in section J, below. | 2870 similar in spirit to the @file{sys*.h} files described in section J, below. |
2692 | 2871 |
2693 | 2872 |
2694 | 2873 |
2695 @example | 2874 @example |
2696 2659 blocktype.c | 2875 blocktype.c |
2697 1410 blocktype.h | 2876 blocktype.h |
2698 7194 dynarr.c | 2877 dynarr.c |
2699 2671 dynarr.h | |
2700 @end example | 2878 @end example |
2701 | 2879 |
2702 These implement a couple of basic C data types to facilitate memory | 2880 These implement a couple of basic C data types to facilitate memory |
2703 allocation. The @code{Blocktype} type efficiently manages the | 2881 allocation. The @code{Blocktype} type efficiently manages the |
2704 allocation of fixed-size blocks by minimizing the number of times that | 2882 allocation of fixed-size blocks by minimizing the number of times that |
2718 mechanism. | 2896 mechanism. |
2719 | 2897 |
2720 | 2898 |
2721 | 2899 |
2722 @example | 2900 @example |
2723 2058 inline.c | 2901 inline.c |
2724 @end example | 2902 @end example |
2725 | 2903 |
2726 This module is used in connection with inline functions (available in | 2904 This module is used in connection with inline functions (available in |
2727 some compilers). Often, inline functions need to have a corresponding | 2905 some compilers). Often, inline functions need to have a corresponding |
2728 non-inline function that does the same thing. This module is where they | 2906 non-inline function that does the same thing. This module is where they |
2732 function definitions, so that each one gets a real function equivalent. | 2910 function definitions, so that each one gets a real function equivalent. |
2733 | 2911 |
2734 | 2912 |
2735 | 2913 |
2736 @example | 2914 @example |
2737 6489 debug.c | 2915 debug.c |
2738 2267 debug.h | 2916 debug.h |
2739 @end example | 2917 @end example |
2740 | 2918 |
2741 These functions provide a system for doing internal consistency checks | 2919 These functions provide a system for doing internal consistency checks |
2742 during code development. This system is not currently used; instead the | 2920 during code development. This system is not currently used; instead the |
2743 simpler @code{assert()} macro is used along with the various checks | 2921 simpler @code{assert()} macro is used along with the various checks |
2744 provided by the @samp{--error-check-*} configuration options. | 2922 provided by the @samp{--error-check-*} configuration options. |
2745 | 2923 |
2746 | 2924 |
2747 | 2925 |
2748 @example | 2926 @example |
2749 1643 prefix-args.c | 2927 prefix-args.c |
2750 @end example | 2928 @end example |
2751 | 2929 |
2752 This is actually the source for a small, self-contained program | 2930 This is actually the source for a small, self-contained program |
2753 used during building. | 2931 used during building. |
2754 | 2932 |
2755 | 2933 |
2756 @example | 2934 @example |
2757 904 universe.h | 2935 universe.h |
2758 @end example | 2936 @end example |
2759 | 2937 |
2760 This is not currently used. | 2938 This is not currently used. |
2761 | 2939 |
2762 | 2940 |
2763 | 2941 |
2764 @node Basic Lisp Modules | 2942 @node Basic Lisp Modules |
2765 @section Basic Lisp Modules | 2943 @section Basic Lisp Modules |
2766 | 2944 |
2767 @example | 2945 @example |
2768 size name | 2946 emacsfns.h |
2769 ------- --------------------- | 2947 lisp-disunion.h |
2770 70167 emacsfns.h | 2948 lisp-union.h |
2771 6305 lisp-disunion.h | 2949 lisp.h |
2772 7086 lisp-union.h | 2950 lrecord.h |
2773 54929 lisp.h | 2951 symsinit.h |
2774 14235 lrecord.h | |
2775 10728 symsinit.h | |
2776 @end example | 2952 @end example |
2777 | 2953 |
2778 These are the basic header files for all XEmacs modules. Each module | 2954 These are the basic header files for all XEmacs modules. Each module |
2779 includes @file{lisp.h}, which brings the other header files in. | 2955 includes @file{lisp.h}, which brings the other header files in. |
2780 @file{lisp.h} contains the definitions of the structures and extractor | 2956 @file{lisp.h} contains the definitions of the structures and extractor |
2790 low-level macros. | 2966 low-level macros. |
2791 | 2967 |
2792 As a general rule, all typedefs should go into the typedefs section of | 2968 As a general rule, all typedefs should go into the typedefs section of |
2793 @file{lisp.h} rather than into a module-specific header file even if the | 2969 @file{lisp.h} rather than into a module-specific header file even if the |
2794 structure is defined elsewhere. This allows function prototypes that | 2970 structure is defined elsewhere. This allows function prototypes that |
2795 use the typedef to be placed into @file{emacsfns.h}. Forward structure | 2971 use the typedef to placed into other header files. Forward structure |
2796 declarations (i.e. a simple declaration like @code{struct foo;} where | 2972 declarations (i.e. a simple declaration like @code{struct foo;} where |
2797 the structure itself is defined elsewhere) should be placed into the | 2973 the structure itself is defined elsewhere) should be placed into the |
2798 typedefs section as necessary. | 2974 typedefs section as necessary. |
2799 | 2975 |
2800 @file{lrecord.h} contains the basic structures and macros that implement | 2976 @file{lrecord.h} contains the basic structures and macros that implement |
2801 all record-type Lisp objects -- i.e. all objects whose type is a field | 2977 all record-type Lisp objects -- i.e. all objects whose type is a field |
2802 in their C structure, which includes all objects except the few most | 2978 in their C structure, which includes all objects except the few most |
2803 basic ones. | 2979 basic ones. |
2804 | 2980 |
2805 @file{emacsfns.h} contains prototypes for most of the exported functions | 2981 @file{lisp.h} contains prototypes for most of the exported functions in |
2806 in the various modules. (In particular, prototypes for Lisp primitives | 2982 the various modules. Lisp primitives defined using @code{DEFUN} that |
2807 should always go into this header file. Prototypes for other functions | 2983 need to be called by C code should be declared using @code{EXFUN}. |
2808 can either go here or in a module-specific header file, depending on how | 2984 Other function prototypes should be placed either into the appropriate |
2809 general-purpose the function is and whether it has special-purpose | 2985 section of @code{lisp.h}, or into a module-specific header file, |
2810 argument types requiring definitions not in @file{lisp.h}.) All | 2986 depending on how general-purpose the function is and whether it has |
2811 initialization functions are prototyped in @file{symsinit.h}. | 2987 special-purpose argument types requiring definitions not in |
2812 | 2988 @file{lisp.h}.) All initialization functions are prototyped in |
2813 | 2989 @file{symsinit.h}. |
2814 | 2990 |
2815 @example | 2991 |
2816 120478 alloc.c | 2992 |
2817 1029 pure.c | 2993 @example |
2818 2506 puresize.h | 2994 alloc.c |
2995 pure.c | |
2996 puresize.h | |
2819 @end example | 2997 @end example |
2820 | 2998 |
2821 The large module @file{alloc.c} implements all of the basic allocation and | 2999 The large module @file{alloc.c} implements all of the basic allocation and |
2822 garbage collection for Lisp objects. The most commonly used Lisp | 3000 garbage collection for Lisp objects. The most commonly used Lisp |
2823 objects are allocated in chunks, similar to the Blocktype data type | 3001 objects are allocated in chunks, similar to the Blocktype data type |
2870 pure space is needed. | 3048 pure space is needed. |
2871 | 3049 |
2872 | 3050 |
2873 | 3051 |
2874 @example | 3052 @example |
2875 122243 eval.c | 3053 eval.c |
2876 2305 backtrace.h | 3054 backtrace.h |
2877 @end example | 3055 @end example |
2878 | 3056 |
2879 This module contains all of the functions to handle the flow of control. | 3057 This module contains all of the functions to handle the flow of control. |
2880 This includes the mechanisms of defining functions, calling functions, | 3058 This includes the mechanisms of defining functions, calling functions, |
2881 traversing stack frames, and binding variables; the control primitives | 3059 traversing stack frames, and binding variables; the control primitives |
2890 flow of control. | 3068 flow of control. |
2891 | 3069 |
2892 | 3070 |
2893 | 3071 |
2894 @example | 3072 @example |
2895 64949 lread.c | 3073 lread.c |
2896 @end example | 3074 @end example |
2897 | 3075 |
2898 This module implements the Lisp reader and the @code{read} function, | 3076 This module implements the Lisp reader and the @code{read} function, |
2899 which converts text into Lisp objects, according to the read syntax of | 3077 which converts text into Lisp objects, according to the read syntax of |
2900 the objects, as described above. This is similar to the parser that is | 3078 the objects, as described above. This is similar to the parser that is |
2901 a part of all compilers. | 3079 a part of all compilers. |
2902 | 3080 |
2903 | 3081 |
2904 | 3082 |
2905 @example | 3083 @example |
2906 40900 print.c | 3084 print.c |
2907 @end example | 3085 @end example |
2908 | 3086 |
2909 This module implements the Lisp print mechanism and the @code{print} | 3087 This module implements the Lisp print mechanism and the @code{print} |
2910 function and related functions. This is the inverse of the Lisp reader | 3088 function and related functions. This is the inverse of the Lisp reader |
2911 -- it converts Lisp objects to a printed, textual representation. | 3089 -- it converts Lisp objects to a printed, textual representation. |
2913 an equivalent object.) | 3091 an equivalent object.) |
2914 | 3092 |
2915 | 3093 |
2916 | 3094 |
2917 @example | 3095 @example |
2918 4518 general.c | 3096 general.c |
2919 60220 symbols.c | 3097 symbols.c |
2920 9966 symeval.h | 3098 symeval.h |
2921 @end example | 3099 @end example |
2922 | 3100 |
2923 @file{symbols.c} implements the handling of symbols, obarrays, and | 3101 @file{symbols.c} implements the handling of symbols, obarrays, and |
2924 retrieving the values of symbols. Much of the code is devoted to | 3102 retrieving the values of symbols. Much of the code is devoted to |
2925 handling the special @dfn{symbol-value-magic} objects that define | 3103 handling the special @dfn{symbol-value-magic} objects that define |
2933 @code{DEFVAR_LISP()} and related macros for declaring variables. | 3111 @code{DEFVAR_LISP()} and related macros for declaring variables. |
2934 | 3112 |
2935 | 3113 |
2936 | 3114 |
2937 @example | 3115 @example |
2938 48973 data.c | 3116 data.c |
2939 25694 floatfns.c | 3117 floatfns.c |
2940 71049 fns.c | 3118 fns.c |
2941 @end example | 3119 @end example |
2942 | 3120 |
2943 These modules implement the methods and standard Lisp primitives for all | 3121 These modules implement the methods and standard Lisp primitives for all |
2944 the basic Lisp object types other than symbols (which are described | 3122 the basic Lisp object types other than symbols (which are described |
2945 above). @file{data.c} contains all the predicates (primitives that return | 3123 above). @file{data.c} contains all the predicates (primitives that return |
2954 arithmetic. | 3132 arithmetic. |
2955 | 3133 |
2956 | 3134 |
2957 | 3135 |
2958 @example | 3136 @example |
2959 23555 bytecode.c | 3137 bytecode.c |
2960 3358 bytecode.h | 3138 bytecode.h |
2961 @end example | 3139 @end example |
2962 | 3140 |
2963 @file{bytecode.c} implements the byte-code interpreter, and @file{bytecode.h} contains | 3141 @file{bytecode.c} implements the byte-code interpreter and |
2964 associated structures. Note that the byte-code @emph{compiler} is | 3142 compiled-function objects, and @file{bytecode.h} contains associated |
2965 written in Lisp. | 3143 structures. Note that the byte-code @emph{compiler} is written in Lisp. |
2966 | 3144 |
2967 | 3145 |
2968 | 3146 |
2969 | 3147 |
2970 @node Modules for Standard Editing Operations | 3148 @node Modules for Standard Editing Operations |
2971 @section Modules for Standard Editing Operations | 3149 @section Modules for Standard Editing Operations |
2972 | 3150 |
2973 @example | 3151 @example |
2974 size name | 3152 buffer.c |
2975 ------- --------------------- | 3153 buffer.h |
2976 82900 buffer.c | 3154 bufslots.h |
2977 60964 buffer.h | |
2978 6059 bufslots.h | |
2979 @end example | 3155 @end example |
2980 | 3156 |
2981 @file{buffer.c} implements the @dfn{buffer} Lisp object type. This | 3157 @file{buffer.c} implements the @dfn{buffer} Lisp object type. This |
2982 includes functions that create and destroy buffers; retrieve buffers by | 3158 includes functions that create and destroy buffers; retrieve buffers by |
2983 name or by other properties; manipulate lists of buffers (remember that | 3159 name or by other properties; manipulate lists of buffers (remember that |
3002 the built-in buffer-local variables. | 3178 the built-in buffer-local variables. |
3003 | 3179 |
3004 | 3180 |
3005 | 3181 |
3006 @example | 3182 @example |
3007 79888 insdel.c | 3183 insdel.c |
3008 6103 insdel.h | 3184 insdel.h |
3009 @end example | 3185 @end example |
3010 | 3186 |
3011 @file{insdel.c} contains low-level functions for inserting and deleting text in | 3187 @file{insdel.c} contains low-level functions for inserting and deleting text in |
3012 a buffer, keeping track of changed regions for use by redisplay, and | 3188 a buffer, keeping track of changed regions for use by redisplay, and |
3013 calling any before-change and after-change functions that may have been | 3189 calling any before-change and after-change functions that may have been |
3017 @file{insdel.h} contains associated headers. | 3193 @file{insdel.h} contains associated headers. |
3018 | 3194 |
3019 | 3195 |
3020 | 3196 |
3021 @example | 3197 @example |
3022 10975 marker.c | 3198 marker.c |
3023 @end example | 3199 @end example |
3024 | 3200 |
3025 This module implements the @dfn{marker} Lisp object type, which | 3201 This module implements the @dfn{marker} Lisp object type, which |
3026 conceptually is a pointer to a text position in a buffer that moves | 3202 conceptually is a pointer to a text position in a buffer that moves |
3027 around as text is inserted and deleted, so as to remain in the same | 3203 around as text is inserted and deleted, so as to remain in the same |
3036 current buffer position of the marker. | 3212 current buffer position of the marker. |
3037 | 3213 |
3038 | 3214 |
3039 | 3215 |
3040 @example | 3216 @example |
3041 193714 extents.c | 3217 extents.c |
3042 15686 extents.h | 3218 extents.h |
3043 @end example | 3219 @end example |
3044 | 3220 |
3045 This module implements the @dfn{extent} Lisp object type, which is like | 3221 This module implements the @dfn{extent} Lisp object type, which is like |
3046 a marker that works over a range of text rather than a single position. | 3222 a marker that works over a range of text rather than a single position. |
3047 Extents are also much more complex and powerful than markers and have a | 3223 Extents are also much more complex and powerful than markers and have a |
3057 cover.) | 3233 cover.) |
3058 | 3234 |
3059 | 3235 |
3060 | 3236 |
3061 @example | 3237 @example |
3062 60155 editfns.c | 3238 editfns.c |
3063 @end example | 3239 @end example |
3064 | 3240 |
3065 @file{editfns.c} contains the standard Lisp primitives for working with | 3241 @file{editfns.c} contains the standard Lisp primitives for working with |
3066 a buffer's text, and calls the low-level functions in @file{insdel.c}. | 3242 a buffer's text, and calls the low-level functions in @file{insdel.c}. |
3067 It also contains primitives for working with @code{point} (the default | 3243 It also contains primitives for working with @code{point} (the default |
3074 @file{editfns.c}. | 3250 @file{editfns.c}. |
3075 | 3251 |
3076 | 3252 |
3077 | 3253 |
3078 @example | 3254 @example |
3079 26081 callint.c | 3255 callint.c |
3080 12577 cmds.c | 3256 cmds.c |
3081 2749 commands.h | 3257 commands.h |
3082 @end example | 3258 @end example |
3083 | 3259 |
3084 @cindex interactive | 3260 @cindex interactive |
3085 These modules implement the basic @dfn{interactive} commands, | 3261 These modules implement the basic @dfn{interactive} commands, |
3086 i.e. user-callable functions. Commands, as opposed to other functions, | 3262 i.e. user-callable functions. Commands, as opposed to other functions, |
3103 @file{commands.h} contains associated structure definitions and prototypes. | 3279 @file{commands.h} contains associated structure definitions and prototypes. |
3104 | 3280 |
3105 | 3281 |
3106 | 3282 |
3107 @example | 3283 @example |
3108 194863 regex.c | 3284 regex.c |
3109 18968 regex.h | 3285 regex.h |
3110 79800 search.c | 3286 search.c |
3111 @end example | 3287 @end example |
3112 | 3288 |
3113 @file{search.c} implements the Lisp primitives for searching for text in | 3289 @file{search.c} implements the Lisp primitives for searching for text in |
3114 a buffer, and some of the low-level algorithms for doing this. In | 3290 a buffer, and some of the low-level algorithms for doing this. In |
3115 particular, the fast fixed-string Boyer-Moore search algorithm is | 3291 particular, the fast fixed-string Boyer-Moore search algorithm is |
3120 routines used in @file{grep} and other GNU utilities. | 3296 routines used in @file{grep} and other GNU utilities. |
3121 | 3297 |
3122 | 3298 |
3123 | 3299 |
3124 @example | 3300 @example |
3125 20476 doprnt.c | 3301 doprnt.c |
3126 @end example | 3302 @end example |
3127 | 3303 |
3128 @file{doprnt.c} implements formatted-string processing, similar to | 3304 @file{doprnt.c} implements formatted-string processing, similar to |
3129 @code{printf()} command in C. | 3305 @code{printf()} command in C. |
3130 | 3306 |
3131 | 3307 |
3132 | 3308 |
3133 @example | 3309 @example |
3134 15372 undo.c | 3310 undo.c |
3135 @end example | 3311 @end example |
3136 | 3312 |
3137 This module implements the undo mechanism for tracking buffer changes. | 3313 This module implements the undo mechanism for tracking buffer changes. |
3138 Most of this could be implemented in Lisp. | 3314 Most of this could be implemented in Lisp. |
3139 | 3315 |
3141 | 3317 |
3142 @node Editor-Level Control Flow Modules | 3318 @node Editor-Level Control Flow Modules |
3143 @section Editor-Level Control Flow Modules | 3319 @section Editor-Level Control Flow Modules |
3144 | 3320 |
3145 @example | 3321 @example |
3146 size name | 3322 event-Xt.c |
3147 ------- --------------------- | 3323 event-stream.c |
3148 84546 event-Xt.c | 3324 event-tty.c |
3149 121483 event-stream.c | 3325 events.c |
3150 6658 event-tty.c | 3326 events.h |
3151 49271 events.c | |
3152 14459 events.h | |
3153 @end example | 3327 @end example |
3154 | 3328 |
3155 These implement the handling of events (user input and other system | 3329 These implement the handling of events (user input and other system |
3156 notifications). | 3330 notifications). |
3157 | 3331 |
3187 events from all different kinds of frames. | 3361 events from all different kinds of frames. |
3188 | 3362 |
3189 | 3363 |
3190 | 3364 |
3191 @example | 3365 @example |
3192 129583 keymap.c | 3366 keymap.c |
3193 2621 keymap.h | 3367 keymap.h |
3194 @end example | 3368 @end example |
3195 | 3369 |
3196 @file{keymap.c} and @file{keymap.h} define the @dfn{keymap} Lisp object | 3370 @file{keymap.c} and @file{keymap.h} define the @dfn{keymap} Lisp object |
3197 type and associated methods and primitives. (Remember that keymaps are | 3371 type and associated methods and primitives. (Remember that keymaps are |
3198 objects that associate event descriptions with functions to be called to | 3372 objects that associate event descriptions with functions to be called to |
3200 relevant keymaps.) | 3374 relevant keymaps.) |
3201 | 3375 |
3202 | 3376 |
3203 | 3377 |
3204 @example | 3378 @example |
3205 25212 keyboard.c | 3379 keyboard.c |
3206 @end example | 3380 @end example |
3207 | 3381 |
3208 @file{keyboard.c} contains functions that implement the actual editor | 3382 @file{keyboard.c} contains functions that implement the actual editor |
3209 command loop -- i.e. the event loop that cyclically retrieves and | 3383 command loop -- i.e. the event loop that cyclically retrieves and |
3210 dispatches events. This code is also rather tricky, just like | 3384 dispatches events. This code is also rather tricky, just like |
3211 @file{event-stream.c}. | 3385 @file{event-stream.c}. |
3212 | 3386 |
3213 | 3387 |
3214 | 3388 |
3215 @example | 3389 @example |
3216 9973 macros.c | 3390 macros.c |
3217 1397 macros.h | 3391 macros.h |
3218 @end example | 3392 @end example |
3219 | 3393 |
3220 These two modules contain the basic code for defining keyboard macros. | 3394 These two modules contain the basic code for defining keyboard macros. |
3221 These functions don't actually do much; most of the code that handles keyboard | 3395 These functions don't actually do much; most of the code that handles keyboard |
3222 macros is mixed in with the event-handling code in @file{event-stream.c}. | 3396 macros is mixed in with the event-handling code in @file{event-stream.c}. |
3223 | 3397 |
3224 | 3398 |
3225 | 3399 |
3226 @example | 3400 @example |
3227 23234 minibuf.c | 3401 minibuf.c |
3228 @end example | 3402 @end example |
3229 | 3403 |
3230 This contains some miscellaneous code related to the minibuffer (most of | 3404 This contains some miscellaneous code related to the minibuffer (most of |
3231 the minibuffer code was moved into Lisp by Richard Mlynarik). This | 3405 the minibuffer code was moved into Lisp by Richard Mlynarik). This |
3232 includes the primitives for completion (although filename completion is | 3406 includes the primitives for completion (although filename completion is |
3241 | 3415 |
3242 @node Modules for the Basic Displayable Lisp Objects | 3416 @node Modules for the Basic Displayable Lisp Objects |
3243 @section Modules for the Basic Displayable Lisp Objects | 3417 @section Modules for the Basic Displayable Lisp Objects |
3244 | 3418 |
3245 @example | 3419 @example |
3246 size name | 3420 device-ns.h |
3247 ------- --------------------- | 3421 device-stream.c |
3248 985 device-ns.h | 3422 device-stream.h |
3249 6454 device-stream.c | 3423 device-tty.c |
3250 1196 device-stream.h | 3424 device-tty.h |
3251 9526 device-tty.c | 3425 device-x.c |
3252 8660 device-tty.h | 3426 device-x.h |
3253 43798 device-x.c | 3427 device.c |
3254 11667 device-x.h | 3428 device.h |
3255 26056 device.c | |
3256 22993 device.h | |
3257 @end example | 3429 @end example |
3258 | 3430 |
3259 These modules implement the @dfn{device} Lisp object type. This | 3431 These modules implement the @dfn{device} Lisp object type. This |
3260 abstracts a particular screen or connection on which frames are | 3432 abstracts a particular screen or connection on which frames are |
3261 displayed. As with Lisp objects, event interfaces, and other | 3433 displayed. As with Lisp objects, event interfaces, and other |
3270 subtypes (X, TTY, NeXTstep, Microsoft Windows, etc.) as devices do. | 3442 subtypes (X, TTY, NeXTstep, Microsoft Windows, etc.) as devices do. |
3271 | 3443 |
3272 | 3444 |
3273 | 3445 |
3274 @example | 3446 @example |
3275 934 frame-ns.h | 3447 frame-ns.h |
3276 2303 frame-tty.c | 3448 frame-tty.c |
3277 69205 frame-x.c | 3449 frame-x.c |
3278 5976 frame-x.h | 3450 frame-x.h |
3279 68175 frame.c | 3451 frame.c |
3280 15080 frame.h | 3452 frame.h |
3281 @end example | 3453 @end example |
3282 | 3454 |
3283 Each device contains one or more frames in which objects (e.g. text) are | 3455 Each device contains one or more frames in which objects (e.g. text) are |
3284 displayed. A frame corresponds to a window in the window system; | 3456 displayed. A frame corresponds to a window in the window system; |
3285 usually this is a top-level window but it could potentially be one of a | 3457 usually this is a top-level window but it could potentially be one of a |
3292 (e.g. raising, lowering, resizing, moving, etc.). | 3464 (e.g. raising, lowering, resizing, moving, etc.). |
3293 | 3465 |
3294 | 3466 |
3295 | 3467 |
3296 @example | 3468 @example |
3297 160783 window.c | 3469 window.c |
3298 15974 window.h | 3470 window.h |
3299 @end example | 3471 @end example |
3300 | 3472 |
3301 @cindex window (in Emacs) | 3473 @cindex window (in Emacs) |
3302 @cindex pane | 3474 @cindex pane |
3303 Each frame consists of one or more non-overlapping @dfn{windows} (better | 3475 Each frame consists of one or more non-overlapping @dfn{windows} (better |
3317 | 3489 |
3318 @node Modules for other Display-Related Lisp Objects | 3490 @node Modules for other Display-Related Lisp Objects |
3319 @section Modules for other Display-Related Lisp Objects | 3491 @section Modules for other Display-Related Lisp Objects |
3320 | 3492 |
3321 @example | 3493 @example |
3322 size name | 3494 faces.c |
3323 ------- --------------------- | 3495 faces.h |
3324 54397 faces.c | 3496 @end example |
3325 15173 faces.h | 3497 |
3326 @end example | 3498 |
3327 | 3499 |
3328 | 3500 @example |
3329 | 3501 bitmaps.h |
3330 @example | 3502 glyphs-ns.h |
3331 4961 bitmaps.h | 3503 glyphs-x.c |
3332 954 glyphs-ns.h | 3504 glyphs-x.h |
3333 105345 glyphs-x.c | 3505 glyphs.c |
3334 4288 glyphs-x.h | 3506 glyphs.h |
3335 72102 glyphs.c | 3507 @end example |
3336 16356 glyphs.h | 3508 |
3337 @end example | 3509 |
3338 | 3510 |
3339 | 3511 @example |
3340 | 3512 objects-ns.h |
3341 @example | 3513 objects-tty.c |
3342 952 objects-ns.h | 3514 objects-tty.h |
3343 9971 objects-tty.c | 3515 objects-x.c |
3344 1465 objects-tty.h | 3516 objects-x.h |
3345 32326 objects-x.c | 3517 objects.c |
3346 2806 objects-x.h | 3518 objects.h |
3347 31944 objects.c | 3519 @end example |
3348 6809 objects.h | 3520 |
3349 @end example | 3521 |
3350 | 3522 |
3351 | 3523 @example |
3352 | 3524 menubar-x.c |
3353 @example | 3525 menubar.c |
3354 57511 menubar-x.c | 3526 @end example |
3355 11243 menubar.c | 3527 |
3356 @end example | 3528 |
3357 | 3529 |
3358 | 3530 @example |
3359 | 3531 scrollbar-x.c |
3360 @example | 3532 scrollbar-x.h |
3361 25012 scrollbar-x.c | 3533 scrollbar.c |
3362 2554 scrollbar-x.h | 3534 scrollbar.h |
3363 26954 scrollbar.c | 3535 @end example |
3364 2778 scrollbar.h | 3536 |
3365 @end example | 3537 |
3366 | 3538 |
3367 | 3539 @example |
3368 | 3540 toolbar-x.c |
3369 @example | 3541 toolbar.c |
3370 23117 toolbar-x.c | 3542 toolbar.h |
3371 43456 toolbar.c | 3543 @end example |
3372 4280 toolbar.h | 3544 |
3373 @end example | 3545 |
3374 | 3546 |
3375 | 3547 @example |
3376 | 3548 font-lock.c |
3377 @example | |
3378 25070 font-lock.c | |
3379 @end example | 3549 @end example |
3380 | 3550 |
3381 This file provides C support for syntax highlighting -- i.e. | 3551 This file provides C support for syntax highlighting -- i.e. |
3382 highlighting different syntactic constructs of a source file in | 3552 highlighting different syntactic constructs of a source file in |
3383 different colors, for easy reading. The C support is provided so that | 3553 different colors, for easy reading. The C support is provided so that |
3384 this is fast. | 3554 this is fast. |
3385 | 3555 |
3386 | 3556 |
3387 | 3557 |
3388 @example | 3558 @example |
3389 32180 dgif_lib.c | 3559 dgif_lib.c |
3390 3999 gif_err.c | 3560 gif_err.c |
3391 10697 gif_lib.h | 3561 gif_lib.h |
3392 9371 gifalloc.c | 3562 gifalloc.c |
3393 @end example | 3563 @end example |
3394 | 3564 |
3395 These modules decode GIF-format image files, for use with glyphs. | 3565 These modules decode GIF-format image files, for use with glyphs. |
3396 | 3566 |
3397 | 3567 |
3398 | 3568 |
3399 @node Modules for the Redisplay Mechanism | 3569 @node Modules for the Redisplay Mechanism |
3400 @section Modules for the Redisplay Mechanism | 3570 @section Modules for the Redisplay Mechanism |
3401 | 3571 |
3402 @example | 3572 @example |
3403 size name | 3573 redisplay-output.c |
3404 ------- --------------------- | 3574 redisplay-tty.c |
3405 38692 redisplay-output.c | 3575 redisplay-x.c |
3406 40835 redisplay-tty.c | 3576 redisplay.c |
3407 65069 redisplay-x.c | 3577 redisplay.h |
3408 234142 redisplay.c | |
3409 17026 redisplay.h | |
3410 @end example | 3578 @end example |
3411 | 3579 |
3412 These files provide the redisplay mechanism. As with many other | 3580 These files provide the redisplay mechanism. As with many other |
3413 subsystems in XEmacs, there is a clean separation between the general | 3581 subsystems in XEmacs, there is a clean separation between the general |
3414 and device-specific support. | 3582 and device-specific support. |
3435 respectively. | 3603 respectively. |
3436 | 3604 |
3437 | 3605 |
3438 | 3606 |
3439 @example | 3607 @example |
3440 14129 indent.c | 3608 indent.c |
3441 @end example | 3609 @end example |
3442 | 3610 |
3443 This module contains various functions and Lisp primitives for | 3611 This module contains various functions and Lisp primitives for |
3444 converting between buffer positions and screen positions. These | 3612 converting between buffer positions and screen positions. These |
3445 functions call the redisplay mechanism to do most of the work, and then | 3613 functions call the redisplay mechanism to do most of the work, and then |
3447 module needs work. | 3615 module needs work. |
3448 | 3616 |
3449 | 3617 |
3450 | 3618 |
3451 @example | 3619 @example |
3452 14754 termcap.c | 3620 termcap.c |
3453 2141 terminfo.c | 3621 terminfo.c |
3454 7253 tparam.c | 3622 tparam.c |
3455 @end example | 3623 @end example |
3456 | 3624 |
3457 These files contain functions for working with the termcap (BSD-style) | 3625 These files contain functions for working with the termcap (BSD-style) |
3458 and terminfo (System V style) databases of terminal capabilities and | 3626 and terminfo (System V style) databases of terminal capabilities and |
3459 escape sequences, used when XEmacs is displaying in a TTY. | 3627 escape sequences, used when XEmacs is displaying in a TTY. |
3460 | 3628 |
3461 | 3629 |
3462 | 3630 |
3463 @example | 3631 @example |
3464 10869 cm.c | 3632 cm.c |
3465 5876 cm.h | 3633 cm.h |
3466 @end example | 3634 @end example |
3467 | 3635 |
3468 These files provide some miscellaneous TTY-output functions and should | 3636 These files provide some miscellaneous TTY-output functions and should |
3469 probably be merged into @file{redisplay-tty.c}. | 3637 probably be merged into @file{redisplay-tty.c}. |
3470 | 3638 |
3472 | 3640 |
3473 @node Modules for Interfacing with the File System | 3641 @node Modules for Interfacing with the File System |
3474 @section Modules for Interfacing with the File System | 3642 @section Modules for Interfacing with the File System |
3475 | 3643 |
3476 @example | 3644 @example |
3477 size name | 3645 lstream.c |
3478 ------- --------------------- | 3646 lstream.h |
3479 43362 lstream.c | |
3480 14240 lstream.h | |
3481 @end example | 3647 @end example |
3482 | 3648 |
3483 These modules implement the @dfn{stream} Lisp object type. This is an | 3649 These modules implement the @dfn{stream} Lisp object type. This is an |
3484 internal-only Lisp object that implements a generic buffering stream. | 3650 internal-only Lisp object that implements a generic buffering stream. |
3485 The idea is to provide a uniform interface onto all sources and sinks of | 3651 The idea is to provide a uniform interface onto all sources and sinks of |
3502 types of streams; others are provided, e.g., in @file{mule-coding.c}. | 3668 types of streams; others are provided, e.g., in @file{mule-coding.c}. |
3503 | 3669 |
3504 | 3670 |
3505 | 3671 |
3506 @example | 3672 @example |
3507 126926 fileio.c | 3673 fileio.c |
3508 @end example | 3674 @end example |
3509 | 3675 |
3510 This implements the basic primitives for interfacing with the file | 3676 This implements the basic primitives for interfacing with the file |
3511 system. This includes primitives for reading files into buffers, | 3677 system. This includes primitives for reading files into buffers, |
3512 writing buffers into files, checking for the presence or accessibility | 3678 writing buffers into files, checking for the presence or accessibility |
3519 @file{simple.el}. | 3685 @file{simple.el}. |
3520 | 3686 |
3521 | 3687 |
3522 | 3688 |
3523 @example | 3689 @example |
3524 10960 filelock.c | 3690 filelock.c |
3525 @end example | 3691 @end example |
3526 | 3692 |
3527 This file provides functions for detecting clashes between different | 3693 This file provides functions for detecting clashes between different |
3528 processes (e.g. XEmacs and some external process, or two different | 3694 processes (e.g. XEmacs and some external process, or two different |
3529 XEmacs processes) modifying the same file. (XEmacs can optionally use | 3695 XEmacs processes) modifying the same file. (XEmacs can optionally use |
3534 modified, the user is made aware of this so that the buffer can be | 3700 modified, the user is made aware of this so that the buffer can be |
3535 synched up with the external changes if necessary. | 3701 synched up with the external changes if necessary. |
3536 | 3702 |
3537 | 3703 |
3538 @example | 3704 @example |
3539 4527 filemode.c | 3705 filemode.c |
3540 @end example | 3706 @end example |
3541 | 3707 |
3542 This file provides some miscellaneous functions that construct a | 3708 This file provides some miscellaneous functions that construct a |
3543 @samp{rwxr-xr-x}-type permissions string (as might appear in an | 3709 @samp{rwxr-xr-x}-type permissions string (as might appear in an |
3544 @file{ls}-style directory listing) given the information returned by the | 3710 @file{ls}-style directory listing) given the information returned by the |
3545 @code{stat()} system call. | 3711 @code{stat()} system call. |
3546 | 3712 |
3547 | 3713 |
3548 | 3714 |
3549 @example | 3715 @example |
3550 22855 dired.c | 3716 dired.c |
3551 2094 ndir.h | 3717 ndir.h |
3552 @end example | 3718 @end example |
3553 | 3719 |
3554 These files implement the XEmacs interface to directory searching. This | 3720 These files implement the XEmacs interface to directory searching. This |
3555 includes a number of primitives for determining the files in a directory | 3721 includes a number of primitives for determining the files in a directory |
3556 and for doing filename completion. (Remember that generic completion is | 3722 and for doing filename completion. (Remember that generic completion is |
3562 those systems, directories can be read directly as files, and parsed.) | 3728 those systems, directories can be read directly as files, and parsed.) |
3563 | 3729 |
3564 | 3730 |
3565 | 3731 |
3566 @example | 3732 @example |
3567 4311 realpath.c | 3733 realpath.c |
3568 @end example | 3734 @end example |
3569 | 3735 |
3570 This file provides an implementation of the @code{realpath()} function | 3736 This file provides an implementation of the @code{realpath()} function |
3571 for expanding symbolic links, on systems that don't implement it or have | 3737 for expanding symbolic links, on systems that don't implement it or have |
3572 a broken implementation. | 3738 a broken implementation. |
3575 | 3741 |
3576 @node Modules for Other Aspects of the Lisp Interpreter and Object System | 3742 @node Modules for Other Aspects of the Lisp Interpreter and Object System |
3577 @section Modules for Other Aspects of the Lisp Interpreter and Object System | 3743 @section Modules for Other Aspects of the Lisp Interpreter and Object System |
3578 | 3744 |
3579 @example | 3745 @example |
3580 size name | 3746 elhash.c |
3581 ------- --------------------- | 3747 elhash.h |
3582 22290 elhash.c | 3748 hash.c |
3583 2454 elhash.h | 3749 hash.h |
3584 12169 hash.c | 3750 @end example |
3585 3369 hash.h | 3751 |
3586 @end example | 3752 These files provide two implementations of hash tables. Files |
3587 | |
3588 These files implement the @dfn{hashtable} Lisp object type. | |
3589 @file{hash.c} and @file{hash.h} provide a generic C implementation of | 3753 @file{hash.c} and @file{hash.h} provide a generic C implementation of |
3590 hash tables (which can stand independently of XEmacs), and | 3754 hash tables which can stand independently of XEmacs. Files |
3591 @file{elhash.c} and @file{elhash.h} provide a Lisp interface onto the C | 3755 @file{elhash.c} and @file{elhash.h} provide a separate implementation of |
3592 hash tables using the hashtable Lisp object type. | 3756 hash tables that can store only Lisp objects, and knows about Lispy |
3593 | 3757 things like garbage collection, and implement the @dfn{hash-table} Lisp |
3594 | 3758 object type. |
3595 | 3759 |
3596 @example | 3760 |
3597 95691 specifier.c | 3761 @example |
3598 11167 specifier.h | 3762 specifier.c |
3763 specifier.h | |
3599 @end example | 3764 @end example |
3600 | 3765 |
3601 This module implements the @dfn{specifier} Lisp object type. This is | 3766 This module implements the @dfn{specifier} Lisp object type. This is |
3602 primarily used for displayable properties, and allows for values that | 3767 primarily used for displayable properties, and allows for values that |
3603 are specific to a particular buffer, window, frame, device, or device | 3768 are specific to a particular buffer, window, frame, device, or device |
3609 looks up a value given a window (from which a buffer, frame, and device | 3774 looks up a value given a window (from which a buffer, frame, and device |
3610 can be derived). | 3775 can be derived). |
3611 | 3776 |
3612 | 3777 |
3613 @example | 3778 @example |
3614 43058 chartab.c | 3779 chartab.c |
3615 6503 chartab.h | 3780 chartab.h |
3616 9918 casetab.c | 3781 casetab.c |
3617 @end example | 3782 @end example |
3618 | 3783 |
3619 @file{chartab.c} and @file{chartab.h} implement the @dfn{char table} | 3784 @file{chartab.c} and @file{chartab.h} implement the @dfn{char table} |
3620 Lisp object type, which maps from characters or certain sorts of | 3785 Lisp object type, which maps from characters or certain sorts of |
3621 character ranges to Lisp objects. The implementation of this object | 3786 character ranges to Lisp objects. The implementation of this object |
3631 and to do case-insensitive searching. | 3796 and to do case-insensitive searching. |
3632 | 3797 |
3633 | 3798 |
3634 | 3799 |
3635 @example | 3800 @example |
3636 49593 syntax.c | 3801 syntax.c |
3637 10200 syntax.h | 3802 syntax.h |
3638 @end example | 3803 @end example |
3639 | 3804 |
3640 @cindex scanner | 3805 @cindex scanner |
3641 This module implements @dfn{syntax tables}, another sort of char table | 3806 This module implements @dfn{syntax tables}, another sort of char table |
3642 that maps characters into syntax classes that define the syntax of these | 3807 that maps characters into syntax classes that define the syntax of these |
3649 comments, etc. | 3814 comments, etc. |
3650 | 3815 |
3651 | 3816 |
3652 | 3817 |
3653 @example | 3818 @example |
3654 10438 casefiddle.c | 3819 casefiddle.c |
3655 @end example | 3820 @end example |
3656 | 3821 |
3657 This module implements various Lisp primitives for upcasing, downcasing | 3822 This module implements various Lisp primitives for upcasing, downcasing |
3658 and capitalizing strings or regions of buffers. | 3823 and capitalizing strings or regions of buffers. |
3659 | 3824 |
3660 | 3825 |
3661 | 3826 |
3662 @example | 3827 @example |
3663 20234 rangetab.c | 3828 rangetab.c |
3664 @end example | 3829 @end example |
3665 | 3830 |
3666 This module implements the @dfn{range table} Lisp object type, which | 3831 This module implements the @dfn{range table} Lisp object type, which |
3667 provides for a mapping from ranges of integers to arbitrary Lisp | 3832 provides for a mapping from ranges of integers to arbitrary Lisp |
3668 objects. | 3833 objects. |
3669 | 3834 |
3670 | 3835 |
3671 | 3836 |
3672 @example | 3837 @example |
3673 3201 opaque.c | 3838 opaque.c |
3674 2206 opaque.h | 3839 opaque.h |
3675 @end example | 3840 @end example |
3676 | 3841 |
3677 This module implements the @dfn{opaque} Lisp object type, an | 3842 This module implements the @dfn{opaque} Lisp object type, an |
3678 internal-only Lisp object that encapsulates an arbitrary block of memory | 3843 internal-only Lisp object that encapsulates an arbitrary block of memory |
3679 so that it can be managed by the Lisp allocation system. To create an | 3844 so that it can be managed by the Lisp allocation system. To create an |
3691 create a new Lisp object type -- it's not hard.) | 3856 create a new Lisp object type -- it's not hard.) |
3692 | 3857 |
3693 | 3858 |
3694 | 3859 |
3695 @example | 3860 @example |
3696 8783 abbrev.c | 3861 abbrev.c |
3697 @end example | 3862 @end example |
3698 | 3863 |
3699 This function provides a few primitives for doing dynamic abbreviation | 3864 This function provides a few primitives for doing dynamic abbreviation |
3700 expansion. In XEmacs, most of the code for this has been moved into | 3865 expansion. In XEmacs, most of the code for this has been moved into |
3701 Lisp. Some C code remains for speed and because the primitive | 3866 Lisp. Some C code remains for speed and because the primitive |
3704 is itself in C only for speed.) | 3869 is itself in C only for speed.) |
3705 | 3870 |
3706 | 3871 |
3707 | 3872 |
3708 @example | 3873 @example |
3709 21934 doc.c | 3874 doc.c |
3710 @end example | 3875 @end example |
3711 | 3876 |
3712 This function provides primitives for retrieving the documentation | 3877 This function provides primitives for retrieving the documentation |
3713 strings of functions and variables. These documentation strings contain | 3878 strings of functions and variables. These documentation strings contain |
3714 certain special markers that get dynamically expanded (e.g. a | 3879 certain special markers that get dynamically expanded (e.g. a |
3723 the appropriate documentation string.) | 3888 the appropriate documentation string.) |
3724 | 3889 |
3725 | 3890 |
3726 | 3891 |
3727 @example | 3892 @example |
3728 13197 md5.c | 3893 md5.c |
3729 @end example | 3894 @end example |
3730 | 3895 |
3731 This function provides a Lisp primitive that implements the MD5 secure | 3896 This function provides a Lisp primitive that implements the MD5 secure |
3732 hashing scheme, used to create a large hash value of a string of data such that | 3897 hashing scheme, used to create a large hash value of a string of data such that |
3733 the data cannot be derived from the hash value. This is used for | 3898 the data cannot be derived from the hash value. This is used for |
3738 | 3903 |
3739 @node Modules for Interfacing with the Operating System | 3904 @node Modules for Interfacing with the Operating System |
3740 @section Modules for Interfacing with the Operating System | 3905 @section Modules for Interfacing with the Operating System |
3741 | 3906 |
3742 @example | 3907 @example |
3743 size name | 3908 callproc.c |
3744 ------- --------------------- | 3909 process.c |
3745 33533 callproc.c | 3910 process.h |
3746 89697 process.c | |
3747 4663 process.h | |
3748 @end example | 3911 @end example |
3749 | 3912 |
3750 These modules allow XEmacs to spawn and communicate with subprocesses | 3913 These modules allow XEmacs to spawn and communicate with subprocesses |
3751 and network connections. | 3914 and network connections. |
3752 | 3915 |
3787 subprocesses. | 3950 subprocesses. |
3788 | 3951 |
3789 | 3952 |
3790 | 3953 |
3791 @example | 3954 @example |
3792 136029 sysdep.c | 3955 sysdep.c |
3793 5986 sysdep.h | 3956 sysdep.h |
3794 @end example | 3957 @end example |
3795 | 3958 |
3796 These modules implement most of the low-level, messy operating-system | 3959 These modules implement most of the low-level, messy operating-system |
3797 interface code. This includes various device control (ioctl) operations | 3960 interface code. This includes various device control (ioctl) operations |
3798 for file descriptors, TTY's, pseudo-terminals, etc. (usually this stuff | 3961 for file descriptors, TTY's, pseudo-terminals, etc. (usually this stuff |
3801 provide them or have broken versions. | 3964 provide them or have broken versions. |
3802 | 3965 |
3803 | 3966 |
3804 | 3967 |
3805 @example | 3968 @example |
3806 3605 sysdir.h | 3969 sysdir.h |
3807 6708 sysfile.h | 3970 sysfile.h |
3808 2027 sysfloat.h | 3971 sysfloat.h |
3809 2918 sysproc.h | 3972 sysproc.h |
3810 745 syspwd.h | 3973 syspwd.h |
3811 7643 syssignal.h | 3974 syssignal.h |
3812 6892 systime.h | 3975 systime.h |
3813 12477 systty.h | 3976 systty.h |
3814 3487 syswait.h | 3977 syswait.h |
3815 @end example | 3978 @end example |
3816 | 3979 |
3817 These header files provide consistent interfaces onto system-dependent | 3980 These header files provide consistent interfaces onto system-dependent |
3818 header files and system calls. The idea is that, instead of including a | 3981 header files and system calls. The idea is that, instead of including a |
3819 standard header file like @file{<sys/param.h>} (which may or may not | 3982 standard header file like @file{<sys/param.h>} (which may or may not |
3864 an int). | 4027 an int). |
3865 | 4028 |
3866 | 4029 |
3867 | 4030 |
3868 @example | 4031 @example |
3869 7940 hpplay.c | 4032 hpplay.c |
3870 10920 libsst.c | 4033 libsst.c |
3871 1480 libsst.h | 4034 libsst.h |
3872 3260 libst.h | 4035 libst.h |
3873 15355 linuxplay.c | 4036 linuxplay.c |
3874 15849 nas.c | 4037 nas.c |
3875 19133 sgiplay.c | 4038 sgiplay.c |
3876 15411 sound.c | 4039 sound.c |
3877 7358 sunplay.c | 4040 sunplay.c |
3878 @end example | 4041 @end example |
3879 | 4042 |
3880 These files implement the ability to play various sounds on some types | 4043 These files implement the ability to play various sounds on some types |
3881 of computers. You have to configure your XEmacs with sound support in | 4044 of computers. You have to configure your XEmacs with sound support in |
3882 order to get this capability. | 4045 order to get this capability. |
3909 currently in use. | 4072 currently in use. |
3910 | 4073 |
3911 | 4074 |
3912 | 4075 |
3913 @example | 4076 @example |
3914 44368 tooltalk.c | 4077 tooltalk.c |
3915 2137 tooltalk.h | 4078 tooltalk.h |
3916 @end example | 4079 @end example |
3917 | 4080 |
3918 These two modules implement an interface to the ToolTalk protocol, which | 4081 These two modules implement an interface to the ToolTalk protocol, which |
3919 is an interprocess communication protocol implemented on some versions | 4082 is an interprocess communication protocol implemented on some versions |
3920 of Unix. ToolTalk is a high-level protocol that allows processes to | 4083 of Unix. ToolTalk is a high-level protocol that allows processes to |
3926 parts of the SPARCWorks development environment. | 4089 parts of the SPARCWorks development environment. |
3927 | 4090 |
3928 | 4091 |
3929 | 4092 |
3930 @example | 4093 @example |
3931 22695 getloadavg.c | 4094 getloadavg.c |
3932 @end example | 4095 @end example |
3933 | 4096 |
3934 This module provides the ability to retrieve the system's current load | 4097 This module provides the ability to retrieve the system's current load |
3935 average. (The way to do this is highly system-specific, unfortunately, | 4098 average. (The way to do this is highly system-specific, unfortunately, |
3936 and requires a lot of special-case code.) | 4099 and requires a lot of special-case code.) |
3937 | 4100 |
3938 | 4101 |
3939 | 4102 |
3940 @example | 4103 @example |
3941 148520 energize.c | 4104 sunpro.c |
3942 6896 energize.h | |
3943 @end example | |
3944 | |
3945 This module provides code to interface to an Energize server (when | |
3946 XEmacs is used as part of Lucid's Energize development environment) and | |
3947 provides some other Energize-specific functions. Much of the code in | |
3948 this module should be made more general-purpose and moved elsewhere, but | |
3949 is no longer very relevant now that Lucid is defunct. It also hasn't | |
3950 worked since version 19.12, since nobody has been maintaining it. | |
3951 | |
3952 | |
3953 | |
3954 @example | |
3955 2861 sunpro.c | |
3956 @end example | 4105 @end example |
3957 | 4106 |
3958 This module provides a small amount of code used internally at Sun to | 4107 This module provides a small amount of code used internally at Sun to |
3959 keep statistics on the usage of XEmacs. | 4108 keep statistics on the usage of XEmacs. |
3960 | 4109 |
3961 | 4110 |
3962 | 4111 |
3963 @example | 4112 @example |
3964 5548 broken-sun.h | 4113 broken-sun.h |
3965 3468 strcmp.c | 4114 strcmp.c |
3966 2179 strcpy.c | 4115 strcpy.c |
3967 1650 sunOS-fix.c | 4116 sunOS-fix.c |
3968 @end example | 4117 @end example |
3969 | 4118 |
3970 These files provide replacement functions and prototypes to fix numerous | 4119 These files provide replacement functions and prototypes to fix numerous |
3971 bugs in early releases of SunOS 4.1. | 4120 bugs in early releases of SunOS 4.1. |
3972 | 4121 |
3973 | 4122 |
3974 | 4123 |
3975 @example | 4124 @example |
3976 11669 hftctl.c | 4125 hftctl.c |
3977 @end example | 4126 @end example |
3978 | 4127 |
3979 This module provides some terminal-control code necessary on versions of | 4128 This module provides some terminal-control code necessary on versions of |
3980 AIX prior to 4.1. | 4129 AIX prior to 4.1. |
3981 | 4130 |
3982 | 4131 |
3983 | 4132 |
3984 @example | 4133 @example |
3985 1776 acldef.h | 4134 msdos.c |
3986 1602 chpdef.h | 4135 msdos.h |
3987 9032 uaf.h | |
3988 105 vlimit.h | |
3989 7145 vms-pp.c | |
3990 1158 vms-pwd.h | |
3991 26532 vmsfns.c | |
3992 6038 vmsmap.c | |
3993 695 vmspaths.h | |
3994 17482 vmsproc.c | |
3995 469 vmsproc.h | |
3996 @end example | |
3997 | |
3998 All of these files are used for VMS support, which has never worked in | |
3999 XEmacs. | |
4000 | |
4001 | |
4002 | |
4003 @example | |
4004 28316 msdos.c | |
4005 1472 msdos.h | |
4006 @end example | 4136 @end example |
4007 | 4137 |
4008 These modules are used for MS-DOS support, which does not work in | 4138 These modules are used for MS-DOS support, which does not work in |
4009 XEmacs. | 4139 XEmacs. |
4010 | 4140 |
4012 | 4142 |
4013 @node Modules for Interfacing with X Windows | 4143 @node Modules for Interfacing with X Windows |
4014 @section Modules for Interfacing with X Windows | 4144 @section Modules for Interfacing with X Windows |
4015 | 4145 |
4016 @example | 4146 @example |
4017 size name | 4147 Emacs.ad.h |
4018 ------- --------------------- | |
4019 3196 Emacs.ad.h | |
4020 @end example | 4148 @end example |
4021 | 4149 |
4022 A file generated from @file{Emacs.ad}, which contains XEmacs-supplied | 4150 A file generated from @file{Emacs.ad}, which contains XEmacs-supplied |
4023 fallback resources (so that XEmacs has pretty defaults). | 4151 fallback resources (so that XEmacs has pretty defaults). |
4024 | 4152 |
4025 | 4153 |
4026 | 4154 |
4027 @example | 4155 @example |
4028 24242 EmacsFrame.c | 4156 EmacsFrame.c |
4029 6979 EmacsFrame.h | 4157 EmacsFrame.h |
4030 3351 EmacsFrameP.h | 4158 EmacsFrameP.h |
4031 @end example | 4159 @end example |
4032 | 4160 |
4033 These modules implement an Xt widget class that encapsulates a frame. | 4161 These modules implement an Xt widget class that encapsulates a frame. |
4034 This is for ease in integrating with Xt. The EmacsFrame widget covers | 4162 This is for ease in integrating with Xt. The EmacsFrame widget covers |
4035 the entire X window except for the menubar; the scrollbars are | 4163 the entire X window except for the menubar; the scrollbars are |
4040 mercilessly at the slightest change. Such is life under Xt. | 4168 mercilessly at the slightest change. Such is life under Xt. |
4041 | 4169 |
4042 | 4170 |
4043 | 4171 |
4044 @example | 4172 @example |
4045 8178 EmacsManager.c | 4173 EmacsManager.c |
4046 1967 EmacsManager.h | 4174 EmacsManager.h |
4047 1895 EmacsManagerP.h | 4175 EmacsManagerP.h |
4048 @end example | 4176 @end example |
4049 | 4177 |
4050 These modules implement a simple Xt manager (i.e. composite) widget | 4178 These modules implement a simple Xt manager (i.e. composite) widget |
4051 class that simply lets its children set whatever geometry they want. | 4179 class that simply lets its children set whatever geometry they want. |
4052 It's amazing that Xt doesn't provide this standardly, but on second | 4180 It's amazing that Xt doesn't provide this standardly, but on second |
4053 thought, it makes sense, considering how amazingly broken Xt is. | 4181 thought, it makes sense, considering how amazingly broken Xt is. |
4054 | 4182 |
4055 | 4183 |
4056 @example | 4184 @example |
4057 13188 EmacsShell-sub.c | 4185 EmacsShell-sub.c |
4058 4588 EmacsShell.c | 4186 EmacsShell.c |
4059 2180 EmacsShell.h | 4187 EmacsShell.h |
4060 3133 EmacsShellP.h | 4188 EmacsShellP.h |
4061 @end example | 4189 @end example |
4062 | 4190 |
4063 These modules implement two Xt widget classes that are subclasses of | 4191 These modules implement two Xt widget classes that are subclasses of |
4064 the TopLevelShell and TransientShell classes. This is necessary to deal | 4192 the TopLevelShell and TransientShell classes. This is necessary to deal |
4065 with more brokenness that Xt has sadistically thrust onto the backs of | 4193 with more brokenness that Xt has sadistically thrust onto the backs of |
4066 developers. | 4194 developers. |
4067 | 4195 |
4068 | 4196 |
4069 | 4197 |
4070 @example | 4198 @example |
4071 9673 xgccache.c | 4199 xgccache.c |
4072 1111 xgccache.h | 4200 xgccache.h |
4073 @end example | 4201 @end example |
4074 | 4202 |
4075 These modules provide functions for maintenance and caching of GC's | 4203 These modules provide functions for maintenance and caching of GC's |
4076 (graphics contexts) under the X Window System. This code is junky and | 4204 (graphics contexts) under the X Window System. This code is junky and |
4077 needs to be rewritten. | 4205 needs to be rewritten. |
4078 | 4206 |
4079 | 4207 |
4080 | 4208 |
4081 @example | 4209 @example |
4082 69181 xselect.c | 4210 xselect.c |
4083 @end example | 4211 @end example |
4084 | 4212 |
4085 @cindex selections | 4213 @cindex selections |
4086 This module provides an interface to the X Window System's concept of | 4214 This module provides an interface to the X Window System's concept of |
4087 @dfn{selections}, the standard way for X applications to communicate | 4215 @dfn{selections}, the standard way for X applications to communicate |
4088 with each other. | 4216 with each other. |
4089 | 4217 |
4090 | 4218 |
4091 | 4219 |
4092 @example | 4220 @example |
4093 929 xintrinsic.h | 4221 xintrinsic.h |
4094 1038 xintrinsicp.h | 4222 xintrinsicp.h |
4095 1579 xmmanagerp.h | 4223 xmmanagerp.h |
4096 1585 xmprimitivep.h | 4224 xmprimitivep.h |
4097 @end example | 4225 @end example |
4098 | 4226 |
4099 These header files are similar in spirit to the @file{sys*.h} files and buffer | 4227 These header files are similar in spirit to the @file{sys*.h} files and buffer |
4100 against different implementations of Xt and Motif. | 4228 against different implementations of Xt and Motif. |
4101 | 4229 |
4111 @end itemize | 4239 @end itemize |
4112 | 4240 |
4113 | 4241 |
4114 | 4242 |
4115 @example | 4243 @example |
4116 16930 xmu.c | 4244 xmu.c |
4117 936 xmu.h | 4245 xmu.h |
4118 @end example | 4246 @end example |
4119 | 4247 |
4120 These files provide an emulation of the Xmu library for those systems | 4248 These files provide an emulation of the Xmu library for those systems |
4121 (i.e. HPUX) that don't provide it as a standard part of X. | 4249 (i.e. HPUX) that don't provide it as a standard part of X. |
4122 | 4250 |
4123 | 4251 |
4124 | 4252 |
4125 @example | 4253 @example |
4126 4201 ExternalClient-Xlib.c | 4254 ExternalClient-Xlib.c |
4127 18083 ExternalClient.c | 4255 ExternalClient.c |
4128 2035 ExternalClient.h | 4256 ExternalClient.h |
4129 2104 ExternalClientP.h | 4257 ExternalClientP.h |
4130 22684 ExternalShell.c | 4258 ExternalShell.c |
4131 1709 ExternalShell.h | 4259 ExternalShell.h |
4132 1971 ExternalShellP.h | 4260 ExternalShellP.h |
4133 2478 extw-Xlib.c | 4261 extw-Xlib.c |
4134 1481 extw-Xlib.h | 4262 extw-Xlib.h |
4135 6565 extw-Xt.c | 4263 extw-Xt.c |
4136 1430 extw-Xt.h | 4264 extw-Xt.h |
4137 @end example | 4265 @end example |
4138 | 4266 |
4139 @cindex external widget | 4267 @cindex external widget |
4140 These files provide the @dfn{external widget} interface, which allows an | 4268 These files provide the @dfn{external widget} interface, which allows an |
4141 XEmacs frame to appear as a widget in another application. To do this, | 4269 XEmacs frame to appear as a widget in another application. To do this, |
4152 | 4280 |
4153 Don't touch this code; something is liable to break if you do. | 4281 Don't touch this code; something is liable to break if you do. |
4154 | 4282 |
4155 | 4283 |
4156 | 4284 |
4157 @example | |
4158 31014 epoch.c | |
4159 @end example | |
4160 | |
4161 This file provides some additional, Epoch-compatible, functionality for | |
4162 interfacing to the X Window System. | |
4163 | |
4164 | |
4165 | |
4166 @node Modules for Internationalization | 4285 @node Modules for Internationalization |
4167 @section Modules for Internationalization | 4286 @section Modules for Internationalization |
4168 | 4287 |
4169 @example | 4288 @example |
4170 size name | 4289 mule-canna.c |
4171 ------- --------------------- | 4290 mule-ccl.c |
4172 42836 mule-canna.c | 4291 mule-charset.c |
4173 16737 mule-ccl.c | 4292 mule-charset.h |
4174 41080 mule-charset.c | 4293 mule-coding.c |
4175 30176 mule-charset.h | 4294 mule-coding.h |
4176 146844 mule-coding.c | 4295 mule-mcpath.c |
4177 16588 mule-coding.h | 4296 mule-mcpath.h |
4178 6996 mule-mcpath.c | 4297 mule-wnnfns.c |
4179 2899 mule-mcpath.h | 4298 mule.c |
4180 57158 mule-wnnfns.c | |
4181 3351 mule.c | |
4182 @end example | 4299 @end example |
4183 | 4300 |
4184 These files implement the MULE (Asian-language) support. Note that MULE | 4301 These files implement the MULE (Asian-language) support. Note that MULE |
4185 actually provides a general interface for all sorts of languages, not | 4302 actually provides a general interface for all sorts of languages, not |
4186 just Asian languages (although they are generally the most complicated | 4303 just Asian languages (although they are generally the most complicated |
4188 | 4305 |
4189 @file{mule-charset.*} and @file{mule-coding.*} provide the heart of the | 4306 @file{mule-charset.*} and @file{mule-coding.*} provide the heart of the |
4190 XEmacs MULE support. @file{mule-charset.*} implements the @dfn{charset} | 4307 XEmacs MULE support. @file{mule-charset.*} implements the @dfn{charset} |
4191 Lisp object type, which encapsulates a character set (an ordered one- or | 4308 Lisp object type, which encapsulates a character set (an ordered one- or |
4192 two-dimensional set of characters, such as US ASCII or JISX0208 Japanese | 4309 two-dimensional set of characters, such as US ASCII or JISX0208 Japanese |
4193 Kanji). | 4310 Kanji). |
4194 | 4311 |
4195 @file{mule-coding.*} implements the @dfn{coding-system} Lisp object | 4312 @file{mule-coding.*} implements the @dfn{coding-system} Lisp object |
4196 type, which encapsulates a method of converting between different | 4313 type, which encapsulates a method of converting between different |
4197 encodings. An encoding is a representation of a stream of characters, | 4314 encodings. An encoding is a representation of a stream of characters, |
4198 possibly from multiple character sets, using a stream of bytes or words, | 4315 possibly from multiple character sets, using a stream of bytes or words, |
4221 be elsewhere. | 4338 be elsewhere. |
4222 | 4339 |
4223 | 4340 |
4224 | 4341 |
4225 @example | 4342 @example |
4226 9400 intl.c | 4343 intl.c |
4227 @end example | 4344 @end example |
4228 | 4345 |
4229 This provides some miscellaneous internationalization code for | 4346 This provides some miscellaneous internationalization code for |
4230 implementing message translation and interfacing to the Ximp input | 4347 implementing message translation and interfacing to the Ximp input |
4231 method. None of this code is currently working. | 4348 method. None of this code is currently working. |
4232 | 4349 |
4233 | 4350 |
4234 | 4351 |
4235 @example | 4352 @example |
4236 1764 iso-wide.h | 4353 iso-wide.h |
4237 @end example | 4354 @end example |
4238 | 4355 |
4239 This contains leftover code from an earlier implementation of | 4356 This contains leftover code from an earlier implementation of |
4240 Asian-language support, and is not currently used. | 4357 Asian-language support, and is not currently used. |
4241 | 4358 |
4258 * Vector:: | 4375 * Vector:: |
4259 * Bit Vector:: | 4376 * Bit Vector:: |
4260 * Symbol:: | 4377 * Symbol:: |
4261 * Marker:: | 4378 * Marker:: |
4262 * String:: | 4379 * String:: |
4263 * Bytecode:: | 4380 * Compiled Function:: |
4264 @end menu | 4381 @end menu |
4265 | 4382 |
4266 @node Introduction to Allocation | 4383 @node Introduction to Allocation |
4267 @section Introduction to Allocation | 4384 @section Introduction to Allocation |
4268 | 4385 |
4292 @itemize @bullet | 4409 @itemize @bullet |
4293 @item | 4410 @item |
4294 (a) Those for whom the value directly represents the contents of the | 4411 (a) Those for whom the value directly represents the contents of the |
4295 Lisp object. Only two types are in this category: integers and | 4412 Lisp object. Only two types are in this category: integers and |
4296 characters. No special allocation or garbage collection is necessary | 4413 characters. No special allocation or garbage collection is necessary |
4297 for such objects. Lisp objects of these types do not need to be | 4414 for such objects. Lisp objects of these types do not need to be |
4298 @code{GCPRO}ed. | 4415 @code{GCPRO}ed. |
4299 @end itemize | 4416 @end itemize |
4300 | 4417 |
4301 In the remaining three categories, the value is a pointer to a | 4418 In the remaining three categories, the value is a pointer to a |
4302 structure. | 4419 structure. |
4335 | 4452 |
4336 @itemize @bullet | 4453 @itemize @bullet |
4337 @item | 4454 @item |
4338 (c) Those lrecords that are allocated in frob blocks (see above). This | 4455 (c) Those lrecords that are allocated in frob blocks (see above). This |
4339 includes the objects that are most common and relatively small, and | 4456 includes the objects that are most common and relatively small, and |
4340 includes floats, bytecodes, symbols (when not in category (b)), extents, | 4457 includes floats, compiled functions, symbols (when not in category (b)), |
4341 events, and markers. With the cleanup of frob blocks done in 19.12, | 4458 extents, events, and markers. With the cleanup of frob blocks done in |
4342 it's not terribly hard to add more objects to this category, but it's a | 4459 19.12, it's not terribly hard to add more objects to this category, but |
4343 bit trickier than adding an object type to type (d) (esp. if the object | 4460 it's a bit trickier than adding an object type to type (d) (esp. if the |
4344 needs a finalization method), and is not likely to save much space | 4461 object needs a finalization method), and is not likely to save much |
4345 unless the object is small and there are many of them. (In fact, if | 4462 space unless the object is small and there are many of them. (In fact, |
4346 there are very few of them, it might actually waste space.) | 4463 if there are very few of them, it might actually waste space.) |
4347 @item | 4464 @item |
4348 (d) Those lrecords that are individually @code{malloc()}ed. These are | 4465 (d) Those lrecords that are individually @code{malloc()}ed. These are |
4349 called @dfn{lcrecords}. All other types are in this category. Adding a | 4466 called @dfn{lcrecords}. All other types are in this category. Adding a |
4350 new type to this category is comparatively easy, and all types added | 4467 new type to this category is comparatively easy, and all types added |
4351 since 19.8 (when the current allocation scheme was devised, by Richard | 4468 since 19.8 (when the current allocation scheme was devised, by Richard |
5069 string data (which would normally be obtained from the now-non-existent | 5186 string data (which would normally be obtained from the now-non-existent |
5070 @code{struct Lisp_String}) at the beginning of the dead string data gap. | 5187 @code{struct Lisp_String}) at the beginning of the dead string data gap. |
5071 The string compactor recognizes this special 0xFFFFFFFF marker and | 5188 The string compactor recognizes this special 0xFFFFFFFF marker and |
5072 handles it correctly. | 5189 handles it correctly. |
5073 | 5190 |
5074 @node Bytecode | 5191 @node Compiled Function |
5075 @section Bytecode | 5192 @section Compiled Function |
5076 | 5193 |
5077 Not yet documented. | 5194 Not yet documented. |
5078 | 5195 |
5079 @node Events and the Event Loop, Evaluation; Stack Frames; Bindings, Allocation of Objects in XEmacs Lisp, Top | 5196 @node Events and the Event Loop, Evaluation; Stack Frames; Bindings, Allocation of Objects in XEmacs Lisp, Top |
5080 @chapter Events and the Event Loop | 5197 @chapter Events and the Event Loop |
5203 at work in XEmacs, under TTY's (TTY's are simpler than X | 5320 at work in XEmacs, under TTY's (TTY's are simpler than X |
5204 so we'll look at this first): | 5321 so we'll look at this first): |
5205 | 5322 |
5206 @noindent | 5323 @noindent |
5207 @example | 5324 @example |
5208 asynch. asynch. asynch. asynch. [Collectors in | 5325 asynch. asynch. asynch. asynch. [Collectors in |
5209 kbd events kbd events process process the OS] | 5326 kbd events kbd events process process the OS] |
5210 | | output output | 5327 | | output output |
5211 | | | | | 5328 | | | | |
5212 | | | | SIGINT, [signal handlers | 5329 | | | | SIGINT, [signal handlers |
5213 | | | | SIGQUIT, in XEmacs] | 5330 | | | | SIGQUIT, in XEmacs] |
5214 V V V V SIGWINCH, | 5331 V V V V SIGWINCH, |
5215 file file file file SIGALRM | 5332 file file file file SIGALRM |
5216 desc. desc. desc. desc. | | 5333 desc. desc. desc. desc. | |
5217 (TTY) (TTY) (pipe) (pipe) | | 5334 (TTY) (TTY) (pipe) (pipe) | |
5218 | | | | fake timeouts | 5335 | | | | fake timeouts |
5222 | | | | | | | 5339 | | | | | | |
5223 | | | | | | | 5340 | | | | | | |
5224 | | | | | | | 5341 | | | | | | |
5225 V V V V V V | 5342 V V V V V V |
5226 ------>-----------<----------------<---------------- | 5343 ------>-----------<----------------<---------------- |
5227 | | 5344 | |
5228 | | 5345 | |
5229 | [collected using select() in emacs_tty_next_event() | 5346 | [collected using select() in emacs_tty_next_event() |
5230 | and converted to the appropriate Emacs event] | 5347 | and converted to the appropriate Emacs event] |
5231 | | 5348 | |
5232 | | 5349 | |
5233 V (above this line is TTY-specific) | 5350 V (above this line is TTY-specific) |
5234 Emacs ------------------------------------------------ | 5351 Emacs ----------------------------------------------- |
5235 event (below this line is the generic event mechanism) | 5352 event (below this line is the generic event mechanism) |
5236 | | 5353 | |
5237 | | 5354 | |
5238 was there if not, call | 5355 was there if not, call |
5239 a SIGINT? emacs_tty_next_event() | 5356 a SIGINT? emacs_tty_next_event() |
5240 | | | 5357 | | |
5241 | | | 5358 | | |
5242 | | | 5359 | | |
5243 V V | 5360 V V |
5244 --->-------<---- | 5361 --->------<---- |
5245 | | 5362 | |
5246 | [collected in event_stream_next_event(); | 5363 | [collected in event_stream_next_event(); |
5247 | SIGINT is converted using maybe_read_quit_event()] | 5364 | SIGINT is converted using maybe_read_quit_event()] |
5248 V | 5365 V |
5249 Emacs | 5366 Emacs |
5250 event | 5367 event |
5251 | | 5368 | |
5252 \---->------>----- maybe_kbd_translate() ---->---\ | 5369 \---->------>----- maybe_kbd_translate() ---->---\ |
5253 | | 5370 | |
5254 | | 5371 | |
5255 | | 5372 | |
5256 command event queue | | 5373 command event queue | |
5257 if not from command | 5374 if not from command |
5258 (contains events that were event queue, call | 5375 (contains events that were event queue, call |
5259 read earlier but not processed, event_stream_next_event() | 5376 read earlier but not processed, event_stream_next_event() |
5260 typically when waiting in a | | 5377 typically when waiting in a | |
5261 sit-for, sleep-for, etc. for | | 5378 sit-for, sleep-for, etc. for | |
5262 a particular event to be received) | | 5379 a particular event to be received) | |
5263 | | | 5380 | | |
5264 | | | 5381 | | |
5265 V V | 5382 V V |
5266 ---->------------------------------------<---- | 5383 ---->------------------------------------<---- |
5267 | | 5384 | |
5268 | [collected in | 5385 | [collected in |
5269 | next_event_internal()] | 5386 | next_event_internal()] |
5270 | | 5387 | |
5271 unread- unread- event from | | 5388 unread- unread- event from | |
5272 command- command- keyboard else, call | 5389 command- command- keyboard else, call |
5273 events event macro next_event_internal() | 5390 events event macro next_event_internal() |
5274 | | | | | 5391 | | | | |
5306 it's the same as the above diagram): | 5423 it's the same as the above diagram): |
5307 | 5424 |
5308 @example | 5425 @example |
5309 asynch. asynch. asynch. asynch. [Collectors in | 5426 asynch. asynch. asynch. asynch. [Collectors in |
5310 kbd kbd process process the OS] | 5427 kbd kbd process process the OS] |
5311 events events output output | 5428 events events output output |
5312 | | | | | 5429 | | | | |
5313 | | | | asynch. asynch. [Collectors in the | 5430 | | | | asynch. asynch. [Collectors in the |
5314 | | | | X X OS and X Window System] | 5431 | | | | X X OS and X Window System] |
5315 | | | | events events | 5432 | | | | events events |
5316 | | | | | | | 5433 | | | | | | |
5317 | | | | | | | 5434 | | | | | | |
5318 | | | | | | SIGINT, [signal handlers | 5435 | | | | | | SIGINT, [signal handlers |
5319 | | | | | | SIGQUIT, in XEmacs] | 5436 | | | | | | SIGQUIT, in XEmacs] |
5320 | | | | | | SIGWINCH, | 5437 | | | | | | SIGWINCH, |
5321 | | | | | | SIGALRM | 5438 | | | | | | SIGALRM |
5322 | | | | | | | | 5439 | | | | | | | |
5323 | | | | | | | | 5440 | | | | | | | |
5324 | | | | | | | timeouts | 5441 | | | | | | | timeouts |
5325 | | | | | | | | | 5442 | | | | | | | | |
5326 | | | | | | | | | 5443 | | | | | | | | |
5327 | | | | | | V | | 5444 | | | | | | V | |
5328 V V V V V V fake | | 5445 V V V V V V fake | |
5329 file file file file file file file | | 5446 file file file file file file file | |
5330 desc. desc. desc. desc. desc. desc. desc. | | 5447 desc. desc. desc. desc. desc. desc. desc. | |
5331 (TTY) (TTY) (pipe) (pipe) (socket) (socket) (pipe) | | 5448 (TTY) (TTY) (pipe) (pipe) (socket) (socket) (pipe) | |
5332 | | | | | | | | | 5449 | | | | | | | | |
5333 | | | | | | | | | 5450 | | | | | | | | |
5334 | | | | | | | | | 5451 | | | | | | | | |
5335 V V V V V V V V | 5452 V V V V V V V V |
5336 --->----------------------------------------<---------<------ | 5453 --->----------------------------------------<---------<------ |
5337 | | | | 5454 | | | |
5338 | | | [collected using select() in | 5455 | | |[collected using select() in |
5339 | | | _XtWaitForSomething(), called | 5456 | | | _XtWaitForSomething(), called |
5340 | | | from XtAppProcessEvent(), called | 5457 | | | from XtAppProcessEvent(), called |
5341 | | | in emacs_Xt_next_event(); | 5458 | | | in emacs_Xt_next_event(); |
5342 | | | dispatched to various callbacks] | 5459 | | | dispatched to various callbacks] |
5343 | | | | 5460 | | | |
5344 | | | | 5461 | | | |
5345 emacs_Xt_ p_s_callback(), | [popup_selection_callback] | 5462 emacs_Xt_ p_s_callback(), | [popup_selection_callback] |
5346 event_handler() x_u_v_s_callback(),| [x_update_vertical_scrollbar_ | 5463 event_handler() x_u_v_s_callback(),| [x_update_vertical_scrollbar_ |
5347 | x_u_h_s_callback(),| callback] | 5464 | x_u_h_s_callback(),| callback] |
5348 | search_callback() | [x_update_horizontal_scrollbar_ | 5465 | search_callback() | [x_update_horizontal_scrollbar_ |
5349 | | | callback] | 5466 | | | callback] |
5350 | | | | 5467 | | | |
5351 | | | | 5468 | | | |
5352 enqueue_Xt_ signal_special_ | | 5469 enqueue_Xt_ signal_special_ | |
5353 dispatch_event() Xt_user_event() | | 5470 dispatch_event() Xt_user_event() | |
5354 [maybe multiple | | | 5471 [maybe multiple | | |
5360 | | | | 5477 | | | |
5361 V V | | 5478 V V | |
5362 -->----------<-- | | 5479 -->----------<-- | |
5363 | | | 5480 | | |
5364 | | | 5481 | | |
5365 dispatch Xt_what_callback() | 5482 dispatch Xt_what_callback() |
5366 event sets flags | 5483 event sets flags |
5367 queue | | 5484 queue | |
5368 | | | 5485 | | |
5369 | | | 5486 | | |
5370 | | | 5487 | | |
5371 | | | 5488 | | |
5372 ---->-----------<-------- | 5489 ---->-----------<-------- |
5373 | | 5490 | |
5374 | | 5491 | |
5375 | [collected and converted as appropriate in | 5492 | [collected and converted as appropriate in |
5376 | emacs_Xt_next_event()] | 5493 | emacs_Xt_next_event()] |
5377 | | 5494 | |
5378 | | 5495 | |
5379 V (above this line is Xt-specific) | 5496 V (above this line is Xt-specific) |
5380 Emacs ------------------------------------------------ | 5497 Emacs ------------------------------------------------ |
5381 event (below this line is the generic event mechanism) | 5498 event (below this line is the generic event mechanism) |
5382 | | 5499 | |
5383 | | 5500 | |
5384 was there if not, call | 5501 was there if not, call |
5385 a SIGINT? emacs_Xt_next_event() | 5502 a SIGINT? emacs_Xt_next_event() |
5386 | | | 5503 | | |
5398 \---->------>----- maybe_kbd_translate() -->-----\ | 5515 \---->------>----- maybe_kbd_translate() -->-----\ |
5399 | | 5516 | |
5400 | | 5517 | |
5401 | | 5518 | |
5402 command event queue | | 5519 command event queue | |
5403 if not from command | 5520 if not from command |
5404 (contains events that were event queue, call | 5521 (contains events that were event queue, call |
5405 read earlier but not processed, event_stream_next_event() | 5522 read earlier but not processed, event_stream_next_event() |
5406 typically when waiting in a | | 5523 typically when waiting in a | |
5407 sit-for, sleep-for, etc. for | | 5524 sit-for, sleep-for, etc. for | |
5408 a particular event to be received) | | 5525 a particular event to be received) | |
5409 | | | 5526 | | |
5410 | | | 5527 | | |
5411 V V | 5528 V V |
5412 ---->----------------------------------<------ | 5529 ---->----------------------------------<------ |
5413 | | 5530 | |
5414 | [collected in | 5531 | [collected in |
5415 | next_event_internal()] | 5532 | next_event_internal()] |
5416 | | 5533 | |
5417 unread- unread- event from | | 5534 unread- unread- event from | |
5418 command- command- keyboard else, call | 5535 command- command- keyboard else, call |
5419 events event macro next_event_internal() | 5536 events event macro next_event_internal() |
5420 | | | | | 5537 | | | | |
5493 @section Evaluation | 5610 @section Evaluation |
5494 | 5611 |
5495 @code{Feval()} evaluates the form (a Lisp object) that is passed to | 5612 @code{Feval()} evaluates the form (a Lisp object) that is passed to |
5496 it. Note that evaluation is only non-trivial for two types of objects: | 5613 it. Note that evaluation is only non-trivial for two types of objects: |
5497 symbols and conses. A symbol is evaluated simply by calling | 5614 symbols and conses. A symbol is evaluated simply by calling |
5498 symbol-value on it and returning the value. | 5615 @code{symbol-value} on it and returning the value. |
5499 | 5616 |
5500 Evaluating a cons means calling a function. First, @code{eval} checks | 5617 Evaluating a cons means calling a function. First, @code{eval} checks |
5501 to see if garbage-collection is necessary, and calls | 5618 to see if garbage-collection is necessary, and calls |
5502 @code{Fgarbage_collect()} if so. It then increases the evaluation depth | 5619 @code{garbage_collect_1()} if so. It then increases the evaluation |
5503 by 1 (@code{lisp_eval_depth}, which is always less than @code{max_lisp_eval_depth}) and adds an | 5620 depth by 1 (@code{lisp_eval_depth}, which is always less than |
5504 element to the linked list of @code{struct backtrace}'s | 5621 @code{max_lisp_eval_depth}) and adds an element to the linked list of |
5505 (@code{backtrace_list}). Each such structure contains a pointer to the | 5622 @code{struct backtrace}'s (@code{backtrace_list}). Each such structure |
5506 function being called plus a list of the function's arguments. | 5623 contains a pointer to the function being called plus a list of the |
5507 Originally these values are stored unevalled, and as they are evaluated, | 5624 function's arguments. Originally these values are stored unevalled, and |
5508 the backtrace structure is updated. Garbage collection pays attention | 5625 as they are evaluated, the backtrace structure is updated. Garbage |
5509 to the objects pointed to in the backtrace structures (garbage | 5626 collection pays attention to the objects pointed to in the backtrace |
5510 collection might happen while a function is being called or while an | 5627 structures (garbage collection might happen while a function is being |
5511 argument is being evaluated, and there could easily be no other | 5628 called or while an argument is being evaluated, and there could easily |
5512 references to the arguments in the argument list; once an argument is | 5629 be no other references to the arguments in the argument list; once an |
5513 evaluated, however, the unevalled version is not needed by eval, and so | 5630 argument is evaluated, however, the unevalled version is not needed by |
5514 the backtrace structure is changed). | 5631 eval, and so the backtrace structure is changed). |
5515 | 5632 |
5516 At this point, the function to be called is determined by looking at | 5633 At this point, the function to be called is determined by looking at |
5517 the car of the cons (if this is a symbol, its function definition is | 5634 the car of the cons (if this is a symbol, its function definition is |
5518 retrieved and the process repeated). The function should then consist | 5635 retrieved and the process repeated). The function should then consist |
5519 of either a @code{Lisp_Subr} (built-in function), a | 5636 of either a @code{Lisp_Subr} (built-in function written in C), a |
5520 @code{Lisp_Compiled_Function} object, or a cons whose car is the symbol | 5637 @code{Lisp_Compiled_Function} object, or a cons whose car is one of the |
5521 @code{autoload}, @code{macro} or @code{lambda}. | 5638 symbols @code{autoload}, @code{macro} or @code{lambda}. |
5522 | 5639 |
5523 If the function is a @code{Lisp_Subr}, the lisp object points to a | 5640 If the function is a @code{Lisp_Subr}, the lisp object points to a |
5524 @code{struct Lisp_Subr} (created by @code{DEFUN()}), which contains a | 5641 @code{struct Lisp_Subr} (created by @code{DEFUN()}), which contains a |
5525 pointer to the C function, a minimum and maximum number of arguments | 5642 pointer to the C function, a minimum and maximum number of arguments |
5526 (possibly the special constants @code{MANY} or @code{UNEVALLED}), a | 5643 (or possibly the special constants @code{MANY} or @code{UNEVALLED}), a |
5527 pointer to the symbol referring to that subr, and a couple of other | 5644 pointer to the symbol referring to that subr, and a couple of other |
5528 things. If the subr wants its arguments @code{UNEVALLED}, they are | 5645 things. If the subr wants its arguments @code{UNEVALLED}, they are |
5529 passed raw as a list. Otherwise, an array of evaluated arguments is | 5646 passed raw as a list. Otherwise, an array of evaluated arguments is |
5530 created and put into the backtrace structure, and either passed whole | 5647 created and put into the backtrace structure, and either passed whole |
5531 (@code{MANY}) or each argument is passed as a C argument. | 5648 (@code{MANY}) or each argument is passed as a C argument. |
5532 | 5649 |
5533 If the function is a @code{Lisp_Compiled_Function} object or a lambda, | 5650 If the function is a @code{Lisp_Compiled_Function}, |
5534 @code{apply_lambda()} is called. If the function is a macro, | 5651 @code{funcall_compiled_function()} is called. If the function is a |
5535 [..... fill in] is done. If the function is an autoload, | 5652 lambda list, @code{funcall_lambda()} is called. If the function is a |
5653 macro, [..... fill in] is done. If the function is an autoload, | |
5536 @code{do_autoload()} is called to load the definition and then eval | 5654 @code{do_autoload()} is called to load the definition and then eval |
5537 starts over [explain this more]. | 5655 starts over [explain this more]. |
5538 | 5656 |
5539 When @code{Feval} exits, the evaluation depth is reduced by one, the | 5657 When @code{Feval()} exits, the evaluation depth is reduced by one, the |
5540 debugger is called if appropriate, and the current backtrace structure | 5658 debugger is called if appropriate, and the current backtrace structure |
5541 is removed from the list. | 5659 is removed from the list. |
5542 | 5660 |
5543 @code{apply_lambda()} is passed a function, a list of arguments, and a | 5661 Both @code{funcall_compiled_function()} and @code{funcall_lambda()} need |
5544 flag indicating whether to evaluate the arguments. It creates an array | 5662 to go through the list of formal parameters to the function and bind |
5545 of (possibly) evaluated arguments and fixes up the backtrace structure, | 5663 them to the actual arguments, checking for @code{&rest} and |
5546 just like eval does. Then it calls @code{funcall_lambda()}. | 5664 @code{&optional} symbols in the formal parameters and making sure the |
5547 | 5665 number of actual arguments is correct. |
5548 @code{funcall_lambda()} goes through the formal arguments to the | 5666 @code{funcall_compiled_function()} can do this a little more |
5549 function and binds them to the actual arguments, checking for | 5667 efficiently, since the formal parameter list can be checked for sanity |
5550 @code{&rest} and @code{&optional} symbols in the formal arguments and | 5668 when the compiled function object is created. |
5551 making sure the number of actual arguments is correct. Then either | 5669 |
5552 @code{progn} or @code{byte-code} is called to actually execute the body | 5670 @code{funcall_lambda()} simply calls @code{Fprogn} to execute the code |
5553 and return a value. | 5671 in the lambda list. |
5554 | 5672 |
5555 @code{Ffuncall()} implements Lisp @code{funcall}. @code{(funcall fun | 5673 @code{funcall_compiled_function()} calls the real byte-code interpreter |
5674 @code{execute_optimized_program()} on the byte-code instructions, which | |
5675 are converted into an internal form for faster execution. | |
5676 | |
5677 When a compiled function is executed for the first time by | |
5678 @code{funcall_compiled_function()}, or when it is @code{Fpurecopy()}ed | |
5679 during the dump phase of building XEmacs, the byte-code instructions are | |
5680 converted from a @code{Lisp_String} (which is inefficient to access, | |
5681 especially in the presence of MULE) into a @code{Lisp_Opaque} object | |
5682 containing an array of unsigned char, which can be directly executed by | |
5683 the byte-code interpreter. At this time the byte code is also analyzed | |
5684 for validity and transformed into a more optimized form, so that | |
5685 @code{execute_optimized_program()} can really fly. | |
5686 | |
5687 Here are some of the optimizations performed by the internal byte-code | |
5688 transformer: | |
5689 @enumerate | |
5690 @item | |
5691 References to the @code{constants} array are checked for out-of-range | |
5692 indices, so that the byte interpreter doesn't have to. | |
5693 @item | |
5694 References to the @code{constants} array that will be used as a Lisp | |
5695 variable are checked for being correct non-constant (i.e. not @code{t}, | |
5696 @code{nil}, or @code{keywordp}) symbols, so that the byte interpreter | |
5697 doesn't have to. | |
5698 @item | |
5699 The maxiumum number of variable bindings in the byte-code is | |
5700 pre-computed, so that space on the @code{specpdl} stack can be | |
5701 pre-reserved once for the whole function execution. | |
5702 @item | |
5703 All byte-code jumps are relative to the current program counter instead | |
5704 of the start of the program, thereby saving a register. | |
5705 @item | |
5706 One-byte relative jumps are converted from the byte-code form of unsigned | |
5707 chars offset by 127 to machine-friendly signed chars. | |
5708 @end enumerate | |
5709 | |
5710 Of course, this transformation of the @code{instructions} should not be | |
5711 visible to the user, so @code{Fcompiled_function_instructions()} needs | |
5712 to know how to convert the optimized opaque object back into a Lisp | |
5713 string that is identical to the original string from the @file{.elc} | |
5714 file. (Actually, the resulting string may (rarely) contain slightly | |
5715 different, yet equivalent, byte code.) | |
5716 | |
5717 @code{Ffuncall()} implements Lisp @code{funcall}. @code{(funcall fun | |
5556 x1 x2 x3 ...)} is equivalent to @code{(eval (list fun (quote x1) (quote | 5718 x1 x2 x3 ...)} is equivalent to @code{(eval (list fun (quote x1) (quote |
5557 x2) (quote x3) ...))}. @code{Ffuncall()} contains its own code to do | 5719 x2) (quote x3) ...))}. @code{Ffuncall()} contains its own code to do |
5558 the evaluation, however, and is almost identical to eval. | 5720 the evaluation, however, and is very similar to @code{Feval()}. |
5559 | 5721 |
5560 @code{Fapply()} implements Lisp @code{apply}, which is very similar to | 5722 From the performance point of view, it is worth knowing that most of the |
5723 time in Lisp evaluation is spent executing @code{Lisp_Subr} and | |
5724 @code{Lisp_Compiled_Function} objects via @code{Ffuncall()} (not | |
5725 @code{Feval()}). | |
5726 | |
5727 @code{Fapply()} implements Lisp @code{apply}, which is very similar to | |
5561 @code{funcall} except that if the last argument is a list, the result is the | 5728 @code{funcall} except that if the last argument is a list, the result is the |
5562 same as if each of the arguments in the list had been passed separately. | 5729 same as if each of the arguments in the list had been passed separately. |
5563 @code{Fapply()} does some business to expand the last argument if it's a | 5730 @code{Fapply()} does some business to expand the last argument if it's a |
5564 list, then calls @code{Ffuncall()} to do the work. | 5731 list, then calls @code{Ffuncall()} to do the work. |
5565 | 5732 |
5566 @code{apply1()}, @code{call0()}, @code{call1()}, @code{call2()}, and | 5733 @code{apply1()}, @code{call0()}, @code{call1()}, @code{call2()}, and |
5567 @code{call3()} call a function, passing it the argument(s) given (the | 5734 @code{call3()} call a function, passing it the argument(s) given (the |
5568 arguments are given as separate C arguments rather than being passed as | 5735 arguments are given as separate C arguments rather than being passed as |
5569 an array). @code{apply1()} uses @code{apply} while the others use | 5736 an array). @code{apply1()} uses @code{Fapply()} while the others use |
5570 @code{funcall}. | 5737 @code{Ffuncall()} to do the real work. |
5571 | 5738 |
5572 @node Dynamic Binding; The specbinding Stack; Unwind-Protects | 5739 @node Dynamic Binding; The specbinding Stack; Unwind-Protects |
5573 @section Dynamic Binding; The specbinding Stack; Unwind-Protects | 5740 @section Dynamic Binding; The specbinding Stack; Unwind-Protects |
5574 | 5741 |
5575 @example | 5742 @example |
5576 struct specbinding | 5743 struct specbinding |
5577 @{ | 5744 @{ |
5578 Lisp_Object symbol, old_value; | 5745 Lisp_Object symbol; |
5746 Lisp_Object old_value; | |
5579 Lisp_Object (*func) (Lisp_Object); /* for unwind-protect */ | 5747 Lisp_Object (*func) (Lisp_Object); /* for unwind-protect */ |
5580 @}; | 5748 @}; |
5581 @end example | 5749 @end example |
5582 | 5750 |
5583 @code{struct specbinding} is used for local-variable bindings and | 5751 @code{struct specbinding} is used for local-variable bindings and |
5627 | 5795 |
5628 @code{or}, @code{and}, @code{if}, @code{cond}, @code{progn}, | 5796 @code{or}, @code{and}, @code{if}, @code{cond}, @code{progn}, |
5629 @code{prog1}, @code{prog2}, @code{setq}, @code{quote}, @code{function}, | 5797 @code{prog1}, @code{prog2}, @code{setq}, @code{quote}, @code{function}, |
5630 @code{let*}, @code{let}, @code{while} | 5798 @code{let*}, @code{let}, @code{while} |
5631 | 5799 |
5632 All of these are very simple and work as expected, calling | 5800 All of these are very simple and work as expected, calling |
5633 @code{Feval()} or @code{Fprogn()} as necessary and (in the case of | 5801 @code{Feval()} or @code{Fprogn()} as necessary and (in the case of |
5634 @code{let} and @code{let*}) using @code{specbind()} to create bindings | 5802 @code{let} and @code{let*}) using @code{specbind()} to create bindings |
5635 and @code{unbind_to()} to undo the bindings when finished. Note that | 5803 and @code{unbind_to()} to undo the bindings when finished. |
5636 these functions do a lot of @code{GCPRO}ing to protect their arguments | 5804 |
5637 from garbage collection because they call @code{Feval()} (@pxref{Garbage | 5805 Note that, with the exeption of @code{Fprogn}, these functions are |
5638 Collection}). | 5806 typically called in real life only in interpreted code, since the byte |
5807 compiler knows how to convert calls to these functions directly into | |
5808 byte code. | |
5639 | 5809 |
5640 @node Catch and Throw | 5810 @node Catch and Throw |
5641 @section Catch and Throw | 5811 @section Catch and Throw |
5642 | 5812 |
5643 @example | 5813 @example |
5885 can temporarily change the current buffer using @code{set-buffer} (often | 6055 can temporarily change the current buffer using @code{set-buffer} (often |
5886 enclosed in a @code{save-excursion} so that the former current buffer | 6056 enclosed in a @code{save-excursion} so that the former current buffer |
5887 gets restored when the code is finished). However, calling | 6057 gets restored when the code is finished). However, calling |
5888 @code{set-buffer} will NOT cause a permanent change in the current | 6058 @code{set-buffer} will NOT cause a permanent change in the current |
5889 buffer. The reason for this is that the top-level event loop sets | 6059 buffer. The reason for this is that the top-level event loop sets |
5890 @code{current_buffer} to the buffer of the selected window, each time | 6060 @code{current_buffer} to the buffer of the selected window, each time |
5891 it finishes executing a user command. | 6061 it finishes executing a user command. |
5892 @end enumerate | 6062 @end enumerate |
5893 | 6063 |
5894 Make sure you understand the distinction between @dfn{current buffer} | 6064 Make sure you understand the distinction between @dfn{current buffer} |
5895 and @dfn{buffer of the selected window}, and the distinction between | 6065 and @dfn{buffer of the selected window}, and the distinction between |
6346 @end menu | 6516 @end menu |
6347 | 6517 |
6348 @node Japanese EUC (Extended Unix Code) | 6518 @node Japanese EUC (Extended Unix Code) |
6349 @subsection Japanese EUC (Extended Unix Code) | 6519 @subsection Japanese EUC (Extended Unix Code) |
6350 | 6520 |
6351 This encompasses the character sets Printing-ASCII, Japanese-JISSX0201, | 6521 This encompasses the character sets Printing-ASCII, Japanese-JISX0201, |
6352 and Japanese-JISX0208-Kana (half-width katakana, the right half of | 6522 and Japanese-JISX0208-Kana (half-width katakana, the right half of |
6353 JISX0201). It uses 8-bit bytes. | 6523 JISX0201). It uses 8-bit bytes. |
6354 | 6524 |
6355 Note that Printing-ASCII and Japanese-JISX0201-Kana are 94-character | 6525 Note that Printing-ASCII and Japanese-JISX0201-Kana are 94-character |
6356 charsets, while Japanese-JISX0208 is a 94x94-character charset. | 6526 charsets, while Japanese-JISX0208 is a 94x94-character charset. |
6536 @node CCL | 6706 @node CCL |
6537 @section CCL | 6707 @section CCL |
6538 | 6708 |
6539 @example | 6709 @example |
6540 CCL PROGRAM SYNTAX: | 6710 CCL PROGRAM SYNTAX: |
6541 CCL_PROGRAM := (CCL_MAIN_BLOCK | 6711 CCL_PROGRAM := (CCL_MAIN_BLOCK |
6542 [ CCL_EOF_BLOCK ]) | 6712 [ CCL_EOF_BLOCK ]) |
6543 | 6713 |
6544 CCL_MAIN_BLOCK := CCL_BLOCK | 6714 CCL_MAIN_BLOCK := CCL_BLOCK |
6545 CCL_EOF_BLOCK := CCL_BLOCK | 6715 CCL_EOF_BLOCK := CCL_BLOCK |
6546 | 6716 |
6547 CCL_BLOCK := STATEMENT | (STATEMENT [STATEMENT ...]) | 6717 CCL_BLOCK := STATEMENT | (STATEMENT [STATEMENT ...]) |
6548 STATEMENT := | 6718 STATEMENT := |
6549 SET | IF | BRANCH | LOOP | REPEAT | BREAK | 6719 SET | IF | BRANCH | LOOP | REPEAT | BREAK |
6550 | READ | WRITE | 6720 | READ | WRITE |
6551 | 6721 |
6552 SET := (REG = EXPRESSION) | (REG SELF_OP EXPRESSION) | 6722 SET := (REG = EXPRESSION) | (REG SELF_OP EXPRESSION) |
6553 | INT-OR-CHAR | 6723 | INT-OR-CHAR |
6554 | 6724 |
6555 EXPRESSION := ARG | (EXPRESSION OP ARG) | 6725 EXPRESSION := ARG | (EXPRESSION OP ARG) |
6556 | 6726 |
6557 IF := (if EXPRESSION CCL_BLOCK CCL_BLOCK) | 6727 IF := (if EXPRESSION CCL_BLOCK CCL_BLOCK) |
6558 BRANCH := (branch EXPRESSION CCL_BLOCK [CCL_BLOCK ...]) | 6728 BRANCH := (branch EXPRESSION CCL_BLOCK [CCL_BLOCK ...]) |
6559 LOOP := (loop STATEMENT [STATEMENT ...]) | 6729 LOOP := (loop STATEMENT [STATEMENT ...]) |
6560 BREAK := (break) | 6730 BREAK := (break) |
6561 REPEAT := (repeat) | 6731 REPEAT := (repeat) |
6562 | (write-repeat [REG | INT-OR-CHAR | string]) | 6732 | (write-repeat [REG | INT-OR-CHAR | string]) |
6563 | (write-read-repeat REG [INT-OR-CHAR | string | ARRAY]?) | 6733 | (write-read-repeat REG [INT-OR-CHAR | string | ARRAY]?) |
6564 READ := (read REG) | (read REG REG) | 6734 READ := (read REG) | (read REG REG) |
6565 | (read-if REG ARITH_OP ARG CCL_BLOCK CCL_BLOCK) | 6735 | (read-if REG ARITH_OP ARG CCL_BLOCK CCL_BLOCK) |
6566 | (read-branch REG CCL_BLOCK [CCL_BLOCK ...]) | 6736 | (read-branch REG CCL_BLOCK [CCL_BLOCK ...]) |
6567 WRITE := (write REG) | (write REG REG) | 6737 WRITE := (write REG) | (write REG REG) |
6568 | (write INT-OR-CHAR) | (write STRING) | STRING | 6738 | (write INT-OR-CHAR) | (write STRING) | STRING |
6569 | (write REG ARRAY) | 6739 | (write REG ARRAY) |
6570 END := (end) | 6740 END := (end) |
6571 | 6741 |
6572 REG := r0 | r1 | r2 | r3 | r4 | r5 | r6 | r7 | 6742 REG := r0 | r1 | r2 | r3 | r4 | r5 | r6 | r7 |
6573 ARG := REG | INT-OR-CHAR | 6743 ARG := REG | INT-OR-CHAR |
6574 OP := + | - | * | / | % | & | '|' | ^ | << | >> | <8 | >8 | // | 6744 OP := + | - | * | / | % | & | '|' | ^ | << | >> | <8 | >8 | // |
6575 | < | > | == | <= | >= | != | 6745 | < | > | == | <= | >= | != |
6576 SELF_OP := | 6746 SELF_OP := |
6577 += | -= | *= | /= | %= | &= | '|=' | ^= | <<= | >>= | 6747 += | -= | *= | /= | %= | &= | '|=' | ^= | <<= | >>= |
6578 ARRAY := '[' INT-OR-CHAR ... ']' | 6748 ARRAY := '[' INT-OR-CHAR ... ']' |
6579 INT-OR-CHAR := INT | CHAR | 6749 INT-OR-CHAR := INT | CHAR |
6580 | 6750 |
6581 MACHINE CODE: | 6751 MACHINE CODE: |
6582 | 6752 |
6583 The machine code consists of a vector of 32-bit words. | 6753 The machine code consists of a vector of 32-bit words. |
6584 The first such word specifies the start of the EOF section of the code; | 6754 The first such word specifies the start of the EOF section of the code; |
6594 RRR (3-bit): register number | 6764 RRR (3-bit): register number |
6595 XXXXXXXXXXXXXXXX (15-bit): | 6765 XXXXXXXXXXXXXXXX (15-bit): |
6596 CCCCCCCCCCCCCCC: constant or address | 6766 CCCCCCCCCCCCCCC: constant or address |
6597 000000000000rrr: register number | 6767 000000000000rrr: register number |
6598 | 6768 |
6599 AAAA: 00000 + | 6769 AAAA: 00000 + |
6600 00001 - | 6770 00001 - |
6601 00010 * | 6771 00010 * |
6602 00011 / | 6772 00011 / |
6603 00100 % | 6773 00100 % |
6604 00101 & | 6774 00101 & |
6605 00110 | | 6775 00110 | |
6606 00111 ~ | 6776 00111 ~ |
6607 | 6777 |
6608 01000 << | 6778 01000 << |
6609 01001 >> | 6779 01001 >> |
6610 01010 <8 | 6780 01010 <8 |
6612 01100 // | 6782 01100 // |
6613 01101 not used | 6783 01101 not used |
6614 01110 not used | 6784 01110 not used |
6615 01111 not used | 6785 01111 not used |
6616 | 6786 |
6617 10000 < | 6787 10000 < |
6618 10001 > | 6788 10001 > |
6619 10010 == | 6789 10010 == |
6620 10011 <= | 6790 10011 <= |
6621 10100 >= | 6791 10100 >= |
6622 10101 != | 6792 10101 != |
6623 | 6793 |
6624 OPERATORS: TTTTT RRR XX.. | 6794 OPERATORS: TTTTT RRR XX.. |
6625 | 6795 |
6626 SetCS: 00000 RRR C...C RRR = C...C | 6796 SetCS: 00000 RRR C...C RRR = C...C |
6627 SetCL: 00001 RRR ..... RRR = c...c | 6797 SetCL: 00001 RRR ..... RRR = c...c |
6628 c.............c | 6798 c.............c |
6629 SetR: 00010 RRR ..rrr RRR = rrr | 6799 SetR: 00010 RRR ..rrr RRR = rrr |
6630 SetA: 00011 RRR ..rrr RRR = array[rrr] | 6800 SetA: 00011 RRR ..rrr RRR = array[rrr] |
6631 C.............C size of array = C...C | 6801 C.............C size of array = C...C |
6632 c.............c contents = c...c | 6802 c.............c contents = c...c |
6633 | 6803 |
6634 Jump: 00100 000 c...c jump to c...c | 6804 Jump: 00100 000 c...c jump to c...c |
6635 JumpCond: 00101 RRR c...c if (!RRR) jump to c...c | 6805 JumpCond: 00101 RRR c...c if (!RRR) jump to c...c |
6636 WriteJump: 00110 RRR c...c Write1 RRR, jump to c...c | 6806 WriteJump: 00110 RRR c...c Write1 RRR, jump to c...c |
6637 WriteReadJump: 00111 RRR c...c Write1, Read1 RRR, jump to c...c | 6807 WriteReadJump: 00111 RRR c...c Write1, Read1 RRR, jump to c...c |
6638 WriteCJump: 01000 000 c...c Write1 C...C, jump to c...c | 6808 WriteCJump: 01000 000 c...c Write1 C...C, jump to c...c |
6639 C...C | 6809 C...C |
6640 WriteCReadJump: 01001 RRR c...c Write1 C...C, Read1 RRR, | 6810 WriteCReadJump: 01001 RRR c...c Write1 C...C, Read1 RRR, |
6641 C.............C and jump to c...c | 6811 C.............C and jump to c...c |
6642 WriteSJump: 01010 000 c...c WriteS, jump to c...c | 6812 WriteSJump: 01010 000 c...c WriteS, jump to c...c |
6643 C.............C | 6813 C.............C |
6644 S.............S | 6814 S.............S |
6645 ... | 6815 ... |
6646 WriteSReadJump: 01011 RRR c...c WriteS, Read1 RRR, jump to c...c | 6816 WriteSReadJump: 01011 RRR c...c WriteS, Read1 RRR, jump to c...c |
6647 C.............C | 6817 C.............C |
6648 S.............S | 6818 S.............S |
6649 ... | 6819 ... |
6650 WriteAReadJump: 01100 RRR c...c WriteA, Read1 RRR, jump to c...c | 6820 WriteAReadJump: 01100 RRR c...c WriteA, Read1 RRR, jump to c...c |
6651 C.............C size of array = C...C | 6821 C.............C size of array = C...C |
6652 c.............c contents = c...c | 6822 c.............c contents = c...c |
6653 ... | 6823 ... |
6654 Branch: 01101 RRR C...C if (RRR >= 0 && RRR < C..) | 6824 Branch: 01101 RRR C...C if (RRR >= 0 && RRR < C..) |
6655 c.............c branch to (RRR+1)th address | 6825 c.............c branch to (RRR+1)th address |
6656 Read1: 01110 RRR ... read 1-byte to RRR | 6826 Read1: 01110 RRR ... read 1-byte to RRR |
6657 Read2: 01111 RRR ..rrr read 2-byte to RRR and rrr | 6827 Read2: 01111 RRR ..rrr read 2-byte to RRR and rrr |
6658 ReadBranch: 10000 RRR C...C Read1 and Branch | 6828 ReadBranch: 10000 RRR C...C Read1 and Branch |
6659 c.............c | 6829 c.............c |
6660 ... | 6830 ... |
6661 Write1: 10001 RRR ..... write 1-byte RRR | 6831 Write1: 10001 RRR ..... write 1-byte RRR |
6662 Write2: 10010 RRR ..rrr write 2-byte RRR and rrr | 6832 Write2: 10010 RRR ..rrr write 2-byte RRR and rrr |
6663 WriteC: 10011 000 ..... write 1-char C...CC | 6833 WriteC: 10011 000 ..... write 1-char C...CC |
6664 C.............C | 6834 C.............C |
6665 WriteS: 10100 000 ..... write C..-byte of string | 6835 WriteS: 10100 000 ..... write C..-byte of string |
6666 C.............C | 6836 C.............C |
6667 S.............S | 6837 S.............S |
6668 ... | 6838 ... |
6669 WriteA: 10101 RRR ..... write array[RRR] | 6839 WriteA: 10101 RRR ..... write array[RRR] |
6670 C.............C size of array = C...C | 6840 C.............C size of array = C...C |
6671 c.............c contents = c...c | 6841 c.............c contents = c...c |
6672 ... | 6842 ... |
6673 End: 10110 000 ..... terminate the execution | 6843 End: 10110 000 ..... terminate the execution |
6674 | 6844 |
6675 SetSelfCS: 10111 RRR C...C RRR AAAAA= C...C | 6845 SetSelfCS: 10111 RRR C...C RRR AAAAA= C...C |
6676 ..........AAAAA | 6846 ..........AAAAA |
6677 SetSelfCL: 11000 RRR ..... RRR AAAAA= c...c | 6847 SetSelfCL: 11000 RRR ..... RRR AAAAA= c...c |
6678 c.............c | 6848 c.............c |
6679 ..........AAAAA | 6849 ..........AAAAA |
6680 SetSelfR: 11001 RRR ..Rrr RRR AAAAA= rrr | 6850 SetSelfR: 11001 RRR ..Rrr RRR AAAAA= rrr |
6681 ..........AAAAA | 6851 ..........AAAAA |
6682 SetExprCL: 11010 RRR ..Rrr RRR = rrr AAAAA c...c | 6852 SetExprCL: 11010 RRR ..Rrr RRR = rrr AAAAA c...c |
6683 c.............c | 6853 c.............c |
6684 ..........AAAAA | 6854 ..........AAAAA |
6685 SetExprR: 11011 RRR ..rrr RRR = rrr AAAAA Rrr | 6855 SetExprR: 11011 RRR ..rrr RRR = rrr AAAAA Rrr |
6686 ............Rrr | 6856 ............Rrr |
6687 ..........AAAAA | 6857 ..........AAAAA |
6688 JumpCondC: 11100 RRR c...c if !(RRR AAAAA C..) jump to c...c | 6858 JumpCondC: 11100 RRR c...c if !(RRR AAAAA C..) jump to c...c |
6689 C.............C | 6859 C.............C |
6690 ..........AAAAA | 6860 ..........AAAAA |
6691 JumpCondR: 11101 RRR c...c if !(RRR AAAAA rrr) jump to c...c | 6861 JumpCondR: 11101 RRR c...c if !(RRR AAAAA rrr) jump to c...c |
6692 ............rrr | 6862 ............rrr |
6693 ..........AAAAA | 6863 ..........AAAAA |
6694 ReadJumpCondC: 11110 RRR c...c Read1 and JumpCondC | 6864 ReadJumpCondC: 11110 RRR c...c Read1 and JumpCondC |
6695 C.............C | 6865 C.............C |
6696 ..........AAAAA | 6866 ..........AAAAA |
6697 ReadJumpCondR: 11111 RRR c...c Read1 and JumpCondR | 6867 ReadJumpCondR: 11111 RRR c...c Read1 and JumpCondR |
6698 ............rrr | 6868 ............rrr |
6699 ..........AAAAA | 6869 ..........AAAAA |
6700 @end example | 6870 @end example |
6701 | 6871 |
6702 @node The Lisp Reader and Compiler, Lstreams, MULE Character Sets and Encodings, Top | 6872 @node The Lisp Reader and Compiler, Lstreams, MULE Character Sets and Encodings, Top |
6967 already-running XEmacs process to display another frame on your local | 7137 already-running XEmacs process to display another frame on your local |
6968 TTY. | 7138 TTY. |
6969 | 7139 |
6970 Thus, there is a hierarchy console -> display -> frame -> window. | 7140 Thus, there is a hierarchy console -> display -> frame -> window. |
6971 There is a separate Lisp object type for each of these four concepts. | 7141 There is a separate Lisp object type for each of these four concepts. |
6972 Furthermore, there is logically a @dfn{selected console}, | 7142 Furthermore, there is logically a @dfn{selected console}, |
6973 @dfn{selected display}, @dfn{selected frame}, and @dfn{selected window}. | 7143 @dfn{selected display}, @dfn{selected frame}, and @dfn{selected window}. |
6974 Each of these objects is distinguished in various ways, such as being the | 7144 Each of these objects is distinguished in various ways, such as being the |
6975 default object for various functions that act on objects of that type. | 7145 default object for various functions that act on objects of that type. |
6976 Note that every containing object rememembers the ``selected'' object | 7146 Note that every containing object rememembers the ``selected'' object |
6977 among the objects that it contains: e.g. not only is there a selected | 7147 among the objects that it contains: e.g. not only is there a selected |
7363 Extents are compared using memory indices. There are two orderings | 7533 Extents are compared using memory indices. There are two orderings |
7364 for extents and both orders are kept current at all times. The normal | 7534 for extents and both orders are kept current at all times. The normal |
7365 or @dfn{display} order is as follows: | 7535 or @dfn{display} order is as follows: |
7366 | 7536 |
7367 @example | 7537 @example |
7368 Extent A is ``less than'' extent B, that is, earlier in the display order, | 7538 Extent A is ``less than'' extent B, |
7369 if: A-start < B-start, | 7539 that is, earlier in the display order, |
7370 or if: A-start = B-start, and A-end > B-end | 7540 if: A-start < B-start, |
7541 or if: A-start = B-start, and A-end > B-end | |
7371 @end example | 7542 @end example |
7372 | 7543 |
7373 So if two extents begin at the same position, the larger of them is the | 7544 So if two extents begin at the same position, the larger of them is the |
7374 earlier one in the display order (@code{EXTENT_LESS} is true). | 7545 earlier one in the display order (@code{EXTENT_LESS} is true). |
7375 | 7546 |
7376 For the e-order, the same thing holds: | 7547 For the e-order, the same thing holds: |
7377 | 7548 |
7378 @example | 7549 @example |
7379 Extent A is ``less than'' extent B in e-order, that is, later in the buffer, | 7550 Extent A is ``less than'' extent B in e-order, |
7380 if: A-end < B-end, | 7551 that is, later in the buffer, |
7381 or if: A-end = B-end, and A-start > B-start | 7552 if: A-end < B-end, |
7553 or if: A-end = B-end, and A-start > B-start | |
7382 @end example | 7554 @end example |
7383 | 7555 |
7384 So if two extents end at the same position, the smaller of them is the | 7556 So if two extents end at the same position, the smaller of them is the |
7385 earlier one in the e-order (@code{EXTENT_E_LESS} is true). | 7557 earlier one in the e-order (@code{EXTENT_E_LESS} is true). |
7386 | 7558 |