changeset 4984:f23cd0184dcf

xlike, doc changes -------------------- ChangeLog entries follow: -------------------- man/ChangeLog addition: 2010-02-05 Ben Wing <ben@xemacs.org> * internals/internals.texi (A Summary of the Various XEmacs Modules): * internals/internals.texi (Conversion to and from External Data): * internals/internals.texi (General Guidelines for Writing Mule-Aware Code): Correct names of files renamed common -> xlike. Fix up outdated explanation of old-style DFC conversion macros. Add a section on the different types of character and their uses, taken from a long comment in lisp.h. src/ChangeLog addition: 2010-02-05 Ben Wing <ben@xemacs.org> * depend: Regenerate. * make-src-depend (PrintPatternDeps): Remove refs to xgccache, no longer existent. * select-gtk.c (THIS_IS_GTK): * select-gtk.c (gtk_decline_selection_request): * select-x.c (THIS_IS_X): * select-xlike-inc.c: * select-xlike-inc.c (selection_data_to_lisp_data): Rename PROCESSING_X_CODE to THIS_IS_X and PROCESSING_GTK_CODE to THIS_SI_GTK for consistency with other xlike code. Rename select-xlike-inc.c from select-common.h, in keeping with xlike terminology.
author Ben Wing <ben@xemacs.org>
date Fri, 05 Feb 2010 12:11:12 -0600
parents 4234fd5a7b17
children 358aa3bb603f
files man/ChangeLog man/internals/internals.texi src/ChangeLog src/depend src/make-src-depend src/select-common.h src/select-gtk.c src/select-x.c src/select-xlike-inc.c
diffstat 9 files changed, 467 insertions(+), 380 deletions(-) [+]
line wrap: on
line diff
--- a/man/ChangeLog	Fri Feb 05 08:09:03 2010 -0600
+++ b/man/ChangeLog	Fri Feb 05 12:11:12 2010 -0600
@@ -1,3 +1,13 @@
+2010-02-05  Ben Wing  <ben@xemacs.org>
+
+	* internals/internals.texi (A Summary of the Various XEmacs Modules):
+	* internals/internals.texi (Conversion to and from External Data):
+	* internals/internals.texi (General Guidelines for Writing Mule-Aware Code):
+	Correct names of files renamed common -> xlike.
+	Fix up outdated explanation of old-style DFC conversion macros.
+	Add a section on the different types of character and their uses,
+	taken from a long comment in lisp.h.
+
 2010-01-27  Ben Wing  <ben@xemacs.org>
 
 	* internals/internals.texi (lrecords):
--- a/man/internals/internals.texi	Fri Feb 05 08:09:03 2010 -0600
+++ b/man/internals/internals.texi	Fri Feb 05 12:11:12 2010 -0600
@@ -3183,7 +3183,7 @@
 @item @file{scrollbar.c} @tab @ref{Modules for other Display-Related Lisp Objects}.
 @item @file{scrollbar.h} @tab @ref{Modules for other Display-Related Lisp Objects}.
 @item @file{search.c} @tab @ref{Modules for Standard Editing Operations}.
-@item @file{select-common.h} @tab
+@item @file{select-xlike-inc.c} @tab
 @item @file{select-gtk.c} @tab
 @item @file{select-msw.c} @tab @ref{Modules for Interfacing with X Windows}.
 @item @file{select-x.c} @tab @ref{Modules for Interfacing with X Windows}.
@@ -3229,8 +3229,8 @@
 @item @file{tests.c} @tab
 @item @file{text.c} @tab
 @item @file{text.h} @tab
-@item @file{toolbar-common.c} @tab
-@item @file{toolbar-common.h} @tab
+@item @file{toolbar-xlike.c} @tab
+@item @file{toolbar-xlike.h} @tab
 @item @file{toolbar-gtk.c} @tab
 @item @file{toolbar-msw.c} @tab @ref{Modules for other Display-Related Lisp Objects}.
 @item @file{toolbar-x.c} @tab @ref{Modules for other Display-Related Lisp Objects}.
@@ -12901,19 +12901,18 @@
 especially when the output is an @code{alloca()}ed string. (When the
 destination is a Lisp string, there are other functions that should be
 used instead -- @code{build_extstring()} and @code{make_extstring()},
-for example.) The convenience macros are of two types -- the older kind
-that store the result into a specified variable, and the newer kind that
-return the result.  The newer kind of macros don't exist when the output
-is sized data, because that would have two return values.  NOTE: All
-convenience macros are ultimately defined in terms of
-@code{TO_EXTERNAL_FORMAT} and @code{TO_INTERNAL_FORMAT}.  Thus, any
-comments above about the workings of these macros also apply to all
-convenience macros.
-
-A typical old-style convenience macro is
-
-@example
-  C_STRING_TO_EXTERNAL (in, out, codesys);
+for example.) Most convenience macros return the result as the return
+value.  However, when two values need to be returned (that is, the
+output is sized data), both values are stored into variables that are
+passed into the macros as parameters.  NOTE: All convenience macros
+are ultimately defined in terms of @code{TO_EXTERNAL_FORMAT} and
+@code{TO_INTERNAL_FORMAT}.  Thus, any comments above about the
+workings of these macros also apply to all convenience macros.
+
+A typical convenience macro is
+
+@example
+  out = ITEXT_TO_EXTERNAL (in, codesys);
 @end example
 
 This is equivalent to
@@ -12922,14 +12921,13 @@
   TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, codesys);
 @end example
 
