Win32 has (rather annoying) two-tiered APIs, 'A' APIs and 'W' APIs. The former is available on both Win9x/ME and Win2k/XP while the latter is only available on Win2k/XP. The latter is also "emulated" on Win9x/ME by MSLU (Microsoft Layer for Unicode). MS's recommended way of building a single 'Unicode' binary is to use 'W' APIs (use 'T' APIs that are macro-expanded to 'W" API calls at the compile time when 'UNICODE'? is defined).
However, we do not use this approach. I guess the decision not to take that path was made because the DLL for MSLU can't be shipped with Mozilla. Although it's very likely to be present on 99% of Win9x/ME boxes (it comes with MS IE), it would certainly be ironic to make MS IE a requirement for Mozilla on Win9x/ME.
Anyway, what Mozilla does is to do what MSLU does on its own [1]. It involves detecting the OS and setting function pointers to either 'A' or 'W' API wrappers (with string parameter conversion between 'A'NSI and Unicode) depending on the OS. Most of these is localized in widget/src/windows (viewer for test also need), but xpcom/io (for file i/o) and intl/locale/src/windows need to behave differently depending on the OS. My tentative patch for bug 162361 has some overlap with what's done in widget/src/windows. Besides, the OS detection code is duplicated in two files intl/locale/src/windows.
To avoid the following pattern as much as possible and to avoid the duplication of code,
if (isNT) { call W API}
else { call A API }I guess we have to move a part of |nsIToolkit| implementation (wrapper for Win32 APIs) in widget/src/windows/nsToolkit.h Perhaps, we can make a 'convenience class' |nsWindowsAPI| with static member variables that are function pointers to Win32 API wrappers. These member variables have to be init'd once at the xpcom startup to either A API wrappers or W API wrappers. In addition, we need a member function |IsNT()| to be used for a few cases where we can't help using
if (isNT) { call W API}
else { call A API }Any thought or opinion is welcome. Incidentally, this will finish up Mozilla's transition to 'Unicode' on Win2k/XP and take care of a host of bugs (see int'l release notes for 1.4)
Jungshik
[1] http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsWindowAPI.h http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsToolkit.cpp http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsToolkit.h
