Changeset 15481 in webkit for trunk/JavaScriptCore/API
- Timestamp:
- Jul 17, 2006, 1:14:39 AM (19 years ago)
- Location:
- trunk/JavaScriptCore/API
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.cpp
r15445 r15481 36 36 using namespace KJS; 37 37 38 JSValueRef JSEvaluateScript(JSContextRef c ontext, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)38 JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) 39 39 { 40 40 JSLock lock; 41 ExecState* exec = toJS(c ontext);41 ExecState* exec = toJS(ctx); 42 42 JSObject* jsThisObject = toJS(thisObject); 43 43 UString::Rep* scriptRep = toJS(script); … … 59 59 } 60 60 61 bool JSCheckScriptSyntax(JSContextRef c ontext, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)61 bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) 62 62 { 63 63 JSLock lock; 64 64 65 ExecState* exec = toJS(c ontext);65 ExecState* exec = toJS(ctx); 66 66 UString::Rep* scriptRep = toJS(script); 67 67 UString::Rep* sourceURLRep = toJS(sourceURL); … … 76 76 } 77 77 78 void JSGarbageCollect( )78 void JSGarbageCollect(JSContextRef) 79 79 { 80 80 JSLock lock; -
trunk/JavaScriptCore/API/JSBase.h
r15480 r15481 68 68 @function 69 69 @abstract Evaluates a string of JavaScript. 70 @param c ontextThe execution context to use.70 @param ctx The execution context to use. 71 71 @param script A JSString containing the script to evaluate. 72 72 @param thisObject The object to use as "this," or NULL to use the global object as "this." … … 76 76 @result The JSValue that results from evaluating script, or NULL if an exception is thrown. 77 77 */ 78 JSValueRef JSEvaluateScript(JSContextRef c ontext, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);78 JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); 79 79 80 80 /*! 81 81 @function JSCheckScriptSyntax 82 82 @abstract Checks for syntax errors in a string of JavaScript. 83 @param c ontextThe execution context to use.83 @param ctx The execution context to use. 84 84 @param script A JSString containing the script to check for syntax errors. 85 85 @param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. … … 88 88 @result true if the script is syntactically correct, otherwise false. 89 89 */ 90 bool JSCheckScriptSyntax(JSContextRef c ontext, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);90 bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); 91 91 92 92 /*! 93 93 @function 94 94 @abstract Performs a JavaScript garbage collection. 95 @param ctx The execution context to use. 95 96 @discussion JavaScript values that are on the machine stack, in a register, 96 97 protected by JSValueProtect, set as the global object of an execution context, … … 100 101 collect as needed. 101 102 */ 102 void JSGarbageCollect( void);103 void JSGarbageCollect(JSContextRef ctx); 103 104 104 105 #ifdef __cplusplus -
trunk/JavaScriptCore/API/JSCallbackObject.cpp
r15480 r15481 38 38 const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0, 0 }; 39 39 40 JSCallbackObject::JSCallbackObject(JSContextRef c ontext, JSClassRef jsClass)40 JSCallbackObject::JSCallbackObject(JSContextRef ctx, JSClassRef jsClass) 41 41 : JSObject() 42 42 { 43 init(c ontext, jsClass);44 } 45 46 JSCallbackObject::JSCallbackObject(JSContextRef c ontext, JSClassRef jsClass, JSValue* prototype)43 init(ctx, jsClass); 44 } 45 46 JSCallbackObject::JSCallbackObject(JSContextRef ctx, JSClassRef jsClass, JSValue* prototype) 47 47 : JSObject(prototype) 48 48 { 49 init(c ontext, jsClass);50 } 51 52 void JSCallbackObject::init(JSContextRef c ontext, JSClassRef jsClass)53 { 54 ExecState* exec = toJS(c ontext);49 init(ctx, jsClass); 50 } 51 52 void JSCallbackObject::init(JSContextRef ctx, JSClassRef jsClass) 53 { 54 ExecState* exec = toJS(ctx); 55 55 56 56 m_privateData = 0; … … 61 61 do { 62 62 if (JSObjectInitializeCallback initialize = jsClass->initialize) 63 initialize(c ontext, thisRef, toRef(exec->exceptionSlot()));63 initialize(ctx, thisRef, toRef(exec->exceptionSlot())); 64 64 } while ((jsClass = jsClass->parentClass)); 65 65 } … … 86 86 bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 87 87 { 88 JSContextRef c ontext= toRef(exec);88 JSContextRef ctx = toRef(exec); 89 89 JSObjectRef thisRef = toRef(this); 90 90 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); … … 93 93 // optional optimization to bypass getProperty in cases when we only need to know if the property exists 94 94 if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) { 95 if (hasProperty(c ontext, thisRef, propertyNameRef)) {95 if (hasProperty(ctx, thisRef, propertyNameRef)) { 96 96 slot.setCustom(this, callbackGetter); 97 97 return true; 98 98 } 99 99 } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { 100 if (JSValueRef value = getProperty(c ontext, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) {100 if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) { 101 101 // cache the value so we don't have to compute it again 102 102 // FIXME: This violates the PropertySlot design a little bit. … … 132 132 void JSCallbackObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) 133 133 { 134 JSContextRef c ontext= toRef(exec);134 JSContextRef ctx = toRef(exec); 135 135 JSObjectRef thisRef = toRef(this); 136 136 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); … … 139 139 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { 140 140 if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { 141 if (setProperty(c ontext, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())))141 if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()))) 142 142 return; 143 143 } … … 148 148 return; 149 149 if (JSObjectSetPropertyCallback setProperty = entry->setProperty) 150 setProperty(c ontext, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()));150 setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())); 151 151 else 152 152 throwError(exec, ReferenceError, "Writable static value property defined with NULL setProperty callback."); … … 174 174 bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& propertyName) 175 175 { 176 JSContextRef c ontext= toRef(exec);176 JSContextRef ctx = toRef(exec); 177 177 JSObjectRef thisRef = toRef(this); 178 178 JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); … … 180 180 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { 181 181 if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { 182 if (deleteProperty(c ontext, thisRef, propertyNameRef, toRef(exec->exceptionSlot())))182 if (deleteProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) 183 183 return true; 184 184 } … … 326 326 double JSCallbackObject::toNumber(ExecState* exec) const 327 327 { 328 JSContextRef c ontext= toRef(exec);328 JSContextRef ctx = toRef(exec); 329 329 JSObjectRef thisRef = toRef(this); 330 330 331 331 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) 332 332 if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) 333 if (JSValueRef value = convertToType(c ontext, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot())))333 if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot()))) 334 334 return toJS(value)->getNumber(); 335 335 … … 339 339 UString JSCallbackObject::toString(ExecState* exec) const 340 340 { 341 JSContextRef c ontext= toRef(exec);341 JSContextRef ctx = toRef(exec); 342 342 JSObjectRef thisRef = toRef(this); 343 343 344 344 for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) 345 345 if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) 346 if (JSValueRef value = convertToType(c ontext, thisRef, kJSTypeString, toRef(exec->exceptionSlot())))346 if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot()))) 347 347 return toJS(value)->getString(); 348 348 -
trunk/JavaScriptCore/API/JSContextRef.cpp
r15437 r15481 47 47 48 48 Interpreter* interpreter = new Interpreter(globalObject); // adds the built-in object prototype to the global object 49 JSGlobalContextRef c ontext= reinterpret_cast<JSGlobalContextRef>(interpreter->globalExec());50 return JSGlobalContextRetain(c ontext);49 JSGlobalContextRef ctx = reinterpret_cast<JSGlobalContextRef>(interpreter->globalExec()); 50 return JSGlobalContextRetain(ctx); 51 51 } 52 52 53 JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef c ontext)53 JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx) 54 54 { 55 55 JSLock lock; 56 ExecState* exec = toJS(c ontext);56 ExecState* exec = toJS(ctx); 57 57 exec->dynamicInterpreter()->ref(); 58 return c ontext;58 return ctx; 59 59 } 60 60 61 void JSGlobalContextRelease(JSGlobalContextRef c ontext)61 void JSGlobalContextRelease(JSGlobalContextRef ctx) 62 62 { 63 63 JSLock lock; 64 ExecState* exec = toJS(c ontext);64 ExecState* exec = toJS(ctx); 65 65 exec->dynamicInterpreter()->deref(); 66 66 } 67 67 68 JSObjectRef JSContextGetGlobalObject(JSContextRef c ontext)68 JSObjectRef JSContextGetGlobalObject(JSContextRef ctx) 69 69 { 70 ExecState* exec = toJS(c ontext);70 ExecState* exec = toJS(ctx); 71 71 return toRef(exec->dynamicInterpreter()->globalObject()); 72 72 } -
trunk/JavaScriptCore/API/JSContextRef.h
r15437 r15481 51 51 @function 52 52 @abstract Retains a global JavaScript execution context. 53 @param c ontextThe JSGlobalContext to retain.54 @result A JSGlobalContext that is the same as c ontext.53 @param ctx The JSGlobalContext to retain. 54 @result A JSGlobalContext that is the same as ctx. 55 55 */ 56 JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef c ontext);56 JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx); 57 57 58 58 /*! 59 59 @function 60 60 @abstract Releases a global JavaScript execution context. 61 @param c ontextThe JSGlobalContext to release.61 @param ctx The JSGlobalContext to release. 62 62 */ 63 void JSGlobalContextRelease(JSGlobalContextRef c ontext);63 void JSGlobalContextRelease(JSGlobalContextRef ctx); 64 64 65 65 /*! 66 66 @function 67 67 @abstract Gets the global object of a JavaScript execution context. 68 @param c ontextThe JSContext whose global object you want to get.69 @result c ontext's global object.68 @param ctx The JSContext whose global object you want to get. 69 @result ctx's global object. 70 70 */ 71 JSObjectRef JSContextGetGlobalObject(JSContextRef c ontext);71 JSObjectRef JSContextGetGlobalObject(JSContextRef ctx); 72 72 73 73 #ifdef __cplusplus -
trunk/JavaScriptCore/API/JSNode.c
r15465 r15481 39 39 40 40 // Example of throwing a type error for invalid values 41 if (!JSValueIsObjectOfClass( thisObject, JSNode_class(context))) {41 if (!JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) { 42 42 JSStringRef message = JSStringCreateWithUTF8CString("TypeError: appendChild can only be called on nodes"); 43 *exception = JSValueMakeString( message);43 *exception = JSValueMakeString(context, message); 44 44 JSStringRelease(message); 45 } else if (argumentCount < 1 || !JSValueIsObjectOfClass( arguments[0], JSNode_class(context))) {45 } else if (argumentCount < 1 || !JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) { 46 46 JSStringRef message = JSStringCreateWithUTF8CString("TypeError: first argument to appendChild must be a node"); 47 *exception = JSValueMakeString( message);47 *exception = JSValueMakeString(context, message); 48 48 JSStringRelease(message); 49 49 } else { … … 54 54 } 55 55 56 return JSValueMakeUndefined( );56 return JSValueMakeUndefined(context); 57 57 } 58 58 … … 64 64 // Example of ignoring invalid values 65 65 if (argumentCount > 0) { 66 if (JSValueIsObjectOfClass( thisObject, JSNode_class(context))) {67 if (JSValueIsObjectOfClass( arguments[0], JSNode_class(context))) {66 if (JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) { 67 if (JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) { 68 68 Node* node = JSObjectGetPrivate(thisObject); 69 69 Node* child = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL)); … … 74 74 } 75 75 76 return JSValueMakeUndefined( );76 return JSValueMakeUndefined(context); 77 77 } 78 78 … … 83 83 84 84 if (argumentCount > 1) { 85 if (JSValueIsObjectOfClass( thisObject, JSNode_class(context))) {86 if (JSValueIsObjectOfClass( arguments[0], JSNode_class(context))) {87 if (JSValueIsObjectOfClass( arguments[1], JSNode_class(context))) {85 if (JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) { 86 if (JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) { 87 if (JSValueIsObjectOfClass(context, arguments[1], JSNode_class(context))) { 88 88 Node* node = JSObjectGetPrivate(thisObject); 89 89 Node* newChild = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL)); … … 96 96 } 97 97 98 return JSValueMakeUndefined( );98 return JSValueMakeUndefined(context); 99 99 } 100 100 … … 125 125 if (node) { 126 126 JSStringRef nodeType = JSStringCreateWithUTF8CString(node->nodeType); 127 JSValueRef value = JSValueMakeString( nodeType);127 JSValueRef value = JSValueMakeString(context, nodeType); 128 128 JSStringRelease(nodeType); 129 129 return value; … … 147 147 UNUSED_PARAM(object); 148 148 149 return JSValueMakeUndefined( );149 return JSValueMakeUndefined(context); 150 150 } 151 151 … … 183 183 if (!prototype) { 184 184 prototype = JSObjectMake(context, JSNodePrototype_class(context), NULL); 185 JSValueProtect( prototype);185 JSValueProtect(context, prototype); 186 186 } 187 187 return prototype; -
trunk/JavaScriptCore/API/JSNodeList.c
r15465 r15481 39 39 } 40 40 41 return JSValueMakeUndefined( );41 return JSValueMakeUndefined(context); 42 42 } 43 43 … … 65 65 NodeList* nodeList = JSObjectGetPrivate(thisObject); 66 66 assert(nodeList); 67 return JSValueMakeNumber( NodeList_length(nodeList));67 return JSValueMakeNumber(context, NodeList_length(nodeList)); 68 68 } 69 69 … … 77 77 NodeList* nodeList = JSObjectGetPrivate(thisObject); 78 78 assert(nodeList); 79 double index = JSValueToNumber(context, JSValueMakeString( propertyName), exception);79 double index = JSValueToNumber(context, JSValueMakeString(context, propertyName), exception); 80 80 unsigned uindex = index; 81 81 if (uindex == index) { // false for NaN … … 116 116 if (!prototype) { 117 117 prototype = JSObjectMake(context, JSNodeListPrototype_class(context), NULL); 118 JSValueProtect( prototype);118 JSValueProtect(context, prototype); 119 119 } 120 120 return prototype; -
trunk/JavaScriptCore/API/JSObjectRef.cpp
r15480 r15481 60 60 } 61 61 62 JSObjectRef JSObjectMake(JSContextRef c ontext, JSClassRef jsClass, JSValueRef prototype)63 { 64 JSLock lock; 65 66 ExecState* exec = toJS(c ontext);62 JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, JSValueRef prototype) 63 { 64 JSLock lock; 65 66 ExecState* exec = toJS(ctx); 67 67 JSValue* jsPrototype = toJS(prototype); 68 68 … … 73 73 return toRef(new JSObject(jsPrototype)); // slightly more efficient 74 74 else 75 return toRef(new JSCallbackObject(c ontext, jsClass, jsPrototype));76 } 77 78 JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef c ontext, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)79 { 80 JSLock lock; 81 ExecState* exec = toJS(c ontext);75 return toRef(new JSCallbackObject(ctx, jsClass, jsPrototype)); 76 } 77 78 JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction) 79 { 80 JSLock lock; 81 ExecState* exec = toJS(ctx); 82 82 Identifier nameID = name ? Identifier(toJS(name)) : Identifier("anonymous"); 83 83 … … 85 85 } 86 86 87 JSObjectRef JSObjectMakeConstructor(JSContextRef c ontext, JSObjectCallAsConstructorCallback callAsConstructor)88 { 89 JSLock lock; 90 ExecState* exec = toJS(c ontext);87 JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSObjectCallAsConstructorCallback callAsConstructor) 88 { 89 JSLock lock; 90 ExecState* exec = toJS(ctx); 91 91 return toRef(new JSCallbackConstructor(exec, callAsConstructor)); 92 92 } 93 93 94 JSObjectRef JSObjectMakeFunction(JSContextRef c ontext, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)95 { 96 JSLock lock; 97 98 ExecState* exec = toJS(c ontext);94 JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) 95 { 96 JSLock lock; 97 98 ExecState* exec = toJS(ctx); 99 99 UString::Rep* bodyRep = toJS(body); 100 100 UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; … … 117 117 } 118 118 119 JSValueRef JSObjectGetPrototype(JS ObjectRef object)119 JSValueRef JSObjectGetPrototype(JSContextRef, JSObjectRef object) 120 120 { 121 121 JSObject* jsObject = toJS(object); … … 123 123 } 124 124 125 void JSObjectSetPrototype(JS ObjectRef object, JSValueRef value)125 void JSObjectSetPrototype(JSContextRef, JSObjectRef object, JSValueRef value) 126 126 { 127 127 JSObject* jsObject = toJS(object); … … 131 131 } 132 132 133 bool JSObjectHasProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName)134 { 135 JSLock lock; 136 ExecState* exec = toJS(c ontext);133 bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) 134 { 135 JSLock lock; 136 ExecState* exec = toJS(ctx); 137 137 JSObject* jsObject = toJS(object); 138 138 UString::Rep* nameRep = toJS(propertyName); … … 141 141 } 142 142 143 JSValueRef JSObjectGetProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)144 { 145 JSLock lock; 146 ExecState* exec = toJS(c ontext);143 JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) 144 { 145 JSLock lock; 146 ExecState* exec = toJS(ctx); 147 147 JSObject* jsObject = toJS(object); 148 148 UString::Rep* nameRep = toJS(propertyName); … … 157 157 } 158 158 159 void JSObjectSetProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)160 { 161 JSLock lock; 162 ExecState* exec = toJS(c ontext);159 void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) 160 { 161 JSLock lock; 162 ExecState* exec = toJS(ctx); 163 163 JSObject* jsObject = toJS(object); 164 164 UString::Rep* nameRep = toJS(propertyName); … … 173 173 } 174 174 175 JSValueRef JSObjectGetPropertyAtIndex(JSContextRef c ontext, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception)176 { 177 JSLock lock; 178 ExecState* exec = toJS(c ontext);175 JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception) 176 { 177 JSLock lock; 178 ExecState* exec = toJS(ctx); 179 179 JSObject* jsObject = toJS(object); 180 180 … … 189 189 190 190 191 void JSObjectSetPropertyAtIndex(JSContextRef c ontext, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception)192 { 193 JSLock lock; 194 ExecState* exec = toJS(c ontext);191 void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception) 192 { 193 JSLock lock; 194 ExecState* exec = toJS(ctx); 195 195 JSObject* jsObject = toJS(object); 196 196 JSValue* jsValue = toJS(value); … … 204 204 } 205 205 206 bool JSObjectDeleteProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)207 { 208 JSLock lock; 209 ExecState* exec = toJS(c ontext);206 bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) 207 { 208 JSLock lock; 209 ExecState* exec = toJS(ctx); 210 210 JSObject* jsObject = toJS(object); 211 211 UString::Rep* nameRep = toJS(propertyName); … … 242 242 } 243 243 244 bool JSObjectIsFunction(JS ObjectRef object)244 bool JSObjectIsFunction(JSContextRef, JSObjectRef object) 245 245 { 246 246 JSObject* jsObject = toJS(object); … … 248 248 } 249 249 250 JSValueRef JSObjectCallAsFunction(JSContextRef c ontext, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)251 { 252 JSLock lock; 253 ExecState* exec = toJS(c ontext);250 JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 251 { 252 JSLock lock; 253 ExecState* exec = toJS(ctx); 254 254 JSObject* jsObject = toJS(object); 255 255 JSObject* jsThisObject = toJS(thisObject); … … 272 272 } 273 273 274 bool JSObjectIsConstructor(JS ObjectRef object)274 bool JSObjectIsConstructor(JSContextRef, JSObjectRef object) 275 275 { 276 276 JSObject* jsObject = toJS(object); … … 278 278 } 279 279 280 JSObjectRef JSObjectCallAsConstructor(JSContextRef c ontext, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)281 { 282 JSLock lock; 283 ExecState* exec = toJS(c ontext);280 JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 281 { 282 JSLock lock; 283 ExecState* exec = toJS(ctx); 284 284 JSObject* jsObject = toJS(object); 285 285 … … 308 308 }; 309 309 310 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef c ontext, JSObjectRef object)311 { 312 JSLock lock; 313 JSObject* jsObject = toJS(object); 314 ExecState* exec = toJS(c ontext);310 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object) 311 { 312 JSLock lock; 313 JSObject* jsObject = toJS(object); 314 ExecState* exec = toJS(ctx); 315 315 316 316 JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(); -
trunk/JavaScriptCore/API/JSObjectRef.h
r15480 r15481 61 61 @typedef JSObjectInitializeCallback 62 62 @abstract The callback invoked when an object is first created. 63 @param c ontextThe execution context to use.63 @param ctx The execution context to use. 64 64 @param object The JSObject being created. 65 65 @param exception A pointer to a JSValueRef in which to return an exception, if any. 66 66 @discussion If you named your function Initialize, you would declare it like this: 67 67 68 void Initialize(JSContextRef c ontext, JSObjectRef object, JSValueRef* exception);68 void Initialize(JSContextRef ctx, JSObjectRef object, JSValueRef* exception); 69 69 */ 70 70 typedef void 71 (*JSObjectInitializeCallback) (JSContextRef c ontext, JSObjectRef object, JSValueRef* exception);71 (*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object, JSValueRef* exception); 72 72 73 73 /*! … … 85 85 @typedef JSObjectHasPropertyCallback 86 86 @abstract The callback invoked when determining whether an object has a property. 87 @param c ontext The current execution context.87 @param ctx The execution context to use. 88 88 @param object The JSObject to search for the property. 89 89 @param propertyName A JSString containing the name of the property look up. … … 91 91 @discussion If you named your function HasProperty, you would declare it like this: 92 92 93 bool HasProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName);93 bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 94 94 95 95 If this function returns false, the hasProperty request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain. … … 100 100 */ 101 101 typedef bool 102 (*JSObjectHasPropertyCallback) (JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName);102 (*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 103 103 104 104 /*! 105 105 @typedef JSObjectGetPropertyCallback 106 106 @abstract The callback invoked when getting a property's value. 107 @param c ontext The current execution context.107 @param ctx The execution context to use. 108 108 @param object The JSObject to search for the property. 109 109 @param propertyName A JSString containing the name of the property to get. … … 112 112 @discussion If you named your function GetProperty, you would declare it like this: 113 113 114 JSValueRef GetProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);114 JSValueRef GetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 115 115 116 116 If this function returns NULL, the get request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain. 117 117 */ 118 118 typedef JSValueRef 119 (*JSObjectGetPropertyCallback) (JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);119 (*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 120 120 121 121 /*! 122 122 @typedef JSObjectSetPropertyCallback 123 123 @abstract The callback invoked when setting a property's value. 124 @param c ontext The current execution context.124 @param ctx The execution context to use. 125 125 @param object The JSObject on which to set the property's value. 126 126 @param propertyName A JSString containing the name of the property to set. … … 130 130 @discussion If you named your function SetProperty, you would declare it like this: 131 131 132 bool SetProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);132 bool SetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); 133 133 134 134 If this function returns false, the set request forwards to object's statically declared properties, then its parent class chain (which includes the default object class). 135 135 */ 136 136 typedef bool 137 (*JSObjectSetPropertyCallback) (JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);137 (*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); 138 138 139 139 /*! 140 140 @typedef JSObjectDeletePropertyCallback 141 141 @abstract The callback invoked when deleting a property. 142 @param c ontext The current execution context.142 @param ctx The execution context to use. 143 143 @param object The JSObject in which to delete the property. 144 144 @param propertyName A JSString containing the name of the property to delete. … … 147 147 @discussion If you named your function DeleteProperty, you would declare it like this: 148 148 149 bool DeleteProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);149 bool DeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 150 150 151 151 If this function returns false, the delete request forwards to object's statically declared properties, then its parent class chain (which includes the default object class). 152 152 */ 153 153 typedef bool 154 (*JSObjectDeletePropertyCallback) (JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);154 (*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 155 155 156 156 /*! 157 157 @typedef JSObjectGetPropertyNamesCallback 158 158 @abstract The callback invoked to get the names of an object's properties. 159 @param c ontext The current execution context.159 @param ctx The execution context to use. 160 160 @param object The JSObject whose property names need to be appended to propertyNames. 161 161 @param accumulator A JavaScript property name accumulator, to which the object should add the names of its properties. 162 162 @discussion If you named your function GetPropertyNames, you would declare it like this: 163 163 164 void GetPropertyNames(JSContextRef c ontext, JSObjectRef object, JSPropertyNameAccumulatorRef accumulator);164 void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef accumulator); 165 165 166 166 Use JSPropertyNameAccumulatorAddName to add property names to accumulator. … … 174 174 */ 175 175 typedef void 176 (*JSObjectGetPropertyNamesCallback) (JSContextRef c ontext, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);176 (*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); 177 177 178 178 /*! 179 179 @typedef JSObjectCallAsFunctionCallback 180 180 @abstract The callback invoked when an object is called as a function. 181 @param c ontext The current execution context.181 @param ctx The execution context to use. 182 182 @param function A JSObject that is the function being called. 183 183 @param thisObject A JSObject that is the 'this' variable in the function's scope. … … 188 188 @discussion If you named your function CallAsFunction, you would declare it like this: 189 189 190 JSValueRef CallAsFunction(JSContextRef c ontext, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);190 JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 191 191 192 192 If your callback were invoked by the JavaScript expression 'myObject.myMemberFunction()', function would be set to myMemberFunction, and thisObject would be set to myObject. … … 195 195 */ 196 196 typedef JSValueRef 197 (*JSObjectCallAsFunctionCallback) (JSContextRef c ontext, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);197 (*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 198 198 199 199 /*! 200 200 @typedef JSObjectCallAsConstructorCallback 201 201 @abstract The callback invoked when an object is used as a constructor in a 'new' expression. 202 @param c ontext The current execution context.202 @param ctx The execution context to use. 203 203 @param constructor A JSObject that is the constructor being called. 204 204 @param argumentCount An integer count of the number of arguments in arguments. … … 208 208 @discussion If you named your function CallAsConstructor, you would declare it like this: 209 209 210 JSObjectRef CallAsConstructor(JSContextRef c ontext, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);210 JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 211 211 212 212 If your callback were invoked by the JavaScript expression 'new myConstructorFunction()', constructor would be set to myConstructorFunction. … … 215 215 */ 216 216 typedef JSObjectRef 217 (*JSObjectCallAsConstructorCallback) (JSContextRef c ontext, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);217 (*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 218 218 219 219 /*! 220 220 @typedef JSObjectHasInstanceCallback 221 221 @abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression. 222 @param c ontext The current execution context.222 @param ctx The execution context to use. 223 223 @param constructor The JSObject that is the target of the 'instanceof' expression. 224 224 @param possibleInstance The JSValue being tested to determine if it is an instance of constructor. … … 228 228 @discussion If you named your function HasInstance, you would declare it like this: 229 229 230 bool HasInstance(JSContextRef c ontext, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);230 bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); 231 231 232 232 If your callback were invoked by the JavaScript expression 'someValue instanceof myObject', constructor would be set to myObject and possibleInstance would be set to someValue. … … 237 237 */ 238 238 typedef bool 239 (*JSObjectHasInstanceCallback) (JSContextRef c ontext, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);239 (*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); 240 240 241 241 /*! 242 242 @typedef JSObjectConvertToTypeCallback 243 243 @abstract The callback invoked when converting an object to a particular JavaScript type. 244 @param c ontext The current execution context.244 @param ctx The execution context to use. 245 245 @param object The JSObject to convert. 246 246 @param type A JSType specifying the JavaScript type to convert to. … … 249 249 @discussion If you named your function ConvertToType, you would declare it like this: 250 250 251 JSValueRef ConvertToType(JSContextRef c ontext, JSObjectRef object, JSType type, JSValueRef* exception);251 JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); 252 252 253 253 If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class). … … 256 256 */ 257 257 typedef JSValueRef 258 (*JSObjectConvertToTypeCallback) (JSContextRef c ontext, JSObjectRef object, JSType type, JSValueRef* exception);258 (*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); 259 259 260 260 /*! … … 376 376 @function 377 377 @abstract Creates a JavaScript object with a given class and prototype. 378 @param c ontextThe execution context to use.378 @param ctx The execution context to use. 379 379 @param jsClass The JSClass to assign to the object. Pass NULL to use the default object class. 380 380 @param prototype The prototype to assign to the object. Pass NULL to use the default object prototype. 381 381 @result A JSObject with the given class and prototype. 382 382 */ 383 JSObjectRef JSObjectMake(JSContextRef c ontext, JSClassRef jsClass, JSValueRef prototype);383 JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, JSValueRef prototype); 384 384 385 385 /*! 386 386 @function 387 387 @abstract Convenience method for creating a JavaScript function with a given callback as its implementation. 388 @param c ontextThe execution context to use.388 @param ctx The execution context to use. 389 389 @param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function. 390 390 @param callAsFunction The JSObjectCallAsFunctionCallback to invoke when the function is called. 391 391 @result A JSObject that is an anonymous function. The object's prototype will be the default function prototype. 392 392 */ 393 JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef c ontext, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction);393 JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction); 394 394 /*! 395 395 @function 396 396 @abstract Convenience method for creating a JavaScript constructor with a given callback as its implementation. 397 @param c ontextThe execution context to use.397 @param ctx The execution context to use. 398 398 @param callAsConstructor The JSObjectCallAsConstructorCallback to invoke when the constructor is used in a 'new' expression. 399 399 @result A JSObject that is a constructor. The object's prototype will be the default object prototype. 400 400 */ 401 JSObjectRef JSObjectMakeConstructor(JSContextRef c ontext, JSObjectCallAsConstructorCallback callAsConstructor);401 JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSObjectCallAsConstructorCallback callAsConstructor); 402 402 403 403 /*! 404 404 @function 405 405 @abstract Creates a function with a given script as its body. 406 @param c ontextThe execution context to use.406 @param ctx The execution context to use. 407 407 @param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function. 408 408 @param parameterCount An integer count of the number of parameter names in parameterNames. … … 415 415 @discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution. 416 416 */ 417 JSObjectRef JSObjectMakeFunction(JSContextRef c ontext, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);417 JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); 418 418 419 419 /*! 420 420 @function 421 421 @abstract Gets an object's prototype. 422 @param ctx The execution context to use. 422 423 @param object A JSObject whose prototype you want to get. 423 424 @result A JSValue containing the object's prototype. 424 425 */ 425 JSValueRef JSObjectGetPrototype(JSObjectRef object); 426 JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object); 427 426 428 /*! 427 429 @function 428 430 @abstract Sets an object's prototype. 431 @param ctx The execution context to use. 429 432 @param object The JSObject whose prototype you want to set. 430 433 @param value A JSValue to set as the object's prototype. 431 434 */ 432 void JSObjectSetPrototype(JS ObjectRef object, JSValueRef value);435 void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value); 433 436 434 437 /*! … … 439 442 @result true if the object has a property whose name matches propertyName, otherwise false. 440 443 */ 441 bool JSObjectHasProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName);444 bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 442 445 443 446 /*! 444 447 @function 445 448 @abstract Gets a property from an object. 446 @param c ontextThe execution context to use.449 @param ctx The execution context to use. 447 450 @param object The JSObject whose property you want to get. 448 451 @param propertyName A JSString containing the property's name. … … 450 453 @result The property's value if object has the property, otherwise the undefined value. 451 454 */ 452 JSValueRef JSObjectGetProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);455 JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 453 456 454 457 /*! 455 458 @function 456 459 @abstract Sets a property on an object. 457 @param c ontextThe execution context to use.460 @param ctx The execution context to use. 458 461 @param object The JSObject whose property you want to set. 459 462 @param propertyName A JSString containing the property's name. … … 462 465 @param attributes A logically ORed set of JSPropertyAttributes to give to the property. 463 466 */ 464 void JSObjectSetProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception);467 void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception); 465 468 466 469 /*! 467 470 @function 468 471 @abstract Deletes a property from an object. 469 @param c ontextThe execution context to use.472 @param ctx The execution context to use. 470 473 @param object The JSObject whose property you want to delete. 471 474 @param propertyName A JSString containing the property's name. … … 473 476 @result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set). 474 477 */ 475 bool JSObjectDeleteProperty(JSContextRef c ontext, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);478 bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 476 479 477 480 /*! 478 481 @function 479 482 @abstract Gets a property from an object by numeric index. 480 @param c ontextThe execution context to use.483 @param ctx The execution context to use. 481 484 @param object The JSObject whose property you want to get. 482 485 @param propertyIndex The property's name as a number … … 485 488 @discussion Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but it enables optimized access to JavaScript arrays. 486 489 */ 487 JSValueRef JSObjectGetPropertyAtIndex(JSContextRef c ontext, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception);490 JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception); 488 491 489 492 /*! 490 493 @function 491 494 @abstract Sets a property on an object by numeric index. 492 @param c ontextThe execution context to use.495 @param ctx The execution context to use. 493 496 @param object The JSObject whose property you want to set. 494 497 @param propertyIndex The property's name as a number … … 497 500 @discussion Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but it enables optimized access to JavaScript arrays. 498 501 */ 499 void JSObjectSetPropertyAtIndex(JSContextRef c ontext, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception);502 void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception); 500 503 501 504 /*! … … 520 523 @function 521 524 @abstract Tests whether an object can be called as a function. 525 @param ctx The execution context to use. 522 526 @param object The JSObject to test. 523 527 @result true if the object can be called as a function, otherwise false. 524 528 */ 525 bool JSObjectIsFunction(JSObjectRef object); 529 bool JSObjectIsFunction(JSContextRef ctx, JSObjectRef object); 530 526 531 /*! 527 532 @function 528 533 @abstract Calls an object as a function. 529 @param c ontextThe execution context to use.534 @param ctx The execution context to use. 530 535 @param object The JSObject to call as a function. 531 536 @param thisObject The object to use as "this," or NULL to use the global object as "this." … … 535 540 @result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function. 536 541 */ 537 JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 542 JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 543 538 544 /*! 539 545 @function 540 546 @abstract Tests whether an object can be called as a constructor. 547 @param ctx The execution context to use. 541 548 @param object The JSObject to test. 542 549 @result true if the object can be called as a constructor, otherwise false. 543 550 */ 544 bool JSObjectIsConstructor(JSObjectRef object); 551 bool JSObjectIsConstructor(JSContextRef ctx, JSObjectRef object); 552 545 553 /*! 546 554 @function 547 555 @abstract Calls an object as a constructor. 548 @param c ontextThe execution context to use.556 @param ctx The execution context to use. 549 557 @param object The JSObject to call as a constructor. 550 558 @param argumentCount An integer count of the number of arguments in arguments. … … 553 561 @result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor. 554 562 */ 555 JSObjectRef JSObjectCallAsConstructor(JSContextRef c ontext, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);563 JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 556 564 557 565 /*! 558 566 @function 559 567 @abstract Get the names of all enumerable properties of an object. 560 @param c ontextThe execution context to use.568 @param ctx The execution context to use. 561 569 @param object The object from which to get property names. 562 570 @result A JSPropertyNameArray containing the names of all the object's enumerable properties. 563 571 */ 564 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef c ontext, JSObjectRef object);572 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object); 565 573 566 574 /*! -
trunk/JavaScriptCore/API/JSStringRef.cpp
r15404 r15481 36 36 37 37 using namespace KJS; 38 39 JSValueRef JSValueMakeString(JSStringRef string)40 {41 JSLock lock;42 UString::Rep* rep = toJS(string);43 return toRef(jsString(UString(rep)));44 }45 38 46 39 JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars) -
trunk/JavaScriptCore/API/JSValueRef.cpp
r15443 r15481 40 40 #include <algorithm> // for std::min 41 41 42 JSType JSValueGetType(JS ValueRef value)42 JSType JSValueGetType(JSContextRef, JSValueRef value) 43 43 { 44 44 KJS::JSValue* jsValue = toJS(value); … … 64 64 using namespace KJS; // placed here to avoid conflict between KJS::JSType and JSType, above. 65 65 66 bool JSValueIsUndefined(JS ValueRef value)66 bool JSValueIsUndefined(JSContextRef, JSValueRef value) 67 67 { 68 68 JSValue* jsValue = toJS(value); … … 70 70 } 71 71 72 bool JSValueIsNull(JS ValueRef value)72 bool JSValueIsNull(JSContextRef, JSValueRef value) 73 73 { 74 74 JSValue* jsValue = toJS(value); … … 76 76 } 77 77 78 bool JSValueIsBoolean(JS ValueRef value)78 bool JSValueIsBoolean(JSContextRef, JSValueRef value) 79 79 { 80 80 JSValue* jsValue = toJS(value); … … 82 82 } 83 83 84 bool JSValueIsNumber(JS ValueRef value)84 bool JSValueIsNumber(JSContextRef, JSValueRef value) 85 85 { 86 86 JSValue* jsValue = toJS(value); … … 88 88 } 89 89 90 bool JSValueIsString(JS ValueRef value)90 bool JSValueIsString(JSContextRef, JSValueRef value) 91 91 { 92 92 JSValue* jsValue = toJS(value); … … 94 94 } 95 95 96 bool JSValueIsObject(JS ValueRef value)96 bool JSValueIsObject(JSContextRef, JSValueRef value) 97 97 { 98 98 JSValue* jsValue = toJS(value); … … 100 100 } 101 101 102 bool JSValueIsObjectOfClass(JS ValueRef value, JSClassRef jsClass)102 bool JSValueIsObjectOfClass(JSContextRef, JSValueRef value, JSClassRef jsClass) 103 103 { 104 104 JSValue* jsValue = toJS(value); … … 110 110 } 111 111 112 bool JSValueIsEqual(JSContextRef c ontext, JSValueRef a, JSValueRef b, JSValueRef* exception)113 { 114 JSLock lock; 115 ExecState* exec = toJS(c ontext);112 bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception) 113 { 114 JSLock lock; 115 ExecState* exec = toJS(ctx); 116 116 JSValue* jsA = toJS(a); 117 117 JSValue* jsB = toJS(b); … … 126 126 } 127 127 128 bool JSValueIsStrictEqual(JSContextRef c ontext, JSValueRef a, JSValueRef b)129 { 130 JSLock lock; 131 ExecState* exec = toJS(c ontext);128 bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b) 129 { 130 JSLock lock; 131 ExecState* exec = toJS(ctx); 132 132 JSValue* jsA = toJS(a); 133 133 JSValue* jsB = toJS(b); … … 138 138 } 139 139 140 bool JSValueIsInstanceOfConstructor(JSContextRef c ontext, JSValueRef value, JSObjectRef constructor, JSValueRef* exception)141 { 142 ExecState* exec = toJS(c ontext);140 bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception) 141 { 142 ExecState* exec = toJS(ctx); 143 143 JSValue* jsValue = toJS(value); 144 144 JSObject* jsConstructor = toJS(constructor); … … 154 154 } 155 155 156 JSValueRef JSValueMakeUndefined( )156 JSValueRef JSValueMakeUndefined(JSContextRef) 157 157 { 158 158 return toRef(jsUndefined()); 159 159 } 160 160 161 JSValueRef JSValueMakeNull( )161 JSValueRef JSValueMakeNull(JSContextRef) 162 162 { 163 163 return toRef(jsNull()); 164 164 } 165 165 166 JSValueRef JSValueMakeBoolean( bool value)166 JSValueRef JSValueMakeBoolean(JSContextRef, bool value) 167 167 { 168 168 return toRef(jsBoolean(value)); 169 169 } 170 170 171 JSValueRef JSValueMakeNumber( double value)171 JSValueRef JSValueMakeNumber(JSContextRef, double value) 172 172 { 173 173 JSLock lock; … … 175 175 } 176 176 177 bool JSValueToBoolean(JSContextRef context, JSValueRef value) 178 { 179 ExecState* exec = toJS(context); 177 JSValueRef JSValueMakeString(JSContextRef, JSStringRef string) 178 { 179 JSLock lock; 180 UString::Rep* rep = toJS(string); 181 return toRef(jsString(UString(rep))); 182 } 183 184 bool JSValueToBoolean(JSContextRef ctx, JSValueRef value) 185 { 186 ExecState* exec = toJS(ctx); 180 187 JSValue* jsValue = toJS(value); 181 188 return jsValue->toBoolean(exec); 182 189 } 183 190 184 double JSValueToNumber(JSContextRef c ontext, JSValueRef value, JSValueRef* exception)185 { 186 JSLock lock; 187 JSValue* jsValue = toJS(value); 188 ExecState* exec = toJS(c ontext);191 double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception) 192 { 193 JSLock lock; 194 JSValue* jsValue = toJS(value); 195 ExecState* exec = toJS(ctx); 189 196 190 197 double number = jsValue->toNumber(exec); … … 198 205 } 199 206 200 JSStringRef JSValueToStringCopy(JSContextRef c ontext, JSValueRef value, JSValueRef* exception)201 { 202 JSLock lock; 203 JSValue* jsValue = toJS(value); 204 ExecState* exec = toJS(c ontext);207 JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception) 208 { 209 JSLock lock; 210 JSValue* jsValue = toJS(value); 211 ExecState* exec = toJS(ctx); 205 212 206 213 JSStringRef stringRef = toRef(jsValue->toString(exec).rep()->ref()); … … 214 221 } 215 222 216 JSObjectRef JSValueToObject(JSContextRef c ontext, JSValueRef value, JSValueRef* exception)217 { 218 JSLock lock; 219 ExecState* exec = toJS(c ontext);223 JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception) 224 { 225 JSLock lock; 226 ExecState* exec = toJS(ctx); 220 227 JSValue* jsValue = toJS(value); 221 228 … … 230 237 } 231 238 232 void JSValueProtect(JS ValueRef value)239 void JSValueProtect(JSContextRef, JSValueRef value) 233 240 { 234 241 JSLock lock; … … 237 244 } 238 245 239 void JSValueUnprotect(JS ValueRef value)246 void JSValueUnprotect(JSContextRef, JSValueRef value) 240 247 { 241 248 JSLock lock; -
trunk/JavaScriptCore/API/JSValueRef.h
r15443 r15481 58 58 @function 59 59 @abstract Returns a JavaScript value's type. 60 @param ctx The execution context to use. 60 61 @param value The JSValue whose type you want to obtain. 61 62 @result A value of type JSType that identifies value's type. 62 63 */ 63 JSType JSValueGetType(JS ValueRef value);64 JSType JSValueGetType(JSContextRef ctx, JSValueRef value); 64 65 65 66 /*! 66 67 @function 67 68 @abstract Tests whether a JavaScript value's type is the undefined type. 69 @param ctx The execution context to use. 68 70 @param value The JSValue to test. 69 71 @result true if value's type is the undefined type, otherwise false. 70 72 */ 71 bool JSValueIsUndefined(JS ValueRef value);73 bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value); 72 74 73 75 /*! 74 76 @function 75 77 @abstract Tests whether a JavaScript value's type is the null type. 78 @param ctx The execution context to use. 76 79 @param value The JSValue to test. 77 80 @result true if value's type is the null type, otherwise false. 78 81 */ 79 bool JSValueIsNull(JS ValueRef value);82 bool JSValueIsNull(JSContextRef ctx, JSValueRef value); 80 83 81 84 /*! 82 85 @function 83 86 @abstract Tests whether a JavaScript value's type is the boolean type. 87 @param ctx The execution context to use. 84 88 @param value The JSValue to test. 85 89 @result true if value's type is the boolean type, otherwise false. 86 90 */ 87 bool JSValueIsBoolean(JS ValueRef value);91 bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value); 88 92 89 93 /*! 90 94 @function 91 95 @abstract Tests whether a JavaScript value's type is the number type. 96 @param ctx The execution context to use. 92 97 @param value The JSValue to test. 93 98 @result true if value's type is the number type, otherwise false. 94 99 */ 95 bool JSValueIsNumber(JS ValueRef value);100 bool JSValueIsNumber(JSContextRef ctx, JSValueRef value); 96 101 97 102 /*! 98 103 @function 99 104 @abstract Tests whether a JavaScript value's type is the string type. 105 @param ctx The execution context to use. 100 106 @param value The JSValue to test. 101 107 @result true if value's type is the string type, otherwise false. 102 108 */ 103 bool JSValueIsString(JS ValueRef value);109 bool JSValueIsString(JSContextRef ctx, JSValueRef value); 104 110 105 111 /*! 106 112 @function 107 113 @abstract Tests whether a JavaScript value's type is the object type. 114 @param ctx The execution context to use. 108 115 @param value The JSValue to test. 109 116 @result true if value's type is the object type, otherwise false. 110 117 */ 111 bool JSValueIsObject(JS ValueRef value);118 bool JSValueIsObject(JSContextRef ctx, JSValueRef value); 112 119 113 120 /*! 114 121 @function 115 122 @abstract Tests whether a JavaScript value is an object with a given 123 @param ctx The execution context to use. 116 124 class in its class chain. 117 125 @param value The JSValue to test. … … 119 127 otherwise false. 120 128 */ 121 bool JSValueIsObjectOfClass(JS ValueRef value, JSClassRef jsClass);129 bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass); 122 130 123 131 // Comparing values … … 126 134 @function 127 135 @abstract Tests whether two JavaScript values are equal, as compared by the JS == operator. 128 @param c ontextThe execution context to use.136 @param ctx The execution context to use. 129 137 @param a The first value to test. 130 138 @param b The second value to test. … … 132 140 @result true if the two values are equal, false if they are not equal or an exception is thrown. 133 141 */ 134 bool JSValueIsEqual(JSContextRef c ontext, JSValueRef a, JSValueRef b, JSValueRef* exception);142 bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception); 135 143 136 144 /*! 137 145 @function 138 146 @abstract Tests whether two JavaScript values are strict equal, as compared by the JS === operator. 139 @param c ontextThe execution context to use.147 @param ctx The execution context to use. 140 148 @param a The first value to test. 141 149 @param b The second value to test. 142 150 @result true if the two values are strict equal, otherwise false. 143 151 */ 144 bool JSValueIsStrictEqual(JSContextRef c ontext, JSValueRef a, JSValueRef b);152 bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b); 145 153 146 154 /*! 147 155 @function 148 156 @abstract Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator. 149 @param c ontextThe execution context to use.157 @param ctx The execution context to use. 150 158 @param value The JSValue to test. 151 159 @param object The constructor to test against. … … 153 161 @result true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false. 154 162 */ 155 bool JSValueIsInstanceOfConstructor(JSContextRef c ontext, JSValueRef value, JSObjectRef constructor, JSValueRef* exception);163 bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception); 156 164 157 165 // Creating values … … 159 167 /*! 160 168 @function 161 @abstract Creates a JavaScript value of the undefined type. 162 @result The unique undefined value. 163 */ 164 JSValueRef JSValueMakeUndefined(void); 165 166 /*! 167 @function 168 @abstract Creates a JavaScript value of the null type. 169 @result The unique null value. 170 */ 171 JSValueRef JSValueMakeNull(void); 169 @abstract Creates a JavaScript value of the undefined type. 170 @param ctx The execution context to use. 171 @result The unique undefined value. 172 */ 173 JSValueRef JSValueMakeUndefined(JSContextRef ctx); 174 175 /*! 176 @function 177 @abstract Creates a JavaScript value of the null type. 178 @param ctx The execution context to use. 179 @result The unique null value. 180 */ 181 JSValueRef JSValueMakeNull(JSContextRef ctx); 172 182 173 183 /*! 174 184 @function 175 185 @abstract Creates a JavaScript value of the boolean type. 186 @param ctx The execution context to use. 176 187 @param boolean The bool to assign to the newly created JSValue. 177 188 @result A JSValue of the boolean type, representing the value of boolean. 178 189 */ 179 180 JSValueRef JSValueMakeBoolean(bool boolean); 190 JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool boolean); 181 191 182 192 /*! 183 193 @function 184 194 @abstract Creates a JavaScript value of the number type. 195 @param ctx The execution context to use. 185 196 @param number The double to assign to the newly created JSValue. 186 197 @result A JSValue of the number type, representing the value of number. 187 198 */ 188 JSValueRef JSValueMakeNumber( double number);199 JSValueRef JSValueMakeNumber(JSContextRef ctx, double number); 189 200 190 201 /*! 191 202 @function 192 203 @abstract Creates a JavaScript value of the string type. 204 @param ctx The execution context to use. 193 205 @param string The JSString to assign to the newly created JSValue. The 194 206 newly created JSValue retains string, and releases it upon garbage collection. 195 207 @result A JSValue of the string type, representing the value of string. 196 208 */ 197 JSValueRef JSValueMakeString(JS StringRef string);209 JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string); 198 210 199 211 // Converting to primitive values … … 202 214 @function 203 215 @abstract Converts a JavaScript value to boolean and returns the resulting boolean. 204 @param c ontextThe execution context to use.216 @param ctx The execution context to use. 205 217 @param value The JSValue to convert. 206 218 @result The boolean result of conversion. 207 219 */ 208 bool JSValueToBoolean(JSContextRef c ontext, JSValueRef value);220 bool JSValueToBoolean(JSContextRef ctx, JSValueRef value); 209 221 210 222 /*! 211 223 @function 212 224 @abstract Converts a JavaScript value to number and returns the resulting number. 213 @param c ontextThe execution context to use.225 @param ctx The execution context to use. 214 226 @param value The JSValue to convert. 215 227 @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. 216 228 @result The numeric result of conversion, or NaN if an exception is thrown. 217 229 */ 218 double JSValueToNumber(JSContextRef c ontext, JSValueRef value, JSValueRef* exception);230 double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception); 219 231 220 232 /*! 221 233 @function 222 234 @abstract Converts a JavaScript value to string and copies the result into a JavaScript string. 223 @param c ontextThe execution context to use.235 @param ctx The execution context to use. 224 236 @param value The JSValue to convert. 225 237 @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. 226 238 @result A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule. 227 239 */ 228 JSStringRef JSValueToStringCopy(JSContextRef c ontext, JSValueRef value, JSValueRef* exception);240 JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception); 229 241 230 242 /*! 231 243 @function 232 244 @abstract Converts a JavaScript value to object and returns the resulting object. 233 @param c ontextThe execution context to use.245 @param ctx The execution context to use. 234 246 @param value The JSValue to convert. 235 247 @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. 236 248 @result The JSObject result of conversion, or NULL if an exception is thrown. 237 249 */ 238 JSObjectRef JSValueToObject(JSContextRef c ontext, JSValueRef value, JSValueRef* exception);250 JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception); 239 251 240 252 // Garbage collection … … 242 254 @function 243 255 @abstract Protects a JavaScript value from garbage collection. 256 @param ctx The execution context to use. 244 257 @param value The JSValue to protect. 245 258 @discussion A value may be protected multiple times and must be unprotected an 246 259 equal number of times before becoming eligible for garbage collection. 247 260 */ 248 void JSValueProtect(JS ValueRef value);261 void JSValueProtect(JSContextRef ctx, JSValueRef value); 249 262 250 263 /*! 251 264 @function 252 265 @abstract Unprotects a JavaScript value from garbage collection. 266 @param ctx The execution context to use. 253 267 @param value The JSValue to unprotect. 254 268 @discussion A value may be protected multiple times and must be unprotected an 255 269 equal number of times before becoming eligible for garbage collection. 256 270 */ 257 void JSValueUnprotect(JS ValueRef value);271 void JSValueUnprotect(JSContextRef ctx, JSValueRef value); 258 272 259 273 #ifdef __cplusplus -
trunk/JavaScriptCore/API/minidom.c
r15480 r15481 89 89 } 90 90 91 return JSValueMakeUndefined( );91 return JSValueMakeUndefined(context); 92 92 } 93 93 -
trunk/JavaScriptCore/API/testapi.c
r15480 r15481 130 130 131 131 if (JSStringIsEqualToUTF8CString(propertyName, "alwaysOne")) { 132 return JSValueMakeNumber( 1);132 return JSValueMakeNumber(context, 1); 133 133 } 134 134 135 135 if (JSStringIsEqualToUTF8CString(propertyName, "myPropertyName")) { 136 return JSValueMakeNumber( 1);136 return JSValueMakeNumber(context, 1); 137 137 } 138 138 139 139 if (JSStringIsEqualToUTF8CString(propertyName, "cantFind")) { 140 return JSValueMakeUndefined( );140 return JSValueMakeUndefined(context); 141 141 } 142 142 143 143 if (JSStringIsEqualToUTF8CString(propertyName, "0")) { 144 *exception = JSValueMakeNumber( 1);145 return JSValueMakeNumber( 1);144 *exception = JSValueMakeNumber(context, 1); 145 return JSValueMakeNumber(context, 1); 146 146 } 147 147 … … 170 170 171 171 if (JSStringIsEqualToUTF8CString(propertyName, "throwOnDelete")) { 172 *exception = JSValueMakeNumber( 2);172 *exception = JSValueMakeNumber(context, 2); 173 173 return false; 174 174 } … … 198 198 UNUSED_PARAM(thisObject); 199 199 200 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber( 0)))201 return JSValueMakeNumber( 1);202 203 return JSValueMakeUndefined( );200 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(context, 0))) 201 return JSValueMakeNumber(context, 1); 202 203 return JSValueMakeUndefined(context); 204 204 } 205 205 … … 209 209 UNUSED_PARAM(object); 210 210 211 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber( 0)))212 return JSValueToObject(context, JSValueMakeNumber( 1), NULL);213 214 return JSValueToObject(context, JSValueMakeNumber( 0), NULL);211 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(context, 0))) 212 return JSValueToObject(context, JSValueMakeNumber(context, 1), NULL); 213 214 return JSValueToObject(context, JSValueMakeNumber(context, 0), NULL); 215 215 } 216 216 … … 233 233 switch (type) { 234 234 case kJSTypeNumber: 235 return JSValueMakeNumber( 1);235 return JSValueMakeNumber(context, 1); 236 236 default: 237 237 break; … … 305 305 } 306 306 307 return JSValueMakeUndefined( );307 return JSValueMakeUndefined(context); 308 308 } 309 309 … … 332 332 333 333 JSObjectRef globalObject = JSContextGetGlobalObject(context); 334 assert(JSValueIsObject( globalObject));335 336 JSValueRef jsUndefined = JSValueMakeUndefined( );337 JSValueRef jsNull = JSValueMakeNull( );338 JSValueRef jsTrue = JSValueMakeBoolean( true);339 JSValueRef jsFalse = JSValueMakeBoolean( false);340 JSValueRef jsZero = JSValueMakeNumber( 0);341 JSValueRef jsOne = JSValueMakeNumber( 1);342 JSValueRef jsOneThird = JSValueMakeNumber( 1.0 / 3.0);343 JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, JSValueMakeNull( ));334 assert(JSValueIsObject(context, globalObject)); 335 336 JSValueRef jsUndefined = JSValueMakeUndefined(context); 337 JSValueRef jsNull = JSValueMakeNull(context); 338 JSValueRef jsTrue = JSValueMakeBoolean(context, true); 339 JSValueRef jsFalse = JSValueMakeBoolean(context, false); 340 JSValueRef jsZero = JSValueMakeNumber(context, 0); 341 JSValueRef jsOne = JSValueMakeNumber(context, 1); 342 JSValueRef jsOneThird = JSValueMakeNumber(context, 1.0 / 3.0); 343 JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, JSValueMakeNull(context)); 344 344 345 345 // FIXME: test funny utf8 characters 346 346 JSStringRef jsEmptyIString = JSStringCreateWithUTF8CString(""); 347 JSValueRef jsEmptyString = JSValueMakeString( jsEmptyIString);347 JSValueRef jsEmptyString = JSValueMakeString(context, jsEmptyIString); 348 348 349 349 JSStringRef jsOneIString = JSStringCreateWithUTF8CString("1"); 350 JSValueRef jsOneString = JSValueMakeString( jsOneIString);350 JSValueRef jsOneString = JSValueMakeString(context, jsOneIString); 351 351 352 352 #if defined(__APPLE__) … … 360 360 361 361 JSStringRef jsCFIString = JSStringCreateWithCFString(cfString); 362 JSValueRef jsCFString = JSValueMakeString( jsCFIString);362 JSValueRef jsCFString = JSValueMakeString(context, jsCFIString); 363 363 364 364 CFStringRef cfEmptyString = CFStringCreateWithCString(kCFAllocatorDefault, "", kCFStringEncodingUTF8); 365 365 366 366 JSStringRef jsCFEmptyIString = JSStringCreateWithCFString(cfEmptyString); 367 JSValueRef jsCFEmptyString = JSValueMakeString( jsCFEmptyIString);367 JSValueRef jsCFEmptyString = JSValueMakeString(context, jsCFEmptyIString); 368 368 369 369 CFIndex cfStringLength = CFStringGetLength(cfString); … … 373 373 buffer); 374 374 JSStringRef jsCFIStringWithCharacters = JSStringCreateWithCharacters(buffer, cfStringLength); 375 JSValueRef jsCFStringWithCharacters = JSValueMakeString( jsCFIStringWithCharacters);375 JSValueRef jsCFStringWithCharacters = JSValueMakeString(context, jsCFIStringWithCharacters); 376 376 377 377 JSStringRef jsCFEmptyIStringWithCharacters = JSStringCreateWithCharacters(buffer, CFStringGetLength(cfEmptyString)); 378 JSValueRef jsCFEmptyStringWithCharacters = JSValueMakeString( jsCFEmptyIStringWithCharacters);379 #endif // __APPLE__ 380 381 assert(JSValueGetType( jsUndefined) == kJSTypeUndefined);382 assert(JSValueGetType( jsNull) == kJSTypeNull);383 assert(JSValueGetType( jsTrue) == kJSTypeBoolean);384 assert(JSValueGetType( jsFalse) == kJSTypeBoolean);385 assert(JSValueGetType( jsZero) == kJSTypeNumber);386 assert(JSValueGetType( jsOne) == kJSTypeNumber);387 assert(JSValueGetType( jsOneThird) == kJSTypeNumber);388 assert(JSValueGetType( jsEmptyString) == kJSTypeString);389 assert(JSValueGetType( jsOneString) == kJSTypeString);390 #if defined(__APPLE__) 391 assert(JSValueGetType( jsCFString) == kJSTypeString);392 assert(JSValueGetType( jsCFStringWithCharacters) == kJSTypeString);393 assert(JSValueGetType( jsCFEmptyString) == kJSTypeString);394 assert(JSValueGetType( jsCFEmptyStringWithCharacters) == kJSTypeString);378 JSValueRef jsCFEmptyStringWithCharacters = JSValueMakeString(context, jsCFEmptyIStringWithCharacters); 379 #endif // __APPLE__ 380 381 assert(JSValueGetType(context, jsUndefined) == kJSTypeUndefined); 382 assert(JSValueGetType(context, jsNull) == kJSTypeNull); 383 assert(JSValueGetType(context, jsTrue) == kJSTypeBoolean); 384 assert(JSValueGetType(context, jsFalse) == kJSTypeBoolean); 385 assert(JSValueGetType(context, jsZero) == kJSTypeNumber); 386 assert(JSValueGetType(context, jsOne) == kJSTypeNumber); 387 assert(JSValueGetType(context, jsOneThird) == kJSTypeNumber); 388 assert(JSValueGetType(context, jsEmptyString) == kJSTypeString); 389 assert(JSValueGetType(context, jsOneString) == kJSTypeString); 390 #if defined(__APPLE__) 391 assert(JSValueGetType(context, jsCFString) == kJSTypeString); 392 assert(JSValueGetType(context, jsCFStringWithCharacters) == kJSTypeString); 393 assert(JSValueGetType(context, jsCFEmptyString) == kJSTypeString); 394 assert(JSValueGetType(context, jsCFEmptyStringWithCharacters) == kJSTypeString); 395 395 #endif // __APPLE__ 396 396 … … 419 419 420 420 exception = NULL; 421 assert(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber( 1), &exception));421 assert(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber(context, 1), &exception)); 422 422 assert(exception); 423 423 … … 510 510 511 511 jsGlobalValue = JSObjectMake(context, NULL, NULL); 512 JSValueProtect( jsGlobalValue);513 JSGarbageCollect( );514 assert(JSValueIsObject( jsGlobalValue));515 JSValueUnprotect( jsGlobalValue);512 JSValueProtect(context, jsGlobalValue); 513 JSGarbageCollect(context); 514 assert(JSValueIsObject(context, jsGlobalValue)); 515 JSValueUnprotect(context, jsGlobalValue); 516 516 517 517 JSStringRef goodSyntax = JSStringCreateWithUTF8CString("x = 1;"); … … 532 532 result = JSEvaluateScript(context, badSyntax, NULL, NULL, 1, &exception); 533 533 assert(!result); 534 assert(JSValueIsObject( exception));534 assert(JSValueIsObject(context, exception)); 535 535 536 536 JSStringRef array = JSStringCreateWithUTF8CString("Array"); … … 539 539 result = JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, NULL); 540 540 assert(result); 541 assert(JSValueIsObject( result));541 assert(JSValueIsObject(context, result)); 542 542 assert(JSValueIsInstanceOfConstructor(context, result, arrayConstructor, NULL)); 543 assert(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull( ), arrayConstructor, NULL));543 assert(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull(context), arrayConstructor, NULL)); 544 544 545 545 o = JSValueToObject(context, result, NULL); 546 546 exception = NULL; 547 assert(JSValueIsUndefined( JSObjectGetPropertyAtIndex(context, o, 0, &exception)));547 assert(JSValueIsUndefined(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception))); 548 548 assert(!exception); 549 549 550 JSObjectSetPropertyAtIndex(context, o, 0, JSValueMakeNumber( 1), &exception);550 JSObjectSetPropertyAtIndex(context, o, 0, JSValueMakeNumber(context, 1), &exception); 551 551 assert(!exception); 552 552 … … 562 562 JSStringRef line = JSStringCreateWithUTF8CString("line"); 563 563 assert(!JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception)); 564 assert(JSValueIsObject( exception));564 assert(JSValueIsObject(context, exception)); 565 565 v = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), line, NULL); 566 566 assertEqualsAsNumber(v, 2); // FIXME: Lexer::setCode bumps startingLineNumber by 1 -- we need to change internal callers so that it doesn't have to (saying '0' to mean '1' in the API would be really confusing -- it's really confusing internally, in fact) … … 573 573 JSStringRelease(functionBody); 574 574 assert(!exception); 575 assert(JSObjectIsFunction( function));575 assert(JSObjectIsFunction(context, function)); 576 576 v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL); 577 577 assert(v); … … 583 583 v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, &exception); 584 584 assert(v && !exception); 585 assert(JSValueIsUndefined( v));585 assert(JSValueIsUndefined(context, v)); 586 586 587 587 exception = NULL; … … 592 592 function = JSObjectMakeFunction(context, foo, 1, argumentNames, functionBody, NULL, 1, &exception); 593 593 assert(function && !exception); 594 JSValueRef arguments[] = { JSValueMakeNumber( 2) };594 JSValueRef arguments[] = { JSValueMakeNumber(context, 2) }; 595 595 v = JSObjectCallAsFunction(context, function, NULL, 1, arguments, &exception); 596 596 JSStringRelease(foo); … … 598 598 599 599 string = JSValueToStringCopy(context, function, NULL); 600 assertEqualsAsUTF8String(JSValueMakeString( string), "function foo(foo) \n{\n return foo;\n}");600 assertEqualsAsUTF8String(JSValueMakeString(context, string), "function foo(foo) \n{\n return foo;\n}"); 601 601 JSStringRelease(string); 602 602 … … 618 618 619 619 o = JSObjectMake(context, NULL, NULL); 620 JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber( 1), kJSPropertyAttributeNone, NULL);621 JSObjectSetProperty(context, o, jsCFIString, JSValueMakeNumber( 1), kJSPropertyAttributeDontEnum, NULL);620 JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber(context, 1), kJSPropertyAttributeNone, NULL); 621 JSObjectSetProperty(context, o, jsCFIString, JSValueMakeNumber(context, 1), kJSPropertyAttributeDontEnum, NULL); 622 622 JSPropertyNameArrayRef nameArray = JSObjectCopyPropertyNames(context, o); 623 623 size_t expectedCount = JSPropertyNameArrayGetCount(nameArray); … … 645 645 JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8); 646 646 result = JSEvaluateScript(context, script, NULL, NULL, 1, &exception); 647 if (JSValueIsUndefined( result))647 if (JSValueIsUndefined(context, result)) 648 648 printf("PASS: Test script executed successfully.\n"); 649 649 else { … … 661 661 JSObjectMake(context, MyObject_class(context), 0); 662 662 JSObjectMake(context, MyObject_class(context), 0); 663 JSGarbageCollect( );663 JSGarbageCollect(context); 664 664 assert(didFinalize); 665 665
Note:
See TracChangeset
for help on using the changeset viewer.