summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/API
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commit9364f22aed35e1a1e9d07c121510f80be3ab0502 (patch)
treed49911209b132da58d838efa852daf28d516df21 /JavaScriptCore/API
parent87eb0cb35bad8784770ebc807e6c982432e47107 (diff)
downloadexternal_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.zip
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.gz
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.bz2
Initial Contribution
Diffstat (limited to 'JavaScriptCore/API')
-rw-r--r--JavaScriptCore/API/JSCallbackObject.h4
-rw-r--r--JavaScriptCore/API/JSCallbackObjectFunctions.h10
-rw-r--r--JavaScriptCore/API/JSClassRef.cpp10
-rw-r--r--JavaScriptCore/API/JSClassRef.h4
-rw-r--r--JavaScriptCore/API/JSObjectRef.cpp28
5 files changed, 23 insertions, 33 deletions
diff --git a/JavaScriptCore/API/JSCallbackObject.h b/JavaScriptCore/API/JSCallbackObject.h
index 52b89fd..7eb32a6 100644
--- a/JavaScriptCore/API/JSCallbackObject.h
+++ b/JavaScriptCore/API/JSCallbackObject.h
@@ -47,8 +47,8 @@ public:
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned, PropertySlot&);
- virtual void put(ExecState*, const Identifier&, JSValue*);
- virtual void put(ExecState*, unsigned, JSValue*);
+ virtual void put(ExecState*, const Identifier&, JSValue*, int attr);
+ virtual void put(ExecState*, unsigned, JSValue*, int attr);
virtual bool deleteProperty(ExecState*, const Identifier&);
virtual bool deleteProperty(ExecState*, unsigned);
diff --git a/JavaScriptCore/API/JSCallbackObjectFunctions.h b/JavaScriptCore/API/JSCallbackObjectFunctions.h
index f767400..f987dd8 100644
--- a/JavaScriptCore/API/JSCallbackObjectFunctions.h
+++ b/JavaScriptCore/API/JSCallbackObjectFunctions.h
@@ -150,7 +150,7 @@ bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, unsigned proper
}
template <class Base>
-void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
+void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(this);
@@ -181,19 +181,19 @@ void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName
if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
if (entry->attributes & kJSPropertyAttributeReadOnly)
return;
- JSCallbackObject<Base>::putDirect(propertyName, value); // put as override property
+ JSCallbackObject<Base>::putDirect(propertyName, value, attr); // put as override property
return;
}
}
}
- return Base::put(exec, propertyName, value);
+ return Base::put(exec, propertyName, value, attr);
}
template <class Base>
-void JSCallbackObject<Base>::put(ExecState* exec, unsigned propertyName, JSValue* value)
+void JSCallbackObject<Base>::put(ExecState* exec, unsigned propertyName, JSValue* value, int attr)
{
- return put(exec, Identifier::from(propertyName), value);
+ return put(exec, Identifier::from(propertyName), value, attr);
}
template <class Base>
diff --git a/JavaScriptCore/API/JSClassRef.cpp b/JavaScriptCore/API/JSClassRef.cpp
index f2abef9..98aaaf5 100644
--- a/JavaScriptCore/API/JSClassRef.cpp
+++ b/JavaScriptCore/API/JSClassRef.cpp
@@ -98,9 +98,9 @@ OpaqueJSClass::~OpaqueJSClass()
JSClassRelease(prototypeClass);
}
-PassRefPtr<OpaqueJSClass> OpaqueJSClass::createNoAutomaticPrototype(const JSClassDefinition* definition)
+JSClassRef OpaqueJSClass::createNoAutomaticPrototype(const JSClassDefinition* definition)
{
- return adoptRef(new OpaqueJSClass(definition, 0));
+ return new OpaqueJSClass(definition, 0);
}
void clearReferenceToPrototype(JSObjectRef prototype)
@@ -110,7 +110,7 @@ void clearReferenceToPrototype(JSObjectRef prototype)
jsClass->cachedPrototype = 0;
}
-PassRefPtr<OpaqueJSClass> OpaqueJSClass::create(const JSClassDefinition* definition)
+JSClassRef OpaqueJSClass::create(const JSClassDefinition* definition)
{
if (const JSStaticFunction* staticFunctions = definition->staticFunctions) {
// copy functions into a prototype class
@@ -122,10 +122,10 @@ PassRefPtr<OpaqueJSClass> OpaqueJSClass::create(const JSClassDefinition* definit
// remove functions from the original class
JSClassDefinition objectDefinition = *definition;
objectDefinition.staticFunctions = 0;
- return adoptRef(new OpaqueJSClass(&objectDefinition, protoClass));
+ return new OpaqueJSClass(&objectDefinition, protoClass);
}
- return adoptRef(new OpaqueJSClass(definition, 0));
+ return new OpaqueJSClass(definition, 0);
}
/*!
diff --git a/JavaScriptCore/API/JSClassRef.h b/JavaScriptCore/API/JSClassRef.h
index 6532440..eb2b35b 100644
--- a/JavaScriptCore/API/JSClassRef.h
+++ b/JavaScriptCore/API/JSClassRef.h
@@ -57,8 +57,8 @@ struct StaticFunctionEntry {
};
struct OpaqueJSClass : public RefCounted<OpaqueJSClass> {
- static PassRefPtr<OpaqueJSClass> create(const JSClassDefinition*);
- static PassRefPtr<OpaqueJSClass> createNoAutomaticPrototype(const JSClassDefinition*);
+ static OpaqueJSClass* create(const JSClassDefinition*);
+ static OpaqueJSClass* createNoAutomaticPrototype(const JSClassDefinition*);
~OpaqueJSClass();
KJS::JSObject* prototype(JSContextRef ctx);
diff --git a/JavaScriptCore/API/JSObjectRef.cpp b/JavaScriptCore/API/JSObjectRef.cpp
index 8ac5221..c6cda25 100644
--- a/JavaScriptCore/API/JSObjectRef.cpp
+++ b/JavaScriptCore/API/JSObjectRef.cpp
@@ -1,6 +1,6 @@
// -*- mode: c++; c-basic-offset: 4 -*-
/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,13 +27,15 @@
#include "config.h"
#include "JSObjectRef.h"
+#include <wtf/Platform.h>
#include "APICast.h"
+#include "JSValueRef.h"
#include "JSCallbackConstructor.h"
#include "JSCallbackFunction.h"
#include "JSCallbackObject.h"
#include "JSClassRef.h"
#include "JSGlobalObject.h"
-#include "JSValueRef.h"
+
#include "PropertyNameArray.h"
#include "function.h"
#include "function_object.h"
@@ -41,18 +43,17 @@
#include "internal.h"
#include "object.h"
#include "object_object.h"
-#include <wtf/Platform.h>
using namespace KJS;
JSClassRef JSClassCreate(const JSClassDefinition* definition)
{
JSLock lock;
- RefPtr<OpaqueJSClass> jsClass = (definition->attributes & kJSClassAttributeNoAutomaticPrototype)
+ JSClassRef jsClass = (definition->attributes & kJSClassAttributeNoAutomaticPrototype)
? OpaqueJSClass::createNoAutomaticPrototype(definition)
: OpaqueJSClass::create(definition);
- return jsClass.release().releaseRef();
+ return JSClassRetain(jsClass);
}
JSClassRef JSClassRetain(JSClassRef jsClass)
@@ -176,21 +177,10 @@ void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef prope
JSLock lock;
ExecState* exec = toJS(ctx);
JSObject* jsObject = toJS(object);
- Identifier name(toJS(propertyName));
+ UString::Rep* nameRep = toJS(propertyName);
JSValue* jsValue = toJS(value);
-
- // If non-0 attributes were passed, we may need to use a lower-level call than
- // the normal JSObject::put. If there is no existing property, then use either
- // initializeVariable or putDirect instead, since those have the power to set attributes.
- if (attributes && !jsObject->hasProperty(exec, name)) {
- if (jsObject->isGlobalObject())
- static_cast<JSGlobalObject*>(jsObject)->initializeVariable(exec, name, jsValue, attributes);
- else
- jsObject->putDirect(name, jsValue, attributes);
- return;
- }
-
- jsObject->put(exec, name, jsValue);
+
+ jsObject->put(exec, Identifier(nameRep), jsValue, attributes);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());