mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
568787b95f
By default, windows.h exposes a large number of problematic define statements which are UpperCamelCase, such as a define from `CreateWindow` to `CreateWindow{A,W}`. As many of these names are generic (e.g. CreateFile, CreateWindow), they can mess up Gecko code that may legitimately have its own methods with the same names. The header also defines some traditional SCREAMING_SNAKE_CASE defines which can mess up our code by conflicting with local values. This patch adds a simple code generator which generates wrappers for these defines, and uses them to wrap the windows.h wrapper using the `stl_wrappers` mechanism, allowing us to use windows.h in more places. Differential Revision: https://phabricator.services.mozilla.com/D10932
23 lines
879 B
Python
23 lines
879 B
Python
# 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/.
|
|
from __future__ import print_function
|
|
import os
|
|
import string
|
|
from mozbuild.util import FileAvoidWrite
|
|
from system_header_util import header_path
|
|
|
|
|
|
# The 'unused' arg is the output file from the file_generate action. We actually
|
|
# generate all the files in header_list
|
|
|
|
|
|
def gen_wrappers(unused, outdir, compiler, template_file, *header_list):
|
|
template = open(template_file, 'r').read()
|
|
|
|
for header in header_list:
|
|
path = header_path(header, compiler)
|
|
with FileAvoidWrite(os.path.join(outdir, header)) as f:
|
|
f.write(string.Template(template).substitute(HEADER=header,
|
|
HEADER_PATH=path))
|