<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[191230] trunk/Source/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/191230">191230</a></dd>
<dt>Author</dt> <dd>ggaren@apple.com</dd>
<dt>Date</dt> <dd>2015-10-16 16:57:35 -0700 (Fri, 16 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update JavaScriptCore API docs
https://bugs.webkit.org/show_bug.cgi?id=150262

Reviewed by Mark Lam.

Apply some edits for clarity. These came out of a docs review.

* API/JSContext.h:
* API/JSExport.h:
* API/JSManagedValue.h:
* API/JSValue.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreAPIJSContexth">trunk/Source/JavaScriptCore/API/JSContext.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPIJSExporth">trunk/Source/JavaScriptCore/API/JSExport.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPIJSManagedValueh">trunk/Source/JavaScriptCore/API/JSManagedValue.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPIJSValueh">trunk/Source/JavaScriptCore/API/JSValue.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreAPIJSContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSContext.h (191229 => 191230)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSContext.h        2015-10-16 23:48:45 UTC (rev 191229)
+++ trunk/Source/JavaScriptCore/API/JSContext.h        2015-10-16 23:57:35 UTC (rev 191230)
</span><span class="lines">@@ -35,14 +35,9 @@
</span><span class="cx"> 
</span><span class="cx"> /*!
</span><span class="cx"> @interface
</span><del>-@discussion An instance of JSContext represents a JavaScript execution environment. All
- JavaScript execution takes place within a context.
- JSContext is also used to manage the life-cycle of objects within the
- JavaScript virtual machine. Every instance of JSValue is associated with a
- JSContext via a strong reference. The JSValue will keep the JSContext it
- references alive so long as the JSValue remains alive. When all of the JSValues
- that reference a particular JSContext have been deallocated the JSContext
- will be deallocated unless it has been previously retained.
</del><ins>+@discussion A JSContext is a JavaScript execution environment. All
+ JavaScript execution takes place within a context, and all JavaScript values
+ are tied to a context.
</ins><span class="cx"> */
</span><span class="cx"> NS_CLASS_AVAILABLE(10_9, 7_0)
</span><span class="cx"> @interface JSContext : NSObject
</span><span class="lines">@@ -155,9 +150,6 @@
</span><span class="cx">  This property may also be used to check for uncaught exceptions arising from
</span><span class="cx">  API function calls (since the default behaviour of &lt;code&gt;exceptionHandler&lt;/code&gt; is to
</span><span class="cx">  assign an uncaught exception to this property).
</span><del>-
- If a JSValue originating from a different JSVirtualMachine than this context
- is assigned to this property, an Objective-C exception will be raised.
</del><span class="cx"> */
</span><span class="cx"> @property (strong) JSValue *exception;
</span><span class="cx"> 
</span><span class="lines">@@ -166,17 +158,16 @@
</span><span class="cx"> @discussion If a call to an API function results in an uncaught JavaScript exception, the
</span><span class="cx">  &lt;code&gt;exceptionHandler&lt;/code&gt; block will be invoked. The default implementation for the
</span><span class="cx">  exception handler will store the exception to the exception property on
</span><del>- context. As a consequence the default behaviour is for unhandled exceptions
</del><ins>+ context. As a consequence the default behaviour is for uncaught exceptions
</ins><span class="cx">  occurring within a callback from JavaScript to be rethrown upon return.
</span><del>- Setting this value to nil will result in all uncaught exceptions thrown from
- the API being silently consumed.
</del><ins>+ Setting this value to nil will cause all exceptions occurring
+ within a callback from JavaScript to be silently caught.
</ins><span class="cx"> */
</span><span class="cx"> @property (copy) void(^exceptionHandler)(JSContext *context, JSValue *exception);
</span><span class="cx"> 
</span><span class="cx"> /*!
</span><span class="cx"> @property
</span><del>-@discussion All instances of JSContext are associated with a single JSVirtualMachine. The
- virtual machine provides an &quot;object space&quot; or set of execution resources.
</del><ins>+@discussion All instances of JSContext are associated with a JSVirtualMachine.
</ins><span class="cx"> */
</span><span class="cx"> @property (readonly, strong) JSVirtualMachine *virtualMachine;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIJSExporth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSExport.h (191229 => 191230)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSExport.h        2015-10-16 23:48:45 UTC (rev 191229)
+++ trunk/Source/JavaScriptCore/API/JSExport.h        2015-10-16 23:57:35 UTC (rev 191230)
</span><span class="lines">@@ -29,40 +29,39 @@
</span><span class="cx"> 
</span><span class="cx"> /*!
</span><span class="cx"> @protocol
</span><del>-@abstract JSExport provides a declarative way to export Objective-C instance methods,
- class methods, and properties to JavaScript code.
</del><ins>+@abstract JSExport provides a declarative way to export Objective-C objects and
+ classes -- including properties, instance methods, class methods, and
+ initializers -- to JavaScript.
</ins><span class="cx"> 
</span><del>-@discussion When a JavaScript value is created from an instance of an Objective-C class
- for which no copying conversion is specified a JavaScript wrapper object will
- be created.
</del><ins>+@discussion When an Objective-C object is exported to JavaScript, a JavaScript
+ wrapper object is created.
</ins><span class="cx"> 
</span><del>- In JavaScript, inheritance is supported via a chain of prototype objects, and
- for each Objective-C class (and per JSContext) an object appropriate for use
- as a prototype will be provided. For the class NSObject the prototype object
- will be the JavaScript context's Object Prototype. For all other Objective-C
- classes a Prototype object will be created. The Prototype object for a given
</del><ins>+ In JavaScript, inheritance works via a chain of prototype objects.
+ For each Objective-C class in each JSContext, an object appropriate for use
+ as a prototype will be provided. For the class NSObject the prototype
+ will be the Object prototype. For all other Objective-C
+ classes a prototype will be created. The prototype for a given
</ins><span class="cx">  Objective-C class will have its internal [Prototype] property set to point to
</span><del>- the Prototype object of the Objective-C class's superclass. As such the
</del><ins>+ the prototype created for the Objective-C class's superclass. As such the
</ins><span class="cx">  prototype chain for a JavaScript wrapper object will reflect the wrapped
</span><span class="cx">  Objective-C type's inheritance hierarchy.
</span><span class="cx"> 
</span><del>- In addition to the Prototype object a JavaScript Constructor object will also
- be produced for each Objective-C class. The Constructor object has a property
- named 'prototype' that references the Prototype object, and the Prototype
- object has a property named 'constructor' that references the Constructor.
- The Constructor object is not callable.
</del><ins>+ JavaScriptCore also produces a constructor for each Objective-C class. The
+ constructor has a property named 'prototype' that references the prototype,
+ and the prototype has a property named 'constructor' that references the
+ constructor.
</ins><span class="cx"> 
</span><del>- By default no methods or properties of the Objective-C class will be exposed
- to JavaScript; however methods and properties may explicitly be exported.
- For each protocol that a class conforms to, if the protocol incorporates the
- protocol JSExport, then the protocol will be interpreted as a list of methods
- and properties to be exported to JavaScript.
</del><ins>+ By default JavaScriptCore does not export any methods or properties from an
+ Objective-C class to JavaScript; however methods and properties may be exported
+ explicitly using JSExport. For each protocol that a class conforms to, if the
+ protocol incorporates the protocol JSExport, JavaScriptCore exports the methods
+ and properties in that protocol to JavaScript
</ins><span class="cx"> 
</span><del>- For each instance method being exported a corresponding JavaScript function
- will be assigned as a property of the Prototype object. For each Objective-C
- property being exported a JavaScript accessor property will be created on the
- Prototype. For each class method exported a JavaScript function will be
- created on the Constructor object. For example:
</del><ins>+ For each exported instance method JavaScriptCore will assign a corresponding
+ JavaScript function to the prototype. For each exported Objective-C property
+ JavaScriptCore will assign a corresponding JavaScript accessor to the prototype.
+ For each exported class method JavaScriptCore will assign a corresponding
+ JavaScript function to the constructor. For example:
</ins><span class="cx"> 
</span><span class="cx"> &lt;pre&gt;
</span><span class="cx"> @textblock
</span><span class="lines">@@ -86,34 +85,29 @@
</span><span class="cx">  since the class conforms to the &lt;code&gt;MyClassJavaScriptMethods&lt;/code&gt; protocol, and this
</span><span class="cx">  protocol incorporates &lt;code&gt;JSExport&lt;/code&gt;. &lt;code&gt;bar&lt;/code&gt; will not be exported.
</span><span class="cx"> 
</span><del>- Properties, arguments, and return values of the following types are
- supported:
</del><ins>+ JSExport supports properties, arguments, and return values of the following types:
</ins><span class="cx"> 
</span><del>- Primitive numbers: signed values of up to 32-bits are converted in a manner
-    consistent with valueWithInt32/toInt32, unsigned values of up to 32-bits
-    are converted in a manner consistent with valueWithUInt32/toUInt32, all
-    other numeric values are converted consistently with valueWithDouble/
-    toDouble.
</del><ins>+ Primitive numbers: signed values up to 32-bits convert using JSValue's
+ valueWithInt32/toInt32. Unsigned values up to 32-bits convert using JSValue's
+ valueWithUInt32/toUInt32. All other numeric values convert using JSValue's
+ valueWithDouble/toDouble.
</ins><span class="cx"> 
</span><del>- BOOL: values are converted consistently with valueWithBool/toBool.
</del><ins>+ BOOL: values convert using JSValue's valueWithBool/toBool.
</ins><span class="cx"> 
</span><del>- id: values are converted consistently with valueWithObject/toObject.
</del><ins>+ id: values convert using JSValue's valueWithObject/toObject.
</ins><span class="cx"> 
</span><del>- Objective-C Class: - where the type is a pointer to a specified Objective-C
-    class, conversion is consistent with valueWithObjectOfClass/toObject.
</del><ins>+ Objective-C instance pointers: Pointers convert using JSValue's
+ valueWithObjectOfClass/toObject.
</ins><span class="cx"> 
</span><del>- struct types: C struct types are supported, where JSValue provides support
-    for the given type. Support is built in for CGPoint, NSRange, CGRect, and
-    CGSize.
</del><ins>+ C structs: C structs for CGPoint, NSRange, CGRect, and CGSize convert using
+ JSValue's appropriate methods. Other C structs are not supported.
</ins><span class="cx"> 
</span><del>- block types: Blocks can only be passed if they had been converted 
-    successfully by valueWithObject/toObject previously.
</del><ins>+ Blocks: Blocks convert using JSValue's valueWithObject/toObject.
</ins><span class="cx"> 
</span><del>- For any interface that conforms to JSExport the normal copying conversion for
- built in types will be inhibited - so, for example, if an instance that
- derives from NSString but conforms to JSExport is passed to valueWithObject:
- then a wrapper object for the Objective-C object will be returned rather than
- a JavaScript string primitive.
</del><ins>+ All objects that conform to JSExport convert to JavaScript wrapper objects,
+ even if they subclass classes that would otherwise behave differently. For
+ example, if a subclass of NSString conforms to JSExport, it converts to
+ JavaScript as a wrapper object rather than a JavaScript string.
</ins><span class="cx"> */
</span><span class="cx"> @protocol JSExport
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIJSManagedValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSManagedValue.h (191229 => 191230)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSManagedValue.h        2015-10-16 23:48:45 UTC (rev 191229)
+++ trunk/Source/JavaScriptCore/API/JSManagedValue.h        2015-10-16 23:57:35 UTC (rev 191230)
</span><span class="lines">@@ -37,18 +37,16 @@
</span><span class="cx"> /*!
</span><span class="cx"> @interface
</span><span class="cx"> @discussion JSManagedValue represents a &quot;conditionally retained&quot; JSValue. 
</span><del>- &quot;Conditionally retained&quot; means that as long as either the JSManagedValue's 
- JavaScript value is reachable through the JavaScript object graph
- or the JSManagedValue object is reachable through the external Objective-C 
- object graph as reported to the JSVirtualMachine using 
- addManagedReference:withOwner:, the corresponding JavaScript value will 
- be retained. However, if neither of these conditions are true, the 
</del><ins>+ &quot;Conditionally retained&quot; means that as long as the JSManagedValue's 
+ JSValue is reachable through the JavaScript object graph,
+ or through the Objective-C object graph reported to the JSVirtualMachine using
+ addManagedReference:withOwner:, the corresponding JSValue will 
+ be retained. However, if neither graph reaches the JSManagedValue, the 
</ins><span class="cx">  corresponding JSValue will be released and set to nil.
</span><span class="cx"> 
</span><del>- The primary use case for JSManagedValue is for safely referencing JSValues 
- from the Objective-C heap. It is incorrect to store a JSValue into an 
- Objective-C heap object, as this can very easily create a reference cycle, 
- keeping the entire JSContext alive.
</del><ins>+The primary use for a JSManagedValue is to store a JSValue in an Objective-C
+or Swift object that is exported to JavaScript. It is incorrect to store a JSValue
+in an object that is exported to JavaScript, since doing so creates a retain cycle.
</ins><span class="cx"> */ 
</span><span class="cx"> NS_CLASS_AVAILABLE(10_9, 7_0)
</span><span class="cx"> @interface JSManagedValue : NSObject
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIJSValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSValue.h (191229 => 191230)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSValue.h        2015-10-16 23:48:45 UTC (rev 191229)
+++ trunk/Source/JavaScriptCore/API/JSValue.h        2015-10-16 23:57:35 UTC (rev 191230)
</span><span class="lines">@@ -34,21 +34,15 @@
</span><span class="cx"> 
</span><span class="cx"> /*!
</span><span class="cx"> @interface
</span><del>-@discussion A JSValue is a reference to a value within the JavaScript object space of a
- JSVirtualMachine. All instances of JSValue originate from a JSContext and
- hold a strong reference to this JSContext. As long as any value associated with 
- a particular JSContext is retained, that JSContext will remain alive. 
- Where an instance method is invoked upon a JSValue, and this returns another 
- JSValue, the returned JSValue will originate from the same JSContext as the 
- JSValue on which the method was invoked.
</del><ins>+@discussion A JSValue is a reference to a JavaScript value. Every JSValue
+ originates from a JSContext and holds a strong reference to it.
+ When a JSValue instance method creates a new JSValue, the new value
+ originates from the same JSContext.
</ins><span class="cx"> 
</span><del>- All JavaScript values are associated with a particular JSVirtualMachine
- (the associated JSVirtualMachine is available indirectly via the context
- property). An instance of JSValue may only be passed as an argument to
- methods on instances of JSValue and JSContext that belong to the same
- JSVirtualMachine - passing a JSValue to a method on an object originating
- from a different JSVirtualMachine will result in an Objective-C exception
- being raised.
</del><ins>+ All JSValues values also originate from a JSVirtualMachine
+ (available indirectly via the context property). It is an error to pass a
+ JSValue to a method or property of a JSValue or JSContext originating from a
+ different JSVirtualMachine. Doing so will raise an Objective-C exception.
</ins><span class="cx"> */
</span><span class="cx"> NS_CLASS_AVAILABLE(10_9, 7_0)
</span><span class="cx"> @interface JSValue : NSObject
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (191229 => 191230)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-10-16 23:48:45 UTC (rev 191229)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-10-16 23:57:35 UTC (rev 191230)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-10-16  Geoffrey Garen  &lt;ggaren@apple.com&gt;
+
+        Update JavaScriptCore API docs
+        https://bugs.webkit.org/show_bug.cgi?id=150262
+
+        Reviewed by Mark Lam.
+
+        Apply some edits for clarity. These came out of a docs review.
+
+        * API/JSContext.h:
+        * API/JSExport.h:
+        * API/JSManagedValue.h:
+        * API/JSValue.h:
+
</ins><span class="cx"> 2015-10-16  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed. Fix typo in TypeError messages in TypedArray.prototype.forEach/filter.
</span></span></pre>
</div>
</div>

</body>
</html>