-but is easier to write and somewhat clearer, since it clearly identifies
-the arguments without the clutter of having the preprocessor types mixed
-in.
-
-The new-style equivalent is @code{NEW_C_STRING_TO_EXTERNAL (src,
-codesys)}, which @emph{returns} the converted data (still in
-@code{alloca()} space).  This is far more convenient for most
-operations.
+but is easier to write and somewhat clearer, since it clearly
+identifies the arguments without the clutter of having the
+preprocessor types mixed in.  Furthermore, it @emph{returns} the
+converted data (still in @code{alloca()} space) rather than
+@emph{storing} it, which is far more convenient for most operations
+as there is no need to declare an extra temporary variable to hold
+the return value.
 
 @node General Guidelines for Writing Mule-Aware Code, An Example of Mule-Aware Code, Conversion to and from External Data, Coding for Mule
 @subsection General Guidelines for Writing Mule-Aware Code
@@ -12948,9 +12946,69 @@
 format, use @code{Ibyte}.  If you want a Lisp-visible character, use a
 @code{Lisp_Object} and @code{make_char}.  If you want a pointer to move
 through the internal text, use @code{Ibyte *}.  Also note that you
-almost certainly do not need @code{Ichar *}.  Other typedefs to clarify
-the use of @code{char} are @code{Char_ASCII}, @code{Char_Binary},
-@code{UChar_Binary}, and @code{CIbyte}.
+almost certainly do not need @code{Ichar *}.
+
+All uses of @code{char} should be replaced with one of the following:
+
+@table @code
+@item Ibyte
+Pointer to internally-formatted text.  The data representing the text
+in a buffer is logically a set of Ibytes.
+@item CIbyte
+Used when you are working with internal data but for whatever reason
+need to have it declared a @code{char *}.  Examples are function arguments
+whose values are most commonly literal strings, or where you have to
+apply a stdlib string function to internal data.
+
+In general, you should avoid this where possible and use Ascbyte if the
+text is just ASCII (e.g. string literals) or otherwise Ibyte, for
+consistency.  For example, the new Mule workspace contains Ibyte
+versions of the stdlib string functions.
+@item Extbyte, UExtbyte
+Pointer to text in some external format, which can be defined as all
+formats other than the internal one.  The data representing a string
+in "external" format (binary or any external encoding) is logically a
+set of Extbytes.  Extbyte is guaranteed to be just a char, so for
+example strlen (Extbyte *) is OK.  Extbyte is only a documentation
+device for referring to external text.
+@item Ascbyte, UAscbyte
+pure ASCII text, consisting of bytesf in a string in entirely US-ASCII
+format: (Nothing outside the range 00 - 7F).
+@item Binbyte, CBinbyte, SBinbyte
+Binary data that is not meant to be interpreted as text.
+@item Rawbyte, CRawbyte
+General data in memory, where we don't care about whether it's text or
+binary; often used when computing memory-based/byte-based offsets of
+pointers.  In general, there should be no manipulation of the memory
+pointed to by these pointers other than just copying it around.
+@item Boolbyte
+A byte used to represent a boolean value: 0 or 1.
+Normally use plain Boolint, and only use Boolbyte to save space.
+@item Bitbyte
+A byte composed of bitfields.  Hardly ever used.
+@item Chbyte, UChbyte, SChbyte
+A no-semantics @code{char}.  Used (pretty-much) ONLY for casting
+arguments to functions accepting a @code{char *}, @code{unsigned char
+*}, etc. where the other types don't exactly apply and what you are
+logically concerned with is the type of the function's argument and
+not its semantics.
+
+DO NOT DO NOT DO NOT DO NOT use this as a sloppy replacement for one of
+the other types.  If you're not using this as part of casting an
+argument to a function call, and you're not Ben Wing, you're using it
+wrong.  Go find another one of the types.
+@end table
+
+Note the significance of the prefixed versions of the above types:
+
+@table @code
+@item U
+@code{unsigned char}
+@item S
+@code{signed char}
+@item C
+plain @code{char}
+@end table
 
 @item Be careful not to confuse @code{Charcount}, @code{Bytecount}, @code{Charbpos} and @code{Bytebpos}.
 The whole point of using different types is to avoid confusion about the
--- a/src/ChangeLog	Fri Feb 05 08:09:03 2010 -0600
+++ b/src/ChangeLog	Fri Feb 05 12:11:12 2010 -0600
@@ -1,3 +1,21 @@
+2010-02-05  Ben Wing  <ben@xemacs.org>
+
+	* depend:
+	Regenerate.
+	* make-src-depend (PrintPatternDeps):
+	Remove refs to xgccache, no longer existent.
+	
+	* select-gtk.c (THIS_IS_GTK):
+	* select-gtk.c (gtk_decline_selection_request):
+	* select-x.c (THIS_IS_X):
+	* select-xlike-inc.c:
+	* select-xlike-inc.c (selection_data_to_lisp_data):
+	Rename PROCESSING_X_CODE to THIS_IS_X and PROCESSING_GTK_CODE to
+	THIS_SI_GTK for consistency with other xlike code.
+	
+	Rename select-xlike-inc.c from select-common.h, in keeping with
+	xlike terminology.
+
 2010-02-05  Ben Wing  <ben@xemacs.org>
 
 	* lisp.h:
--- a/src/depend	Fri Feb 05 08:09:03 2010 -0600
+++ b/src/depend	Fri Feb 05 12:11:12 2010 -0600
@@ -34,6 +34,7 @@
 event-xlike-inc.o: 
 objects-xlike-inc.o: $(LWLIB_SRCDIR)/lwlib.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects.h redisplay.h scrollbar.h specifier.h sysgtk.h window-impl.h window.h winslots.h xintrinsic.h
 redisplay-xlike-inc.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h debug.h device-impl.h device.h devslots.h dumper.h faces.h file-coding.h frame-impl.h frame.h frameslots.h gc.h gccache-gtk.h gccache-x.h general-slots.h glyphs-gtk.h glyphs-x.h glyphs.h gutter.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h mule-ccl.h number-gmp.h number-mp.h number.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects.h redisplay.h scrollbar.h specifier.h symeval.h symsinit.h sysdep.h sysgtk.h sysproc.h syssignal.h systime.h text.h vdb.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h
