mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
fixing warnings, removing need for JStrings to be copied for mClass
This commit is contained in:
parent
aee50b580f
commit
e2d1e94396
@ -76,8 +76,8 @@ struct ObjectFunctionEntry {
|
||||
};
|
||||
|
||||
|
||||
JSObject *JSObject::objectPrototypeObject = JSObject::initJSObject();
|
||||
String JSObject::ObjectString = widenCString("Object");
|
||||
JSObject* JSObject::ObjectPrototypeObject = JSObject::initJSObject();
|
||||
JSString* JSObject::ObjectString = new JSString("Object");
|
||||
|
||||
// This establishes the ur-prototype, there's a timing issue
|
||||
// here - the JSObject static initializers have to run before
|
||||
@ -98,12 +98,9 @@ void JSObject::initObjectObject(JSScope *g)
|
||||
{
|
||||
JSNativeFunction *objCon = new JSNativeFunction(objectConstructor);
|
||||
|
||||
objCon->setProperty(widenCString("prototype"), JSValue(objectPrototypeObject));
|
||||
objCon->setProperty(widenCString("prototype"), JSValue(ObjectPrototypeObject));
|
||||
|
||||
|
||||
|
||||
|
||||
g->setProperty(ObjectString, JSValue(objCon));
|
||||
g->setProperty(*ObjectString, JSValue(objCon));
|
||||
}
|
||||
|
||||
|
||||
@ -149,8 +146,8 @@ JSValue function_call(Context *cx, const JSValues& argv)
|
||||
|
||||
|
||||
|
||||
String JSFunction::FunctionString = widenCString("Function");
|
||||
JSObject *JSFunction::functionPrototypeObject = NULL; // the 'original Function prototype object'
|
||||
JSString* JSFunction::FunctionString = new JSString("Function");
|
||||
JSObject* JSFunction::FunctionPrototypeObject = NULL; // the 'original Function prototype object'
|
||||
|
||||
struct FunctionFunctionEntry {
|
||||
char *name;
|
||||
@ -165,21 +162,21 @@ struct FunctionFunctionEntry {
|
||||
void JSFunction::initFunctionObject(JSScope *g)
|
||||
{
|
||||
// first build the Function Prototype Object
|
||||
functionPrototypeObject = new JSNativeFunction(functionPrototypeFunction);
|
||||
FunctionPrototypeObject = new JSNativeFunction(functionPrototypeFunction);
|
||||
for (int i = 0; i < sizeof(FunctionFunctions) / sizeof(FunctionFunctionEntry); i++)
|
||||
functionPrototypeObject->setProperty(widenCString(FunctionFunctions[i].name), JSValue(new JSNativeFunction(FunctionFunctions[i].fn) ) );
|
||||
FunctionPrototypeObject->setProperty(widenCString(FunctionFunctions[i].name), JSValue(new JSNativeFunction(FunctionFunctions[i].fn) ) );
|
||||
|
||||
// now the Function Constructor Object
|
||||
JSNativeFunction *functionConstructorObject = new JSNativeFunction(function_constructor);
|
||||
functionConstructorObject->setPrototype(functionPrototypeObject);
|
||||
functionConstructorObject->setPrototype(FunctionPrototypeObject);
|
||||
functionConstructorObject->setProperty(widenCString("length"), JSValue((int32)1));
|
||||
functionConstructorObject->setProperty(widenCString("prototype"), JSValue(functionPrototypeObject));
|
||||
functionConstructorObject->setProperty(widenCString("prototype"), JSValue(FunctionPrototypeObject));
|
||||
|
||||
// This is interesting - had to use defineVariable here to specify a type because
|
||||
// when left as Any_Type (via setProperty), the Function predefined type interacted
|
||||
// badly with this value. (I think setProperty perhaps should have reset the entry
|
||||
// in mTypes) (?)
|
||||
g->defineVariable(FunctionString, &Function_Type, JSValue(functionConstructorObject));
|
||||
g->defineVariable(*FunctionString, &Function_Type, JSValue(functionConstructorObject));
|
||||
}
|
||||
|
||||
/**************************************************************************************/
|
||||
|
108
js/js2/jstypes.h
108
js/js2/jstypes.h
@ -59,9 +59,9 @@ namespace JSTypes {
|
||||
|
||||
class JSObject;
|
||||
class JSArray;
|
||||
class JSString;
|
||||
class JSFunction;
|
||||
class JSScope;
|
||||
class JSString;
|
||||
class JSType;
|
||||
class Context;
|
||||
|
||||
@ -226,13 +226,13 @@ namespace JSTypes {
|
||||
JSString* mClass; // this is the internal [[Class]] property
|
||||
|
||||
static JSObject *initJSObject();
|
||||
static String ObjectString;
|
||||
static JSObject *objectPrototypeObject;
|
||||
static JSString *ObjectString;
|
||||
static JSObject *ObjectPrototypeObject;
|
||||
|
||||
void init(JSObject* prototype);
|
||||
void init(JSObject* prototype) { mPrototype = prototype; mType = &Any_Type; mClass = ObjectString; }
|
||||
|
||||
public:
|
||||
JSObject() { init(objectPrototypeObject); }
|
||||
JSObject() { init(ObjectPrototypeObject); }
|
||||
JSObject(JSValue &constructor) { init(constructor.object->getProperty(widenCString("prototype")).object); }
|
||||
JSObject(JSObject *prototype) { init(prototype); }
|
||||
|
||||
@ -362,49 +362,6 @@ namespace JSTypes {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Private representation of a JS function. This simply
|
||||
* holds a reference to the iCode module that is the
|
||||
* compiled code of the function.
|
||||
*/
|
||||
class JSFunction : public JSObject {
|
||||
static String FunctionString;
|
||||
static JSObject *functionPrototypeObject;
|
||||
ICodeModule* mICode;
|
||||
protected:
|
||||
JSFunction() : mICode(0) {}
|
||||
|
||||
typedef JavaScript::gc_traits_finalizable<JSFunction> traits;
|
||||
typedef gc_allocator<JSFunction, traits> allocator;
|
||||
|
||||
public:
|
||||
static void JSFunction::initFunctionObject(JSScope *g);
|
||||
|
||||
JSFunction(ICodeModule* iCode);
|
||||
~JSFunction();
|
||||
|
||||
void* operator new(size_t) { return allocator::allocate(1); }
|
||||
|
||||
ICodeModule* getICode() { return mICode; }
|
||||
virtual bool isNative() { return false; }
|
||||
};
|
||||
|
||||
class JSNativeFunction : public JSFunction {
|
||||
public:
|
||||
typedef JSValue (*JSCode)(Context *cx, const JSValues& argv);
|
||||
JSCode mCode;
|
||||
JSNativeFunction(JSCode code) : mCode(code) {}
|
||||
virtual bool isNative() { return true; }
|
||||
};
|
||||
|
||||
class JSBinaryOperator : public JSFunction {
|
||||
public:
|
||||
typedef JSValue (*JSBinaryCode)(const JSValue& arg1, const JSValue& arg2);
|
||||
JSBinaryCode mCode;
|
||||
JSBinaryOperator(JSBinaryCode code) : mCode(code) {}
|
||||
virtual bool isNative() { return true; }
|
||||
};
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
// bastring.cc defines a funky operator new that assumes a byte-allocator.
|
||||
typedef string_char_traits<char16> JSCharTraits;
|
||||
@ -447,6 +404,55 @@ namespace JSTypes {
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private representation of a JS function. This simply
|
||||
* holds a reference to the iCode module that is the
|
||||
* compiled code of the function.
|
||||
*/
|
||||
class JSFunction : public JSObject {
|
||||
static JSString* FunctionString;
|
||||
static JSObject* FunctionPrototypeObject;
|
||||
ICodeModule* mICode;
|
||||
protected:
|
||||
JSFunction() : mICode(0) {}
|
||||
|
||||
typedef JavaScript::gc_traits_finalizable<JSFunction> traits;
|
||||
typedef gc_allocator<JSFunction, traits> allocator;
|
||||
|
||||
public:
|
||||
static void JSFunction::initFunctionObject(JSScope *g);
|
||||
|
||||
JSFunction(ICodeModule* iCode)
|
||||
: JSObject(FunctionPrototypeObject),
|
||||
mICode(iCode)
|
||||
{
|
||||
setClass(FunctionString);
|
||||
}
|
||||
|
||||
~JSFunction();
|
||||
|
||||
void* operator new(size_t) { return allocator::allocate(1); }
|
||||
|
||||
ICodeModule* getICode() { return mICode; }
|
||||
virtual bool isNative() { return false; }
|
||||
};
|
||||
|
||||
class JSNativeFunction : public JSFunction {
|
||||
public:
|
||||
typedef JSValue (*JSCode)(Context *cx, const JSValues& argv);
|
||||
JSCode mCode;
|
||||
JSNativeFunction(JSCode code) : mCode(code) {}
|
||||
virtual bool isNative() { return true; }
|
||||
};
|
||||
|
||||
class JSBinaryOperator : public JSFunction {
|
||||
public:
|
||||
typedef JSValue (*JSBinaryCode)(const JSValue& arg1, const JSValue& arg2);
|
||||
JSBinaryCode mCode;
|
||||
JSBinaryOperator(JSBinaryCode code) : mCode(code) {}
|
||||
virtual bool isNative() { return true; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides a set of nested scopes.
|
||||
*/
|
||||
@ -561,12 +567,6 @@ namespace JSTypes {
|
||||
int32 distance(const JSType *other) const;
|
||||
};
|
||||
|
||||
|
||||
inline void JSObject::init(JSObject* prototype) { mPrototype = prototype; mType = &Any_Type; mClass = new JSString(ObjectString); }
|
||||
|
||||
inline JSFunction::JSFunction(ICodeModule* iCode) : mICode(iCode), JSObject(functionPrototypeObject) { setClass(new JSString(FunctionString)); }
|
||||
|
||||
|
||||
} /* namespace JSTypes */
|
||||
} /* namespace JavaScript */
|
||||
|
||||
|
@ -76,8 +76,8 @@ struct ObjectFunctionEntry {
|
||||
};
|
||||
|
||||
|
||||
JSObject *JSObject::objectPrototypeObject = JSObject::initJSObject();
|
||||
String JSObject::ObjectString = widenCString("Object");
|
||||
JSObject* JSObject::ObjectPrototypeObject = JSObject::initJSObject();
|
||||
JSString* JSObject::ObjectString = new JSString("Object");
|
||||
|
||||
// This establishes the ur-prototype, there's a timing issue
|
||||
// here - the JSObject static initializers have to run before
|
||||
@ -98,12 +98,9 @@ void JSObject::initObjectObject(JSScope *g)
|
||||
{
|
||||
JSNativeFunction *objCon = new JSNativeFunction(objectConstructor);
|
||||
|
||||
objCon->setProperty(widenCString("prototype"), JSValue(objectPrototypeObject));
|
||||
objCon->setProperty(widenCString("prototype"), JSValue(ObjectPrototypeObject));
|
||||
|
||||
|
||||
|
||||
|
||||
g->setProperty(ObjectString, JSValue(objCon));
|
||||
g->setProperty(*ObjectString, JSValue(objCon));
|
||||
}
|
||||
|
||||
|
||||
@ -149,8 +146,8 @@ JSValue function_call(Context *cx, const JSValues& argv)
|
||||
|
||||
|
||||
|
||||
String JSFunction::FunctionString = widenCString("Function");
|
||||
JSObject *JSFunction::functionPrototypeObject = NULL; // the 'original Function prototype object'
|
||||
JSString* JSFunction::FunctionString = new JSString("Function");
|
||||
JSObject* JSFunction::FunctionPrototypeObject = NULL; // the 'original Function prototype object'
|
||||
|
||||
struct FunctionFunctionEntry {
|
||||
char *name;
|
||||
@ -165,21 +162,21 @@ struct FunctionFunctionEntry {
|
||||
void JSFunction::initFunctionObject(JSScope *g)
|
||||
{
|
||||
// first build the Function Prototype Object
|
||||
functionPrototypeObject = new JSNativeFunction(functionPrototypeFunction);
|
||||
FunctionPrototypeObject = new JSNativeFunction(functionPrototypeFunction);
|
||||
for (int i = 0; i < sizeof(FunctionFunctions) / sizeof(FunctionFunctionEntry); i++)
|
||||
functionPrototypeObject->setProperty(widenCString(FunctionFunctions[i].name), JSValue(new JSNativeFunction(FunctionFunctions[i].fn) ) );
|
||||
FunctionPrototypeObject->setProperty(widenCString(FunctionFunctions[i].name), JSValue(new JSNativeFunction(FunctionFunctions[i].fn) ) );
|
||||
|
||||
// now the Function Constructor Object
|
||||
JSNativeFunction *functionConstructorObject = new JSNativeFunction(function_constructor);
|
||||
functionConstructorObject->setPrototype(functionPrototypeObject);
|
||||
functionConstructorObject->setPrototype(FunctionPrototypeObject);
|
||||
functionConstructorObject->setProperty(widenCString("length"), JSValue((int32)1));
|
||||
functionConstructorObject->setProperty(widenCString("prototype"), JSValue(functionPrototypeObject));
|
||||
functionConstructorObject->setProperty(widenCString("prototype"), JSValue(FunctionPrototypeObject));
|
||||
|
||||
// This is interesting - had to use defineVariable here to specify a type because
|
||||
// when left as Any_Type (via setProperty), the Function predefined type interacted
|
||||
// badly with this value. (I think setProperty perhaps should have reset the entry
|
||||
// in mTypes) (?)
|
||||
g->defineVariable(FunctionString, &Function_Type, JSValue(functionConstructorObject));
|
||||
g->defineVariable(*FunctionString, &Function_Type, JSValue(functionConstructorObject));
|
||||
}
|
||||
|
||||
/**************************************************************************************/
|
||||
|
@ -59,9 +59,9 @@ namespace JSTypes {
|
||||
|
||||
class JSObject;
|
||||
class JSArray;
|
||||
class JSString;
|
||||
class JSFunction;
|
||||
class JSScope;
|
||||
class JSString;
|
||||
class JSType;
|
||||
class Context;
|
||||
|
||||
@ -226,13 +226,13 @@ namespace JSTypes {
|
||||
JSString* mClass; // this is the internal [[Class]] property
|
||||
|
||||
static JSObject *initJSObject();
|
||||
static String ObjectString;
|
||||
static JSObject *objectPrototypeObject;
|
||||
static JSString *ObjectString;
|
||||
static JSObject *ObjectPrototypeObject;
|
||||
|
||||
void init(JSObject* prototype);
|
||||
void init(JSObject* prototype) { mPrototype = prototype; mType = &Any_Type; mClass = ObjectString; }
|
||||
|
||||
public:
|
||||
JSObject() { init(objectPrototypeObject); }
|
||||
JSObject() { init(ObjectPrototypeObject); }
|
||||
JSObject(JSValue &constructor) { init(constructor.object->getProperty(widenCString("prototype")).object); }
|
||||
JSObject(JSObject *prototype) { init(prototype); }
|
||||
|
||||
@ -362,49 +362,6 @@ namespace JSTypes {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Private representation of a JS function. This simply
|
||||
* holds a reference to the iCode module that is the
|
||||
* compiled code of the function.
|
||||
*/
|
||||
class JSFunction : public JSObject {
|
||||
static String FunctionString;
|
||||
static JSObject *functionPrototypeObject;
|
||||
ICodeModule* mICode;
|
||||
protected:
|
||||
JSFunction() : mICode(0) {}
|
||||
|
||||
typedef JavaScript::gc_traits_finalizable<JSFunction> traits;
|
||||
typedef gc_allocator<JSFunction, traits> allocator;
|
||||
|
||||
public:
|
||||
static void JSFunction::initFunctionObject(JSScope *g);
|
||||
|
||||
JSFunction(ICodeModule* iCode);
|
||||
~JSFunction();
|
||||
|
||||
void* operator new(size_t) { return allocator::allocate(1); }
|
||||
|
||||
ICodeModule* getICode() { return mICode; }
|
||||
virtual bool isNative() { return false; }
|
||||
};
|
||||
|
||||
class JSNativeFunction : public JSFunction {
|
||||
public:
|
||||
typedef JSValue (*JSCode)(Context *cx, const JSValues& argv);
|
||||
JSCode mCode;
|
||||
JSNativeFunction(JSCode code) : mCode(code) {}
|
||||
virtual bool isNative() { return true; }
|
||||
};
|
||||
|
||||
class JSBinaryOperator : public JSFunction {
|
||||
public:
|
||||
typedef JSValue (*JSBinaryCode)(const JSValue& arg1, const JSValue& arg2);
|
||||
JSBinaryCode mCode;
|
||||
JSBinaryOperator(JSBinaryCode code) : mCode(code) {}
|
||||
virtual bool isNative() { return true; }
|
||||
};
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
// bastring.cc defines a funky operator new that assumes a byte-allocator.
|
||||
typedef string_char_traits<char16> JSCharTraits;
|
||||
@ -447,6 +404,55 @@ namespace JSTypes {
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private representation of a JS function. This simply
|
||||
* holds a reference to the iCode module that is the
|
||||
* compiled code of the function.
|
||||
*/
|
||||
class JSFunction : public JSObject {
|
||||
static JSString* FunctionString;
|
||||
static JSObject* FunctionPrototypeObject;
|
||||
ICodeModule* mICode;
|
||||
protected:
|
||||
JSFunction() : mICode(0) {}
|
||||
|
||||
typedef JavaScript::gc_traits_finalizable<JSFunction> traits;
|
||||
typedef gc_allocator<JSFunction, traits> allocator;
|
||||
|
||||
public:
|
||||
static void JSFunction::initFunctionObject(JSScope *g);
|
||||
|
||||
JSFunction(ICodeModule* iCode)
|
||||
: JSObject(FunctionPrototypeObject),
|
||||
mICode(iCode)
|
||||
{
|
||||
setClass(FunctionString);
|
||||
}
|
||||
|
||||
~JSFunction();
|
||||
|
||||
void* operator new(size_t) { return allocator::allocate(1); }
|
||||
|
||||
ICodeModule* getICode() { return mICode; }
|
||||
virtual bool isNative() { return false; }
|
||||
};
|
||||
|
||||
class JSNativeFunction : public JSFunction {
|
||||
public:
|
||||
typedef JSValue (*JSCode)(Context *cx, const JSValues& argv);
|
||||
JSCode mCode;
|
||||
JSNativeFunction(JSCode code) : mCode(code) {}
|
||||
virtual bool isNative() { return true; }
|
||||
};
|
||||
|
||||
class JSBinaryOperator : public JSFunction {
|
||||
public:
|
||||
typedef JSValue (*JSBinaryCode)(const JSValue& arg1, const JSValue& arg2);
|
||||
JSBinaryCode mCode;
|
||||
JSBinaryOperator(JSBinaryCode code) : mCode(code) {}
|
||||
virtual bool isNative() { return true; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides a set of nested scopes.
|
||||
*/
|
||||
@ -561,12 +567,6 @@ namespace JSTypes {
|
||||
int32 distance(const JSType *other) const;
|
||||
};
|
||||
|
||||
|
||||
inline void JSObject::init(JSObject* prototype) { mPrototype = prototype; mType = &Any_Type; mClass = new JSString(ObjectString); }
|
||||
|
||||
inline JSFunction::JSFunction(ICodeModule* iCode) : mICode(iCode), JSObject(functionPrototypeObject) { setClass(new JSString(FunctionString)); }
|
||||
|
||||
|
||||
} /* namespace JSTypes */
|
||||
} /* namespace JavaScript */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user