Diff
Modified: trunk/Source/_javascript_Core/API/JSContext.h (160453 => 160454)
--- trunk/Source/_javascript_Core/API/JSContext.h 2013-12-11 22:06:13 UTC (rev 160453)
+++ trunk/Source/_javascript_Core/API/JSContext.h 2013-12-11 22:13:23 UTC (rev 160454)
@@ -58,7 +58,7 @@
@abstract Create a JSContext.
@result The new context.
*/
-- (id)init;
+- (instancetype)init;
/*!
@method
@@ -66,7 +66,7 @@
@param virtualMachine The JSVirtualMachine in which the context will be created.
@result The new context.
*/
-- (id)initWithVirtualMachine:(JSVirtualMachine *)virtualMachine;
+- (instancetype)initWithVirtualMachine:(JSVirtualMachine *)virtualMachine;
/*!
@methodgroup Evaluating Scripts
@@ -117,14 +117,14 @@
@methodgroup Global Properties
*/
/*!
-@method
+@property
@abstract Get the global object of the context.
@discussion This method retrieves the global object of the _javascript_ execution context.
Instances of JSContext originating from WebKit will return a reference to the
WindowProxy object.
@result The global object.
*/
-- (JSValue *)globalObject;
+@property (readonly, strong) JSValue *globalObject;
/*!
@property
@@ -143,7 +143,7 @@
If a JSValue originating from a different JSVirtualMachine than this context
is assigned to this property, an Objective-C exception will be raised.
*/
-@property(retain) JSValue *exception;
+@property (strong) JSValue *exception;
/*!
@property
@@ -155,14 +155,14 @@
Setting this value to nil will result in all uncaught exceptions thrown from
the API being silently consumed.
*/
-@property(copy) void(^exceptionHandler)(JSContext *context, JSValue *exception);
+@property (copy) void(^exceptionHandler)(JSContext *context, JSValue *exception);
/*!
@property
@discussion All instances of JSContext are associated with a single JSVirtualMachine. The
virtual machine provides an "object space" or set of execution resources.
*/
-@property(readonly, retain) JSVirtualMachine *virtualMachine;
+@property (readonly, strong) JSVirtualMachine *virtualMachine;
/*!
@property
@@ -187,7 +187,7 @@
and then the value converted to a string used to resolve a property of the
global object.
*/
-@interface JSContext(SubscriptSupport)
+@interface JSContext (SubscriptSupport)
/*!
method
@@ -211,7 +211,7 @@
@category
@discussion These functions are for bridging between the C API and the Objective-C API.
*/
-@interface JSContext(JSContextRefSupport)
+@interface JSContext (JSContextRefSupport)
/*!
@method
@@ -222,11 +222,11 @@
+ (JSContext *)contextWithJSGlobalContextRef:(JSGlobalContextRef)jsGlobalContextRef;
/*!
-@method
+@property
@abstract Get the C API counterpart wrapped by a JSContext.
@result The C API equivalent of this JSContext.
*/
-- (JSGlobalContextRef)JSGlobalContextRef;
+@property (readonly) JSGlobalContextRef JSGlobalContextRef;
@end
#endif
Modified: trunk/Source/_javascript_Core/API/JSContext.mm (160453 => 160454)
--- trunk/Source/_javascript_Core/API/JSContext.mm 2013-12-11 22:06:13 UTC (rev 160453)
+++ trunk/Source/_javascript_Core/API/JSContext.mm 2013-12-11 22:13:23 UTC (rev 160454)
@@ -54,12 +54,12 @@
return m_context;
}
-- (id)init
+- (instancetype)init
{
return [self initWithVirtualMachine:[[[JSVirtualMachine alloc] init] autorelease]];
}
-- (id)initWithVirtualMachine:(JSVirtualMachine *)virtualMachine
+- (instancetype)initWithVirtualMachine:(JSVirtualMachine *)virtualMachine
{
self = [super init];
if (!self)
@@ -198,9 +198,9 @@
@end
-@implementation JSContext(Internal)
+@implementation JSContext (Internal)
-- (id)initWithGlobalContextRef:(JSGlobalContextRef)context
+- (instancetype)initWithGlobalContextRef:(JSGlobalContextRef)context
{
self = [super init];
if (!self)
Modified: trunk/Source/_javascript_Core/API/JSManagedValue.h (160453 => 160454)
--- trunk/Source/_javascript_Core/API/JSManagedValue.h 2013-12-11 22:06:13 UTC (rev 160453)
+++ trunk/Source/_javascript_Core/API/JSManagedValue.h 2013-12-11 22:13:23 UTC (rev 160454)
@@ -70,15 +70,15 @@
@param value
@result The new JSManagedValue.
*/
-- (id)initWithValue:(JSValue *)value;
+- (instancetype)initWithValue:(JSValue *)value;
/*!
-@method
+@property
@abstract Get the JSValue from the JSManagedValue.
@result The corresponding JSValue for this JSManagedValue or
nil if the JSValue has been collected.
*/
-- (JSValue *)value;
+@property (readonly, strong) JSValue *value;
@end
Modified: trunk/Source/_javascript_Core/API/JSManagedValue.mm (160453 => 160454)
--- trunk/Source/_javascript_Core/API/JSManagedValue.mm 2013-12-11 22:06:13 UTC (rev 160453)
+++ trunk/Source/_javascript_Core/API/JSManagedValue.mm 2013-12-11 22:13:23 UTC (rev 160454)
@@ -176,12 +176,12 @@
return [[[self alloc] initWithValue:value] autorelease];
}
-- (id)init
+- (instancetype)init
{
return [self initWithValue:nil];
}
-- (id)initWithValue:(JSValue *)value
+- (instancetype)initWithValue:(JSValue *)value
{
self = [super init];
if (!self)
Modified: trunk/Source/_javascript_Core/API/JSStringRefCF.h (160453 => 160454)
--- trunk/Source/_javascript_Core/API/JSStringRefCF.h 2013-12-11 22:06:13 UTC (rev 160453)
+++ trunk/Source/_javascript_Core/API/JSStringRefCF.h 2013-12-11 22:13:23 UTC (rev 160454)
@@ -51,7 +51,7 @@
@param string The JSString to copy into the new CFString.
@result A CFString containing string. Ownership follows the Create Rule.
*/
-JS_EXPORT CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string);
+JS_EXPORT CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string) CF_RETURNS_RETAINED;
#ifdef __cplusplus
}
Modified: trunk/Source/_javascript_Core/API/JSValue.h (160453 => 160454)
--- trunk/Source/_javascript_Core/API/JSValue.h 2013-12-11 22:06:13 UTC (rev 160453)
+++ trunk/Source/_javascript_Core/API/JSValue.h 2013-12-11 22:13:23 UTC (rev 160454)
@@ -61,7 +61,7 @@
@property
@abstract The JSContext that this value originates from.
*/
-@property(readonly, retain) JSContext *context;
+@property (readonly, strong) JSContext *context;
/*!
@methodgroup Creating _javascript_ Values
@@ -483,7 +483,7 @@
return type of the latter.
Support is provided for structs of type CGPoint, NSRange, CGRect and CGSize.
*/
-@interface JSValue(StructSupport)
+@interface JSValue (StructSupport)
/*!
@method
@@ -572,7 +572,7 @@
An object key passed as a subscript will be converted to a _javascript_ value,
and then the value converted to a string used as a property name.
*/
-@interface JSValue(SubscriptSupport)
+@interface JSValue (SubscriptSupport)
- (JSValue *)objectForKeyedSubscript:(id)key;
- (JSValue *)objectAtIndexedSubscript:(NSUInteger)index;
@@ -585,7 +585,7 @@
@category
@discussion These functions are for bridging between the C API and the Objective-C API.
*/
-@interface JSValue(JSValueRefSupport)
+@interface JSValue (JSValueRefSupport)
/*!
@method
@@ -597,11 +597,11 @@
+ (JSValue *)valueWithJSValueRef:(JSValueRef)value inContext:(JSContext *)context;
/*!
-@method
+@property
@abstract Returns the C API counterpart wrapped by a JSContext.
@result The C API equivalent of this JSValue.
*/
-- (JSValueRef)JSValueRef;
+@property (readonly) JSValueRef JSValueRef;
@end
#ifdef __cplusplus
Modified: trunk/Source/_javascript_Core/API/JSVirtualMachine.h (160453 => 160454)
--- trunk/Source/_javascript_Core/API/JSVirtualMachine.h 2013-12-11 22:06:13 UTC (rev 160453)
+++ trunk/Source/_javascript_Core/API/JSVirtualMachine.h 2013-12-11 22:13:23 UTC (rev 160454)
@@ -48,7 +48,7 @@
@method
@abstract Create a new JSVirtualMachine.
*/
-- (id)init;
+- (instancetype)init;
/*!
@methodgroup Memory Management
Modified: trunk/Source/_javascript_Core/API/JSVirtualMachine.mm (160453 => 160454)
--- trunk/Source/_javascript_Core/API/JSVirtualMachine.mm 2013-12-11 22:06:13 UTC (rev 160453)
+++ trunk/Source/_javascript_Core/API/JSVirtualMachine.mm 2013-12-11 22:13:23 UTC (rev 160454)
@@ -86,7 +86,7 @@
NSMapTable *m_externalObjectGraph;
}
-- (id)init
+- (instancetype)init
{
JSContextGroupRef group = JSContextGroupCreate();
self = [self initWithContextGroupRef:group];
@@ -95,7 +95,7 @@
return self;
}
-- (id)initWithContextGroupRef:(JSContextGroupRef)group
+- (instancetype)initWithContextGroupRef:(JSContextGroupRef)group
{
self = [super init];
if (!self)
Modified: trunk/Source/_javascript_Core/ChangeLog (160453 => 160454)
--- trunk/Source/_javascript_Core/ChangeLog 2013-12-11 22:06:13 UTC (rev 160453)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-12-11 22:13:23 UTC (rev 160454)
@@ -1,5 +1,29 @@
2013-12-11 Mark Rowe <[email protected]>
+ <https://webkit.org/b/125141> Modernize the _javascript_Core API headers
+ <rdar://problem/15540121>
+
+ This consists of three main changes:
+ 1) Converting the return type of initializer methods to instancetype.
+ 2) Declaring properties rather than getters and setters.
+ 3) Tagging C API methods with information about their memory management semantics.
+
+ Changing the declarations from getters and setters to properties also required
+ updating the headerdoc in a number of places.
+
+ Reviewed by Anders Carlsson.
+
+ * API/JSContext.h:
+ * API/JSContext.mm:
+ * API/JSManagedValue.h:
+ * API/JSManagedValue.mm:
+ * API/JSStringRefCF.h:
+ * API/JSValue.h:
+ * API/JSVirtualMachine.h:
+ * API/JSVirtualMachine.mm:
+
+2013-12-11 Mark Rowe <[email protected]>
+
<https://webkit.org/b/125559> Move _javascript_Core off the legacy WebKit availability macros
The legacy WebKit availability macros are verbose, confusing, and provide no benefit over