Bug 1812276 - Add a minimal shlwapi.h wrapper, like we do with windows.h. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D167879
This commit is contained in:
Mike Hommey 2023-01-26 22:21:04 +00:00
Родитель 6be52ed1d4
Коммит e450188d9b
5 изменённых файлов: 110 добавлений и 7 удалений

Просмотреть файл

@ -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")

Просмотреть файл

@ -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.

Просмотреть файл

@ -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*);

Просмотреть файл

@ -0,0 +1,43 @@
/* -*- 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 <shlwapi.h>
#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++" {
// clang-format off
${decls}
// clang-format on
} // extern "C++"
#endif // enabled
#pragma GCC diagnostic pop
#endif // !defined(mozilla_shlwapi_h)

Просмотреть файл

@ -19,25 +19,27 @@
// Check if the header should be disabled
#if defined(MOZ_DISABLE_WINDOWS_WRAPPER)
#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "explicitly disabled"
# define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "explicitly disabled"
#elif !defined(__cplusplus)
#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-C++ source file"
# define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-C++ source file"
#else
// We're allowed to wrap in the current context. Define `MOZ_WRAPPED_WINDOWS_H`
// to note that fact, and perform the wrapping.
#define MOZ_WRAPPED_WINDOWS_H
# define MOZ_WRAPPED_WINDOWS_H
extern "C++" {
// clang-format off
${decls}
// clang-format on
} // extern "C++"
} // extern "C++"
#undef GetCurrentTime // Use GetTickCount() instead.
# undef GetCurrentTime // Use GetTickCount() instead.
#endif // enabled
#endif // enabled
#pragma GCC diagnostic pop
#endif // !defined(mozilla_windows_h)
#endif // !defined(mozilla_windows_h)