+select-xlike-inc.o: 
 toolbar-xlike.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h charset.h compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h dumper.h faces.h frame-impl.h frame.h frameslots.h gc.h general-slots.h glyphs.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h redisplay.h scrollbar.h specifier.h symeval.h symsinit.h sysgtk.h text.h toolbar-xlike.h toolbar.h vdb.h window-impl.h window.h winslots.h xintrinsic.h
 #endif
 #if defined(HAVE_X_WINDOWS)
@@ -55,7 +56,7 @@
 objects-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h charset.h compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h device-impl.h device.h devslots.h dumper.h elhash.h font-mgr.h gc.h gccache-gtk.h gccache-x.h general-slots.h glyphs-gtk.h glyphs-x.h glyphs.h insdel.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects-xlike-inc.c objects.h redisplay.h scrollbar.h specifier.h symeval.h symsinit.h sysgtk.h text.h vdb.h window-impl.h window.h winslots.h xintrinsic.h
 redisplay-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h debug.h device-impl.h device.h devslots.h dumper.h faces.h file-coding.h frame-impl.h frame.h frameslots.h gc.h gccache-gtk.h gccache-x.h general-slots.h glyphs-gtk.h glyphs-x.h glyphs.h gutter.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h mule-ccl.h number-gmp.h number-mp.h number.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects.h redisplay-xlike-inc.c redisplay.h scrollbar.h specifier.h symeval.h symsinit.h sysdep.h sysgtk.h sysproc.h syssignal.h systime.h text.h vdb.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h
 scrollbar-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h compiler.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h dumper.h frame-impl.h frame.h frameslots.h gc.h general-slots.h glyphs-x.h glyphs.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h redisplay.h scrollbar-x.h scrollbar.h specifier.h symeval.h symsinit.h text.h vdb.h window-impl.h window.h winslots.h xintrinsic.h
-select-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h charset.h compiler.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h dumper.h frame-impl.h frame.h frameslots.h gc.h general-slots.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h objects-x.h objects.h opaque.h redisplay.h select-common.h select.h specifier.h symeval.h symsinit.h systime.h text.h vdb.h xintrinsic.h xmotif.h
+select-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h charset.h compiler.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h dumper.h frame-impl.h frame.h frameslots.h gc.h general-slots.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h objects-x.h objects.h opaque.h redisplay.h select-xlike-inc.c select.h specifier.h symeval.h symsinit.h systime.h text.h vdb.h xintrinsic.h xmotif.h
 toolbar-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h charset.h compiler.h conslots.h console-impl.h console-x-impl.h console-x.h console.h dumper.h faces.h frame-impl.h frame.h frameslots.h gc.h general-slots.h glyphs-x.h glyphs.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h objects-x.h objects.h redisplay.h scrollbar.h specifier.h symeval.h symsinit.h text.h toolbar-xlike.h toolbar.h vdb.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h
 #endif
 #if defined(HAVE_TTY)
@@ -85,7 +86,7 @@
 objects-gtk.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h buffer.h bufslots.h casetab.h charset.h chartab.h compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h device-impl.h device.h devslots.h dumper.h gc.h gccache-gtk.h gccache-x.h general-slots.h glyphs-gtk.h glyphs-x.h glyphs.h insdel.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects-xlike-inc.c objects.h redisplay.h scrollbar.h specifier.h symeval.h symsinit.h sysgdkx.h sysgtk.h text.h vdb.h window-impl.h window.h winslots.h xintrinsic.h
 redisplay-gtk.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h debug.h device-impl.h device.h devslots.h dumper.h faces.h file-coding.h frame-impl.h frame.h frameslots.h gc.h gccache-gtk.h gccache-x.h general-slots.h glyphs-gtk.h glyphs-x.h glyphs.h gutter.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h mule-ccl.h number-gmp.h number-mp.h number.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects.h redisplay-xlike-inc.c redisplay.h scrollbar.h specifier.h symeval.h symsinit.h sysdep.h sysgdkx.h sysgtk.h sysproc.h syssignal.h systime.h text.h vdb.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h
 scrollbar-gtk.o: $(CONFIG_H) $(LISP_H) compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h dumper.h frame-impl.h frame.h frameslots.h gc.h general-slots.h glyphs-gtk.h glyphs.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h redisplay.h scrollbar-gtk.h scrollbar.h specifier.h symeval.h symsinit.h sysgtk.h text.h vdb.h window-impl.h window.h winslots.h
-select-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h dumper.h events.h frame.h gc.h general-slots.h keymap-buttons.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h opaque.h redisplay.h select-common.h select.h specifier.h symeval.h symsinit.h sysgtk.h systime.h text.h vdb.h
+select-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h dumper.h events.h frame.h gc.h general-slots.h keymap-buttons.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h opaque.h redisplay.h select-xlike-inc.c select.h specifier.h symeval.h symsinit.h sysgtk.h systime.h text.h vdb.h
 toolbar-gtk.o: $(CONFIG_H) $(LISP_H) compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h dumper.h frame.h gc.h general-slots.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h redisplay.h specifier.h symeval.h symsinit.h sysgtk.h text.h toolbar-xlike.h vdb.h
 ui-byhand.o: gui.h
 ui-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h compiler.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device.h dumper.h elhash.h emacs-marshals.c emacs-widget-accessors.c events.h faces.h gc.h general-slots.h glade.c glyphs-gtk.h glyphs.h gtk-glue.c gui.h hash.h keymap-buttons.h lisp-disunion.h lisp-union.h lisp.h lrecord.h mc-alloc.h number-gmp.h number-mp.h number.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects.h redisplay.h scrollbar.h specifier.h symeval.h symsinit.h sysdll.h sysgtk.h systime.h text.h ui-byhand.c ui-gtk.h vdb.h window-impl.h window.h winslots.h
