JSContextRef execRef = toRef(exec);
JSObjectRef thisRef = toRef(this);
- size_t argc = args.size();
- JSValueRef argv[argc];
- for (size_t i = 0; i < argc; i++)
- argv[i] = toRef(args[i]);
- return toJS(m_callback(execRef, thisRef, argc, argv, toRef(exec->exceptionSlot())));
+ size_t argumentCount = args.size();
+ JSValueRef arguments[argumentCount];
+ for (size_t i = 0; i < argumentCount; i++)
+ arguments[i] = toRef(args[i]);
+ return toJS(m_callback(execRef, thisRef, argumentCount, arguments, toRef(exec->exceptionSlot())));
}
void JSCallbackConstructor::setPrivate(void* data)
JSObjectRef thisRef = toRef(this);
JSObjectRef thisObjRef = toRef(thisObj);
- size_t argc = args.size();
- JSValueRef argv[argc];
- for (size_t i = 0; i < argc; i++)
- argv[i] = toRef(args[i]);
- return toJS(m_callback(execRef, thisRef, thisObjRef, argc, argv, toRef(exec->exceptionSlot())));
+ size_t argumentCount = args.size();
+ JSValueRef arguments[argumentCount];
+ for (size_t i = 0; i < argumentCount; i++)
+ arguments[i] = toRef(args[i]);
+ return toJS(m_callback(execRef, thisRef, thisObjRef, argumentCount, arguments, toRef(exec->exceptionSlot())));
}
void JSCallbackFunction::setPrivate(void* data)
for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callbacks.callAsConstructor) {
- size_t argc = args.size();
- JSValueRef argv[argc];
- for (size_t i = 0; i < argc; i++)
- argv[i] = toRef(args[i]);
- return toJS(callAsConstructor(execRef, thisRef, argc, argv, toRef(exec->exceptionSlot())));
+ size_t argumentCount = args.size();
+ JSValueRef arguments[argumentCount];
+ for (size_t i = 0; i < argumentCount; i++)
+ arguments[i] = toRef(args[i]);
+ return toJS(callAsConstructor(execRef, thisRef, argumentCount, arguments, toRef(exec->exceptionSlot())));
}
}
for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callbacks.callAsFunction) {
- size_t argc = args.size();
- JSValueRef argv[argc];
- for (size_t i = 0; i < argc; i++)
- argv[i] = toRef(args[i]);
- return toJS(callAsFunction(execRef, thisRef, thisObjRef, argc, argv, toRef(exec->exceptionSlot())));
+ size_t argumentCount = args.size();
+ JSValueRef arguments[argumentCount];
+ for (size_t i = 0; i < argumentCount; i++)
+ arguments[i] = toRef(args[i]);
+ return toJS(callAsFunction(execRef, thisRef, thisObjRef, argumentCount, arguments, toRef(exec->exceptionSlot())));
}
}
static JSClassRef JSNode_class(JSContextRef context);
-static JSValueRef JSNodePrototype_appendChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
+static JSValueRef JSNodePrototype_appendChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
UNUSED_PARAM(context);
UNUSED_PARAM(function);
JSStringRef message = JSStringCreateWithUTF8CString("TypeError: appendChild can only be called on nodes");
*exception = JSValueMakeString(message);
JSStringRelease(message);
- } else if (argc < 1 || !JSValueIsObjectOfClass(argv[0], JSNode_class(context))) {
+ } else if (argumentCount < 1 || !JSValueIsObjectOfClass(arguments[0], JSNode_class(context))) {
JSStringRef message = JSStringCreateWithUTF8CString("TypeError: first argument to appendChild must be a node");
*exception = JSValueMakeString(message);
JSStringRelease(message);
} else {
Node* node = JSObjectGetPrivate(thisObject);
- Node* child = JSObjectGetPrivate(JSValueToObject(context, argv[0], NULL));
+ Node* child = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL));
Node_appendChild(node, child);
}
return JSValueMakeUndefined();
}
-static JSValueRef JSNodePrototype_removeChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
+static JSValueRef JSNodePrototype_removeChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
UNUSED_PARAM(context);
UNUSED_PARAM(function);
// Example of ignoring invalid values
- if (argc > 0) {
+ if (argumentCount > 0) {
if (JSValueIsObjectOfClass(thisObject, JSNode_class(context))) {
- if (JSValueIsObjectOfClass(argv[0], JSNode_class(context))) {
+ if (JSValueIsObjectOfClass(arguments[0], JSNode_class(context))) {
Node* node = JSObjectGetPrivate(thisObject);
- Node* child = JSObjectGetPrivate(JSValueToObject(context, argv[0], NULL));
+ Node* child = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL));
Node_removeChild(node, child);
}
return JSValueMakeUndefined();
}
-static JSValueRef JSNodePrototype_replaceChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
+static JSValueRef JSNodePrototype_replaceChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
UNUSED_PARAM(context);
UNUSED_PARAM(function);
- if (argc > 1) {
+ if (argumentCount > 1) {
if (JSValueIsObjectOfClass(thisObject, JSNode_class(context))) {
- if (JSValueIsObjectOfClass(argv[0], JSNode_class(context))) {
- if (JSValueIsObjectOfClass(argv[1], JSNode_class(context))) {
+ if (JSValueIsObjectOfClass(arguments[0], JSNode_class(context))) {
+ if (JSValueIsObjectOfClass(arguments[1], JSNode_class(context))) {
Node* node = JSObjectGetPrivate(thisObject);
- Node* newChild = JSObjectGetPrivate(JSValueToObject(context, argv[0], NULL));
- Node* oldChild = JSObjectGetPrivate(JSValueToObject(context, argv[1], NULL));
+ Node* newChild = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL));
+ Node* oldChild = JSObjectGetPrivate(JSValueToObject(context, arguments[1], NULL));
Node_replaceChild(node, newChild, oldChild);
}
return jsNode;
}
-JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t argc, JSValueRef argv[], JSValueRef* exception)
+JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
UNUSED_PARAM(object);
- UNUSED_PARAM(argc);
- UNUSED_PARAM(argv);
+ UNUSED_PARAM(argumentCount);
+ UNUSED_PARAM(arguments);
return JSNode_new(context, Node_new());
}
#include "Node.h"
extern JSObjectRef JSNode_new(JSContextRef context, Node* node);
-extern JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t argc, JSValueRef argv[], JSValueRef* exception);
+extern JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception);
#endif // JSNode_h
#include "JSNodeList.h"
#include "UnusedParam.h"
-static JSValueRef JSNodeListPrototype_item(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
+static JSValueRef JSNodeListPrototype_item(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
- if (argc > 0) {
+ if (argumentCount > 0) {
NodeList* nodeList = JSObjectGetPrivate(thisObject);
assert(nodeList);
- Node* node = NodeList_item(nodeList, JSValueToNumber(context, argv[0], exception));
+ Node* node = NodeList_item(nodeList, JSValueToNumber(context, arguments[0], exception));
if (node)
return JSNode_new(context, node);
}
return jsObject->implementsCall();
}
-JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
+JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
JSLock lock;
ExecState* exec = toJS(context);
jsThisObject = exec->dynamicInterpreter()->globalObject();
List argList;
- for (size_t i = 0; i < argc; i++)
- argList.append(toJS(argv[i]));
+ for (size_t i = 0; i < argumentCount; i++)
+ argList.append(toJS(arguments[i]));
JSValueRef result = toRef(jsObject->call(exec, jsThisObject, argList)); // returns NULL if object->implementsCall() is false
if (exec->hadException()) {
return jsObject->implementsConstruct();
}
-JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argc, JSValueRef argv[], JSValueRef* exception)
+JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
JSLock lock;
ExecState* exec = toJS(context);
JSObject* jsObject = toJS(object);
List argList;
- for (size_t i = 0; i < argc; i++)
- argList.append(toJS(argv[i]));
+ for (size_t i = 0; i < argumentCount; i++)
+ argList.append(toJS(arguments[i]));
JSObjectRef result = toRef(jsObject->construct(exec, argList)); // returns NULL if object->implementsCall() is false
if (exec->hadException()) {
@param context The current execution context.
@param function A JSObject that is the function being called.
@param thisObject A JSObject that is the 'this' variable in the function's scope.
-@param argc An integer count of the number of arguments in argv.
-@param argv A JSValue array of the arguments passed to the function.
+@param argumentCount An integer count of the number of arguments in arguments.
+@param arguments A JSValue array of the arguments passed to the function.
@param exception A pointer to a JSValueRef in which to return an exception, if any.
@result A JSValue that is the function's return value.
@discussion If you named your function CallAsFunction, you would declare it like this:
-JSValueRef CallAsFunction(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception);
+JSValueRef CallAsFunction(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception);
If your callback were invoked by the JavaScript expression 'myObject.myMemberFunction()', function would be set to myMemberFunction, and thisObject would be set to myObject.
If this callback is NULL, calling your object as a function will throw an exception.
*/
typedef JSValueRef
-(*JSObjectCallAsFunctionCallback) (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception);
+(*JSObjectCallAsFunctionCallback) (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception);
/*!
@typedef JSObjectCallAsConstructorCallback
@abstract The callback invoked when an object is used as a constructor in a 'new' expression.
@param context The current execution context.
@param constructor A JSObject that is the constructor being called.
-@param argc An integer count of the number of arguments in argv.
-@param argv A JSValue array of the arguments passed to the function.
+@param argumentCount An integer count of the number of arguments in arguments.
+@param arguments A JSValue array of the arguments passed to the function.
@param exception A pointer to a JSValueRef in which to return an exception, if any.
@result A JSObject that is the constructor's return value.
@discussion If you named your function CallAsConstructor, you would declare it like this:
-JSObjectRef CallAsConstructor(JSContextRef context, JSObjectRef constructor, size_t argc, JSValueRef argv[], JSValueRef* exception);
+JSObjectRef CallAsConstructor(JSContextRef context, JSObjectRef constructor, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception);
If your callback were invoked by the JavaScript expression 'new myConstructorFunction()', constructor would be set to myConstructorFunction.
If this callback is NULL, using your object as a constructor in a 'new' expression will throw an exception.
*/
typedef JSObjectRef
-(*JSObjectCallAsConstructorCallback) (JSContextRef context, JSObjectRef constructor, size_t argc, JSValueRef argv[], JSValueRef* exception);
+(*JSObjectCallAsConstructorCallback) (JSContextRef context, JSObjectRef constructor, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception);
/*!
@typedef JSObjectHasInstanceCallback
@param context The execution context to use.
@param object The JSObject to call as a function.
@param thisObject The object to use as "this," or NULL to use the global object as "this."
-@param argc An integer count of the number of arguments in argv.
-@param argv A JSValue array of the arguments to pass to the function.
+@param argumentCount An integer count of the number of arguments in arguments.
+@param arguments A JSValue array of the arguments to pass to the function.
@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.
@result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function.
*/
-JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception);
+JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception);
/*!
@function
@abstract Tests whether an object can be called as a constructor.
@abstract Calls an object as a constructor.
@param context The execution context to use.
@param object The JSObject to call as a constructor.
-@param argc An integer count of the number of arguments in argv.
-@param argv A JSValue array of the arguments to pass to the function.
+@param argumentCount An integer count of the number of arguments in arguments.
+@param arguments A JSValue array of the arguments to pass to the function.
@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.
@result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.
*/
-JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argc, JSValueRef argv[], JSValueRef* exception);
+JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception);
/*!
@function
#include <wtf/UnusedParam.h>
static char* createStringWithContentsOfFile(const char* fileName);
-static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception);
+static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception);
int main(int argc, char* argv[])
{
return 0;
}
-static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
+static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
- if (argc > 0) {
- JSStringRef string = JSValueToStringCopy(context, argv[0], NULL);
+ if (argumentCount > 0) {
+ JSStringRef string = JSValueToStringCopy(context, arguments[0], NULL);
size_t numChars = JSStringGetMaximumUTF8CStringSize(string);
char stringUTF8[numChars];
JSStringGetUTF8CString(string, stringUTF8, numChars);
JSStringRelease(propertyName);
}
-static JSValueRef MyObject_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
+static JSValueRef MyObject_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
UNUSED_PARAM(context);
UNUSED_PARAM(object);
UNUSED_PARAM(thisObject);
- if (argc > 0 && JSValueIsStrictEqual(context, argv[0], JSValueMakeNumber(0)))
+ if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(0)))
return JSValueMakeNumber(1);
return JSValueMakeUndefined();
}
-static JSObjectRef MyObject_callAsConstructor(JSContextRef context, JSObjectRef object, size_t argc, JSValueRef argv[], JSValueRef* exception)
+static JSObjectRef MyObject_callAsConstructor(JSContextRef context, JSObjectRef object, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
UNUSED_PARAM(context);
UNUSED_PARAM(object);
- if (argc > 0 && JSValueIsStrictEqual(context, argv[0], JSValueMakeNumber(0)))
+ if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(0)))
return JSValueToObject(context, JSValueMakeNumber(1), NULL);
return JSValueToObject(context, JSValueMakeNumber(0), NULL);
return jsClass;
}
-static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functionObject, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
+static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functionObject, JSObjectRef thisObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
UNUSED_PARAM(functionObject);
UNUSED_PARAM(thisObject);
- if (argc > 0) {
- JSStringRef string = JSValueToStringCopy(context, argv[0], NULL);
+ if (argumentCount > 0) {
+ JSStringRef string = JSValueToStringCopy(context, arguments[0], NULL);
size_t sizeUTF8 = JSStringGetMaximumUTF8CStringSize(string);
char stringUTF8[sizeUTF8];
JSStringGetUTF8CString(string, stringUTF8, sizeUTF8);
return JSValueMakeUndefined();
}
-static JSObjectRef myConstructor_callAsConstructor(JSContextRef context, JSObjectRef constructorObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
+static JSObjectRef myConstructor_callAsConstructor(JSContextRef context, JSObjectRef constructorObject, size_t argumentCount, JSValueRef arguments[], JSValueRef* exception)
{
UNUSED_PARAM(constructorObject);
JSObjectRef result = JSObjectMake(context, NULL, 0);
- if (argc > 0) {
+ if (argumentCount > 0) {
JSStringRef value = JSStringCreateWithUTF8CString("value");
- JSObjectSetProperty(context, result, value, argv[0], kJSPropertyAttributeNone, NULL);
+ JSObjectSetProperty(context, result, value, arguments[0], kJSPropertyAttributeNone, NULL);
JSStringRelease(value);
}
+2006-07-14 Geoffrey Garen <ggaren@apple.com>
+
+ RS by Maciej.
+
+ Global replace in the API of argc/argv with argumentCount/arguments.
+
2006-07-14 Geoffrey Garen <ggaren@apple.com>
Reviewed by Maciej.