diff --git a/config/moz.build b/config/moz.build index 7651bcd111ea..90d9b21d47ea 100644 --- a/config/moz.build +++ b/config/moz.build @@ -80,6 +80,17 @@ if CONFIG["WRAP_STL_INCLUDES"]: ], flags=[stl_compiler], ) + GeneratedFile( + "/dist/stl_wrappers/shlwapi.h", + script="make-windows-h-wrapper.py", + entry_point="generate", + inputs=[ + "shlwapi-h-constant.decls.h", + "shlwapi-h-unicode.decls.h", + "shlwapi-h-wrapper.template.h", + ], + flags=[stl_compiler], + ) if CONFIG["WRAP_SYSTEM_INCLUDES"]: include("system-headers.mozbuild") diff --git a/config/shlwapi-h-constant.decls.h b/config/shlwapi-h-constant.decls.h new file mode 100644 index 000000000000..494a5a7dd755 --- /dev/null +++ b/config/shlwapi-h-constant.decls.h @@ -0,0 +1,23 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * This file contains a series of C-style declarations for constants defined in + * shlwapi.h using #define. Adding a new constant should be a simple as adding + * its name (and optionally type) to this file. + * + * This file is processed by make-windows-h-wrapper.py to generate a wrapper for + * the header which removes the defines usually implementing these constants. + * + * Wrappers defined in this file will be declared as `constexpr` values, + * and will have their value derived from the windows.h define. + * + * NOTE: This is *NOT* a real C header, but rather an input to the avove script. + * Only basic declarations in the form found here are allowed. + */ + +// XXX(glandium): We don't have any here, because they don't look like they +// could cause problems. diff --git a/config/shlwapi-h-unicode.decls.h b/config/shlwapi-h-unicode.decls.h new file mode 100644 index 000000000000..17c2ab6eac1f --- /dev/null +++ b/config/shlwapi-h-unicode.decls.h @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * This file contains a series of C-style function prototypes for A/W-suffixed + * Win32 APIs defined by shlwapi.h. + * + * This file is processed by make-windows-h-wrapper.py to generate a wrapper for + * the header which removes the defines usually implementing these aliases. + * + * Wrappers defined in this file will have the 'stdcall' calling convention, + * will be defined as 'inline', and will only be defined if the corresponding + * #define directive has not been #undef-ed. + * + * NOTE: This is *NOT* a real C header, but rather an input to the avove script. + * Only basic declarations in the form found here are allowed. + */ + +// XXX(glandium): there are a ton more, but this is the one that is causing +// immediate problems. +HRESULT GetAcceptLanguages(LPTSTR, DWORD*); diff --git a/config/shlwapi-h-wrapper.template.h b/config/shlwapi-h-wrapper.template.h new file mode 100644 index 000000000000..126e6e6d55d4 --- /dev/null +++ b/config/shlwapi-h-wrapper.template.h @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_shlwapi_h +#define mozilla_shlwapi_h + +// Include the "real" shlwapi.h header. +// +// Also turn off deprecation warnings, as we may be wrapping deprecated fns. + +#pragma GCC system_header +#include_next + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +// Check if the header should be disabled +#if defined(MOZ_DISABLE_WINDOWS_WRAPPER) +# define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "explicitly disabled" + +#elif !defined(__cplusplus) +# define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-C++ source file" + +#else +// We're allowed to wrap in the current context. Define `MOZ_WRAPPED_SHLWAPI_H` +// to note that fact, and perform the wrapping. +# define MOZ_WRAPPED_SHLWAPI_H +extern "C++" { + +$ { decls } + +} // extern "C++" + +#endif // enabled + +#pragma GCC diagnostic pop + +#endif // !defined(mozilla_shlwapi_h)