├── JsCoreEngineWrapper.h ├── JsCoreEngineWrapper.m ├── MIT-LICENSE ├── README ├── lib ├── JSBase.h ├── JSContextRef.h ├── JSObjectRef.h ├── JSStringRef.h ├── JSStringRefCF.h ├── JSValueRef.h ├── JavaScript.h ├── JavaScriptCore.h ├── SCNEngine.h ├── SCNEngine.m └── WebKitAvailability.h └── libiOSJavaScriptCore.a /JsCoreEngineWrapper.h: -------------------------------------------------------------------------------- 1 | // 2 | // JsCoreEngineWrapper.h 3 | // Miso 4 | // 5 | // Created by Joshua Wu on 9/26/11. 6 | // Copyright 2011 Miso. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SCNEngine.h" 11 | 12 | @protocol JsCoreEngineWrapperDelegate; 13 | @interface JsCoreEngineWrapper : NSObject { 14 | SCNEngine *_scnEngine; 15 | } 16 | 17 | + (JsCoreEngineWrapper *)instance; 18 | - (void)evalJsString:(NSString *)jsString delegate:(id)delegate { 19 | 20 | @end 21 | 22 | @protocol JsCoreEngineWrapperDelegate 23 | 24 | - (void)JsCoreEvalResultsDidLoad:(NSString *)result; 25 | 26 | @end -------------------------------------------------------------------------------- /JsCoreEngineWrapper.m: -------------------------------------------------------------------------------- 1 | // 2 | // JsCoreEngineWrapper.m 3 | // Miso 4 | // 5 | // Created by Joshua Wu on 9/26/11. 6 | // Copyright 2011 Miso. All rights reserved. 7 | // 8 | 9 | #import "JsCoreEngineWrapper.h" 10 | 11 | @interface JsCoreEngineWrapper () 12 | 13 | - (void)evalJsStringBackground:(NSMutableDictionary *)evalParams; 14 | - (void)returnResultToDelegate:(NSMutableDictionary *)evalParams; 15 | - (void)reloadJsCore; 16 | 17 | @end 18 | 19 | @implementation JsCoreEngineWrapper 20 | 21 | +(JsCoreEngineWrapper *)instance { 22 | static JsCoreEngineWrapper *coreEngine = nil; 23 | 24 | if (coreEngine == nil) { 25 | coreEngine = [[JsCoreEngineWrapper alloc] init]; 26 | } 27 | 28 | return coreEngine; 29 | } 30 | 31 | - (id)init { 32 | if((self = [super init])) { 33 | // ScnEngine setup 34 | [self reloadJsCore]; 35 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadJsCore) name:@"REFRESH_TEMPLATES" object:nil]; 36 | } 37 | 38 | return self; 39 | } 40 | 41 | - (void)reloadJsCore { 42 | [_scnEngine release]; 43 | _scnEngine = [[SCNEngine alloc] init]; 44 | 45 | //NOTE: initialize any javascript libraries you wish to load here. 46 | /* 47 | NSString *libString = @"compiled/templates.js"; 48 | NSString *dirPath = [[TemplateController instance].localBaseUrl 49 | stringByAppendingPathComponent:[libString stringByDeletingLastPathComponent]]; 50 | NSString *fqFilePath = [dirPath stringByAppendingPathComponent:[libString lastPathComponent]]; 51 | 52 | NSString *data = [NSString stringWithContentsOfFile:fqFilePath encoding:NSUTF8StringEncoding error:nil]; 53 | if (data) { 54 | [_scnEngine runJS:data]; 55 | } 56 | */ 57 | 58 | } 59 | 60 | - (void)evalJsString:(NSString *)jsString delegate:(id)delegate { 61 | NSMutableDictionary *evalParams = [NSMutableDictionary dictionary]; 62 | [evalParams setObject:[NSNumber numberWithInt:jobNumber] forKey:@"jobNumber"]; 63 | [evalParams setObject:jsString forKey:@"jsString"]; 64 | [evalParams setObject:delegate forKey:@"delegate"]; 65 | 66 | [self performSelectorInBackground:@selector(runJSBackground:) withObject:evalParams]; 67 | } 68 | 69 | - (void)evalJsStringBackground:(NSMutableDictionary *)evalParams { 70 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 71 | 72 | NSString *jsString = [evalParams objectForKey:@"jsString"]; 73 | NSString *result = [_scnEngine runJS:jsString]; 74 | 75 | if (result != nil) { 76 | [evalParams setObject:result forKey:@"result"]; 77 | } 78 | 79 | [self performSelectorOnMainThread:@selector(returnResultToDelegate:) withObject:evalParams waitUntilDone:NO]; 80 | 81 | [pool release]; 82 | 83 | } 84 | 85 | - (void)returnResultToDelegate:(NSMutableDictionary *)evalParams { 86 | id delegate = [evalParams objectForKey:@"delegate"]; 87 | 88 | if ([delegate respondsToSelector:@selector(JsCoreEvalResultsDidLoad:)]) { 89 | [delegate JsCoreEvalResultsDidLoad:[evalParams objectOrNilForKey:@"result"]]; 90 | } 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2012 Joshua Wu 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | JsCoreEngineWrapper 2 | ------------------- 3 | Simple singleton iOS class that wraps a JavascriptCore library to process javascript in the background thread 4 | 5 | Installation 6 | ------------ 7 | 1. Import all the files into your project 8 | 2. Go to build phases and add the following libraries: 9 | - libstdc++.dylib 10 | - libicucore.dylib 11 | - libiOSJavaScriptCore.a 12 | 3. import "JsCoreEngineWrapper.h" 13 | 14 | Usage 15 | ----- 16 | 17 | 1. Implement delegate methods to get the callback 18 | 19 | eg. 20 | - (void)JsCoreEvalResultsDidLoad:(NSString *)result { 21 | NSLog(@"results: %@", result); 22 | } 23 | 24 | 2. Anywhere in your class, invoke javascript 25 | 26 | eg. 27 | [JsCoreEngineWrapper instance].evalJsString("...")]; 28 | 29 | 3. Get the result in the delegate method and there you have it! Javascript in the background thread. 30 | -------------------------------------------------------------------------------- /lib/JSBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSBase_h 27 | #define JSBase_h 28 | 29 | #ifndef __cplusplus 30 | #include 31 | #endif 32 | 33 | /* JavaScript engine interface */ 34 | 35 | /*! @typedef JSContextGroupRef A group that associates JavaScript contexts with one another. Contexts in the same group may share and exchange JavaScript objects. */ 36 | typedef const struct OpaqueJSContextGroup* JSContextGroupRef; 37 | 38 | /*! @typedef JSContextRef A JavaScript execution context. Holds the global object and other execution state. */ 39 | typedef const struct OpaqueJSContext* JSContextRef; 40 | 41 | /*! @typedef JSGlobalContextRef A global JavaScript execution context. A JSGlobalContext is a JSContext. */ 42 | typedef struct OpaqueJSContext* JSGlobalContextRef; 43 | 44 | /*! @typedef JSStringRef A UTF16 character buffer. The fundamental string representation in JavaScript. */ 45 | typedef struct OpaqueJSString* JSStringRef; 46 | 47 | /*! @typedef JSClassRef A JavaScript class. Used with JSObjectMake to construct objects with custom behavior. */ 48 | typedef struct OpaqueJSClass* JSClassRef; 49 | 50 | /*! @typedef JSPropertyNameArrayRef An array of JavaScript property names. */ 51 | typedef struct OpaqueJSPropertyNameArray* JSPropertyNameArrayRef; 52 | 53 | /*! @typedef JSPropertyNameAccumulatorRef An ordered set used to collect the names of a JavaScript object's properties. */ 54 | typedef struct OpaqueJSPropertyNameAccumulator* JSPropertyNameAccumulatorRef; 55 | 56 | 57 | /* JavaScript data types */ 58 | 59 | /*! @typedef JSValueRef A JavaScript value. The base type for all JavaScript values, and polymorphic functions on them. */ 60 | typedef const struct OpaqueJSValue* JSValueRef; 61 | 62 | /*! @typedef JSObjectRef A JavaScript object. A JSObject is a JSValue. */ 63 | typedef struct OpaqueJSValue* JSObjectRef; 64 | 65 | /* JavaScript symbol exports */ 66 | 67 | #undef JS_EXPORT 68 | #if defined(JS_NO_EXPORT) 69 | #define JS_EXPORT 70 | #elif defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC__) 71 | #define JS_EXPORT __attribute__((visibility("default"))) 72 | #elif defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE) 73 | #if defined(BUILDING_JavaScriptCore) || defined(BUILDING_WTF) 74 | #define JS_EXPORT __declspec(dllexport) 75 | #else 76 | #define JS_EXPORT __declspec(dllimport) 77 | #endif 78 | #else 79 | #define JS_EXPORT 80 | #endif 81 | 82 | #ifdef __cplusplus 83 | extern "C" { 84 | #endif 85 | 86 | /* Script Evaluation */ 87 | 88 | /*! 89 | @function JSEvaluateScript 90 | @abstract Evaluates a string of JavaScript. 91 | @param ctx The execution context to use. 92 | @param script A JSString containing the script to evaluate. 93 | @param thisObject The object to use as "this," or NULL to use the global object as "this." 94 | @param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. 95 | @param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. 96 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 97 | @result The JSValue that results from evaluating script, or NULL if an exception is thrown. 98 | */ 99 | JS_EXPORT JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); 100 | 101 | /*! 102 | @function JSCheckScriptSyntax 103 | @abstract Checks for syntax errors in a string of JavaScript. 104 | @param ctx The execution context to use. 105 | @param script A JSString containing the script to check for syntax errors. 106 | @param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. 107 | @param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. 108 | @param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception. 109 | @result true if the script is syntactically correct, otherwise false. 110 | */ 111 | JS_EXPORT bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); 112 | 113 | /*! 114 | @function JSGarbageCollect 115 | @abstract Performs a JavaScript garbage collection. 116 | @param ctx The execution context to use. 117 | @discussion JavaScript values that are on the machine stack, in a register, 118 | protected by JSValueProtect, set as the global object of an execution context, 119 | or reachable from any such value will not be collected. 120 | 121 | During JavaScript execution, you are not required to call this function; the 122 | JavaScript engine will garbage collect as needed. JavaScript values created 123 | within a context group are automatically destroyed when the last reference 124 | to the context group is released. 125 | */ 126 | JS_EXPORT void JSGarbageCollect(JSContextRef ctx); 127 | 128 | #ifdef __cplusplus 129 | } 130 | #endif 131 | 132 | #endif /* JSBase_h */ 133 | -------------------------------------------------------------------------------- /lib/JSContextRef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSContextRef_h 27 | #define JSContextRef_h 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #ifndef __cplusplus 34 | #include 35 | #endif 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /*! 42 | @function 43 | @abstract Creates a JavaScript context group. 44 | @discussion A JSContextGroup associates JavaScript contexts with one another. 45 | Contexts in the same group may share and exchange JavaScript objects. Sharing and/or exchanging 46 | JavaScript objects between contexts in different groups will produce undefined behavior. 47 | When objects from the same context group are used in multiple threads, explicit 48 | synchronization is required. 49 | @result The created JSContextGroup. 50 | */ 51 | JS_EXPORT JSContextGroupRef JSContextGroupCreate() AVAILABLE_IN_WEBKIT_VERSION_4_0; 52 | 53 | /*! 54 | @function 55 | @abstract Retains a JavaScript context group. 56 | @param group The JSContextGroup to retain. 57 | @result A JSContextGroup that is the same as group. 58 | */ 59 | JS_EXPORT JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) AVAILABLE_IN_WEBKIT_VERSION_4_0; 60 | 61 | /*! 62 | @function 63 | @abstract Releases a JavaScript context group. 64 | @param group The JSContextGroup to release. 65 | */ 66 | JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) AVAILABLE_IN_WEBKIT_VERSION_4_0; 67 | 68 | /*! 69 | @function 70 | @abstract Creates a global JavaScript execution context. 71 | @discussion JSGlobalContextCreate allocates a global object and populates it with all the 72 | built-in JavaScript objects, such as Object, Function, String, and Array. 73 | 74 | In WebKit version 4.0 and later, the context is created in a unique context group. 75 | Therefore, scripts may execute in it concurrently with scripts executing in other contexts. 76 | However, you may not use values created in the context in other contexts. 77 | @param globalObjectClass The class to use when creating the global object. Pass 78 | NULL to use the default object class. 79 | @result A JSGlobalContext with a global object of class globalObjectClass. 80 | */ 81 | JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; 82 | 83 | /*! 84 | @function 85 | @abstract Creates a global JavaScript execution context in the context group provided. 86 | @discussion JSGlobalContextCreateInGroup allocates a global object and populates it with 87 | all the built-in JavaScript objects, such as Object, Function, String, and Array. 88 | @param globalObjectClass The class to use when creating the global object. Pass 89 | NULL to use the default object class. 90 | @param group The context group to use. The created global context retains the group. 91 | Pass NULL to create a unique group for the context. 92 | @result A JSGlobalContext with a global object of class globalObjectClass and a context 93 | group equal to group. 94 | */ 95 | JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) AVAILABLE_IN_WEBKIT_VERSION_4_0; 96 | 97 | /*! 98 | @function 99 | @abstract Retains a global JavaScript execution context. 100 | @param ctx The JSGlobalContext to retain. 101 | @result A JSGlobalContext that is the same as ctx. 102 | */ 103 | JS_EXPORT JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx); 104 | 105 | /*! 106 | @function 107 | @abstract Releases a global JavaScript execution context. 108 | @param ctx The JSGlobalContext to release. 109 | */ 110 | JS_EXPORT void JSGlobalContextRelease(JSGlobalContextRef ctx); 111 | 112 | /*! 113 | @function 114 | @abstract Gets the global object of a JavaScript execution context. 115 | @param ctx The JSContext whose global object you want to get. 116 | @result ctx's global object. 117 | */ 118 | JS_EXPORT JSObjectRef JSContextGetGlobalObject(JSContextRef ctx); 119 | 120 | /*! 121 | @function 122 | @abstract Gets the context group to which a JavaScript execution context belongs. 123 | @param ctx The JSContext whose group you want to get. 124 | @result ctx's group. 125 | */ 126 | JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) AVAILABLE_IN_WEBKIT_VERSION_4_0; 127 | 128 | #ifdef __cplusplus 129 | } 130 | #endif 131 | 132 | #endif /* JSContextRef_h */ 133 | -------------------------------------------------------------------------------- /lib/JSObjectRef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 | * Copyright (C) 2008 Kelvin W Sherlock (ksherlock@gmail.com) 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef JSObjectRef_h 28 | #define JSObjectRef_h 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #ifndef __cplusplus 35 | #include 36 | #endif 37 | #include /* for size_t */ 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /*! 44 | @enum JSPropertyAttribute 45 | @constant kJSPropertyAttributeNone Specifies that a property has no special attributes. 46 | @constant kJSPropertyAttributeReadOnly Specifies that a property is read-only. 47 | @constant kJSPropertyAttributeDontEnum Specifies that a property should not be enumerated by JSPropertyEnumerators and JavaScript for...in loops. 48 | @constant kJSPropertyAttributeDontDelete Specifies that the delete operation should fail on a property. 49 | */ 50 | enum { 51 | kJSPropertyAttributeNone = 0, 52 | kJSPropertyAttributeReadOnly = 1 << 1, 53 | kJSPropertyAttributeDontEnum = 1 << 2, 54 | kJSPropertyAttributeDontDelete = 1 << 3 55 | }; 56 | 57 | /*! 58 | @typedef JSPropertyAttributes 59 | @abstract A set of JSPropertyAttributes. Combine multiple attributes by logically ORing them together. 60 | */ 61 | typedef unsigned JSPropertyAttributes; 62 | 63 | /*! 64 | @enum JSClassAttribute 65 | @constant kJSClassAttributeNone Specifies that a class has no special attributes. 66 | @constant kJSClassAttributeNoAutomaticPrototype Specifies that a class should not automatically generate a shared prototype for its instance objects. Use kJSClassAttributeNoAutomaticPrototype in combination with JSObjectSetPrototype to manage prototypes manually. 67 | */ 68 | enum { 69 | kJSClassAttributeNone = 0, 70 | kJSClassAttributeNoAutomaticPrototype = 1 << 1 71 | }; 72 | 73 | /*! 74 | @typedef JSClassAttributes 75 | @abstract A set of JSClassAttributes. Combine multiple attributes by logically ORing them together. 76 | */ 77 | typedef unsigned JSClassAttributes; 78 | 79 | /*! 80 | @typedef JSObjectInitializeCallback 81 | @abstract The callback invoked when an object is first created. 82 | @param ctx The execution context to use. 83 | @param object The JSObject being created. 84 | @discussion If you named your function Initialize, you would declare it like this: 85 | 86 | void Initialize(JSContextRef ctx, JSObjectRef object); 87 | 88 | Unlike the other object callbacks, the initialize callback is called on the least 89 | derived class (the parent class) first, and the most derived class last. 90 | */ 91 | typedef void 92 | (*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object); 93 | 94 | /*! 95 | @typedef JSObjectFinalizeCallback 96 | @abstract The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread. 97 | @param object The JSObject being finalized. 98 | @discussion If you named your function Finalize, you would declare it like this: 99 | 100 | void Finalize(JSObjectRef object); 101 | 102 | The finalize callback is called on the most derived class first, and the least 103 | derived class (the parent class) last. 104 | 105 | You must not call any function that may cause a garbage collection or an allocation 106 | of a garbage collected object from within a JSObjectFinalizeCallback. This includes 107 | all functions that have a JSContextRef parameter. 108 | */ 109 | typedef void 110 | (*JSObjectFinalizeCallback) (JSObjectRef object); 111 | 112 | /*! 113 | @typedef JSObjectHasPropertyCallback 114 | @abstract The callback invoked when determining whether an object has a property. 115 | @param ctx The execution context to use. 116 | @param object The JSObject to search for the property. 117 | @param propertyName A JSString containing the name of the property look up. 118 | @result true if object has the property, otherwise false. 119 | @discussion If you named your function HasProperty, you would declare it like this: 120 | 121 | bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 122 | 123 | If this function returns false, the hasProperty request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain. 124 | 125 | This callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value would be expensive. 126 | 127 | If this callback is NULL, the getProperty callback will be used to service hasProperty requests. 128 | */ 129 | typedef bool 130 | (*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 131 | 132 | /*! 133 | @typedef JSObjectGetPropertyCallback 134 | @abstract The callback invoked when getting a property's value. 135 | @param ctx The execution context to use. 136 | @param object The JSObject to search for the property. 137 | @param propertyName A JSString containing the name of the property to get. 138 | @param exception A pointer to a JSValueRef in which to return an exception, if any. 139 | @result The property's value if object has the property, otherwise NULL. 140 | @discussion If you named your function GetProperty, you would declare it like this: 141 | 142 | JSValueRef GetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 143 | 144 | If this function returns NULL, the get request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain. 145 | */ 146 | typedef JSValueRef 147 | (*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 148 | 149 | /*! 150 | @typedef JSObjectSetPropertyCallback 151 | @abstract The callback invoked when setting a property's value. 152 | @param ctx The execution context to use. 153 | @param object The JSObject on which to set the property's value. 154 | @param propertyName A JSString containing the name of the property to set. 155 | @param value A JSValue to use as the property's value. 156 | @param exception A pointer to a JSValueRef in which to return an exception, if any. 157 | @result true if the property was set, otherwise false. 158 | @discussion If you named your function SetProperty, you would declare it like this: 159 | 160 | bool SetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); 161 | 162 | If this function returns false, the set request forwards to object's statically declared properties, then its parent class chain (which includes the default object class). 163 | */ 164 | typedef bool 165 | (*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); 166 | 167 | /*! 168 | @typedef JSObjectDeletePropertyCallback 169 | @abstract The callback invoked when deleting a property. 170 | @param ctx The execution context to use. 171 | @param object The JSObject in which to delete the property. 172 | @param propertyName A JSString containing the name of the property to delete. 173 | @param exception A pointer to a JSValueRef in which to return an exception, if any. 174 | @result true if propertyName was successfully deleted, otherwise false. 175 | @discussion If you named your function DeleteProperty, you would declare it like this: 176 | 177 | bool DeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 178 | 179 | If this function returns false, the delete request forwards to object's statically declared properties, then its parent class chain (which includes the default object class). 180 | */ 181 | typedef bool 182 | (*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 183 | 184 | /*! 185 | @typedef JSObjectGetPropertyNamesCallback 186 | @abstract The callback invoked when collecting the names of an object's properties. 187 | @param ctx The execution context to use. 188 | @param object The JSObject whose property names are being collected. 189 | @param accumulator A JavaScript property name accumulator in which to accumulate the names of object's properties. 190 | @discussion If you named your function GetPropertyNames, you would declare it like this: 191 | 192 | void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); 193 | 194 | Property name accumulators are used by JSObjectCopyPropertyNames and JavaScript for...in loops. 195 | 196 | Use JSPropertyNameAccumulatorAddName to add property names to accumulator. A class's getPropertyNames callback only needs to provide the names of properties that the class vends through a custom getProperty or setProperty callback. Other properties, including statically declared properties, properties vended by other classes, and properties belonging to object's prototype, are added independently. 197 | */ 198 | typedef void 199 | (*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); 200 | 201 | /*! 202 | @typedef JSObjectCallAsFunctionCallback 203 | @abstract The callback invoked when an object is called as a function. 204 | @param ctx The execution context to use. 205 | @param function A JSObject that is the function being called. 206 | @param thisObject A JSObject that is the 'this' variable in the function's scope. 207 | @param argumentCount An integer count of the number of arguments in arguments. 208 | @param arguments A JSValue array of the arguments passed to the function. 209 | @param exception A pointer to a JSValueRef in which to return an exception, if any. 210 | @result A JSValue that is the function's return value. 211 | @discussion If you named your function CallAsFunction, you would declare it like this: 212 | 213 | JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 214 | 215 | If your callback were invoked by the JavaScript expression 'myObject.myFunction()', function would be set to myFunction, and thisObject would be set to myObject. 216 | 217 | If this callback is NULL, calling your object as a function will throw an exception. 218 | */ 219 | typedef JSValueRef 220 | (*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 221 | 222 | /*! 223 | @typedef JSObjectCallAsConstructorCallback 224 | @abstract The callback invoked when an object is used as a constructor in a 'new' expression. 225 | @param ctx The execution context to use. 226 | @param constructor A JSObject that is the constructor being called. 227 | @param argumentCount An integer count of the number of arguments in arguments. 228 | @param arguments A JSValue array of the arguments passed to the function. 229 | @param exception A pointer to a JSValueRef in which to return an exception, if any. 230 | @result A JSObject that is the constructor's return value. 231 | @discussion If you named your function CallAsConstructor, you would declare it like this: 232 | 233 | JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 234 | 235 | If your callback were invoked by the JavaScript expression 'new myConstructor()', constructor would be set to myConstructor. 236 | 237 | If this callback is NULL, using your object as a constructor in a 'new' expression will throw an exception. 238 | */ 239 | typedef JSObjectRef 240 | (*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 241 | 242 | /*! 243 | @typedef JSObjectHasInstanceCallback 244 | @abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression. 245 | @param ctx The execution context to use. 246 | @param constructor The JSObject that is the target of the 'instanceof' expression. 247 | @param possibleInstance The JSValue being tested to determine if it is an instance of constructor. 248 | @param exception A pointer to a JSValueRef in which to return an exception, if any. 249 | @result true if possibleInstance is an instance of constructor, otherwise false. 250 | @discussion If you named your function HasInstance, you would declare it like this: 251 | 252 | bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); 253 | 254 | If your callback were invoked by the JavaScript expression 'someValue instanceof myObject', constructor would be set to myObject and possibleInstance would be set to someValue. 255 | 256 | If this callback is NULL, 'instanceof' expressions that target your object will return false. 257 | 258 | Standard JavaScript practice calls for objects that implement the callAsConstructor callback to implement the hasInstance callback as well. 259 | */ 260 | typedef bool 261 | (*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); 262 | 263 | /*! 264 | @typedef JSObjectConvertToTypeCallback 265 | @abstract The callback invoked when converting an object to a particular JavaScript type. 266 | @param ctx The execution context to use. 267 | @param object The JSObject to convert. 268 | @param type A JSType specifying the JavaScript type to convert to. 269 | @param exception A pointer to a JSValueRef in which to return an exception, if any. 270 | @result The objects's converted value, or NULL if the object was not converted. 271 | @discussion If you named your function ConvertToType, you would declare it like this: 272 | 273 | JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); 274 | 275 | If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class). 276 | 277 | This function is only invoked when converting an object to number or string. An object converted to boolean is 'true.' An object converted to object is itself. 278 | */ 279 | typedef JSValueRef 280 | (*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); 281 | 282 | /*! 283 | @struct JSStaticValue 284 | @abstract This structure describes a statically declared value property. 285 | @field name A null-terminated UTF8 string containing the property's name. 286 | @field getProperty A JSObjectGetPropertyCallback to invoke when getting the property's value. 287 | @field setProperty A JSObjectSetPropertyCallback to invoke when setting the property's value. May be NULL if the ReadOnly attribute is set. 288 | @field attributes A logically ORed set of JSPropertyAttributes to give to the property. 289 | */ 290 | typedef struct { 291 | const char* const name; 292 | JSObjectGetPropertyCallback getProperty; 293 | JSObjectSetPropertyCallback setProperty; 294 | JSPropertyAttributes attributes; 295 | } JSStaticValue; 296 | 297 | /*! 298 | @struct JSStaticFunction 299 | @abstract This structure describes a statically declared function property. 300 | @field name A null-terminated UTF8 string containing the property's name. 301 | @field callAsFunction A JSObjectCallAsFunctionCallback to invoke when the property is called as a function. 302 | @field attributes A logically ORed set of JSPropertyAttributes to give to the property. 303 | */ 304 | typedef struct { 305 | const char* const name; 306 | JSObjectCallAsFunctionCallback callAsFunction; 307 | JSPropertyAttributes attributes; 308 | } JSStaticFunction; 309 | 310 | /*! 311 | @struct JSClassDefinition 312 | @abstract This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL. 313 | @field version The version number of this structure. The current version is 0. 314 | @field attributes A logically ORed set of JSClassAttributes to give to the class. 315 | @field className A null-terminated UTF8 string containing the class's name. 316 | @field parentClass A JSClass to set as the class's parent class. Pass NULL use the default object class. 317 | @field staticValues A JSStaticValue array containing the class's statically declared value properties. Pass NULL to specify no statically declared value properties. The array must be terminated by a JSStaticValue whose name field is NULL. 318 | @field staticFunctions A JSStaticFunction array containing the class's statically declared function properties. Pass NULL to specify no statically declared function properties. The array must be terminated by a JSStaticFunction whose name field is NULL. 319 | @field initialize The callback invoked when an object is first created. Use this callback to initialize the object. 320 | @field finalize The callback invoked when an object is finalized (prepared for garbage collection). Use this callback to release resources allocated for the object, and perform other cleanup. 321 | @field hasProperty The callback invoked when determining whether an object has a property. If this field is NULL, getProperty is called instead. The hasProperty callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value is expensive. 322 | @field getProperty The callback invoked when getting a property's value. 323 | @field setProperty The callback invoked when setting a property's value. 324 | @field deleteProperty The callback invoked when deleting a property. 325 | @field getPropertyNames The callback invoked when collecting the names of an object's properties. 326 | @field callAsFunction The callback invoked when an object is called as a function. 327 | @field hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression. 328 | @field callAsConstructor The callback invoked when an object is used as a constructor in a 'new' expression. 329 | @field convertToType The callback invoked when converting an object to a particular JavaScript type. 330 | @discussion The staticValues and staticFunctions arrays are the simplest and most efficient means for vending custom properties. Statically declared properties autmatically service requests like getProperty, setProperty, and getPropertyNames. Property access callbacks are required only to implement unusual properties, like array indexes, whose names are not known at compile-time. 331 | 332 | If you named your getter function "GetX" and your setter function "SetX", you would declare a JSStaticValue array containing "X" like this: 333 | 334 | JSStaticValue StaticValueArray[] = { 335 | { "X", GetX, SetX, kJSPropertyAttributeNone }, 336 | { 0, 0, 0, 0 } 337 | }; 338 | 339 | Standard JavaScript practice calls for storing function objects in prototypes, so they can be shared. The default JSClass created by JSClassCreate follows this idiom, instantiating objects with a shared, automatically generating prototype containing the class's function objects. The kJSClassAttributeNoAutomaticPrototype attribute specifies that a JSClass should not automatically generate such a prototype. The resulting JSClass instantiates objects with the default object prototype, and gives each instance object its own copy of the class's function objects. 340 | 341 | A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute. 342 | */ 343 | typedef struct { 344 | int version; /* current (and only) version is 0 */ 345 | JSClassAttributes attributes; 346 | 347 | const char* className; 348 | JSClassRef parentClass; 349 | 350 | const JSStaticValue* staticValues; 351 | const JSStaticFunction* staticFunctions; 352 | 353 | JSObjectInitializeCallback initialize; 354 | JSObjectFinalizeCallback finalize; 355 | JSObjectHasPropertyCallback hasProperty; 356 | JSObjectGetPropertyCallback getProperty; 357 | JSObjectSetPropertyCallback setProperty; 358 | JSObjectDeletePropertyCallback deleteProperty; 359 | JSObjectGetPropertyNamesCallback getPropertyNames; 360 | JSObjectCallAsFunctionCallback callAsFunction; 361 | JSObjectCallAsConstructorCallback callAsConstructor; 362 | JSObjectHasInstanceCallback hasInstance; 363 | JSObjectConvertToTypeCallback convertToType; 364 | } JSClassDefinition; 365 | 366 | /*! 367 | @const kJSClassDefinitionEmpty 368 | @abstract A JSClassDefinition structure of the current version, filled with NULL pointers and having no attributes. 369 | @discussion Use this constant as a convenience when creating class definitions. For example, to create a class definition with only a finalize method: 370 | 371 | JSClassDefinition definition = kJSClassDefinitionEmpty; 372 | definition.finalize = Finalize; 373 | */ 374 | JS_EXPORT extern const JSClassDefinition kJSClassDefinitionEmpty; 375 | 376 | /*! 377 | @function 378 | @abstract Creates a JavaScript class suitable for use with JSObjectMake. 379 | @param definition A JSClassDefinition that defines the class. 380 | @result A JSClass with the given definition. Ownership follows the Create Rule. 381 | */ 382 | JS_EXPORT JSClassRef JSClassCreate(const JSClassDefinition* definition); 383 | 384 | /*! 385 | @function 386 | @abstract Retains a JavaScript class. 387 | @param jsClass The JSClass to retain. 388 | @result A JSClass that is the same as jsClass. 389 | */ 390 | JS_EXPORT JSClassRef JSClassRetain(JSClassRef jsClass); 391 | 392 | /*! 393 | @function 394 | @abstract Releases a JavaScript class. 395 | @param jsClass The JSClass to release. 396 | */ 397 | JS_EXPORT void JSClassRelease(JSClassRef jsClass); 398 | 399 | /*! 400 | @function 401 | @abstract Creates a JavaScript object. 402 | @param ctx The execution context to use. 403 | @param jsClass The JSClass to assign to the object. Pass NULL to use the default object class. 404 | @param data A void* to set as the object's private data. Pass NULL to specify no private data. 405 | @result A JSObject with the given class and private data. 406 | @discussion The default object class does not allocate storage for private data, so you must provide a non-NULL jsClass to JSObjectMake if you want your object to be able to store private data. 407 | 408 | data is set on the created object before the intialize methods in its class chain are called. This enables the initialize methods to retrieve and manipulate data through JSObjectGetPrivate. 409 | */ 410 | JS_EXPORT JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data); 411 | 412 | /*! 413 | @function 414 | @abstract Convenience method for creating a JavaScript function with a given callback as its implementation. 415 | @param ctx The execution context to use. 416 | @param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function. 417 | @param callAsFunction The JSObjectCallAsFunctionCallback to invoke when the function is called. 418 | @result A JSObject that is a function. The object's prototype will be the default function prototype. 419 | */ 420 | JS_EXPORT JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction); 421 | 422 | /*! 423 | @function 424 | @abstract Convenience method for creating a JavaScript constructor. 425 | @param ctx The execution context to use. 426 | @param jsClass A JSClass that is the class your constructor will assign to the objects its constructs. jsClass will be used to set the constructor's .prototype property, and to evaluate 'instanceof' expressions. Pass NULL to use the default object class. 427 | @param callAsConstructor A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a 'new' expression. Pass NULL to use the default object constructor. 428 | @result A JSObject that is a constructor. The object's prototype will be the default object prototype. 429 | @discussion The default object constructor takes no arguments and constructs an object of class jsClass with no private data. 430 | */ 431 | JS_EXPORT JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor); 432 | 433 | /*! 434 | @function 435 | @abstract Creates a JavaScript Array object. 436 | @param ctx The execution context to use. 437 | @param argumentCount An integer count of the number of arguments in arguments. 438 | @param arguments A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0. 439 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 440 | @result A JSObject that is an Array. 441 | @discussion The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument 442 | is supplied, this function returns an array with one element. 443 | */ 444 | JS_EXPORT JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0; 445 | 446 | /*! 447 | @function 448 | @abstract Creates a JavaScript Date object, as if by invoking the built-in Date constructor. 449 | @param ctx The execution context to use. 450 | @param argumentCount An integer count of the number of arguments in arguments. 451 | @param arguments A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0. 452 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 453 | @result A JSObject that is a Date. 454 | */ 455 | JS_EXPORT JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0; 456 | 457 | /*! 458 | @function 459 | @abstract Creates a JavaScript Error object, as if by invoking the built-in Error constructor. 460 | @param ctx The execution context to use. 461 | @param argumentCount An integer count of the number of arguments in arguments. 462 | @param arguments A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0. 463 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 464 | @result A JSObject that is a Error. 465 | */ 466 | JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0; 467 | 468 | /*! 469 | @function 470 | @abstract Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor. 471 | @param ctx The execution context to use. 472 | @param argumentCount An integer count of the number of arguments in arguments. 473 | @param arguments A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0. 474 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 475 | @result A JSObject that is a RegExp. 476 | */ 477 | JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0; 478 | 479 | /*! 480 | @function 481 | @abstract Creates a function with a given script as its body. 482 | @param ctx The execution context to use. 483 | @param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function. 484 | @param parameterCount An integer count of the number of parameter names in parameterNames. 485 | @param parameterNames A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0. 486 | @param body A JSString containing the script to use as the function's body. 487 | @param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. 488 | @param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. 489 | @param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception. 490 | @result A JSObject that is a function, or NULL if either body or parameterNames contains a syntax error. The object's prototype will be the default function prototype. 491 | @discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution. 492 | */ 493 | JS_EXPORT JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); 494 | 495 | /*! 496 | @function 497 | @abstract Gets an object's prototype. 498 | @param ctx The execution context to use. 499 | @param object A JSObject whose prototype you want to get. 500 | @result A JSValue that is the object's prototype. 501 | */ 502 | JS_EXPORT JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object); 503 | 504 | /*! 505 | @function 506 | @abstract Sets an object's prototype. 507 | @param ctx The execution context to use. 508 | @param object The JSObject whose prototype you want to set. 509 | @param value A JSValue to set as the object's prototype. 510 | */ 511 | JS_EXPORT void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value); 512 | 513 | /*! 514 | @function 515 | @abstract Tests whether an object has a given property. 516 | @param object The JSObject to test. 517 | @param propertyName A JSString containing the property's name. 518 | @result true if the object has a property whose name matches propertyName, otherwise false. 519 | */ 520 | JS_EXPORT bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 521 | 522 | /*! 523 | @function 524 | @abstract Gets a property from an object. 525 | @param ctx The execution context to use. 526 | @param object The JSObject whose property you want to get. 527 | @param propertyName A JSString containing the property's name. 528 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 529 | @result The property's value if object has the property, otherwise the undefined value. 530 | */ 531 | JS_EXPORT JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 532 | 533 | /*! 534 | @function 535 | @abstract Sets a property on an object. 536 | @param ctx The execution context to use. 537 | @param object The JSObject whose property you want to set. 538 | @param propertyName A JSString containing the property's name. 539 | @param value A JSValue to use as the property's value. 540 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 541 | @param attributes A logically ORed set of JSPropertyAttributes to give to the property. 542 | */ 543 | JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception); 544 | 545 | /*! 546 | @function 547 | @abstract Deletes a property from an object. 548 | @param ctx The execution context to use. 549 | @param object The JSObject whose property you want to delete. 550 | @param propertyName A JSString containing the property's name. 551 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 552 | @result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set). 553 | */ 554 | JS_EXPORT bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); 555 | 556 | /*! 557 | @function 558 | @abstract Gets a property from an object by numeric index. 559 | @param ctx The execution context to use. 560 | @param object The JSObject whose property you want to get. 561 | @param propertyIndex An integer value that is the property's name. 562 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 563 | @result The property's value if object has the property, otherwise the undefined value. 564 | @discussion Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties. 565 | */ 566 | JS_EXPORT JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception); 567 | 568 | /*! 569 | @function 570 | @abstract Sets a property on an object by numeric index. 571 | @param ctx The execution context to use. 572 | @param object The JSObject whose property you want to set. 573 | @param propertyIndex The property's name as a number. 574 | @param value A JSValue to use as the property's value. 575 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 576 | @discussion Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties. 577 | */ 578 | JS_EXPORT void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception); 579 | 580 | /*! 581 | @function 582 | @abstract Gets an object's private data. 583 | @param object A JSObject whose private data you want to get. 584 | @result A void* that is the object's private data, if the object has private data, otherwise NULL. 585 | */ 586 | JS_EXPORT void* JSObjectGetPrivate(JSObjectRef object); 587 | 588 | /*! 589 | @function 590 | @abstract Sets a pointer to private data on an object. 591 | @param object The JSObject whose private data you want to set. 592 | @param data A void* to set as the object's private data. 593 | @result true if object can store private data, otherwise false. 594 | @discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data. 595 | */ 596 | JS_EXPORT bool JSObjectSetPrivate(JSObjectRef object, void* data); 597 | 598 | /*! 599 | @function 600 | @abstract Tests whether an object can be called as a function. 601 | @param ctx The execution context to use. 602 | @param object The JSObject to test. 603 | @result true if the object can be called as a function, otherwise false. 604 | */ 605 | JS_EXPORT bool JSObjectIsFunction(JSContextRef ctx, JSObjectRef object); 606 | 607 | /*! 608 | @function 609 | @abstract Calls an object as a function. 610 | @param ctx The execution context to use. 611 | @param object The JSObject to call as a function. 612 | @param thisObject The object to use as "this," or NULL to use the global object as "this." 613 | @param argumentCount An integer count of the number of arguments in arguments. 614 | @param arguments A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0. 615 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 616 | @result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function. 617 | */ 618 | JS_EXPORT JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 619 | 620 | /*! 621 | @function 622 | @abstract Tests whether an object can be called as a constructor. 623 | @param ctx The execution context to use. 624 | @param object The JSObject to test. 625 | @result true if the object can be called as a constructor, otherwise false. 626 | */ 627 | JS_EXPORT bool JSObjectIsConstructor(JSContextRef ctx, JSObjectRef object); 628 | 629 | /*! 630 | @function 631 | @abstract Calls an object as a constructor. 632 | @param ctx The execution context to use. 633 | @param object The JSObject to call as a constructor. 634 | @param argumentCount An integer count of the number of arguments in arguments. 635 | @param arguments A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0. 636 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 637 | @result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor. 638 | */ 639 | JS_EXPORT JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 640 | 641 | /*! 642 | @function 643 | @abstract Gets the names of an object's enumerable properties. 644 | @param ctx The execution context to use. 645 | @param object The object whose property names you want to get. 646 | @result A JSPropertyNameArray containing the names object's enumerable properties. Ownership follows the Create Rule. 647 | */ 648 | JS_EXPORT JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object); 649 | 650 | /*! 651 | @function 652 | @abstract Retains a JavaScript property name array. 653 | @param array The JSPropertyNameArray to retain. 654 | @result A JSPropertyNameArray that is the same as array. 655 | */ 656 | JS_EXPORT JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array); 657 | 658 | /*! 659 | @function 660 | @abstract Releases a JavaScript property name array. 661 | @param array The JSPropetyNameArray to release. 662 | */ 663 | JS_EXPORT void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array); 664 | 665 | /*! 666 | @function 667 | @abstract Gets a count of the number of items in a JavaScript property name array. 668 | @param array The array from which to retrieve the count. 669 | @result An integer count of the number of names in array. 670 | */ 671 | JS_EXPORT size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array); 672 | 673 | /*! 674 | @function 675 | @abstract Gets a property name at a given index in a JavaScript property name array. 676 | @param array The array from which to retrieve the property name. 677 | @param index The index of the property name to retrieve. 678 | @result A JSStringRef containing the property name. 679 | */ 680 | JS_EXPORT JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index); 681 | 682 | /*! 683 | @function 684 | @abstract Adds a property name to a JavaScript property name accumulator. 685 | @param accumulator The accumulator object to which to add the property name. 686 | @param propertyName The property name to add. 687 | */ 688 | JS_EXPORT void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef accumulator, JSStringRef propertyName); 689 | 690 | #ifdef __cplusplus 691 | } 692 | #endif 693 | 694 | #endif /* JSObjectRef_h */ 695 | -------------------------------------------------------------------------------- /lib/JSStringRef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSStringRef_h 27 | #define JSStringRef_h 28 | 29 | #include 30 | 31 | #ifndef __cplusplus 32 | #include 33 | #endif 34 | #include /* for size_t */ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #if !defined(WIN32) && !defined(_WIN32) && !defined(__WINSCW__) \ 41 | && !((defined(__CC_ARM) || defined(__ARMCC__)) && defined(__SYMBIAN32__)) /* RVCT */ 42 | /*! 43 | @typedef JSChar 44 | @abstract A Unicode character. 45 | */ 46 | typedef unsigned short JSChar; 47 | #else 48 | typedef wchar_t JSChar; 49 | #endif 50 | 51 | /*! 52 | @function 53 | @abstract Creates a JavaScript string from a buffer of Unicode characters. 54 | @param chars The buffer of Unicode characters to copy into the new JSString. 55 | @param numChars The number of characters to copy from the buffer pointed to by chars. 56 | @result A JSString containing chars. Ownership follows the Create Rule. 57 | */ 58 | JS_EXPORT JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars); 59 | /*! 60 | @function 61 | @abstract Creates a JavaScript string from a null-terminated UTF8 string. 62 | @param string The null-terminated UTF8 string to copy into the new JSString. 63 | @result A JSString containing string. Ownership follows the Create Rule. 64 | */ 65 | JS_EXPORT JSStringRef JSStringCreateWithUTF8CString(const char* string); 66 | 67 | /*! 68 | @function 69 | @abstract Retains a JavaScript string. 70 | @param string The JSString to retain. 71 | @result A JSString that is the same as string. 72 | */ 73 | JS_EXPORT JSStringRef JSStringRetain(JSStringRef string); 74 | /*! 75 | @function 76 | @abstract Releases a JavaScript string. 77 | @param string The JSString to release. 78 | */ 79 | JS_EXPORT void JSStringRelease(JSStringRef string); 80 | 81 | /*! 82 | @function 83 | @abstract Returns the number of Unicode characters in a JavaScript string. 84 | @param string The JSString whose length (in Unicode characters) you want to know. 85 | @result The number of Unicode characters stored in string. 86 | */ 87 | JS_EXPORT size_t JSStringGetLength(JSStringRef string); 88 | /*! 89 | @function 90 | @abstract Returns a pointer to the Unicode character buffer that 91 | serves as the backing store for a JavaScript string. 92 | @param string The JSString whose backing store you want to access. 93 | @result A pointer to the Unicode character buffer that serves as string's 94 | backing store, which will be deallocated when string is deallocated. 95 | */ 96 | JS_EXPORT const JSChar* JSStringGetCharactersPtr(JSStringRef string); 97 | 98 | /*! 99 | @function 100 | @abstract Returns the maximum number of bytes a JavaScript string will 101 | take up if converted into a null-terminated UTF8 string. 102 | @param string The JSString whose maximum converted size (in bytes) you 103 | want to know. 104 | @result The maximum number of bytes that could be required to convert string into a 105 | null-terminated UTF8 string. The number of bytes that the conversion actually ends 106 | up requiring could be less than this, but never more. 107 | */ 108 | JS_EXPORT size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string); 109 | /*! 110 | @function 111 | @abstract Converts a JavaScript string into a null-terminated UTF8 string, 112 | and copies the result into an external byte buffer. 113 | @param string The source JSString. 114 | @param buffer The destination byte buffer into which to copy a null-terminated 115 | UTF8 representation of string. On return, buffer contains a UTF8 string 116 | representation of string. If bufferSize is too small, buffer will contain only 117 | partial results. If buffer is not at least bufferSize bytes in size, 118 | behavior is undefined. 119 | @param bufferSize The size of the external buffer in bytes. 120 | @result The number of bytes written into buffer (including the null-terminator byte). 121 | */ 122 | JS_EXPORT size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize); 123 | 124 | /*! 125 | @function 126 | @abstract Tests whether two JavaScript strings match. 127 | @param a The first JSString to test. 128 | @param b The second JSString to test. 129 | @result true if the two strings match, otherwise false. 130 | */ 131 | JS_EXPORT bool JSStringIsEqual(JSStringRef a, JSStringRef b); 132 | /*! 133 | @function 134 | @abstract Tests whether a JavaScript string matches a null-terminated UTF8 string. 135 | @param a The JSString to test. 136 | @param b The null-terminated UTF8 string to test. 137 | @result true if the two strings match, otherwise false. 138 | */ 139 | JS_EXPORT bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b); 140 | 141 | #ifdef __cplusplus 142 | } 143 | #endif 144 | 145 | #endif /* JSStringRef_h */ 146 | -------------------------------------------------------------------------------- /lib/JSStringRefCF.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2007 Apple Computer, Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSStringRefCF_h 27 | #define JSStringRefCF_h 28 | 29 | #include "JSBase.h" 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* CFString convenience methods */ 37 | 38 | /*! 39 | @function 40 | @abstract Creates a JavaScript string from a CFString. 41 | @discussion This function is optimized to take advantage of cases when 42 | CFStringGetCharactersPtr returns a valid pointer. 43 | @param string The CFString to copy into the new JSString. 44 | @result A JSString containing string. Ownership follows the Create Rule. 45 | */ 46 | JS_EXPORT JSStringRef JSStringCreateWithCFString(CFStringRef string); 47 | /*! 48 | @function 49 | @abstract Creates a CFString from a JavaScript string. 50 | @param alloc The alloc parameter to pass to CFStringCreate. 51 | @param string The JSString to copy into the new CFString. 52 | @result A CFString containing string. Ownership follows the Create Rule. 53 | */ 54 | JS_EXPORT CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* JSStringRefCF_h */ 61 | -------------------------------------------------------------------------------- /lib/JSValueRef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JSValueRef_h 27 | #define JSValueRef_h 28 | 29 | #include 30 | #include 31 | 32 | #ifndef __cplusplus 33 | #include 34 | #endif 35 | 36 | /*! 37 | @enum JSType 38 | @abstract A constant identifying the type of a JSValue. 39 | @constant kJSTypeUndefined The unique undefined value. 40 | @constant kJSTypeNull The unique null value. 41 | @constant kJSTypeBoolean A primitive boolean value, one of true or false. 42 | @constant kJSTypeNumber A primitive number value. 43 | @constant kJSTypeString A primitive string value. 44 | @constant kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef). 45 | */ 46 | typedef enum { 47 | kJSTypeUndefined, 48 | kJSTypeNull, 49 | kJSTypeBoolean, 50 | kJSTypeNumber, 51 | kJSTypeString, 52 | kJSTypeObject 53 | } JSType; 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | /*! 60 | @function 61 | @abstract Returns a JavaScript value's type. 62 | @param ctx The execution context to use. 63 | @param value The JSValue whose type you want to obtain. 64 | @result A value of type JSType that identifies value's type. 65 | */ 66 | JS_EXPORT JSType JSValueGetType(JSContextRef ctx, JSValueRef value); 67 | 68 | /*! 69 | @function 70 | @abstract Tests whether a JavaScript value's type is the undefined type. 71 | @param ctx The execution context to use. 72 | @param value The JSValue to test. 73 | @result true if value's type is the undefined type, otherwise false. 74 | */ 75 | JS_EXPORT bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value); 76 | 77 | /*! 78 | @function 79 | @abstract Tests whether a JavaScript value's type is the null type. 80 | @param ctx The execution context to use. 81 | @param value The JSValue to test. 82 | @result true if value's type is the null type, otherwise false. 83 | */ 84 | JS_EXPORT bool JSValueIsNull(JSContextRef ctx, JSValueRef value); 85 | 86 | /*! 87 | @function 88 | @abstract Tests whether a JavaScript value's type is the boolean type. 89 | @param ctx The execution context to use. 90 | @param value The JSValue to test. 91 | @result true if value's type is the boolean type, otherwise false. 92 | */ 93 | JS_EXPORT bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value); 94 | 95 | /*! 96 | @function 97 | @abstract Tests whether a JavaScript value's type is the number type. 98 | @param ctx The execution context to use. 99 | @param value The JSValue to test. 100 | @result true if value's type is the number type, otherwise false. 101 | */ 102 | JS_EXPORT bool JSValueIsNumber(JSContextRef ctx, JSValueRef value); 103 | 104 | /*! 105 | @function 106 | @abstract Tests whether a JavaScript value's type is the string type. 107 | @param ctx The execution context to use. 108 | @param value The JSValue to test. 109 | @result true if value's type is the string type, otherwise false. 110 | */ 111 | JS_EXPORT bool JSValueIsString(JSContextRef ctx, JSValueRef value); 112 | 113 | /*! 114 | @function 115 | @abstract Tests whether a JavaScript value's type is the object type. 116 | @param ctx The execution context to use. 117 | @param value The JSValue to test. 118 | @result true if value's type is the object type, otherwise false. 119 | */ 120 | JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value); 121 | 122 | /*! 123 | @function 124 | @abstract Tests whether a JavaScript value is an object with a given class in its class chain. 125 | @param ctx The execution context to use. 126 | @param value The JSValue to test. 127 | @param jsClass The JSClass to test against. 128 | @result true if value is an object and has jsClass in its class chain, otherwise false. 129 | */ 130 | JS_EXPORT bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass); 131 | 132 | /* Comparing values */ 133 | 134 | /*! 135 | @function 136 | @abstract Tests whether two JavaScript values are equal, as compared by the JS == operator. 137 | @param ctx The execution context to use. 138 | @param a The first value to test. 139 | @param b The second value to test. 140 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 141 | @result true if the two values are equal, false if they are not equal or an exception is thrown. 142 | */ 143 | JS_EXPORT bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception); 144 | 145 | /*! 146 | @function 147 | @abstract Tests whether two JavaScript values are strict equal, as compared by the JS === operator. 148 | @param ctx The execution context to use. 149 | @param a The first value to test. 150 | @param b The second value to test. 151 | @result true if the two values are strict equal, otherwise false. 152 | */ 153 | JS_EXPORT bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b); 154 | 155 | /*! 156 | @function 157 | @abstract Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator. 158 | @param ctx The execution context to use. 159 | @param value The JSValue to test. 160 | @param constructor The constructor to test against. 161 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 162 | @result true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false. 163 | */ 164 | JS_EXPORT bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception); 165 | 166 | /* Creating values */ 167 | 168 | /*! 169 | @function 170 | @abstract Creates a JavaScript value of the undefined type. 171 | @param ctx The execution context to use. 172 | @result The unique undefined value. 173 | */ 174 | JS_EXPORT JSValueRef JSValueMakeUndefined(JSContextRef ctx); 175 | 176 | /*! 177 | @function 178 | @abstract Creates a JavaScript value of the null type. 179 | @param ctx The execution context to use. 180 | @result The unique null value. 181 | */ 182 | JS_EXPORT JSValueRef JSValueMakeNull(JSContextRef ctx); 183 | 184 | /*! 185 | @function 186 | @abstract Creates a JavaScript value of the boolean type. 187 | @param ctx The execution context to use. 188 | @param boolean The bool to assign to the newly created JSValue. 189 | @result A JSValue of the boolean type, representing the value of boolean. 190 | */ 191 | JS_EXPORT JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool boolean); 192 | 193 | /*! 194 | @function 195 | @abstract Creates a JavaScript value of the number type. 196 | @param ctx The execution context to use. 197 | @param number The double to assign to the newly created JSValue. 198 | @result A JSValue of the number type, representing the value of number. 199 | */ 200 | JS_EXPORT JSValueRef JSValueMakeNumber(JSContextRef ctx, double number); 201 | 202 | /*! 203 | @function 204 | @abstract Creates a JavaScript value of the string type. 205 | @param ctx The execution context to use. 206 | @param string The JSString to assign to the newly created JSValue. The 207 | newly created JSValue retains string, and releases it upon garbage collection. 208 | @result A JSValue of the string type, representing the value of string. 209 | */ 210 | JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string); 211 | 212 | /* Converting to and from JSON formatted strings */ 213 | 214 | /*! 215 | @function 216 | @abstract Creates a JavaScript value from a JSON formatted string. 217 | @param ctx The execution context to use. 218 | @param string The JSString containing the JSON string to be parsed. 219 | @result A JSValue containing the parsed value, or NULL if the input is invalid. 220 | */ 221 | JS_EXPORT JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) AVAILABLE_AFTER_WEBKIT_VERSION_4_0; 222 | 223 | /*! 224 | @function 225 | @abstract Creates a JavaScript string containing the JSON serialized representation of a JS value. 226 | @param ctx The execution context to use. 227 | @param value The value to serialize. 228 | @param indent The number of spaces to indent when nesting. If 0, the resulting JSON will not contains newlines. The size of the indent is clamped to 10 spaces. 229 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 230 | @result A JSString with the result of serialization, or NULL if an exception is thrown. 231 | */ 232 | JS_EXPORT JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef value, unsigned indent, JSValueRef* exception) AVAILABLE_AFTER_WEBKIT_VERSION_4_0; 233 | 234 | /* Converting to primitive values */ 235 | 236 | /*! 237 | @function 238 | @abstract Converts a JavaScript value to boolean and returns the resulting boolean. 239 | @param ctx The execution context to use. 240 | @param value The JSValue to convert. 241 | @result The boolean result of conversion. 242 | */ 243 | JS_EXPORT bool JSValueToBoolean(JSContextRef ctx, JSValueRef value); 244 | 245 | /*! 246 | @function 247 | @abstract Converts a JavaScript value to number and returns the resulting number. 248 | @param ctx The execution context to use. 249 | @param value The JSValue to convert. 250 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 251 | @result The numeric result of conversion, or NaN if an exception is thrown. 252 | */ 253 | JS_EXPORT double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception); 254 | 255 | /*! 256 | @function 257 | @abstract Converts a JavaScript value to string and copies the result into a JavaScript string. 258 | @param ctx The execution context to use. 259 | @param value The JSValue to convert. 260 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 261 | @result A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule. 262 | */ 263 | JS_EXPORT JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception); 264 | 265 | /*! 266 | @function 267 | @abstract Converts a JavaScript value to object and returns the resulting object. 268 | @param ctx The execution context to use. 269 | @param value The JSValue to convert. 270 | @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. 271 | @result The JSObject result of conversion, or NULL if an exception is thrown. 272 | */ 273 | JS_EXPORT JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception); 274 | 275 | /* Garbage collection */ 276 | /*! 277 | @function 278 | @abstract Protects a JavaScript value from garbage collection. 279 | @param ctx The execution context to use. 280 | @param value The JSValue to protect. 281 | @discussion Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it. 282 | 283 | A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection. 284 | */ 285 | JS_EXPORT void JSValueProtect(JSContextRef ctx, JSValueRef value); 286 | 287 | /*! 288 | @function 289 | @abstract Unprotects a JavaScript value from garbage collection. 290 | @param ctx The execution context to use. 291 | @param value The JSValue to unprotect. 292 | @discussion A value may be protected multiple times and must be unprotected an 293 | equal number of times before becoming eligible for garbage collection. 294 | */ 295 | JS_EXPORT void JSValueUnprotect(JSContextRef ctx, JSValueRef value); 296 | 297 | #ifdef __cplusplus 298 | } 299 | #endif 300 | 301 | #endif /* JSValueRef_h */ 302 | -------------------------------------------------------------------------------- /lib/JavaScript.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Apple Inc. All rights reserved. 3 | * Copyright (C) 2008 Alp Toker 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef JavaScript_h 28 | #define JavaScript_h 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #endif /* JavaScript_h */ 37 | -------------------------------------------------------------------------------- /lib/JavaScriptCore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef JavaScriptCore_h 27 | #define JavaScriptCore_h 28 | 29 | #include 30 | #include 31 | 32 | #endif /* JavaScriptCore_h */ 33 | -------------------------------------------------------------------------------- /lib/SCNEngine.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCNEngine.h 3 | // SproutCoreNative 4 | // 5 | // Created by Johannes Fahrenkrug on 18.07.11. 6 | // Copyright 2011 Springenwerk. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | @interface SCNEngine : NSObject { 14 | JSGlobalContextRef _jsContext; 15 | JSClassRef _SCNClass; 16 | } 17 | 18 | static JSValueRef __SCNLogMethod(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 19 | static JSValueRef __SCNToStringMethod(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 20 | static JSValueRef __SCNGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyNameJS, JSValueRef* exception); 21 | 22 | 23 | - (JSGlobalContextRef) jsContext; 24 | - (NSString *)runJS:(NSString *)aJSString; 25 | - (void)loadJSLibrary:(NSString*)libraryName; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /lib/SCNEngine.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCNEngine.m 3 | // SproutCoreNative 4 | // 5 | // Created by Johannes Fahrenkrug on 18.07.11. 6 | // Copyright 2011 Springenwerk. All rights reserved. 7 | // 8 | 9 | #import "SCNEngine.h" 10 | 11 | 12 | @implementation SCNEngine 13 | 14 | - (JSGlobalContextRef)jsContext 15 | { 16 | if (_jsContext == NULL) { 17 | _jsContext = JSGlobalContextCreate(NULL); 18 | 19 | JSClassDefinition jsClass = kJSClassDefinitionEmpty; 20 | jsClass.getProperty = __SCNGetProperty; 21 | _SCNClass = JSClassCreate(&jsClass); 22 | 23 | JSObjectRef global = JSContextGetGlobalObject(_jsContext); 24 | JSObjectRef obj = JSObjectMake(_jsContext, _SCNClass, nil); 25 | JSStringRef property = JSStringCreateWithUTF8CString([@"SCN" UTF8String]); 26 | JSValueRef exception = NULL; 27 | JSObjectSetProperty(_jsContext, global, property, (JSValueRef)obj, kJSPropertyAttributeDontDelete, &exception); 28 | } 29 | 30 | return _jsContext; 31 | } 32 | 33 | /** 34 | Runs a string of JS in this instance's JS context and returns the result as a string 35 | */ 36 | - (NSString *)runJS:(NSString *)aJSString 37 | { 38 | if (!aJSString) { 39 | NSLog(@"[SCN] JS String is empty!"); 40 | return nil; 41 | } 42 | 43 | JSStringRef scriptJS = JSStringCreateWithUTF8CString([aJSString UTF8String]); 44 | JSValueRef exception = NULL; 45 | 46 | JSValueRef result = JSEvaluateScript([self jsContext], scriptJS, NULL, NULL, 0, &exception); 47 | NSString *res = nil; 48 | 49 | if (!result) { 50 | if (exception) { 51 | JSStringRef exceptionArg = JSValueToStringCopy([self jsContext], exception, NULL); 52 | NSString* exceptionRes = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, exceptionArg); 53 | 54 | JSStringRelease(exceptionArg); 55 | NSLog(@"[SCN] JavaScript exception: %@", exceptionRes); 56 | } 57 | 58 | NSLog(@"[SCN] No result returned"); 59 | } else { 60 | JSStringRef jstrArg = JSValueToStringCopy([self jsContext], result, NULL); 61 | res = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, jstrArg); 62 | 63 | JSStringRelease(jstrArg); 64 | } 65 | 66 | JSStringRelease(scriptJS); 67 | 68 | return res; 69 | } 70 | 71 | /** 72 | Loads a JS library file from the app's bundle (without the .js extension) 73 | */ 74 | - (void)loadJSLibrary:(NSString*)libraryName { 75 | NSString *library = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:libraryName ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]; 76 | 77 | NSLog(@"[SCN] loading library %@...", libraryName); 78 | [self runJS:library]; 79 | } 80 | 81 | #pragma mark - 82 | #pragma mark C Functions for JSC 83 | 84 | /** 85 | The native console.log method 86 | */ 87 | static JSValueRef __SCNLogMethod(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 88 | { 89 | JSValueRef excp = NULL; 90 | if(argumentCount > 0) { 91 | NSLog(@"[SCN] JS LOG: %@", 92 | (NSString*)JSStringCopyCFString(kCFAllocatorDefault, (JSStringRef)JSValueToStringCopy(ctx, arguments[0], &excp))); 93 | } 94 | 95 | return JSValueMakeNull(ctx); 96 | } 97 | 98 | /** 99 | The native toString method for the SCN JS Object 100 | */ 101 | static JSValueRef __SCNToStringMethod(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 102 | { 103 | return JSValueMakeString(ctx, JSStringCreateWithUTF8CString([@"The SproutCoreNative object." UTF8String])); 104 | } 105 | 106 | /** 107 | The function that is called when any property is requested on the SCN JS object 108 | */ 109 | static JSValueRef __SCNGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyNameJS, JSValueRef* exception) { 110 | NSString *propertyName = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, propertyNameJS); 111 | if([propertyName isEqualToString:@"log"]) { 112 | return JSObjectMakeFunctionWithCallback(ctx, propertyNameJS, __SCNLogMethod); 113 | } else if ([propertyName isEqualToString:@"toString"]) { 114 | return JSObjectMakeFunctionWithCallback(ctx, propertyNameJS, __SCNToStringMethod); 115 | } 116 | NSLog(@"[SCN] undefined property %@", propertyName); 117 | return JSValueMakeNull(ctx); 118 | } 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /lib/WebKitAvailability.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008, 2009, 2010 Apple Inc. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef __WebKitAvailability__ 27 | #define __WebKitAvailability__ 28 | 29 | /* The structure of this header is based on AvailabilityMacros.h. The major difference is that the availability 30 | macros are defined in terms of WebKit version numbers rather than Mac OS X system version numbers, as WebKit 31 | releases span multiple versions of Mac OS X. 32 | */ 33 | 34 | #define WEBKIT_VERSION_1_0 0x0100 35 | #define WEBKIT_VERSION_1_1 0x0110 36 | #define WEBKIT_VERSION_1_2 0x0120 37 | #define WEBKIT_VERSION_1_3 0x0130 38 | #define WEBKIT_VERSION_2_0 0x0200 39 | #define WEBKIT_VERSION_3_0 0x0300 40 | #define WEBKIT_VERSION_3_1 0x0310 41 | #define WEBKIT_VERSION_4_0 0x0400 42 | #define WEBKIT_VERSION_LATEST 0x9999 43 | 44 | #ifdef __APPLE__ 45 | #include 46 | #else 47 | /* 48 | * For non-Mac platforms, require the newest version. 49 | */ 50 | #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_LATEST 51 | /* 52 | * only certain compilers support __attribute__((deprecated)) 53 | */ 54 | #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) 55 | #define DEPRECATED_ATTRIBUTE __attribute__((deprecated)) 56 | #else 57 | #define DEPRECATED_ATTRIBUTE 58 | #endif 59 | #endif 60 | 61 | /* The versions of GCC that shipped with Xcode prior to 3.0 (GCC build number < 5400) did not support attributes on methods. 62 | If we are building with one of these versions, we need to omit the attribute. We achieve this by wrapping the annotation 63 | in WEBKIT_OBJC_METHOD_ANNOTATION, which will remove the annotation when an old version of GCC is in use and will otherwise 64 | expand to the annotation. The same is needed for protocol methods. 65 | */ 66 | #if defined(__APPLE_CC__) && __APPLE_CC__ < 5400 67 | #define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) 68 | #else 69 | #define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION 70 | #endif 71 | 72 | 73 | /* If minimum WebKit version is not specified, assume the version that shipped with the target Mac OS X version */ 74 | #ifndef WEBKIT_VERSION_MIN_REQUIRED 75 | #if !defined(MAC_OS_X_VERSION_10_2) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2 76 | #error WebKit was not available prior to Mac OS X 10.2 77 | #elif !defined(MAC_OS_X_VERSION_10_3) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 78 | /* WebKit 1.0 is the only version available on Mac OS X 10.2. */ 79 | #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_1_0 80 | #elif !defined(MAC_OS_X_VERSION_10_4) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4 81 | /* WebKit 1.1 is the version that shipped on Mac OS X 10.3. */ 82 | #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_1_1 83 | #elif !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 84 | /* WebKit 2.0 is the version that shipped on Mac OS X 10.4. */ 85 | #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_2_0 86 | #elif !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 87 | /* WebKit 3.0 is the version that shipped on Mac OS X 10.5. */ 88 | #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_3_0 89 | #elif !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 90 | /* WebKit 4.0 is the version that shipped on Mac OS X 10.6. */ 91 | #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_4_0 92 | #else 93 | #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_LATEST 94 | #endif 95 | #endif 96 | 97 | 98 | /* If maximum WebKit version is not specified, assume largerof(latest, minimum) */ 99 | #ifndef WEBKIT_VERSION_MAX_ALLOWED 100 | #if WEBKIT_VERSION_MIN_REQUIRED > WEBKIT_VERSION_LATEST 101 | #define WEBKIT_VERSION_MAX_ALLOWED WEBKIT_VERSION_MIN_REQUIRED 102 | #else 103 | #define WEBKIT_VERSION_MAX_ALLOWED WEBKIT_VERSION_LATEST 104 | #endif 105 | #endif 106 | 107 | 108 | /* Sanity check the configured values */ 109 | #if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_MIN_REQUIRED 110 | #error WEBKIT_VERSION_MAX_ALLOWED must be >= WEBKIT_VERSION_MIN_REQUIRED 111 | #endif 112 | #if WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_0 113 | #error WEBKIT_VERSION_MIN_REQUIRED must be >= WEBKIT_VERSION_1_0 114 | #endif 115 | 116 | 117 | 118 | 119 | 120 | 121 | /* 122 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 123 | * 124 | * Used on functions introduced in WebKit 1.0 125 | */ 126 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 127 | 128 | /* 129 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED 130 | * 131 | * Used on functions introduced in WebKit 1.0, 132 | * and deprecated in WebKit 1.0 133 | */ 134 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE 135 | 136 | /* 137 | * DEPRECATED_IN_WEBKIT_VERSION_1_0_AND_LATER 138 | * 139 | * Used on types deprecated in WebKit 1.0 140 | */ 141 | #define DEPRECATED_IN_WEBKIT_VERSION_1_0_AND_LATER DEPRECATED_ATTRIBUTE 142 | 143 | 144 | 145 | 146 | 147 | 148 | /* 149 | * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 150 | * 151 | * Used on declarations introduced in WebKit 1.1 152 | */ 153 | #if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_1_1 154 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER UNAVAILABLE_ATTRIBUTE 155 | #elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_1 156 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER WEAK_IMPORT_ATTRIBUTE 157 | #else 158 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 159 | #endif 160 | 161 | /* 162 | * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED 163 | * 164 | * Used on declarations introduced in WebKit 1.1, 165 | * and deprecated in WebKit 1.1 166 | */ 167 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_1 168 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE 169 | #else 170 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 171 | #endif 172 | 173 | /* 174 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_1 175 | * 176 | * Used on declarations introduced in WebKit 1.0, 177 | * but later deprecated in WebKit 1.1 178 | */ 179 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_1 180 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_1 DEPRECATED_ATTRIBUTE 181 | #else 182 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_1 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 183 | #endif 184 | 185 | /* 186 | * DEPRECATED_IN_WEBKIT_VERSION_1_1_AND_LATER 187 | * 188 | * Used on types deprecated in WebKit 1.1 189 | */ 190 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_1 191 | #define DEPRECATED_IN_WEBKIT_VERSION_1_1_AND_LATER DEPRECATED_ATTRIBUTE 192 | #else 193 | #define DEPRECATED_IN_WEBKIT_VERSION_1_1_AND_LATER 194 | #endif 195 | 196 | 197 | 198 | 199 | 200 | 201 | /* 202 | * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER 203 | * 204 | * Used on declarations introduced in WebKit 1.2 205 | */ 206 | #if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_1_2 207 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER UNAVAILABLE_ATTRIBUTE 208 | #elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_2 209 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER WEAK_IMPORT_ATTRIBUTE 210 | #else 211 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER 212 | #endif 213 | 214 | /* 215 | * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED 216 | * 217 | * Used on declarations introduced in WebKit 1.2, 218 | * and deprecated in WebKit 1.2 219 | */ 220 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 221 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE 222 | #else 223 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER 224 | #endif 225 | 226 | /* 227 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 228 | * 229 | * Used on declarations introduced in WebKit 1.0, 230 | * but later deprecated in WebKit 1.2 231 | */ 232 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 233 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 DEPRECATED_ATTRIBUTE 234 | #else 235 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 236 | #endif 237 | 238 | /* 239 | * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 240 | * 241 | * Used on declarations introduced in WebKit 1.1, 242 | * but later deprecated in WebKit 1.2 243 | */ 244 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 245 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 DEPRECATED_ATTRIBUTE 246 | #else 247 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 248 | #endif 249 | 250 | /* 251 | * DEPRECATED_IN_WEBKIT_VERSION_1_2_AND_LATER 252 | * 253 | * Used on types deprecated in WebKit 1.2 254 | */ 255 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 256 | #define DEPRECATED_IN_WEBKIT_VERSION_1_2_AND_LATER DEPRECATED_ATTRIBUTE 257 | #else 258 | #define DEPRECATED_IN_WEBKIT_VERSION_1_2_AND_LATER 259 | #endif 260 | 261 | 262 | 263 | 264 | 265 | 266 | /* 267 | * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER 268 | * 269 | * Used on declarations introduced in WebKit 1.3 270 | */ 271 | #if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_1_3 272 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER UNAVAILABLE_ATTRIBUTE 273 | #elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_3 274 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER WEAK_IMPORT_ATTRIBUTE 275 | #else 276 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER 277 | #endif 278 | 279 | /* 280 | * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED 281 | * 282 | * Used on declarations introduced in WebKit 1.3, 283 | * and deprecated in WebKit 1.3 284 | */ 285 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 286 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE 287 | #else 288 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER 289 | #endif 290 | 291 | /* 292 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 293 | * 294 | * Used on declarations introduced in WebKit 1.0, 295 | * but later deprecated in WebKit 1.3 296 | */ 297 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 298 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 DEPRECATED_ATTRIBUTE 299 | #else 300 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 301 | #endif 302 | 303 | /* 304 | * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 305 | * 306 | * Used on declarations introduced in WebKit 1.1, 307 | * but later deprecated in WebKit 1.3 308 | */ 309 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 310 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 DEPRECATED_ATTRIBUTE 311 | #else 312 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 313 | #endif 314 | 315 | /* 316 | * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 317 | * 318 | * Used on declarations introduced in WebKit 1.2, 319 | * but later deprecated in WebKit 1.3 320 | */ 321 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 322 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 DEPRECATED_ATTRIBUTE 323 | #else 324 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER 325 | #endif 326 | 327 | /* 328 | * DEPRECATED_IN_WEBKIT_VERSION_1_3_AND_LATER 329 | * 330 | * Used on types deprecated in WebKit 1.3 331 | */ 332 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 333 | #define DEPRECATED_IN_WEBKIT_VERSION_1_3_AND_LATER DEPRECATED_ATTRIBUTE 334 | #else 335 | #define DEPRECATED_IN_WEBKIT_VERSION_1_3_AND_LATER 336 | #endif 337 | 338 | 339 | 340 | 341 | 342 | 343 | /* 344 | * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER 345 | * 346 | * Used on declarations introduced in WebKit 2.0 347 | */ 348 | #if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_2_0 349 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER UNAVAILABLE_ATTRIBUTE 350 | #elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_2_0 351 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER WEAK_IMPORT_ATTRIBUTE 352 | #else 353 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER 354 | #endif 355 | 356 | /* 357 | * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED 358 | * 359 | * Used on declarations introduced in WebKit 2.0, 360 | * and deprecated in WebKit 2.0 361 | */ 362 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 363 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE 364 | #else 365 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER 366 | #endif 367 | 368 | /* 369 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 370 | * 371 | * Used on declarations introduced in WebKit 1.0, 372 | * but later deprecated in WebKit 2.0 373 | */ 374 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 375 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE 376 | #else 377 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 378 | #endif 379 | 380 | /* 381 | * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 382 | * 383 | * Used on declarations introduced in WebKit 1.1, 384 | * but later deprecated in WebKit 2.0 385 | */ 386 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 387 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE 388 | #else 389 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 390 | #endif 391 | 392 | /* 393 | * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 394 | * 395 | * Used on declarations introduced in WebKit 1.2, 396 | * but later deprecated in WebKit 2.0 397 | */ 398 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 399 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE 400 | #else 401 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER 402 | #endif 403 | 404 | /* 405 | * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 406 | * 407 | * Used on declarations introduced in WebKit 1.3, 408 | * but later deprecated in WebKit 2.0 409 | */ 410 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 411 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE 412 | #else 413 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER 414 | #endif 415 | 416 | /* 417 | * DEPRECATED_IN_WEBKIT_VERSION_2_0_AND_LATER 418 | * 419 | * Used on types deprecated in WebKit 2.0 420 | */ 421 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 422 | #define DEPRECATED_IN_WEBKIT_VERSION_2_0_AND_LATER DEPRECATED_ATTRIBUTE 423 | #else 424 | #define DEPRECATED_IN_WEBKIT_VERSION_2_0_AND_LATER 425 | #endif 426 | 427 | 428 | 429 | 430 | 431 | 432 | /* 433 | * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER 434 | * 435 | * Used on declarations introduced in WebKit 3.0 436 | */ 437 | #if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_3_0 438 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER UNAVAILABLE_ATTRIBUTE 439 | #elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_3_0 440 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER WEAK_IMPORT_ATTRIBUTE 441 | #else 442 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER 443 | #endif 444 | 445 | /* 446 | * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED 447 | * 448 | * Used on declarations introduced in WebKit 3.0, 449 | * and deprecated in WebKit 3.0 450 | */ 451 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 452 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE 453 | #else 454 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER 455 | #endif 456 | 457 | /* 458 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 459 | * 460 | * Used on declarations introduced in WebKit 1.0, 461 | * but later deprecated in WebKit 3.0 462 | */ 463 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 464 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE 465 | #else 466 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 467 | #endif 468 | 469 | /* 470 | * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 471 | * 472 | * Used on declarations introduced in WebKit 1.1, 473 | * but later deprecated in WebKit 3.0 474 | */ 475 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 476 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE 477 | #else 478 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 479 | #endif 480 | 481 | /* 482 | * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 483 | * 484 | * Used on declarations introduced in WebKit 1.2, 485 | * but later deprecated in WebKit 3.0 486 | */ 487 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 488 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE 489 | #else 490 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER 491 | #endif 492 | 493 | /* 494 | * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 495 | * 496 | * Used on declarations introduced in WebKit 1.3, 497 | * but later deprecated in WebKit 3.0 498 | */ 499 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 500 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE 501 | #else 502 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER 503 | #endif 504 | 505 | /* 506 | * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 507 | * 508 | * Used on declarations introduced in WebKit 2.0, 509 | * but later deprecated in WebKit 3.0 510 | */ 511 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 512 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE 513 | #else 514 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER 515 | #endif 516 | 517 | /* 518 | * DEPRECATED_IN_WEBKIT_VERSION_3_0_AND_LATER 519 | * 520 | * Used on types deprecated in WebKit 3.0 521 | */ 522 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 523 | #define DEPRECATED_IN_WEBKIT_VERSION_3_0_AND_LATER DEPRECATED_ATTRIBUTE 524 | #else 525 | #define DEPRECATED_IN_WEBKIT_VERSION_3_0_AND_LATER 526 | #endif 527 | 528 | 529 | 530 | 531 | 532 | 533 | /* 534 | * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER 535 | * 536 | * Used on declarations introduced in WebKit 3.1 537 | */ 538 | #if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_3_1 539 | #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER UNAVAILABLE_ATTRIBUTE 540 | #elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_3_1 541 | #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER WEAK_IMPORT_ATTRIBUTE 542 | #else 543 | #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER 544 | #endif 545 | 546 | /* 547 | * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED 548 | * 549 | * Used on declarations introduced in WebKit 3.1, 550 | * and deprecated in WebKit 3.1 551 | */ 552 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 553 | #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE 554 | #else 555 | #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER 556 | #endif 557 | 558 | /* 559 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 560 | * 561 | * Used on declarations introduced in WebKit 1.0, 562 | * but later deprecated in WebKit 3.1 563 | */ 564 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 565 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE 566 | #else 567 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 568 | #endif 569 | 570 | /* 571 | * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 572 | * 573 | * Used on declarations introduced in WebKit 1.1, 574 | * but later deprecated in WebKit 3.1 575 | */ 576 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 577 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE 578 | #else 579 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 580 | #endif 581 | 582 | /* 583 | * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 584 | * 585 | * Used on declarations introduced in WebKit 1.2, 586 | * but later deprecated in WebKit 3.1 587 | */ 588 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 589 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE 590 | #else 591 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER 592 | #endif 593 | 594 | /* 595 | * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 596 | * 597 | * Used on declarations introduced in WebKit 1.3, 598 | * but later deprecated in WebKit 3.1 599 | */ 600 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 601 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE 602 | #else 603 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER 604 | #endif 605 | 606 | /* 607 | * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 608 | * 609 | * Used on declarations introduced in WebKit 2.0, 610 | * but later deprecated in WebKit 3.1 611 | */ 612 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 613 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE 614 | #else 615 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER 616 | #endif 617 | 618 | /* 619 | * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 620 | * 621 | * Used on declarations introduced in WebKit 3.0, 622 | * but later deprecated in WebKit 3.1 623 | */ 624 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 625 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE 626 | #else 627 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER 628 | #endif 629 | 630 | /* 631 | * DEPRECATED_IN_WEBKIT_VERSION_3_1_AND_LATER 632 | * 633 | * Used on types deprecated in WebKit 3.1 634 | */ 635 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 636 | #define DEPRECATED_IN_WEBKIT_VERSION_3_1_AND_LATER DEPRECATED_ATTRIBUTE 637 | #else 638 | #define DEPRECATED_IN_WEBKIT_VERSION_3_1_AND_LATER 639 | #endif 640 | 641 | 642 | 643 | 644 | 645 | 646 | /* 647 | * AVAILABLE_IN_WEBKIT_VERSION_4_0 648 | * 649 | * Used on declarations introduced in WebKit 4.0 650 | */ 651 | #if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_4_0 652 | #define AVAILABLE_IN_WEBKIT_VERSION_4_0 UNAVAILABLE_ATTRIBUTE 653 | #elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_4_0 654 | #define AVAILABLE_IN_WEBKIT_VERSION_4_0 WEAK_IMPORT_ATTRIBUTE 655 | #else 656 | #define AVAILABLE_IN_WEBKIT_VERSION_4_0 657 | #endif 658 | 659 | /* 660 | * AVAILABLE_IN_WEBKIT_VERSION_4_0_BUT_DEPRECATED 661 | * 662 | * Used on declarations introduced in WebKit 4.0, 663 | * and deprecated in WebKit 4.0 664 | */ 665 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_4_0 666 | #define AVAILABLE_IN_WEBKIT_VERSION_4_0_BUT_DEPRECATED DEPRECATED_ATTRIBUTE 667 | #else 668 | #define AVAILABLE_IN_WEBKIT_VERSION_4_0_BUT_DEPRECATED AVAILABLE_IN_WEBKIT_VERSION_4_0 669 | #endif 670 | 671 | /* 672 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 673 | * 674 | * Used on declarations introduced in WebKit 1.0, 675 | * but later deprecated in WebKit 4.0 676 | */ 677 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_4_0 678 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 679 | #else 680 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 681 | #endif 682 | 683 | /* 684 | * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 685 | * 686 | * Used on declarations introduced in WebKit 1.1, 687 | * but later deprecated in WebKit 4.0 688 | */ 689 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_4_0 690 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 691 | #else 692 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 693 | #endif 694 | 695 | /* 696 | * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 697 | * 698 | * Used on declarations introduced in WebKit 1.2, 699 | * but later deprecated in WebKit 4.0 700 | */ 701 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_4_0 702 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 703 | #else 704 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER 705 | #endif 706 | 707 | /* 708 | * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 709 | * 710 | * Used on declarations introduced in WebKit 1.3, 711 | * but later deprecated in WebKit 4.0 712 | */ 713 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_4_0 714 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 715 | #else 716 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER 717 | #endif 718 | 719 | /* 720 | * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 721 | * 722 | * Used on declarations introduced in WebKit 2.0, 723 | * but later deprecated in WebKit 4.0 724 | */ 725 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_4_0 726 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 727 | #else 728 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER 729 | #endif 730 | 731 | /* 732 | * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 733 | * 734 | * Used on declarations introduced in WebKit 3.0, 735 | * but later deprecated in WebKit 4.0 736 | */ 737 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_4_0 738 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 739 | #else 740 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER 741 | #endif 742 | 743 | /* 744 | * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 745 | * 746 | * Used on declarations introduced in WebKit 3.1, 747 | * but later deprecated in WebKit 4.0 748 | */ 749 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_4_0 750 | #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 751 | #else 752 | #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER 753 | #endif 754 | 755 | /* 756 | * DEPRECATED_IN_WEBKIT_VERSION_4_0 757 | * 758 | * Used on types deprecated in WebKit 4.0 759 | */ 760 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_4_0 761 | #define DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 762 | #else 763 | #define DEPRECATED_IN_WEBKIT_VERSION_4_0 764 | #endif 765 | 766 | 767 | 768 | 769 | 770 | 771 | /* 772 | * AVAILABLE_AFTER_WEBKIT_VERSION_4_0 773 | * 774 | * Used on declarations introduced after WebKit 4.0 775 | */ 776 | #if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_LATEST 777 | #define AVAILABLE_AFTER_WEBKIT_VERSION_4_0 UNAVAILABLE_ATTRIBUTE 778 | #elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_LATEST 779 | #define AVAILABLE_AFTER_WEBKIT_VERSION_4_0 WEAK_IMPORT_ATTRIBUTE 780 | #else 781 | #define AVAILABLE_AFTER_WEBKIT_VERSION_4_0 782 | #endif 783 | 784 | /* 785 | * AVAILABLE_AFTER_WEBKIT_VERSION_4_0_BUT_DEPRECATED 786 | * 787 | * Used on declarations introduced after WebKit 4.0, 788 | * and deprecated after WebKit 4.0 789 | */ 790 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 791 | #define AVAILABLE_AFTER_WEBKIT_VERSION_4_0_BUT_DEPRECATED DEPRECATED_ATTRIBUTE 792 | #else 793 | #define AVAILABLE_AFTER_WEBKIT_VERSION_4_0_BUT_DEPRECATED AVAILABLE_AFTER_WEBKIT_VERSION_4_0 794 | #endif 795 | 796 | /* 797 | * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 798 | * 799 | * Used on declarations introduced in WebKit 1.0, 800 | * but later deprecated after WebKit 4.0 801 | */ 802 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 803 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 804 | #else 805 | #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER 806 | #endif 807 | 808 | /* 809 | * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 810 | * 811 | * Used on declarations introduced in WebKit 1.1, 812 | * but later deprecated after WebKit 4.0 813 | */ 814 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 815 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 816 | #else 817 | #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER 818 | #endif 819 | 820 | /* 821 | * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 822 | * 823 | * Used on declarations introduced in WebKit 1.2, 824 | * but later deprecated after WebKit 4.0 825 | */ 826 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 827 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 828 | #else 829 | #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER 830 | #endif 831 | 832 | /* 833 | * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 834 | * 835 | * Used on declarations introduced in WebKit 1.3, 836 | * but later deprecated after WebKit 4.0 837 | */ 838 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 839 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 840 | #else 841 | #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER 842 | #endif 843 | 844 | /* 845 | * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 846 | * 847 | * Used on declarations introduced in WebKit 2.0, 848 | * but later deprecated after WebKit 4.0 849 | */ 850 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 851 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 852 | #else 853 | #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER 854 | #endif 855 | 856 | /* 857 | * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 858 | * 859 | * Used on declarations introduced in WebKit 3.0, 860 | * but later deprecated after WebKit 4.0 861 | */ 862 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 863 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 864 | #else 865 | #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER 866 | #endif 867 | 868 | /* 869 | * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 870 | * 871 | * Used on declarations introduced in WebKit 3.1, 872 | * but later deprecated after WebKit 4.0 873 | */ 874 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 875 | #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 876 | #else 877 | #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER 878 | #endif 879 | 880 | /* 881 | * AVAILABLE_WEBKIT_VERSION_4_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 882 | * 883 | * Used on declarations introduced in WebKit 4.0 884 | * but later deprecated after WebKit 4.0 885 | */ 886 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 887 | #define AVAILABLE_WEBKIT_VERSION_4_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 888 | #else 889 | #define AVAILABLE_WEBKIT_VERSION_4_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_4_0_AND_LATER 890 | #endif 891 | 892 | /* 893 | * DEPRECATED_AFTER_WEBKIT_VERSION_4_0 894 | * 895 | * Used on types deprecated after WebKit 4.0 896 | */ 897 | #if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST 898 | #define DEPRECATED_AFTER_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE 899 | #else 900 | #define DEPRECATED_AFTER_WEBKIT_VERSION_4_0 901 | #endif 902 | 903 | 904 | #endif /* __WebKitAvailability__ */ 905 | -------------------------------------------------------------------------------- /libiOSJavaScriptCore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LemonCake/JsCoreEngineiOS/3df463091980acdf7b482654b559bbd33b0068c4/libiOSJavaScriptCore.a --------------------------------------------------------------------------------