[Webkit-unassigned] [Bug 160032] Adding JSObjectGetClass method

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jul 21 16:28:43 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=160032

--- Comment #7 from Danilo Cesar Lemes de Paula <danilo.cesar at collabora.co.uk> ---
Comment on attachment 284232
  --> https://bugs.webkit.org/attachment.cgi?id=284232
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=284232&action=review

>> Source/JavaScriptCore/ChangeLog:10
>> +        Usefull to create other objects with the same classe and constructor.
> 
> A few typos here.

Fixed.

>> Source/JavaScriptCore/API/JSObjectRef.cpp:244
>> +    JSObject* jsObject = uncheckedToJS(object);
> 
> As public API we shouldn't do an unsafe cast like this, it would be better to use the regular toJS() like other API functions, which looks like it would fail if clients call this incorrectly.

I agree with that. I used unchecked because I took as example the JSObjectGetPrivate, that uses unchecked. Fixed anyway.

>> Source/JavaScriptCore/API/JSObjectRef.cpp:248
>> +    return 0;
> 
> Style: New code should use nullptr instead of 0 or NULL.

Fixed.

>> Source/JavaScriptCore/API/JSObjectRef.h:498
>> + at param ctx  The execution context to use.
> 
> Nit: There is no ctx parameter here. There probably should be one, used just like the other API methods to take the API lock (JSLockHolder).

Oh, didn't noticed the Lock thing. I'm fixing it...

>> Source/JavaScriptCore/API/JSObjectRef.h:499
>> + at param object A JSObject whose prototype you want to get.
> 
> Nit: You are referencing a param named "object" so you should give the parameter this name in the signature below.

I took it out as the styler complained that "object" has no meaning... Makes sense to let it there and ignore the warning...

>> Source/JavaScriptCore/API/JSObjectRef.h:500
>> + at result A JSClassRef that was used to create the  object.
> 
> Nit: Fix the double space in here.

nice catch.

>> Source/JavaScriptCore/API/JSObjectRef.h:502
>> +JS_EXPORT JSClassRef JSObjectGetClass(JSObjectRef);
> 
> As a new API, this would need an availability macro CF_AVAILABLE(..., ...). I'm not sure what the right values to fill in would be. WebKit2 has WK_MAC_TBA values that are post-processed. It would be similar here but the machinery would need to be added.

CF_AVAILABLE(10_12, 10_0)? If no, I guess I will need a small guidance on that.

>> Source/JavaScriptCore/API/tests/testapi.c:1312
>> +    if (myObjectClassRef != JSObjectGetClass(myObject)) {
> 
> What happens if you try to get the class of a built-in JavaScript object that you did not create with a ClassRef? For example, the class of the Global object, a Function instance? It would be good to have tests for the non-basic/expected cases.

I guess your're right.

>> Source/JavaScriptCore/API/tests/testapi.c:1313
>> +        printf("FAIL: JSObjectGetClass didn't return the correct JSClassRef \n");
> 
> Nit: Follow suit with the others and end in a period instead of a space.

Fixed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160721/0aeda3b0/attachment-0001.html>


More information about the webkit-unassigned mailing list