Changeset 15235 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jul 8, 2006, 11:08:34 AM (19 years ago)
Author:
ggaren
Message:

Reviewed by Anders.


  • Make JSObjectGetProperty return a JSValue or NULL, like JSEvaluate does.
  • API/JSObjectRef.cpp: (JSObjectGetProperty):
  • API/JSObjectRef.h:
  • API/testapi.c: (main):
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r15234 r15235  
    128128}
    129129
    130 bool JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef* value)
     130JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName)
    131131{
    132132    JSLock lock;
     
    136136
    137137    JSValue* jsValue = jsObject->get(exec, Identifier(nameRep));
    138     if (value)
    139         *value = toRef(jsValue);
    140     return !jsValue->isUndefined();
     138    if (jsValue->isUndefined())
     139        return 0;
     140    return jsValue;
    141141}
    142142
  • trunk/JavaScriptCore/API/JSObjectRef.h

    r15233 r15235  
    387387@param object The JSObject whose property you want to get.
    388388@param propertyName A JSStringBuffer containing the property's name.
    389 @param value A pointer to a JSValueRef in which to store the property's value. On return, value will contain the property's value. Pass NULL if you do not care to store the property's value.
    390 @result true if the object has a property whose name matches propertyName, otherwise false. If this function returns false, the contents of value will be unmodified.
    391 */
    392 bool JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef* value);
     389@result The property's value, or NULL if the object does not have a property whose name matches propertyName.
     390*/
     391JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName);
    393392/*!
    394393@function
  • trunk/JavaScriptCore/API/testapi.c

    r15233 r15235  
    536536    JSStringBufferRelease(badSyntaxBuf);
    537537
    538     v = NULL;
    539538    JSStringBufferRef arrayBuf = JSStringBufferCreateUTF8("Array");
    540     assert(JSObjectGetProperty(context, globalObject, arrayBuf, &v));
     539    v = JSObjectGetProperty(context, globalObject, arrayBuf);
     540    assert(v);
    541541    JSObjectRef arrayConstructor = JSValueToObject(context, v);
    542542    JSStringBufferRelease(arrayBuf);
     
    548548    JSStringBufferRef functionBuf;
    549549   
    550     v = NULL;
    551550    exception = NULL;
    552551    functionBuf = JSStringBufferCreateUTF8("rreturn Array;");
     
    554553    assert(!JSFunctionMakeWithBody(context, functionBuf, NULL, 1, &exception));
    555554    assert(JSValueIsObject(exception));
    556     assert(JSObjectGetProperty(context, exception, lineBuf, &v));
     555    v = JSObjectGetProperty(context, exception, lineBuf);
     556    assert(v);
    557557    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)
    558558    JSStringBufferRelease(functionBuf);
  • trunk/JavaScriptCore/ChangeLog

    r15234 r15235  
     12006-07-08  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Anders.
     4       
     5        - Make JSObjectGetProperty return a JSValue or NULL, like JSEvaluate does.
     6
     7        * API/JSObjectRef.cpp:
     8        (JSObjectGetProperty):
     9        * API/JSObjectRef.h:
     10        * API/testapi.c:
     11        (main):
     12
    1132006-07-08  Geoffrey Garen  <[email protected]>
    214
Note: See TracChangeset for help on using the changeset viewer.