X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9bcd318d5fa2a38139c9651d263a06c797529333..ba379fdc102753d6be2c4d937058fe40257329fe:/API/JSObjectRef.cpp diff --git a/API/JSObjectRef.cpp b/API/JSObjectRef.cpp index e81e512..50ee635 100644 --- a/API/JSObjectRef.cpp +++ b/API/JSObjectRef.cpp @@ -105,10 +105,10 @@ JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObje exec->globalData().heap.registerThread(); JSLock lock(exec); - JSValuePtr jsPrototype = jsClass - ? jsClass->prototype(exec) - : exec->lexicalGlobalObject()->objectPrototype(); - + JSValue jsPrototype = jsClass ? jsClass->prototype(exec) : 0; + 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); return toRef(constructor); @@ -122,7 +122,7 @@ JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned pa Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous"); - ArgList args; + MarkedArgumentBuffer args; for (unsigned i = 0; i < parameterCount; i++) args.append(jsString(exec, parameterNames[i]->ustring())); args.append(jsString(exec, body->ustring())); @@ -130,7 +130,7 @@ JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned pa JSObject* result = constructFunction(exec, args, nameID, sourceURL->ustring(), startingLineNumber); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); result = 0; } @@ -145,9 +145,9 @@ JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSVa JSObject* result; if (argumentCount) { - ArgList argList; + MarkedArgumentBuffer argList; for (size_t i = 0; i < argumentCount; ++i) - argList.append(toJS(arguments[i])); + argList.append(toJS(exec, arguments[i])); result = constructArray(exec, argList); } else @@ -155,7 +155,7 @@ JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSVa if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); result = 0; } @@ -169,14 +169,14 @@ JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSVal exec->globalData().heap.registerThread(); JSLock lock(exec); - ArgList argList; + MarkedArgumentBuffer argList; for (size_t i = 0; i < argumentCount; ++i) - argList.append(toJS(arguments[i])); + argList.append(toJS(exec, arguments[i])); JSObject* result = constructDate(exec, argList); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); result = 0; } @@ -190,14 +190,14 @@ JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSVa exec->globalData().heap.registerThread(); JSLock lock(exec); - ArgList argList; + MarkedArgumentBuffer argList; for (size_t i = 0; i < argumentCount; ++i) - argList.append(toJS(arguments[i])); + argList.append(toJS(exec, arguments[i])); JSObject* result = constructError(exec, argList); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); result = 0; } @@ -211,14 +211,14 @@ JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSV exec->globalData().heap.registerThread(); JSLock lock(exec); - ArgList argList; + MarkedArgumentBuffer argList; for (size_t i = 0; i < argumentCount; ++i) - argList.append(toJS(arguments[i])); + argList.append(toJS(exec, arguments[i])); JSObject* result = constructRegExp(exec, argList); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); result = 0; } @@ -226,16 +226,24 @@ JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSV return toRef(result); } -JSValueRef JSObjectGetPrototype(JSContextRef, JSObjectRef object) +JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object) { + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); - return toRef(jsObject->prototype()); + return toRef(exec, jsObject->prototype()); } -void JSObjectSetPrototype(JSContextRef, JSObjectRef object, JSValueRef value) +void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value) { + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); - JSValuePtr jsValue = toJS(value); + JSValue jsValue = toJS(exec, value); jsObject->setPrototype(jsValue.isObject() ? jsValue : jsNull()); } @@ -259,13 +267,13 @@ JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef JSObject* jsObject = toJS(object); - JSValuePtr jsValue = jsObject->get(exec, propertyName->identifier(&exec->globalData())); + JSValue jsValue = jsObject->get(exec, propertyName->identifier(&exec->globalData())); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); } - return toRef(jsValue); + return toRef(exec, jsValue); } void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) @@ -276,7 +284,7 @@ void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef prope JSObject* jsObject = toJS(object); Identifier name(propertyName->identifier(&exec->globalData())); - JSValuePtr jsValue = toJS(value); + JSValue jsValue = toJS(exec, value); if (attributes && !jsObject->hasProperty(exec, name)) jsObject->putWithAttributes(exec, name, jsValue, attributes); @@ -287,7 +295,7 @@ void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef prope if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); } } @@ -300,13 +308,13 @@ JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsi JSObject* jsObject = toJS(object); - JSValuePtr jsValue = jsObject->get(exec, propertyIndex); + JSValue jsValue = jsObject->get(exec, propertyIndex); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); } - return toRef(jsValue); + return toRef(exec, jsValue); } @@ -317,12 +325,12 @@ void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned p JSLock lock(exec); JSObject* jsObject = toJS(object); - JSValuePtr jsValue = toJS(value); + JSValue jsValue = toJS(exec, value); jsObject->put(exec, propertyIndex, jsValue); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); } } @@ -338,7 +346,7 @@ bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef pr bool result = jsObject->deleteProperty(exec, propertyName->identifier(&exec->globalData())); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); } return result; @@ -389,19 +397,19 @@ JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObject if (!jsThisObject) jsThisObject = exec->globalThisValue(); - ArgList argList; + MarkedArgumentBuffer argList; for (size_t i = 0; i < argumentCount; i++) - argList.append(toJS(arguments[i])); + argList.append(toJS(exec, arguments[i])); CallData callData; CallType callType = jsObject->getCallData(callData); if (callType == CallTypeNone) return 0; - JSValueRef result = toRef(call(exec, jsObject, callType, callData, jsThisObject, argList)); + JSValueRef result = toRef(exec, call(exec, jsObject, callType, callData, jsThisObject, argList)); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); result = 0; } @@ -428,13 +436,13 @@ JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size if (constructType == ConstructTypeNone) return 0; - ArgList argList; + MarkedArgumentBuffer argList; for (size_t i = 0; i < argumentCount; i++) - argList.append(toJS(arguments[i])); + argList.append(toJS(exec, arguments[i])); JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList)); if (exec->hadException()) { if (exception) - *exception = toRef(exec->exception()); + *exception = toRef(exec, exec->exception()); exec->clearException(); result = 0; }