Bug 752737 - Delete the default and copy constructors and assignment operator from JSString and JSObject to avoid errors. r=luke

--HG--
extra : rebase_source : 37d8f094e917a097ac1b2ee0d4956f15e46c532c
This commit is contained in:
Jeff Walden 2012-05-07 16:45:19 -07:00
parent 3a093e8b9c
commit 340a8204d1
8 changed files with 17 additions and 29 deletions

View File

@ -13,7 +13,8 @@ BEGIN_TEST(testConservativeGC)
jsval v3;
EVAL("String(Math.PI);", &v3);
CHECK(JSVAL_IS_STRING(v3));
JSString strCopy = *JSVAL_TO_STRING(v3);
char strCopy[sizeof(JSString)];
js_memcpy(&strCopy, JSVAL_TO_STRING(v3), sizeof(JSString));
jsval tmp;
EVAL("({foo2: 'bar2'});", &tmp);
@ -25,7 +26,8 @@ BEGIN_TEST(testConservativeGC)
EVAL("String(Math.sqrt(3));", &tmp);
CHECK(JSVAL_IS_STRING(tmp));
JSString *str2 = JSVAL_TO_STRING(tmp);
JSString str2Copy = *str2;
char str2Copy[sizeof(JSString)];
js_memcpy(&str2Copy, str2, sizeof(JSString));
tmp = JSVAL_NULL;
@ -39,10 +41,10 @@ BEGIN_TEST(testConservativeGC)
JS_GC(rt);
checkObjectFields((JSObject *)objCopy, JSVAL_TO_OBJECT(v2));
CHECK(!memcmp(&strCopy, JSVAL_TO_STRING(v3), sizeof(strCopy)));
CHECK(!memcmp(strCopy, JSVAL_TO_STRING(v3), sizeof(strCopy)));
checkObjectFields((JSObject *)obj2Copy, obj2);
CHECK(!memcmp(&str2Copy, str2, sizeof(str2Copy)));
CHECK(!memcmp(str2Copy, str2, sizeof(str2Copy)));
return true;
}

View File

@ -998,6 +998,10 @@ struct JSObject : public js::ObjectImpl
MOZ_STATIC_ASSERT(sizeof(JSObject) % sizeof(js::Value) == 0,
"fixed slots after an object must be aligned");
}
JSObject() MOZ_DELETE;
JSObject(const JSObject &other) MOZ_DELETE;
void operator=(const JSObject &other) MOZ_DELETE;
};
/*

View File

@ -41,8 +41,6 @@
#ifndef BooleanObject_h___
#define BooleanObject_h___
#include "mozilla/Attributes.h"
#include "jsbool.h"
namespace js {
@ -79,10 +77,6 @@ class BooleanObject : public JSObject
/* For access to init, as Boolean.prototype is special. */
friend JSObject *
::js_InitBooleanClass(JSContext *cx, JSObject *global);
private:
BooleanObject() MOZ_DELETE;
BooleanObject &operator=(const BooleanObject &bo) MOZ_DELETE;
};
} // namespace js

View File

@ -94,10 +94,8 @@ class Debugger;
* even deletable) Object, Array, &c. properties (although a slot won't be used
* again if its property is deleted and readded).
*/
class GlobalObject : public JSObject {
GlobalObject(const GlobalObject &other) MOZ_DELETE;
void operator=(const GlobalObject &other) MOZ_DELETE;
class GlobalObject : public JSObject
{
/*
* Count of slots to store built-in constructors, prototypes, and initial
* visible properties for the constructors.

View File

@ -41,8 +41,6 @@
#ifndef NumberObject_h___
#define NumberObject_h___
#include "mozilla/Attributes.h"
#include "jsnum.h"
namespace js {
@ -79,10 +77,6 @@ class NumberObject : public JSObject
/* For access to init, as Number.prototype is special. */
friend JSObject *
::js_InitNumberClass(JSContext *cx, JSObject *global);
private:
NumberObject() MOZ_DELETE;
NumberObject &operator=(const NumberObject &so) MOZ_DELETE;
};
} // namespace js

View File

@ -424,9 +424,6 @@ class RegExpObject : public JSObject
bool createShared(JSContext *cx, RegExpGuard *g);
RegExpShared *maybeShared() const;
RegExpObject() MOZ_DELETE;
RegExpObject &operator=(const RegExpObject &reo) MOZ_DELETE;
/* Call setShared in preference to setPrivate. */
void setPrivate(void *priv) MOZ_DELETE;
};

View File

@ -422,6 +422,11 @@ class JSString : public js::gc::Cell
void dump();
bool equals(const char *s);
#endif
private:
JSString() MOZ_DELETE;
JSString(const JSString &other) MOZ_DELETE;
void operator=(const JSString &other) MOZ_DELETE;
};
class JSRope : public JSString

View File

@ -41,8 +41,6 @@
#ifndef StringObject_h___
#define StringObject_h___
#include "mozilla/Attributes.h"
#include "jsobj.h"
#include "jsstr.h"
@ -99,10 +97,6 @@ class StringObject : public JSObject
* this String object's last property to it.
*/
Shape *assignInitialShape(JSContext *cx);
private:
StringObject() MOZ_DELETE;
StringObject &operator=(const StringObject &so) MOZ_DELETE;
};
} // namespace js