зеркало из https://github.com/mozilla/gecko-dev.git
Bug 948638 - Always use jsid struct types. r=Waldo
This commit is contained in:
Родитель
a45c89d4d3
Коммит
e4de4469c3
|
@ -28,17 +28,13 @@
|
|||
#include "js/TypeDecls.h"
|
||||
#include "js/Utility.h"
|
||||
|
||||
#ifdef JS_USE_JSID_STRUCT_TYPES
|
||||
struct jsid
|
||||
{
|
||||
size_t asBits;
|
||||
bool operator==(jsid rhs) const { return asBits == rhs.asBits; }
|
||||
bool operator!=(jsid rhs) const { return asBits != rhs.asBits; }
|
||||
};
|
||||
# define JSID_BITS(id) (id.asBits)
|
||||
#else
|
||||
# define JSID_BITS(id) (id)
|
||||
#endif
|
||||
#define JSID_BITS(id) (id.asBits)
|
||||
|
||||
#define JSID_TYPE_STRING 0x0
|
||||
#define JSID_TYPE_INT 0x1
|
||||
|
@ -152,13 +148,8 @@ JSID_IS_EMPTY(const jsid id)
|
|||
|
||||
#undef id
|
||||
|
||||
#ifdef JS_USE_JSID_STRUCT_TYPES
|
||||
extern JS_PUBLIC_DATA(const jsid) JSID_VOID;
|
||||
extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY;
|
||||
#else
|
||||
# define JSID_VOID ((jsid)JSID_TYPE_VOID)
|
||||
# define JSID_EMPTY ((jsid)JSID_TYPE_OBJECT)
|
||||
#endif
|
||||
|
||||
extern JS_PUBLIC_DATA(const JS::Handle<jsid>) JSID_VOIDHANDLE;
|
||||
extern JS_PUBLIC_DATA(const JS::Handle<jsid>) JSID_EMPTYHANDLE;
|
||||
|
|
|
@ -28,29 +28,7 @@ class JSObject;
|
|||
class JSScript;
|
||||
class JSString;
|
||||
|
||||
// In release builds, jsid is defined to be an integral type. This
|
||||
// prevents many bugs from being caught at compile time. E.g.:
|
||||
//
|
||||
// jsid id = ...
|
||||
// if (id) // error
|
||||
// ...
|
||||
//
|
||||
// size_t n = id; // error
|
||||
//
|
||||
// To catch more errors, jsid is given a struct type in C++ debug builds.
|
||||
// Struct assignment and (in C++) operator== allow correct code to be mostly
|
||||
// oblivious to the change. This feature can be explicitly disabled in debug
|
||||
// builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES.
|
||||
//
|
||||
#if defined(JS_DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES)
|
||||
# define JS_USE_JSID_STRUCT_TYPES
|
||||
#endif
|
||||
|
||||
#ifdef JS_USE_JSID_STRUCT_TYPES
|
||||
struct jsid;
|
||||
#else
|
||||
typedef ptrdiff_t jsid;
|
||||
#endif
|
||||
|
||||
typedef char16_t jschar;
|
||||
|
||||
|
|
|
@ -7,10 +7,8 @@
|
|||
#include "js/Id.h"
|
||||
#include "js/RootingAPI.h"
|
||||
|
||||
#ifdef JS_USE_JSID_STRUCT_TYPES
|
||||
const jsid JSID_VOID = { size_t(JSID_TYPE_VOID) };
|
||||
const jsid JSID_EMPTY = { size_t(JSID_TYPE_OBJECT) };
|
||||
#endif
|
||||
|
||||
static const jsid voidIdValue = JSID_VOID;
|
||||
static const jsid emptyIdValue = JSID_EMPTY;
|
||||
|
|
Загрузка…
Ссылка в новой задаче