Mercurial > hg > xemacs-beta
annotate src/device-impl.h @ 5576:071b810ceb18
Declare labels as line where appropriate; use #'labels, not #'flet, tests.
lisp/ChangeLog addition:
2011-10-03 Aidan Kehoe <kehoea@parhasard.net>
* simple.el (handle-pre-motion-command-current-command-is-motion):
Implement #'keysyms-equal with #'labels + (declare (inline ...)),
instead of abusing macrolet to the same end.
* specifier.el (let-specifier):
* mule/mule-cmds.el (describe-language-environment):
* mule/mule-cmds.el (set-language-environment-coding-systems):
* mule/mule-x-init.el (x-use-halfwidth-roman-font):
* faces.el (Face-frob-property):
* keymap.el (key-sequence-list-description):
* lisp-mode.el (construct-lisp-mode-menu):
* loadhist.el (unload-feature):
* mouse.el (default-mouse-track-check-for-activation):
Declare various labels inline in dumped files when that reduces
the size of the dumped image. Declaring labels inline is normally
only worthwhile for inner loops and so on, but it's reasonable
exercise of the related code to have these changes in core.
tests/ChangeLog addition:
2011-10-03 Aidan Kehoe <kehoea@parhasard.net>
* automated/case-tests.el (uni-mappings):
* automated/database-tests.el (delete-database-files):
* automated/hash-table-tests.el (iterations):
* automated/lisp-tests.el (test1):
* automated/lisp-tests.el (a):
* automated/lisp-tests.el (cl-floor):
* automated/lisp-tests.el (foo):
* automated/lisp-tests.el (list-nreverse):
* automated/lisp-tests.el (needs-lexical-context):
* automated/mule-tests.el (featurep):
* automated/os-tests.el (original-string):
* automated/os-tests.el (with):
* automated/symbol-tests.el (check-weak-list-unique):
Replace #'flet with #'labels where appropriate in these tests,
following my own advice on style in the docstrings of those
functions.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Mon, 03 Oct 2011 20:16:14 +0100 |
| parents | 308d34e9f07d |
| children | 0f2338afbabf |
| rev | line source |
|---|---|
| 872 | 1 /* Define device-object for XEmacs. |
| 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | |
| 3 Copyright (C) 1995, 2002 Ben Wing | |
| 4 Copyright (C) 1995 Sun Microsystems | |
| 5 | |
| 6 This file is part of XEmacs. | |
| 7 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5127
diff
changeset
|
8 XEmacs is free software: you can redistribute it and/or modify it |
| 872 | 9 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5127
diff
changeset
|
10 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5127
diff
changeset
|
11 option) any later version. |
| 872 | 12 |
| 13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 16 for more details. | |
| 17 | |
| 18 You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5127
diff
changeset
|
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 872 | 20 |
| 21 /* Synched up with: Not in FSF. */ | |
| 22 | |
| 23 /* Written by Chuck Thompson and Ben Wing. */ | |
| 24 | |
| 25 #ifndef INCLUDED_device_impl_h_ | |
| 26 #define INCLUDED_device_impl_h_ | |
| 27 | |
| 28 #include "console-impl.h" | |
| 29 #include "device.h" | |
| 30 | |
| 31 /* This should really be in redisplay.h but by putting it here we | |
| 32 won't have to ensure that redisplay.h is always included before | |
| 33 this file. */ | |
| 34 struct pixel_to_glyph_translation_cache | |
| 35 { | |
| 36 unsigned int valid :1; | |
| 37 struct frame *frame; | |
| 38 int low_x_coord, high_x_coord, col, obj_x; | |
| 39 int low_y_coord, high_y_coord, row, obj_y; | |
| 40 struct window *w; | |
| 41 Charbpos charpos; | |
| 42 Charbpos closest; | |
| 43 Charcount modeline_closest; | |
| 44 Lisp_Object obj1, obj2; | |
| 45 int retval; | |
| 46 }; | |
| 47 | |
| 48 /* Less public: */ | |
| 49 #define DEVICE_TYPE_NAME(d) ((d)->devmeths->name) | |
| 50 #define DEVICE_IMPL_FLAG(d, f) CONMETH_IMPL_FLAG ((d)->devmeths, (f)) | |
| 51 #define DEVICE_SPECIFIC_FRAME_PROPS(d) \ | |
| 52 ((d)->devmeths->device_specific_frame_props) | |
| 53 | |
| 54 /* More public: */ | |
| 55 #define DEVICE_TYPE(d) ((d)->devmeths->symbol) | |
| 56 #define XDEVICE_TYPE(d) DEVICE_TYPE (XDEVICE (d)) | |
| 57 | |
| 58 /******** Accessing / calling a device method *********/ | |
| 59 | |
| 60 #define HAS_DEVMETH_P(d, m) HAS_CONTYPE_METH_P ((d)->devmeths, m) | |
| 61 #define DEVMETH(d, m, args) CONTYPE_METH ((d)->devmeths, m, args) | |
| 62 #define MAYBE_DEVMETH(d, m, args) MAYBE_CONTYPE_METH ((d)->devmeths, m, args) | |
| 63 #define DEVMETH_OR_GIVEN(d, m, args, given) \ | |
| 64 CONTYPE_METH_OR_GIVEN((d)->devmeths, m, args, given) | |
| 65 #define MAYBE_INT_DEVMETH(d, m, args) \ | |
| 66 MAYBE_INT_CONTYPE_METH ((d)->devmeths, m, args) | |
| 67 #define MAYBE_LISP_DEVMETH(d, m, args) \ | |
| 68 MAYBE_LISP_CONTYPE_METH ((d)->devmeths, m, args) | |
| 69 | |
| 70 struct device | |
| 71 { | |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
72 NORMAL_LISP_OBJECT_HEADER header; |
| 872 | 73 |
| 74 /* Methods for this device's console. This can also be retrieved | |
| 75 through device->console, but it's faster this way. */ | |
| 76 struct console_methods *devmeths; | |
| 77 | |
| 1204 | 78 /* Duplicates devmeths->symbol. See comment in struct console. */ |
| 934 | 79 enum console_variant devtype; |
| 80 | |
| 872 | 81 /* A structure of auxiliary data specific to the device type. |
| 82 struct x_device is used for X window frames; defined in console-x.h | |
| 83 struct tty_device is used to TTY's; defined in console-tty.h */ | |
| 84 void *device_data; | |
| 85 | |
| 86 /* redisplay flags */ | |
| 87 unsigned int buffers_changed :1; | |
| 88 unsigned int clip_changed :1; | |
| 89 unsigned int extents_changed :1; | |
| 90 unsigned int faces_changed :1; | |
| 91 unsigned int frame_changed :1; | |
| 905 | 92 unsigned int frame_layout_changed :1; /* The layout of frame |
| 93 elements has changed. */ | |
| 872 | 94 unsigned int glyphs_changed :1; |
| 95 unsigned int subwindows_changed :1; | |
| 96 unsigned int subwindows_state_changed :1; | |
| 97 unsigned int icon_changed :1; | |
| 98 unsigned int menubar_changed :1; | |
| 99 unsigned int modeline_changed :1; | |
| 100 unsigned int point_changed :1; | |
| 101 unsigned int size_changed :1; | |
| 102 unsigned int gutter_changed :1; | |
| 103 unsigned int toolbar_changed :1; | |
| 104 unsigned int windows_changed :1; | |
| 105 unsigned int windows_structure_changed :1; | |
| 106 | |
| 107 unsigned int locked :1; | |
| 108 | |
| 109 /* Cache information about last pixel position translated to a | |
| 110 glyph. The law of locality applies very heavily here so caching | |
| 111 the value leads to a significant win. At the moment this is | |
| 112 really X specific but once we have generic mouse support it won't | |
| 113 be. */ | |
| 114 struct pixel_to_glyph_translation_cache pixel_to_glyph_cache; | |
| 115 | |
| 116 /* Output baud rate of device; used for redisplay decisions. */ | |
| 117 int baud_rate; | |
| 118 | |
| 119 /* sound flags */ | |
| 120 unsigned int on_console_p :1; | |
| 121 unsigned int connected_to_nas_p :1; | |
| 122 | |
| 1204 | 123 #define MARKED_SLOT(x) Lisp_Object x; |
| 872 | 124 #include "devslots.h" |
| 125 | |
| 126 /* File descriptors for input and output. Much of the time | |
| 127 (but not always) these will be the same. For an X device, | |
| 128 these both hold the file descriptor of the socket used | |
| 129 to communicate with the X server. For a TTY device, these | |
| 130 may or may not be the same and point to the terminal that | |
| 131 is used for I/O. */ | |
| 132 int infd, outfd; | |
| 133 | |
| 134 /* infd and outfd are moved outside HAVE_UNIXOID_EVENT_LOOP conditionals, | |
| 135 because Win32, presumably the first port which does not use select() | |
| 136 polling, DOES have handles for a console device. -- kkm */ | |
| 137 | |
| 138 #ifdef HAVE_UNIXOID_EVENT_LOOP | |
| 139 /* holds some data necessary for SIGIO control. Perhaps this should | |
| 140 be inside of device_data; but it is used for both TTY's and X | |
| 141 device. Perhaps it should be conditionalized on SIGIO; but | |
| 142 this requires including syssignal.h. */ | |
| 143 int old_fcntl_owner; | |
| 144 #endif | |
| 145 }; | |
| 146 | |
| 147 /* Redefine basic properties more efficiently */ | |
| 148 | |
| 149 #undef DEVICE_LIVE_P | |
| 150 #define DEVICE_LIVE_P(d) (!EQ (DEVICE_TYPE (d), Qdead)) | |
| 151 #undef DEVICE_CONSOLE | |
| 152 #define DEVICE_CONSOLE(d) ((d)->console) | |
| 153 #undef DEVICE_FRAME_LIST | |
| 154 #define DEVICE_FRAME_LIST(d) ((d)->frame_list) | |
| 155 | |
| 156 #define DEVICE_TYPE_P(d, type) EQ (DEVICE_TYPE (d), Q##type) | |
| 157 | |
| 158 #ifdef ERROR_CHECK_TYPES | |
| 159 DECLARE_INLINE_HEADER ( | |
| 160 struct device * | |
| 161 error_check_device_type (struct device *d, Lisp_Object sym) | |
| 162 ) | |
| 163 { | |
| 164 assert (EQ (DEVICE_TYPE (d), sym)); | |
| 165 return d; | |
| 166 } | |
| 167 # define DEVICE_TYPE_DATA(d, type) \ | |
| 168 ((struct type##_device *) error_check_device_type (d, Q##type)->device_data) | |
| 169 #else | |
| 170 # define DEVICE_TYPE_DATA(d, type) \ | |
| 171 ((struct type##_device *) (d)->device_data) | |
| 172 #endif | |
| 173 | |
| 174 #define CHECK_DEVICE_TYPE(x, type) \ | |
| 175 do { \ | |
| 176 CHECK_DEVICE (x); \ | |
| 177 if (!(DEVICEP (x) && DEVICE_TYPE_P (XDEVICE (x), \ | |
| 178 type))) \ | |
| 179 dead_wrong_type_argument \ | |
| 180 (type##_console_methods->predicate_symbol, x); \ | |
| 181 } while (0) | |
| 182 #define CONCHECK_DEVICE_TYPE(x, type) \ | |
| 183 do { \ | |
| 184 CONCHECK_DEVICE (x); \ | |
| 185 if (!(DEVICEP (x) && DEVICE_TYPE_P (XDEVICE (x), \ | |
| 186 type))) \ | |
| 187 x = wrong_type_argument \ | |
| 188 (type##_console_methods->predicate_symbol, x); \ | |
| 189 } while (0) | |
| 190 | |
| 191 #define DEVICE_DISPLAY_P(dev) \ | |
| 192 (DEVICE_LIVE_P (dev) && \ | |
| 193 !DEVICE_IMPL_FLAG (dev, XDEVIMPF_IS_A_PRINTER)) | |
| 194 | |
| 195 #define CHECK_DISPLAY_DEVICE(dev) \ | |
| 196 do { \ | |
| 197 CHECK_DEVICE (dev); \ | |
| 198 if (!(DEVICEP (dev) \ | |
| 199 && DEVICE_DISPLAY_P (XDEVICE (dev)))) \ | |
| 200 dead_wrong_type_argument (Qdisplay, dev); \ | |
| 201 } while (0) | |
| 202 | |
| 203 #define CONCHECK_DISPLAY_DEVICE(dev) \ | |
| 204 do { \ | |
| 205 CONCHECK_DEVICE (dev); \ | |
| 206 if (!(DEVICEP (dev) \ | |
| 207 && DEVICE_DISPLAY_P (XDEVICE (dev)))) \ | |
| 208 wrong_type_argument (Qdisplay, dev); \ | |
| 209 } while (0) | |
| 210 | |
| 211 #define DEVICE_PRINTER_P(dev) \ | |
| 212 (DEVICE_LIVE_P (dev) && !DEVICE_DISPLAY_P (dev)) | |
| 213 | |
| 214 #define CHECK_PRINTER_DEVICE(dev) \ | |
| 215 do { \ | |
| 216 CHECK_DEVICE (dev); \ | |
| 217 if (!(DEVICEP (dev) \ | |
| 218 && DEVICE_PRINTER_P (XDEVICE (dev)))) \ | |
| 219 dead_wrong_type_argument (Qprinter, dev); \ | |
| 220 } while (0) | |
| 221 | |
| 222 #define CONCHECK_PRINTER_DEVICE(dev) \ | |
| 223 do { \ | |
| 224 CONCHECK_DEVICE (dev); \ | |
| 225 if (!(DEVICEP (dev) \ | |
| 226 && DEVICE_PRINTER_P (XDEVICE (dev)))) \ | |
| 227 wrong_type_argument (Qprinter, dev); \ | |
| 228 } while (0) | |
| 229 | |
| 230 /* #### These should be in the device-*.h files but there are | |
| 231 too many places where the abstraction is broken. Need to | |
| 232 fix. */ | |
| 233 | |
| 234 #define DEVICE_X_P(dev) CONSOLE_TYPESYM_X_P (DEVICE_TYPE (dev)) | |
| 235 #define CHECK_X_DEVICE(z) CHECK_DEVICE_TYPE (z, x) | |
| 236 #define CONCHECK_X_DEVICE(z) CONCHECK_DEVICE_TYPE (z, x) | |
| 237 | |
| 238 #define DEVICE_GTK_P(dev) CONSOLE_TYPESYM_GTK_P (DEVICE_TYPE (dev)) | |
| 239 #define CHECK_GTK_DEVICE(z) CHECK_DEVICE_TYPE (z, gtk) | |
| 240 #define CONCHECK_GTK_DEVICE(z) CONCHECK_DEVICE_TYPE (z, gtk) | |
| 241 | |
| 242 #define DEVICE_MSWINDOWS_P(dev) CONSOLE_TYPESYM_MSWINDOWS_P (DEVICE_TYPE (dev)) | |
| 243 #define CHECK_MSWINDOWS_DEVICE(z) CHECK_DEVICE_TYPE (z, mswindows) | |
| 244 #define CONCHECK_MSWINDOWS_DEVICE(z) CONCHECK_DEVICE_TYPE (z, mswindows) | |
| 245 | |
| 246 #define DEVICE_TTY_P(dev) CONSOLE_TYPESYM_TTY_P (DEVICE_TYPE (dev)) | |
| 247 #define CHECK_TTY_DEVICE(z) CHECK_DEVICE_TYPE (z, tty) | |
| 248 #define CONCHECK_TTY_DEVICE(z) CONCHECK_DEVICE_TYPE (z, tty) | |
| 249 | |
| 250 #define DEVICE_STREAM_P(dev) CONSOLE_TYPESYM_STREAM_P (DEVICE_TYPE (dev)) | |
| 251 #define CHECK_STREAM_DEVICE(z) CHECK_DEVICE_TYPE (z, stream) | |
| 252 #define CONCHECK_STREAM_DEVICE(z) CONCHECK_DEVICE_TYPE (z, stream) | |
| 253 | |
| 254 #define DEVICE_WIN_P(dev) CONSOLE_TYPESYM_WIN_P (DEVICE_TYPE (dev)) | |
| 255 | |
| 256 #define DEVICE_REDISPLAY_INFO(d) ((d)->redisplay_info) | |
| 257 | |
| 258 #define DEVICE_NAME(d) ((d)->name) | |
| 259 #define DEVICE_CLASS(d) ((d)->device_class) | |
| 260 /* Catch people attempting to set this. */ | |
| 261 #define DEVICE_SELECTED_FRAME(d) NON_LVALUE ((d)->selected_frame) | |
| 262 #define DEVICE_FRAME_WITH_FOCUS_REAL(d) ((d)->frame_with_focus_real) | |
| 263 #define DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS(d) ((d)->frame_with_focus_for_hooks) | |
| 264 #define DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS(d) \ | |
| 265 ((d)->frame_that_ought_to_have_focus) | |
| 266 #define DEVICE_USER_DEFINED_TAGS(d) ((d)->user_defined_tags) | |
| 267 #define DEVICE_CONNECTION(d) ((d)->connection) | |
| 268 #define DEVICE_CANON_CONNECTION(d) ((d)->canon_connection) | |
| 269 #define DEVICE_BAUD_RATE(d) ((d)->baud_rate) | |
| 270 #define DEVICE_INFD(d) ((d)->infd) | |
| 271 #define DEVICE_OUTFD(d) ((d)->outfd) | |
| 272 #define DEVICE_OLD_FCNTL_OWNER(d) ((d)->old_fcntl_owner) | |
| 273 #define DEVICE_ON_CONSOLE_P(d) ((d)->on_console_p) | |
| 274 #define DEVICE_CONNECTED_TO_NAS_P(d) ((d)->connected_to_nas_p) | |
| 275 | |
| 276 #define LOCK_DEVICE(d) ((void) ((d)->locked = 1)) | |
| 277 #define UNLOCK_DEVICE(d) ((void) ((d)->locked = 0)) | |
| 278 | |
| 279 #define INVALIDATE_DEVICE_PIXEL_TO_GLYPH_CACHE(d) \ | |
| 280 ((void) ((d)->pixel_to_glyph_cache.valid = 0)) | |
| 281 | |
| 282 #define INVALIDATE_PIXEL_TO_GLYPH_CACHE do { \ | |
| 283 Lisp_Object IPTGC_devcons, IPTGC_concons; \ | |
| 284 DEVICE_LOOP_NO_BREAK (IPTGC_devcons, IPTGC_concons) \ | |
| 285 INVALIDATE_DEVICE_PIXEL_TO_GLYPH_CACHE (XDEVICE (XCAR (IPTGC_devcons))); \ | |
| 286 } while (0) | |
| 287 | |
| 288 #define MARK_DEVICE_FACES_CHANGED(d) \ | |
| 289 ((void) (faces_changed = (d)->faces_changed = 1)) | |
| 290 | |
| 291 #define MARK_DEVICE_GLYPHS_CHANGED(d) \ | |
| 292 ((void) (glyphs_changed = (d)->glyphs_changed = 1)) | |
| 293 | |
| 294 #define MARK_DEVICE_SUBWINDOWS_CHANGED(d) \ | |
| 295 ((void) (subwindows_changed = (d)->subwindows_changed = 1)) | |
| 296 | |
| 297 #define MARK_DEVICE_SUBWINDOWS_STATE_CHANGED(d) \ | |
| 298 ((void) (subwindows_state_changed = (d)->subwindows_state_changed = 1)) | |
| 299 | |
| 300 #define MARK_DEVICE_TOOLBARS_CHANGED(d) \ | |
| 301 ((void) (toolbar_changed = (d)->toolbar_changed = 1)) | |
| 302 | |
| 303 #define MARK_DEVICE_GUTTERS_CHANGED(d) \ | |
| 304 ((void) (gutter_changed = (d)->gutter_changed = 1)) | |
| 305 | |
| 306 #define MARK_DEVICE_SIZE_CHANGED(d) \ | |
| 307 ((void) (size_changed = (d)->size_changed = 1)) | |
| 308 | |
| 309 #define MARK_DEVICE_FRAMES_FACES_CHANGED(d) do { \ | |
| 310 struct device *mdffc_d = (d); \ | |
| 311 Lisp_Object frmcons; \ | |
| 312 DEVICE_FRAME_LOOP (frmcons, mdffc_d) \ | |
| 313 XFRAME (XCAR (frmcons))->faces_changed = 1; \ | |
| 314 MARK_DEVICE_FACES_CHANGED (mdffc_d); \ | |
| 315 } while (0) | |
| 316 | |
| 317 #define MARK_DEVICE_FRAMES_GLYPHS_CHANGED(d) do { \ | |
| 318 struct device *mdffc_d = (d); \ | |
| 319 Lisp_Object frmcons; \ | |
| 320 DEVICE_FRAME_LOOP (frmcons, mdffc_d) \ | |
| 321 XFRAME (XCAR (frmcons))->glyphs_changed = 1; \ | |
| 322 MARK_DEVICE_GLYPHS_CHANGED (mdffc_d); \ | |
| 323 } while (0) | |
| 324 | |
| 325 #define MARK_DEVICE_FRAME_CHANGED(d) \ | |
| 326 ((void) (frame_changed = (d)->frame_changed = 1)) | |
| 327 | |
| 905 | 328 #define MARK_DEVICE_FRAME_LAYOUT_CHANGED(d) \ |
| 329 ((void) (frame_layout_changed = (d)->frame_layout_changed = 1)) | |
| 330 | |
| 872 | 331 #define MARK_DEVICE_WINDOWS_CHANGED(d) \ |
| 332 ((void) (windows_changed = (d)->windows_changed = 1)) | |
| 333 | |
| 334 #define MARK_DEVICE_WINDOWS_STRUCTURE_CHANGED(d) \ | |
| 335 ((void) (windows_structure_changed = (d)->windows_structure_changed = 1)) | |
| 336 | |
| 337 #endif /* INCLUDED_device_impl_h_ */ |
