Mercurial > hg > xemacs-beta
annotate src/libinterface.c @ 5560:58b38d5b32d0
Implement print-circle, allowing recursive and circular structures to be read.
src/ChangeLog addition:
2011-09-04 Aidan Kehoe <kehoea@parhasard.net>
* alloc.c:
* alloc.c (ALLOC_FROB_BLOCK_LISP_OBJECT_1):
* alloc.c (ALLOC_FROB_BLOCK_LISP_OBJECT):
* alloc.c (cons_print_preprocess):
* alloc.c (vector_print_preprocess):
* alloc.c (vector_nsubst_structures_descend):
* alloc.c (Fmake_symbol):
* alloc.c (UNMARK_symbol):
* alloc.c (sweep_symbols):
* alloc.c (reinit_alloc_objects_early):
* alloc.c (reinit_alloc_early):
* bytecode.c:
* bytecode.c (compiled_function_print_preprocess):
* bytecode.c (compiled_function_nsubst_structures_descend):
* bytecode.c (set_compiled_function_arglist):
* bytecode.c (set_compiled_function_interactive):
* bytecode.c (bytecode_objects_create):
* chartab.c:
* chartab.c (print_preprocess_mapper):
* chartab.c (nsubst_structures_mapper):
* chartab.c (char_table_nsubst_structures_descend):
* chartab.c (chartab_objects_create):
* elhash.c:
* elhash.c (nsubst_structures_map_hash_table):
* elhash.c (hash_table_nsubst_structures_descend):
* elhash.c (print_preprocess_mapper):
* elhash.c (hash_table_print_preprocess):
* elhash.c (inchash_eq):
* elhash.c (hash_table_objects_create):
* elhash.c (syms_of_elhash):
* elhash.h:
* emacs.c (main_1):
* fns.c:
* fns.c (check_eq_nokey):
* fns.c (Fnsubst):
* fns.c (syms_of_fns):
* lisp.h:
* lisp.h (struct Lisp_Symbol):
* lisp.h (IN_OBARRAY):
* lisp.h (struct):
* lisp.h (PRINT_PREPROCESS):
* lread.c (read1):
* lrecord.h:
* lrecord.h (struct lrecord_implementation):
* lrecord.h (DEFINE_DUMPABLE_MODULE_LISP_OBJECT):
* print.c:
* print.c (PRINT_CIRCLE_LIMIT):
* print.c (print_continuous_numbering_changed):
* print.c (print_prepare):
* print.c (print_finish):
* print.c (Fprin1_to_string):
* print.c (print_cons):
* print.c (print_preprocess_inchash_eq):
* print.c (print_preprocess):
* print.c (print_sort_get_numbers):
* print.c (print_sort_compare_ordinals):
* print.c (print_gensym_or_circle):
* print.c (nsubst_structures_descend):
* print.c (nsubst_structures):
* print.c (print_internal):
* print.c (print_symbol):
* print.c (vars_of_print):
* rangetab.c:
* rangetab.c (range_table_print_preprocess):
* rangetab.c (range_table_nsubst_structures_descend):
* rangetab.c (rangetab_objects_create):
* rangetab.c (syms_of_rangetab):
* symbols.c:
* symbols.c (symbol_print_preprocess):
* symbols.c (Fintern):
* symbols.c (Funintern):
* symbols.c (reinit_symbol_objects_early):
* symbols.c (init_symbols_once_early):
* symsinit.h:
Implement print-circle, printing circular structures in a readable
fashion, and treating them appropriately on read. This is by means
of two new object methods, print_preprocess (detecting
circularities), and nsubst_structures_descend (replacing
placeholders with the read objects).
Expose the substitution to Lisp via #'nsubst and its new
:descend-structures keyword.
Store information as to whether symbols are interned in obarray or
not in their header, making checking for keywords and uninterned
symbols (and thus printing) cheaper.
Default print_gensym to t, as Common Lisp does, and as a
more-than-decade old comment suggests.
lisp/ChangeLog addition:
2011-09-04 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-output-file-form):
* bytecomp.el (byte-compile-output-docform):
Bind print-circle, print-continuous-numbering in these functions,
now those variables are available.
* lisp.el (forward-sexp):
* lisp.el (backward-sexp):
Recognise leading #N= as being part of an expression.
tests/ChangeLog addition:
2011-09-04 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-reader-tests.el:
* automated/lisp-tests.el (literal-with-uninterned):
* automated/symbol-tests.el (foo):
Test print-circle, for printing (mutually-)recursive and circular
structures.
Bind print-continuous-numbering where appropriate.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Sun, 04 Sep 2011 19:51:35 +0100 |
| parents | 308d34e9f07d |
| children |
| rev | line source |
|---|---|
| 870 | 1 /* Interface to graphics/etc libraries, with cdecl calling convention. |
| 2 Copyright (C) 2002 Ben Wing | |
| 3 | |
| 4 This file is part of XEmacs. | |
| 5 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
870
diff
changeset
|
6 XEmacs is free software: you can redistribute it and/or modify it |
| 870 | 7 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:
870
diff
changeset
|
8 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:
870
diff
changeset
|
9 option) any later version. |
| 870 | 10 |
| 11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 for more details. | |
| 15 | |
| 16 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:
870
diff
changeset
|
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 870 | 18 |
| 19 /* Synched up with: Not in FSF. */ | |
| 20 | |
| 21 #include <config.h> | |
| 22 #include "lisp.h" | |
| 23 | |
| 24 #include "libinterface.h" | |
| 25 | |
| 26 /* YUUUUUUUUUUUUUUCK! | |
| 27 | |
| 28 This file exists only because VC++ lacks pragmas that let you change the | |
| 29 default calling convention in the middle of a file. With optimization, | |
| 30 we compile XEmacs using fastcall as the default convention; but | |
| 31 libraries are not compiled this way, and thus need __cdecl in their | |
| 32 declaration. Without the pragma, we either | |
| 33 | |
| 34 (a) depend on libraries that declare their external functions with | |
| 35 suitable preprocessor definitions that we can change; | |
| 36 | |
| 37 (b) force the user to recompile the library with fastcall (not | |
| 38 reasonable); | |
| 39 | |
| 40 (c) hack the headers manually (not reasonable); | |
| 41 | |
| 42 (d) put all calls to the library in a separate file where the default | |
| 43 calling convention is __cdecl (hence, this file). | |
| 44 | |
| 45 In fact, some libraries do make (a) feasible. This is the case with PNG | |
| 46 and ZLIB. JPEG almost does so, since all externs are wrapped with | |
| 47 EXTERN(); but they fail to wrap their definition of EXTERN with #ifndef | |
| 48 EXTERN, so we can't override it. XPM is similar, wrapping their externs | |
| 49 with FUNC() -- again, not overridable. With PNG, we define PNG_EXPORT; | |
| 50 with ZLIB, we define ZEXPORT and ZEXPORTVA. */ | |
| 51 | |
| 52 #ifdef HAVE_XPM | |
| 53 | |
| 54 void | |
| 55 qxe_XpmFreeXpmImage (XpmImage *image) | |
| 56 { | |
| 57 XpmFreeXpmImage (image); | |
| 58 } | |
| 59 | |
| 60 void | |
| 61 qxe_XpmFreeXpmInfo (XpmInfo *info) | |
| 62 { | |
| 63 XpmFreeXpmInfo (info); | |
| 64 } | |
| 65 | |
| 66 int | |
| 67 qxe_XpmCreateXpmImageFromBuffer (char *buffer, XpmImage *image, XpmInfo *info) | |
| 68 { | |
| 69 return XpmCreateXpmImageFromBuffer (buffer, image, info); | |
| 70 } | |
| 71 | |
| 72 void | |
| 73 qxe_XpmFree (void *ptr) | |
| 74 { | |
| 75 XpmFree (ptr); | |
| 76 } | |
| 77 | |
| 78 int | |
| 79 qxe_XpmReadFileToData (char *filename, char ***data_return) | |
| 80 { | |
| 81 return XpmReadFileToData (filename, data_return); | |
| 82 } | |
| 83 | |
| 84 #endif /* HAVE_XPM */ | |
| 85 | |
| 86 #ifdef HAVE_JPEG | |
| 87 | |
| 88 boolean | |
| 89 qxe_jpeg_finish_decompress (j_decompress_ptr cinfo) | |
| 90 { | |
| 91 return jpeg_finish_decompress (cinfo); | |
| 92 } | |
| 93 | |
| 94 boolean | |
| 95 qxe_jpeg_start_decompress (j_decompress_ptr cinfo) | |
| 96 { | |
| 97 return jpeg_start_decompress (cinfo); | |
| 98 } | |
| 99 | |
| 100 JDIMENSION | |
| 101 qxe_jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, | |
| 102 JDIMENSION max_lines) | |
| 103 { | |
| 104 return jpeg_read_scanlines (cinfo, scanlines, max_lines); | |
| 105 } | |
| 106 | |
| 107 int | |
| 108 qxe_jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) | |
| 109 { | |
| 110 return jpeg_read_header (cinfo, require_image); | |
| 111 } | |
| 112 | |
| 113 void | |
| 114 qxe_jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, | |
| 115 size_t structsize) | |
| 116 { | |
| 117 jpeg_CreateDecompress (cinfo, version, structsize); | |
| 118 } | |
| 119 | |
| 120 struct jpeg_error_mgr * | |
| 121 qxe_jpeg_std_error (struct jpeg_error_mgr *err) | |
| 122 { | |
| 123 return jpeg_std_error (err); | |
| 124 } | |
| 125 | |
| 126 void | |
| 127 qxe_jpeg_destroy_decompress (j_decompress_ptr cinfo) | |
| 128 { | |
| 129 jpeg_destroy_decompress (cinfo); | |
| 130 } | |
| 131 | |
| 132 boolean | |
| 133 qxe_jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) | |
| 134 { | |
| 135 return jpeg_resync_to_restart (cinfo, desired); | |
| 136 } | |
| 137 | |
| 138 #endif /* HAVE_JPEG */ | |
| 139 | |
| 140 #ifdef HAVE_TIFF | |
| 141 | |
| 142 tdata_t | |
| 143 qxe_TIFFmalloc (tsize_t x1) | |
| 144 { | |
| 145 return _TIFFmalloc (x1); | |
| 146 } | |
| 147 | |
| 148 void | |
| 149 qxe_TIFFfree (tdata_t x1) | |
| 150 { | |
| 151 _TIFFfree (x1); | |
| 152 } | |
| 153 | |
| 154 void | |
| 155 qxe_TIFFClose (TIFF *x1) | |
| 156 { | |
| 157 TIFFClose (x1); | |
| 158 } | |
| 159 | |
| 160 int | |
| 161 qxe_TIFFGetField (TIFF *x1, ttag_t x2, uint32 *x3) | |
| 162 { | |
| 163 return TIFFGetField (x1, x2, x3); | |
| 164 } | |
| 165 | |
| 166 TIFF * | |
| 167 qxe_TIFFClientOpen (const char *x1, const char *x2, | |
| 168 thandle_t x3, | |
| 169 TIFFReadWriteProc x4, TIFFReadWriteProc x5, | |
| 170 TIFFSeekProc x6, TIFFCloseProc x7, | |
| 171 TIFFSizeProc x8, | |
| 172 TIFFMapFileProc x9, TIFFUnmapFileProc x10) | |
| 173 { | |
| 174 return TIFFClientOpen (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10); | |
| 175 } | |
| 176 | |
| 177 TIFFErrorHandler | |
| 178 qxe_TIFFSetErrorHandler (TIFFErrorHandler x1) | |
| 179 { | |
| 180 return TIFFSetErrorHandler (x1); | |
| 181 } | |
| 182 | |
| 183 TIFFErrorHandler | |
| 184 qxe_TIFFSetWarningHandler (TIFFErrorHandler x1) | |
| 185 { | |
| 186 return TIFFSetWarningHandler (x1); | |
| 187 } | |
| 188 | |
| 189 int | |
| 190 qxe_TIFFReadRGBAImage (TIFF *x1, uint32 x2, uint32 x3, uint32 *x4, int x5) | |
| 191 { | |
| 192 return TIFFReadRGBAImage (x1, x2, x3, x4, x5); | |
| 193 } | |
| 194 | |
| 195 #endif /* HAVE_TIFF */ |