--- a/src/make-src-depend	Fri Feb 05 08:09:03 2010 -0600
+++ b/src/make-src-depend	Fri Feb 05 12:11:12 2010 -0600
@@ -142,8 +142,8 @@
 
 PrintPatternDeps ('-msw\\.',   "HAVE_MS_WINDOWS");
 PrintPatternDeps ('-xlike',   "HAVE_XLIKE");
-# X-specific files: *-x.c *-x-impl.h xgccache.c balloon_help.c x*.h Emacs*.[ch]
-PrintPatternDeps ('-x\\.|xgccache|balloon_help|^Emacs',     "HAVE_X_WINDOWS");
+# X-specific files: *-x.c *-x-impl.h balloon_help.c x*.h Emacs*.[ch]
+PrintPatternDeps ('-x\\.|balloon_help|^Emacs',     "HAVE_X_WINDOWS");
 PrintPatternDeps ('-tty\\.',   "HAVE_TTY");
 # GTK-specific files: *-gtk.[ch] *-gtk-*.[ch] gtk-*.[ch] emacs-marshals.c emacs-widget-accessors.c glade.c ui-byhand.c
 PrintPatternDeps ('gtk|emacs-marshals|emacs-widget-accessors|glade|ui-byhand',   "HAVE_GTK");
