Commit 50f74725 authored by ggaren's avatar ggaren
Browse files

Reviewed by Anders.

        
        - Make JSObjectGetProperty return a JSValue or NULL, like JSEvaluate does.

        * API/JSObjectRef.cpp:
        (JSObjectGetProperty):
        * API/JSObjectRef.h:
        * API/testapi.c:
        (main):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15235 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7944ca37
......@@ -127,7 +127,7 @@ bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSStringBuffe
return jsObject->hasProperty(exec, Identifier(nameRep));
}
bool JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef* value)
JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName)
{
JSLock lock;
ExecState* exec = toJS(context);
......@@ -135,9 +135,9 @@ bool JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBuffe
UString::Rep* nameRep = toJS(propertyName);
JSValue* jsValue = jsObject->get(exec, Identifier(nameRep));
if (value)
*value = toRef(jsValue);
return !jsValue->isUndefined();
if (jsValue->isUndefined())
return 0;
return jsValue;
}
bool JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef value, JSPropertyAttributes attributes)
......
......@@ -386,10 +386,9 @@ bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSStringBuffe
@param context The execution context to use.
@param object The JSObject whose property you want to get.
@param propertyName A JSStringBuffer containing the property's name.
@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.
@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.
@result The property's value, or NULL if the object does not have a property whose name matches propertyName.
*/
bool JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef* value);
JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName);
/*!
@function
@abstract Sets a property on an object.
......
......@@ -535,9 +535,9 @@ int main(int argc, char* argv[])
JSStringBufferRelease(goodSyntaxBuf);
JSStringBufferRelease(badSyntaxBuf);
v = NULL;
JSStringBufferRef arrayBuf = JSStringBufferCreateUTF8("Array");
assert(JSObjectGetProperty(context, globalObject, arrayBuf, &v));
v = JSObjectGetProperty(context, globalObject, arrayBuf);
assert(v);
JSObjectRef arrayConstructor = JSValueToObject(context, v);
JSStringBufferRelease(arrayBuf);
result = JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, NULL);
......@@ -547,13 +547,13 @@ int main(int argc, char* argv[])
JSStringBufferRef functionBuf;
v = NULL;
exception = NULL;
functionBuf = JSStringBufferCreateUTF8("rreturn Array;");
JSStringBufferRef lineBuf = JSStringBufferCreateUTF8("line");
assert(!JSFunctionMakeWithBody(context, functionBuf, NULL, 1, &exception));
assert(JSValueIsObject(exception));
assert(JSObjectGetProperty(context, exception, lineBuf, &v));
v = JSObjectGetProperty(context, exception, lineBuf);
assert(v);
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)
JSStringBufferRelease(functionBuf);
JSStringBufferRelease(lineBuf);
......
2006-07-08 Geoffrey Garen <ggaren@apple.com>
Reviewed by Anders.
- Make JSObjectGetProperty return a JSValue or NULL, like JSEvaluate does.
* API/JSObjectRef.cpp:
(JSObjectGetProperty):
* API/JSObjectRef.h:
* API/testapi.c:
(main):
2006-07-08 Geoffrey Garen <ggaren@apple.com>
 
Style change -- no review necessary.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment