+2005-12-10 Darin Adler <darin@apple.com>
+
+ Rubber stamped by Maciej.
+
+ - did long-promised KJS renaming:
+
+ ValueImp -> JSValue
+ ObjectImp -> JSObject
+ AllocatedValueImp -> JSCell
+
+ A renaming to get a class out of the way
+
+ KJS::Bindings::JSObject -> JavaJSObject
+
+ and some other "imp-reduction" renaming
+
+ *InstanceImp -> *Instance
+ *ProtoFuncImp -> *ProtoFunc
+ *PrototypeImp -> *Prototype
+ ArgumentsImp -> Arguments
+ RuntimeArrayImp -> RuntimeArray
+ RuntimeMethodImp -> RuntimeMethod
+
+ * most files and functions
+
2005-12-10 Darin Adler <darin@apple.com>
Reviewed by Maciej.
return true;
}
-NPObject *_NPN_CreateScriptObject (NPP npp, KJS::ObjectImp *imp, const KJS::Bindings::RootObject *originExecutionContext, const KJS::Bindings::RootObject *executionContext)
+NPObject *_NPN_CreateScriptObject (NPP npp, KJS::JSObject *imp, const KJS::Bindings::RootObject *originExecutionContext, const KJS::Bindings::RootObject *executionContext)
{
JavaScriptObject *obj = (JavaScriptObject *)_NPN_CreateObject(npp, NPScriptObjectClass);
// Lookup the function object.
ExecState *exec = obj->executionContext->interpreter()->globalExec();
JSLock lock;
- ValueImp *func = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
+ JSValue *func = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
if (func->isNull()) {
NPN_InitializeVariantAsNull(result);
return false;
} else {
// Call the function object.
- ObjectImp *funcImp = static_cast<ObjectImp*>(func);
- ObjectImp *thisObj = const_cast<ObjectImp*>(obj->imp);
+ JSObject *funcImp = static_cast<JSObject*>(func);
+ JSObject *thisObj = const_cast<JSObject*>(obj->imp);
List argList = listFromVariantArgs(exec, args, argCount);
- ValueImp *resultV = funcImp->call (exec, thisObj, argList);
+ JSValue *resultV = funcImp->call (exec, thisObj, argList);
// Convert and return the result of the function call.
convertValueToNPVariant(exec, resultV, result);
return false;
ExecState *exec = obj->executionContext->interpreter()->globalExec();
- ValueImp *result;
+ JSValue *result;
JSLock lock;
NPUTF16 *scriptString;
PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
JSLock lock;
- ValueImp *result;
+ JSValue *result;
if (i->isString) {
result = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
} else {
ExecState *exec = obj->executionContext->interpreter()->globalExec();
JSLock lock;
- ValueImp *func = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
+ JSValue *func = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
if (func->isUndefined()) {
return false;
typedef struct
{
NPObject object;
- KJS::ObjectImp *imp;
+ KJS::JSObject *imp;
const KJS::Bindings::RootObject *originExecutionContext;
const KJS::Bindings::RootObject *executionContext;
} JavaScriptObject;
-NPObject *_NPN_CreateScriptObject (NPP npp, KJS::ObjectImp *imp, const KJS::Bindings::RootObject *originExecutionContext, const KJS::Bindings::RootObject *executionContext);
+NPObject *_NPN_CreateScriptObject (NPP npp, KJS::JSObject *imp, const KJS::Bindings::RootObject *originExecutionContext, const KJS::Bindings::RootObject *executionContext);
#ifdef __cplusplus
}
// Do nothing.
}
-ValueImp *CInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
+JSValue *CInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
{
- ValueImp *resultValue;
+ JSValue *resultValue;
// Overloading methods are not allowed by NPObjects. Should only be one
// name match for a particular method.
}
-ValueImp *CInstance::invokeDefaultMethod (ExecState *exec, const List &args)
+JSValue *CInstance::invokeDefaultMethod (ExecState *exec, const List &args)
{
- ValueImp *resultValue;
+ JSValue *resultValue;
if (_object->_class->invokeDefault) {
unsigned i, count = args.size();
}
-ValueImp *CInstance::defaultValue (Type hint) const
+JSValue *CInstance::defaultValue (Type hint) const
{
if (hint == StringType) {
return stringValue();
return valueOf();
}
-ValueImp *CInstance::stringValue() const
+JSValue *CInstance::stringValue() const
{
char buf[1024];
snprintf(buf, 1024, "NPObject %p, NPClass %p", _object, _object->_class);
return jsString(buf);
}
-ValueImp *CInstance::numberValue() const
+JSValue *CInstance::numberValue() const
{
// FIXME: Implement something sensible
return jsNumber(0);
}
-ValueImp *CInstance::booleanValue() const
+JSValue *CInstance::booleanValue() const
{
// FIXME: Implement something sensible
return jsBoolean(false);
}
-ValueImp *CInstance::valueOf() const
+JSValue *CInstance::valueOf() const
{
return stringValue();
}
virtual void begin();
virtual void end();
- virtual ValueImp *valueOf() const;
- virtual ValueImp *defaultValue (KJS::Type hint) const;
+ virtual JSValue *valueOf() const;
+ virtual JSValue *defaultValue (KJS::Type hint) const;
- virtual ValueImp *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
- virtual ValueImp *invokeDefaultMethod (ExecState *exec, const List &args);
+ virtual JSValue *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
+ virtual JSValue *invokeDefaultMethod (ExecState *exec, const List &args);
- ValueImp *stringValue() const;
- ValueImp *numberValue() const;
- ValueImp *booleanValue() const;
+ JSValue *stringValue() const;
+ JSValue *numberValue() const;
+ JSValue *booleanValue() const;
NPObject *getObject() const { return _object; }
// ---------------------- CField ----------------------
-ValueImp *CField::valueFromInstance(ExecState *exec, const Instance *inst) const
+JSValue *CField::valueFromInstance(ExecState *exec, const Instance *inst) const
{
const CInstance *instance = static_cast<const CInstance*>(inst);
NPObject *obj = instance->getObject();
- ValueImp *aValue;
+ JSValue *aValue;
NPVariant property;
VOID_TO_NPVARIANT(property);
if (obj->_class->getProperty) {
return aValue;
}
-void CField::setValueToInstance(ExecState *exec, const Instance *inst, ValueImp *aValue) const
+void CField::setValueToInstance(ExecState *exec, const Instance *inst, JSValue *aValue) const
{
const CInstance *instance = static_cast<const CInstance*>(inst);
NPObject *obj = instance->getObject();
_fieldIdentifier = ident;
};
- virtual ValueImp *valueFromInstance(ExecState *exec, const Instance *instance) const;
- virtual void setValueToInstance(ExecState *exec, const Instance *instance, ValueImp *aValue) const;
+ virtual JSValue *valueFromInstance(ExecState *exec, const Instance *instance) const;
+ virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const;
virtual const char *name() const { return _NPN_UTF8FromIdentifier(_fieldIdentifier); }
virtual RuntimeType type() const { return ""; }
CArray &operator=(const CArray &other);
- virtual void setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const;
- virtual ValueImp *valueAt(ExecState *exec, unsigned int index) const;
+ virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const;
+ virtual JSValue *valueAt(ExecState *exec, unsigned int index) const;
virtual unsigned int getLength() const;
virtual ~CArray();
}
// Variant value must be released with NPReleaseVariantValue()
-void coerceValueToNPVariantStringType(ExecState *exec, ValueImp *value, NPVariant *result)
+void coerceValueToNPVariantStringType(ExecState *exec, JSValue *value, NPVariant *result)
{
UString ustring = value->toString(exec);
CString cstring = ustring.UTF8String();
}
// Variant value must be released with NPReleaseVariantValue()
-void convertValueToNPVariant(ExecState *exec, ValueImp *value, NPVariant *result)
+void convertValueToNPVariant(ExecState *exec, JSValue *value, NPVariant *result)
{
Type type = value->type();
NPN_InitializeVariantAsNull(result);
}
else if (type == ObjectType) {
- ObjectImp *objectImp = static_cast<ObjectImp*>(value);
+ JSObject *objectImp = static_cast<JSObject*>(value);
if (objectImp->classInfo() == &RuntimeObjectImp::info) {
RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(value);
CInstance *instance = static_cast<CInstance*>(imp->getInternalInstance());
NPN_InitializeVariantAsUndefined(result);
}
-ValueImp *convertNPVariantToValue(ExecState *exec, const NPVariant *variant)
+JSValue *convertNPVariantToValue(ExecState *exec, const NPVariant *variant)
{
NPVariantType type = variant->type;
NPObject *obj = variant->value.objectValue;
if (obj->_class == NPScriptObjectClass) {
- // Get ObjectImp from NP_JavaScriptObject.
+ // Get JSObject from NP_JavaScriptObject.
JavaScriptObject *o = (JavaScriptObject *)obj;
- return const_cast<ObjectImp*>(o->imp);
+ return const_cast<JSObject*>(o->imp);
}
else {
// Wrap NPObject in a CInstance.
void convertNPStringToUTF16(const NPString *string, NPUTF16 **UTF16Chars, unsigned int *UTF16Length);
void convertUTF8ToUTF16(const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16Chars, unsigned int *UTF16Length);
-void coerceValueToNPVariantStringType(KJS::ExecState *exec, KJS::ValueImp *value, NPVariant *result);
-void convertValueToNPVariant(KJS::ExecState *exec, KJS::ValueImp *value, NPVariant *result);
-KJS::ValueImp *convertNPVariantToValue(KJS::ExecState *exec, const NPVariant *variant);
+void coerceValueToNPVariantStringType(KJS::ExecState *exec, KJS::JSValue *value, NPVariant *result);
+void convertValueToNPVariant(KJS::ExecState *exec, KJS::JSValue *value, NPVariant *result);
+KJS::JSValue *convertNPVariantToValue(KJS::ExecState *exec, const NPVariant *variant);
typedef struct
{
return _class;
}
-ValueImp *JavaInstance::stringValue() const
+JSValue *JavaInstance::stringValue() const
{
jstring stringValue = (jstring)callJNIObjectMethod (_instance->_instance, "toString", "()Ljava/lang/String;");
JNIEnv *env = getJNIEnv();
return jsString(u);
}
-ValueImp *JavaInstance::numberValue() const
+JSValue *JavaInstance::numberValue() const
{
jdouble doubleValue = callJNIDoubleMethod (_instance->_instance, "doubleValue", "()D");
return jsNumber(doubleValue);
}
-ValueImp *JavaInstance::booleanValue() const
+JSValue *JavaInstance::booleanValue() const
{
jboolean booleanValue = callJNIBooleanMethod (_instance->_instance, "booleanValue", "()Z");
return jsBoolean(booleanValue);
}
-ValueImp *JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
+JSValue *JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
{
int i, count = args.size();
jvalue *jArgs;
- ValueImp *resultValue;
+ JSValue *resultValue;
Method *method = 0;
unsigned int numMethods = methodList.length();
bool handled = false;
if (execContext && execContext->nativeHandle()) {
jobject obj = _instance->_instance;
- ValueImp *exceptionDescription = NULL;
+ JSValue *exceptionDescription = NULL;
const char *callingURL = 0; // FIXME, need to propagate calling URL to Java
handled = dispatchJNICall (execContext->nativeHandle(), obj, jMethod->isStatic(), jMethod->JNIReturnType(), jMethod->methodID(obj), jArgs, result, callingURL, exceptionDescription);
if (exceptionDescription) {
return resultValue;
}
-ValueImp *JavaInstance::invokeDefaultMethod (ExecState *exec, const List &args)
+JSValue *JavaInstance::invokeDefaultMethod (ExecState *exec, const List &args)
{
return jsUndefined();
}
-ValueImp *JavaInstance::defaultValue (Type hint) const
+JSValue *JavaInstance::defaultValue (Type hint) const
{
if (hint == StringType) {
return stringValue();
return valueOf();
}
-ValueImp *JavaInstance::valueOf() const
+JSValue *JavaInstance::valueOf() const
{
return stringValue();
};
virtual void begin();
virtual void end();
- virtual ValueImp *valueOf() const;
- virtual ValueImp *defaultValue (Type hint) const;
+ virtual JSValue *valueOf() const;
+ virtual JSValue *defaultValue (Type hint) const;
- virtual ValueImp *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
- virtual ValueImp *invokeDefaultMethod (ExecState *exec, const List &args);
+ virtual JSValue *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
+ virtual JSValue *invokeDefaultMethod (ExecState *exec, const List &args);
jobject javaInstance() const { return _instance->_instance; }
- ValueImp *stringValue() const;
- ValueImp *numberValue() const;
- ValueImp *booleanValue() const;
+ JSValue *stringValue() const;
+ JSValue *numberValue() const;
+ JSValue *booleanValue() const;
private:
JavaInstance (); // prevent default construction
return (RootObject::runLoop() == CFRunLoopGetCurrent());
}
-jvalue JSObject::invoke (JSObjectCallContext *context)
+jvalue JavaJSObject::invoke (JSObjectCallContext *context)
{
jvalue result;
}
if (context->type == CreateNative) {
- result.j = JSObject::createNative(nativeHandle);
+ result.j = JavaJSObject::createNative(nativeHandle);
}
else {
- ObjectImp *imp = jlong_to_impptr(nativeHandle);
+ JSObject *imp = jlong_to_impptr(nativeHandle);
if (!rootForImp(imp)) {
fprintf (stderr, "%s:%d: Attempt to access JavaScript from destroyed applet, type %d.\n", __FILE__, __LINE__, context->type);
return result;
switch (context->type){
case Call: {
- result.l = JSObject(nativeHandle).call(context->string, context->args);
+ result.l = JavaJSObject(nativeHandle).call(context->string, context->args);
break;
}
case Eval: {
- result.l = JSObject(nativeHandle).eval(context->string);
+ result.l = JavaJSObject(nativeHandle).eval(context->string);
break;
}
case GetMember: {
- result.l = JSObject(nativeHandle).getMember(context->string);
+ result.l = JavaJSObject(nativeHandle).getMember(context->string);
break;
}
case SetMember: {
- JSObject(nativeHandle).setMember(context->string, context->value);
+ JavaJSObject(nativeHandle).setMember(context->string, context->value);
break;
}
case RemoveMember: {
- JSObject(nativeHandle).removeMember(context->string);
+ JavaJSObject(nativeHandle).removeMember(context->string);
break;
}
case GetSlot: {
- result.l = JSObject(nativeHandle).getSlot(context->index);
+ result.l = JavaJSObject(nativeHandle).getSlot(context->index);
break;
}
case SetSlot: {
- JSObject(nativeHandle).setSlot(context->index, context->value);
+ JavaJSObject(nativeHandle).setSlot(context->index, context->value);
break;
}
case ToString: {
- result.l = (jobject) JSObject(nativeHandle).toString();
+ result.l = (jobject) JavaJSObject(nativeHandle).toString();
break;
}
case Finalize: {
- ObjectImp *imp = jlong_to_impptr(nativeHandle);
+ JSObject *imp = jlong_to_impptr(nativeHandle);
if (findReferenceDictionary(imp) == 0) {
// We may have received a finalize method call from the VM
// AFTER removing our last reference to the Java instance.
JS_LOG ("finalize called on instance we have already removed.\n");
}
else {
- JSObject(nativeHandle).finalize();
+ JavaJSObject(nativeHandle).finalize();
}
break;
}
}
-JSObject::JSObject(jlong nativeJSObject)
+JavaJSObject::JavaJSObject(jlong nativeJSObject)
{
_imp = jlong_to_impptr(nativeJSObject);
- // If we are unable to cast the nativeJSObject to an ObjectImp something is
+ // If we are unable to cast the nativeJSObject to an JSObject something is
// terribly wrong.
assert (_imp != 0);
}
-jobject JSObject::call(jstring methodName, jobjectArray args) const
+jobject JavaJSObject::call(jstring methodName, jobjectArray args) const
{
JS_LOG ("methodName = %s\n", JavaString(methodName).UTF8String());
JSLock lock;
Identifier identifier(JavaString(methodName).ustring());
- ValueImp *func = _imp->get (exec, identifier);
+ JSValue *func = _imp->get (exec, identifier);
if (func->isUndefinedOrNull()) {
// Maybe throw an exception here?
return 0;
}
// Call the function object.
- ObjectImp *funcImp = static_cast<ObjectImp*>(func);
- ObjectImp *thisObj = const_cast<ObjectImp*>(_imp);
+ JSObject *funcImp = static_cast<JSObject*>(func);
+ JSObject *thisObj = const_cast<JSObject*>(_imp);
List argList = listFromJArray(args);
- ValueImp *result = funcImp->call(exec, thisObj, argList);
+ JSValue *result = funcImp->call(exec, thisObj, argList);
return convertValueToJObject(result);
}
-jobject JSObject::eval(jstring script) const
+jobject JavaJSObject::eval(jstring script) const
{
JS_LOG ("script = %s\n", JavaString(script).UTF8String());
- ObjectImp *thisObj = const_cast<ObjectImp*>(_imp);
- ValueImp *result;
+ JSObject *thisObj = const_cast<JSObject*>(_imp);
+ JSValue *result;
JSLock lock;
return convertValueToJObject (result);
}
-jobject JSObject::getMember(jstring memberName) const
+jobject JavaJSObject::getMember(jstring memberName) const
{
JS_LOG ("(%p) memberName = %s\n", _imp, JavaString(memberName).UTF8String());
ExecState *exec = _root->interpreter()->globalExec();
JSLock lock;
- ValueImp *result = _imp->get (exec, Identifier (JavaString(memberName).ustring()));
+ JSValue *result = _imp->get (exec, Identifier (JavaString(memberName).ustring()));
return convertValueToJObject(result);
}
-void JSObject::setMember(jstring memberName, jobject value) const
+void JavaJSObject::setMember(jstring memberName, jobject value) const
{
JS_LOG ("memberName = %s, value = %p\n", JavaString(memberName).UTF8String(), value);
ExecState *exec = _root->interpreter()->globalExec();
}
-void JSObject::removeMember(jstring memberName) const
+void JavaJSObject::removeMember(jstring memberName) const
{
JS_LOG ("memberName = %s\n", JavaString(memberName).UTF8String());
}
-jobject JSObject::getSlot(jint index) const
+jobject JavaJSObject::getSlot(jint index) const
{
JS_LOG ("index = %ld\n", index);
ExecState *exec = _root->interpreter()->globalExec();
JSLock lock;
- ValueImp *result = _imp->get (exec, (unsigned)index);
+ JSValue *result = _imp->get (exec, (unsigned)index);
return convertValueToJObject(result);
}
-void JSObject::setSlot(jint index, jobject value) const
+void JavaJSObject::setSlot(jint index, jobject value) const
{
JS_LOG ("index = %ld, value = %p\n", index, value);
}
-jstring JSObject::toString() const
+jstring JavaJSObject::toString() const
{
JS_LOG ("\n");
JSLock lock;
- ObjectImp *thisObj = const_cast<ObjectImp*>(_imp);
+ JSObject *thisObj = const_cast<JSObject*>(_imp);
ExecState *exec = _root->interpreter()->globalExec();
return (jstring)convertValueToJValue (exec, thisObj, object_type, "java.lang.String").l;
}
-void JSObject::finalize() const
+void JavaJSObject::finalize() const
{
JS_LOG ("\n");
removeNativeReference (_imp);
}
-// We're either creating a 'Root' object (via a call to JSObject.getWindow()), or
-// another JSObject.
-jlong JSObject::createNative(jlong nativeHandle)
+// We're either creating a 'Root' object (via a call to JavaJSObject.getWindow()), or
+// another JavaJSObject.
+jlong JavaJSObject::createNative(jlong nativeHandle)
{
JS_LOG ("nativeHandle = %d\n", (int)nativeHandle);
FindRootObjectForNativeHandleFunctionPtr aFunc = RootObject::findRootObjectForNativeHandleFunction();
if (aFunc) {
Bindings::RootObject *root = aFunc(jlong_to_ptr(nativeHandle));
- // If root is !NULL We must have been called via netscape.javascript.JSObject.getWindow(),
- // otherwise we are being called after creating a JSObject in
- // JSObject::convertValueToJObject().
+ // If root is !NULL We must have been called via netscape.javascript.JavaJSObject.getWindow(),
+ // otherwise we are being called after creating a JavaJSObject in
+ // JavaJSObject::convertValueToJObject().
if (root) {
addNativeReference (root, root->rootObjectImp());
return ptr_to_jlong(root->rootObjectImp());
return ptr_to_jlong(0);
}
-jobject JSObject::convertValueToJObject (ValueImp *value) const
+jobject JavaJSObject::convertValueToJObject (JSValue *value) const
{
ExecState *exec = _root->interpreter()->globalExec();
JNIEnv *env = getJNIEnv();
// string -> java.lang.String
// boolean -> java.lang.Boolean
// Java instance -> Java instance
- // Everything else -> JSObject
+ // Everything else -> JavaJSObject
Type type = value->type();
if (type == NumberType) {
}
}
else {
- // Create a JSObject.
+ // Create a JavaJSObject.
jlong nativeHandle;
if (type == ObjectType){
- ObjectImp *imp = static_cast<ObjectImp*>(value);
+ JSObject *imp = static_cast<JSObject*>(value);
// We either have a wrapper around a Java instance or a JavaScript
// object. If we have a wrapper around a Java instance, return that
- // instance, otherwise create a new Java JSObject with the ObjectImp*
+ // instance, otherwise create a new Java JavaJSObject with the JSObject*
// as it's nativeHandle.
if (imp->classInfo() && strcmp(imp->classInfo()->className, "RuntimeObject") == 0) {
RuntimeObjectImp *runtimeImp = static_cast<RuntimeObjectImp*>(value);
nativeHandle = UndefinedHandle;
}
- // Now create the Java JSObject. Look for the JSObject in it's new (Tiger)
+ // Now create the Java JavaJSObject. Look for the JavaJSObject in it's new (Tiger)
// location and in the original Java 1.4.2 location.
jclass JSObjectClass;
- JSObjectClass = env->FindClass ("sun/plugin/javascript/webkit/JSObject");
+ JSObjectClass = env->FindClass ("sun/plugin/javascript/webkit/JavaJSObject");
if (!JSObjectClass) {
env->ExceptionDescribe();
env->ExceptionClear();
- JSObjectClass = env->FindClass ("apple/applet/JSObject");
+ JSObjectClass = env->FindClass ("apple/applet/JavaJSObject");
}
jmethodID constructorID = env->GetMethodID (JSObjectClass, "<init>", "(J)V");
return result;
}
-ValueImp *JSObject::convertJObjectToValue (jobject theObject) const
+JSValue *JavaJSObject::convertJObjectToValue (jobject theObject) const
{
- // Instances of netscape.javascript.JSObject get converted back to
+ // Instances of netscape.javascript.JavaJSObject get converted back to
// JavaScript objects. All other objects are wrapped. It's not
// possible to pass primitive types from the Java to JavaScript.
// See section 22.7 of 'JavaScript: The Definitive Guide, 4th Edition',
jobject classOfInstance = callJNIObjectMethod(theObject, "getClass", "()Ljava/lang/Class;");
jstring className = (jstring)callJNIObjectMethod(classOfInstance, "getName", "()Ljava/lang/String;");
- if (strcmp(Bindings::JavaString(className).UTF8String(), "netscape.javascript.JSObject") == 0) {
+ if (strcmp(Bindings::JavaString(className).UTF8String(), "netscape.javascript.JavaJSObject") == 0) {
// Pull the nativeJSObject value from the Java instance. This is a
- // pointer to the ObjectImp.
+ // pointer to the JSObject.
JNIEnv *env = getJNIEnv();
jfieldID fieldID = env->GetFieldID((jclass)classOfInstance, "nativeJSObject", "int");
if (fieldID == NULL) {
if (nativeHandle == UndefinedHandle) {
return jsUndefined();
}
- ObjectImp *imp = static_cast<ObjectImp*>(jlong_to_impptr(nativeHandle));
+ JSObject *imp = static_cast<JSObject*>(jlong_to_impptr(nativeHandle));
return imp;
}
return newImp;
}
-List JSObject::listFromJArray(jobjectArray jArray) const
+List JavaJSObject::listFromJArray(jobjectArray jArray) const
{
JNIEnv *env = getJNIEnv();
int i, numObjects = jArray ? env->GetArrayLength (jArray) : 0;
JSObjectCallContext context;
context.type = CreateNative;
context.nativeHandle = nativeHandle;
- return JSObject::invoke (&context).j;
+ return JavaJSObject::invoke (&context).j;
}
void KJS_JSObject_JSFinalize (JNIEnv *env, jclass jsClass, jlong nativeHandle)
JSObjectCallContext context;
context.type = Finalize;
context.nativeHandle = nativeHandle;
- JSObject::invoke (&context);
+ JavaJSObject::invoke (&context);
}
jobject KJS_JSObject_JSObjectCall (JNIEnv *env, jclass jsClass, jlong nativeHandle, jstring jurl, jstring methodName, jobjectArray args, jboolean ctx)
context.nativeHandle = nativeHandle;
context.string = methodName;
context.args = args;
- return JSObject::invoke (&context).l;
+ return JavaJSObject::invoke (&context).l;
}
jobject KJS_JSObject_JSObjectEval (JNIEnv *env, jclass jsClass, jlong nativeHandle, jstring jurl, jstring jscript, jboolean ctx)
context.type = Eval;
context.nativeHandle = nativeHandle;
context.string = jscript;
- return JSObject::invoke (&context).l;
+ return JavaJSObject::invoke (&context).l;
}
jobject KJS_JSObject_JSObjectGetMember (JNIEnv *env, jclass jsClass, jlong nativeHandle, jstring jurl, jstring jname, jboolean ctx)
context.type = GetMember;
context.nativeHandle = nativeHandle;
context.string = jname;
- return JSObject::invoke (&context).l;
+ return JavaJSObject::invoke (&context).l;
}
void KJS_JSObject_JSObjectSetMember (JNIEnv *env, jclass jsClass, jlong nativeHandle, jstring jurl, jstring jname, jobject value, jboolean ctx)
context.nativeHandle = nativeHandle;
context.string = jname;
context.value = value;
- JSObject::invoke (&context);
+ JavaJSObject::invoke (&context);
}
void KJS_JSObject_JSObjectRemoveMember (JNIEnv *env, jclass jsClass, jlong nativeHandle, jstring jurl, jstring jname, jboolean ctx)
context.type = RemoveMember;
context.nativeHandle = nativeHandle;
context.string = jname;
- JSObject::invoke (&context);
+ JavaJSObject::invoke (&context);
}
jobject KJS_JSObject_JSObjectGetSlot (JNIEnv *env, jclass jsClass, jlong nativeHandle, jstring jurl, jint jindex, jboolean ctx)
context.type = GetSlot;
context.nativeHandle = nativeHandle;
context.index = jindex;
- return JSObject::invoke (&context).l;
+ return JavaJSObject::invoke (&context).l;
}
void KJS_JSObject_JSObjectSetSlot (JNIEnv *env, jclass jsClass, jlong nativeHandle, jstring jurl, jint jindex, jobject value, jboolean ctx)
context.nativeHandle = nativeHandle;
context.index = jindex;
context.value = value;
- JSObject::invoke (&context);
+ JavaJSObject::invoke (&context);
}
jstring KJS_JSObject_JSObjectToString (JNIEnv *env, jclass clazz, jlong nativeHandle)
JSObjectCallContext context;
context.type = ToString;
context.nativeHandle = nativeHandle;
- return (jstring)JSObject::invoke (&context).l;
+ return (jstring)JavaJSObject::invoke (&context).l;
}
}
#include <JavaVM/jni.h>
#define jlong_to_ptr(a) ((void*)(uintptr_t)(a))
-#define jlong_to_impptr(a) (static_cast<KJS::ObjectImp*>(((void*)(uintptr_t)(a))))
+#define jlong_to_impptr(a) (static_cast<KJS::JSObject*>(((void*)(uintptr_t)(a))))
#define ptr_to_jlong(a) ((jlong)(uintptr_t)(a))
namespace KJS {
typedef struct JSObjectCallContext JSObjectCallContext;
-class JSObject
+class JavaJSObject
{
public:
- JSObject(jlong nativeHandle);
+ JavaJSObject(jlong nativeHandle);
static jlong createNative(jlong nativeHandle);
jobject call(jstring methodName, jobjectArray args) const;
static jvalue invoke (JSObjectCallContext *context);
- jobject convertValueToJObject (ValueImp *value) const;
- ValueImp *convertJObjectToValue (jobject theObject) const;
+ jobject convertValueToJObject (JSValue *value) const;
+ JSValue *convertJObjectToValue (jobject theObject) const;
List listFromJArray(jobjectArray jArray) const;
private:
const RootObject *_root;
- ObjectImp *_imp;
+ JSObject *_imp;
};
extern "C" {
-// Functions called from the Java VM when making calls to the JSObject class.
+// Functions called from the Java VM when making calls to the JavaJSObject class.
jlong KJS_JSCreateNativeJSObject (JNIEnv *env, jclass clazz, jstring jurl, jlong nativeHandle, jboolean ctx);
void KJS_JSObject_JSFinalize (JNIEnv *env, jclass jsClass, jlong nativeJSObject);
jobject KJS_JSObject_JSObjectCall (JNIEnv *env, jclass jsClass, jlong nativeJSObject, jstring jurl, jstring methodName, jobjectArray args, jboolean ctx);
- (NSURL *)_webViewURL;
@end
-bool KJS::Bindings::dispatchJNICall (const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, ValueImp *&exceptionDescription)
+bool KJS::Bindings::dispatchJNICall (const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, JSValue *&exceptionDescription)
{
id view = (id)targetAppletView;
_field = new JavaInstance(aField, 0);
}
-ValueImp *JavaArray::convertJObjectToArray (ExecState *exec, jobject anObject, const char *type, const RootObject *r)
+JSValue *JavaArray::convertJObjectToArray (ExecState *exec, jobject anObject, const char *type, const RootObject *r)
{
if (type[0] != '[')
return jsUndefined();
- return new RuntimeArrayImp(exec, new JavaArray((jobject)anObject, type, r));
+ return new RuntimeArray(exec, new JavaArray((jobject)anObject, type, r));
}
jvalue JavaField::dispatchValueFromInstance(ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const
{
const RootObject *execContext = instance->executionContext();
if (execContext && execContext->nativeHandle()) {
- ValueImp *exceptionDescription = NULL;
+ JSValue *exceptionDescription = NULL;
jvalue args[1];
args[0].l = jinstance;
return result;
}
-ValueImp *JavaField::valueFromInstance(ExecState *exec, const Instance *i) const
+JSValue *JavaField::valueFromInstance(ExecState *exec, const Instance *i) const
{
const JavaInstance *instance = static_cast<const JavaInstance *>(i);
- ValueImp *jsresult = jsUndefined();
+ JSValue *jsresult = jsUndefined();
switch (_JNIType) {
case object_type: {
{
const RootObject *execContext = instance->executionContext();
if (execContext && execContext->nativeHandle()) {
- ValueImp *exceptionDescription = NULL;
+ JSValue *exceptionDescription = NULL;
jvalue args[2];
jvalue result;
}
}
-void JavaField::setValueToInstance(ExecState *exec, const Instance *i, ValueImp *aValue) const
+void JavaField::setValueToInstance(ExecState *exec, const Instance *i, JSValue *aValue) const
{
const JavaInstance *instance = static_cast<const JavaInstance *>(i);
jvalue javaValue = convertValueToJValue (exec, aValue, _JNIType, type());
_type = strdup(other._type);
};
-void JavaArray::setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const
+void JavaArray::setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const
{
JNIEnv *env = getJNIEnv();
char *javaClassName = 0;
}
-ValueImp *JavaArray::valueAt(ExecState *exec, unsigned int index) const
+JSValue *JavaArray::valueAt(ExecState *exec, unsigned int index) const
{
JNIEnv *env = getJNIEnv();
JNIType arrayType = JNITypeFromPrimitiveType(_type[1]);
return *this;
}
- virtual ValueImp *valueFromInstance(ExecState *exec, const Instance *instance) const;
- virtual void setValueToInstance(ExecState *exec, const Instance *instance, ValueImp *aValue) const;
+ virtual JSValue *valueFromInstance(ExecState *exec, const Instance *instance) const;
+ virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const;
virtual const char *name() const { return _name.UTF8String(); }
virtual RuntimeType type() const { return _type.UTF8String(); }
return *this;
};
- virtual void setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const;
- virtual ValueImp *valueAt(ExecState *exec, unsigned int index) const;
+ virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const;
+ virtual JSValue *valueAt(ExecState *exec, unsigned int index) const;
virtual unsigned int getLength() const;
virtual ~JavaArray();
jobject javaArray() const { return _array->_instance; }
- static ValueImp *convertJObjectToArray (ExecState *exec, jobject anObject, const char *type, const RootObject *r);
+ static JSValue *convertJObjectToArray (ExecState *exec, jobject anObject, const char *type, const RootObject *r);
const RootObject *executionContext() const { return _root; }
return result;
}
-jvalue convertValueToJValue (ExecState *exec, ValueImp *value, JNIType _JNIType, const char *javaClassName)
+jvalue convertValueToJValue (ExecState *exec, JSValue *value, JNIType _JNIType, const char *javaClassName)
{
jvalue result;
// First see if we have a Java instance.
if (value->isObject()){
- ObjectImp *objectImp = static_cast<ObjectImp*>(value);
+ JSObject *objectImp = static_cast<JSObject*>(value);
if (objectImp->classInfo() == &RuntimeObjectImp::info) {
RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(value);
JavaInstance *instance = static_cast<JavaInstance*>(imp->getInternalInstance());
result.l = instance->javaInstance();
}
- else if (objectImp->classInfo() == &RuntimeArrayImp::info) {
- RuntimeArrayImp *imp = static_cast<RuntimeArrayImp *>(value);
+ else if (objectImp->classInfo() == &RuntimeArray::info) {
+ RuntimeArray *imp = static_cast<RuntimeArray *>(value);
JavaArray *array = static_cast<JavaArray*>(imp->getConcreteArray());
result.l = array->javaArray();
}
JNIType JNITypeFromPrimitiveType(char type);
const char *signatureFromPrimitiveType(JNIType type);
-jvalue convertValueToJValue(ExecState *exec, ValueImp *value, JNIType _JNIType, const char *javaClassName);
+jvalue convertValueToJValue(ExecState *exec, JSValue *value, JNIType _JNIType, const char *javaClassName);
jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature);
JavaVM *getJavaVM();
JNIEnv *getJNIEnv();
-bool dispatchJNICall(const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, ValueImp *&exceptionDescription);
+bool dispatchJNICall(const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, JSValue *&exceptionDescription);
} // namespace Bindings
ExecState *exec = [obj _executionContext]->interpreter()->globalExec();
KJSDidExecuteFunctionPtr func = Instance::didExecuteFunction();
if (func)
- func (exec, static_cast<ObjectImp*>([obj _executionContext]->rootObjectImp()));
+ func (exec, static_cast<JSObject*>([obj _executionContext]->rootObjectImp()));
}
-- (void)_initializeWithObjectImp:(ObjectImp *)imp originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const RootObject *)executionContext
+- (void)_initializeWithObjectImp:(JSObject *)imp originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const RootObject *)executionContext
{
_private->imp = imp;
_private->executionContext = executionContext;
addNativeReference (executionContext, imp);
}
-- _initWithObjectImp:(ObjectImp *)imp originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const RootObject *)executionContext
+- _initWithJSObject:(JSObject *)imp originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const RootObject *)executionContext
{
assert (imp != 0);
//assert (root != 0);
return self;
}
-- (ObjectImp *)_imp
+- (JSObject *)_imp
{
if (!_private->imp && _private->isCreatedByDOMWrapper) {
// Associate the WebScriptObject with the JS wrapper for the ObjC DOM
JSLock lock;
- ValueImp *v = convertObjcValueToValue(exec, &name, ObjcObjectType);
+ JSValue *v = convertObjcValueToValue(exec, &name, ObjcObjectType);
Identifier identifier(v->toString(exec));
- ValueImp *func = [self _imp]->get (exec, identifier);
+ JSValue *func = [self _imp]->get (exec, identifier);
if (!func || func->isUndefined()) {
// Maybe throw an exception here?
}
// Call the function object.
- ObjectImp *funcImp = static_cast<ObjectImp*>(func);
- ObjectImp *thisObj = const_cast<ObjectImp*>([self _imp]);
+ JSObject *funcImp = static_cast<JSObject*>(func);
+ JSObject *thisObj = const_cast<JSObject*>([self _imp]);
List argList = listFromNSArray(exec, args);
- ValueImp *result = funcImp->call (exec, thisObj, argList);
+ JSValue *result = funcImp->call (exec, thisObj, argList);
if (exec->hadException()) {
LOG_EXCEPTION (exec);
return nil;
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
- ValueImp *result;
+ JSValue *result;
JSLock lock;
- ValueImp *v = convertObjcValueToValue(exec, &script, ObjcObjectType);
+ JSValue *v = convertObjcValueToValue(exec, &script, ObjcObjectType);
Completion completion = [self _executionContext]->interpreter()->evaluate(UString(), 0, v->toString(exec));
ComplType type = completion.complType();
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
JSLock lock;
- ValueImp *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
+ JSValue *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
[self _imp]->put (exec, Identifier (v->toString(exec)), (convertObjcValueToValue(exec, &value, ObjcObjectType)));
if (exec->hadException()) {
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
JSLock lock;
- ValueImp *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
- ValueImp *result = [self _imp]->get (exec, Identifier (v->toString(exec)));
+ JSValue *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
+ JSValue *result = [self _imp]->get (exec, Identifier (v->toString(exec)));
if (exec->hadException()) {
LOG_EXCEPTION (exec);
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
JSLock lock;
- ValueImp *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
+ JSValue *v = convertObjcValueToValue(exec, &key, ObjcObjectType);
[self _imp]->deleteProperty (exec, Identifier (v->toString(exec)));
if (exec->hadException()) {
return @"Undefined";
JSLock lock;
- ObjectImp *thisObj = const_cast<ObjectImp*>([self _imp]);
+ JSObject *thisObj = const_cast<JSObject*>([self _imp]);
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
id result = convertValueToObjcValue(exec, thisObj, ObjcObjectType).objectValue;
ExecState *exec = [self _executionContext]->interpreter()->globalExec();
JSLock lock;
- ValueImp *result = [self _imp]->get (exec, (unsigned)index);
+ JSValue *result = [self _imp]->get (exec, (unsigned)index);
if (exec->hadException()) {
LOG_EXCEPTION (exec);
throwError(root->interpreter()->globalExec(), GeneralError, description);
}
-+ (id)_convertValueToObjcValue:(ValueImp *)value originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const RootObject *)executionContext
++ (id)_convertValueToObjcValue:(JSValue *)value originExecutionContext:(const RootObject *)originExecutionContext executionContext:(const RootObject *)executionContext
{
// First see if we have a ObjC instance.
if (value->isObject()) {
- ObjectImp *objectImp = static_cast<ObjectImp*>(value);
+ JSObject *objectImp = static_cast<JSObject*>(value);
Interpreter *intepreter = executionContext->interpreter();
ExecState *exec = intepreter->globalExec();
JSLock lock;
if (objectImp->classInfo() != &RuntimeObjectImp::info) {
- ValueImp *runtimeObject = objectImp->get(exec, "__apple_runtime_object");
+ JSValue *runtimeObject = objectImp->get(exec, "__apple_runtime_object");
if (runtimeObject && runtimeObject->isObject())
objectImp = static_cast<RuntimeObjectImp*>(runtimeObject);
}
#include <JavaScriptCore/value.h>
@interface WebScriptObject (Private)
-+ (id)_convertValueToObjcValue:(KJS::ValueImp *)value originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext;
++ (id)_convertValueToObjcValue:(KJS::JSValue *)value originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext;
- _init;
-- _initWithObjectImp:(KJS::ObjectImp *)imp originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext ;
-- (void)_initializeWithObjectImp:(KJS::ObjectImp *)imp originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext ;
+- _initWithJSObject:(KJS::JSObject *)imp originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext ;
+- (void)_initializeWithObjectImp:(KJS::JSObject *)imp originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext ;
- (void)_initializeScriptDOMNodeImp;
-- (KJS::ObjectImp *)_imp;
+- (KJS::JSObject *)_imp;
- (void)_setExecutionContext:(const KJS::Bindings::RootObject *)context;
- (const KJS::Bindings::RootObject *)_executionContext;
- (void)_setOriginExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext;
@interface WebScriptObjectPrivate : NSObject
{
@public
- KJS::ObjectImp *imp;
+ KJS::JSObject *imp;
const KJS::Bindings::RootObject *executionContext;
const KJS::Bindings::RootObject *originExecutionContext;
BOOL isCreatedByDOMWrapper;
virtual MethodList methodsNamed(const char *name, Instance *instance) const;
virtual Field *fieldNamed(const char *name, Instance *instance) const;
- virtual ValueImp *fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
+ virtual JSValue *fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
virtual Constructor *constructorAt(int i) const { return 0; }
virtual int numConstructors() const { return 0; }
return aField;
}
-ValueImp *ObjcClass::fallbackObject (ExecState *exec, Instance *instance, const Identifier &propertyName)
+JSValue *ObjcClass::fallbackObject (ExecState *exec, Instance *instance, const Identifier &propertyName)
{
ObjcInstance * objcInstance = static_cast<ObjcInstance*>(instance);
id targetObject = objcInstance->getObject();
virtual void begin();
virtual void end();
- virtual ValueImp *valueOf() const;
- virtual ValueImp *defaultValue (Type hint) const;
+ virtual JSValue *valueOf() const;
+ virtual JSValue *defaultValue (Type hint) const;
- virtual ValueImp *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
- virtual ValueImp *invokeDefaultMethod (ExecState *exec, const List &args);
+ virtual JSValue *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
+ virtual JSValue *invokeDefaultMethod (ExecState *exec, const List &args);
- virtual void setValueOfField (ExecState *exec, const Field *aField, ValueImp *aValue) const;
+ virtual void setValueOfField (ExecState *exec, const Field *aField, JSValue *aValue) const;
virtual bool supportsSetValueOfUndefinedField ();
- virtual void setValueOfUndefinedField (ExecState *exec, const Identifier &property, ValueImp *aValue);
+ virtual void setValueOfUndefinedField (ExecState *exec, const Identifier &property, JSValue *aValue);
- virtual ValueImp *ObjcInstance::getValueOfField (ExecState *exec, const Field *aField) const;
- virtual ValueImp *getValueOfUndefinedField (ExecState *exec, const Identifier &property, Type hint) const;
+ virtual JSValue *ObjcInstance::getValueOfField (ExecState *exec, const Field *aField) const;
+ virtual JSValue *getValueOfUndefinedField (ExecState *exec, const Identifier &property, Type hint) const;
ObjectStructPtr getObject() const { return _instance; }
- ValueImp *stringValue() const;
- ValueImp *numberValue() const;
- ValueImp *booleanValue() const;
+ JSValue *stringValue() const;
+ JSValue *numberValue() const;
+ JSValue *booleanValue() const;
private:
ObjectStructPtr _instance;
return static_cast<Bindings::Class*>(_class);
}
-ValueImp *ObjcInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
+JSValue *ObjcInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args)
{
- ValueImp *resultValue;
+ JSValue *resultValue;
// Overloading methods is not allowed in ObjectiveC. Should only be one
// name match for a particular method.
if (method->isFallbackMethod()) {
if (objcValueTypeForType([signature methodReturnType]) != ObjcObjectType) {
NSLog(@"Incorrect signature for invokeUndefinedMethodFromWebScript:withArguments: -- return type must be object.");
- NS_VALUERETURN(jsUndefined(), ValueImp *);
+ NS_VALUERETURN(jsUndefined(), JSValue *);
}
// Invoke invokeUndefinedMethodFromWebScript:withArguments:, pass JavaScript function
return resultValue;
}
-ValueImp *ObjcInstance::invokeDefaultMethod (ExecState *exec, const List &args)
+JSValue *ObjcInstance::invokeDefaultMethod (ExecState *exec, const List &args)
{
- ValueImp *resultValue;
+ JSValue *resultValue;
NS_DURING
if (![_instance respondsToSelector:@selector(invokeDefaultMethodWithArguments:)])
- NS_VALUERETURN(jsUndefined(), ValueImp *);
+ NS_VALUERETURN(jsUndefined(), JSValue *);
NSMethodSignature *signature = [_instance methodSignatureForSelector:@selector(invokeDefaultMethodWithArguments:)];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
if (objcValueTypeForType([signature methodReturnType]) != ObjcObjectType) {
NSLog(@"Incorrect signature for invokeDefaultMethodWithArguments: -- return type must be object.");
- NS_VALUERETURN(jsUndefined(), ValueImp *);
+ NS_VALUERETURN(jsUndefined(), JSValue *);
}
NSMutableArray *objcArgs = [NSMutableArray array];
return resultValue;
}
-void ObjcInstance::setValueOfField (ExecState *exec, const Field *aField, ValueImp *aValue) const
+void ObjcInstance::setValueOfField (ExecState *exec, const Field *aField, JSValue *aValue) const
{
aField->setValueToInstance (exec, this, aValue);
}
return false;
}
-void ObjcInstance::setValueOfUndefinedField (ExecState *exec, const Identifier &property, ValueImp *aValue)
+void ObjcInstance::setValueOfUndefinedField (ExecState *exec, const Identifier &property, JSValue *aValue)
{
id targetObject = getObject();
}
}
-ValueImp *ObjcInstance::getValueOfField (ExecState *exec, const Field *aField) const {
+JSValue *ObjcInstance::getValueOfField (ExecState *exec, const Field *aField) const {
return aField->valueFromInstance (exec, this);
}
-ValueImp *ObjcInstance::getValueOfUndefinedField (ExecState *exec, const Identifier &property, Type hint) const
+JSValue *ObjcInstance::getValueOfUndefinedField (ExecState *exec, const Identifier &property, Type hint) const
{
- ValueImp *volatile result = jsUndefined();
+ JSValue *volatile result = jsUndefined();
id targetObject = getObject();
return result;
}
-ValueImp *ObjcInstance::defaultValue (Type hint) const
+JSValue *ObjcInstance::defaultValue (Type hint) const
{
if (hint == StringType) {
return stringValue();
return valueOf();
}
-ValueImp *ObjcInstance::stringValue() const
+JSValue *ObjcInstance::stringValue() const
{
return convertNSStringToString ([getObject() description]);
}
-ValueImp *ObjcInstance::numberValue() const
+JSValue *ObjcInstance::numberValue() const
{
// FIXME: Implement something sensible
return jsNumber(0);
}
-ValueImp *ObjcInstance::booleanValue() const
+JSValue *ObjcInstance::booleanValue() const
{
// FIXME: Implement something sensible
return jsBoolean(false);
}
-ValueImp *ObjcInstance::valueOf() const
+JSValue *ObjcInstance::valueOf() const
{
return stringValue();
}
return *this;
}
- virtual ValueImp *valueFromInstance(ExecState *exec, const Instance *instance) const;
- virtual void setValueToInstance(ExecState *exec, const Instance *instance, ValueImp *aValue) const;
+ virtual JSValue *valueFromInstance(ExecState *exec, const Instance *instance) const;
+ virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const;
virtual const char *name() const;
virtual RuntimeType type() const;
virtual ~ObjcArray();
- virtual void setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const;
- virtual ValueImp *valueAt(ExecState *exec, unsigned int index) const;
+ virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const;
+ virtual JSValue *valueAt(ExecState *exec, unsigned int index) const;
virtual unsigned int getLength() const;
ObjectStructPtr getObjcArray() const { return _array; }
- static ValueImp *convertObjcArrayToArray(ExecState *exec, ObjectStructPtr anObject);
+ static JSValue *convertObjcArrayToArray(ExecState *exec, ObjectStructPtr anObject);
private:
ObjectStructPtr _array;
};
-class ObjcFallbackObjectImp : public ObjectImp {
+class ObjcFallbackObjectImp : public JSObject {
public:
- ObjcFallbackObjectImp(ObjectImp *proto);
+ ObjcFallbackObjectImp(JSObject *proto);
ObjcFallbackObjectImp(ObjcInstance *i, const Identifier propertyName);
const ClassInfo *classInfo() const { return &info; }
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
- virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
- virtual ValueImp *defaultValue(ExecState *exec, Type hint) const;
+ virtual JSValue *defaultValue(ExecState *exec, Type hint) const;
virtual Type type() const;
virtual bool toBoolean(ExecState *exec) const;
return "";
}
-ValueImp *ObjcField::valueFromInstance(ExecState *exec, const Instance *instance) const
+JSValue *ObjcField::valueFromInstance(ExecState *exec, const Instance *instance) const
{
- ValueImp *aValue;
+ JSValue *aValue;
id targetObject = (static_cast<const ObjcInstance*>(instance))->getObject();
id objcValue = nil;
return aValue;
}
-static id convertValueToObjcObject (ExecState *exec, ValueImp *value)
+static id convertValueToObjcObject (ExecState *exec, JSValue *value)
{
const Bindings::RootObject *root = rootForInterpreter(exec->interpreter());
if (!root) {
}
-void ObjcField::setValueToInstance(ExecState *exec, const Instance *instance, ValueImp *aValue) const
+void ObjcField::setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const
{
id targetObject = (static_cast<const ObjcInstance*>(instance))->getObject();
id value = convertValueToObjcObject(exec, aValue);
return *this;
}
-void ObjcArray::setValueAt(ExecState *exec, unsigned int index, ValueImp *aValue) const
+void ObjcArray::setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const
{
if (![_array respondsToSelector:@selector(insertObject:atIndex:)]) {
throwError(exec, TypeError, "Array is not mutable.");
}
-ValueImp *ObjcArray::valueAt(ExecState *exec, unsigned int index) const
+JSValue *ObjcArray::valueAt(ExecState *exec, unsigned int index) const
{
if (index > [_array count])
return throwError(exec, RangeError, "Index exceeds array size.");
ObjectStructPtr obj = 0;
- ObjectImp * volatile error;
+ JSObject * volatile error;
volatile bool haveError = false;
NS_DURING
const ClassInfo ObjcFallbackObjectImp::info = {"ObjcFallbackObject", 0, 0, 0};
-ObjcFallbackObjectImp::ObjcFallbackObjectImp(ObjectImp *proto)
- : ObjectImp(proto)
+ObjcFallbackObjectImp::ObjcFallbackObjectImp(JSObject *proto)
+ : JSObject(proto)
{
_instance = 0;
}
}
void ObjcFallbackObjectImp::put(ExecState *exec, const Identifier &propertyName,
- ValueImp *value, int attr)
+ JSValue *value, int attr)
{
}
return false;
}
-ValueImp *ObjcFallbackObjectImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
+JSValue *ObjcFallbackObjectImp::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
- ValueImp *result = jsUndefined();
+ JSValue *result = jsUndefined();
RuntimeObjectImp *imp = static_cast<RuntimeObjectImp*>(thisObj);
if (imp) {
return false;
}
-ValueImp *ObjcFallbackObjectImp::defaultValue(ExecState *exec, Type hint) const
+JSValue *ObjcFallbackObjectImp::defaultValue(ExecState *exec, Type hint) const
{
return _instance->getValueOfUndefinedField(exec, _item, hint);
}
class RootObject;
-ObjcValue convertValueToObjcValue(ExecState *exec, ValueImp *value, ObjcValueType type);
-ValueImp *convertNSStringToString(NSString *nsstring);
-ValueImp *convertObjcValueToValue(ExecState *exec, void *buffer, ObjcValueType type);
+ObjcValue convertValueToObjcValue(ExecState *exec, JSValue *value, ObjcValueType type);
+JSValue *convertNSStringToString(NSString *nsstring);
+JSValue *convertObjcValueToValue(ExecState *exec, void *buffer, ObjcValueType type);
ObjcValueType objcValueTypeForType(const char *type);
void JSMethodNameToObjCMethodName(const char *name, char *name, unsigned int length);
-void *createObjcInstanceForValue(ValueImp *value, const RootObject *origin, const RootObject *current);
+void *createObjcInstanceForValue(JSValue *value, const RootObject *origin, const RootObject *current);
-ObjectImp *throwError(ExecState *, ErrorType, NSString *message);
+JSObject *throwError(ExecState *, ErrorType, NSString *message);
} // namespace Bindings
} // namespace KJS
[], other exception
*/
-ObjcValue convertValueToObjcValue (ExecState *exec, ValueImp *value, ObjcValueType type)
+ObjcValue convertValueToObjcValue (ExecState *exec, JSValue *value, ObjcValueType type)
{
ObjcValue result;
double d = 0;
return result;
}
-ValueImp *convertNSStringToString(NSString *nsstring)
+JSValue *convertNSStringToString(NSString *nsstring)
{
unichar *chars;
unsigned int length = [nsstring length];
chars = (unichar *)malloc(sizeof(unichar)*length);
[nsstring getCharacters:chars];
UString u((const UChar*)chars, length);
- ValueImp *aValue = jsString(u);
+ JSValue *aValue = jsString(u);
free((void *)chars);
return aValue;
}
other should not happen
*/
-ValueImp *convertObjcValueToValue (ExecState *exec, void *buffer, ObjcValueType type)
+JSValue *convertObjcValueToValue (ExecState *exec, void *buffer, ObjcValueType type)
{
- ValueImp *aValue = NULL;
+ JSValue *aValue = NULL;
switch (type) {
case ObjcObjectType:
} else if ([*obj isKindOfClass:[NSNumber class]]) {
aValue = jsNumber([*obj doubleValue]);
} else if ([*obj isKindOfClass:[NSArray class]]) {
- aValue = new RuntimeArrayImp(exec, new ObjcArray(*obj));
+ aValue = new RuntimeArray(exec, new ObjcArray(*obj));
} else if ([*obj isKindOfClass:[WebScriptObject class]]) {
WebScriptObject *jsobject = (WebScriptObject *)*obj;
aValue = [jsobject _imp];
}
-void *createObjcInstanceForValue(ValueImp *value, const RootObject *origin, const RootObject *current)
+void *createObjcInstanceForValue(JSValue *value, const RootObject *origin, const RootObject *current)
{
if (!value->isObject())
return 0;
- ObjectImp *object = static_cast<ObjectImp *>(value);
- return [[[WebScriptObject alloc] _initWithObjectImp:object originExecutionContext:origin executionContext:current] autorelease];
+ JSObject *object = static_cast<JSObject *>(value);
+ return [[[WebScriptObject alloc] _initWithJSObject:object originExecutionContext:origin executionContext:current] autorelease];
}
-ObjectImp *throwError(ExecState *exec, ErrorType type, NSString *message)
+JSObject *throwError(ExecState *exec, ErrorType type, NSString *message)
{
assert(message);
size_t length = [message length];
unichar *buffer = new unichar[length];
[message getCharacters:buffer];
- ObjectImp *error = throwError(exec, type, UString(reinterpret_cast<UChar *>(buffer), length));
+ JSObject *error = throwError(exec, type, UString(reinterpret_cast<UChar *>(buffer), length));
delete [] buffer;
return error;
}
void Instance::setDidExecuteFunction (KJSDidExecuteFunctionPtr func) { _DidExecuteFunction = func; }
KJSDidExecuteFunctionPtr Instance::didExecuteFunction () { return _DidExecuteFunction; }
-ValueImp *Instance::getValueOfField (KJS::ExecState *exec, const Field *aField) const {
+JSValue *Instance::getValueOfField (KJS::ExecState *exec, const Field *aField) const {
return aField->valueFromInstance (exec, this);
}
-void Instance::setValueOfField (KJS::ExecState *exec, const Field *aField, ValueImp *aValue) const {
+void Instance::setValueOfField (KJS::ExecState *exec, const Field *aField, JSValue *aValue) const {
aField->setValueToInstance (exec, this, aValue);
}
return newInstance;
}
-ObjectImp *Instance::createRuntimeObject (BindingLanguage language, void *nativeInstance, const RootObject *executionContext)
+JSObject *Instance::createRuntimeObject (BindingLanguage language, void *nativeInstance, const RootObject *executionContext)
{
Instance *interfaceObject = Instance::createBindingForLanguageInstance(language, (void *)nativeInstance, executionContext);
return new RuntimeObjectImp(interfaceObject,true);
}
-void *Instance::createLanguageInstanceForValue (ExecState *exec, BindingLanguage language, ObjectImp *value, const RootObject *origin, const RootObject *current)
+void *Instance::createLanguageInstanceForValue (ExecState *exec, BindingLanguage language, JSObject *value, const RootObject *origin, const RootObject *current)
{
void *result = 0;
if (!value->isObject())
return 0;
- ObjectImp *imp = static_cast<ObjectImp*>(value);
+ JSObject *imp = static_cast<JSObject*>(value);
switch (language) {
case Instance::ObjectiveCLanguage: {
virtual const char *name() const = 0;
virtual RuntimeType type() const = 0;
- virtual ValueImp *valueFromInstance(ExecState *, const Instance *) const = 0;
- virtual void setValueToInstance(ExecState *, const Instance *, ValueImp *) const = 0;
+ virtual JSValue *valueFromInstance(ExecState *, const Instance *) const = 0;
+ virtual void setValueToInstance(ExecState *, const Instance *, JSValue *) const = 0;
virtual ~Field() {}
};
virtual Field *fieldNamed(const char *name, Instance *instance) const = 0;
- virtual ValueImp *fallbackObject(ExecState *, Instance *, const Identifier &) { return jsUndefined(); }
+ virtual JSValue *fallbackObject(ExecState *, Instance *, const Identifier &) { return jsUndefined(); }
virtual ~Class() {}
};
-typedef void (*KJSDidExecuteFunctionPtr)(ExecState *exec, ObjectImp *rootObject);
+typedef void (*KJSDidExecuteFunctionPtr)(ExecState *exec, JSObject *rootObject);
class Instance
{
static KJSDidExecuteFunctionPtr didExecuteFunction();
static Instance *createBindingForLanguageInstance(BindingLanguage language, void *nativeInstance, const RootObject *r = 0);
- static void *createLanguageInstanceForValue(ExecState *exec, BindingLanguage language, ObjectImp *value, const RootObject *origin, const RootObject *current);
- static ObjectImp *createRuntimeObject(BindingLanguage language, void *nativeInstance, const RootObject *r = 0);
+ static void *createLanguageInstanceForValue(ExecState *exec, BindingLanguage language, JSObject *value, const RootObject *origin, const RootObject *current);
+ static JSObject *createRuntimeObject(BindingLanguage language, void *nativeInstance, const RootObject *r = 0);
Instance() : _executionContext(0) {}
virtual Class *getClass() const = 0;
- virtual ValueImp *getValueOfField(ExecState *exec, const Field *aField) const;
- virtual ValueImp *getValueOfUndefinedField(ExecState *exec, const Identifier &property, Type hint) const { return jsUndefined(); }
- virtual void setValueOfField(ExecState *exec, const Field *aField, ValueImp *aValue) const;
+ virtual JSValue *getValueOfField(ExecState *exec, const Field *aField) const;
+ virtual JSValue *getValueOfUndefinedField(ExecState *exec, const Identifier &property, Type hint) const { return jsUndefined(); }
+ virtual void setValueOfField(ExecState *exec, const Field *aField, JSValue *aValue) const;
virtual bool supportsSetValueOfUndefinedField() { return false; }
- virtual void setValueOfUndefinedField(ExecState *exec, const Identifier &property, ValueImp *aValue) {}
+ virtual void setValueOfUndefinedField(ExecState *exec, const Identifier &property, JSValue *aValue) {}
- virtual ValueImp *invokeMethod(ExecState *exec, const MethodList &method, const List &args) = 0;
- virtual ValueImp *invokeDefaultMethod(ExecState *exec, const List &args) = 0;
+ virtual JSValue *invokeMethod(ExecState *exec, const MethodList &method, const List &args) = 0;
+ virtual JSValue *invokeDefaultMethod(ExecState *exec, const List &args) = 0;
- virtual ValueImp *defaultValue(Type hint) const = 0;
+ virtual JSValue *defaultValue(Type hint) const = 0;
- virtual ValueImp *valueOf() const { return jsString(getClass()->name()); }
+ virtual JSValue *valueOf() const { return jsString(getClass()->name()); }
void setExecutionContext(const RootObject *r) { _executionContext = r; }
const RootObject *executionContext() const { return _executionContext; }
class Array
{
public:
- virtual void setValueAt(ExecState *, unsigned index, ValueImp *) const = 0;
- virtual ValueImp *valueAt(ExecState *, unsigned index) const = 0;
+ virtual void setValueAt(ExecState *, unsigned index, JSValue *) const = 0;
+ virtual JSValue *valueAt(ExecState *, unsigned index) const = 0;
virtual unsigned int getLength() const = 0;
virtual ~Array() {}
};
using namespace KJS;
-const ClassInfo RuntimeArrayImp::info = {"RuntimeArray", &ArrayInstanceImp::info, 0, 0};
+const ClassInfo RuntimeArray::info = {"RuntimeArray", &ArrayInstance::info, 0, 0};
-RuntimeArrayImp::RuntimeArrayImp(ExecState *exec, Bindings::Array *a)
- : ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype(), a->getLength())
+RuntimeArray::RuntimeArray(ExecState *exec, Bindings::Array *a)
+ : ArrayInstance(exec->lexicalInterpreter()->builtinArrayPrototype(), a->getLength())
{
// Always takes ownership of concrete array.
_array = a;
}
-RuntimeArrayImp::~RuntimeArrayImp()
+RuntimeArray::~RuntimeArray()
{
delete _array;
}
-ValueImp *RuntimeArrayImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *RuntimeArray::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
- RuntimeArrayImp *thisObj = static_cast<RuntimeArrayImp *>(slot.slotBase());
+ RuntimeArray *thisObj = static_cast<RuntimeArray *>(slot.slotBase());
return jsNumber(thisObj->getLength());
}
-ValueImp *RuntimeArrayImp::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *RuntimeArray::indexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
- RuntimeArrayImp *thisObj = static_cast<RuntimeArrayImp *>(slot.slotBase());
+ RuntimeArray *thisObj = static_cast<RuntimeArray *>(slot.slotBase());
return thisObj->getConcreteArray()->valueAt(exec, slot.index());
}
-bool RuntimeArrayImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+bool RuntimeArray::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
if (propertyName == lengthPropertyName) {
slot.setCustom(this, lengthGetter);
}
}
- return ArrayInstanceImp::getOwnPropertySlot(exec, propertyName, slot);
+ return ArrayInstance::getOwnPropertySlot(exec, propertyName, slot);
}
-bool RuntimeArrayImp::getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot& slot)
+bool RuntimeArray::getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot& slot)
{
if (index < getLength()) {
slot.setCustomIndex(this, index, indexGetter);
return true;
}
- return ArrayInstanceImp::getOwnPropertySlot(exec, index, slot);
+ return ArrayInstance::getOwnPropertySlot(exec, index, slot);
}
-void RuntimeArrayImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
+void RuntimeArray::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
{
if (propertyName == lengthPropertyName) {
throwError(exec, RangeError);
return;
}
- ObjectImp::put(exec, propertyName, value, attr);
+ JSObject::put(exec, propertyName, value, attr);
}
-void RuntimeArrayImp::put(ExecState *exec, unsigned index, ValueImp *value, int attr)
+void RuntimeArray::put(ExecState *exec, unsigned index, JSValue *value, int attr)
{
if (index >= getLength()) {
throwError(exec, RangeError);
getConcreteArray()->setValueAt(exec, index, value);
}
-bool RuntimeArrayImp::deleteProperty(ExecState *exec, const Identifier &propertyName)
+bool RuntimeArray::deleteProperty(ExecState *exec, const Identifier &propertyName)
{
return false;
}
-bool RuntimeArrayImp::deleteProperty(ExecState *exec, unsigned index)
+bool RuntimeArray::deleteProperty(ExecState *exec, unsigned index)
{
return false;
}
namespace KJS {
-class RuntimeArrayImp : public ArrayInstanceImp {
+class RuntimeArray : public ArrayInstance {
public:
- RuntimeArrayImp(ExecState *exec, Bindings::Array *i);
- ~RuntimeArrayImp();
+ RuntimeArray(ExecState *exec, Bindings::Array *i);
+ ~RuntimeArray();
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
- virtual void put(ExecState *exec, unsigned propertyName, ValueImp *value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
+ virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
static const ClassInfo info;
private:
- static ValueImp *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
- static ValueImp *indexGetter(ExecState *, const Identifier&, const PropertySlot&);
+ static JSValue *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
+ static JSValue *indexGetter(ExecState *, const Identifier&, const PropertySlot&);
Bindings::Array *_array;
};
using namespace KJS::Bindings;
using namespace KJS;
-RuntimeMethodImp::RuntimeMethodImp(ExecState *exec, const Identifier &ident, Bindings::MethodList &m) : FunctionImp (exec, ident)
+RuntimeMethod::RuntimeMethod(ExecState *exec, const Identifier &ident, Bindings::MethodList &m) : FunctionImp (exec, ident)
{
_methodList = m;
}
-RuntimeMethodImp::~RuntimeMethodImp()
+RuntimeMethod::~RuntimeMethod()
{
}
-ValueImp *RuntimeMethodImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *RuntimeMethod::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
- RuntimeMethodImp *thisObj = static_cast<RuntimeMethodImp *>(slot.slotBase());
+ RuntimeMethod *thisObj = static_cast<RuntimeMethod *>(slot.slotBase());
// Ick! There may be more than one method with this name. Arbitrarily
// just pick the first method. The fundamental problem here is that
return jsNumber(thisObj->_methodList.methodAt(0)->numParameters());
}
-bool RuntimeMethodImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
+bool RuntimeMethod::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
{
if (propertyName == lengthPropertyName) {
slot.setCustom(this, lengthGetter);
return FunctionImp::getOwnPropertySlot(exec, propertyName, slot);
}
-bool RuntimeMethodImp::implementsCall() const
+bool RuntimeMethod::implementsCall() const
{
return true;
}
-ValueImp *RuntimeMethodImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
+JSValue *RuntimeMethod::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
if (_methodList.length() > 0) {
RuntimeObjectImp *imp;
// If thisObj is the DOM object for a plugin, get the corresponding
// runtime object from the DOM object.
if (thisObj->classInfo() != &KJS::RuntimeObjectImp::info) {
- ValueImp *runtimeObject = thisObj->get(exec, "__apple_runtime_object");
+ JSValue *runtimeObject = thisObj->get(exec, "__apple_runtime_object");
imp = static_cast<RuntimeObjectImp*>(runtimeObject);
}
else {
instance->begin();
- ValueImp *aValue = instance->invokeMethod(exec, _methodList, args);
+ JSValue *aValue = instance->invokeMethod(exec, _methodList, args);
instance->end();
return jsUndefined();
}
-CodeType RuntimeMethodImp::codeType() const
+CodeType RuntimeMethod::codeType() const
{
return FunctionCode;
}
-Completion RuntimeMethodImp::execute(ExecState *exec)
+Completion RuntimeMethod::execute(ExecState *exec)
{
return Completion(Normal, jsUndefined());
}
namespace KJS {
-class RuntimeMethodImp : public FunctionImp
+class RuntimeMethod : public FunctionImp
{
public:
- RuntimeMethodImp(ExecState *exec, const Identifier &n, Bindings::MethodList &methodList);
+ RuntimeMethod(ExecState *exec, const Identifier &n, Bindings::MethodList &methodList);
- virtual ~RuntimeMethodImp();
+ virtual ~RuntimeMethod();
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
virtual CodeType codeType() const;
virtual Completion execute(ExecState *exec);
private:
- static ValueImp *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
+ static JSValue *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
Bindings::MethodList _methodList;
};
const ClassInfo RuntimeObjectImp::info = {"RuntimeObject", 0, 0, 0};
-RuntimeObjectImp::RuntimeObjectImp(ObjectImp *proto)
- : ObjectImp(proto)
+RuntimeObjectImp::RuntimeObjectImp(JSObject *proto)
+ : JSObject(proto)
{
instance = 0;
}
instance = i;
}
-ValueImp *RuntimeObjectImp::fallbackObjectGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *RuntimeObjectImp::fallbackObjectGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
RuntimeObjectImp *thisObj = static_cast<RuntimeObjectImp *>(slot.slotBase());
Bindings::Instance *instance = thisObj->instance;
instance->begin();
Class *aClass = instance->getClass();
- ValueImp *result = aClass->fallbackObject(exec, instance, propertyName);
+ JSValue *result = aClass->fallbackObject(exec, instance, propertyName);
instance->end();
return result;
}
-ValueImp *RuntimeObjectImp::fieldGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *RuntimeObjectImp::fieldGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
RuntimeObjectImp *thisObj = static_cast<RuntimeObjectImp *>(slot.slotBase());
Bindings::Instance *instance = thisObj->instance;
Class *aClass = instance->getClass();
Field *aField = aClass->fieldNamed(propertyName.ascii(), instance);
- ValueImp *result = instance->getValueOfField(exec, aField);
+ JSValue *result = instance->getValueOfField(exec, aField);
instance->end();
return result;
}
-ValueImp *RuntimeObjectImp::methodGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *RuntimeObjectImp::methodGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
RuntimeObjectImp *thisObj = static_cast<RuntimeObjectImp *>(slot.slotBase());
Bindings::Instance *instance = thisObj->instance;
Class *aClass = instance->getClass();
MethodList methodList = aClass->methodsNamed(propertyName.ascii(), instance);
- ValueImp *result = new RuntimeMethodImp(exec, propertyName, methodList);
+ JSValue *result = new RuntimeMethod(exec, propertyName, methodList);
instance->end();
}
void RuntimeObjectImp::put(ExecState *exec, const Identifier &propertyName,
- ValueImp *value, int attr)
+ JSValue *value, int attr)
{
instance->begin();
return false;
}
-ValueImp *RuntimeObjectImp::defaultValue(ExecState *exec, Type hint) const
+JSValue *RuntimeObjectImp::defaultValue(ExecState *exec, Type hint) const
{
- ValueImp *result;
+ JSValue *result;
instance->begin();
return true;
}
-ValueImp *RuntimeObjectImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
+JSValue *RuntimeObjectImp::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
instance->begin();
- ValueImp *aValue = getInternalInstance()->invokeDefaultMethod(exec, args);
+ JSValue *aValue = getInternalInstance()->invokeDefaultMethod(exec, args);
instance->end();
namespace KJS {
-class RuntimeObjectImp : public ObjectImp {
+class RuntimeObjectImp : public JSObject {
public:
- RuntimeObjectImp(ObjectImp *proto);
+ RuntimeObjectImp(JSObject *proto);
~RuntimeObjectImp();
RuntimeObjectImp(Bindings::Instance *i, bool ownsInstance = true);
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool canPut(ExecState *exec, const Identifier &propertyName) const;
- virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
- virtual ValueImp *defaultValue(ExecState *exec, Type hint) const;
+ virtual JSValue *defaultValue(ExecState *exec, Type hint) const;
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
void setInternalInstance(Bindings::Instance *i) { instance = i; }
Bindings::Instance *getInternalInstance() const { return instance; }
static const ClassInfo info;
private:
- static ValueImp *fallbackObjectGetter(ExecState *, const Identifier&, const PropertySlot&);
- static ValueImp *fieldGetter(ExecState *, const Identifier&, const PropertySlot&);
- static ValueImp *methodGetter(ExecState *, const Identifier&, const PropertySlot&);
+ static JSValue *fallbackObjectGetter(ExecState *, const Identifier&, const PropertySlot&);
+ static JSValue *fieldGetter(ExecState *, const Identifier&, const PropertySlot&);
+ static JSValue *methodGetter(ExecState *, const Identifier&, const PropertySlot&);
Bindings::Instance *instance;
bool ownsInstance;
// Java does NOT always call finalize (and thus KJS_JSObject_JSFinalize) when
// it collects an objects. This presents some difficulties. We must ensure
-// the a JSObject's corresponding JavaScript object doesn't get collected. We
+// the a JavaJSObject's corresponding JavaScript object doesn't get collected. We
// do this by incrementing the JavaScript's reference count the first time we
-// create a JSObject for it, and decrementing the JavaScript reference count when
-// the last JSObject that refers to it is finalized, or when the applet is
+// create a JavaJSObject for it, and decrementing the JavaScript reference count when
+// the last JavaJSObject that refers to it is finalized, or when the applet is
// shutdown.
//
// To do this we keep a dictionary that maps each applet instance
// dictionary.
// FIXME: This is a potential performance bottleneck with many applets. We could fix be adding a
// imp to root dictionary.
-CFMutableDictionaryRef KJS::Bindings::findReferenceDictionary(ObjectImp *imp)
+CFMutableDictionaryRef KJS::Bindings::findReferenceDictionary(JSObject *imp)
{
CFMutableDictionaryRef refsByRoot = getReferencesByRootDictionary ();
CFMutableDictionaryRef foundDictionary = 0;
// FIXME: This is a potential performance bottleneck with many applets. We could fix be adding a
// imp to root dictionary.
-const Bindings::RootObject *KJS::Bindings::rootForImp (ObjectImp *imp)
+const Bindings::RootObject *KJS::Bindings::rootForImp (JSObject *imp)
{
CFMutableDictionaryRef refsByRoot = getReferencesByRootDictionary ();
const Bindings::RootObject *rootObject = 0;
return result;
}
-void KJS::Bindings::addNativeReference (const Bindings::RootObject *root, ObjectImp *imp)
+void KJS::Bindings::addNativeReference (const Bindings::RootObject *root, JSObject *imp)
{
if (root) {
CFMutableDictionaryRef referencesDictionary = getReferencesDictionary (root);
}
}
-void KJS::Bindings::removeNativeReference (ObjectImp *imp)
+void KJS::Bindings::removeNativeReference (JSObject *imp)
{
if (!imp)
return;
JSObjectCallContext *callContext = (JSObjectCallContext *)sourceContext.info;
CFRunLoopRef originatingLoop = callContext->originatingLoop;
- JSObject::invoke (callContext);
+ JavaJSObject::invoke (callContext);
// Signal the originating thread that we're done.
CFRunLoopSourceSignal (completionSource);
CFDictionaryGetKeysAndValues (referencesDictionary, (const void **)allImps, NULL);
for(i = 0; i < count; i++) {
JSLock lock;
- ObjectImp *anImp = static_cast<ObjectImp*>(allImps[i]);
+ JSObject *anImp = static_cast<JSObject*>(allImps[i]);
gcUnprotect(anImp);
}
free ((void *)allImps);
typedef RootObject *(*FindRootObjectForNativeHandleFunctionPtr)(void *);
-extern CFMutableDictionaryRef findReferenceDictionary(ObjectImp *imp);
-extern const RootObject *rootForImp (ObjectImp *imp);
+extern CFMutableDictionaryRef findReferenceDictionary(JSObject *imp);
+extern const RootObject *rootForImp (JSObject *imp);
extern const RootObject *rootForInterpreter (Interpreter *interpreter);
-extern void addNativeReference (const RootObject *root, ObjectImp *imp);
-extern void removeNativeReference (ObjectImp *imp);
+extern void addNativeReference (const RootObject *root, JSObject *imp);
+extern void removeNativeReference (JSObject *imp);
class RootObject
{
-friend class JSObject;
+friend class JavaJSObject;
public:
RootObject (const void *nativeHandle) : _nativeHandle(nativeHandle), _imp(0), _interpreter(0) {}
~RootObject () {
gcUnprotect(_imp);
}
- void setRootObjectImp (ObjectImp *i) {
+ void setRootObjectImp (JSObject *i) {
JSLock lock;
_imp = i;
gcProtect(_imp);
}
- ObjectImp *rootObjectImp() const { return _imp; }
+ JSObject *rootObjectImp() const { return _imp; }
void setInterpreter (Interpreter *i);
Interpreter *interpreter() const { return _interpreter; }
private:
const void *_nativeHandle;
- ObjectImp *_imp;
+ JSObject *_imp;
Interpreter *_interpreter;
static FindRootObjectForNativeHandleFunctionPtr _findRootObjectForNativeHandleFunctionPtr;
namespace KJS {
- class ArrayInstanceImp : public ObjectImp {
+ class ArrayInstance : public JSObject {
public:
- ArrayInstanceImp(ObjectImp *proto, unsigned initialLength);
- ArrayInstanceImp(ObjectImp *proto, const List &initialValues);
- ~ArrayInstanceImp();
+ ArrayInstance(JSObject *proto, unsigned initialLength);
+ ArrayInstance(JSObject *proto, const List &initialValues);
+ ~ArrayInstance();
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
- virtual void put(ExecState *exec, unsigned propertyName, ValueImp *value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
+ virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
virtual ReferenceList propList(ExecState *exec, bool recursive);
unsigned getLength() const { return length; }
void sort(ExecState *exec);
- void sort(ExecState *exec, ObjectImp *compareFunction);
+ void sort(ExecState *exec, JSObject *compareFunction);
private:
- static ValueImp *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
+ static JSValue *lengthGetter(ExecState *, const Identifier&, const PropertySlot&);
void setLength(unsigned newLength, ExecState *exec);
unsigned length;
unsigned storageLength;
unsigned capacity;
- ValueImp **storage;
+ JSValue **storage;
};
} // namespace KJS
using namespace KJS;
-// ------------------------------ ArrayInstanceImp -----------------------------
+// ------------------------------ ArrayInstance -----------------------------
const unsigned sparseArrayCutoff = 10000;
-const ClassInfo ArrayInstanceImp::info = {"Array", 0, 0, 0};
+const ClassInfo ArrayInstance::info = {"Array", 0, 0, 0};
-ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, unsigned initialLength)
- : ObjectImp(proto)
+ArrayInstance::ArrayInstance(JSObject *proto, unsigned initialLength)
+ : JSObject(proto)
, length(initialLength)
, storageLength(initialLength < sparseArrayCutoff ? initialLength : 0)
, capacity(storageLength)
- , storage(capacity ? (ValueImp **)fastCalloc(capacity, sizeof(ValueImp *)) : 0)
+ , storage(capacity ? (JSValue **)fastCalloc(capacity, sizeof(JSValue *)) : 0)
{
}
-ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, const List &list)
- : ObjectImp(proto)
+ArrayInstance::ArrayInstance(JSObject *proto, const List &list)
+ : JSObject(proto)
, length(list.size())
, storageLength(length)
, capacity(storageLength)
- , storage(capacity ? (ValueImp **)fastMalloc(sizeof(ValueImp *) * capacity) : 0)
+ , storage(capacity ? (JSValue **)fastMalloc(sizeof(JSValue *) * capacity) : 0)
{
ListIterator it = list.begin();
unsigned l = length;
}
}
-ArrayInstanceImp::~ArrayInstanceImp()
+ArrayInstance::~ArrayInstance()
{
fastFree(storage);
}
-ValueImp *ArrayInstanceImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *ArrayInstance::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
- return jsNumber(static_cast<ArrayInstanceImp *>(slot.slotBase())->length);
+ return jsNumber(static_cast<ArrayInstance *>(slot.slotBase())->length);
}
-bool ArrayInstanceImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+bool ArrayInstance::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
if (propertyName == lengthPropertyName) {
slot.setCustom(this, lengthGetter);
if (index >= length)
return false;
if (index < storageLength) {
- ValueImp *v = storage[index];
+ JSValue *v = storage[index];
if (!v || v->isUndefined())
return false;
slot.setValueSlot(this, &storage[index]);
}
}
- return ObjectImp::getOwnPropertySlot(exec, propertyName, slot);
+ return JSObject::getOwnPropertySlot(exec, propertyName, slot);
}
-bool ArrayInstanceImp::getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot& slot)
+bool ArrayInstance::getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot& slot)
{
if (index >= length)
return false;
if (index < storageLength) {
- ValueImp *v = storage[index];
+ JSValue *v = storage[index];
if (!v || v->isUndefined())
return false;
slot.setValueSlot(this, &storage[index]);
return true;
}
- return ObjectImp::getOwnPropertySlot(exec, index, slot);
+ return JSObject::getOwnPropertySlot(exec, index, slot);
}
// Special implementation of [[Put]] - see ECMA 15.4.5.1
-void ArrayInstanceImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
+void ArrayInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
{
if (propertyName == lengthPropertyName) {
setLength(value->toUInt32(exec), exec);
return;
}
- ObjectImp::put(exec, propertyName, value, attr);
+ JSObject::put(exec, propertyName, value, attr);
}
-void ArrayInstanceImp::put(ExecState *exec, unsigned index, ValueImp *value, int attr)
+void ArrayInstance::put(ExecState *exec, unsigned index, JSValue *value, int attr)
{
if (index < sparseArrayCutoff && index >= storageLength) {
resizeStorage(index + 1);
}
assert(index >= sparseArrayCutoff);
- ObjectImp::put(exec, Identifier::from(index), value, attr);
+ JSObject::put(exec, Identifier::from(index), value, attr);
}
-bool ArrayInstanceImp::deleteProperty(ExecState *exec, const Identifier &propertyName)
+bool ArrayInstance::deleteProperty(ExecState *exec, const Identifier &propertyName)
{
if (propertyName == lengthPropertyName)
return false;
}
}
- return ObjectImp::deleteProperty(exec, propertyName);
+ return JSObject::deleteProperty(exec, propertyName);
}
-bool ArrayInstanceImp::deleteProperty(ExecState *exec, unsigned index)
+bool ArrayInstance::deleteProperty(ExecState *exec, unsigned index)
{
if (index >= length)
return true;
return true;
}
- return ObjectImp::deleteProperty(exec, Identifier::from(index));
+ return JSObject::deleteProperty(exec, Identifier::from(index));
}
-ReferenceList ArrayInstanceImp::propList(ExecState *exec, bool recursive)
+ReferenceList ArrayInstance::propList(ExecState *exec, bool recursive)
{
- ReferenceList properties = ObjectImp::propList(exec,recursive);
+ ReferenceList properties = JSObject::propList(exec,recursive);
// avoid fetching this every time through the loop
- ValueImp *undefined = jsUndefined();
+ JSValue *undefined = jsUndefined();
for (unsigned i = 0; i < storageLength; ++i) {
- ValueImp *imp = storage[i];
+ JSValue *imp = storage[i];
if (imp && imp != undefined) {
properties.append(Reference(this, i));
}
return properties;
}
-void ArrayInstanceImp::resizeStorage(unsigned newLength)
+void ArrayInstance::resizeStorage(unsigned newLength)
{
if (newLength < storageLength) {
- memset(storage + newLength, 0, sizeof(ValueImp *) * (storageLength - newLength));
+ memset(storage + newLength, 0, sizeof(JSValue *) * (storageLength - newLength));
}
if (newLength > capacity) {
unsigned newCapacity;
newCapacity = sparseArrayCutoff;
}
}
- storage = (ValueImp **)fastRealloc(storage, newCapacity * sizeof (ValueImp *));
- memset(storage + capacity, 0, sizeof(ValueImp *) * (newCapacity - capacity));
+ storage = (JSValue **)fastRealloc(storage, newCapacity * sizeof (JSValue *));
+ memset(storage + capacity, 0, sizeof(JSValue *) * (newCapacity - capacity));
capacity = newCapacity;
}
storageLength = newLength;
}
-void ArrayInstanceImp::setLength(unsigned newLength, ExecState *exec)
+void ArrayInstance::setLength(unsigned newLength, ExecState *exec)
{
if (newLength <= storageLength) {
resizeStorage(newLength);
length = newLength;
}
-void ArrayInstanceImp::mark()
+void ArrayInstance::mark()
{
- ObjectImp::mark();
+ JSObject::mark();
unsigned l = storageLength;
for (unsigned i = 0; i < l; ++i) {
- ValueImp *imp = storage[i];
+ JSValue *imp = storage[i];
if (imp && !imp->marked())
imp->mark();
}
static int compareByStringForQSort(const void *a, const void *b)
{
ExecState *exec = execForCompareByStringForQSort;
- ValueImp *va = *(ValueImp **)a;
- ValueImp *vb = *(ValueImp **)b;
+ JSValue *va = *(JSValue **)a;
+ JSValue *vb = *(JSValue **)b;
if (va->isUndefined()) {
return vb->isUndefined() ? 0 : 1;
}
return compare(va->toString(exec), vb->toString(exec));
}
-void ArrayInstanceImp::sort(ExecState *exec)
+void ArrayInstance::sort(ExecState *exec)
{
int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec);
execForCompareByStringForQSort = exec;
- qsort(storage, lengthNotIncludingUndefined, sizeof(ValueImp *), compareByStringForQSort);
+ qsort(storage, lengthNotIncludingUndefined, sizeof(JSValue *), compareByStringForQSort);
execForCompareByStringForQSort = 0;
}
struct CompareWithCompareFunctionArguments {
- CompareWithCompareFunctionArguments(ExecState *e, ObjectImp *cf)
+ CompareWithCompareFunctionArguments(ExecState *e, JSObject *cf)
: exec(e)
, compareFunction(cf)
, globalObject(e->dynamicInterpreter()->globalObject())
}
ExecState *exec;
- ObjectImp *compareFunction;
+ JSObject *compareFunction;
List arguments;
- ObjectImp *globalObject;
+ JSObject *globalObject;
};
static CompareWithCompareFunctionArguments *compareWithCompareFunctionArguments;
{
CompareWithCompareFunctionArguments *args = compareWithCompareFunctionArguments;
- ValueImp *va = *(ValueImp **)a;
- ValueImp *vb = *(ValueImp **)b;
+ JSValue *va = *(JSValue **)a;
+ JSValue *vb = *(JSValue **)b;
if (va->isUndefined()) {
return vb->isUndefined() ? 0 : 1;
}
return compareResult < 0 ? -1 : compareResult > 0 ? 1 : 0;
}
-void ArrayInstanceImp::sort(ExecState *exec, ObjectImp *compareFunction)
+void ArrayInstance::sort(ExecState *exec, JSObject *compareFunction)
{
int lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec);
CompareWithCompareFunctionArguments args(exec, compareFunction);
compareWithCompareFunctionArguments = &args;
- qsort(storage, lengthNotIncludingUndefined, sizeof(ValueImp *), compareWithCompareFunctionForQSort);
+ qsort(storage, lengthNotIncludingUndefined, sizeof(JSValue *), compareWithCompareFunctionForQSort);
compareWithCompareFunctionArguments = 0;
}
-unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd(ExecState *exec)
+unsigned ArrayInstance::pushUndefinedObjectsToEnd(ExecState *exec)
{
- ValueImp *undefined = jsUndefined();
+ JSValue *undefined = jsUndefined();
unsigned o = 0;
for (unsigned i = 0; i != storageLength; ++i) {
- ValueImp *v = storage[i];
+ JSValue *v = storage[i];
if (v && v != undefined) {
if (o != i)
storage[o] = v;
while (it != sparseProperties.end()) {
Reference ref = it++;
storage[o] = ref.getValue(exec);
- ObjectImp::deleteProperty(exec, ref.getPropertyName(exec));
+ JSObject::deleteProperty(exec, ref.getPropertyName(exec));
o++;
}
if (newLength != storageLength)
- memset(storage + o, 0, sizeof(ValueImp *) * (storageLength - o));
+ memset(storage + o, 0, sizeof(JSValue *) * (storageLength - o));
return o;
}
-// ------------------------------ ArrayPrototypeImp ----------------------------
+// ------------------------------ ArrayPrototype ----------------------------
-const ClassInfo ArrayPrototypeImp::info = {"Array", &ArrayInstanceImp::info, &arrayTable, 0};
+const ClassInfo ArrayPrototype::info = {"Array", &ArrayInstance::info, &arrayTable, 0};
/* Source for array_object.lut.h
@begin arrayTable 16
- toString ArrayProtoFuncImp::ToString DontEnum|Function 0
- toLocaleString ArrayProtoFuncImp::ToLocaleString DontEnum|Function 0
- concat ArrayProtoFuncImp::Concat DontEnum|Function 1
- join ArrayProtoFuncImp::Join DontEnum|Function 1
- pop ArrayProtoFuncImp::Pop DontEnum|Function 0
- push ArrayProtoFuncImp::Push DontEnum|Function 1
- reverse ArrayProtoFuncImp::Reverse DontEnum|Function 0
- shift ArrayProtoFuncImp::Shift DontEnum|Function 0
- slice ArrayProtoFuncImp::Slice DontEnum|Function 2
- sort ArrayProtoFuncImp::Sort DontEnum|Function 1
- splice ArrayProtoFuncImp::Splice DontEnum|Function 2
- unshift ArrayProtoFuncImp::UnShift DontEnum|Function 1
- every ArrayProtoFuncImp::Every DontEnum|Function 5
- forEach ArrayProtoFuncImp::ForEach DontEnum|Function 5
- some ArrayProtoFuncImp::Some DontEnum|Function 5
+ toString ArrayProtoFunc::ToString DontEnum|Function 0
+ toLocaleString ArrayProtoFunc::ToLocaleString DontEnum|Function 0
+ concat ArrayProtoFunc::Concat DontEnum|Function 1
+ join ArrayProtoFunc::Join DontEnum|Function 1
+ pop ArrayProtoFunc::Pop DontEnum|Function 0
+ push ArrayProtoFunc::Push DontEnum|Function 1
+ reverse ArrayProtoFunc::Reverse DontEnum|Function 0
+ shift ArrayProtoFunc::Shift DontEnum|Function 0
+ slice ArrayProtoFunc::Slice DontEnum|Function 2
+ sort ArrayProtoFunc::Sort DontEnum|Function 1
+ splice ArrayProtoFunc::Splice DontEnum|Function 2
+ unshift ArrayProtoFunc::UnShift DontEnum|Function 1
+ every ArrayProtoFunc::Every DontEnum|Function 5
+ forEach ArrayProtoFunc::ForEach DontEnum|Function 5
+ some ArrayProtoFunc::Some DontEnum|Function 5
@end
*/
// ECMA 15.4.4
-ArrayPrototypeImp::ArrayPrototypeImp(ExecState *exec,
- ObjectPrototypeImp *objProto)
- : ArrayInstanceImp(objProto, 0)
+ArrayPrototype::ArrayPrototype(ExecState *exec,
+ ObjectPrototype *objProto)
+ : ArrayInstance(objProto, 0)
{
setInternalValue(jsNull());
}
-bool ArrayPrototypeImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+bool ArrayPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
- return getStaticFunctionSlot<ArrayProtoFuncImp, ArrayInstanceImp>(exec, &arrayTable, this, propertyName, slot);
+ return getStaticFunctionSlot<ArrayProtoFunc, ArrayInstance>(exec, &arrayTable, this, propertyName, slot);
}
-// ------------------------------ ArrayProtoFuncImp ----------------------------
+// ------------------------------ ArrayProtoFunc ----------------------------
-ArrayProtoFuncImp::ArrayProtoFuncImp(ExecState *exec, int i, int len)
+ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len)
: InternalFunctionImp(
- static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
+ static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
), id(i)
{
put(exec,lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum);
}
-bool ArrayProtoFuncImp::implementsCall() const
+bool ArrayProtoFunc::implementsCall() const
{
return true;
}
-static ValueImp *getProperty(ExecState *exec, ObjectImp *obj, unsigned index)
+static JSValue *getProperty(ExecState *exec, JSObject *obj, unsigned index)
{
PropertySlot slot;
if (!obj->getPropertySlot(exec, index, slot))
}
// ECMA 15.4.4
-ValueImp *ArrayProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
+JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
unsigned length = thisObj->get(exec,lengthPropertyName)->toUInt32(exec);
- ValueImp *result = 0; // work around gcc 4.0 bug in uninitialized variable warning
+ JSValue *result = 0; // work around gcc 4.0 bug in uninitialized variable warning
switch (id) {
case ToLocaleString:
case ToString:
- if (!thisObj->inherits(&ArrayInstanceImp::info))
+ if (!thisObj->inherits(&ArrayInstance::info))
return throwError(exec, TypeError);
// fall through
case Join: {
- static HashSet< ObjectImp*, PointerHash<ObjectImp*> > visitedElems;
+ static HashSet< JSObject*, PointerHash<JSObject*> > visitedElems;
if (visitedElems.contains(thisObj))
return jsString("");
UString separator = ",";
if (k >= 1)
str += separator;
- ValueImp *element = thisObj->get(exec, k);
+ JSValue *element = thisObj->get(exec, k);
if (element->isUndefinedOrNull())
continue;
bool fallback = false;
if (id == ToLocaleString) {
- ObjectImp *o = element->toObject(exec);
- ValueImp *conversionFunction = o->get(exec, toLocaleStringPropertyName);
- if (conversionFunction->isObject() && static_cast<ObjectImp *>(conversionFunction)->implementsCall()) {
- str += static_cast<ObjectImp *>(conversionFunction)->call(exec, o, List())->toString(exec);
+ JSObject *o = element->toObject(exec);
+ JSValue *conversionFunction = o->get(exec, toLocaleStringPropertyName);
+ if (conversionFunction->isObject() && static_cast<JSObject *>(conversionFunction)->implementsCall()) {
+ str += static_cast<JSObject *>(conversionFunction)->call(exec, o, List())->toString(exec);
} else {
// try toString() fallback
fallback = true;
if (id == ToString || id == Join || fallback) {
if (element->isObject()) {
- ObjectImp *o = static_cast<ObjectImp *>(element);
- ValueImp *conversionFunction = o->get(exec, toStringPropertyName);
- if (conversionFunction->isObject() && static_cast<ObjectImp *>(conversionFunction)->implementsCall()) {
- str += static_cast<ObjectImp *>(conversionFunction)->call(exec, o, List())->toString(exec);
+ JSObject *o = static_cast<JSObject *>(element);
+ JSValue *conversionFunction = o->get(exec, toStringPropertyName);
+ if (conversionFunction->isObject() && static_cast<JSObject *>(conversionFunction)->implementsCall()) {
+ str += static_cast<JSObject *>(conversionFunction)->call(exec, o, List())->toString(exec);
} else {
return throwError(exec, RangeError, "Can't convert " + o->className() + " object to string");
}
break;
}
case Concat: {
- ObjectImp *arr = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
+ JSObject *arr = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
int n = 0;
- ValueImp *curArg = thisObj;
- ObjectImp *curObj = static_cast<ObjectImp *>(thisObj);
+ JSValue *curArg = thisObj;
+ JSObject *curObj = static_cast<JSObject *>(thisObj);
ListIterator it = args.begin();
for (;;) {
if (curArg->isObject() &&
- curObj->inherits(&ArrayInstanceImp::info)) {
+ curObj->inherits(&ArrayInstance::info)) {
unsigned int k = 0;
// Older versions tried to optimize out getting the length of thisObj
// by checking for n != 0, but that doesn't work if thisObj is an empty array.
length = curObj->get(exec,lengthPropertyName)->toUInt32(exec);
while (k < length) {
- if (ValueImp *v = getProperty(exec, curObj, k))
+ if (JSValue *v = getProperty(exec, curObj, k))
arr->put(exec, n, v);
n++;
k++;
if (it == args.end())
break;
curArg = *it;
- curObj = static_cast<ObjectImp *>(it++); // may be 0
+ curObj = static_cast<JSObject *>(it++); // may be 0
}
arr->put(exec,lengthPropertyName, jsNumber(n), DontEnum | DontDelete);
for (unsigned int k = 0; k < middle; k++) {
unsigned lk1 = length - k - 1;
- ValueImp *obj2 = getProperty(exec, thisObj, lk1);
- ValueImp *obj = getProperty(exec, thisObj, k);
+ JSValue *obj2 = getProperty(exec, thisObj, lk1);
+ JSValue *obj = getProperty(exec, thisObj, k);
if (obj2)
thisObj->put(exec, k, obj2);
} else {
result = thisObj->get(exec, 0);
for(unsigned int k = 1; k < length; k++) {
- if (ValueImp *obj = getProperty(exec, thisObj, k))
+ if (JSValue *obj = getProperty(exec, thisObj, k))
thisObj->put(exec, k-1, obj);
else
thisObj->deleteProperty(exec, k-1);
// http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10
// We return a new array
- ObjectImp *resObj = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
+ JSObject *resObj = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
result = resObj;
double begin = 0;
if (!args[0]->isUndefined()) {
int b = static_cast<int>(begin);
int e = static_cast<int>(end);
for(int k = b; k < e; k++, n++) {
- if (ValueImp *v = getProperty(exec, thisObj, k))
+ if (JSValue *v = getProperty(exec, thisObj, k))
resObj->put(exec, n, v);
}
resObj->put(exec, lengthPropertyName, jsNumber(n), DontEnum | DontDelete);
for ( unsigned int i = 0 ; i<length ; ++i )
printf("KJS Array::Sort: %d: %s\n", i, thisObj->get(exec, i)->toString(exec).ascii() );
#endif
- ObjectImp *sortFunction = NULL;
+ JSObject *sortFunction = NULL;
if (!args[0]->isUndefined())
{
sortFunction = args[0]->toObject(exec);
sortFunction = NULL;
}
- if (thisObj->classInfo() == &ArrayInstanceImp::info) {
+ if (thisObj->classInfo() == &ArrayInstance::info) {
if (sortFunction)
- ((ArrayInstanceImp *)thisObj)->sort(exec, sortFunction);
+ ((ArrayInstance *)thisObj)->sort(exec, sortFunction);
else
- ((ArrayInstanceImp *)thisObj)->sort(exec);
+ ((ArrayInstance *)thisObj)->sort(exec);
result = thisObj;
break;
}
// or quicksort, and much less swapping than bubblesort/insertionsort.
for ( unsigned int i = 0 ; i<length-1 ; ++i )
{
- ValueImp *iObj = thisObj->get(exec,i);
+ JSValue *iObj = thisObj->get(exec,i);
unsigned int themin = i;
- ValueImp *minObj = iObj;
+ JSValue *minObj = iObj;
for ( unsigned int j = i+1 ; j<length ; ++j )
{
- ValueImp *jObj = thisObj->get(exec,j);
+ JSValue *jObj = thisObj->get(exec,j);
double cmp;
if (jObj->isUndefined()) {
cmp = 1; // don't check minObj because there's no need to differentiate == (0) from > (1)
}
case Splice: {
// 15.4.4.12 - oh boy this is huge
- ObjectImp *resObj = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
+ JSObject *resObj = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()));
result = resObj;
int begin = args[0]->toUInt32(exec);
if ( begin < 0 )
//printf( "Splicing from %d, deleteCount=%d \n", begin, deleteCount );
for(unsigned int k = 0; k < deleteCount; k++) {
- if (ValueImp *v = getProperty(exec, thisObj, k+begin))
+ if (JSValue *v = getProperty(exec, thisObj, k+begin))
resObj->put(exec, k, v);
}
resObj->put(exec, lengthPropertyName, jsNumber(deleteCount), DontEnum | DontDelete);
{
for ( unsigned int k = begin; k < length - deleteCount; ++k )
{
- if (ValueImp *v = getProperty(exec, thisObj, k+deleteCount))
+ if (JSValue *v = getProperty(exec, thisObj, k+deleteCount))
thisObj->put(exec, k+additionalArgs, v);
else
thisObj->deleteProperty(exec, k+additionalArgs);
{
for ( unsigned int k = length - deleteCount; (int)k > begin; --k )
{
- if (ValueImp *obj = getProperty(exec, thisObj, k + deleteCount - 1))
+ if (JSValue *obj = getProperty(exec, thisObj, k + deleteCount - 1))
thisObj->put(exec, k + additionalArgs - 1, obj);
else
thisObj->deleteProperty(exec, k+additionalArgs-1);
unsigned int nrArgs = args.size();
for ( unsigned int k = length; k > 0; --k )
{
- if (ValueImp *v = getProperty(exec, thisObj, k - 1))
+ if (JSValue *v = getProperty(exec, thisObj, k - 1))
thisObj->put(exec, k+nrArgs-1, v);
else
thisObj->deleteProperty(exec, k+nrArgs-1);
//http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach
//http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some
- ObjectImp *eachFunction = args[0]->toObject(exec);
+ JSObject *eachFunction = args[0]->toObject(exec);
if (!eachFunction->implementsCall())
return throwError(exec, TypeError);
- ObjectImp *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicInterpreter()->globalObject() : args[1]->toObject(exec);
+ JSObject *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicInterpreter()->globalObject() : args[1]->toObject(exec);
if (id == Some || id == Every)
result = jsBoolean(id == Every);
// ------------------------------ ArrayObjectImp -------------------------------
ArrayObjectImp::ArrayObjectImp(ExecState *exec,
- FunctionPrototypeImp *funcProto,
- ArrayPrototypeImp *arrayProto)
+ FunctionPrototype *funcProto,
+ ArrayPrototype *arrayProto)
: InternalFunctionImp(funcProto)
{
// ECMA 15.4.3.1 Array.prototype
}
// ECMA 15.4.2
-ObjectImp *ArrayObjectImp::construct(ExecState *exec, const List &args)
+JSObject *ArrayObjectImp::construct(ExecState *exec, const List &args)
{
// a single numeric argument denotes the array size (!)
if (args.size() == 1 && args[0]->isNumber()) {
uint32_t n = args[0]->toUInt32(exec);
if (n != args[0]->toNumber(exec))
return throwError(exec, RangeError, "Array size is not a small enough positive integer.");
- return new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype(), n);
+ return new ArrayInstance(exec->lexicalInterpreter()->builtinArrayPrototype(), n);
}
// otherwise the array is constructed with the arguments in it
- return new ArrayInstanceImp(exec->lexicalInterpreter()->builtinArrayPrototype(), args);
+ return new ArrayInstance(exec->lexicalInterpreter()->builtinArrayPrototype(), args);
}
bool ArrayObjectImp::implementsCall() const
}
// ECMA 15.6.1
-ValueImp *ArrayObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
+JSValue *ArrayObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
{
// equivalent to 'new Array(....)'
return construct(exec,args);
namespace KJS {
- class ArrayPrototypeImp : public ArrayInstanceImp {
+ class ArrayPrototype : public ArrayInstance {
public:
- ArrayPrototypeImp(ExecState *exec,
- ObjectPrototypeImp *objProto);
+ ArrayPrototype(ExecState *exec,
+ ObjectPrototype *objProto);
bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
};
- class ArrayProtoFuncImp : public InternalFunctionImp {
+ class ArrayProtoFunc : public InternalFunctionImp {
public:
- ArrayProtoFuncImp(ExecState *exec, int i, int len);
+ ArrayProtoFunc(ExecState *exec, int i, int len);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
enum { ToString, ToLocaleString, Concat, Join, Pop, Push,
Reverse, Shift, Slice, Sort, Splice, UnShift,
class ArrayObjectImp : public InternalFunctionImp {
public:
ArrayObjectImp(ExecState *exec,
- FunctionPrototypeImp *funcProto,
- ArrayPrototypeImp *arrayProto);
+ FunctionPrototype *funcProto,
+ ArrayPrototype *arrayProto);
virtual bool implementsConstruct() const;
- virtual ObjectImp *construct(ExecState *exec, const List &args);
+ virtual JSObject *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
};
using namespace KJS;
-// ------------------------------ BooleanInstanceImp ---------------------------
+// ------------------------------ BooleanInstance ---------------------------
-const ClassInfo BooleanInstanceImp::info = {"Boolean", 0, 0, 0};
+const ClassInfo BooleanInstance::info = {"Boolean", 0, 0, 0};
-BooleanInstanceImp::BooleanInstanceImp(ObjectImp *proto)
- : ObjectImp(proto)
+BooleanInstance::BooleanInstance(JSObject *proto)
+ : JSObject(proto)
{
}
-// ------------------------------ BooleanPrototypeImp --------------------------
+// ------------------------------ BooleanPrototype --------------------------
// ECMA 15.6.4
-BooleanPrototypeImp::BooleanPrototypeImp(ExecState *exec,
- ObjectPrototypeImp *objectProto,
- FunctionPrototypeImp *funcProto)
- : BooleanInstanceImp(objectProto)
+BooleanPrototype::BooleanPrototype(ExecState *exec,
+ ObjectPrototype *objectProto,
+ FunctionPrototype *funcProto)
+ : BooleanInstance(objectProto)
{
// The constructor will be added later by InterpreterImp::InterpreterImp()
- putDirect(toStringPropertyName, new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0), DontEnum);
- putDirect(valueOfPropertyName, new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0), DontEnum);
+ putDirect(toStringPropertyName, new BooleanProtoFunc(exec,funcProto,BooleanProtoFunc::ToString,0), DontEnum);
+ putDirect(valueOfPropertyName, new BooleanProtoFunc(exec,funcProto,BooleanProtoFunc::ValueOf,0), DontEnum);
setInternalValue(jsBoolean(false));
}
-// ------------------------------ BooleanProtoFuncImp --------------------------
+// ------------------------------ BooleanProtoFunc --------------------------
-BooleanProtoFuncImp::BooleanProtoFuncImp(ExecState *exec,
- FunctionPrototypeImp *funcProto, int i, int len)
+BooleanProtoFunc::BooleanProtoFunc(ExecState *exec,
+ FunctionPrototype *funcProto, int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
-bool BooleanProtoFuncImp::implementsCall() const
+bool BooleanProtoFunc::implementsCall() const
{
return true;
}
// ECMA 15.6.4.2 + 15.6.4.3
-ValueImp *BooleanProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &/*args*/)
+JSValue *BooleanProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)
{
// no generic function. "this" has to be a Boolean object
- if (!thisObj->inherits(&BooleanInstanceImp::info))
+ if (!thisObj->inherits(&BooleanInstance::info))
return throwError(exec, TypeError);
// execute "toString()" or "valueOf()", respectively
- ValueImp *v = thisObj->internalValue();
+ JSValue *v = thisObj->internalValue();
assert(v);
if (id == ToString)
// ------------------------------ BooleanObjectImp -----------------------------
-BooleanObjectImp::BooleanObjectImp(ExecState *exec, FunctionPrototypeImp *funcProto,
- BooleanPrototypeImp *booleanProto)
+BooleanObjectImp::BooleanObjectImp(ExecState *exec, FunctionPrototype *funcProto,
+ BooleanPrototype *booleanProto)
: InternalFunctionImp(funcProto)
{
putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly);
}
// ECMA 15.6.2
-ObjectImp *BooleanObjectImp::construct(ExecState *exec, const List &args)
+JSObject *BooleanObjectImp::construct(ExecState *exec, const List &args)
{
- ObjectImp *obj(new BooleanInstanceImp(exec->lexicalInterpreter()->builtinBooleanPrototype()));
+ JSObject *obj(new BooleanInstance(exec->lexicalInterpreter()->builtinBooleanPrototype()));
bool b;
if (args.size() > 0)
}
// ECMA 15.6.1
-ValueImp *BooleanObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
+JSValue *BooleanObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
{
if (args.isEmpty())
return jsBoolean(false);
namespace KJS {
- class BooleanInstanceImp : public ObjectImp {
+ class BooleanInstance : public JSObject {
public:
- BooleanInstanceImp(ObjectImp *proto);
+ BooleanInstance(JSObject *proto);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
* The initial value of Boolean.prototype (and thus all objects created
* with the Boolean constructor
*/
- class BooleanPrototypeImp : public BooleanInstanceImp {
+ class BooleanPrototype : public BooleanInstance {
public:
- BooleanPrototypeImp(ExecState *exec,
- ObjectPrototypeImp *objectProto,
- FunctionPrototypeImp *funcProto);
+ BooleanPrototype(ExecState *exec,
+ ObjectPrototype *objectProto,
+ FunctionPrototype *funcProto);
};
/**
* Class to implement all methods that are properties of the
* Boolean.prototype object
*/
- class BooleanProtoFuncImp : public InternalFunctionImp {
+ class BooleanProtoFunc : public InternalFunctionImp {
public:
- BooleanProtoFuncImp(ExecState *exec,
- FunctionPrototypeImp *funcProto, int i, int len);
+ BooleanProtoFunc(ExecState *exec,
+ FunctionPrototype *funcProto, int i, int len);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
enum { ToString, ValueOf };
private:
* The initial value of the the global variable's "Boolean" property
*/
class BooleanObjectImp : public InternalFunctionImp {
- friend class BooleanProtoFuncImp;
+ friend class BooleanProtoFunc;
public:
- BooleanObjectImp(ExecState *exec, FunctionPrototypeImp *funcProto,
- BooleanPrototypeImp *booleanProto);
+ BooleanObjectImp(ExecState *exec, FunctionPrototype *funcProto,
+ BooleanPrototype *booleanProto);
virtual bool implementsConstruct() const;
- virtual ObjectImp *construct(ExecState *exec, const List &args);
+ virtual JSObject *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
};
} // namespace
gotGoodPointer:
if (((CollectorCell *)x)->u.freeCell.zeroIfFree != 0) {
- AllocatedValueImp *imp = reinterpret_cast<AllocatedValueImp *>(x);
+ JSCell *imp = reinterpret_cast<JSCell *>(x);
if (!imp->marked())
imp->mark();
}
Entry *table = ProtectedValues::_table;
Entry *end = table + ProtectedValues::_tableSize;
for (Entry *entry = table; entry != end; ++entry) {
- AllocatedValueImp *val = entry->key;
+ JSCell *val = entry->key;
if (val && !val->marked()) {
val->mark();
}
// special case with a block where all cells are used -- testing indicates this happens often
for (size_t i = 0; i < CELLS_PER_BLOCK; i++) {
CollectorCell *cell = curBlock->cells + i;
- AllocatedValueImp *imp = reinterpret_cast<AllocatedValueImp *>(cell);
+ JSCell *imp = reinterpret_cast<JSCell *>(cell);
if (imp->m_marked) {
imp->m_marked = false;
} else {
- imp->~AllocatedValueImp();
+ imp->~JSCell();
--usedCells;
--numLiveObjects;
if (cell->u.freeCell.zeroIfFree == 0) {
++minimumCellsToProcess;
} else {
- AllocatedValueImp *imp = reinterpret_cast<AllocatedValueImp *>(cell);
+ JSCell *imp = reinterpret_cast<JSCell *>(cell);
if (imp->m_marked) {
imp->m_marked = false;
} else {
- imp->~AllocatedValueImp();
+ imp->~JSCell();
--usedCells;
--numLiveObjects;
size_t cell = 0;
while (cell < heap.usedOversizeCells) {
- AllocatedValueImp *imp = (AllocatedValueImp *)heap.oversizeCells[cell];
+ JSCell *imp = (JSCell *)heap.oversizeCells[cell];
if (!imp->m_marked) {
- imp->~AllocatedValueImp();
+ imp->~JSCell();
#if DEBUG_COLLECTOR
heap.oversizeCells[cell]->u.freeCell.zeroIfFree = 0;
#else
size_t size = ProtectedValues::_tableSize;
ProtectedValues::KeyValue *table = ProtectedValues::_table;
for (size_t i = 0; i < size; i++) {
- AllocatedValueImp *val = table[i].key;
+ JSCell *val = table[i].key;
if (val) {
++count;
}
#if APPLE_CHANGES
-static const char *className(AllocatedValueImp *val)
+static const char *className(JSCell *val)
{
const char *name = "???";
switch (val->type()) {
name = "number";
break;
case ObjectType: {
- const ClassInfo *info = static_cast<ObjectImp *>(val)->classInfo();
+ const ClassInfo *info = static_cast<JSObject *>(val)->classInfo();
name = info ? info->className : "Object";
break;
}
int size = ProtectedValues::_tableSize;
ProtectedValues::KeyValue *table = ProtectedValues::_table;
for (int i = 0; i < size; i++) {
- AllocatedValueImp *val = table[i].key;
+ JSCell *val = table[i].key;
if (val) {
CFStringRef name = CFStringCreateWithCString(NULL, className(val), kCFStringEncodingASCII);
CFSetAddValue(classes, name);
*/
class Completion {
public:
- Completion(ComplType c = Normal, ValueImp *v = NULL, const Identifier &t = Identifier::null())
+ Completion(ComplType c = Normal, JSValue *v = NULL, const Identifier &t = Identifier::null())
: comp(c), val(v), tar(t) { }
ComplType complType() const { return comp; }
- ValueImp *value() const { return val; }
+ JSValue *value() const { return val; }
Identifier target() const { return tar; }
bool isValueCompletion() const { return val; }
private:
ComplType comp;
- ValueImp *val;
+ JSValue *val;
Identifier tar;
};
*/
class ContextImp {
public:
- ContextImp(ObjectImp *glob, InterpreterImp *, ObjectImp *thisV, CodeType type = GlobalCode,
+ ContextImp(JSObject *glob, InterpreterImp *, JSObject *thisV, CodeType type = GlobalCode,
ContextImp *callingContext = 0, FunctionImp *functiion = 0, const List *args = 0);
~ContextImp();
const ScopeChain &scopeChain() const { return scope; }
CodeType codeType() { return m_codeType; }
- ObjectImp *variableObject() const { return variable; }
- void setVariableObject(ObjectImp *v) { variable = v; }
- ObjectImp *thisValue() const { return thisVal; }
+ JSObject *variableObject() const { return variable; }
+ void setVariableObject(JSObject *v) { variable = v; }
+ JSObject *thisValue() const { return thisVal; }
ContextImp *callingContext() { return _callingContext; }
- ObjectImp *activationObject() { return activation; }
+ JSObject *activationObject() { return activation; }
FunctionImp *function() const { return _function; }
const List *arguments() const { return _arguments; }
- void pushScope(ObjectImp *s) { scope.push(s); }
+ void pushScope(JSObject *s) { scope.push(s); }
void popScope() { scope.pop(); }
LabelStack *seenLabels() { return &ls; }
// because ContextImp is always allocated on the stack,
// there is no need to protect various pointers from conservative
// GC since they will be caught by the conservative sweep anyway!
- ObjectImp *activation;
+ JSObject *activation;
ScopeChain scope;
- ObjectImp *variable;
- ObjectImp *thisVal;
+ JSObject *variable;
+ JSObject *thisVal;
LabelStack ls;
CodeType m_codeType;
* Class to implement all methods that are properties of the
* Date.prototype object
*/
-class DateProtoFuncImp : public InternalFunctionImp {
+class DateProtoFunc : public InternalFunctionImp {
public:
- DateProtoFuncImp(ExecState *, int i, int len);
+ DateProtoFunc(ExecState *, int i, int len);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args);
Completion execute(const List &);
enum { ToString, ToDateString, ToTimeString, ToLocaleString,
*/
class DateObjectFuncImp : public InternalFunctionImp {
public:
- DateObjectFuncImp(ExecState *, FunctionPrototypeImp *, int i, int len);
+ DateObjectFuncImp(ExecState *, FunctionPrototype *, int i, int len);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args);
enum { Parse, UTC };
}
}
-// ------------------------------ DateInstanceImp ------------------------------
+// ------------------------------ DateInstance ------------------------------
-const ClassInfo DateInstanceImp::info = {"Date", 0, 0, 0};
+const ClassInfo DateInstance::info = {"Date", 0, 0, 0};
-DateInstanceImp::DateInstanceImp(ObjectImp *proto)
- : ObjectImp(proto)
+DateInstance::DateInstance(JSObject *proto)
+ : JSObject(proto)
{
}
-// ------------------------------ DatePrototypeImp -----------------------------
+// ------------------------------ DatePrototype -----------------------------
-const ClassInfo DatePrototypeImp::info = {"Date", &DateInstanceImp::info, &dateTable, 0};
+const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, &dateTable, 0};
/* Source for date_object.lut.h
We use a negative ID to denote the "UTC" variant.
@begin dateTable 61
- toString DateProtoFuncImp::ToString DontEnum|Function 0
- toUTCString -DateProtoFuncImp::ToUTCString DontEnum|Function 0
- toDateString DateProtoFuncImp::ToDateString DontEnum|Function 0
- toTimeString DateProtoFuncImp::ToTimeString DontEnum|Function 0
- toLocaleString DateProtoFuncImp::ToLocaleString DontEnum|Function 0
- toLocaleDateString DateProtoFuncImp::ToLocaleDateString DontEnum|Function 0
- toLocaleTimeString DateProtoFuncImp::ToLocaleTimeString DontEnum|Function 0
- valueOf DateProtoFuncImp::ValueOf DontEnum|Function 0
- getTime DateProtoFuncImp::GetTime DontEnum|Function 0
- getFullYear DateProtoFuncImp::GetFullYear DontEnum|Function 0
- getUTCFullYear -DateProtoFuncImp::GetFullYear DontEnum|Function 0
- toGMTString -DateProtoFuncImp::ToGMTString DontEnum|Function 0
- getMonth DateProtoFuncImp::GetMonth DontEnum|Function 0
- getUTCMonth -DateProtoFuncImp::GetMonth DontEnum|Function 0
- getDate DateProtoFuncImp::GetDate DontEnum|Function 0
- getUTCDate -DateProtoFuncImp::GetDate DontEnum|Function 0
- getDay DateProtoFuncImp::GetDay DontEnum|Function 0
- getUTCDay -DateProtoFuncImp::GetDay DontEnum|Function 0
- getHours DateProtoFuncImp::GetHours DontEnum|Function 0
- getUTCHours -DateProtoFuncImp::GetHours DontEnum|Function 0
- getMinutes DateProtoFuncImp::GetMinutes DontEnum|Function 0
- getUTCMinutes -DateProtoFuncImp::GetMinutes DontEnum|Function 0
- getSeconds DateProtoFuncImp::GetSeconds DontEnum|Function 0
- getUTCSeconds -DateProtoFuncImp::GetSeconds DontEnum|Function 0
- getMilliseconds DateProtoFuncImp::GetMilliSeconds DontEnum|Function 0
- getUTCMilliseconds -DateProtoFuncImp::GetMilliSeconds DontEnum|Function 0
- getTimezoneOffset DateProtoFuncImp::GetTimezoneOffset DontEnum|Function 0
- setTime DateProtoFuncImp::SetTime DontEnum|Function 1
- setMilliseconds DateProtoFuncImp::SetMilliSeconds DontEnum|Function 1
- setUTCMilliseconds -DateProtoFuncImp::SetMilliSeconds DontEnum|Function 1
- setSeconds DateProtoFuncImp::SetSeconds DontEnum|Function 2
- setUTCSeconds -DateProtoFuncImp::SetSeconds DontEnum|Function 2
- setMinutes DateProtoFuncImp::SetMinutes DontEnum|Function 3
- setUTCMinutes -DateProtoFuncImp::SetMinutes DontEnum|Function 3
- setHours DateProtoFuncImp::SetHours DontEnum|Function 4
- setUTCHours -DateProtoFuncImp::SetHours DontEnum|Function 4
- setDate DateProtoFuncImp::SetDate DontEnum|Function 1
- setUTCDate -DateProtoFuncImp::SetDate DontEnum|Function 1
- setMonth DateProtoFuncImp::SetMonth DontEnum|Function 2
- setUTCMonth -DateProtoFuncImp::SetMonth DontEnum|Function 2
- setFullYear DateProtoFuncImp::SetFullYear DontEnum|Function 3
- setUTCFullYear -DateProtoFuncImp::SetFullYear DontEnum|Function 3
- setYear DateProtoFuncImp::SetYear DontEnum|Function 1
- getYear DateProtoFuncImp::GetYear DontEnum|Function 0
+ toString DateProtoFunc::ToString DontEnum|Function 0
+ toUTCString -DateProtoFunc::ToUTCString DontEnum|Function 0
+ toDateString DateProtoFunc::ToDateString DontEnum|Function 0
+ toTimeString DateProtoFunc::ToTimeString DontEnum|Function 0
+ toLocaleString DateProtoFunc::ToLocaleString DontEnum|Function 0
+ toLocaleDateString DateProtoFunc::ToLocaleDateString DontEnum|Function 0
+ toLocaleTimeString DateProtoFunc::ToLocaleTimeString DontEnum|Function 0
+ valueOf DateProtoFunc::ValueOf DontEnum|Function 0
+ getTime DateProtoFunc::GetTime DontEnum|Function 0
+ getFullYear DateProtoFunc::GetFullYear DontEnum|Function 0
+ getUTCFullYear -DateProtoFunc::GetFullYear DontEnum|Function 0
+ toGMTString -DateProtoFunc::ToGMTString DontEnum|Function 0
+ getMonth DateProtoFunc::GetMonth DontEnum|Function 0
+ getUTCMonth -DateProtoFunc::GetMonth DontEnum|Function 0
+ getDate DateProtoFunc::GetDate DontEnum|Function 0
+ getUTCDate -DateProtoFunc::GetDate DontEnum|Function 0
+ getDay DateProtoFunc::GetDay DontEnum|Function 0
+ getUTCDay -DateProtoFunc::GetDay DontEnum|Function 0
+ getHours DateProtoFunc::GetHours DontEnum|Function 0
+ getUTCHours -DateProtoFunc::GetHours DontEnum|Function 0
+ getMinutes DateProtoFunc::GetMinutes DontEnum|Function 0
+ getUTCMinutes -DateProtoFunc::GetMinutes DontEnum|Function 0
+ getSeconds DateProtoFunc::GetSeconds DontEnum|Function 0
+ getUTCSeconds -DateProtoFunc::GetSeconds DontEnum|Function 0
+ getMilliseconds DateProtoFunc::GetMilliSeconds DontEnum|Function 0
+ getUTCMilliseconds -DateProtoFunc::GetMilliSeconds DontEnum|Function 0
+ getTimezoneOffset DateProtoFunc::GetTimezoneOffset DontEnum|Function 0
+ setTime DateProtoFunc::SetTime DontEnum|Function 1
+ setMilliseconds DateProtoFunc::SetMilliSeconds DontEnum|Function 1
+ setUTCMilliseconds -DateProtoFunc::SetMilliSeconds DontEnum|Function 1
+ setSeconds DateProtoFunc::SetSeconds DontEnum|Function 2
+ setUTCSeconds -DateProtoFunc::SetSeconds DontEnum|Function 2
+ setMinutes DateProtoFunc::SetMinutes DontEnum|Function 3
+ setUTCMinutes -DateProtoFunc::SetMinutes DontEnum|Function 3
+ setHours DateProtoFunc::SetHours DontEnum|Function 4
+ setUTCHours -DateProtoFunc::SetHours DontEnum|Function 4
+ setDate DateProtoFunc::SetDate DontEnum|Function 1
+ setUTCDate -DateProtoFunc::SetDate DontEnum|Function 1
+ setMonth DateProtoFunc::SetMonth DontEnum|Function 2
+ setUTCMonth -DateProtoFunc::SetMonth DontEnum|Function 2
+ setFullYear DateProtoFunc::SetFullYear DontEnum|Function 3
+ setUTCFullYear -DateProtoFunc::SetFullYear DontEnum|Function 3
+ setYear DateProtoFunc::SetYear DontEnum|Function 1
+ getYear DateProtoFunc::GetYear DontEnum|Function 0
@end
*/
// ECMA 15.9.4
-DatePrototypeImp::DatePrototypeImp(ExecState *, ObjectPrototypeImp *objectProto)
- : DateInstanceImp(objectProto)
+DatePrototype::DatePrototype(ExecState *, ObjectPrototype *objectProto)
+ : DateInstance(objectProto)
{
setInternalValue(jsNaN());
// The constructor will be added later, after DateObjectImp has been built.
}
-bool DatePrototypeImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+bool DatePrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
- return getStaticFunctionSlot<DateProtoFuncImp, ObjectImp>(exec, &dateTable, this, propertyName, slot);
+ return getStaticFunctionSlot<DateProtoFunc, JSObject>(exec, &dateTable, this, propertyName, slot);
}
-// ------------------------------ DateProtoFuncImp -----------------------------
+// ------------------------------ DateProtoFunc -----------------------------
-DateProtoFuncImp::DateProtoFuncImp(ExecState *exec, int i, int len)
- : InternalFunctionImp(static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())),
+DateProtoFunc::DateProtoFunc(ExecState *exec, int i, int len)
+ : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())),
id(abs(i)), utc(i<0)
// We use a negative ID to denote the "UTC" variant.
{
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
-bool DateProtoFuncImp::implementsCall() const
+bool DateProtoFunc::implementsCall() const
{
return true;
}
return minusOne < 0;
}
-ValueImp *DateProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
+JSValue *DateProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
if ((id == ToString || id == ValueOf || id == GetTime || id == SetTime) &&
- !thisObj->inherits(&DateInstanceImp::info)) {
+ !thisObj->inherits(&DateInstance::info)) {
// non-generic function called on non-date object
// ToString and ValueOf are generic according to the spec, but the mozilla
}
- ValueImp *result = 0;
+ JSValue *result = 0;
UString s;
#if !__APPLE__
const int bufsize=100;
oldlocale = setlocale(LC_ALL, 0);
// FIXME: Where's the code to set the locale back to oldlocale?
#endif
- ValueImp *v = thisObj->internalValue();
+ JSValue *v = thisObj->internalValue();
double milli = v->toNumber(exec);
if (isNaN(milli)) {
switch (id) {
// TODO: MakeTime (15.9.11.1) etc. ?
DateObjectImp::DateObjectImp(ExecState *exec,
- FunctionPrototypeImp *funcProto,
- DatePrototypeImp *dateProto)
+ FunctionPrototype *funcProto,
+ DatePrototype *dateProto)
: InternalFunctionImp(funcProto)
{
// ECMA 15.9.4.1 Date.prototype
}
// ECMA 15.9.3
-ObjectImp *DateObjectImp::construct(ExecState *exec, const List &args)
+JSObject *DateObjectImp::construct(ExecState *exec, const List &args)
{
int numArgs = args.size();
}
}
- DateInstanceImp *ret = new DateInstanceImp(exec->lexicalInterpreter()->builtinDatePrototype());
+ DateInstance *ret = new DateInstance(exec->lexicalInterpreter()->builtinDatePrototype());
ret->setInternalValue(jsNumber(timeClip(value)));
return ret;
}
}
// ECMA 15.9.2
-ValueImp *DateObjectImp::callAsFunction(ExecState * /*exec*/, ObjectImp * /*thisObj*/, const List &/*args*/)
+JSValue *DateObjectImp::callAsFunction(ExecState * /*exec*/, JSObject * /*thisObj*/, const List &/*args*/)
{
time_t t = time(0);
tm ts;
// ------------------------------ DateObjectFuncImp ----------------------------
-DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len)
+DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
// ECMA 15.9.4.2 - 3
-ValueImp *DateObjectFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
+JSValue *DateObjectFuncImp::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
if (id == Parse) {
return jsNumber(parseDate(args[0]->toString(exec)));
namespace KJS {
- class FunctionPrototypeImp;
- class ObjectPrototypeImp;
+ class FunctionPrototype;
+ class ObjectPrototype;
- class DateInstanceImp : public ObjectImp {
+ class DateInstance : public JSObject {
public:
- DateInstanceImp(ObjectImp *proto);
+ DateInstance(JSObject *proto);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
* The initial value of Date.prototype (and thus all objects created
* with the Date constructor
*/
- class DatePrototypeImp : public DateInstanceImp {
+ class DatePrototype : public DateInstance {
public:
- DatePrototypeImp(ExecState *, ObjectPrototypeImp *);
+ DatePrototype(ExecState *, ObjectPrototype *);
virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
*/
class DateObjectImp : public InternalFunctionImp {
public:
- DateObjectImp(ExecState *, FunctionPrototypeImp *, DatePrototypeImp *);
+ DateObjectImp(ExecState *, FunctionPrototype *, DatePrototype *);
virtual bool implementsConstruct() const;
- virtual ObjectImp *construct(ExecState *, const List &args);
+ virtual JSObject *construct(ExecState *, const List &args);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args);
Completion execute(const List &);
- ObjectImp *construct(const List &);
+ JSObject *construct(const List &);
};
} // namespace
}
bool Debugger::exception(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
- ObjectImp */*exceptionObj*/)
+ JSObject */*exceptionObj*/)
{
return true;
}
}
bool Debugger::callEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
- ObjectImp */*function*/, const List &/*args*/)
+ JSObject */*function*/, const List &/*args*/)
{
return true;
}
bool Debugger::returnEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
- ObjectImp */*function*/)
+ JSObject */*function*/)
{
return true;
}
class DebuggerImp;
class Interpreter;
class ExecState;
- class ObjectImp;
+ class JSObject;
class UString;
class List;
* be aborted
*/
virtual bool exception(ExecState *exec, int sourceId, int lineno,
- ObjectImp *exceptionObj);
+ JSObject *exceptionObj);
/**
* Called when a line of the script is reached (before it is executed)
* be aborted
*/
virtual bool callEvent(ExecState *exec, int sourceId, int lineno,
- ObjectImp *function, const List &args);
+ JSObject *function, const List &args);
/**
* Called on each function exit. The function being returned from is that
* be aborted
*/
virtual bool returnEvent(ExecState *exec, int sourceId, int lineno,
- ObjectImp *function);
+ JSObject *function);
private:
DebuggerImp *rep;
using namespace KJS;
-// ------------------------------ ErrorInstanceImp ----------------------------
+// ------------------------------ ErrorInstance ----------------------------
-const ClassInfo ErrorInstanceImp::info = {"Error", 0, 0, 0};
+const ClassInfo ErrorInstance::info = {"Error", 0, 0, 0};
-ErrorInstanceImp::ErrorInstanceImp(ObjectImp *proto)
-: ObjectImp(proto)
+ErrorInstance::ErrorInstance(JSObject *proto)
+: JSObject(proto)
{
}
-// ------------------------------ ErrorPrototypeImp ----------------------------
+// ------------------------------ ErrorPrototype ----------------------------
// ECMA 15.9.4
-ErrorPrototypeImp::ErrorPrototypeImp(ExecState *exec,
- ObjectPrototypeImp *objectProto,
- FunctionPrototypeImp *funcProto)
- : ObjectImp(objectProto)
+ErrorPrototype::ErrorPrototype(ExecState *exec,
+ ObjectPrototype *objectProto,
+ FunctionPrototype *funcProto)
+ : JSObject(objectProto)
{
setInternalValue(jsUndefined());
// The constructor will be added later in ErrorObjectImp's constructor
put(exec, namePropertyName, jsString("Error"), DontEnum);
put(exec, messagePropertyName, jsString("Unknown error"), DontEnum);
- putDirect(toStringPropertyName, new ErrorProtoFuncImp(exec,funcProto), DontEnum);
+ putDirect(toStringPropertyName, new ErrorProtoFunc(exec,funcProto), DontEnum);
}
-// ------------------------------ ErrorProtoFuncImp ----------------------------
+// ------------------------------ ErrorProtoFunc ----------------------------
-ErrorProtoFuncImp::ErrorProtoFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto)
+ErrorProtoFunc::ErrorProtoFunc(ExecState *exec, FunctionPrototype *funcProto)
: InternalFunctionImp(funcProto)
{
putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
}
-bool ErrorProtoFuncImp::implementsCall() const
+bool ErrorProtoFunc::implementsCall() const
{
return true;
}
-ValueImp *ErrorProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &/*args*/)
+JSValue *ErrorProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)
{
// toString()
UString s = "Error";
- ValueImp *v = thisObj->get(exec, namePropertyName);
+ JSValue *v = thisObj->get(exec, namePropertyName);
if (!v->isUndefined()) {
s = v->toString(exec);
}
// ------------------------------ ErrorObjectImp -------------------------------
-ErrorObjectImp::ErrorObjectImp(ExecState *exec, FunctionPrototypeImp *funcProto,
- ErrorPrototypeImp *errorProto)
+ErrorObjectImp::ErrorObjectImp(ExecState *exec, FunctionPrototype *funcProto,
+ ErrorPrototype *errorProto)
: InternalFunctionImp(funcProto)
{
// ECMA 15.11.3.1 Error.prototype
}
// ECMA 15.9.3
-ObjectImp *ErrorObjectImp::construct(ExecState *exec, const List &args)
+JSObject *ErrorObjectImp::construct(ExecState *exec, const List &args)
{
- ObjectImp *proto = static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinErrorPrototype());
- ObjectImp *imp = new ErrorInstanceImp(proto);
- ObjectImp *obj(imp);
+ JSObject *proto = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinErrorPrototype());
+ JSObject *imp = new ErrorInstance(proto);
+ JSObject *obj(imp);
if (!args[0]->isUndefined())
imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
}
// ECMA 15.9.2
-ValueImp *ErrorObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
+JSValue *ErrorObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
{
// "Error()" gives the sames result as "new Error()"
return construct(exec,args);
}
-// ------------------------------ NativeErrorPrototypeImp ----------------------
+// ------------------------------ NativeErrorPrototype ----------------------
-NativeErrorPrototypeImp::NativeErrorPrototypeImp(ExecState *exec, ErrorPrototypeImp *errorProto,
+NativeErrorPrototype::NativeErrorPrototype(ExecState *exec, ErrorPrototype *errorProto,
ErrorType et, UString name, UString message)
- : ObjectImp(errorProto)
+ : JSObject(errorProto)
{
errType = et;
putDirect(namePropertyName, jsString(name), 0);
const ClassInfo NativeErrorImp::info = {"Function", &InternalFunctionImp::info, 0, 0};
-NativeErrorImp::NativeErrorImp(ExecState *exec, FunctionPrototypeImp *funcProto,
- ObjectImp *prot)
+NativeErrorImp::NativeErrorImp(ExecState *exec, FunctionPrototype *funcProto,
+ JSObject *prot)
: InternalFunctionImp(funcProto), proto(prot)
{
putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
return true;
}
-ObjectImp *NativeErrorImp::construct(ExecState *exec, const List &args)
+JSObject *NativeErrorImp::construct(ExecState *exec, const List &args)
{
- ObjectImp *imp = new ErrorInstanceImp(proto);
- ObjectImp *obj(imp);
+ JSObject *imp = new ErrorInstance(proto);
+ JSObject *obj(imp);
if (!args[0]->isUndefined())
imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
return obj;
return true;
}
-ValueImp *NativeErrorImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
+JSValue *NativeErrorImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
{
return construct(exec,args);
}
void NativeErrorImp::mark()
{
- ObjectImp::mark();
+ JSObject::mark();
if (proto && !proto->marked())
proto->mark();
}
namespace KJS {
- class ErrorInstanceImp : public ObjectImp {
+ class ErrorInstance : public JSObject {
public:
- ErrorInstanceImp(ObjectImp *proto);
+ ErrorInstance(JSObject *proto);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
};
- class ErrorPrototypeImp : public ObjectImp {
+ class ErrorPrototype : public JSObject {
public:
- ErrorPrototypeImp(ExecState *exec,
- ObjectPrototypeImp *objectProto,
- FunctionPrototypeImp *funcProto);
+ ErrorPrototype(ExecState *exec,
+ ObjectPrototype *objectProto,
+ FunctionPrototype *funcProto);
};
- class ErrorProtoFuncImp : public InternalFunctionImp {
+ class ErrorProtoFunc : public InternalFunctionImp {
public:
- ErrorProtoFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto);
+ ErrorProtoFunc(ExecState *exec, FunctionPrototype *funcProto);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
};
class ErrorObjectImp : public InternalFunctionImp {
public:
- ErrorObjectImp(ExecState *exec, FunctionPrototypeImp *funcProto,
- ErrorPrototypeImp *errorProto);
+ ErrorObjectImp(ExecState *exec, FunctionPrototype *funcProto,
+ ErrorPrototype *errorProto);
virtual bool implementsConstruct() const;
- virtual ObjectImp *construct(ExecState *exec, const List &args);
+ virtual JSObject *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
};
- class NativeErrorPrototypeImp : public ObjectImp {
+ class NativeErrorPrototype : public JSObject {
public:
- NativeErrorPrototypeImp(ExecState *exec, ErrorPrototypeImp *errorProto,
+ NativeErrorPrototype(ExecState *exec, ErrorPrototype *errorProto,
ErrorType et, UString name, UString message);
private:
ErrorType errType;
class NativeErrorImp : public InternalFunctionImp {
public:
- NativeErrorImp(ExecState *exec, FunctionPrototypeImp *funcProto,
- ObjectImp *prot);
+ NativeErrorImp(ExecState *exec, FunctionPrototype *funcProto,
+ JSObject *prot);
virtual bool implementsConstruct() const;
- virtual ObjectImp *construct(ExecState *exec, const List &args);
+ virtual JSObject *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
virtual void mark();
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
private:
- ObjectImp *proto;
+ JSObject *proto;
};
} // namespace
FunctionImp::FunctionImp(ExecState *exec, const Identifier &n)
: InternalFunctionImp(
- static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
+ static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
), param(0L), ident(n)
{
}
return true;
}
-ValueImp *FunctionImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
+JSValue *FunctionImp::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
- ObjectImp *globalObj = exec->dynamicInterpreter()->globalObject();
+ JSObject *globalObj = exec->dynamicInterpreter()->globalObject();
// enter a new execution context
ContextImp ctx(globalObj, exec->dynamicInterpreter()->imp(), thisObj, codeType(),
// ECMA 10.1.3q
void FunctionImp::processParameters(ExecState *exec, const List &args)
{
- ObjectImp *variable = exec->context().imp()->variableObject();
+ JSObject *variable = exec->context().imp()->variableObject();
#ifdef KJS_VERBOSE
fprintf(stderr, "---------------------------------------------------\n"
{
}
-ValueImp *FunctionImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *FunctionImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase());
ContextImp *context = exec->_context;
return jsNull();
}
-ValueImp *FunctionImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *FunctionImp::lengthGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase());
const Parameter *p = thisObj->param;
return InternalFunctionImp::getOwnPropertySlot(exec, propertyName, slot);
}
-void FunctionImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
+void FunctionImp::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
{
if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)
return;
}
// ECMA 13.2.2 [[Construct]]
-ObjectImp *DeclaredFunctionImp::construct(ExecState *exec, const List &args)
+JSObject *DeclaredFunctionImp::construct(ExecState *exec, const List &args)
{
- ObjectImp *proto;
- ValueImp *p = get(exec,prototypePropertyName);
+ JSObject *proto;
+ JSValue *p = get(exec,prototypePropertyName);
if (p->isObject())
- proto = static_cast<ObjectImp*>(p);
+ proto = static_cast<JSObject*>(p);
else
proto = exec->lexicalInterpreter()->builtinObjectPrototype();
- ObjectImp *obj(new ObjectImp(proto));
+ JSObject *obj(new JSObject(proto));
- ValueImp *res = call(exec,obj,args);
+ JSValue *res = call(exec,obj,args);
if (res->isObject())
- return static_cast<ObjectImp *>(res);
+ return static_cast<JSObject *>(res);
else
return obj;
}
return (*this)[indexAsNumber];
}
-// ------------------------------ ArgumentsImp ---------------------------------
+// ------------------------------ Arguments ---------------------------------
-const ClassInfo ArgumentsImp::info = {"Arguments", 0, 0, 0};
+const ClassInfo Arguments::info = {"Arguments", 0, 0, 0};
// ECMA 10.1.8
-ArgumentsImp::ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args, ActivationImp *act)
-: ObjectImp(exec->lexicalInterpreter()->builtinObjectPrototype()),
+Arguments::Arguments(ExecState *exec, FunctionImp *func, const List &args, ActivationImp *act)
+: JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()),
_activationObject(act),
indexToNameMap(func, args)
{
ListIterator iterator = args.begin();
for (; iterator != args.end(); i++, iterator++) {
if (!indexToNameMap.isMapped(Identifier::from(i))) {
- ObjectImp::put(exec, Identifier::from(i), *iterator, DontEnum);
+ JSObject::put(exec, Identifier::from(i), *iterator, DontEnum);
}
}
}
-void ArgumentsImp::mark()
+void Arguments::mark()
{
- ObjectImp::mark();
+ JSObject::mark();
if (_activationObject && !_activationObject->marked())
_activationObject->mark();
}
-ValueImp *ArgumentsImp::mappedIndexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *Arguments::mappedIndexGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
- ArgumentsImp *thisObj = static_cast<ArgumentsImp *>(slot.slotBase());
+ Arguments *thisObj = static_cast<Arguments *>(slot.slotBase());
return thisObj->_activationObject->get(exec, thisObj->indexToNameMap[propertyName]);
}
-bool ArgumentsImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
+bool Arguments::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
if (indexToNameMap.isMapped(propertyName)) {
slot.setCustom(this, mappedIndexGetter);
return true;
}
- return ObjectImp::getOwnPropertySlot(exec, propertyName, slot);
+ return JSObject::getOwnPropertySlot(exec, propertyName, slot);
}
-void ArgumentsImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
+void Arguments::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
{
if (indexToNameMap.isMapped(propertyName)) {
_activationObject->put(exec, indexToNameMap[propertyName], value, attr);
} else {
- ObjectImp::put(exec, propertyName, value, attr);
+ JSObject::put(exec, propertyName, value, attr);
}
}
-bool ArgumentsImp::deleteProperty(ExecState *exec, const Identifier &propertyName)
+bool Arguments::deleteProperty(ExecState *exec, const Identifier &propertyName)
{
if (indexToNameMap.isMapped(propertyName)) {
indexToNameMap.unMap(propertyName);
return true;
} else {
- return ObjectImp::deleteProperty(exec, propertyName);
+ return JSObject::deleteProperty(exec, propertyName);
}
}
// FIXME: Do we need to support enumerating the arguments property?
}
-ValueImp *ActivationImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValue *ActivationImp::argumentsGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
ActivationImp *thisObj = static_cast<ActivationImp *>(slot.slotBase());
bool ActivationImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
// do this first so property map arguments property wins over the below
- if (ObjectImp::getOwnPropertySlot(exec, propertyName, slot))
+ if (JSObject::getOwnPropertySlot(exec, propertyName, slot))
return true;
if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier()) {
{
if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier())
return false;
- return ObjectImp::deleteProperty(exec, propertyName);
+ return JSObject::deleteProperty(exec, propertyName);
}
void ActivationImp::mark()
_arguments.mark();
if (_argumentsObject && !_argumentsObject->marked())
_argumentsObject->mark();
- ObjectImp::mark();
+ JSObject::mark();
}
void ActivationImp::createArgumentsObject(ExecState *exec) const
{
- _argumentsObject = new ArgumentsImp(exec, _function, _arguments, const_cast<ActivationImp *>(this));
+ _argumentsObject = new Arguments(exec, _function, _arguments, const_cast<ActivationImp *>(this));
}
// ------------------------------ GlobalFunc -----------------------------------
-GlobalFuncImp::GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len)
+GlobalFuncImp::GlobalFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
return true;
}
-static ValueImp *encode(ExecState *exec, const List &args, const char *do_not_escape)
+static JSValue *encode(ExecState *exec, const List &args, const char *do_not_escape)
{
UString r = "", s, str = args[0]->toString(exec);
CString cstr = str.UTF8String();
return jsString(r);
}
-static ValueImp *decode(ExecState *exec, const List &args, const char *do_not_unescape, bool strict)
+static JSValue *decode(ExecState *exec, const List &args, const char *do_not_unescape, bool strict)
{
UString s = "", str = args[0]->toString(exec);
int k = 0, len = str.size();
return s.toDouble( true /*tolerant*/, false /* NaN for empty string */ );
}
-ValueImp *GlobalFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
+JSValue *GlobalFuncImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
{
- ValueImp *res = jsUndefined();
+ JSValue *res = jsUndefined();
static const char do_not_escape[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
switch (id) {
case Eval: { // eval()
- ValueImp *x = args[0];
+ JSValue *x = args[0];
if (!x->isString())
return x;
else {
}
// enter a new execution context
- ObjectImp *thisVal = static_cast<ObjectImp *>(exec->context().thisValue());
+ JSObject *thisVal = static_cast<JSObject *>(exec->context().thisValue());
ContextImp ctx(exec->dynamicInterpreter()->globalObject(),
exec->dynamicInterpreter()->imp(),
thisVal,
virtual ~FunctionImp();
virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
void addParameter(const Identifier &n);
Identifier getParameterName(int index);
Identifier ident;
private:
- static ValueImp *argumentsGetter(ExecState *, const Identifier &, const PropertySlot&);
- static ValueImp *lengthGetter(ExecState *, const Identifier &, const PropertySlot&);
+ static JSValue *argumentsGetter(ExecState *, const Identifier &, const PropertySlot&);
+ static JSValue *lengthGetter(ExecState *, const Identifier &, const PropertySlot&);
void processParameters(ExecState *exec, const List &);
virtual void processVarDecls(ExecState *exec);
FunctionBodyNode *b, const ScopeChain &sc);
bool implementsConstruct() const;
- ObjectImp *construct(ExecState *exec, const List &args);
+ JSObject *construct(ExecState *exec, const List &args);
virtual Completion execute(ExecState *exec);
CodeType codeType() const { return FunctionCode; }
Identifier * _map;
};
- class ArgumentsImp : public ObjectImp {
+ class Arguments : public JSObject {
public:
- ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args, ActivationImp *act);
+ Arguments(ExecState *exec, FunctionImp *func, const List &args, ActivationImp *act);
virtual void mark();
virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
private:
- static ValueImp *mappedIndexGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
+ static JSValue *mappedIndexGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
ActivationImp *_activationObject;
mutable IndexToNameMap indexToNameMap;
};
- class ActivationImp : public ObjectImp {
+ class ActivationImp : public JSObject {
public:
ActivationImp(FunctionImp *function, const List &arguments);
bool isActivation() { return true; }
private:
static PropertySlot::GetValueFunc getArgumentsGetter();
- static ValueImp *argumentsGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
+ static JSValue *argumentsGetter(ExecState *exec, const Identifier &, const PropertySlot& slot);
void createArgumentsObject(ExecState *exec) const;
FunctionImp *_function;
List _arguments;
- mutable ArgumentsImp *_argumentsObject;
+ mutable Arguments *_argumentsObject;
};
class GlobalFuncImp : public InternalFunctionImp {
public:
- GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len);
+ GlobalFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
virtual CodeType codeType() const;
enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape,
DecodeURI, DecodeURIComponent, EncodeURI, EncodeURIComponent
using namespace KJS;
-// ------------------------------ FunctionPrototypeImp -------------------------
+// ------------------------------ FunctionPrototype -------------------------
-FunctionPrototypeImp::FunctionPrototypeImp(ExecState *exec)
+FunctionPrototype::FunctionPrototype(ExecState *exec)
{
putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
- putDirect(toStringPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0), DontEnum);
+ putDirect(toStringPropertyName, new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0), DontEnum);
static const Identifier applyPropertyName("apply");
- putDirect(applyPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply, 2), DontEnum);
+ putDirect(applyPropertyName, new FunctionProtoFunc(exec, this, FunctionProtoFunc::Apply, 2), DontEnum);
static const Identifier callPropertyName("call");
- putDirect(callPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Call, 1), DontEnum);
+ putDirect(callPropertyName, new FunctionProtoFunc(exec, this, FunctionProtoFunc::Call, 1), DontEnum);
}
-FunctionPrototypeImp::~FunctionPrototypeImp()
+FunctionPrototype::~FunctionPrototype()
{
}
-bool FunctionPrototypeImp::implementsCall() const
+bool FunctionPrototype::implementsCall() const
{
return true;
}
// ECMA 15.3.4
-ValueImp *FunctionPrototypeImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
+JSValue *FunctionPrototype::callAsFunction(ExecState */*exec*/, JSObject */*thisObj*/, const List &/*args*/)
{
return jsUndefined();
}
-// ------------------------------ FunctionProtoFuncImp -------------------------
+// ------------------------------ FunctionProtoFunc -------------------------
-FunctionProtoFuncImp::FunctionProtoFuncImp(ExecState *exec,
- FunctionPrototypeImp *funcProto, int i, int len)
+FunctionProtoFunc::FunctionProtoFunc(ExecState *exec,
+ FunctionPrototype *funcProto, int i, int len)
: InternalFunctionImp(funcProto), id(i)
{
putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
-bool FunctionProtoFuncImp::implementsCall() const
+bool FunctionProtoFunc::implementsCall() const
{
return true;
}
-ValueImp *FunctionProtoFuncImp::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
+JSValue *FunctionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
- ValueImp *result = NULL;
+ JSValue *result = NULL;
switch (id) {
case ToString: {
}
break;
case Apply: {
- ValueImp *thisArg = args[0];
- ValueImp *argArray = args[1];
- ObjectImp *func = thisObj;
+ JSValue *thisArg = args[0];
+ JSValue *argArray = args[1];
+ JSObject *func = thisObj;
if (!func->implementsCall())
return throwError(exec, TypeError);
- ObjectImp *applyThis;
+ JSObject *applyThis;
if (thisArg->isUndefinedOrNull())
applyThis = exec->dynamicInterpreter()->globalObject();
else
List applyArgs;
if (!argArray->isUndefinedOrNull()) {
if (argArray->isObject() &&
- (static_cast<ObjectImp *>(argArray)->inherits(&ArrayInstanceImp::info) ||
- static_cast<ObjectImp *>(argArray)->inherits(&ArgumentsImp::info))) {
+ (static_cast<JSObject *>(argArray)->inherits(&ArrayInstance::info) ||
+ static_cast<JSObject *>(argArray)->inherits(&Arguments::info))) {
- ObjectImp *argArrayObj = static_cast<ObjectImp *>(argArray);
+ JSObject *argArrayObj = static_cast<JSObject *>(argArray);
unsigned int length = argArrayObj->get(exec,lengthPropertyName)->toUInt32(exec);
for (unsigned int i = 0; i < length; i++)
applyArgs.append(argArrayObj->get(exec,i));
}
break;
case Call: {
- ValueImp *thisArg = args[0];
- ObjectImp *func = thisObj;
+ JSValue *thisArg = args[0];
+ JSObject *func = thisObj;
if (!func->implementsCall())
return throwError(exec, TypeError);
- ObjectImp *callThis;
+ JSObject *callThis;
if (thisArg->isUndefinedOrNull())
callThis = exec->dynamicInterpreter()->globalObject();
else
// ------------------------------ FunctionObjectImp ----------------------------
-FunctionObjectImp::FunctionObjectImp(ExecState *exec, FunctionPrototypeImp *funcProto)
+FunctionObjectImp::FunctionObjectImp(ExecState *exec, FunctionPrototype *funcProto)
: InternalFunctionImp(funcProto)
{
putDirect(prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly);
}
// ECMA 15.3.2 The Function Constructor
-ObjectImp *FunctionObjectImp::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber)
+JSObject *FunctionObjectImp::construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber)
{
UString p("");
UString body;
bool cont = dbg->sourceParsed(exec,sid,UString(),body,errLine);
if (!cont) {
dbg->imp()->abort();
- return new ObjectImp();
+ return new JSObject();
}
}
List consArgs;
- ObjectImp *objCons = exec->lexicalInterpreter()->builtinObject();
- ObjectImp *prototype = objCons->construct(exec,List::empty());
+ JSObject *objCons = exec->lexicalInterpreter()->builtinObject();
+ JSObject *prototype = objCons->construct(exec,List::empty());
prototype->put(exec, constructorPropertyName, fimp, DontEnum|DontDelete|ReadOnly);
fimp->put(exec, prototypePropertyName, prototype, DontEnum|DontDelete|ReadOnly);
return fimp;
}
// ECMA 15.3.2 The Function Constructor
-ObjectImp *FunctionObjectImp::construct(ExecState *exec, const List &args)
+JSObject *FunctionObjectImp::construct(ExecState *exec, const List &args)
{
return FunctionObjectImp::construct(exec, args, UString(), 0);
}
}
// ECMA 15.3.1 The Function Constructor Called as a Function
-ValueImp *FunctionObjectImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
+JSValue *FunctionObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
{
return construct(exec,args);
}
* The initial value of Function.prototype (and thus all objects created
* with the Function constructor)
*/
- class FunctionPrototypeImp : public InternalFunctionImp {
+ class FunctionPrototype : public InternalFunctionImp {
public:
- FunctionPrototypeImp(ExecState *exec);
- virtual ~FunctionPrototypeImp();
+ FunctionPrototype(ExecState *exec);
+ virtual ~FunctionPrototype();
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
};
/**
* Class to implement all methods that are properties of the
* Function.prototype object
*/
- class FunctionProtoFuncImp : public InternalFunctionImp {
+ class FunctionProtoFunc : public InternalFunctionImp {
public:
- FunctionProtoFuncImp(ExecState *exec,
- FunctionPrototypeImp *funcProto, int i, int len);
+ FunctionProtoFunc(ExecState *exec,
+ FunctionPrototype *funcProto, int i, int len);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
enum { ToString, Apply, Call };
private:
*/
class FunctionObjectImp : public InternalFunctionImp {
public:
- FunctionObjectImp(ExecState *exec, FunctionPrototypeImp *funcProto);
+ FunctionObjectImp(ExecState *exec, FunctionPrototype *funcProto);
virtual ~FunctionObjectImp();
virtual bool implementsConstruct() const;
- virtual ObjectImp *construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
- virtual ObjectImp *construct(ExecState *exec, const List &args);
+ virtual JSObject *construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
+ virtual JSObject *construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
};
} // namespace
// ------------------------------ UndefinedImp ---------------------------------
-ValueImp *UndefinedImp::toPrimitive(ExecState *, Type) const
+JSValue *UndefinedImp::toPrimitive(ExecState *, Type) const
{
return const_cast<UndefinedImp *>(this);
}
return "undefined";
}
-ObjectImp *UndefinedImp::toObject(ExecState *exec) const
+JSObject *UndefinedImp::toObject(ExecState *exec) const
{
return throwError(exec, TypeError, "Undefined value");
}
// ------------------------------ NullImp --------------------------------------
-ValueImp *NullImp::toPrimitive(ExecState *, Type) const
+JSValue *NullImp::toPrimitive(ExecState *, Type) const
{
return const_cast<NullImp *>(this);
}
return "null";
}
-ObjectImp *NullImp::toObject(ExecState *exec) const
+JSObject *NullImp::toObject(ExecState *exec) const
{
return throwError(exec, TypeError, "Null value");
}
// ------------------------------ BooleanImp -----------------------------------
-ValueImp *BooleanImp::toPrimitive(ExecState *, Type) const
+JSValue *BooleanImp::toPrimitive(ExecState *, Type) const
{
return const_cast<BooleanImp *>(this);
}
return val ? "true" : "false";
}
-ObjectImp *BooleanImp::toObject(ExecState *exec) const
+JSObject *BooleanImp::toObject(ExecState *exec) const
{
List args;
args.append(const_cast<BooleanImp*>(this));
- return static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinBoolean()->construct(exec,args));
+ return static_cast<JSObject *>(exec->lexicalInterpreter()->builtinBoolean()->construct(exec,args));
}
// ------------------------------ StringImp ------------------------------------
-ValueImp *StringImp::toPrimitive(ExecState *, Type) const
+JSValue *StringImp::toPrimitive(ExecState *, Type) const
{
return const_cast<StringImp *>(this);
}
return val;
}
-ObjectImp *StringImp::toObject(ExecState *exec) const
+JSObject *StringImp::toObject(ExecState *exec) const
{
List args;
args.append(const_cast<StringImp*>(this));
- return static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinString()->construct(exec, args));
+ return static_cast<JSObject *>(exec->lexicalInterpreter()->builtinString()->construct(exec, args));
}
// ------------------------------ NumberImp ------------------------------------
-ValueImp *NumberImp::toPrimitive(ExecState *, Type) const
+JSValue *NumberImp::toPrimitive(ExecState *, Type) const
{
return const_cast<NumberImp *>(this);
}
return UString::from(val);
}
-ObjectImp *NumberImp::toObject(ExecState *exec) const
+JSObject *NumberImp::toObject(ExecState *exec) const
{
List args;
args.append(const_cast<NumberImp*>(this));
- return static_cast<ObjectImp *>(exec->lexicalInterpreter()->builtinNumber()->construct(exec,args));
+ return static_cast<JSObject *>(exec->lexicalInterpreter()->builtinNumber()->construct(exec,args));
}
bool NumberImp::getUInt32(uint32_t& uint32) const
// ------------------------------ ContextImp -----------------------------------
// ECMA 10.2
-ContextImp::ContextImp(ObjectImp *glob, InterpreterImp *interpreter, ObjectImp *thisV, CodeType type,
+ContextImp::ContextImp(JSObject *glob, InterpreterImp *interpreter, JSObject *thisV, CodeType type,
ContextImp *callingCon, FunctionImp *func, const List *args)
: _interpreter(interpreter), _function(func), _arguments(args)
{
case GlobalCode:
scope.clear();
scope.push(glob);
- thisVal = static_cast<ObjectImp*>(glob);
+ thisVal = static_cast<JSObject*>(glob);
break;
case FunctionCode:
case AnonymousCode:
InterpreterImp* InterpreterImp::s_hook = 0L;
-typedef HashMap<ObjectImp *, InterpreterImp *, PointerHash<ObjectImp *> > InterpreterMap;
+typedef HashMap<JSObject *, InterpreterImp *, PointerHash<JSObject *> > InterpreterMap;
static inline InterpreterMap &interpreterMap()
{
return *map;
}
-InterpreterImp::InterpreterImp(Interpreter *interp, ObjectImp *glob)
+InterpreterImp::InterpreterImp(Interpreter *interp, JSObject *glob)
: globExec(interp, 0)
, _context(0)
{
// Contructor prototype objects (Object.prototype, Array.prototype etc)
- FunctionPrototypeImp *funcProto = new FunctionPrototypeImp(&globExec);
+ FunctionPrototype *funcProto = new FunctionPrototype(&globExec);
b_FunctionPrototype = funcProto;
- ObjectPrototypeImp *objProto = new ObjectPrototypeImp(&globExec, funcProto);
+ ObjectPrototype *objProto = new ObjectPrototype(&globExec, funcProto);
b_ObjectPrototype = objProto;
funcProto->setPrototype(b_ObjectPrototype);
- ArrayPrototypeImp *arrayProto = new ArrayPrototypeImp(&globExec, objProto);
+ ArrayPrototype *arrayProto = new ArrayPrototype(&globExec, objProto);
b_ArrayPrototype = arrayProto;
- StringPrototypeImp *stringProto = new StringPrototypeImp(&globExec, objProto);
+ StringPrototype *stringProto = new StringPrototype(&globExec, objProto);
b_StringPrototype = stringProto;
- BooleanPrototypeImp *booleanProto = new BooleanPrototypeImp(&globExec, objProto, funcProto);
+ BooleanPrototype *booleanProto = new BooleanPrototype(&globExec, objProto, funcProto);
b_BooleanPrototype = booleanProto;
- NumberPrototypeImp *numberProto = new NumberPrototypeImp(&globExec, objProto, funcProto);
+ NumberPrototype *numberProto = new NumberPrototype(&globExec, objProto, funcProto);
b_NumberPrototype = numberProto;
- DatePrototypeImp *dateProto = new DatePrototypeImp(&globExec, objProto);
+ DatePrototype *dateProto = new DatePrototype(&globExec, objProto);
b_DatePrototype = dateProto;
- RegExpPrototypeImp *regexpProto = new RegExpPrototypeImp(&globExec, objProto, funcProto);
+ RegExpPrototype *regexpProto = new RegExpPrototype(&globExec, objProto, funcProto);
b_RegExpPrototype = regexpProto;
- ErrorPrototypeImp *errorProto = new ErrorPrototypeImp(&globExec, objProto, funcProto);
+ ErrorPrototype *errorProto = new ErrorPrototype(&globExec, objProto, funcProto);
b_ErrorPrototype = errorProto;
- static_cast<ObjectImp*>(global)->setPrototype(b_ObjectPrototype);
+ static_cast<JSObject*>(global)->setPrototype(b_ObjectPrototype);
// Constructors (Object, Array, etc.)
b_Object = new ObjectObjectImp(&globExec, objProto, funcProto);
b_Error = new ErrorObjectImp(&globExec, funcProto, errorProto);
// Error object prototypes
- b_evalErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, EvalError, "EvalError", "EvalError");
- b_rangeErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, RangeError, "RangeError", "RangeError");
- b_referenceErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, ReferenceError, "ReferenceError", "ReferenceError");
- b_syntaxErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, SyntaxError, "SyntaxError", "SyntaxError");
- b_typeErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, TypeError, "TypeError", "TypeError");
- b_uriErrorPrototype = new NativeErrorPrototypeImp(&globExec, errorProto, URIError, "URIError", "URIError");
+ b_evalErrorPrototype = new NativeErrorPrototype(&globExec, errorProto, EvalError, "EvalError", "EvalError");
+ b_rangeErrorPrototype = new NativeErrorPrototype(&globExec, errorProto, RangeError, "RangeError", "RangeError");
+ b_referenceErrorPrototype = new NativeErrorPrototype(&globExec, errorProto, ReferenceError, "ReferenceError", "ReferenceError");
+ b_syntaxErrorPrototype = new NativeErrorPrototype(&globExec, errorProto, SyntaxError, "SyntaxError", "SyntaxError");
+ b_typeErrorPrototype = new NativeErrorPrototype(&globExec, errorProto, TypeError, "TypeError", "TypeError");
+ b_uriErrorPrototype = new NativeErrorPrototype(&globExec, errorProto, URIError, "URIError", "URIError");
// Error objects
b_evalError = new NativeErrorImp(&globExec, funcProto, b_evalErrorPrototype);
return progNode;
}
-Completion InterpreterImp::evaluate(const UString &code, ValueImp *thisV, const UString &sourceURL, int startingLineNumber)
+Completion InterpreterImp::evaluate(const UString &code, JSValue *thisV, const UString &sourceURL, int startingLineNumber)
{
JSLock lock;
// no program node means a syntax error occurred
if (!progNode) {
- ObjectImp *err = Error::create(&globExec, SyntaxError, errMsg, errLine, sid, &sourceURL);
+ JSObject *err = Error::create(&globExec, SyntaxError, errMsg, errLine, sid, &sourceURL);
return Completion(Throw,err);
}
recursion++;
- ObjectImp *globalObj = globalObject();
- ObjectImp *thisObj = globalObject();
+ JSObject *globalObj = globalObject();
+ JSObject *thisObj = globalObject();
if (thisV) {
// "this" must be an object... use same rules as Function.prototype.apply()
b_uriErrorPrototype = builtins._internal->b_uriErrorPrototype;
}
-InterpreterImp *InterpreterImp::interpreterWithGlobalObject(ObjectImp *global)
+InterpreterImp *InterpreterImp::interpreterWithGlobalObject(JSObject *global)
{
return interpreterMap().get(global);
}
{
}
-InternalFunctionImp::InternalFunctionImp(FunctionPrototypeImp *funcProto)
- : ObjectImp(funcProto)
+InternalFunctionImp::InternalFunctionImp(FunctionPrototype *funcProto)
+ : JSObject(funcProto)
{
}
return true;
}
-bool InternalFunctionImp::hasInstance(ExecState *exec, ValueImp *value)
+bool InternalFunctionImp::hasInstance(ExecState *exec, JSValue *value)
{
if (!value->isObject())
return false;
- ValueImp *prot = get(exec,prototypePropertyName);
+ JSValue *prot = get(exec,prototypePropertyName);
if (!prot->isObject() && !prot->isNull()) {
throwError(exec, TypeError, "Invalid prototype encountered in instanceof operation.");
return false;
}
- ObjectImp *v = static_cast<ObjectImp *>(value);
+ JSObject *v = static_cast<JSObject *>(value);
while ((v = v->prototype()->getObject())) {
if (v == prot)
return true;
// ------------------------------ global functions -----------------------------
-double roundValue(ExecState *exec, ValueImp *v)
+double roundValue(ExecState *exec, JSValue *v)
{
double d = v->toNumber(exec);
double ad = fabs(d);
#ifndef NDEBUG
#include <stdio.h>
-void printInfo(ExecState *exec, const char *s, ValueImp *o, int lineno)
+void printInfo(ExecState *exec, const char *s, JSValue *o, int lineno)
{
if (!o)
fprintf(stderr, "KJS: %s: (null)", s);
else {
- ValueImp *v = o;
+ JSValue *v = o;
UString name;
switch (v->type()) {
name = "Number";
break;
case ObjectType:
- name = static_cast<ObjectImp *>(v)->className();
+ name = static_cast<JSObject *>(v)->className();
if (name.isNull())
name = "(unknown class)";
break;
class Node;
class ProgramNode;
class FunctionBodyNode;
- class FunctionPrototypeImp;
+ class FunctionPrototype;
class FunctionImp;
class Debugger;
// Primitive impls
// ---------------------------------------------------------------------------
- class UndefinedImp : public AllocatedValueImp {
+ class UndefinedImp : public JSCell {
public:
Type type() const { return UndefinedType; }
- ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ JSValue *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- ObjectImp *toObject(ExecState *exec) const;
+ JSObject *toObject(ExecState *exec) const;
};
- class NullImp : public AllocatedValueImp {
+ class NullImp : public JSCell {
public:
Type type() const { return NullType; }
- ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ JSValue *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- ObjectImp *toObject(ExecState *exec) const;
+ JSObject *toObject(ExecState *exec) const;
};
- class BooleanImp : public AllocatedValueImp {
+ class BooleanImp : public JSCell {
public:
BooleanImp(bool v = false) : val(v) { }
bool value() const { return val; }
Type type() const { return BooleanType; }
- ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ JSValue *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- ObjectImp *toObject(ExecState *exec) const;
+ JSObject *toObject(ExecState *exec) const;
private:
bool val;
};
- class StringImp : public AllocatedValueImp {
+ class StringImp : public JSCell {
public:
StringImp(const UString& v) : val(v) { }
UString value() const { return val; }
Type type() const { return StringType; }
- ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ JSValue *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- ObjectImp *toObject(ExecState *exec) const;
+ JSObject *toObject(ExecState *exec) const;
private:
UString val;
};
- class NumberImp : public AllocatedValueImp {
+ class NumberImp : public JSCell {
friend class ConstantValues;
friend class InterpreterImp;
- friend ValueImp *jsNumber(double);
+ friend JSValue *jsNumber(double);
public:
double value() const { return val; }
Type type() const { return NumberType; }
- ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
+ JSValue *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const;
bool toBoolean(ExecState *exec) const;
double toNumber(ExecState *exec) const;
UString toString(ExecState *exec) const;
- ObjectImp *toObject(ExecState *exec) const;
+ JSObject *toObject(ExecState *exec) const;
private:
NumberImp(double v) : val(v) { }
class SavedBuiltinsInternal {
friend class InterpreterImp;
private:
- ProtectedPtr<ObjectImp> b_Object;
- ProtectedPtr<ObjectImp> b_Function;
- ProtectedPtr<ObjectImp> b_Array;
- ProtectedPtr<ObjectImp> b_Boolean;
- ProtectedPtr<ObjectImp> b_String;
- ProtectedPtr<ObjectImp> b_Number;
- ProtectedPtr<ObjectImp> b_Date;
- ProtectedPtr<ObjectImp> b_RegExp;
- ProtectedPtr<ObjectImp> b_Error;
-
- ProtectedPtr<ObjectImp> b_ObjectPrototype;
- ProtectedPtr<ObjectImp> b_FunctionPrototype;
- ProtectedPtr<ObjectImp> b_ArrayPrototype;
- ProtectedPtr<ObjectImp> b_BooleanPrototype;
- ProtectedPtr<ObjectImp> b_StringPrototype;
- ProtectedPtr<ObjectImp> b_NumberPrototype;
- ProtectedPtr<ObjectImp> b_DatePrototype;
- ProtectedPtr<ObjectImp> b_RegExpPrototype;
- ProtectedPtr<ObjectImp> b_ErrorPrototype;
-
- ProtectedPtr<ObjectImp> b_evalError;
- ProtectedPtr<ObjectImp> b_rangeError;
- ProtectedPtr<ObjectImp> b_referenceError;
- ProtectedPtr<ObjectImp> b_syntaxError;
- ProtectedPtr<ObjectImp> b_typeError;
- ProtectedPtr<ObjectImp> b_uriError;
-
- ProtectedPtr<ObjectImp> b_evalErrorPrototype;
- ProtectedPtr<ObjectImp> b_rangeErrorPrototype;
- ProtectedPtr<ObjectImp> b_referenceErrorPrototype;
- ProtectedPtr<ObjectImp> b_syntaxErrorPrototype;
- ProtectedPtr<ObjectImp> b_typeErrorPrototype;
- ProtectedPtr<ObjectImp> b_uriErrorPrototype;
+ ProtectedPtr<JSObject> b_Object;
+ ProtectedPtr<JSObject> b_Function;
+ ProtectedPtr<JSObject> b_Array;
+ ProtectedPtr<JSObject> b_Boolean;
+ ProtectedPtr<JSObject> b_String;
+ ProtectedPtr<JSObject> b_Number;
+ ProtectedPtr<JSObject> b_Date;
+ ProtectedPtr<JSObject> b_RegExp;
+ ProtectedPtr<JSObject> b_Error;
+
+ ProtectedPtr<JSObject> b_ObjectPrototype;
+ ProtectedPtr<JSObject> b_FunctionPrototype;
+ ProtectedPtr<JSObject> b_ArrayPrototype;
+ ProtectedPtr<JSObject> b_BooleanPrototype;
+ ProtectedPtr<JSObject> b_StringPrototype;
+ ProtectedPtr<JSObject> b_NumberPrototype;
+ ProtectedPtr<JSObject> b_DatePrototype;
+ ProtectedPtr<JSObject> b_RegExpPrototype;
+ ProtectedPtr<JSObject> b_ErrorPrototype;
+
+ ProtectedPtr<JSObject> b_evalError;
+ ProtectedPtr<JSObject> b_rangeError;
+ ProtectedPtr<JSObject> b_referenceError;
+ ProtectedPtr<JSObject> b_syntaxError;
+ ProtectedPtr<JSObject> b_typeError;
+ ProtectedPtr<JSObject> b_uriError;
+
+ ProtectedPtr<JSObject> b_evalErrorPrototype;
+ ProtectedPtr<JSObject> b_rangeErrorPrototype;
+ ProtectedPtr<JSObject> b_referenceErrorPrototype;
+ ProtectedPtr<JSObject> b_syntaxErrorPrototype;
+ ProtectedPtr<JSObject> b_typeErrorPrototype;
+ ProtectedPtr<JSObject> b_uriErrorPrototype;
};
class InterpreterImp {
friend class Collector;
public:
- InterpreterImp(Interpreter *interp, ObjectImp *glob);
+ InterpreterImp(Interpreter *interp, JSObject *glob);
~InterpreterImp();
- ObjectImp *globalObject() { return global; }
+ JSObject *globalObject() { return global; }
Interpreter *interpreter() const { return m_interpreter; }
void initGlobalObject();
ExecState *globalExec() { return &globExec; }
bool checkSyntax(const UString &code);
- Completion evaluate(const UString &code, ValueImp *thisV, const UString &sourceURL, int startingLineNumber);
+ Completion evaluate(const UString &code, JSValue *thisV, const UString &sourceURL, int startingLineNumber);
Debugger *debugger() const { return dbg; }
void setDebugger(Debugger *d) { dbg = d; }
- ObjectImp *builtinObject() const { return b_Object; }
- ObjectImp *builtinFunction() const { return b_Function; }
- ObjectImp *builtinArray() const { return b_Array; }
- ObjectImp *builtinBoolean() const { return b_Boolean; }
- ObjectImp *builtinString() const { return b_String; }
- ObjectImp *builtinNumber() const { return b_Number; }
- ObjectImp *builtinDate() const { return b_Date; }
- ObjectImp *builtinRegExp() const { return b_RegExp; }
- ObjectImp *builtinError() const { return b_Error; }
-
- ObjectImp *builtinObjectPrototype() const { return b_ObjectPrototype; }
- ObjectImp *builtinFunctionPrototype() const { return b_FunctionPrototype; }
- ObjectImp *builtinArrayPrototype() const { return b_ArrayPrototype; }
- ObjectImp *builtinBooleanPrototype() const { return b_BooleanPrototype; }
- ObjectImp *builtinStringPrototype() const { return b_StringPrototype; }
- ObjectImp *builtinNumberPrototype() const { return b_NumberPrototype; }
- ObjectImp *builtinDatePrototype() const { return b_DatePrototype; }
- ObjectImp *builtinRegExpPrototype() const { return b_RegExpPrototype; }
- ObjectImp *builtinErrorPrototype() const { return b_ErrorPrototype; }
-
- ObjectImp *builtinEvalError() const { return b_evalError; }
- ObjectImp *builtinRangeError() const { return b_rangeError; }
- ObjectImp *builtinReferenceError() const { return b_referenceError; }
- ObjectImp *builtinSyntaxError() const { return b_syntaxError; }
- ObjectImp *builtinTypeError() const { return b_typeError; }
- ObjectImp *builtinURIError() const { return b_uriError; }
-
- ObjectImp *builtinEvalErrorPrototype() const { return b_evalErrorPrototype; }
- ObjectImp *builtinRangeErrorPrototype() const { return b_rangeErrorPrototype; }
- ObjectImp *builtinReferenceErrorPrototype() const { return b_referenceErrorPrototype; }
- ObjectImp *builtinSyntaxErrorPrototype() const { return b_syntaxErrorPrototype; }
- ObjectImp *builtinTypeErrorPrototype() const { return b_typeErrorPrototype; }
- ObjectImp *builtinURIErrorPrototype() const { return b_uriErrorPrototype; }
+ JSObject *builtinObject() const { return b_Object; }
+ JSObject *builtinFunction() const { return b_Function; }
+ JSObject *builtinArray() const { return b_Array; }
+ JSObject *builtinBoolean() const { return b_Boolean; }
+ JSObject *builtinString() const { return b_String; }
+ JSObject *builtinNumber() const { return b_Number; }
+ JSObject *builtinDate() const { return b_Date; }
+ JSObject *builtinRegExp() const { return b_RegExp; }
+ JSObject *builtinError() const { return b_Error; }
+
+ JSObject *builtinObjectPrototype() const { return b_ObjectPrototype; }
+ JSObject *builtinFunctionPrototype() const { return b_FunctionPrototype; }
+ JSObject *builtinArrayPrototype() const { return b_ArrayPrototype; }
+ JSObject *builtinBooleanPrototype() const { return b_BooleanPrototype; }
+ JSObject *builtinStringPrototype() const { return b_StringPrototype; }
+ JSObject *builtinNumberPrototype() const { return b_NumberPrototype; }
+ JSObject *builtinDatePrototype() const { return b_DatePrototype; }
+ JSObject *builtinRegExpPrototype() const { return b_RegExpPrototype; }
+ JSObject *builtinErrorPrototype() const { return b_ErrorPrototype; }
+
+ JSObject *builtinEvalError() const { return b_evalError; }
+ JSObject *builtinRangeError() const { return b_rangeError; }
+ JSObject *builtinReferenceError() const { return b_referenceError; }
+ JSObject *builtinSyntaxError() const { return b_syntaxError; }
+ JSObject *builtinTypeError() const { return b_typeError; }
+ JSObject *builtinURIError() const { return b_uriError; }
+
+ JSObject *builtinEvalErrorPrototype() const { return b_evalErrorPrototype; }
+ JSObject *builtinRangeErrorPrototype() const { return b_rangeErrorPrototype; }
+ JSObject *builtinReferenceErrorPrototype() const { return b_referenceErrorPrototype; }
+ JSObject *builtinSyntaxErrorPrototype() const { return b_syntaxErrorPrototype; }
+ JSObject *builtinTypeErrorPrototype() const { return b_typeErrorPrototype; }
+ JSObject *builtinURIErrorPrototype() const { return b_uriErrorPrototype; }
void setCompatMode(Interpreter::CompatMode mode) { m_compatMode = mode; }
Interpreter::CompatMode compatMode() const { return m_compatMode; }
InterpreterImp *nextInterpreter() const { return next; }
InterpreterImp *prevInterpreter() const { return prev; }
- static InterpreterImp *interpreterWithGlobalObject(ObjectImp *);
+ static InterpreterImp *interpreterWithGlobalObject(JSObject *);
void setContext(ContextImp *c) { _context = c; }
ContextImp *context() const { return _context; }
private:
void clear();
Interpreter *m_interpreter;
- ObjectImp *global;
+ JSObject *global;
Debugger *dbg;
// Built-in properties of the object prototype. These are accessible
// from here even if they are replaced by js code (e.g. assigning to
// Array.prototype)
- ProtectedPtr<ObjectImp> b_Object;
- ProtectedPtr<ObjectImp> b_Function;
- ProtectedPtr<ObjectImp> b_Array;
- ProtectedPtr<ObjectImp> b_Boolean;
- ProtectedPtr<ObjectImp> b_String;
- ProtectedPtr<ObjectImp> b_Number;
- ProtectedPtr<ObjectImp> b_Date;
- ProtectedPtr<ObjectImp> b_RegExp;
- ProtectedPtr<ObjectImp> b_Error;
-
- ProtectedPtr<ObjectImp> b_ObjectPrototype;
- ProtectedPtr<ObjectImp> b_FunctionPrototype;
- ProtectedPtr<ObjectImp> b_ArrayPrototype;
- ProtectedPtr<ObjectImp> b_BooleanPrototype;
- ProtectedPtr<ObjectImp> b_StringPrototype;
- ProtectedPtr<ObjectImp> b_NumberPrototype;
- ProtectedPtr<ObjectImp> b_DatePrototype;
- ProtectedPtr<ObjectImp> b_RegExpPrototype;
- ProtectedPtr<ObjectImp> b_ErrorPrototype;
-
- ProtectedPtr<ObjectImp> b_evalError;
- ProtectedPtr<ObjectImp> b_rangeError;
- ProtectedPtr<ObjectImp> b_referenceError;
- ProtectedPtr<ObjectImp> b_syntaxError;
- ProtectedPtr<ObjectImp> b_typeError;
- ProtectedPtr<ObjectImp> b_uriError;
-
- ProtectedPtr<ObjectImp> b_evalErrorPrototype;
- ProtectedPtr<ObjectImp> b_rangeErrorPrototype;
- ProtectedPtr<ObjectImp> b_referenceErrorPrototype;
- ProtectedPtr<ObjectImp> b_syntaxErrorPrototype;
- ProtectedPtr<ObjectImp> b_typeErrorPrototype;
- ProtectedPtr<ObjectImp> b_uriErrorPrototype;
+ ProtectedPtr<JSObject> b_Object;
+ ProtectedPtr<JSObject> b_Function;
+ ProtectedPtr<JSObject> b_Array;
+ ProtectedPtr<JSObject> b_Boolean;
+ ProtectedPtr<JSObject> b_String;
+ ProtectedPtr<JSObject> b_Number;
+ ProtectedPtr<JSObject> b_Date;
+ ProtectedPtr<JSObject> b_RegExp;
+ ProtectedPtr<JSObject> b_Error;
+
+ ProtectedPtr<JSObject> b_ObjectPrototype;
+ ProtectedPtr<JSObject> b_FunctionPrototype;
+ ProtectedPtr<JSObject> b_ArrayPrototype;
+ ProtectedPtr<JSObject> b_BooleanPrototype;
+ ProtectedPtr<JSObject> b_StringPrototype;
+ ProtectedPtr<JSObject> b_NumberPrototype;
+ ProtectedPtr<JSObject> b_DatePrototype;
+ ProtectedPtr<JSObject> b_RegExpPrototype;
+ ProtectedPtr<JSObject> b_ErrorPrototype;
+
+ ProtectedPtr<JSObject> b_evalError;
+ ProtectedPtr<JSObject> b_rangeError;
+ ProtectedPtr<JSObject> b_referenceError;
+ ProtectedPtr<JSObject> b_syntaxError;
+ ProtectedPtr<JSObject> b_typeError;
+ ProtectedPtr<JSObject> b_uriError;
+
+ ProtectedPtr<JSObject> b_evalErrorPrototype;
+ ProtectedPtr<JSObject> b_rangeErrorPrototype;
+ ProtectedPtr<JSObject> b_referenceErrorPrototype;
+ ProtectedPtr<JSObject> b_syntaxErrorPrototype;
+ ProtectedPtr<JSObject> b_typeErrorPrototype;
+ ProtectedPtr<JSObject> b_uriErrorPrototype;
ExecState globExec;
Interpreter::CompatMode m_compatMode;
- class InternalFunctionImp : public ObjectImp {
+ class InternalFunctionImp : public JSObject {
public:
InternalFunctionImp();
- InternalFunctionImp(FunctionPrototypeImp *funcProto);
+ InternalFunctionImp(FunctionPrototype *funcProto);
bool implementsHasInstance() const;
- bool hasInstance(ExecState *exec, ValueImp *value);
+ bool hasInstance(ExecState *exec, JSValue *value);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
};
// helper function for toInteger, toInt32, toUInt32 and toUInt16
- double roundValue(ExecState *, ValueImp *);
+ double roundValue(ExecState *, JSValue *);
#ifndef NDEBUG
- void printInfo(ExecState *exec, const char *s, ValueImp *, int lineno = -1);
+ void printInfo(ExecState *exec, const char *s, JSValue *, int lineno = -1);
#endif
inline LabelStack::~LabelStack()
return rep->scopeChain();
}
-ObjectImp *Context::variableObject() const
+JSObject *Context::variableObject() const
{
return rep->variableObject();
}
-ObjectImp *Context::thisValue() const
+JSObject *Context::thisValue() const
{
return rep->thisValue();
}
// ------------------------------ Interpreter ----------------------------------
-Interpreter::Interpreter(ObjectImp *global)
+Interpreter::Interpreter(JSObject *global)
: rep(0)
, m_argumentsPropertyName(&argumentsPropertyName)
, m_specialPrototypePropertyName(&specialPrototypePropertyName)
, m_argumentsPropertyName(&argumentsPropertyName)
, m_specialPrototypePropertyName(&specialPrototypePropertyName)
{
- rep = new InterpreterImp(this, new ObjectImp);
+ rep = new InterpreterImp(this, new JSObject);
}
Interpreter::~Interpreter()
delete rep;
}
-ObjectImp *Interpreter::globalObject() const
+JSObject *Interpreter::globalObject() const
{
return rep->globalObject();
}
return rep->checkSyntax(code);
}
-Completion Interpreter::evaluate(const UString &code, ValueImp *thisV, const UString &)
+Completion Interpreter::evaluate(const UString &code, JSValue *thisV, const UString &)
{
return evaluate(UString(), 0, code, thisV);
}
-Completion Interpreter::evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, ValueImp *thisV)
+Completion Interpreter::evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, JSValue *thisV)
{
Completion comp = rep->evaluate(code,thisV, sourceURL, startingLineNumber);
return comp;
}
-ObjectImp *Interpreter::builtinObject() const
+JSObject *Interpreter::builtinObject() const
{
return rep->builtinObject();
}
-ObjectImp *Interpreter::builtinFunction() const
+JSObject *Interpreter::builtinFunction() const
{
return rep->builtinFunction();
}
-ObjectImp *Interpreter::builtinArray() const
+JSObject *Interpreter::builtinArray() const
{
return rep->builtinArray();
}
-ObjectImp *Interpreter::builtinBoolean() const
+JSObject *Interpreter::builtinBoolean() const
{
return rep->builtinBoolean();
}
-ObjectImp *Interpreter::builtinString() const
+JSObject *Interpreter::builtinString() const
{
return rep->builtinString();
}
-ObjectImp *Interpreter::builtinNumber() const
+JSObject *Interpreter::builtinNumber() const
{
return rep->builtinNumber();
}
-ObjectImp *Interpreter::builtinDate() const
+JSObject *Interpreter::builtinDate() const
{
return rep->builtinDate();
}
-ObjectImp *Interpreter::builtinRegExp() const
+JSObject *Interpreter::builtinRegExp() const
{
return rep->builtinRegExp();
}
-ObjectImp *Interpreter::builtinError() const
+JSObject *Interpreter::builtinError() const
{
return rep->builtinError();
}
-ObjectImp *Interpreter::builtinObjectPrototype() const
+JSObject *Interpreter::builtinObjectPrototype() const
{
return rep->builtinObjectPrototype();
}
-ObjectImp *Interpreter::builtinFunctionPrototype() const
+JSObject *Interpreter::builtinFunctionPrototype() const
{
return rep->builtinFunctionPrototype();
}
-ObjectImp *Interpreter::builtinArrayPrototype() const
+JSObject *Interpreter::builtinArrayPrototype() const
{
return rep->builtinArrayPrototype();
}
-ObjectImp *Interpreter::builtinBooleanPrototype() const
+JSObject *Interpreter::builtinBooleanPrototype() const
{
return rep->builtinBooleanPrototype();
}
-ObjectImp *Interpreter::builtinStringPrototype() const
+JSObject *Interpreter::builtinStringPrototype() const
{
return rep->builtinStringPrototype();
}
-ObjectImp *Interpreter::builtinNumberPrototype() const
+JSObject *Interpreter::builtinNumberPrototype() const
{
return rep->builtinNumberPrototype();
}
-ObjectImp *Interpreter::builtinDatePrototype() const
+JSObject *Interpreter::builtinDatePrototype() const
{
return rep->builtinDatePrototype();
}
-ObjectImp *Interpreter::builtinRegExpPrototype() const
+JSObject *Interpreter::builtinRegExpPrototype() const
{
return rep->builtinRegExpPrototype();
}
-ObjectImp *Interpreter::builtinErrorPrototype() const
+JSObject *Interpreter::builtinErrorPrototype() const
{
return rep->builtinErrorPrototype();
}
-ObjectImp *Interpreter::builtinEvalError() const
+JSObject *Interpreter::builtinEvalError() const
{
return rep->builtinEvalError();
}
-ObjectImp *Interpreter::builtinRangeError() const
+JSObject *Interpreter::builtinRangeError() const
{
return rep->builtinRangeError();
}
-ObjectImp *Interpreter::builtinReferenceError() const
+JSObject *Interpreter::builtinReferenceError() const
{
return rep->builtinReferenceError();
}
-ObjectImp *Interpreter::builtinSyntaxError() const
+JSObject *Interpreter::builtinSyntaxError() const
{
return rep->builtinSyntaxError();
}
-ObjectImp *Interpreter::builtinTypeError() const
+JSObject *Interpreter::builtinTypeError() const
{
return rep->builtinTypeError();
}
-ObjectImp *Interpreter::builtinURIError() const
+JSObject *Interpreter::builtinURIError() const
{
return rep->builtinURIError();
}
-ObjectImp *Interpreter::builtinEvalErrorPrototype() const
+JSObject *Interpreter::builtinEvalErrorPrototype() const
{
return rep->builtinEvalErrorPrototype();
}
-ObjectImp *Interpreter::builtinRangeErrorPrototype() const
+JSObject *Interpreter::builtinRangeErrorPrototype() const
{
return rep->builtinRangeErrorPrototype();
}
-ObjectImp *Interpreter::builtinReferenceErrorPrototype() const
+JSObject *Interpreter::builtinReferenceErrorPrototype() const
{
return rep->builtinReferenceErrorPrototype();
}
-ObjectImp *Interpreter::builtinSyntaxErrorPrototype() const
+JSObject *Interpreter::builtinSyntaxErrorPrototype() const
{
return rep->builtinSyntaxErrorPrototype();
}
-ObjectImp *Interpreter::builtinTypeErrorPrototype() const
+JSObject *Interpreter::builtinTypeErrorPrototype() const
{
return rep->builtinTypeErrorPrototype();
}
-ObjectImp *Interpreter::builtinURIErrorPrototype() const
+JSObject *Interpreter::builtinURIErrorPrototype() const
{
return rep->builtinURIErrorPrototype();
}
}
-void *Interpreter::createLanguageInstanceForValue(ExecState *exec, int language, ObjectImp *value, const Bindings::RootObject *origin, const Bindings::RootObject *current)
+void *Interpreter::createLanguageInstanceForValue(ExecState *exec, int language, JSObject *value, const Bindings::RootObject *origin, const Bindings::RootObject *current)
{
return Bindings::Instance::createLanguageInstanceForValue (exec, (Bindings::Instance::BindingLanguage)language, value, origin, current);
}
class ContextImp;
class InterpreterImp;
- class RuntimeMethodImp;
+ class RuntimeMethod;
class ScopeChain;
namespace Bindings {
*
* @return The execution context's variable object
*/
- ObjectImp *variableObject() const;
+ JSObject *variableObject() const;
/**
* Returns the "this" value for the execution context. This is the value
*
* @return The execution context's "this" value
*/
- ObjectImp *thisValue() const;
+ JSObject *thisValue() const;
/**
* Returns the context from which the current context was invoked. For
*
* @param global The object to use as the global object for this interpreter
*/
- Interpreter(ObjectImp *global);
+ Interpreter(JSObject *global);
/**
* Creates a new interpreter. A global object will be created and
* initialized with the standard global properties.
* Returns the object that is used as the global object during all script
* execution performed by this interpreter
*/
- ObjectImp *globalObject() const;
+ JSObject *globalObject() const;
void initGlobalObject();
* execution. This should either be jsNull() or an Object.
* @return A completion object representing the result of the execution.
*/
- Completion evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, ValueImp *thisV = NULL);
+ Completion evaluate(const UString &sourceURL, int startingLineNumber, const UString &code, JSValue *thisV = NULL);
// Overload of evaluate to keep JavaScriptGlue both source and binary compatible.
- Completion evaluate(const UString &code, ValueImp *thisV = NULL, const UString &sourceFilename = UString());
+ Completion evaluate(const UString &code, JSValue *thisV = NULL, const UString &sourceFilename = UString());
/**
* @internal
*
* @return The builtin "Object" object
*/
- ObjectImp *builtinObject() const;
+ JSObject *builtinObject() const;
/**
* Returns the builtin "Function" object.
*/
- ObjectImp *builtinFunction() const;
+ JSObject *builtinFunction() const;
/**
* Returns the builtin "Array" object.
*/
- ObjectImp *builtinArray() const;
+ JSObject *builtinArray() const;
/**
* Returns the builtin "Boolean" object.
*/
- ObjectImp *builtinBoolean() const;
+ JSObject *builtinBoolean() const;
/**
* Returns the builtin "String" object.
*/
- ObjectImp *builtinString() const;
+ JSObject *builtinString() const;
/**
* Returns the builtin "Number" object.
*/
- ObjectImp *builtinNumber() const;
+ JSObject *builtinNumber() const;
/**
* Returns the builtin "Date" object.
*/
- ObjectImp *builtinDate() const;
+ JSObject *builtinDate() const;
/**
* Returns the builtin "RegExp" object.
*/
- ObjectImp *builtinRegExp() const;
+ JSObject *builtinRegExp() const;
/**
* Returns the builtin "Error" object.
*/
- ObjectImp *builtinError() const;
+ JSObject *builtinError() const;
/**
* Returns the builtin "Object.prototype" object.
*/
- ObjectImp *builtinObjectPrototype() const;
+ JSObject *builtinObjectPrototype() const;
/**
* Returns the builtin "Function.prototype" object.
*/
- ObjectImp *builtinFunctionPrototype() const;
+ JSObject *builtinFunctionPrototype() const;
/**
* Returns the builtin "Array.prototype" object.
*/
- ObjectImp *builtinArrayPrototype() const;
+ JSObject *builtinArrayPrototype() const;
/**
* Returns the builtin "Boolean.prototype" object.
*/
- ObjectImp *builtinBooleanPrototype() const;
+ JSObject *builtinBooleanPrototype() const;
/**
* Returns the builtin "String.prototype" object.
*/
- ObjectImp *builtinStringPrototype() const;
+ JSObject *builtinStringPrototype() const;
/**
* Returns the builtin "Number.prototype" object.
*/
- ObjectImp *builtinNumberPrototype() const;
+ JSObject *builtinNumberPrototype() const;
/**
* Returns the builtin "Date.prototype" object.
*/
- ObjectImp *builtinDatePrototype() const;
+ JSObject *builtinDatePrototype() const;
/**
* Returns the builtin "RegExp.prototype" object.
*/
- ObjectImp *builtinRegExpPrototype() const;
+ JSObject *builtinRegExpPrototype() const;
/**
* Returns the builtin "Error.prototype" object.
*/
- ObjectImp *builtinErrorPrototype() const;
+ JSObject *builtinErrorPrototype() const;
/**
* The initial value of "Error" global property
*/
- ObjectImp *builtinEvalError() const;
- ObjectImp *builtinRangeError() const;
- ObjectImp *builtinReferenceError() const;
- ObjectImp *builtinSyntaxError() const;
- ObjectImp *builtinTypeError() const;
- ObjectImp *builtinURIError() const;
+ JSObject *builtinEvalError() const;
+ JSObject *builtinRangeError() const;
+ JSObject *builtinReferenceError() const;
+ JSObject *builtinSyntaxError() const;
+ JSObject *builtinTypeError() const;
+ JSObject *builtinURIError() const;
- ObjectImp *builtinEvalErrorPrototype() const;
- ObjectImp *builtinRangeErrorPrototype() const;
- ObjectImp *builtinReferenceErrorPrototype() const;
- ObjectImp *builtinSyntaxErrorPrototype() const;
- ObjectImp *builtinTypeErrorPrototype() const;
- ObjectImp *builtinURIErrorPrototype() const;
+ JSObject *builtinEvalErrorPrototype() const;
+ JSObject *builtinRangeErrorPrototype() const;
+ JSObject *builtinReferenceErrorPrototype() const;
+ JSObject *builtinSyntaxErrorPrototype() const;
+ JSObject *builtinTypeErrorPrototype() const;
+ JSObject *builtinURIErrorPrototype() const;
enum CompatMode { NativeMode, IECompat, NetscapeCompat };
/**
* is used to determine if an object is the Window object so we can perform
* security checks.
*/
- virtual bool isGlobalObject(ValueImp *v) { return false; }
+ virtual bool isGlobalObject(JSValue *v) { return false; }
/**
* Find the interpreter for a particular global object. This should really
* created in an application to correctly implement this method. The only
* override of this method is currently in WebCore.
*/
- virtual Interpreter *interpreterForGlobalObject (const ValueImp *imp) { return 0; }
+ virtual Interpreter *interpreterForGlobalObject (const JSValue *imp) { return 0; }
/**
* Determine if the it is 'safe' to execute code in the target interpreter from an
*/
virtual bool isSafeScript (const Interpreter *target) { return true; }
- virtual void *createLanguageInstanceForValue (ExecState *exec, int language, ObjectImp *value, const Bindings::RootObject *origin, const Bindings::RootObject *current);
+ virtual void *createLanguageInstanceForValue (ExecState *exec, int language, JSObject *value, const Bindings::RootObject *origin, const Bindings::RootObject *current);
#endif
// This is a workaround to avoid accessing the global variables for these identifiers in
friend class InterpreterImp;
friend class FunctionImp;
#if APPLE_CHANGES
- friend class RuntimeMethodImp;
+ friend class RuntimeMethod;
#endif
friend class GlobalFuncImp;
*/
Context context() const { return _context; }
- void setException(ValueImp *e) { _exception = e; }
+ void setException(JSValue *e) { _exception = e; }
void clearException() { _exception = NULL; }
- ValueImp *exception() const { return _exception; }
+ JSValue *exception() const { return _exception; }
bool hadException() const { return _exception; }
private:
: _interpreter(interp), _context(con), _exception(NULL) { }
Interpreter *_interpreter;
ContextImp *_context;
- ValueImp *_exception;
+ JSValue *_exception;
};
} // namespace
{
ListImpState state;
int capacity;
- ValueImp **overflow;
+ JSValue **overflow;
union {
- ValueImp *values[inlineValuesSize];
+ JSValue *values[inlineValuesSize];
ListImp *nextInFreeList;
};
}
}
-ValueImp *List::at(int i) const
+JSValue *List::at(int i) const
{
ListImp *imp = static_cast<ListImp *>(_impBase);
if ((unsigned)i >= (unsigned)imp->size)
_impBase->size = 0;
}
-void List::append(ValueImp *v)
+void List::append(JSValue *v)
{
ListImp *imp = static_cast<ListImp *>(_impBase);
if (i >= imp->capacity) {
int newCapacity = i * 2;
- ValueImp **newOverflow = new ValueImp * [newCapacity - inlineValuesSize];
- ValueImp **oldOverflow = imp->overflow;
+ JSValue **newOverflow = new JSValue * [newCapacity - inlineValuesSize];
+ JSValue **oldOverflow = imp->overflow;
int oldOverflowSize = i - inlineValuesSize;
for (int j = 0; j != oldOverflowSize; j++)
newOverflow[j] = oldOverflow[j];
for (int i = 0; i != inlineSize; ++i)
copy.append(imp->values[i]);
- ValueImp **overflow = imp->overflow;
+ JSValue **overflow = imp->overflow;
int overflowSize = size - inlineSize;
for (int i = 0; i != overflowSize; ++i)
copy.append(overflow[i]);
for (int i = 1; i < inlineSize; ++i)
copy.append(imp->values[i]);
- ValueImp **overflow = imp->overflow;
+ JSValue **overflow = imp->overflow;
int overflowSize = size - inlineSize;
for (int i = 0; i < overflowSize; ++i)
copy.append(overflow[i]);
*
* @param val Pointer to object.
*/
- void append(ValueImp *val);
+ void append(JSValue *val);
/**
* Remove all elements from the list.
*/
* @return Return the element at position i. KJS::Undefined if the
* index is out of range.
*/
- ValueImp *at(int i) const;
+ JSValue *at(int i) const;
/**
* Equivalent to at.
*/
- ValueImp *operator[](int i) const { return at(i); }
+ JSValue *operator[](int i) const { return at(i); }
/**
* Returns a pointer to a static instance of an empty list. Useful if a
* Dereference the iterator.
* @return A pointer to the element the iterator operates on.
*/
- ValueImp *operator->() const { return _list->at(_i); }
- ValueImp *operator*() const { return _list->at(_i); }
+ JSValue *operator->() const { return _list->at(_i); }
+ JSValue *operator*() const { return _list->at(_i); }
/**
* Prefix increment operator.
* @return The element after the increment.
*/
- ValueImp *operator++() { return _list->at(++_i); }
+ JSValue *operator++() { return _list->at(++_i); }
/**
* Postfix increment operator.
*/
- ValueImp *operator++(int) { return _list->at(_i++); }
+ JSValue *operator++(int) { return _list->at(_i++); }
/**
* Prefix decrement operator.
*/
- ValueImp *operator--() { return _list->at(--_i); }
+ JSValue *operator--() { return _list->at(--_i); }
/**
* Postfix decrement operator.
*/
- ValueImp *operator--(int) { return _list->at(_i--); }
+ JSValue *operator--(int) { return _list->at(_i--); }
/**
* Compare the iterator with another one.
* @return True if the two iterators operate on the same list element.
* Helper for getStaticFunctionSlot and getStaticPropertySlot
*/
template <class FuncImp>
- inline ValueImp *staticFunctionGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+ inline JSValue *staticFunctionGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
{
- // Look for cached value in dynamic map of properties (in ObjectImp)
- ObjectImp *thisObj = slot.slotBase();
- ValueImp *cachedVal = thisObj->getDirect(propertyName);
+ // Look for cached value in dynamic map of properties (in JSObject)
+ JSObject *thisObj = slot.slotBase();
+ JSValue *cachedVal = thisObj->getDirect(propertyName);
if (cachedVal)
return cachedVal;
const HashEntry *entry = slot.staticEntry();
- ValueImp *val = new FuncImp(exec, entry->value, entry->params);
+ JSValue *val = new FuncImp(exec, entry->value, entry->params);
thisObj->putDirect(propertyName, val, entry->attr);
return val;
}
* Helper for getStaticValueSlot and getStaticPropertySlot
*/
template <class ThisImp>
- inline ValueImp *staticValueGetter(ExecState *exec, const Identifier&, const PropertySlot& slot)
+ inline JSValue *staticValueGetter(ExecState *exec, const Identifier&, const PropertySlot& slot)
{
ThisImp *thisObj = static_cast<ThisImp *>(slot.slotBase());
const HashEntry *entry = slot.staticEntry();
*/
template <class FuncImp, class ParentImp>
inline bool getStaticFunctionSlot(ExecState *exec, const HashTable *table,
- ObjectImp* thisObj, const Identifier& propertyName, PropertySlot& slot)
+ JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot)
{
const HashEntry* entry = Lookup::findEntry(table, propertyName);
*/
template <class ThisImp, class ParentImp>
inline void lookupPut(ExecState *exec, const Identifier &propertyName,
- ValueImp *value, int attr,
+ JSValue *value, int attr,
const HashTable* table, ThisImp* thisObj)
{
const HashEntry* entry = Lookup::findEntry(table, propertyName);
if (!entry) // not found: forward to parent
thisObj->ParentImp::put(exec, propertyName, value, attr);
else if (entry->attr & Function) // function: put as override property
- thisObj->ObjectImp::put(exec, propertyName, value, attr);
+ thisObj->JSObject::put(exec, propertyName, value, attr);
else if (entry->attr & ReadOnly) // readonly! Can't put!
#ifdef KJS_VERBOSE
fprintf(stderr,"WARNING: Attempt to change value of readonly property '%s'\n",propertyName.ascii());
* that cached object. Note that the object constructor must take 1 argument, exec.
*/
template <class ClassCtor>
- inline ObjectImp *cacheGlobalObject(ExecState *exec, const Identifier &propertyName)
+ inline JSObject *cacheGlobalObject(ExecState *exec, const Identifier &propertyName)
{
- ObjectImp *globalObject = static_cast<ObjectImp *>(exec->lexicalInterpreter()->globalObject());
- ValueImp *obj = globalObject->getDirect(propertyName);
+ JSObject *globalObject = static_cast<JSObject *>(exec->lexicalInterpreter()->globalObject());
+ JSValue *obj = globalObject->getDirect(propertyName);
if (obj) {
assert(obj->isObject());
- return static_cast<ObjectImp *>(obj);
+ return static_cast<JSObject *>(obj);
}
- ObjectImp *newObject = new ClassCtor(exec);
+ JSObject *newObject = new ClassCtor(exec);
globalObject->put(exec, propertyName, newObject, Internal);
return newObject;
}
* then the last line will use IMPLEMENT_PROTOTYPE_WITH_PARENT, with DOMNodeProto as last argument.
*/
#define DEFINE_PROTOTYPE(ClassName,ClassProto) \
- class ClassProto : public ObjectImp { \
- friend ObjectImp *cacheGlobalObject<ClassProto>(ExecState *exec, const Identifier &propertyName); \
+ class ClassProto : public JSObject { \
+ friend JSObject *cacheGlobalObject<ClassProto>(ExecState *exec, const Identifier &propertyName); \
public: \
- static ObjectImp *self(ExecState *exec) \
+ static JSObject *self(ExecState *exec) \
{ \
return cacheGlobalObject<ClassProto>(exec, "[[" ClassName ".prototype]]"); \
} \
protected: \
ClassProto( ExecState *exec ) \
- : ObjectImp( exec->lexicalInterpreter()->builtinObjectPrototype() ) {} \
+ : JSObject( exec->lexicalInterpreter()->builtinObjectPrototype() ) {} \
\
public: \
virtual const ClassInfo *classInfo() const { return &info; } \
#define IMPLEMENT_PROTOTYPE(ClassProto,ClassFunc) \
bool ClassProto::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) \
{ \
- return getStaticFunctionSlot<ClassFunc,ObjectImp>(exec, &ClassProto##Table, this, propertyName, slot); \
+ return getStaticFunctionSlot<ClassFunc,JSObject>(exec, &ClassProto##Table, this, propertyName, slot); \
}
#define IMPLEMENT_PROTOTYPE_WITH_PARENT(ClassProto,ClassFunc,ParentProto) \
bool ClassProto::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) \
{ \
- if (getStaticFunctionSlot<ClassFunc,ObjectImp>(exec, &ClassProto##Table, this, propertyName, slot)) \
+ if (getStaticFunctionSlot<ClassFunc,JSObject>(exec, &ClassProto##Table, this, propertyName, slot)) \
return true; \
return ParentProto::self(exec)->getOwnPropertySlot(exec, propertyName, slot); \
}
put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum); \
} \
/* Macro user needs to implement the callAsFunction function. */ \
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args); \
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); \
private: \
int id; \
};
*/
MathObjectImp::MathObjectImp(ExecState * /*exec*/,
- ObjectPrototypeImp *objProto)
- : ObjectImp(objProto)
+ ObjectPrototype *objProto)
+ : JSObject(objProto)
{
}
bool MathObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
{
- return getStaticPropertySlot<MathFuncImp, MathObjectImp, ObjectImp>(exec, &mathTable, this, propertyName, slot);
+ return getStaticPropertySlot<MathFuncImp, MathObjectImp, JSObject>(exec, &mathTable, this, propertyName, slot);
}
-ValueImp *MathObjectImp::getValueProperty(ExecState *, int token) const
+JSValue *MathObjectImp::getValueProperty(ExecState *, int token) const
{
double d = -42; // ;)
switch (token) {
MathFuncImp::MathFuncImp(ExecState *exec, int i, int l)
: InternalFunctionImp(
- static_cast<FunctionPrototypeImp*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
+ static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
), id(i)
{
putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
return true;
}
-ValueImp *MathFuncImp::callAsFunction(ExecState *exec, ObjectImp */*thisObj*/, const List &args)
+JSValue *MathFuncImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
{
double arg = args[0]->toNumber(exec);
double arg2 = args[1]->toNumber(exec);
namespace KJS {
- class MathObjectImp : public ObjectImp {
+ class MathObjectImp : public JSObject {
public:
MathObjectImp(ExecState *exec,
- ObjectPrototypeImp *objProto);
+ ObjectPrototype *objProto);
bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
- ValueImp *getValueProperty(ExecState *exec, int token) const;
+ JSValue *getValueProperty(ExecState *exec, int token) const;
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
enum { Euler, Ln2, Ln10, Log2E, Log10E, Pi, Sqrt1_2, Sqrt2,
public:
MathFuncImp(ExecState *exec, int i, int l);
virtual bool implementsCall() const;
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
+ virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
private:
int id;
};
#define KJS_CHECKEXCEPTION \
if (exec->hadException()) { \
setExceptionDetailsIfNeeded(exec); \
- ValueImp *ex = exec->exception(); \
+ JSValue *ex = exec->exception(); \
exec->clearException(); \
return Completion(Throw, ex); \
} \
return Completion(Throw, Error::create(exec, e, message, lineNo(), sourceId(), &sourceURL));
}
-ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg)
+JSValue *Node::throwError(ExecState *exec, ErrorType e, const char *msg)
{
return KJS::throwError(exec, e, msg, lineNo(), sourceId(), &sourceURL);
}
-ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr)
+JSValue *Node::throwError(ExecState *exec, ErrorType e, const char *msg, JSValue *v, Node *expr)
{
UString message = msg;
substitute(message, v->toString(exec));
}
-ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, const Identifier &label)
+JSValue *Node::throwError(ExecState *exec, ErrorType e, const char *msg, const Identifier &label)
{
UString message = msg;
substitute(message, label.ustring());
return KJS::throwError(exec, e, message, lineNo(), sourceId(), &sourceURL);
}
-ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *e1, Node *e2)
+JSValue *Node::throwError(ExecState *exec, ErrorType e, const char *msg, JSValue *v, Node *e1, Node *e2)
{
UString message = msg;
substitute(message, v->toString(exec));
return KJS::throwError(exec, e, message, lineNo(), sourceId(), &sourceURL);
}
-ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, Node *expr, const Identifier &label)
+JSValue *Node::throwError(ExecState *exec, ErrorType e, const char *msg, JSValue *v, Node *expr, const Identifier &label)
{
UString message = msg;
substitute(message, v->toString(exec));
return KJS::throwError(exec, e, message, lineNo(), sourceId(), &sourceURL);
}
-ValueImp *Node::throwError(ExecState *exec, ErrorType e, const char *msg, ValueImp *v, const Identifier &label)
+JSValue *Node::throwError(ExecState *exec, ErrorType e, const char *msg, JSValue *v, const Identifier &label)
{
UString message = msg;
substitute(message, v->toString(exec));
return KJS::throwError(exec, e, message, lineNo(), sourceId(), &sourceURL);
}
-ValueImp *Node::throwUndefinedVariableError(ExecState *exec, const Identifier &ident)
+JSValue *Node::throwUndefinedVariableError(ExecState *exec, const Identifier &ident)
{
return throwError(exec, ReferenceError, "Can't find variable: %s", ident);
}
void Node::setExceptionDetailsIfNeeded(ExecState *exec)
{
- ValueImp *exceptionValue = exec->exception();
+ JSValue *exceptionValue = exec->exception();
if (exceptionValue->isObject()) {
- ObjectImp *exception = static_cast<ObjectImp *>(exceptionValue);
+ JSObject *exception = static_cast<JSObject *>(exceptionValue);
if (!exception->hasProperty(exec, "line") && !exception->hasProperty(exec, "sourceURL")) {
exception->put(exec, "line", jsNumber(line));
exception->put(exec, "sourceURL", jsString(sourceURL));
// ------------------------------ NullNode -------------------------------------
-ValueImp *NullNode::evaluate(ExecState *)
+JSValue *NullNode::evaluate(ExecState *)
{
return jsNull();
}
// ------------------------------ BooleanNode ----------------------------------
-ValueImp *BooleanNode::evaluate(ExecState *)
+JSValue *BooleanNode::evaluate(ExecState *)
{
return jsBoolean(value);
}
// ------------------------------ NumberNode -----------------------------------
-ValueImp *NumberNode::evaluate(ExecState *)
+JSValue *NumberNode::evaluate(ExecState *)
{
return jsNumber(value);
}
// ------------------------------ StringNode -----------------------------------
-ValueImp *StringNode::evaluate(ExecState *)
+JSValue *StringNode::evaluate(ExecState *)
{
return jsString(value);
}
// ------------------------------ RegExpNode -----------------------------------
-ValueImp *RegExpNode::evaluate(ExecState *exec)
+JSValue *RegExpNode::evaluate(ExecState *exec)
{
List list;
list.append(jsString(pattern));
list.append(jsString(flags));
- ObjectImp *reg = exec->lexicalInterpreter()->imp()->builtinRegExp();
+ JSObject *reg = exec->lexicalInterpreter()->imp()->builtinRegExp();
return reg->construct(exec,list);
}
// ------------------------------ ThisNode -------------------------------------
// ECMA 11.1.1
-ValueImp *ThisNode::evaluate(ExecState *exec)
+JSValue *ThisNode::evaluate(ExecState *exec)
{
return exec->context().imp()->thisValue();
}
// ------------------------------ ResolveNode ----------------------------------
// ECMA 11.1.2 & 10.1.4
-ValueImp *ResolveNode::evaluate(ExecState *exec)
+JSValue *ResolveNode::evaluate(ExecState *exec)
{
const ScopeChain& chain = exec->context().imp()->scopeChain();
ScopeChainIterator iter = chain.begin();
PropertySlot slot;
do {
- ObjectImp *o = *iter;
+ JSObject *o = *iter;
if (o->getPropertySlot(exec, ident, slot))
return slot.getValue(exec, ident);
// ------------------------------ GroupNode ------------------------------------
// ECMA 11.1.6
-ValueImp *GroupNode::evaluate(ExecState *exec)
+JSValue *GroupNode::evaluate(ExecState *exec)
{
return group->evaluate(exec);
}
// ------------------------------ ElementNode ----------------------------------
// ECMA 11.1.4
-ValueImp *ElementNode::evaluate(ExecState *exec)
+JSValue *ElementNode::evaluate(ExecState *exec)
{
- ObjectImp *array = exec->lexicalInterpreter()->builtinArray()->construct(exec, List::empty());
+ JSObject *array = exec->lexicalInterpreter()->builtinArray()->construct(exec, List::empty());
int length = 0;
for (ElementNode *n = this; n; n = n->list.get()) {
- ValueImp *val = n->node->evaluate(exec);
+ JSValue *val = n->node->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
length += n->elision;
array->put(exec, length++, val);
// ------------------------------ ArrayNode ------------------------------------
// ECMA 11.1.4
-ValueImp *ArrayNode::evaluate(ExecState *exec)
+JSValue *ArrayNode::evaluate(ExecState *exec)
{
- ObjectImp *array;
+ JSObject *array;
int length;
if (element) {
- array = static_cast<ObjectImp*>(element->evaluate(exec));
+ array = static_cast<JSObject*>(element->evaluate(exec));
KJS_CHECKEXCEPTIONVALUE
length = opt ? array->get(exec,lengthPropertyName)->toInt32(exec) : 0;
} else {
- ValueImp *newArr = exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty());
- array = static_cast<ObjectImp*>(newArr);
+ JSValue *newArr = exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty());
+ array = static_cast<JSObject*>(newArr);
length = 0;
}
// ------------------------------ ObjectLiteralNode ----------------------------
// ECMA 11.1.5
-ValueImp *ObjectLiteralNode::evaluate(ExecState *exec)
+JSValue *ObjectLiteralNode::evaluate(ExecState *exec)
{
if (list)
return list->evaluate(exec);
// ------------------------------ PropertyValueNode ----------------------------
// ECMA 11.1.5
-ValueImp *PropertyValueNode::evaluate(ExecState *exec)
+JSValue *PropertyValueNode::evaluate(ExecState *exec)
{
- ObjectImp *obj = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
+ JSObject *obj = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
for (PropertyValueNode *p = this; p; p = p->list.get()) {
- ValueImp *n = p->name->evaluate(exec);
+ JSValue *n = p->name->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- ValueImp *v = p->assign->evaluate(exec);
+ JSValue *v = p->assign->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
obj->put(exec, Identifier(n->toString(exec)), v);
// ------------------------------ PropertyNode ---------------------------------
// ECMA 11.1.5
-ValueImp *PropertyNode::evaluate(ExecState *)
+JSValue *PropertyNode::evaluate(ExecState *)
{
- ValueImp *s;
+ JSValue *s;
if (str.isNull()) {
s = jsString(UString::from(numeric));
// ------------------------------ BracketAccessorNode --------------------------------
// ECMA 11.2.1a
-ValueImp *BracketAccessorNode::evaluate(ExecState *exec)
+JSValue *BracketAccessorNode::evaluate(ExecState *exec)
{
- ValueImp *v1 = expr1->evaluate(exec);
+ JSValue *v1 = expr1->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- ValueImp *v2 = expr2->evaluate(exec);
+ JSValue *v2 = expr2->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
- ObjectImp *o = v1->toObject(exec);
+ JSObject *o = v1->toObject(exec);
uint32_t i;
if (v2->getUInt32(i))
return o->get(exec, i);
// ------------------------------ DotAccessorNode --------------------------------
// ECMA 11.2.1b
-ValueImp *DotAccessorNode::evaluate(ExecState *exec)
+JSValue *DotAccessorNode::evaluate(ExecState *exec)
{
- ValueImp *v = expr->evaluate(exec);
+ JSValue *v = expr->evaluate(exec);
KJS_CHECKEXCEPTIONVALUE
return v->toObject(exec)->get(exec, ident);
// ------------------------------ ArgumentListNode -----------------------------
-ValueImp *ArgumentListNode::evaluate(ExecState *)
+JSValue *ArgumentListNode::evaluate(ExecState *)
{
assert(0);
return 0; // dummy, see evaluateList()
List l;
for (ArgumentListNode *n = this; n; n = n->list.get()) {
- ValueImp *v = n->expr->evaluate(exec);
+ JSValue *v = n->expr->evaluate(exec);
KJS_CHECKEXCEPTIONLIST
l.append(v);
}