? OpaqueJSClass::createNoAutomaticPrototype(definition)
: OpaqueJSClass::create(definition);
- return jsClass.release().releaseRef();
+ return jsClass.release().leakRef();
}
JSClassRef JSClassRetain(JSClassRef jsClass)
APIEntryShim entryShim(exec);
if (!jsClass)
- return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient
+ return toRef(constructEmptyObject(exec));
- JSCallbackObject<JSObject>* object = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
+ JSCallbackObject<JSNonFinalObject>* object = JSCallbackObject<JSNonFinalObject>::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
if (JSObject* prototype = jsClass->prototype(exec))
- object->setPrototype(prototype);
+ object->setPrototype(exec->globalData(), prototype);
return toRef(object);
}
Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous");
- return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID));
+ return toRef(JSCallbackFunction::create(exec, exec->lexicalGlobalObject(), callAsFunction, nameID));
}
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
- JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
- constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
+ JSCallbackConstructor* constructor = JSCallbackConstructor::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
+ constructor->putDirect(exec->globalData(), exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
args.append(jsString(exec, parameterNames[i]->ustring()));
args.append(jsString(exec, body->ustring()));
- JSObject* result = constructFunction(exec, args, nameID, sourceURL->ustring(), startingLineNumber);
+ JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL->ustring(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
for (size_t i = 0; i < argumentCount; ++i)
argList.append(toJS(exec, arguments[i]));
- JSObject* result = constructDate(exec, argList);
+ JSObject* result = constructDate(exec, exec->lexicalGlobalObject(), argList);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
- MarkedArgumentBuffer argList;
- for (size_t i = 0; i < argumentCount; ++i)
- argList.append(toJS(exec, arguments[i]));
+ JSValue message = argumentCount ? toJS(exec, arguments[0]) : jsUndefined();
+ Structure* errorStructure = exec->lexicalGlobalObject()->errorStructure();
+ JSObject* result = ErrorInstance::create(exec, errorStructure, message);
- JSObject* result = constructError(exec, argList);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
for (size_t i = 0; i < argumentCount; ++i)
argList.append(toJS(exec, arguments[i]));
- JSObject* result = constructRegExp(exec, argList);
+ JSObject* result = constructRegExp(exec, exec->lexicalGlobalObject(), argList);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
JSObject* jsObject = toJS(object);
JSValue jsValue = toJS(exec, value);
- jsObject->setPrototype(jsValue.isObject() ? jsValue : jsNull());
+ jsObject->setPrototypeWithCycleCheck(exec->globalData(), jsValue.isObject() ? jsValue : jsNull());
}
bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
JSValue jsValue = toJS(exec, value);
if (attributes && !jsObject->hasProperty(exec, name))
- jsObject->putWithAttributes(exec, name, jsValue, attributes);
+ jsObject->methodTable()->putDirectVirtual(jsObject, exec, name, jsValue, attributes);
else {
PutPropertySlot slot;
- jsObject->put(exec, name, jsValue, slot);
+ jsObject->methodTable()->put(jsObject, exec, name, jsValue, slot);
}
if (exec->hadException()) {
JSObject* jsObject = toJS(object);
JSValue jsValue = toJS(exec, value);
- jsObject->put(exec, propertyIndex, jsValue);
+ jsObject->methodTable()->putByIndex(jsObject, exec, propertyIndex, jsValue, false);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
JSObject* jsObject = toJS(object);
- bool result = jsObject->deleteProperty(exec, propertyName->identifier(&exec->globalData()));
+ bool result = jsObject->methodTable()->deleteProperty(jsObject, exec, propertyName->identifier(&exec->globalData()));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
{
JSObject* jsObject = toJS(object);
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
- return static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
- else if (jsObject->inherits(&JSCallbackObject<JSObject>::info))
- return static_cast<JSCallbackObject<JSObject>*>(jsObject)->getPrivate();
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
+ return jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
+ if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info))
+ return jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->getPrivate();
return 0;
}
{
JSObject* jsObject = toJS(object);
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
- static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
+ jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
return true;
- } else if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
- static_cast<JSCallbackObject<JSObject>*>(jsObject)->setPrivate(data);
+ }
+ if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info)) {
+ jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->setPrivate(data);
return true;
}
JSObject* jsObject = toJS(object);
JSValue result;
Identifier name(propertyName->identifier(&exec->globalData()));
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
- result = static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
- else if (jsObject->inherits(&JSCallbackObject<JSObject>::info))
- result = static_cast<JSCallbackObject<JSObject>*>(jsObject)->getPrivateProperty(name);
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
+ result = jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
+ else if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info))
+ result = jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->getPrivateProperty(name);
return toRef(exec, result);
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
- JSValue jsValue = toJS(exec, value);
+ JSValue jsValue = value ? toJS(exec, value) : JSValue();
Identifier name(propertyName->identifier(&exec->globalData()));
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
- static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivateProperty(name, jsValue);
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
+ jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
return true;
}
- if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
- static_cast<JSCallbackObject<JSObject>*>(jsObject)->setPrivateProperty(name, jsValue);
+ if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info)) {
+ jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
return true;
}
return false;
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->globalData()));
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
- static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
+ jsCast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
- if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
- static_cast<JSCallbackObject<JSObject>*>(jsObject)->deletePrivateProperty(name);
+ if (jsObject->inherits(&JSCallbackObject<JSNonFinalObject>::s_info)) {
+ jsCast<JSCallbackObject<JSNonFinalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
return false;
bool JSObjectIsFunction(JSContextRef, JSObjectRef object)
{
CallData callData;
- return toJS(object)->getCallData(callData) != CallTypeNone;
+ JSCell* cell = toJS(object);
+ return cell->methodTable()->getCallData(cell, callData) != CallTypeNone;
}
JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
argList.append(toJS(exec, arguments[i]));
CallData callData;
- CallType callType = jsObject->getCallData(callData);
+ CallType callType = jsObject->methodTable()->getCallData(jsObject, callData);
if (callType == CallTypeNone)
return 0;
{
JSObject* jsObject = toJS(object);
ConstructData constructData;
- return jsObject->getConstructData(constructData) != ConstructTypeNone;
+ return jsObject->methodTable()->getConstructData(jsObject, constructData) != ConstructTypeNone;
}
JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
JSObject* jsObject = toJS(object);
ConstructData constructData;
- ConstructType constructType = jsObject->getConstructData(constructData);
+ ConstructType constructType = jsObject->methodTable()->getConstructData(jsObject, constructData);
if (constructType == ConstructTypeNone)
return 0;
return result;
}
-struct OpaqueJSPropertyNameArray : FastAllocBase {
+struct OpaqueJSPropertyNameArray {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
OpaqueJSPropertyNameArray(JSGlobalData* globalData)
: refCount(0)
, globalData(globalData)
JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(globalData);
PropertyNameArray array(globalData);
- jsObject->getPropertyNames(exec, array);
+ jsObject->methodTable()->getPropertyNames(jsObject, exec, array, ExcludeDontEnumProperties);
size_t size = array.size();
propertyNames->array.reserveInitialCapacity(size);
for (size_t i = 0; i < size; ++i)
- propertyNames->array.append(JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create(array[i].ustring()).releaseRef()));
+ propertyNames->array.append(JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create(array[i].ustring()).leakRef()));
return JSPropertyNameArrayRetain(propertyNames);
}