Diff
Modified: trunk/Source/_javascript_Core/API/JSBlockAdaptor.h (142318 => 142319)
--- trunk/Source/_javascript_Core/API/JSBlockAdaptor.h 2013-02-08 21:18:30 UTC (rev 142318)
+++ trunk/Source/_javascript_Core/API/JSBlockAdaptor.h 2013-02-08 21:41:25 UTC (rev 142319)
@@ -24,7 +24,6 @@
*/
#import <_javascript_Core/_javascript_Core.h>
-#import <wtf/RetainPtr.h>
#if JS_OBJC_API_ENABLED
Modified: trunk/Source/_javascript_Core/API/JSBlockAdaptor.mm (142318 => 142319)
--- trunk/Source/_javascript_Core/API/JSBlockAdaptor.mm 2013-02-08 21:18:30 UTC (rev 142318)
+++ trunk/Source/_javascript_Core/API/JSBlockAdaptor.mm 2013-02-08 21:41:25 UTC (rev 142319)
@@ -33,12 +33,13 @@
#import "Error.h"
#import "JSBlockAdaptor.h"
#import "JSContextInternal.h"
-#import "JSWrapperMap.h"
#import "JSCJSValue.h"
#import "JSValueInternal.h"
+#import "JSWrapperMap.h"
#import "ObjcRuntimeExtras.h"
#import "Operations.h"
-#import "wtf/OwnPtr.h"
+#import <wtf/OwnPtr.h>
+#import <wtf/RetainPtr.h>
extern "C" {
id __NSMakeSpecialForwardingCaptureBlock(const char *signature, void (^handler)(NSInvocation *));
@@ -340,7 +341,7 @@
}
} else if (m_signatureWithOffsets && JSValueIsObject(contextRef, argument)) {
// Check if the argument is a _javascript_ function
- // (and that were able to create a forwarding block for this signature).
+ // (and that we're able to create a forwarding block for this signature).
JSObjectRef object = JSValueToObject(contextRef, argument, exception);
if (JSObjectIsFunction(contextRef, object))
function = object;
Modified: trunk/Source/_javascript_Core/API/JSContext.h (142318 => 142319)
--- trunk/Source/_javascript_Core/API/JSContext.h 2013-02-08 21:18:30 UTC (rev 142318)
+++ trunk/Source/_javascript_Core/API/JSContext.h 2013-02-08 21:41:25 UTC (rev 142319)
@@ -76,8 +76,8 @@
// of exception is not nil, the callback will result in that value being thrown.
// This property may also be used to check for uncaught exceptions arising from
// API function calls (since the default behaviour of "exceptionHandler" is to
-// assign ant uncaught exception to this property).
-// If a JSValue orginating from a different JSVirtualMachine this this context
+// assign an uncaught exception to this property).
+// 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;
@@ -85,7 +85,7 @@
// "exceptionHandler" block will be invoked. The default implementation for the
// exception handler will store the exception to the exception property on
// context. As a consequence the default behaviour is for unhandled exceptions
-// occuring within a callback from _javascript_ to be rethrown upon return.
+// occurring within a callback from _javascript_ to be rethrown upon return.
// 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);
@@ -103,7 +103,7 @@
// JSValue *v = context[@"X"]; // Get value for "X" from the global object.
// context[@"Y"] = v; // Assign 'v' to "Y" on the global object.
//
-// An object key passed as a subscript will be converted to a JavaScipt value,
+// An object key passed as a subscript will be converted to a _javascript_ value,
// and then the value converted to a string used to resolve a property of the
// global object.
@interface JSContext(SubscriptSupport)
Modified: trunk/Source/_javascript_Core/API/JSExport.h (142318 => 142319)
--- trunk/Source/_javascript_Core/API/JSExport.h 2013-02-08 21:18:30 UTC (rev 142318)
+++ trunk/Source/_javascript_Core/API/JSExport.h 2013-02-08 21:41:25 UTC (rev 142319)
@@ -27,7 +27,7 @@
#if JS_OBJC_API_ENABLED
-// When an _javascript_ value is created from an instance of an Objective-C class
+// 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.
//
@@ -68,9 +68,13 @@
// - (void)bar;
// @end
//
+// Data properties that are created on the prototype or constructor objects have
+// the attributes: writable:true, enumerable:false, configurable:true. Accessor
+// properties have the attributes: enumerable:false and configurable:true.
+//
// If an instance of MyClass is converted to a _javascript_ value, the resulting
// wrapper object will (via its prototype) export the method "foo" to _javascript_,
-// since the class conforms to the MyClassJavaScriptExports protocol, and this
+// since the class conforms to the MyClassJavaScriptMethods protocol, and this
// protocol incorporates JSExport. "bar" will not be exported.
//
// Properties, arguments, and return values of the following types are
@@ -93,14 +97,14 @@
// block types, if a _javascript_ Function is passed as an argument, where the
// type required is a block with a void return value (and where the block's
// arguments are all of supported types), then a special adaptor block
-// will be created, allowing the the _javascript_ function to be used in the
-// place of a block.
+// will be created, allowing the _javascript_ function to be used in the place
+// of a block.
//
// 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 by conforms to JSExport is passed to valueWithObject:,
-// a wrapper object for the Objective-C object will be returned rather than a
-// _javascript_ string primitive.
+// 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.
@protocol JSExport
@end
Modified: trunk/Source/_javascript_Core/API/JSValue.h (142318 => 142319)
--- trunk/Source/_javascript_Core/API/JSValue.h 2013-02-08 21:18:30 UTC (rev 142318)
+++ trunk/Source/_javascript_Core/API/JSValue.h 2013-02-08 21:41:25 UTC (rev 142319)
@@ -155,7 +155,7 @@
- (BOOL)hasProperty:(NSString *)property;
// This method may be used to create a data or accessor property on an object;
// this method operates in accordance with the Object.defineProperty method in
-// the _javascript_ langauage.
+// the _javascript_ language.
- (void)defineProperty:(NSString *)property descriptor:(id)descriptor;
// Access an indexed property from the value. This method will return the
@@ -180,13 +180,13 @@
// This method has the same function as the _javascript_ operator "instanceof".
- (BOOL)isInstanceOf:(id)value;
-// Call this value as a function passing the specified "this" value and arguments.
+// Call this value as a function passing the specified arguments.
- (JSValue *)callWithArguments:(NSArray *)arguments;
// Call this value as a constructor passing the specified arguments.
- (JSValue *)constructWithArguments:(NSArray *)arguments;
// Access the property named "method" from this value; call the value resulting
// from the property access as a function, passing this value as the "this"
-// value, and the specified agruments.
+// value, and the specified arguments.
- (JSValue *)invokeMethod:(NSString *)method withArguments:(NSArray *)arguments;
// The JSContext that this value originates from.
@@ -195,8 +195,8 @@
@end
// Objective-C methods exported to _javascript_ may have argument and/or return
-// values of struct types if the struct if conversion to and from the struct
-// is supported by JSValue. Support is provided for any types where JSValue
+// values of struct types, provided that conversion to and from the struct is
+// supported by JSValue. Support is provided for any types where JSValue
// contains both a class method "valueWith<Type>:inContext:", and and instance
// method "to<Type>" - where the string "<Type>" in these selector names match,
// with the first argument to the former being of the same struct type as the
@@ -226,7 +226,7 @@
// Convert a value to type CGRect by reading properties named "x", "y", "width",
// and "height" from this value, and converting the results to double.
- (CGRect)toRect;
-// Convert a value to type CGRange by accessing properties named "width" and
+// Convert a value to type CGSize by accessing properties named "width" and
// "height" from this value converting the results to double.
- (CGSize)toSize;
@@ -241,7 +241,7 @@
// object[@"Y"] = v1; // Assign 'v1' to property "Y" of 'object'.
// object[101] = v2; // Assign 'v2' to index 101 of 'object'.
//
-// An object key passed as a subscript will be converted to a JavaScipt value,
+// 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)
Modified: trunk/Source/_javascript_Core/API/JSValue.mm (142318 => 142319)
--- trunk/Source/_javascript_Core/API/JSValue.mm 2013-02-08 21:18:30 UTC (rev 142318)
+++ trunk/Source/_javascript_Core/API/JSValue.mm 2013-02-08 21:41:25 UTC (rev 142319)
@@ -24,6 +24,8 @@
*/
#include "config.h"
+//#import "JSValue.h"
+
#import "APICast.h"
#import "APIShims.h"
#import "DateInstance.h"
@@ -36,11 +38,11 @@
#import "ObjcRuntimeExtras.h"
#import "Operations.h"
#import "JSCJSValue.h"
-#import "wtf/HashMap.h"
-#import "wtf/HashSet.h"
-#import "wtf/Vector.h"
+#import <wtf/HashMap.h>
+#import <wtf/HashSet.h>
+#import <wtf/Vector.h>
#import <wtf/TCSpinLock.h>
-#import "wtf/text/WTFString.h"
+#import <wtf/text/WTFString.h>
#import <wtf/text/StringHash.h>
#if JS_OBJC_API_ENABLED
Modified: trunk/Source/_javascript_Core/API/JSWrapperMap.mm (142318 => 142319)
--- trunk/Source/_javascript_Core/API/JSWrapperMap.mm 2013-02-08 21:18:30 UTC (rev 142318)
+++ trunk/Source/_javascript_Core/API/JSWrapperMap.mm 2013-02-08 21:41:25 UTC (rev 142319)
@@ -36,7 +36,7 @@
#import "Operations.h"
#import "WeakGCMap.h"
#import <wtf/TCSpinLock.h>
-#import "wtf/Vector.h"
+#import <wtf/Vector.h>
@class JSObjCClassInfo;
@@ -74,7 +74,7 @@
// All semicolons are removed, lowercase letters following a semicolon are capitalized.
static NSString *selectorToPropertyName(const char* start)
{
- // Use 'index' to check for colons, if there are non, this is easy!
+ // Use 'index' to check for colons, if there are none, this is easy!
const char* firstColon = index(start, ':');
if (!firstColon)
return [NSString stringWithUTF8String:start];
@@ -114,9 +114,9 @@
return result;
}
-// Make an object that is in all ways are completely vanilla _javascript_ object,
+// Make an object that is in all ways a completely vanilla _javascript_ object,
// other than that it has a native brand set that will be displayed by the default
-// Object.prototype.toString comversion.
+// Object.prototype.toString conversion.
static JSValue *createObjectWithCustomBrand(JSContext *context, NSString *brand, JSClassRef parentClass = 0, void* privateData = 0)
{
JSClassDefinition definition;
@@ -162,8 +162,8 @@
// This method will iterate over the set of required methods in the protocol, and:
// * Determine a property name (either via a renameMap or default conversion).
-// * If an accessorMap is provided, and conatins a this name, store the method in the map.
-// * Otherwise, if the object doesn't already conatin a property with name, create it.
+// * If an accessorMap is provided, and contains this name, store the method in the map.
+// * Otherwise, if the object doesn't already contain a property with name, create it.
static void copyMethodsToObject(JSContext *context, Class objcClass, Protocol *protocol, BOOL isInstanceMethod, JSValue *object, NSMutableDictionary *accessorMethods = nil)
{
NSMutableDictionary *renameMap = createRenameMap(protocol, isInstanceMethod);
@@ -454,7 +454,7 @@
if (JSObjCClassInfo* classInfo = (JSObjCClassInfo*)m_classMap[cls])
return classInfo;
- // Skip internal classes begining with '_' - just copy link to the parent class's info.
+ // Skip internal classes beginning with '_' - just copy link to the parent class's info.
if ('_' == *class_getName(cls))
return m_classMap[cls] = [self classInfoForClass:class_getSuperclass(cls)];
@@ -478,7 +478,7 @@
// FIXME: https://bugs.webkit.org/show_bug.cgi?id=105891
// This general approach to wrapper caching is pretty effective, but there are a couple of problems:
// (1) For immortal objects JSValues will effectively leak and this results in error output being logged - we should avoid adding associated objects to immortal objects.
- // (2) A long lived object may rack up many JSValues. When the contexts are released these will unproctect the associated _javascript_ objects,
+ // (2) A long lived object may rack up many JSValues. When the contexts are released these will unprotect the associated _javascript_ objects,
// but still, would probably nicer if we made it so that only one associated object was required, broadcasting object dealloc.
JSC::ExecState* exec = toJS(contextInternalContext(m_context));
jsWrapper = toJS(exec, valueInternalValue(wrapper)).toObject(exec);
Modified: trunk/Source/_javascript_Core/ChangeLog (142318 => 142319)
--- trunk/Source/_javascript_Core/ChangeLog 2013-02-08 21:18:30 UTC (rev 142318)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-02-08 21:41:25 UTC (rev 142319)
@@ -1,3 +1,24 @@
+2013-02-08 Gavin Barraclough <[email protected]>
+
+ Objective-C API for _javascript_Core
+ https://bugs.webkit.org/show_bug.cgi?id=105889
+
+ Reviewed by Joseph Pecoraro
+
+ Following up on review comments, mostly typos.
+
+ * API/JSBlockAdaptor.h:
+ * API/JSBlockAdaptor.mm:
+ (-[JSBlockAdaptor blockFromValue:inContext:withException:]):
+ * API/JSContext.h:
+ * API/JSExport.h:
+ * API/JSValue.h:
+ * API/JSValue.mm:
+ * API/JSWrapperMap.mm:
+ (selectorToPropertyName):
+ (-[JSWrapperMap classInfoForClass:]):
+ (-[JSWrapperMap wrapperForObject:]):
+
2013-02-08 Martin Robinson <[email protected]>
[GTK] Add an experimental gyp build