Changeset 60631 in webkit for trunk/JavaScriptCore/runtime/ObjectConstructor.cpp
- Timestamp:
- Jun 3, 2010, 1:00:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/ObjectConstructor.cpp
r60392 r60631 35 35 ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor); 36 36 37 static JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*);38 static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*);39 static JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*);40 static JSValue JSC_HOST_CALL objectConstructorKeys(ExecState*);41 static JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*);42 static JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*);43 static JSValue JSC_HOST_CALL objectConstructorCreate(ExecState*);37 static EncodedJSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*); 38 static EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*); 39 static EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*); 40 static EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState*); 41 static EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*); 42 static EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*); 43 static EncodedJSValue JSC_HOST_CALL objectConstructorCreate(ExecState*); 44 44 45 45 ObjectConstructor::ObjectConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure) … … 81 81 } 82 82 83 static JSValue JSC_HOST_CALL callObjectConstructor(ExecState* exec)83 static EncodedJSValue JSC_HOST_CALL callObjectConstructor(ExecState* exec) 84 84 { 85 85 ArgList args(exec); 86 return constructObject(exec, args);86 return JSValue::encode(constructObject(exec, args)); 87 87 } 88 88 … … 93 93 } 94 94 95 JSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec)96 { 97 if (!exec->argument(0).isObject()) 98 return throwError(exec, TypeError, "Requested prototype of a value that is not an object.");99 return asObject(exec->argument(0))->prototype();100 } 101 102 JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec)103 { 104 if (!exec->argument(0).isObject()) 105 return throwError(exec, TypeError, "Requested property descriptor of a value that is not an object.");95 EncodedJSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec) 96 { 97 if (!exec->argument(0).isObject()) 98 return JSValue::encode(throwError(exec, TypeError, "Requested prototype of a value that is not an object.")); 99 return JSValue::encode(asObject(exec->argument(0))->prototype()); 100 } 101 102 EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec) 103 { 104 if (!exec->argument(0).isObject()) 105 return JSValue::encode(throwError(exec, TypeError, "Requested property descriptor of a value that is not an object.")); 106 106 UString propertyName = exec->argument(1).toString(exec); 107 107 if (exec->hadException()) 108 return jsNull();108 return JSValue::encode(jsNull()); 109 109 JSObject* object = asObject(exec->argument(0)); 110 110 PropertyDescriptor descriptor; 111 111 if (!object->getOwnPropertyDescriptor(exec, Identifier(exec, propertyName), descriptor)) 112 return jsUndefined();112 return JSValue::encode(jsUndefined()); 113 113 if (exec->hadException()) 114 return jsUndefined();114 return JSValue::encode(jsUndefined()); 115 115 116 116 JSObject* description = constructEmptyObject(exec); … … 126 126 description->putDirect(exec->propertyNames().configurable, jsBoolean(descriptor.configurable()), 0); 127 127 128 return description;128 return JSValue::encode(description); 129 129 } 130 130 131 131 // FIXME: Use the enumeration cache. 132 JSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec)133 { 134 if (!exec->argument(0).isObject()) 135 return throwError(exec, TypeError, "Requested property names of a value that is not an object.");132 EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec) 133 { 134 if (!exec->argument(0).isObject()) 135 return JSValue::encode(throwError(exec, TypeError, "Requested property names of a value that is not an object.")); 136 136 PropertyNameArray properties(exec); 137 137 asObject(exec->argument(0))->getOwnPropertyNames(exec, properties, IncludeDontEnumProperties); … … 140 140 for (size_t i = 0; i < numProperties; i++) 141 141 names->push(exec, jsOwnedString(exec, properties[i].ustring())); 142 return names;142 return JSValue::encode(names); 143 143 } 144 144 145 145 // FIXME: Use the enumeration cache. 146 JSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec)147 { 148 if (!exec->argument(0).isObject()) 149 return throwError(exec, TypeError, "Requested keys of a value that is not an object.");146 EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec) 147 { 148 if (!exec->argument(0).isObject()) 149 return JSValue::encode(throwError(exec, TypeError, "Requested keys of a value that is not an object.")); 150 150 PropertyNameArray properties(exec); 151 151 asObject(exec->argument(0))->getOwnPropertyNames(exec, properties); … … 154 154 for (size_t i = 0; i < numProperties; i++) 155 155 keys->push(exec, jsOwnedString(exec, properties[i].ustring())); 156 return keys;156 return JSValue::encode(keys); 157 157 } 158 158 … … 202 202 if (!get.isUndefined()) { 203 203 CallData callData; 204 if (get .getCallData(callData) == CallTypeNone) {204 if (getCallData(get, callData) == CallTypeNone) { 205 205 throwError(exec, TypeError, "Getter must be a function."); 206 206 return false; … … 218 218 if (!set.isUndefined()) { 219 219 CallData callData; 220 if ( set.getCallData(callData) == CallTypeNone) {220 if (getCallData(set, callData) == CallTypeNone) { 221 221 throwError(exec, TypeError, "Setter must be a function."); 222 222 return false; … … 243 243 } 244 244 245 JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec)246 { 247 if (!exec->argument(0).isObject()) 248 return throwError(exec, TypeError, "Properties can only be defined on Objects.");245 EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec) 246 { 247 if (!exec->argument(0).isObject()) 248 return JSValue::encode(throwError(exec, TypeError, "Properties can only be defined on Objects.")); 249 249 JSObject* O = asObject(exec->argument(0)); 250 250 UString propertyName = exec->argument(1).toString(exec); 251 251 if (exec->hadException()) 252 return jsNull();252 return JSValue::encode(jsNull()); 253 253 PropertyDescriptor descriptor; 254 254 if (!toPropertyDescriptor(exec, exec->argument(2), descriptor)) 255 return jsNull();255 return JSValue::encode(jsNull()); 256 256 ASSERT((descriptor.attributes() & (Getter | Setter)) || (!descriptor.isAccessorDescriptor())); 257 257 ASSERT(!exec->hadException()); 258 258 O->defineOwnProperty(exec, Identifier(exec, propertyName), descriptor, true); 259 return O;259 return JSValue::encode(O); 260 260 } 261 261 … … 294 294 } 295 295 296 JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec)297 { 298 if (!exec->argument(0).isObject()) 299 return throwError(exec, TypeError, "Properties can only be defined on Objects.");296 EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec) 297 { 298 if (!exec->argument(0).isObject()) 299 return JSValue::encode(throwError(exec, TypeError, "Properties can only be defined on Objects.")); 300 300 if (!exec->argument(1).isObject()) 301 return throwError(exec, TypeError, "Property descriptor list must be an Object.");302 return defineProperties(exec, asObject(exec->argument(0)), asObject(exec->argument(1)));303 } 304 305 JSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec)301 return JSValue::encode(throwError(exec, TypeError, "Property descriptor list must be an Object.")); 302 return JSValue::encode(defineProperties(exec, asObject(exec->argument(0)), asObject(exec->argument(1)))); 303 } 304 305 EncodedJSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec) 306 306 { 307 307 if (!exec->argument(0).isObject() && !exec->argument(0).isNull()) 308 return throwError(exec, TypeError, "Object prototype may only be an Object or null.");308 return JSValue::encode(throwError(exec, TypeError, "Object prototype may only be an Object or null.")); 309 309 JSObject* newObject = constructEmptyObject(exec); 310 310 newObject->setPrototype(exec->argument(0)); 311 311 if (exec->argument(1).isUndefined()) 312 return newObject;312 return JSValue::encode(newObject); 313 313 if (!exec->argument(1).isObject()) 314 return throwError(exec, TypeError, "Property descriptor list must be an Object.");315 return defineProperties(exec, newObject, asObject(exec->argument(1)));314 return JSValue::encode(throwError(exec, TypeError, "Property descriptor list must be an Object.")); 315 return JSValue::encode(defineProperties(exec, newObject, asObject(exec->argument(1)))); 316 316 } 317 317
Note:
See TracChangeset
for help on using the changeset viewer.