Bug 792059 - Add NeedsWindowsUndef extended attribute for constants; r=bz

When defining WebIDL constants in C++, we may need to undefine some
constant names that conflict with windows.h preprocessor defines.
Doing this in the binding header is far easier than tracking down the
include orders that may cause conflicts.

MozReview-Commit-ID: A0UoYezIQs5

--HG--
extra : rebase_source : d9100af2ccdb5c6e6468542ac68f74b2e4f9050c
This commit is contained in:
Kyle Machulis 2017-10-23 17:34:28 -07:00
Родитель b0922aec43
Коммит df8270946f
8 изменённых файлов: 31 добавлений и 1 удалений

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

@ -2855,6 +2855,16 @@ class CGConstDefinition(CGThing):
self.const = "static const %s %s = %s;" % (builtinNames[tag],
name,
value)
if member.getExtendedAttribute("NeedsWindowsUndef"):
self.const = fill(
"""
#ifdef XP_WIN
#undef ${name}
#endif // XP_WIN
${constDecl}
""",
name=name,
constDecl=self.const)
def declare(self):
return self.const

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

@ -3976,7 +3976,8 @@ class IDLConst(IDLInterfaceMember):
identifier == "ChromeOnly" or
identifier == "Func" or
identifier == "SecureContext" or
identifier == "NonEnumerable"):
identifier == "NonEnumerable" or
identifier == "NeedsWindowsUndef"):
# Known attributes that we don't need to do anything with here
pass
else:

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

@ -27,6 +27,11 @@ class Promise;
} // namespace mozilla
// We don't export TestCodeGenBinding.h, but it's right in our parent dir.
#ifdef XP_WIN
// If we're on windows, simulate including windows.h. This step will cause
// compilation failure if NeedsWindowsUndef is not defined.
#define NO_ERROR 0x1
#endif
#include "../TestCodeGenBinding.h"
extern bool TestFuncControlledMember(JSContext*, JSObject*);

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

@ -983,6 +983,10 @@ interface TestInterface {
[NonEnumerable]
void nonEnumerableMethod();
// [NeedsWindowsUndef] test generation
[NeedsWindowsUndef]
const unsigned long NO_ERROR = 0xffffffff;
// If you add things here, add them to TestExampleGen and TestJSImplGen as well
};

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

@ -810,6 +810,10 @@ interface TestExampleInterface {
[NonEnumerable]
void nonEnumerableMethod();
// [NeedsWindowsUndef] test generation
[NeedsWindowsUndef]
const unsigned long NO_ERROR = 0xffffffff;
// If you add things here, add them to TestCodeGen and TestJSImplGen as well
};

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

@ -830,6 +830,10 @@ interface TestJSImplInterface {
[NonEnumerable]
void nonEnumerableMethod();
// [NeedsWindowsUndef] test generation
[NeedsWindowsUndef]
const unsigned long NO_ERROR = 0xffffffff;
// If you add things here, add them to TestCodeGen as well
};

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

@ -280,6 +280,7 @@ interface WebGL2RenderingContextBase
const GLenum ALREADY_SIGNALED = 0x911A;
const GLenum TIMEOUT_EXPIRED = 0x911B;
const GLenum CONDITION_SATISFIED = 0x911C;
[NeedsWindowsUndef]
const GLenum WAIT_FAILED = 0x911D;
const GLenum SYNC_FLUSH_COMMANDS_BIT = 0x00000001;
const GLenum VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE;

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

@ -217,6 +217,7 @@ interface WebGLRenderingContextBase {
const GLenum SAMPLE_COVERAGE = 0x80A0;
/* ErrorCode */
[NeedsWindowsUndef]
const GLenum NO_ERROR = 0;
const GLenum INVALID_ENUM = 0x0500;
const GLenum INVALID_VALUE = 0x0501;