Commit 35940e83 authored by darin's avatar darin

JavaScriptCore:

        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

WebCore:

        Rubber stamped by Maciej.

        - updated for KJS class renaming

        * many files and functions


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11527 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2ea0aa85
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.
......
......@@ -97,7 +97,7 @@ static bool _isSafeScript(JavaScriptObject *obj)
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);
......@@ -150,7 +150,7 @@ bool _NPN_Invoke (NPP npp, NPObject *o, NPIdentifier methodName, const NPVariant
// 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);
......@@ -160,10 +160,10 @@ bool _NPN_Invoke (NPP npp, NPObject *o, NPIdentifier methodName, const NPVariant
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);
......@@ -185,7 +185,7 @@ bool _NPN_Evaluate (NPP npp, NPObject *o, NPString *s, NPVariant *variant)
return false;
ExecState *exec = obj->executionContext->interpreter()->globalExec();
ValueImp *result;
JSValue *result;
JSLock lock;
NPUTF16 *scriptString;
......@@ -225,7 +225,7 @@ bool _NPN_GetProperty (NPP npp, NPObject *o, NPIdentifier propertyName, NPVarian
PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
JSLock lock;
ValueImp *result;
JSValue *result;
if (i->isString) {
result = obj->imp->get (exec, identifierFromNPIdentifier(i->value.string));
} else {
......@@ -352,7 +352,7 @@ bool _NPN_HasMethod(NPP npp, NPObject *o, NPIdentifier methodName)
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;
......
......@@ -40,12 +40,12 @@ extern NPClass *NPScriptObjectClass;
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
}
......
......@@ -95,9 +95,9 @@ void CInstance::end()
// 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.
......@@ -147,9 +147,9 @@ ValueImp *CInstance::invokeMethod (ExecState *exec, const MethodList &methodList
}
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();
......@@ -189,7 +189,7 @@ ValueImp *CInstance::invokeDefaultMethod (ExecState *exec, const List &args)
}
ValueImp *CInstance::defaultValue (Type hint) const
JSValue *CInstance::defaultValue (Type hint) const
{
if (hint == StringType) {
return stringValue();
......@@ -204,26 +204,26 @@ ValueImp *CInstance::defaultValue (Type hint) const
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();
}
......
......@@ -51,15 +51,15 @@ public:
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; }
......
......@@ -42,11 +42,11 @@ using namespace KJS::Bindings;
// ---------------------- 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) {
......@@ -59,7 +59,7 @@ ValueImp *CField::valueFromInstance(ExecState *exec, const Instance *inst) const
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();
......
......@@ -48,8 +48,8 @@ public:
_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 ""; }
......@@ -84,8 +84,8 @@ public:
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();
......
......@@ -59,7 +59,7 @@ void convertUTF8ToUTF16(const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16
}
// 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();
......@@ -68,7 +68,7 @@ void coerceValueToNPVariantStringType(ExecState *exec, ValueImp *value, NPVarian
}
// 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();
......@@ -91,7 +91,7 @@ void convertValueToNPVariant(ExecState *exec, ValueImp *value, NPVariant *result
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());
......@@ -126,7 +126,7 @@ void convertValueToNPVariant(ExecState *exec, ValueImp *value, NPVariant *result
NPN_InitializeVariantAsUndefined(result);
}
ValueImp *convertNPVariantToValue(ExecState *exec, const NPVariant *variant)
JSValue *convertNPVariantToValue(ExecState *exec, const NPVariant *variant)
{
NPVariantType type = variant->type;
......@@ -166,9 +166,9 @@ ValueImp *convertNPVariantToValue(ExecState *exec, const NPVariant *variant)
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.
......
......@@ -49,9 +49,9 @@ typedef enum
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
{
......
......@@ -74,7 +74,7 @@ Class *JavaInstance::getClass() const
return _class;
}
ValueImp *JavaInstance::stringValue() const
JSValue *JavaInstance::stringValue() const
{
jstring stringValue = (jstring)callJNIObjectMethod (_instance->_instance, "toString", "()Ljava/lang/String;");
JNIEnv *env = getJNIEnv();
......@@ -84,23 +84,23 @@ ValueImp *JavaInstance::stringValue() const
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();
......@@ -148,7 +148,7 @@ ValueImp *JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodL
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) {
......@@ -294,13 +294,13 @@ ValueImp *JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodL
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();
......@@ -327,7 +327,7 @@ ValueImp *JavaInstance::defaultValue (Type hint) const
return valueOf();
}
ValueImp *JavaInstance::valueOf() const
JSValue *JavaInstance::valueOf() const
{
return stringValue();
};
......
......@@ -73,17 +73,17 @@ public:
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
......
......@@ -56,7 +56,7 @@ static bool isJavaScriptThread()
return (RootObject::runLoop() == CFRunLoopGetCurrent());
}
jvalue JSObject::invoke (JSObjectCallContext *context)
jvalue JavaJSObject::invoke (JSObjectCallContext *context)
{
jvalue result;
......@@ -75,10 +75,10 @@ jvalue JSObject::invoke (JSObjectCallContext *context)
}
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;
......@@ -86,54 +86,54 @@ jvalue JSObject::invoke (JSObjectCallContext *context)
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;
}
......@@ -150,11 +150,11 @@ jvalue JSObject::invoke (JSObjectCallContext *context)
}
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);
......@@ -165,7 +165,7 @@ JSObject::JSObject(jlong nativeJSObject)
}
jobject JSObject::call(jstring methodName, jobjectArray args) const
jobject JavaJSObject::call(jstring methodName, jobjectArray args) const
{
JS_LOG ("methodName = %s\n", JavaString(methodName).UTF8String());
......@@ -174,27 +174,27 @@ jobject JSObject::call(jstring methodName, jobjectArray args) const
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;
......@@ -211,19 +211,19 @@ jobject JSObject::eval(jstring script) const
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();
......@@ -232,7 +232,7 @@ void JSObject::setMember(jstring memberName, jobject value) const
}
void JSObject::removeMember(jstring memberName) const
void JavaJSObject::removeMember(jstring memberName) const
{
JS_LOG ("memberName = %s\n", JavaString(memberName).UTF8String());
......@@ -242,20 +242,20 @@ void JSObject::removeMember(jstring memberName) const
}