<html>
    <head>
      <base href="https://bugs.webkit.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - JSC needs to provide a basic handle api"
   href="https://bugs.webkit.org/show_bug.cgi?id=184907">184907</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>JSC needs to provide a basic handle api
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>JavaScriptCore
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned@lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>oliver@apple.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm trying to write an "interesting" js program and it keeps being frustrating to try and manage lifetime in the C API.

The problems that I keep hitting is that JSValueProtect/Unprotect require a context argument, that means a smart pointer has to carry both the value and context references.

The other problem is weak and conditional ownership.

I think an API along the lines of

typedef JSHandleRef

JSHandleRef JSHandleMake(JSContextRef)
JSHandleRef JSHandleMakeWeak(JSContextRef, nullable JSWeakCallback)

// Note the lack of a context here -- I believe that is completely achievable.
void JSHandleRetain(JSHandleRef)
void JSHandleRelease(JSHandleRef)

// While it would be nice to just have a "get slot" style api, I think that would
// result in ABI heartbreak down the road
JSValueRef JSHandleGetValue(JSHandleRef)
void JSHandleSetValue(JSHandleRef, JSValueRef)</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>