--- a/src/select-common.h	Fri Feb 05 08:09:03 2010 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,343 +0,0 @@
-/* Selection processing for XEmacs -- common btwn select-x.c and select-gtk.c
-   Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of XEmacs.
-
-XEmacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-XEmacs is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with XEmacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: Not synched with FSF. */
-
-#ifdef PROCESSING_X_CODE
-#define XE_ATOM_TYPE Atom
-#define XE_ATOM_TO_SYMBOL x_atom_to_symbol
-#define XE_SYMBOL_TO_ATOM symbol_to_x_atom
-#else
-#define XE_ATOM_TYPE GdkAtom
-#define XE_ATOM_TO_SYMBOL atom_to_symbol
-#define XE_SYMBOL_TO_ATOM symbol_to_gtk_atom
-#endif /* PROCESSING_X_CODE */
-
-/* #### These are going to move into Lisp code(!) with the aid of
-        some new functions I'm working on - ajh */
-
-/* These functions convert from the selection data read from the server into
-   something that we can use from elisp, and vice versa.
-
-	Type:	Format:	Size:		Elisp Type:
-	-----	-------	-----		-----------
-	*	8	*		String
-	ATOM	32	1		Symbol
-	ATOM	32	> 1		Vector of Symbols
-	*	16	1		Integer
-	*	16	> 1		Vector of Integers
-	*	32	1		if <=16 bits: Integer
-					if > 16 bits: Cons of top16, bot16
-	*	32	> 1		Vector of the above
-
-   NOTE NOTE NOTE:
-   Format == 32 means that the buffer will be C longs, which need not be
-   32-bit quantities.  See the note in select-x.c (x_get_window_property).
-
-   When converting a Lisp number to C, it is assumed to be of format 16 if
-   it is an integer, and of format 32 if it is a cons of two integers.
-
-   When converting a vector of numbers from Elisp to C, it is assumed to be
-   of format 16 if every element in the vector is an integer, and is assumed
-   to be of format 32 if any element is a cons of two integers.
-
-   When converting an object to C, it may be of the form (SYMBOL . <data>)
-   where SYMBOL is what we should claim that the type is.  Format and
-   representation are as above.
-
-   NOTE: Under Mule, when someone shoves us a string without a type, we
-   set the type to `COMPOUND_TEXT' and automatically convert to Compound
-   Text.  If the string has a type, we assume that the user wants the
-   data sent as-is so we just do "binary" conversion.
- */
-
-
-static Lisp_Object
-selection_data_to_lisp_data (struct device *d,
-			     Rawbyte *data,
-			     Bytecount size,
-			     XE_ATOM_TYPE type,
-			     int format)
-{
-#ifdef PROCESSING_X_CODE
-  if (type == DEVICE_XATOM_NULL (d))
-    return QNULL;
-
-  /* Convert any 8-bit data to a string, for compactness. */
-  else if (format == 8)
-    return make_extstring ((Extbyte *) data, size,
-			    type == DEVICE_XATOM_TEXT (d) ||
-			    type == DEVICE_XATOM_COMPOUND_TEXT (d)
-			    ? Qctext : Qbinary);
-
-  /* Convert a single atom to a Lisp Symbol.
-     Convert a set of atoms to a vector of symbols. */
-  else if (type == XA_ATOM)
-#else
-  if (type == gdk_atom_intern ("NULL", 0))
-    return QNULL;
-
-  /* Convert any 8-bit data to a string, for compactness. */
-  else if (format == 8)
-    return make_extstring ((Extbyte *) data, size,
-			    ((type == gdk_atom_intern ("TEXT", FALSE)) ||
-			     (type == gdk_atom_intern ("COMPOUND_TEXT", FALSE)))
-			    ? Qctext : Qbinary);
-
-  /* Convert a single atom to a Lisp Symbol.
-     Convert a set of atoms to a vector of symbols. */
-  else if (type == gdk_atom_intern ("ATOM", FALSE))
-#endif /* PROCESSING_X_CODE */
-    {
-      if (size == sizeof (XE_ATOM_TYPE))
-	return XE_ATOM_TO_SYMBOL (d, *((XE_ATOM_TYPE *) data));
-      else
-	{
-	  Elemcount i;
-	  Elemcount len = size / sizeof (XE_ATOM_TYPE);
-	  Lisp_Object v = Fmake_vector (make_int (len), Qzero);
-	  for (i = 0; i < len; i++)
-	    Faset (v, make_int (i), XE_ATOM_TO_SYMBOL (d, ((XE_ATOM_TYPE *) data) [i]));
-	  return v;
-	}
-    }
-
-  /* Convert a single 16 or small 32 bit number to a Lisp Int.
-     If the number is > 16 bits, convert it to a cons of integers,
-     16 bits in each half.
-   */
-  else if (format == 32 && size == sizeof (long))
-    return word_to_lisp (((unsigned long *) data) [0]);
-  else if (format == 16 && size == sizeof (short))
-    return make_int ((int) (((unsigned short *) data) [0]));
-
-  /* Convert any other kind of data to a vector of numbers, represented
-     as above (as an integer, or a cons of two 16 bit integers).
-
-     #### Perhaps we should return the actual type to lisp as well.
-
-	(x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
-	==> [4 4]
-
-     and perhaps it should be
-
-	(x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
-	==> (SPAN . [4 4])
-
-     Right now the fact that the return type was SPAN is discarded before
-     lisp code gets to see it.
-   */
-  else if (format == 16)
-    {
-      Elemcount i;
-      Lisp_Object v = make_vector (size / 4, Qzero);
-      for (i = 0; i < size / 4; i++)
-	{
-	  int j = (int) ((unsigned short *) data) [i];
-	  Faset (v, make_int (i), make_int (j));
-	}
-      return v;
-    }
-  else
-    {
-      Elemcount i;
-      Lisp_Object v = make_vector (size / 4, Qzero);
-      for (i = 0; i < size / 4; i++)
-	{
-	  unsigned long j = ((unsigned long *) data) [i];
-	  Faset (v, make_int (i), word_to_lisp (j));
-	}
-      return v;
-    }
-}
-
-
-static void
-lisp_data_to_selection_data (struct device *d,
-			     Lisp_Object obj,
-			     Rawbyte **data_ret,
-			     XE_ATOM_TYPE *type_ret,
-			     Bytecount *size_ret,
-			     int *format_ret)
-{
-  Lisp_Object type = Qnil;
-
-  if (CONSP (obj) && SYMBOLP (XCAR (obj)))
-    {
-      type = XCAR (obj);
-      obj = XCDR (obj);
-      if (CONSP (obj) && NILP (XCDR (obj)))
-	obj = XCAR (obj);
-    }
-
-  if (EQ (obj, QNULL) || (EQ (type, QNULL)))
-    {				/* This is not the same as declining */
-      *format_ret = 32;
-      *size_ret = 0;
-      *data_ret = 0;
-      type = QNULL;
-    }
-  else if (STRINGP (obj))
-    {
-      const Extbyte *extval;
-      Bytecount extvallen;
-
-      TO_EXTERNAL_FORMAT (LISP_STRING, obj,
-			  ALLOCA, (extval, extvallen),
-			  (NILP (type) ? Qctext : Qbinary));
-      *format_ret = 8;
-      *size_ret = extvallen;
-      *data_ret = xnew_rawbytes (*size_ret);
-      memcpy (*data_ret, extval, *size_ret);
-#ifdef MULE
-      if (NILP (type)) type = QCOMPOUND_TEXT;
-#else
-      if (NILP (type)) type = QSTRING;
-#endif
-    }
-  else if (CHARP (obj))
-    {
-      Ibyte buf[MAX_ICHAR_LEN];
-      Bytecount len;
-      const Extbyte *extval;
-      Bytecount extvallen;
-
-      *format_ret = 8;
-      len = set_itext_ichar (buf, XCHAR (obj));
-      TO_EXTERNAL_FORMAT (DATA, (buf, len),
-			  ALLOCA, (extval, extvallen),
-			  Qctext);
-      *size_ret = extvallen;
-      *data_ret = xnew_rawbytes (*size_ret);
-      memcpy (*data_ret, extval, *size_ret);
-#ifdef MULE
-      if (NILP (type)) type = QCOMPOUND_TEXT;
-#else
-      if (NILP (type)) type = QSTRING;
-#endif
-    }
-  else if (SYMBOLP (obj))
-    {
-      *format_ret = 32;
-      *size_ret = 1;
-      *data_ret = xnew_rawbytes (sizeof (XE_ATOM_TYPE) + 1);
-      (*data_ret) [sizeof (XE_ATOM_TYPE)] = 0;
-      (*(XE_ATOM_TYPE **) data_ret) [0] = XE_SYMBOL_TO_ATOM (d, obj, 0);
-      if (NILP (type)) type = QATOM;
-    }
-  else if (INTP (obj) &&
-	   XINT (obj) <= 0x7FFF &&
-	   XINT (obj) >= -0x8000)
-    {
-      *format_ret = 16;
-      *size_ret = 1;
-      *data_ret = xnew_rawbytes (sizeof (short) + 1);
-      (*data_ret) [sizeof (short)] = 0;
-      (*(short **) data_ret) [0] = (short) XINT (obj);
-      if (NILP (type)) type = QINTEGER;
-    }
-  else if (INTP (obj) || CONSP (obj))
-    {
-      *format_ret = 32;
-      *size_ret = 1;
-      *data_ret = xnew_rawbytes (sizeof (long) + 1);
-      (*data_ret) [sizeof (long)] = 0;
-      (*(unsigned long **) data_ret) [0] = lisp_to_word (obj);
-      if (NILP (type)) type = QINTEGER;
-    }
-  else if (VECTORP (obj))
-    {
-      /* Lisp Vectors may represent a set of ATOMs;
-	 a set of 16 or 32 bit INTEGERs;
-	 or a set of ATOM_PAIRs (represented as [[A1 A2] [A3 A4] ...]
-       */
-      Elemcount i;
-
-      if (SYMBOLP (XVECTOR_DATA (obj) [0]))
-	/* This vector is an ATOM set */
-	{
-	  if (NILP (type)) type = QATOM;
-	  *size_ret = XVECTOR_LENGTH (obj);
-	  *format_ret = 32;
-	  *data_ret = xnew_rawbytes ((*size_ret) * sizeof (XE_ATOM_TYPE));
-	  for (i = 0; i < *size_ret; i++)
-	    if (SYMBOLP (XVECTOR_DATA (obj) [i]))
-	      (*(XE_ATOM_TYPE **) data_ret) [i] =
-		XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (obj) [i], 0);
-	    else
-              syntax_error
-		("all elements of the vector must be of the same type", obj);
-	}
-#if 0 /* #### MULTIPLE doesn't work yet */
-      else if (VECTORP (XVECTOR_DATA (obj) [0]))
-	/* This vector is an ATOM_PAIR set */
-	{
-	  if (NILP (type)) type = QATOM_PAIR;
-	  *size_ret = XVECTOR_LENGTH (obj);
-	  *format_ret = 32;
-	  *data_ret =
-	    xnew_rawbytes ((*size_ret) * sizeof (XE_ATOM_TYPE) * 2);
-	  for (i = 0; i < *size_ret; i++)
-	    if (VECTORP (XVECTOR_DATA (obj) [i]))
-	      {
-		Lisp_Object pair = XVECTOR_DATA (obj) [i];
-		if (XVECTOR_LENGTH (pair) != 2)
-		  syntax_error
-		    ("elements of the vector must be vectors of exactly two elements", pair);
-
-		(*(XE_ATOM_TYPE **) data_ret) [i * 2] =
-		  XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (pair) [0], 0);
-		(*(XE_ATOM_TYPE **) data_ret) [(i * 2) + 1] =
-		  XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (pair) [1], 0);
-	      }
-	    else
-	      syntax_error
-		("all elements of the vector must be of the same type", obj);
-	}
-#endif
-      else
-	/* This vector is an INTEGER set, or something like it */
-	{
-	  *size_ret = XVECTOR_LENGTH (obj);
-	  if (NILP (type)) type = QINTEGER;
-	  *format_ret = 16;
-	  for (i = 0; i < *size_ret; i++)
-	    if (CONSP (XVECTOR_DATA (obj) [i]))
-	      *format_ret = 32;
-	    else if (!INTP (XVECTOR_DATA (obj) [i]))
-	      syntax_error
-		("all elements of the vector must be integers or conses of integers", obj);
-
-	  *data_ret = xnew_rawbytes (*size_ret * (*format_ret/8));
-	  for (i = 0; i < *size_ret; i++)
-	    if (*format_ret == 32)
-	      (*((unsigned long **) data_ret)) [i] =
-		lisp_to_word (XVECTOR_DATA (obj) [i]);
-	    else
-	      (*((unsigned short **) data_ret)) [i] =
-		(unsigned short) lisp_to_word (XVECTOR_DATA (obj) [i]);
-	}
-    }
-  else
-    invalid_argument ("unrecognized selection data", obj);
-
-  *type_ret = XE_SYMBOL_TO_ATOM (d, type, 0);
-}
-
--- a/src/select-gtk.c	Fri Feb 05 08:09:03 2010 -0600
+++ b/src/select-gtk.c	Fri Feb 05 12:11:12 2010 -0600
@@ -82,9 +82,9 @@
   }
 }
 
