Mercurial > hg > xemacs-beta
view src/syswindows.h @ 617:af57a77cbc92
[xemacs-hg @ 2001-06-18 07:09:50 by ben]
---------------------------------------------------------------
DOCUMENTATION FIXES:
---------------------------------------------------------------
eval.c: Correct documentation.
elhash.c: Doc correction.
---------------------------------------------------------------
LISP OBJECT CLEANUP:
---------------------------------------------------------------
bytecode.h, buffer.h, casetab.h, chartab.h, console-msw.h, console.h, database.c, device.h, eldap.h, elhash.h, events.h, extents.h, faces.h, file-coding.h, frame.h, glyphs.h, gui-x.h, gui.h, keymap.h, lisp-disunion.h, lisp-union.h, lisp.h, lrecord.h, lstream.h, mule-charset.h, objects.h, opaque.h, postgresql.h, process.h, rangetab.h, specifier.h, toolbar.h, tooltalk.h, ui-gtk.h: Add wrap_* to all objects (it was already there for a few of them)
-- an expression to encapsulate a pointer into a Lisp object,
rather than the inconvenient XSET*. "wrap" was chosen because
"make" as in make_int(), make_char() is not appropriate. (It
implies allocation. The issue does not exist for ints and chars
because they are not allocated.)
Full error checking has been added to these expressions. When
used without error checking, non-union build, use of these
expressions will incur no loss of efficiency. (In fact, XSET* is
now defined in terms of wrap_* in a non-union build.) In a union
build, you will also get no loss of efficiency provided that you
have a decent optimizing compiler, and a compiler that either
understands inlines or automatically inlines those particular
functions. (And since people don't normally do their production
builds on union, it doesn't matter.)
Update the sample Lisp object definition in lrecord.h accordingly.
dumper.c: Fix places in dumper that referenced wrap_object to reference
its new name, wrap_pointer_1.
buffer.c, bufslots.h, conslots.h, console.c, console.h, devslots.h, device.c, device.h, frame.c, frame.h, frameslots.h, window.c, window.h, winslots.h: -- Extract out the Lisp objects of `struct device' into devslots.h,
just like for the other structures.
-- Extract out the remaining (not copied into the window config)
Lisp objects in `struct window' into winslots.h; use different
macros (WINDOW_SLOT vs. WINDOW_SAVED_SLOT) to differentiate them.
-- Eliminate the `dead' flag of `struct frame', since it
duplicates information already available in `framemeths', and fix
FRAME_LIVE_P accordingly. (Devices and consoles already work this
way.)
-- In *slots.h, switch to system where MARKED_SLOT is automatically
undef'd at the end of the file. (Follows what winslots.h already
does.)
-- Update the comments at the beginning of *slots.h to be accurate.
-- When making any of the above objects dead, zero it out entirely
and reset all Lisp object slots to Qnil. (We were already doing
this somewhat, but not consistently.) This (1) Eliminates the
possibility of extra objects hanging around that ought to be
GC'd, (2) Causes an immediate crash if anyone tries to access a
structure in one of these objects, (3) Ensures consistent behavior
wrt dead objects.
dialog-msw.c: Use internal_object_printer, since this object should not escape.
---------------------------------------------------------------
FIXING A CRASH THAT I HIT ONCE (AND A RELATED BAD BEHAVIOR):
---------------------------------------------------------------
eval.c: Fix up some comments about the FSF implementation.
Fix two nasty bugs:
(1) condition_case_unwind frees the conses sitting in the
catch->tag slot too quickly, resulting in a crash that I hit.
(2) catches need to be unwound one at a time when calling
unwind-protect code, rather than all at once at the end; otherwise,
incorrect behavior can result. (A comment shows exactly how.)
backtrace.h: Improve comment about FSF differences in the handler stack.
---------------------------------------------------------------
FIXING A CRASH THAT I REPEATEDLY HIT WHEN USING THE MOUSE WHEEL
UNDER MSWINDOWS:
---------------------------------------------------------------
Basic idea: My crash is due either to a dead, non-marked,
GC-collected frame inside of a window mirror, or a prematurely
freed window mirror. We need to mark the Lisp objects inside of
window mirrors. Tracking the lifespan of window mirrors and
scrollbar instances is extremely hard, and there may well be
lurking bugs where such objects are freed too soon. The only safe
way to fix these problems (and it fixes both problems at once) is
to make both of these structures Lisp objects.
lrecord.h, emacs.c, inline.c, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, scrollbar.h, symsinit.h: Make scrollbar instances actual Lisp objects. Mark the window
mirrors in them. inline.c needs to know about scrollbar.h now.
Record the new type in lrecord.h. Fix up scrollbar-*.c
appropriately. Create a hash table in scrollbar-msw.c so that the
scrollbar instances stored in scrollbar HWND's are properly
GC-protected. Create complex_vars_of_scrollbar_mswindows() to
create the hash table at startup, and call it from emacs.c. Don't
store the scrollbar instance as a property of the GTK scrollbar,
as it's not used and if we did this, we'd have to separately
GC-protect it in a hash table, like in MS Windows.
lrecord.h, frame.h, frame.c, frameslots.h, redisplay.c, window.c, window.h: Move mark_window_mirror from redisplay.c to window.c. Make window
mirrors actual Lisp objects. Tell lrecord.h about them. Change
the window mirror member of struct frame from a pointer to a Lisp
object, and add XWINDOW_MIRROR in appropriate places. Mark the
scrollbar instances in the window mirror.
redisplay.c, redisplay.h, alloc.c: Delete mark_redisplay. Don't call mark_redisplay. We now mark
frame-specific structures in mark_frame.
NOTE: I also deleted an extremely questionable call to
update_frame_window_mirrors(). It was extremely questionable
before, and now totally impossible, since it will create
Lisp objects during redisplay.
frame.c: Mark the scrollbar instances, which are now Lisp objects.
Call mark_gutter() here, not in mark_redisplay().
gutter.c: Update comments about correct marking.
---------------------------------------------------------------
ISSUES BROUGHT UP BY MARTIN:
---------------------------------------------------------------
buffer.h: Put back these macros the way Steve T and I think they ought to be.
I already explained in a previous changelog entry why I think these
macros should be the way I'd defined them. Once again:
We fix these macros so they don't care about the type of their
lvalues. The non-C-string equivalents of these already function
in the same way, and it's correct because it should be OK to pass
in a CBufbyte *, a BufByte *, a Char_Binary *, an UChar_Binary *,
etc. The whole reason for these different types is to work around
errors caused by signed-vs-unsigned non-matching types. Any
possible error that might be caught in a DFC macro would also be
caught wherever the argument is used elsewhere. So creating
multiple macro versions would add no useful error-checking and
just further complicate an already complicated area.
As for Martin's "ANSI aliasing" bug, XEmacs is not ANSI-aliasing
clean and probably never will be. Unless the board agrees to
change XEmacs in this way (and we really don't want to go down
that road), this is not a bug.
sound.h: Undo Martin's type change.
signal.c: Fix problem identified by Martin with Linux and g++ due to
non-standard declaration of setitimer().
systime.h: Update the docs for "qxe_" to point out why making the
encapsulation explicit is always the right way to go. (setitimer()
itself serves as an example.)
For 21.4:
update-elc-2.el: Correct misplaced parentheses, making lisp/mule not get
recompiled.
author | ben |
---|---|
date | Mon, 18 Jun 2001 07:10:32 +0000 |
parents | 5fd7ba8b56e7 |
children | fdefd0186b75 |
line wrap: on
line source
/* Copyright (C) 2000 Free Software Foundation, Inc. Copyright (C) 2000, 2001 Ben Wing. 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 in FSF. */ /* Authorship: Created May 2000 by Andy Piper. Windows-Mule stuff added by Ben Wing. */ #ifndef INCLUDED_syswindows_h_ #define INCLUDED_syswindows_h_ /* Note that there are currently FOUR different general Windows-related include files in src! Uses are approximately: syswindows.h: Mostly a wrapper around <windows.h>, including missing defines as necessary. Also includes stuff needed on both Cygwin and native Windows, regardless of window system chosen. console-msw.h: Used on both Cygwin and native Windows, but only when native window system (as opposed to X) chosen. nt.h: [will be renamed to win32.h] Used only on native Windows, and regardless of window system chosen -- but used on both purely native Windows (s/windowsnt.h) and MinGW (s/mingw32.h). ntheap.h: Used only on native Windows and only when standard dumping mechanism (unexnt.c) used. All of the last three files include the first. */ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include <windows.h> #if defined (WIN32_LEAN_AND_MEAN) # ifdef HAVE_X_WINDOWS /* Christ almighty. The problems you get when combining two large code bases, neither with any respect for namespace purity. */ # undef Status # endif # include <winspool.h> # ifdef HAVE_X_WINDOWS # define Status int # endif # include <mmsystem.h> # include <shellapi.h> # include <ddeml.h> #endif #include <lmaccess.h> /* next three for NetUserEnum and friends */ #include <lmapibuf.h> #include <lmerr.h> #include <lmcons.h> /* for UNLEN and possibly other constants */ /* mmsystem.h defines. */ #ifndef SND_ASYNC #define SND_ASYNC 1 #endif #ifndef SND_NODEFAULT #define SND_NODEFAULT 2 #endif #ifndef SND_MEMORY #define SND_MEMORY 4 #endif #ifndef SND_FILENAME #define SND_FILENAME 0x2000L #endif /* winspool.h defines. */ #ifndef PHYSICALWIDTH #define PHYSICALWIDTH 110 #endif #ifndef PHYSICALHEIGHT #define PHYSICALHEIGHT 111 #endif #ifndef PHYSICALOFFSETX #define PHYSICALOFFSETX 112 #endif #ifndef PHYSICALOFFSETY #define PHYSICALOFFSETY 113 #endif /* windows.h defines. */ #if defined (CYGWIN) && (CYGWIN_VERSION_DLL_MAJOR < 20) typedef NMHDR *LPNMHDR; #endif #ifndef SPI_GETWHEELSCROLLLINES #define SPI_GETWHEELSCROLLLINES 104 #endif #ifndef WHEEL_PAGESCROLL #define WHEEL_PAGESCROLL (UINT_MAX) #endif #ifndef WHEEL_DELTA #define WHEEL_DELTA 120 #endif #ifndef WM_MOUSEWHEEL #define WM_MOUSEWHEEL 0x20A #endif #ifndef VK_APPS #define VK_APPS 0x5D #endif #ifndef SIF_TRACKPOS #define SIF_TRACKPOS 0x0010 #endif #ifndef FW_BLACK #define FW_BLACK FW_HEAVY #endif #ifndef FW_ULTRABOLD #define FW_ULTRABOLD FW_EXTRABOLD #endif #ifndef FW_DEMIBOLD #define FW_DEMIBOLD FW_SEMIBOLD #endif #ifndef FW_ULTRALIGHT #define FW_ULTRALIGHT FW_EXTRALIGHT #endif #ifndef APPCMD_FILTERINITS #define APPCMD_FILTERINITS 0x20L #endif #ifndef CBF_FAIL_SELFCONNECTIONS #define CBF_FAIL_SELFCONNECTIONS 0x1000 #endif #ifndef CBF_SKIP_ALLNOTIFICATIONS #define CBF_SKIP_ALLNOTIFICATIONS 0x3C0000 #endif #ifndef CBF_FAIL_ADVISES #define CBF_FAIL_ADVISES 0x4000 #endif #ifndef CBF_FAIL_POKES #define CBF_FAIL_POKES 0x10000 #endif #ifndef CBF_FAIL_REQUESTS #define CBF_FAIL_REQUESTS 0x20000 #endif #ifndef SZDDESYS_TOPIC #define SZDDESYS_TOPIC "System" #endif #ifndef JOHAB_CHARSET #define JOHAB_CHARSET 130 #endif #ifndef MAC_CHARSET #define MAC_CHARSET 77 #endif /***************************************************************/ /* Definitions for Mule under MS Windows */ #include <wchar.h> #ifdef CYGWIN /* All but wcscmp and wcslen left out of Cygwin headers -- but present in /usr/include/mingw32/string.h! */ wchar_t* wcscat (wchar_t*, const wchar_t*); wchar_t* wcschr (const wchar_t*, wchar_t); int wcscoll (const wchar_t*, const wchar_t*); wchar_t* wcscpy (wchar_t*, const wchar_t*); size_t wcscspn (const wchar_t*, const wchar_t*); /* Note: No wcserror in CRTDLL. */ wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t); int wcsncmp(const wchar_t*, const wchar_t*, size_t); wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t); wchar_t* wcspbrk(const wchar_t*, const wchar_t*); wchar_t* wcsrchr(const wchar_t*, wchar_t); size_t wcsspn(const wchar_t*, const wchar_t*); wchar_t* wcsstr(const wchar_t*, const wchar_t*); wchar_t* wcstok(wchar_t*, const wchar_t*); size_t wcsxfrm(wchar_t*, const wchar_t*, size_t); #endif /* CYGWIN */ // extern int mswindows_windows9x_p; /* #define XEUNICODE_P (!mswindows_windows9x_p) */ #define XEUNICODE_P 0 #define XETCHAR_SIZE (XEUNICODE_P ? sizeof (WCHAR) : sizeof (CHAR)) #define MAX_XETCHAR_SIZE sizeof (WCHAR) #define XETEXT1(arg) (XEUNICODE_P ? ((char *) (L##arg)) : (arg)) /* We need to do this indirection in case ARG is also a manifest constant. I don't really understand why. --ben */ #define XETEXT(arg) XETEXT1(arg) #define XECOPY_TCHAR(ptr, ch) \ (XEUNICODE_P ? (* (LPWSTR) (ptr) = L##ch) : (* (LPSTR) (ptr) = (ch))) #define xetcslen(arg) (XEUNICODE_P ? wcslen ((wchar_t *) arg) : strlen (arg)) #define xetcscmp(s1, s2) \ (XEUNICODE_P ? wcscmp ((wchar_t *) s1, (wchar_t *) s2) \ : strcmp (s1, s2)) #define xetcscpy(s1, s2) \ (XEUNICODE_P ? (char *) wcscpy ((wchar_t *) s1, (wchar_t *) s2) \ : strcpy (s1, s2)) #define xetcschr(s, ch) \ (XEUNICODE_P ? (char *) wcschr ((wchar_t *) s, (WCHAR) ch) \ : strchr (s, ch)) #define xetcsrchr(s, ch) \ (XEUNICODE_P ? (char *) wcsrchr ((wchar_t *) s, (WCHAR) ch) \ : strrchr (s, ch)) #define LOCAL_FILE_FORMAT_TO_TSTR(path, out) \ do { \ Bufbyte *lttff; \ \ LOCAL_TO_WIN32_FILE_FORMAT (path, lttff); \ C_STRING_TO_EXTERNAL (lttff, out, Qmswindows_tstr); \ } while (0) Lisp_Object tstr_to_local_file_format (Extbyte *pathout); #ifdef CYGWIN #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout) \ do { \ /* NOTE: It is a bit evil that here and below we are passing \ internal-format data to a function that (nominally) should work \ with external-format data. But in point of fact, the Cygwin \ conversion functions are *NOT* localized, and will fail if they \ get 7-bit ISO2022-encoded data. We know that our internal format \ is ASCII-compatible, and so these functions will work fine with \ this data. */ \ Lisp_Object ltwff1 = (path); \ int ltwff2 = \ cygwin_posix_to_win32_path_list_buf_size ((char *) \ XSTRING_DATA (ltwff1)); \ pathout = (Bufbyte *) alloca (ltwff2); \ cygwin_posix_to_win32_path_list ((char *) XSTRING_DATA (ltwff1), \ (char *) pathout); \ } while (0) #else #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout) \ do { \ (pathout) = XSTRING_DATA (path); \ } while (0) #endif #ifdef CYGWIN #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout) \ do { \ Bufbyte *wtlff1 = (path); \ int wtlff2 = \ cygwin_win32_to_posix_path_list_buf_size ((char *) wtlff1); \ Bufbyte *wtlff3 = (Bufbyte *) alloca (wtlff2); \ cygwin_win32_to_posix_path_list ((char *) wtlff1, (char *) wtlff3); \ (pathout) = build_string ((CBufbyte *) wtlff3); \ } while (0) #else #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout) \ do { \ (pathout) = build_string ((CBufbyte *) path); \ } while (0) #endif extern BOOL (WINAPI *xSwitchToThread) (VOID); extern HKL (WINAPI *xGetKeyboardLayout) (DWORD); extern BOOL (WINAPI *xSetMenuDefaultItem) (HMENU, UINT, UINT); extern BOOL (WINAPI *xInsertMenuItemA) (HMENU, UINT, BOOL, LPCMENUITEMINFOA); extern BOOL (WINAPI *xInsertMenuItemW) (HMENU, UINT, BOOL, LPCMENUITEMINFOW); extern HANDLE (WINAPI *xLoadImageA) (HINSTANCE, LPCSTR, UINT, int, int, UINT); extern HANDLE (WINAPI *xLoadImageW) (HINSTANCE, LPCWSTR, UINT, int, int, UINT); extern ATOM (WINAPI *xRegisterClassExA) (CONST WNDCLASSEXA *); extern ATOM (WINAPI *xRegisterClassExW) (CONST WNDCLASSEXW *); extern int (WINAPI *xEnumFontFamiliesExA) (HDC, LPLOGFONTA, FONTENUMPROCA, LPARAM, DWORD); extern int (WINAPI *xEnumFontFamiliesExW) (HDC, LPLOGFONTW, FONTENUMPROCW, LPARAM, DWORD); extern DWORD (WINAPI *xSHGetFileInfoA) (LPCSTR, DWORD, SHFILEINFOA FAR *, UINT, UINT); extern DWORD (WINAPI *xSHGetFileInfoW) (LPCWSTR, DWORD, SHFILEINFOW FAR *, UINT, UINT); extern NET_API_STATUS (NET_API_FUNCTION *xNetUserEnum) ( IN LPCWSTR servername OPTIONAL, IN DWORD level, IN DWORD filter, OUT LPBYTE *bufptr, IN DWORD prefmaxlen, OUT LPDWORD entriesread, OUT LPDWORD totalentries, IN OUT LPDWORD resume_handle OPTIONAL ); extern NET_API_STATUS (NET_API_FUNCTION *xNetApiBufferFree) ( IN LPVOID Buffer ); #endif /* INCLUDED_syswindows_h_ */