Changeset 15444 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jul 14, 2006, 9:16:30 PM (19 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSCallbackConstructor.cpp
r15376 r15444 48 48 JSObjectRef thisRef = toRef(this); 49 49 50 size_t arg c= args.size();51 JSValueRef arg v[argc];52 for (size_t i = 0; i < arg c; i++)53 arg v[i] = toRef(args[i]);54 return toJS(m_callback(execRef, thisRef, arg c, argv, toRef(exec->exceptionSlot())));50 size_t argumentCount = args.size(); 51 JSValueRef arguments[argumentCount]; 52 for (size_t i = 0; i < argumentCount; i++) 53 arguments[i] = toRef(args[i]); 54 return toJS(m_callback(execRef, thisRef, argumentCount, arguments, toRef(exec->exceptionSlot()))); 55 55 } 56 56 -
trunk/JavaScriptCore/API/JSCallbackFunction.cpp
r15376 r15444 51 51 JSObjectRef thisObjRef = toRef(thisObj); 52 52 53 size_t arg c= args.size();54 JSValueRef arg v[argc];55 for (size_t i = 0; i < arg c; i++)56 arg v[i] = toRef(args[i]);57 return toJS(m_callback(execRef, thisRef, thisObjRef, arg c, argv, toRef(exec->exceptionSlot())));53 size_t argumentCount = args.size(); 54 JSValueRef arguments[argumentCount]; 55 for (size_t i = 0; i < argumentCount; i++) 56 arguments[i] = toRef(args[i]); 57 return toJS(m_callback(execRef, thisRef, thisObjRef, argumentCount, arguments, toRef(exec->exceptionSlot()))); 58 58 } 59 59 -
trunk/JavaScriptCore/API/JSCallbackObject.cpp
r15443 r15444 224 224 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 225 225 if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callbacks.callAsConstructor) { 226 size_t arg c= args.size();227 JSValueRef arg v[argc];228 for (size_t i = 0; i < arg c; i++)229 arg v[i] = toRef(args[i]);230 return toJS(callAsConstructor(execRef, thisRef, arg c, argv, toRef(exec->exceptionSlot())));226 size_t argumentCount = args.size(); 227 JSValueRef arguments[argumentCount]; 228 for (size_t i = 0; i < argumentCount; i++) 229 arguments[i] = toRef(args[i]); 230 return toJS(callAsConstructor(execRef, thisRef, argumentCount, arguments, toRef(exec->exceptionSlot()))); 231 231 } 232 232 } … … 276 276 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) { 277 277 if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callbacks.callAsFunction) { 278 size_t arg c= args.size();279 JSValueRef arg v[argc];280 for (size_t i = 0; i < arg c; i++)281 arg v[i] = toRef(args[i]);282 return toJS(callAsFunction(execRef, thisRef, thisObjRef, arg c, argv, toRef(exec->exceptionSlot())));278 size_t argumentCount = args.size(); 279 JSValueRef arguments[argumentCount]; 280 for (size_t i = 0; i < argumentCount; i++) 281 arguments[i] = toRef(args[i]); 282 return toJS(callAsFunction(execRef, thisRef, thisObjRef, argumentCount, arguments, toRef(exec->exceptionSlot()))); 283 283 } 284 284 } -
trunk/JavaScriptCore/API/JSNode.c
r15404 r15444 33 33 static JSClassRef JSNode_class(JSContextRef context); 34 34 35 static JSValueRef JSNodePrototype_appendChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception)35 static JSValueRef JSNodePrototype_appendChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 36 36 { 37 37 UNUSED_PARAM(context); … … 43 43 *exception = JSValueMakeString(message); 44 44 JSStringRelease(message); 45 } else if (arg c < 1 || !JSValueIsObjectOfClass(argv[0], JSNode_class(context))) {45 } else if (argumentCount < 1 || !JSValueIsObjectOfClass(arguments[0], JSNode_class(context))) { 46 46 JSStringRef message = JSStringCreateWithUTF8CString("TypeError: first argument to appendChild must be a node"); 47 47 *exception = JSValueMakeString(message); … … 49 49 } else { 50 50 Node* node = JSObjectGetPrivate(thisObject); 51 Node* child = JSObjectGetPrivate(JSValueToObject(context, arg v[0], NULL));51 Node* child = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL)); 52 52 53 53 Node_appendChild(node, child); … … 57 57 } 58 58 59 static JSValueRef JSNodePrototype_removeChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception)59 static JSValueRef JSNodePrototype_removeChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 60 60 { 61 61 UNUSED_PARAM(context); … … 63 63 64 64 // Example of ignoring invalid values 65 if (arg c> 0) {65 if (argumentCount > 0) { 66 66 if (JSValueIsObjectOfClass(thisObject, JSNode_class(context))) { 67 if (JSValueIsObjectOfClass(arg v[0], JSNode_class(context))) {67 if (JSValueIsObjectOfClass(arguments[0], JSNode_class(context))) { 68 68 Node* node = JSObjectGetPrivate(thisObject); 69 Node* child = JSObjectGetPrivate(JSValueToObject(context, arg v[0], NULL));69 Node* child = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL)); 70 70 71 71 Node_removeChild(node, child); … … 77 77 } 78 78 79 static JSValueRef JSNodePrototype_replaceChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception)79 static JSValueRef JSNodePrototype_replaceChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 80 80 { 81 81 UNUSED_PARAM(context); 82 82 UNUSED_PARAM(function); 83 83 84 if (arg c> 1) {84 if (argumentCount > 1) { 85 85 if (JSValueIsObjectOfClass(thisObject, JSNode_class(context))) { 86 if (JSValueIsObjectOfClass(arg v[0], JSNode_class(context))) {87 if (JSValueIsObjectOfClass(arg v[1], JSNode_class(context))) {86 if (JSValueIsObjectOfClass(arguments[0], JSNode_class(context))) { 87 if (JSValueIsObjectOfClass(arguments[1], JSNode_class(context))) { 88 88 Node* node = JSObjectGetPrivate(thisObject); 89 Node* newChild = JSObjectGetPrivate(JSValueToObject(context, arg v[0], NULL));90 Node* oldChild = JSObjectGetPrivate(JSValueToObject(context, arg v[1], NULL));89 Node* newChild = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL)); 90 Node* oldChild = JSObjectGetPrivate(JSValueToObject(context, arguments[1], NULL)); 91 91 92 92 Node_replaceChild(node, newChild, oldChild); … … 193 193 } 194 194 195 JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t arg c, JSValueRef argv[], JSValueRef* exception)195 JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 196 196 { 197 197 UNUSED_PARAM(object); 198 UNUSED_PARAM(arg c);199 UNUSED_PARAM(arg v);198 UNUSED_PARAM(argumentCount); 199 UNUSED_PARAM(arguments); 200 200 201 201 return JSNode_new(context, Node_new()); -
trunk/JavaScriptCore/API/JSNode.h
r15317 r15444 32 32 33 33 extern JSObjectRef JSNode_new(JSContextRef context, Node* node); 34 extern JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t arg c, JSValueRef argv[], JSValueRef* exception);34 extern JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception); 35 35 36 36 #endif // JSNode_h -
trunk/JavaScriptCore/API/JSNodeList.c
r15404 r15444 29 29 #include "UnusedParam.h" 30 30 31 static JSValueRef JSNodeListPrototype_item(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception)31 static JSValueRef JSNodeListPrototype_item(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 32 32 { 33 if (arg c> 0) {33 if (argumentCount > 0) { 34 34 NodeList* nodeList = JSObjectGetPrivate(thisObject); 35 35 assert(nodeList); 36 Node* node = NodeList_item(nodeList, JSValueToNumber(context, arg v[0], exception));36 Node* node = NodeList_item(nodeList, JSValueToNumber(context, arguments[0], exception)); 37 37 if (node) 38 38 return JSNode_new(context, node); -
trunk/JavaScriptCore/API/JSObjectRef.cpp
r15443 r15444 238 238 } 239 239 240 JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception)240 JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 241 241 { 242 242 JSLock lock; … … 249 249 250 250 List argList; 251 for (size_t i = 0; i < arg c; i++)252 argList.append(toJS(arg v[i]));251 for (size_t i = 0; i < argumentCount; i++) 252 argList.append(toJS(arguments[i])); 253 253 254 254 JSValueRef result = toRef(jsObject->call(exec, jsThisObject, argList)); // returns NULL if object->implementsCall() is false … … 268 268 } 269 269 270 JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t arg c, JSValueRef argv[], JSValueRef* exception)270 JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 271 271 { 272 272 JSLock lock; … … 275 275 276 276 List argList; 277 for (size_t i = 0; i < arg c; i++)278 argList.append(toJS(arg v[i]));277 for (size_t i = 0; i < argumentCount; i++) 278 argList.append(toJS(arguments[i])); 279 279 280 280 JSObjectRef result = toRef(jsObject->construct(exec, argList)); // returns NULL if object->implementsCall() is false -
trunk/JavaScriptCore/API/JSObjectRef.h
r15443 r15444 176 176 @param function A JSObject that is the function being called. 177 177 @param thisObject A JSObject that is the 'this' variable in the function's scope. 178 @param arg c An integer count of the number of arguments in argv.179 @param arg vA JSValue array of the arguments passed to the function.178 @param argumentCount An integer count of the number of arguments in arguments. 179 @param arguments A JSValue array of the arguments passed to the function. 180 180 @param exception A pointer to a JSValueRef in which to return an exception, if any. 181 181 @result A JSValue that is the function's return value. 182 182 @discussion If you named your function CallAsFunction, you would declare it like this: 183 183 184 JSValueRef CallAsFunction(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception);184 JSValueRef CallAsFunction(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception); 185 185 186 186 If your callback were invoked by the JavaScript expression 'myObject.myMemberFunction()', function would be set to myMemberFunction, and thisObject would be set to myObject. … … 189 189 */ 190 190 typedef JSValueRef 191 (*JSObjectCallAsFunctionCallback) (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception);191 (*JSObjectCallAsFunctionCallback) (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception); 192 192 193 193 /*! … … 196 196 @param context The current execution context. 197 197 @param constructor A JSObject that is the constructor being called. 198 @param arg c An integer count of the number of arguments in argv.199 @param arg vA JSValue array of the arguments passed to the function.198 @param argumentCount An integer count of the number of arguments in arguments. 199 @param arguments A JSValue array of the arguments passed to the function. 200 200 @param exception A pointer to a JSValueRef in which to return an exception, if any. 201 201 @result A JSObject that is the constructor's return value. 202 202 @discussion If you named your function CallAsConstructor, you would declare it like this: 203 203 204 JSObjectRef CallAsConstructor(JSContextRef context, JSObjectRef constructor, size_t arg c, JSValueRef argv[], JSValueRef* exception);204 JSObjectRef CallAsConstructor(JSContextRef context, JSObjectRef constructor, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception); 205 205 206 206 If your callback were invoked by the JavaScript expression 'new myConstructorFunction()', constructor would be set to myConstructorFunction. … … 209 209 */ 210 210 typedef JSObjectRef 211 (*JSObjectCallAsConstructorCallback) (JSContextRef context, JSObjectRef constructor, size_t arg c, JSValueRef argv[], JSValueRef* exception);211 (*JSObjectCallAsConstructorCallback) (JSContextRef context, JSObjectRef constructor, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception); 212 212 213 213 /*! … … 500 500 @param object The JSObject to call as a function. 501 501 @param thisObject The object to use as "this," or NULL to use the global object as "this." 502 @param arg c An integer count of the number of arguments in argv.503 @param arg vA JSValue array of the arguments to pass to the function.502 @param argumentCount An integer count of the number of arguments in arguments. 503 @param arguments A JSValue array of the arguments to pass to the function. 504 504 @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 505 505 @result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function. 506 506 */ 507 JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception);507 JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception); 508 508 /*! 509 509 @function … … 518 518 @param context The execution context to use. 519 519 @param object The JSObject to call as a constructor. 520 @param arg c An integer count of the number of arguments in argv.521 @param arg vA JSValue array of the arguments to pass to the function.520 @param argumentCount An integer count of the number of arguments in arguments. 521 @param arguments A JSValue array of the arguments to pass to the function. 522 522 @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 523 523 @result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor. 524 524 */ 525 JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t arg c, JSValueRef argv[], JSValueRef* exception);525 JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception); 526 526 527 527 /*! -
trunk/JavaScriptCore/API/minidom.c
r15443 r15444 30 30 31 31 static char* createStringWithContentsOfFile(const char* fileName); 32 static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception);32 static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception); 33 33 34 34 int main(int argc, char* argv[]) … … 79 79 } 80 80 81 static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception)81 static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 82 82 { 83 if (arg c> 0) {84 JSStringRef string = JSValueToStringCopy(context, arg v[0], NULL);83 if (argumentCount > 0) { 84 JSStringRef string = JSValueToStringCopy(context, arguments[0], NULL); 85 85 size_t numChars = JSStringGetMaximumUTF8CStringSize(string); 86 86 char stringUTF8[numChars]; -
trunk/JavaScriptCore/API/testapi.c
r15443 r15444 183 183 } 184 184 185 static JSValueRef MyObject_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception)185 static JSValueRef MyObject_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 186 186 { 187 187 UNUSED_PARAM(context); … … 189 189 UNUSED_PARAM(thisObject); 190 190 191 if (arg c > 0 && JSValueIsStrictEqual(context, argv[0], JSValueMakeNumber(0)))191 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(0))) 192 192 return JSValueMakeNumber(1); 193 193 … … 195 195 } 196 196 197 static JSObjectRef MyObject_callAsConstructor(JSContextRef context, JSObjectRef object, size_t arg c, JSValueRef argv[], JSValueRef* exception)198 { 199 UNUSED_PARAM(context); 200 UNUSED_PARAM(object); 201 202 if (arg c > 0 && JSValueIsStrictEqual(context, argv[0], JSValueMakeNumber(0)))197 static JSObjectRef MyObject_callAsConstructor(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 198 { 199 UNUSED_PARAM(context); 200 UNUSED_PARAM(object); 201 202 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(0))) 203 203 return JSValueToObject(context, JSValueMakeNumber(1), NULL); 204 204 … … 266 266 } 267 267 268 static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functionObject, JSObjectRef thisObject, size_t arg c, JSValueRef argv[], JSValueRef* exception)268 static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functionObject, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 269 269 { 270 270 UNUSED_PARAM(functionObject); 271 271 UNUSED_PARAM(thisObject); 272 272 273 if (arg c> 0) {274 JSStringRef string = JSValueToStringCopy(context, arg v[0], NULL);273 if (argumentCount > 0) { 274 JSStringRef string = JSValueToStringCopy(context, arguments[0], NULL); 275 275 size_t sizeUTF8 = JSStringGetMaximumUTF8CStringSize(string); 276 276 char stringUTF8[sizeUTF8]; … … 283 283 } 284 284 285 static JSObjectRef myConstructor_callAsConstructor(JSContextRef context, JSObjectRef constructorObject, size_t arg c, JSValueRef argv[], JSValueRef* exception)285 static JSObjectRef myConstructor_callAsConstructor(JSContextRef context, JSObjectRef constructorObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception) 286 286 { 287 287 UNUSED_PARAM(constructorObject); 288 288 289 289 JSObjectRef result = JSObjectMake(context, NULL, 0); 290 if (arg c> 0) {290 if (argumentCount > 0) { 291 291 JSStringRef value = JSStringCreateWithUTF8CString("value"); 292 JSObjectSetProperty(context, result, value, arg v[0], kJSPropertyAttributeNone, NULL);292 JSObjectSetProperty(context, result, value, arguments[0], kJSPropertyAttributeNone, NULL); 293 293 JSStringRelease(value); 294 294 } -
trunk/JavaScriptCore/ChangeLog
r15443 r15444 1 2006-07-14 Geoffrey Garen <[email protected]> 2 3 RS by Maciej. 4 5 Global replace in the API of argc/argv with argumentCount/arguments. 6 1 7 2006-07-14 Geoffrey Garen <[email protected]> 2 8
Note:
See TracChangeset
for help on using the changeset viewer.