-#define PROCESSING_GTK_CODE
-#include "select-common.h"
-#undef PROCESSING_GTK_CODE
+#define THIS_IS_GTK
+#include "select-xlike-inc.c"
+#undef THIS_IS_GTK
 
 
 /* Set the selection data to GDK_NONE and NULL data, meaning we were
--- a/src/select-x.c	Fri Feb 05 08:09:03 2010 -0600
+++ b/src/select-x.c	Fri Feb 05 12:11:12 2010 -0600
@@ -196,9 +196,9 @@
   }
 }
 
-#define PROCESSING_X_CODE
-#include "select-common.h"
-#undef PROCESSING_X_CODE
+#define THIS_IS_X
+#include "select-xlike-inc.c"
+#undef THIS_IS_X
 
 /* Do protocol to assert ourself as a selection owner.
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/select-xlike-inc.c	Fri Feb 05 12:11:12 2010 -0600
@@ -0,0 +1,343 @@
+/* Selection processing for XEmacs -- common btwn select-x.c and select-gtk.c
+   Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not synched with FSF. */
+
+#ifdef THIS_IS_X
+#define XE_ATOM_TYPE Atom
+#define XE_ATOM_TO_SYMBOL x_atom_to_symbol
+#define XE_SYMBOL_TO_ATOM symbol_to_x_atom
+#else
+#define XE_ATOM_TYPE GdkAtom
+#define XE_ATOM_TO_SYMBOL atom_to_symbol
+#define XE_SYMBOL_TO_ATOM symbol_to_gtk_atom
+#endif /* THIS_IS_X */
+
+/* #### These are going to move into Lisp code(!) with the aid of
+        some new functions I'm working on - ajh */
+
+/* These functions convert from the selection data read from the server into
+   something that we can use from elisp, and vice versa.
+
+	Type:	Format:	Size:		Elisp Type:
+	-----	-------	-----		-----------
+	*	8	*		String
+	ATOM	32	1		Symbol
+	ATOM	32	> 1		Vector of Symbols
+	*	16	1		Integer
+	*	16	> 1		Vector of Integers
+	*	32	1		if <=16 bits: Integer
+					if > 16 bits: Cons of top16, bot16
+	*	32	> 1		Vector of the above
+
+   NOTE NOTE NOTE:
+   Format == 32 means that the buffer will be C longs, which need not be
+   32-bit quantities.  See the note in select-x.c (x_get_window_property).
+
+   When converting a Lisp number to C, it is assumed to be of format 16 if
+   it is an integer, and of format 32 if it is a cons of two integers.
+
+   When converting a vector of numbers from Elisp to C, it is assumed to be
+   of format 16 if every element in the vector is an integer, and is assumed
+   to be of format 32 if any element is a cons of two integers.
+
+   When converting an object to C, it may be of the form (SYMBOL . <data>)
+   where SYMBOL is what we should claim that the type is.  Format and
+   representation are as above.
+
+   NOTE: Under Mule, when someone shoves us a string without a type, we
+   set the type to `COMPOUND_TEXT' and automatically convert to Compound
+   Text.  If the string has a type, we assume that the user wants the
+   data sent as-is so we just do "binary" conversion.
+ */
+
+
+static Lisp_Object
+selection_data_to_lisp_data (struct device *d,
+			     Rawbyte *data,
+			     Bytecount size,
+			     XE_ATOM_TYPE type,
+			     int format)
+{
+#ifdef THIS_IS_X
+  if (type == DEVICE_XATOM_NULL (d))
+    return QNULL;
+
+  /* Convert any 8-bit data to a string, for compactness. */
+  else if (format == 8)
+    return make_extstring ((Extbyte *) data, size,
+			    type == DEVICE_XATOM_TEXT (d) ||
+			    type == DEVICE_XATOM_COMPOUND_TEXT (d)
+			    ? Qctext : Qbinary);
+
+  /* Convert a single atom to a Lisp Symbol.
+     Convert a set of atoms to a vector of symbols. */
+  else if (type == XA_ATOM)
+#else
+  if (type == gdk_atom_intern ("NULL", 0))
+    return QNULL;
+
+  /* Convert any 8-bit data to a string, for compactness. */
+  else if (format == 8)
+    return make_extstring ((Extbyte *) data, size,
+			    ((type == gdk_atom_intern ("TEXT", FALSE)) ||
+			     (type == gdk_atom_intern ("COMPOUND_TEXT", FALSE)))
+			    ? Qctext : Qbinary);
+
+  /* Convert a single atom to a Lisp Symbol.
+     Convert a set of atoms to a vector of symbols. */
+  else if (type == gdk_atom_intern ("ATOM", FALSE))
+#endif /* THIS_IS_X */
+    {
+      if (size == sizeof (XE_ATOM_TYPE))
+	return XE_ATOM_TO_SYMBOL (d, *((XE_ATOM_TYPE *) data));
+      else
+	{
+	  Elemcount i;
+	  Elemcount len = size / sizeof (XE_ATOM_TYPE);
+	  Lisp_Object v = Fmake_vector (make_int (len), Qzero);
+	  for (i = 0; i < len; i++)
+	    Faset (v, make_int (i), XE_ATOM_TO_SYMBOL (d, ((XE_ATOM_TYPE *) data) [i]));
+	  return v;
+	}
+    }
+
+  /* Convert a single 16 or small 32 bit number to a Lisp Int.
+     If the number is > 16 bits, convert it to a cons of integers,
+     16 bits in each half.
+   */
+  else if (format == 32 && size == sizeof (long))
+    return word_to_lisp (((unsigned long *) data) [0]);
+  else if (format == 16 && size == sizeof (short))
+    return make_int ((int) (((unsigned short *) data) [0]));
+
+  /* Convert any other kind of data to a vector of numbers, represented
+     as above (as an integer, or a cons of two 16 bit integers).
+
+     #### Perhaps we should return the actual type to lisp as well.
+
+	(x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
+	==> [4 4]
+
+     and perhaps it should be
+
+	(x-get-selection-internal 'PRIMARY 'LINE_NUMBER)
+	==> (SPAN . [4 4])
+
+     Right now the fact that the return type was SPAN is discarded before
+     lisp code gets to see it.
+   */
+  else if (format == 16)
+    {
+      Elemcount i;
+      Lisp_Object v = make_vector (size / 4, Qzero);
+      for (i = 0; i < size / 4; i++)
+	{
+	  int j = (int) ((unsigned short *) data) [i];
+	  Faset (v, make_int (i), make_int (j));
+	}
+      return v;
+    }
+  else
+    {
+      Elemcount i;
+      Lisp_Object v = make_vector (size / 4, Qzero);
+      for (i = 0; i < size / 4; i++)
+	{
+	  unsigned long j = ((unsigned long *) data) [i];
+	  Faset (v, make_int (i), word_to_lisp (j));
+	}
+      return v;
+    }
+}
+
+
+static void
+lisp_data_to_selection_data (struct device *d,
+			     Lisp_Object obj,
+			     Rawbyte **data_ret,
+			     XE_ATOM_TYPE *type_ret,
+			     Bytecount *size_ret,
+			     int *format_ret)
+{
+  Lisp_Object type = Qnil;
+
+  if (CONSP (obj) && SYMBOLP (XCAR (obj)))
+    {
+      type = XCAR (obj);
+      obj = XCDR (obj);
+      if (CONSP (obj) && NILP (XCDR (obj)))
+	obj = XCAR (obj);
+    }
+
+  if (EQ (obj, QNULL) || (EQ (type, QNULL)))
+    {				/* This is not the same as declining */
+      *format_ret = 32;
+      *size_ret = 0;
+      *data_ret = 0;
+      type = QNULL;
+    }
+  else if (STRINGP (obj))
+    {
+      const Extbyte *extval;
+      Bytecount extvallen;
+
+      TO_EXTERNAL_FORMAT (LISP_STRING, obj,
+			  ALLOCA, (extval, extvallen),
+			  (NILP (type) ? Qctext : Qbinary));
+      *format_ret = 8;
+      *size_ret = extvallen;
+      *data_ret = xnew_rawbytes (*size_ret);
+      memcpy (*data_ret, extval, *size_ret);
+#ifdef MULE
+      if (NILP (type)) type = QCOMPOUND_TEXT;
+#else
+      if (NILP (type)) type = QSTRING;
+#endif
+    }
+  else if (CHARP (obj))
+    {
+      Ibyte buf[MAX_ICHAR_LEN];
+      Bytecount len;
+      const Extbyte *extval;
+      Bytecount extvallen;
+
+      *format_ret = 8;
+      len = set_itext_ichar (buf, XCHAR (obj));
+      TO_EXTERNAL_FORMAT (DATA, (buf, len),
+			  ALLOCA, (extval, extvallen),
+			  Qctext);
+      *size_ret = extvallen;
+      *data_ret = xnew_rawbytes (*size_ret);
+      memcpy (*data_ret, extval, *size_ret);
+#ifdef MULE
+      if (NILP (type)) type = QCOMPOUND_TEXT;
+#else
+      if (NILP (type)) type = QSTRING;
+#endif
+    }
+  else if (SYMBOLP (obj))
+    {
+      *format_ret = 32;
+      *size_ret = 1;
+      *data_ret = xnew_rawbytes (sizeof (XE_ATOM_TYPE) + 1);
+      (*data_ret) [sizeof (XE_ATOM_TYPE)] = 0;
+      (*(XE_ATOM_TYPE **) data_ret) [0] = XE_SYMBOL_TO_ATOM (d, obj, 0);
+      if (NILP (type)) type = QATOM;
+    }
+  else if (INTP (obj) &&
+	   XINT (obj) <= 0x7FFF &&
+	   XINT (obj) >= -0x8000)
+    {
+      *format_ret = 16;
+      *size_ret = 1;
+      *data_ret = xnew_rawbytes (sizeof (short) + 1);
+      (*data_ret) [sizeof (short)] = 0;
+      (*(short **) data_ret) [0] = (short) XINT (obj);
+      if (NILP (type)) type = QINTEGER;
+    }
+  else if (INTP (obj) || CONSP (obj))
+    {
+      *format_ret = 32;
+      *size_ret = 1;
+      *data_ret = xnew_rawbytes (sizeof (long) + 1);
+      (*data_ret) [sizeof (long)] = 0;
+      (*(unsigned long **) data_ret) [0] = lisp_to_word (obj);
+      if (NILP (type)) type = QINTEGER;
+    }
+  else if (VECTORP (obj))
+    {
+      /* Lisp Vectors may represent a set of ATOMs;
+	 a set of 16 or 32 bit INTEGERs;
+	 or a set of ATOM_PAIRs (represented as [[A1 A2] [A3 A4] ...]
+       */
+      Elemcount i;
+
+      if (SYMBOLP (XVECTOR_DATA (obj) [0]))
+	/* This vector is an ATOM set */
+	{
+	  if (NILP (type)) type = QATOM;
+	  *size_ret = XVECTOR_LENGTH (obj);
+	  *format_ret = 32;
+	  *data_ret = xnew_rawbytes ((*size_ret) * sizeof (XE_ATOM_TYPE));
+	  for (i = 0; i < *size_ret; i++)
+	    if (SYMBOLP (XVECTOR_DATA (obj) [i]))
+	      (*(XE_ATOM_TYPE **) data_ret) [i] =
+		XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (obj) [i], 0);
+	    else
+              syntax_error
+		("all elements of the vector must be of the same type", obj);
+	}
+#if 0 /* #### MULTIPLE doesn't work yet */
+      else if (VECTORP (XVECTOR_DATA (obj) [0]))
+	/* This vector is an ATOM_PAIR set */
+	{
+	  if (NILP (type)) type = QATOM_PAIR;
+	  *size_ret = XVECTOR_LENGTH (obj);
+	  *format_ret = 32;
+	  *data_ret =
+	    xnew_rawbytes ((*size_ret) * sizeof (XE_ATOM_TYPE) * 2);
+	  for (i = 0; i < *size_ret; i++)
+	    if (VECTORP (XVECTOR_DATA (obj) [i]))
+	      {
+		Lisp_Object pair = XVECTOR_DATA (obj) [i];
+		if (XVECTOR_LENGTH (pair) != 2)
+		  syntax_error
+		    ("elements of the vector must be vectors of exactly two elements", pair);
+
+		(*(XE_ATOM_TYPE **) data_ret) [i * 2] =
+		  XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (pair) [0], 0);
+		(*(XE_ATOM_TYPE **) data_ret) [(i * 2) + 1] =
+		  XE_SYMBOL_TO_ATOM (d, XVECTOR_DATA (pair) [1], 0);
+	      }
+	    else
+	      syntax_error
+		("all elements of the vector must be of the same type", obj);
+	}
+#endif
+      else
+	/* This vector is an INTEGER set, or something like it */
+	{
+	  *size_ret = XVECTOR_LENGTH (obj);
+	  if (NILP (type)) type = QINTEGER;
+	  *format_ret = 16;
+	  for (i = 0; i < *size_ret; i++)
+	    if (CONSP (XVECTOR_DATA (obj) [i]))
+	      *format_ret = 32;
+	    else if (!INTP (XVECTOR_DATA (obj) [i]))
+	      syntax_error
+		("all elements of the vector must be integers or conses of integers", obj);
+
+	  *data_ret = xnew_rawbytes (*size_ret * (*format_ret/8));
+	  for (i = 0; i < *size_ret; i++)
+	    if (*format_ret == 32)
+	      (*((unsigned long **) data_ret)) [i] =
+		lisp_to_word (XVECTOR_DATA (obj) [i]);
+	    else
+	      (*((unsigned short **) data_ret)) [i] =
+		(unsigned short) lisp_to_word (XVECTOR_DATA (obj) [i]);
+	}
+    }
+  else
+    invalid_argument ("unrecognized selection data", obj);
+
+  *type_ret = XE_SYMBOL_TO_ATOM (d, type, 0);
+}
+