<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Adding JSObjectGetClass method"
   href="https://bugs.webkit.org/show_bug.cgi?id=160032#c6">Comment # 6</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Adding JSObjectGetClass method"
   href="https://bugs.webkit.org/show_bug.cgi?id=160032">bug 160032</a>
              from <span class="vcard"><a class="email" href="mailto:joepeck&#64;webkit.org" title="Joseph Pecoraro &lt;joepeck&#64;webkit.org&gt;"> <span class="fn">Joseph Pecoraro</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=284232&amp;action=diff" name="attach_284232" title="Patch">attachment 284232</a> <a href="attachment.cgi?id=284232&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=284232&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=284232&amp;action=review</a>

I'll let someone else evaluate this from a new API perspective, but there is some low hanging fruit you can cleanup in the patch in the process.

<span class="quote">&gt; Source/JavaScriptCore/ChangeLog:10
&gt; +        Usefull to create other objects with the same classe and constructor.</span >

A few typos here.

<span class="quote">&gt; Source/JavaScriptCore/API/JSObjectRef.cpp:244
&gt; +    JSObject* jsObject = uncheckedToJS(object);</span >

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.

<span class="quote">&gt; Source/JavaScriptCore/API/JSObjectRef.cpp:248
&gt; +    return 0;</span >

Style: New code should use nullptr instead of 0 or NULL.

<span class="quote">&gt; Source/JavaScriptCore/API/JSObjectRef.h:498
&gt; +&#64;param ctx  The execution context to use.</span >

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).

<span class="quote">&gt; Source/JavaScriptCore/API/JSObjectRef.h:499
&gt; +&#64;param object A JSObject whose prototype you want to get.</span >

Nit: You are referencing a param named &quot;object&quot; so you should give the parameter this name in the signature below.

<span class="quote">&gt; Source/JavaScriptCore/API/JSObjectRef.h:500
&gt; +&#64;result A JSClassRef that was used to create the  object.</span >

Nit: Fix the double space in here.

<span class="quote">&gt; Source/JavaScriptCore/API/JSObjectRef.h:502
&gt; +JS_EXPORT JSClassRef JSObjectGetClass(JSObjectRef);</span >

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.

<span class="quote">&gt; Source/JavaScriptCore/API/tests/testapi.c:1312
&gt; +    if (myObjectClassRef != JSObjectGetClass(myObject)) {</span >

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.

<span class="quote">&gt; Source/JavaScriptCore/API/tests/testapi.c:1313
&gt; +        printf(&quot;FAIL: JSObjectGetClass didn't return the correct JSClassRef \n&quot;);</span >

Nit: Follow suit with the others and end in a period instead of a space.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>