Mercurial > hg > xemacs-beta
annotate src/select-common.h @ 4976:16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-04 Ben Wing <ben@xemacs.org>
* alloc.c (release_breathing_space):
* alloc.c (resize_string):
* alloc.c (sweep_lcrecords_1):
* alloc.c (SWEEP_FIXED_TYPE_BLOCK_1):
* alloc.c (ADDITIONAL_FREE_compiled_function):
* alloc.c (compact_string_chars):
* alloc.c (ADDITIONAL_FREE_string):
* alloc.c (sweep_strings):
* alloca.c (xemacs_c_alloca):
* alsaplay.c (alsa_play_sound_file):
* buffer.c (init_initial_directory):
* buffer.h:
* buffer.h (BUFFER_FREE):
* console-stream.c (stream_delete_console):
* console-tty.c (free_tty_console_struct):
* data.c (Fnumber_to_string):
* device-gtk.c (gtk_init_device):
* device-gtk.c (free_gtk_device_struct):
* device-gtk.c (gtk_delete_device):
* device-msw.c (mswindows_delete_device):
* device-msw.c (msprinter_delete_device):
* device-tty.c (free_tty_device_struct):
* device-tty.c (tty_delete_device):
* device-x.c (x_init_device):
* device-x.c (free_x_device_struct):
* device-x.c (x_delete_device):
* dialog-msw.c (handle_directory_dialog_box):
* dialog-x.c (dbox_descriptor_to_widget_value):
* dired-msw.c (Fmswindows_insert_directory):
* dired.c (free_user_cache):
* dired.c (user_name_completion_unwind):
* doc.c (unparesseuxify_doc_string):
* doc.c (Fsubstitute_command_keys):
* doprnt.c (emacs_doprnt_1):
* dumper.c (pdump_load_finish):
* dumper.c (pdump_file_free):
* dumper.c (pdump_file_unmap):
* dynarr.c:
* dynarr.c (Dynarr_free):
* editfns.c (uncache_home_directory):
* editfns.c (Fset_time_zone_rule):
* elhash.c:
* elhash.c (pdump_reorganize_hash_table):
* elhash.c (maphash_unwind):
* emacs.c (make_arg_list_1):
* emacs.c (free_argc_argv):
* emacs.c (sort_args):
* emacs.c (Frunning_temacs_p):
* emodules.c (attempt_module_delete):
* eval.c (free_pointer):
* event-Xt.c (unselect_filedesc):
* event-Xt.c (emacs_Xt_select_process):
* event-gtk.c (unselect_filedesc):
* event-gtk.c (dragndrop_data_received):
* event-msw.c (winsock_closer):
* event-msw.c (mswindows_dde_callback):
* event-msw.c (mswindows_wnd_proc):
* event-stream.c (finalize_command_builder):
* event-stream.c (free_command_builder):
* extents.c (free_gap_array):
* extents.c (free_extent_list):
* extents.c (free_soe):
* extents.c (extent_fragment_delete):
* extents.c (extent_priority_sort_function):
* file-coding.c (make_coding_system_1):
* file-coding.c (coding_finalizer):
* file-coding.c (set_coding_stream_coding_system):
* file-coding.c (chain_finalize_coding_stream_1):
* file-coding.c (chain_finalize):
* file-coding.c (free_detection_state):
* file-coding.c (coding_category_symbol_to_id):
* fileio.c:
* fileio.c (Ffile_name_directory):
* fileio.c (if):
* fileio.c (Ffile_symlink_p):
* filelock.c (FREE_LOCK_INFO):
* filelock.c (current_lock_owner):
* font-mgr.c (Ffc_name_unparse):
* font-mgr.c (Ffc_pattern_duplicate):
* frame-gtk.c (gtk_delete_frame):
* frame-msw.c (mswindows_delete_frame):
* frame-msw.c (msprinter_delete_frame):
* frame-x.c (x_cde_destroy_callback):
* frame-x.c (Fcde_start_drag_internal):
* frame-x.c (x_cde_transfer_callback):
* frame-x.c (x_delete_frame):
* frame.c (update_frame_title):
* frame.c (Fset_frame_pointer):
* gc.c (register_for_finalization):
* gccache-gtk.c (free_gc_cache):
* gccache-gtk.c (gc_cache_lookup):
* gccache-x.c (free_gc_cache):
* gccache-x.c (gc_cache_lookup):
* glyphs-eimage.c:
* glyphs-eimage.c (jpeg_instantiate_unwind):
* glyphs-eimage.c (gif_instantiate_unwind):
* glyphs-eimage.c (png_instantiate_unwind):
* glyphs-eimage.c (png_instantiate):
* glyphs-eimage.c (tiff_instantiate_unwind):
* glyphs-gtk.c (convert_EImage_to_GDKImage):
* glyphs-gtk.c (gtk_finalize_image_instance):
* glyphs-gtk.c (gtk_init_image_instance_from_eimage):
* glyphs-gtk.c (gtk_xpm_instantiate):
* glyphs-msw.c (convert_EImage_to_DIBitmap):
* glyphs-msw.c (mswindows_init_image_instance_from_eimage):
* glyphs-msw.c (mswindows_initialize_image_instance_mask):
* glyphs-msw.c (xpm_to_eimage):
* glyphs-msw.c (mswindows_xpm_instantiate):
* glyphs-msw.c (xbm_create_bitmap_from_data):
* glyphs-msw.c (mswindows_finalize_image_instance):
* glyphs-x.c (convert_EImage_to_XImage):
* glyphs-x.c (x_finalize_image_instance):
* glyphs-x.c (x_init_image_instance_from_eimage):
* glyphs-x.c (x_xpm_instantiate):
* gui-x.c (free_popup_widget_value_tree):
* hash.c (free_hash_table):
* hash.c (grow_hash_table):
* hash.c (pregrow_hash_table_if_necessary):
* imgproc.c (build_EImage_quantable):
* insdel.c (uninit_buffer_text):
* intl-win32.c (convert_multibyte_to_internal_malloc):
* intl.c:
* intl.c (Fset_current_locale):
* keymap.c:
* keymap.c (where_is_recursive_mapper):
* keymap.c (where_is_internal):
* lisp.h:
* lisp.h (xfree):
* lstream.c (Lstream_close):
* lstream.c (resizing_buffer_closer):
* mule-coding.c:
* mule-coding.c (iso2022_finalize_detection_state):
* nt.c:
* nt.c (mswindows_get_long_filename):
* nt.c (nt_get_resource):
* nt.c (init_mswindows_environment):
* nt.c (get_cached_volume_information):
* nt.c (mswindows_opendir):
* nt.c (mswindows_closedir):
* nt.c (mswindows_readdir):
* nt.c (mswindows_stat):
* nt.c (mswindows_getdcwd):
* nt.c (Fmswindows_long_file_name):
* ntplay.c (nt_play_sound_file):
* ntplay.c (play_sound_data_1):
* number-gmp.c (gmp_free):
* number-gmp.c (init_number_gmp):
* number-mp.c (bignum_to_string):
* number-mp.c (BIGNUM_TO_TYPE):
* number.c (bignum_print):
* number.c (bignum_convfree):
* number.c (ratio_print):
* number.c (bigfloat_print):
* number.c (bigfloat_finalize):
* objects-gtk.c (gtk_finalize_color_instance):
* objects-gtk.c (gtk_finalize_font_instance):
* objects-msw.c (mswindows_finalize_color_instance):
* objects-msw.c (mswindows_finalize_font_instance):
* objects-tty.c (tty_finalize_color_instance):
* objects-tty.c (tty_finalize_font_instance):
* objects-tty.c (tty_font_list):
* objects-x.c (x_finalize_color_instance):
* objects-x.c (x_finalize_font_instance):
* process.c:
* process.c (finalize_process):
* realpath.c:
* redisplay.c (add_propagation_runes):
* regex.c:
* regex.c (xfree):
* regex.c (REGEX_FREE_STACK):
* regex.c (FREE_STACK_RETURN):
* regex.c (regex_compile):
* regex.c (regexec):
* regex.c (regfree):
* scrollbar-gtk.c (gtk_free_scrollbar_instance):
* scrollbar-gtk.c (gtk_release_scrollbar_instance):
* scrollbar-msw.c (mswindows_free_scrollbar_instance):
* scrollbar-msw.c (unshow_that_mofo):
* scrollbar-x.c (x_free_scrollbar_instance):
* scrollbar-x.c (x_release_scrollbar_instance):
* select-gtk.c (emacs_gtk_selection_handle):
* select-msw.c (mswindows_own_selection):
* select-x.c:
* select-x.c (x_handle_selection_request):
* select-x.c (unexpect_property_change):
* select-x.c (x_handle_property_notify):
* select-x.c (receive_incremental_selection):
* select-x.c (x_get_window_property_as_lisp_data):
* select-x.c (Fx_get_cutbuffer_internal):
* specifier.c (finalize_specifier):
* syntax.c (uninit_buffer_syntax_cache):
* sysdep.c (qxe_allocating_getcwd):
* sysdep.c (qxe_lstat):
* sysdep.c (copy_in_passwd):
* sysdep.c (qxe_ctime):
* sysdep.c (closedir):
* sysdep.c (DIRSIZ):
* termcap.c (tgetent):
* termcap.c (tprint):
* tests.c (Ftest_data_format_conversion):
* text.c (new_dfc_convert_copy_data):
* text.h (eifree):
* text.h (eito_alloca):
* text.h (eito_external):
* toolbar-msw.c (mswindows_output_toolbar):
* ui-gtk.c (CONVERT_RETVAL):
* ui-gtk.c (__allocate_object_storage):
* unicode.c (free_from_unicode_table):
* unicode.c (free_to_unicode_table):
* unicode.c (free_charset_unicode_tables):
* win32.c (mswindows_read_link_1):
Rename: xfree(VAL, TYPE)->xfree(VAL)
Command used:
gr 'xfree *\((.*),.*\);' 'xfree (\1);' *.[ch]
Followed by grepping for 'xfree.*,' and fixing anything left.
Rationale: Having to specify the TYPE argument is annoying and
error-prone. It was originally put in to work around warnings
due to strict aliasing but years and years ago I rewrote it
in a way that doesn't use the TYPE argument at all and no one
has complained since then. (And anyway, XEmacs is far from
ever being in compliance with strict aliasing and would require
far-reaching changes to get that way.)
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 04 Feb 2010 07:28:14 -0600 |
parents | 304aebb79cd3 |
children | 4aebb0131297 |
rev | line source |
---|---|
647 | 1 /* Selection processing for XEmacs -- common btwn select-x.c and select-gtk.c |
2 Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | |
3 | |
4 This file is part of XEmacs. | |
5 | |
6 XEmacs is free software; you can redistribute it and/or modify it | |
7 under the terms of the GNU General Public License as published by the | |
8 Free Software Foundation; either version 2, or (at your option) any | |
9 later version. | |
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 | |
17 along with XEmacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 Boston, MA 02111-1307, USA. */ | |
20 | |
21 /* Synched up with: Not synched with FSF. */ | |
22 | |
23 #ifdef PROCESSING_X_CODE | |
24 #define XE_ATOM_TYPE Atom | |
25 #define XE_ATOM_TO_SYMBOL x_atom_to_symbol | |
26 #define XE_SYMBOL_TO_ATOM symbol_to_x_atom | |
27 #else | |
28 #define XE_ATOM_TYPE GdkAtom | |
29 #define XE_ATOM_TO_SYMBOL atom_to_symbol | |
30 #define XE_SYMBOL_TO_ATOM symbol_to_gtk_atom | |
31 #endif /* PROCESSING_X_CODE */ | |
32 | |
33 /* #### These are going to move into Lisp code(!) with the aid of | |
34 some new functions I'm working on - ajh */ | |
35 | |
36 /* These functions convert from the selection data read from the server into | |
37 something that we can use from elisp, and vice versa. | |
38 | |
39 Type: Format: Size: Elisp Type: | |
40 ----- ------- ----- ----------- | |
41 * 8 * String | |
42 ATOM 32 1 Symbol | |
43 ATOM 32 > 1 Vector of Symbols | |
44 * 16 1 Integer | |
45 * 16 > 1 Vector of Integers | |
46 * 32 1 if <=16 bits: Integer | |
47 if > 16 bits: Cons of top16, bot16 | |
48 * 32 > 1 Vector of the above | |
49 | |
3833 | 50 NOTE NOTE NOTE: |
51 Format == 32 means that the buffer will be C longs, which need not be | |
52 32-bit quantities. See the note in select-x.c (x_get_window_property). | |
53 | |
647 | 54 When converting a Lisp number to C, it is assumed to be of format 16 if |
55 it is an integer, and of format 32 if it is a cons of two integers. | |
56 | |
57 When converting a vector of numbers from Elisp to C, it is assumed to be | |
58 of format 16 if every element in the vector is an integer, and is assumed | |
59 to be of format 32 if any element is a cons of two integers. | |
60 | |
61 When converting an object to C, it may be of the form (SYMBOL . <data>) | |
62 where SYMBOL is what we should claim that the type is. Format and | |
63 representation are as above. | |
64 | |
65 NOTE: Under Mule, when someone shoves us a string without a type, we | |
3025 | 66 set the type to `COMPOUND_TEXT' and automatically convert to Compound |
647 | 67 Text. If the string has a type, we assume that the user wants the |
68 data sent as-is so we just do "binary" conversion. | |
69 */ | |
70 | |
71 | |
72 static Lisp_Object | |
73 selection_data_to_lisp_data (struct device *d, | |
2367 | 74 Rawbyte *data, |
665 | 75 Bytecount size, |
647 | 76 XE_ATOM_TYPE type, |
77 int format) | |
78 { | |
79 #ifdef PROCESSING_X_CODE | |
80 if (type == DEVICE_XATOM_NULL (d)) | |
81 return QNULL; | |
82 | |
83 /* Convert any 8-bit data to a string, for compactness. */ | |
84 else if (format == 8) | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
3833
diff
changeset
|
85 return make_extstring ((Extbyte *) data, size, |
647 | 86 type == DEVICE_XATOM_TEXT (d) || |
87 type == DEVICE_XATOM_COMPOUND_TEXT (d) | |
88 ? Qctext : Qbinary); | |
89 | |
90 /* Convert a single atom to a Lisp Symbol. | |
91 Convert a set of atoms to a vector of symbols. */ | |
92 else if (type == XA_ATOM) | |
93 #else | |
94 if (type == gdk_atom_intern ("NULL", 0)) | |
95 return QNULL; | |
96 | |
97 /* Convert any 8-bit data to a string, for compactness. */ | |
98 else if (format == 8) | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
3833
diff
changeset
|
99 return make_extstring ((Extbyte *) data, size, |
647 | 100 ((type == gdk_atom_intern ("TEXT", FALSE)) || |
101 (type == gdk_atom_intern ("COMPOUND_TEXT", FALSE))) | |
102 ? Qctext : Qbinary); | |
103 | |
104 /* Convert a single atom to a Lisp Symbol. | |
105 Convert a set of atoms to a vector of symbols. */ | |
106 else if (type == gdk_atom_intern ("ATOM", FALSE)) | |
107 #endif /* PROCESSING_X_CODE */ | |
108 { | |
109 if (size == sizeof (XE_ATOM_TYPE)) | |
110 return XE_ATOM_TO_SYMBOL (d, *((XE_ATOM_TYPE *) data)); | |
111 else | |
112 { | |
665 | 113 Elemcount i; |
114 Elemcount len = size / sizeof (XE_ATOM_TYPE); | |
647 | 115 Lisp_Object v = Fmake_vector (make_int (len), Qzero); |
116 for (i = 0; i < len; i++) | |
117 Faset (v, make_int (i), XE_ATOM_TO_SYMBOL (d, ((XE_ATOM_TYPE *) data) [i])); | |
118 return v; | |
119 } | |
120 } | |
121 | |
122 /* Convert a single 16 or small 32 bit number to a Lisp Int. | |
123 If the number is > 16 bits, convert it to a cons of integers, | |
124 16 bits in each half. | |
125 */ | |
126 else if (format == 32 && size == sizeof (long)) | |
127 return word_to_lisp (((unsigned long *) data) [0]); | |
128 else if (format == 16 && size == sizeof (short)) | |
129 return make_int ((int) (((unsigned short *) data) [0])); | |
130 | |
131 /* Convert any other kind of data to a vector of numbers, represented | |
132 as above (as an integer, or a cons of two 16 bit integers). | |
133 | |
134 #### Perhaps we should return the actual type to lisp as well. | |
135 | |
136 (x-get-selection-internal 'PRIMARY 'LINE_NUMBER) | |
137 ==> [4 4] | |
138 | |
139 and perhaps it should be | |
140 | |
141 (x-get-selection-internal 'PRIMARY 'LINE_NUMBER) | |
142 ==> (SPAN . [4 4]) | |
143 | |
144 Right now the fact that the return type was SPAN is discarded before | |
145 lisp code gets to see it. | |
146 */ | |
147 else if (format == 16) | |
148 { | |
665 | 149 Elemcount i; |
647 | 150 Lisp_Object v = make_vector (size / 4, Qzero); |
151 for (i = 0; i < size / 4; i++) | |
152 { | |
153 int j = (int) ((unsigned short *) data) [i]; | |
154 Faset (v, make_int (i), make_int (j)); | |
155 } | |
156 return v; | |
157 } | |
158 else | |
159 { | |
665 | 160 Elemcount i; |
647 | 161 Lisp_Object v = make_vector (size / 4, Qzero); |
162 for (i = 0; i < size / 4; i++) | |
163 { | |
164 unsigned long j = ((unsigned long *) data) [i]; | |
165 Faset (v, make_int (i), word_to_lisp (j)); | |
166 } | |
167 return v; | |
168 } | |
169 } | |
170 | |
171 | |
172 static void | |
173 lisp_data_to_selection_data (struct device *d, | |
174 Lisp_Object obj, | |
2367 | 175 Rawbyte **data_ret, |
647 | 176 XE_ATOM_TYPE *type_ret, |
665 | 177 Bytecount *size_ret, |
647 | 178 int *format_ret) |
179 { | |
180 Lisp_Object type = Qnil; | |
181 | |
182 if (CONSP (obj) && SYMBOLP (XCAR (obj))) | |
183 { | |
184 type = XCAR (obj); | |
185 obj = XCDR (obj); | |
186 if (CONSP (obj) && NILP (XCDR (obj))) | |
187 obj = XCAR (obj); | |
188 } | |
189 | |
190 if (EQ (obj, QNULL) || (EQ (type, QNULL))) | |
191 { /* This is not the same as declining */ | |
192 *format_ret = 32; | |
193 *size_ret = 0; | |
194 *data_ret = 0; | |
195 type = QNULL; | |
196 } | |
197 else if (STRINGP (obj)) | |
198 { | |
199 const Extbyte *extval; | |
665 | 200 Bytecount extvallen; |
647 | 201 |
202 TO_EXTERNAL_FORMAT (LISP_STRING, obj, | |
203 ALLOCA, (extval, extvallen), | |
204 (NILP (type) ? Qctext : Qbinary)); | |
205 *format_ret = 8; | |
206 *size_ret = extvallen; | |
2367 | 207 *data_ret = xnew_rawbytes (*size_ret); |
647 | 208 memcpy (*data_ret, extval, *size_ret); |
209 #ifdef MULE | |
210 if (NILP (type)) type = QCOMPOUND_TEXT; | |
211 #else | |
212 if (NILP (type)) type = QSTRING; | |
213 #endif | |
214 } | |
215 else if (CHARP (obj)) | |
216 { | |
867 | 217 Ibyte buf[MAX_ICHAR_LEN]; |
647 | 218 Bytecount len; |
219 const Extbyte *extval; | |
665 | 220 Bytecount extvallen; |
647 | 221 |
222 *format_ret = 8; | |
867 | 223 len = set_itext_ichar (buf, XCHAR (obj)); |
647 | 224 TO_EXTERNAL_FORMAT (DATA, (buf, len), |
225 ALLOCA, (extval, extvallen), | |
226 Qctext); | |
227 *size_ret = extvallen; | |
2367 | 228 *data_ret = xnew_rawbytes (*size_ret); |
647 | 229 memcpy (*data_ret, extval, *size_ret); |
230 #ifdef MULE | |
231 if (NILP (type)) type = QCOMPOUND_TEXT; | |
232 #else | |
233 if (NILP (type)) type = QSTRING; | |
234 #endif | |
235 } | |
236 else if (SYMBOLP (obj)) | |
237 { | |
238 *format_ret = 32; | |
239 *size_ret = 1; | |
2367 | 240 *data_ret = xnew_rawbytes (sizeof (XE_ATOM_TYPE) + 1); |
647 | 241 (*data_ret) [sizeof (XE_ATOM_TYPE)] = 0; |
242 (*(XE_ATOM_TYPE **) data_ret) [0] = XE_SYMBOL_TO_ATOM (d, obj, 0); | |
243 if (NILP (type)) type = QATOM; | |
244 } | |
245 else if (INTP (obj) && | |
246 XINT (obj) <= 0x7FFF && | |
247 XINT (obj) >= -0x8000) | |
248 { | |
249 *format_ret = 16; | |
250 *size_ret = 1; | |
2367 | 251 *data_ret = xnew_rawbytes (sizeof (short) + 1); |
647 | 252 (*data_ret) [sizeof (short)] = 0; |
253 (*(short **) data_ret) [0] = (short) XINT (obj); | |
254 if (NILP (type)) type = QINTEGER; | |
255 } | |
256 else if (INTP (obj) || CONSP (obj)) | |
257 { | |
258 *format_ret = 32; | |
259 *size_ret = 1; | |
2367 | 260 *data_ret = xnew_rawbytes (sizeof (long) + 1); |
647 | 261 (*data_ret) [sizeof (long)] = 0; |
262 (*(unsigned long **) data_ret) [0] = lisp_to_word (obj); | |
263 if (NILP (type)) type = QINTEGER; | |
264 } | |
265 else if (VECTORP (obj)) | |
266 { | |
267 /* Lisp Vectors may represent a set of ATOMs; | |
268 a set of 16 or 32 bit INTEGERs; | |
269 or a set of ATOM_PAIRs (represented as [[A1 A2] [A3 A4] ...] | |
270 */ | |
665 | 271 Elemcount i; |
647 | 272 |
273 if (SYMBOLP (XVECTOR_DATA (obj) [0])) | |
274 /* This vector is an ATOM set */ | |
275 { | |
276 if (NILP (type)) type = QATOM; | |
277 *size_ret = XVECTOR_LENGTH (obj); | |
278 *format_ret = 32; | |
2367 | 279 *data_ret = xnew_rawbytes ((*size_ret) * sizeof (XE_ATOM_TYPE)); |
647 | 280 for (i = 0; i < *size_ret; i++) |
281 if (SYMBOLP (XVECTOR_DATA (obj) [i])) | |
282 (*(XE_ATOM_TYPE **) data_ret) [i] = | |
283 XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (obj) [i], 0); | |
284 else | |
285 syntax_error | |
286 ("all elements of the vector must be of the same type", obj); | |
287 } | |
288 #if 0 /* #### MULTIPLE doesn't work yet */ | |
289 else if (VECTORP (XVECTOR_DATA (obj) [0])) | |
290 /* This vector is an ATOM_PAIR set */ | |
291 { | |
292 if (NILP (type)) type = QATOM_PAIR; | |
293 *size_ret = XVECTOR_LENGTH (obj); | |
294 *format_ret = 32; | |
2367 | 295 *data_ret = |
296 xnew_rawbytes ((*size_ret) * sizeof (XE_ATOM_TYPE) * 2); | |
647 | 297 for (i = 0; i < *size_ret; i++) |
298 if (VECTORP (XVECTOR_DATA (obj) [i])) | |
299 { | |
300 Lisp_Object pair = XVECTOR_DATA (obj) [i]; | |
301 if (XVECTOR_LENGTH (pair) != 2) | |
302 syntax_error | |
303 ("elements of the vector must be vectors of exactly two elements", pair); | |
304 | |
305 (*(XE_ATOM_TYPE **) data_ret) [i * 2] = | |
306 XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (pair) [0], 0); | |
307 (*(XE_ATOM_TYPE **) data_ret) [(i * 2) + 1] = | |
308 XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (pair) [1], 0); | |
309 } | |
310 else | |
311 syntax_error | |
312 ("all elements of the vector must be of the same type", obj); | |
313 } | |
314 #endif | |
315 else | |
316 /* This vector is an INTEGER set, or something like it */ | |
317 { | |
318 *size_ret = XVECTOR_LENGTH (obj); | |
319 if (NILP (type)) type = QINTEGER; | |
320 *format_ret = 16; | |
321 for (i = 0; i < *size_ret; i++) | |
322 if (CONSP (XVECTOR_DATA (obj) [i])) | |
323 *format_ret = 32; | |
324 else if (!INTP (XVECTOR_DATA (obj) [i])) | |
325 syntax_error | |
326 ("all elements of the vector must be integers or conses of integers", obj); | |
327 | |
2367 | 328 *data_ret = xnew_rawbytes (*size_ret * (*format_ret/8)); |
647 | 329 for (i = 0; i < *size_ret; i++) |
330 if (*format_ret == 32) | |
331 (*((unsigned long **) data_ret)) [i] = | |
332 lisp_to_word (XVECTOR_DATA (obj) [i]); | |
333 else | |
334 (*((unsigned short **) data_ret)) [i] = | |
335 (unsigned short) lisp_to_word (XVECTOR_DATA (obj) [i]); | |
336 } | |
337 } | |
338 else | |
339 invalid_argument ("unrecognized selection data", obj); | |
340 | |
341 *type_ret = XE_SYMBOL_TO_ATOM (d, type, 0); | |
342 } | |
343 |