annotate src/select-common.h @ 4072:aa28d959af41

[xemacs-hg @ 2007-07-22 22:03:29 by aidan] Add support for non-ISO2022 8 bit fixed-width coding-systems
author aidan
date Sun, 22 Jul 2007 22:04:14 +0000
parents 2b1e7cb9ae2c
children 304aebb79cd3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
1 /* Selection processing for XEmacs -- common btwn select-x.c and select-gtk.c
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
2 Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
3
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
4 This file is part of XEmacs.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
5
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
9 later version.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
10
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
14 for more details.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
15
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
20
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
21 /* Synched up with: Not synched with FSF. */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
22
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
23 #ifdef PROCESSING_X_CODE
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
24 #define XE_ATOM_TYPE Atom
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
25 #define XE_ATOM_TO_SYMBOL x_atom_to_symbol
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
26 #define XE_SYMBOL_TO_ATOM symbol_to_x_atom
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
27 #else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
28 #define XE_ATOM_TYPE GdkAtom
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
29 #define XE_ATOM_TO_SYMBOL atom_to_symbol
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
30 #define XE_SYMBOL_TO_ATOM symbol_to_gtk_atom
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
31 #endif /* PROCESSING_X_CODE */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
32
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
33 /* #### These are going to move into Lisp code(!) with the aid of
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
34 some new functions I'm working on - ajh */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
35
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
36 /* These functions convert from the selection data read from the server into
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
37 something that we can use from elisp, and vice versa.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
38
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
39 Type: Format: Size: Elisp Type:
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
40 ----- ------- ----- -----------
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
41 * 8 * String
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
42 ATOM 32 1 Symbol
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
43 ATOM 32 > 1 Vector of Symbols
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
44 * 16 1 Integer
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
45 * 16 > 1 Vector of Integers
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
46 * 32 1 if <=16 bits: Integer
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
47 if > 16 bits: Cons of top16, bot16
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
48 * 32 > 1 Vector of the above
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
49
3833
2b1e7cb9ae2c [xemacs-hg @ 2007-02-17 15:55:21 by stephent]
stephent
parents: 3025
diff changeset
50 NOTE NOTE NOTE:
2b1e7cb9ae2c [xemacs-hg @ 2007-02-17 15:55:21 by stephent]
stephent
parents: 3025
diff changeset
51 Format == 32 means that the buffer will be C longs, which need not be
2b1e7cb9ae2c [xemacs-hg @ 2007-02-17 15:55:21 by stephent]
stephent
parents: 3025
diff changeset
52 32-bit quantities. See the note in select-x.c (x_get_window_property).
2b1e7cb9ae2c [xemacs-hg @ 2007-02-17 15:55:21 by stephent]
stephent
parents: 3025
diff changeset
53
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
54 When converting a Lisp number to C, it is assumed to be of format 16 if
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
55 it is an integer, and of format 32 if it is a cons of two integers.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
56
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
57 When converting a vector of numbers from Elisp to C, it is assumed to be
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
58 of format 16 if every element in the vector is an integer, and is assumed
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
59 to be of format 32 if any element is a cons of two integers.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
60
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
61 When converting an object to C, it may be of the form (SYMBOL . <data>)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
62 where SYMBOL is what we should claim that the type is. Format and
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
63 representation are as above.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
64
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
65 NOTE: Under Mule, when someone shoves us a string without a type, we
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
66 set the type to `COMPOUND_TEXT' and automatically convert to Compound
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
67 Text. If the string has a type, we assume that the user wants the
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
68 data sent as-is so we just do "binary" conversion.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
69 */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
70
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
71
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
72 static Lisp_Object
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
73 selection_data_to_lisp_data (struct device *d,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
74 Rawbyte *data,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
75 Bytecount size,
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
76 XE_ATOM_TYPE type,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
77 int format)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
78 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
79 #ifdef PROCESSING_X_CODE
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
80 if (type == DEVICE_XATOM_NULL (d))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
81 return QNULL;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
82
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
83 /* Convert any 8-bit data to a string, for compactness. */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
84 else if (format == 8)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
85 return make_ext_string ((Extbyte *) data, size,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
86 type == DEVICE_XATOM_TEXT (d) ||
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
87 type == DEVICE_XATOM_COMPOUND_TEXT (d)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
88 ? Qctext : Qbinary);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
89
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
90 /* Convert a single atom to a Lisp Symbol.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
91 Convert a set of atoms to a vector of symbols. */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
92 else if (type == XA_ATOM)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
93 #else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
94 if (type == gdk_atom_intern ("NULL", 0))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
95 return QNULL;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
96
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
97 /* Convert any 8-bit data to a string, for compactness. */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
98 else if (format == 8)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
99 return make_ext_string ((Extbyte *) data, size,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
100 ((type == gdk_atom_intern ("TEXT", FALSE)) ||
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
101 (type == gdk_atom_intern ("COMPOUND_TEXT", FALSE)))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
102 ? Qctext : Qbinary);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
103
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
104 /* Convert a single atom to a Lisp Symbol.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
105 Convert a set of atoms to a vector of symbols. */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
106 else if (type == gdk_atom_intern ("ATOM", FALSE))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
107 #endif /* PROCESSING_X_CODE */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
108 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
109 if (size == sizeof (XE_ATOM_TYPE))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
110 return XE_ATOM_TO_SYMBOL (d, *((XE_ATOM_TYPE *) data));
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
111 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
112 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
113 Elemcount i;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
114 Elemcount len = size / sizeof (XE_ATOM_TYPE);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
115 Lisp_Object v = Fmake_vector (make_int (len), Qzero);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
116 for (i = 0; i < len; i++)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
117 Faset (v, make_int (i), XE_ATOM_TO_SYMBOL (d, ((XE_ATOM_TYPE *) data) [i]));
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
118 return v;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
119 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
120 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
121
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
122 /* Convert a single 16 or small 32 bit number to a Lisp Int.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
123 If the number is > 16 bits, convert it to a cons of integers,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
124 16 bits in each half.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
125 */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
126 else if (format == 32 && size == sizeof (long))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
127 return word_to_lisp (((unsigned long *) data) [0]);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
128 else if (format == 16 && size == sizeof (short))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
129 return make_int ((int) (((unsigned short *) data) [0]));
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
130
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
131 /* Convert any other kind of data to a vector of numbers, represented
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
132 as above (as an integer, or a cons of two 16 bit integers).
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
133
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
134 #### Perhaps we should return the actual type to lisp as well.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
135
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
136 (x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
137 ==> [4 4]
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
138
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
139 and perhaps it should be
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
140
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
141 (x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
142 ==> (SPAN . [4 4])
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
143
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
144 Right now the fact that the return type was SPAN is discarded before
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
145 lisp code gets to see it.
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
146 */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
147 else if (format == 16)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
148 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
149 Elemcount i;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
150 Lisp_Object v = make_vector (size / 4, Qzero);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
151 for (i = 0; i < size / 4; i++)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
152 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
153 int j = (int) ((unsigned short *) data) [i];
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
154 Faset (v, make_int (i), make_int (j));
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
155 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
156 return v;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
157 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
158 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
159 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
160 Elemcount i;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
161 Lisp_Object v = make_vector (size / 4, Qzero);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
162 for (i = 0; i < size / 4; i++)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
163 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
164 unsigned long j = ((unsigned long *) data) [i];
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
165 Faset (v, make_int (i), word_to_lisp (j));
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
166 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
167 return v;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
168 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
169 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
170
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
171
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
172 static void
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
173 lisp_data_to_selection_data (struct device *d,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
174 Lisp_Object obj,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
175 Rawbyte **data_ret,
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
176 XE_ATOM_TYPE *type_ret,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
177 Bytecount *size_ret,
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
178 int *format_ret)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
179 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
180 Lisp_Object type = Qnil;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
181
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
182 if (CONSP (obj) && SYMBOLP (XCAR (obj)))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
183 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
184 type = XCAR (obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
185 obj = XCDR (obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
186 if (CONSP (obj) && NILP (XCDR (obj)))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
187 obj = XCAR (obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
188 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
189
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
190 if (EQ (obj, QNULL) || (EQ (type, QNULL)))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
191 { /* This is not the same as declining */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
192 *format_ret = 32;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
193 *size_ret = 0;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
194 *data_ret = 0;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
195 type = QNULL;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
196 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
197 else if (STRINGP (obj))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
198 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
199 const Extbyte *extval;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
200 Bytecount extvallen;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
201
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
202 TO_EXTERNAL_FORMAT (LISP_STRING, obj,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
203 ALLOCA, (extval, extvallen),
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
204 (NILP (type) ? Qctext : Qbinary));
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
205 *format_ret = 8;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
206 *size_ret = extvallen;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
207 *data_ret = xnew_rawbytes (*size_ret);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
208 memcpy (*data_ret, extval, *size_ret);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
209 #ifdef MULE
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
210 if (NILP (type)) type = QCOMPOUND_TEXT;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
211 #else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
212 if (NILP (type)) type = QSTRING;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
213 #endif
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
214 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
215 else if (CHARP (obj))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
216 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 665
diff changeset
217 Ibyte buf[MAX_ICHAR_LEN];
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
218 Bytecount len;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
219 const Extbyte *extval;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
220 Bytecount extvallen;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
221
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
222 *format_ret = 8;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 665
diff changeset
223 len = set_itext_ichar (buf, XCHAR (obj));
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
224 TO_EXTERNAL_FORMAT (DATA, (buf, len),
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
225 ALLOCA, (extval, extvallen),
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
226 Qctext);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
227 *size_ret = extvallen;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
228 *data_ret = xnew_rawbytes (*size_ret);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
229 memcpy (*data_ret, extval, *size_ret);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
230 #ifdef MULE
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
231 if (NILP (type)) type = QCOMPOUND_TEXT;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
232 #else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
233 if (NILP (type)) type = QSTRING;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
234 #endif
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
235 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
236 else if (SYMBOLP (obj))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
237 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
238 *format_ret = 32;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
239 *size_ret = 1;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
240 *data_ret = xnew_rawbytes (sizeof (XE_ATOM_TYPE) + 1);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
241 (*data_ret) [sizeof (XE_ATOM_TYPE)] = 0;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
242 (*(XE_ATOM_TYPE **) data_ret) [0] = XE_SYMBOL_TO_ATOM (d, obj, 0);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
243 if (NILP (type)) type = QATOM;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
244 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
245 else if (INTP (obj) &&
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
246 XINT (obj) <= 0x7FFF &&
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
247 XINT (obj) >= -0x8000)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
248 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
249 *format_ret = 16;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
250 *size_ret = 1;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
251 *data_ret = xnew_rawbytes (sizeof (short) + 1);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
252 (*data_ret) [sizeof (short)] = 0;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
253 (*(short **) data_ret) [0] = (short) XINT (obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
254 if (NILP (type)) type = QINTEGER;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
255 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
256 else if (INTP (obj) || CONSP (obj))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
257 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
258 *format_ret = 32;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
259 *size_ret = 1;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
260 *data_ret = xnew_rawbytes (sizeof (long) + 1);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
261 (*data_ret) [sizeof (long)] = 0;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
262 (*(unsigned long **) data_ret) [0] = lisp_to_word (obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
263 if (NILP (type)) type = QINTEGER;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
264 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
265 else if (VECTORP (obj))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
266 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
267 /* Lisp Vectors may represent a set of ATOMs;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
268 a set of 16 or 32 bit INTEGERs;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
269 or a set of ATOM_PAIRs (represented as [[A1 A2] [A3 A4] ...]
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
270 */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 647
diff changeset
271 Elemcount i;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
272
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
273 if (SYMBOLP (XVECTOR_DATA (obj) [0]))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
274 /* This vector is an ATOM set */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
275 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
276 if (NILP (type)) type = QATOM;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
277 *size_ret = XVECTOR_LENGTH (obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
278 *format_ret = 32;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
279 *data_ret = xnew_rawbytes ((*size_ret) * sizeof (XE_ATOM_TYPE));
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
280 for (i = 0; i < *size_ret; i++)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
281 if (SYMBOLP (XVECTOR_DATA (obj) [i]))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
282 (*(XE_ATOM_TYPE **) data_ret) [i] =
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
283 XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (obj) [i], 0);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
284 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
285 syntax_error
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
286 ("all elements of the vector must be of the same type", obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
287 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
288 #if 0 /* #### MULTIPLE doesn't work yet */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
289 else if (VECTORP (XVECTOR_DATA (obj) [0]))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
290 /* This vector is an ATOM_PAIR set */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
291 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
292 if (NILP (type)) type = QATOM_PAIR;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
293 *size_ret = XVECTOR_LENGTH (obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
294 *format_ret = 32;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
295 *data_ret =
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
296 xnew_rawbytes ((*size_ret) * sizeof (XE_ATOM_TYPE) * 2);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
297 for (i = 0; i < *size_ret; i++)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
298 if (VECTORP (XVECTOR_DATA (obj) [i]))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
299 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
300 Lisp_Object pair = XVECTOR_DATA (obj) [i];
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
301 if (XVECTOR_LENGTH (pair) != 2)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
302 syntax_error
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
303 ("elements of the vector must be vectors of exactly two elements", pair);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
304
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
305 (*(XE_ATOM_TYPE **) data_ret) [i * 2] =
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
306 XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (pair) [0], 0);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
307 (*(XE_ATOM_TYPE **) data_ret) [(i * 2) + 1] =
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
308 XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (pair) [1], 0);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
309 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
310 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
311 syntax_error
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
312 ("all elements of the vector must be of the same type", obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
313 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
314 #endif
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
315 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
316 /* This vector is an INTEGER set, or something like it */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
317 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
318 *size_ret = XVECTOR_LENGTH (obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
319 if (NILP (type)) type = QINTEGER;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
320 *format_ret = 16;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
321 for (i = 0; i < *size_ret; i++)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
322 if (CONSP (XVECTOR_DATA (obj) [i]))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
323 *format_ret = 32;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
324 else if (!INTP (XVECTOR_DATA (obj) [i]))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
325 syntax_error
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
326 ("all elements of the vector must be integers or conses of integers", obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
327
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
328 *data_ret = xnew_rawbytes (*size_ret * (*format_ret/8));
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
329 for (i = 0; i < *size_ret; i++)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
330 if (*format_ret == 32)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
331 (*((unsigned long **) data_ret)) [i] =
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
332 lisp_to_word (XVECTOR_DATA (obj) [i]);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
333 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
334 (*((unsigned short **) data_ret)) [i] =
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
335 (unsigned short) lisp_to_word (XVECTOR_DATA (obj) [i]);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
336 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
337 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
338 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
339 invalid_argument ("unrecognized selection data", obj);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
340
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
341 *type_ret = XE_SYMBOL_TO_ATOM (d, type, 0);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
342 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents:
diff changeset
343