ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 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 |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #ifndef JSValueRef_h |
| 27 | #define JSValueRef_h |
| 28 | |
ggaren | e76694c | 2006-07-11 05:37:00 +0000 | [diff] [blame] | 29 | #include <JavaScriptCore/JSBase.h> |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 30 | |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 31 | #include <stdbool.h> |
| 32 | |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 33 | /*! |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 34 | @enum JSType |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 35 | @abstract A constant identifying the type of a JSValue. |
| 36 | @constant kJSTypeUndefined The unique undefined value. |
| 37 | @constant kJSTypeNull The unique null value. |
| 38 | @constant kJSTypeBoolean A primitive boolean value, one of true or false. |
| 39 | @constant kJSTypeNumber A primitive number value. |
| 40 | @constant kJSTypeString A primitive string value. |
| 41 | @constant kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef). |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 42 | */ |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 43 | typedef enum { |
| 44 | kJSTypeUndefined, |
| 45 | kJSTypeNull, |
| 46 | kJSTypeBoolean, |
| 47 | kJSTypeNumber, |
| 48 | kJSTypeString, |
| 49 | kJSTypeObject |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 50 | } JSType; |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 51 | |
| 52 | #ifdef __cplusplus |
| 53 | extern "C" { |
| 54 | #endif |
| 55 | |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 56 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 57 | @function |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 58 | @abstract Returns a JavaScript value's type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 59 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 60 | @param value The JSValue whose type you want to obtain. |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 61 | @result A value of type JSType that identifies value's type. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 62 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 63 | JS_EXPORT JSType JSValueGetType(JSContextRef ctx, JSValueRef value); |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 64 | |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 65 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 66 | @function |
| 67 | @abstract Tests whether a JavaScript value's type is the undefined type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 68 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 69 | @param value The JSValue to test. |
| 70 | @result true if value's type is the undefined type, otherwise false. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 71 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 72 | JS_EXPORT bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 73 | |
| 74 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 75 | @function |
| 76 | @abstract Tests whether a JavaScript value's type is the null type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 77 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 78 | @param value The JSValue to test. |
| 79 | @result true if value's type is the null type, otherwise false. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 80 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 81 | JS_EXPORT bool JSValueIsNull(JSContextRef ctx, JSValueRef value); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 82 | |
| 83 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 84 | @function |
| 85 | @abstract Tests whether a JavaScript value's type is the boolean type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 86 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 87 | @param value The JSValue to test. |
| 88 | @result true if value's type is the boolean type, otherwise false. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 89 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 90 | JS_EXPORT bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 91 | |
| 92 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 93 | @function |
| 94 | @abstract Tests whether a JavaScript value's type is the number type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 95 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 96 | @param value The JSValue to test. |
| 97 | @result true if value's type is the number type, otherwise false. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 98 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 99 | JS_EXPORT bool JSValueIsNumber(JSContextRef ctx, JSValueRef value); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 100 | |
| 101 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 102 | @function |
| 103 | @abstract Tests whether a JavaScript value's type is the string type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 104 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 105 | @param value The JSValue to test. |
| 106 | @result true if value's type is the string type, otherwise false. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 107 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 108 | JS_EXPORT bool JSValueIsString(JSContextRef ctx, JSValueRef value); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 109 | |
| 110 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 111 | @function |
| 112 | @abstract Tests whether a JavaScript value's type is the object type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 113 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 114 | @param value The JSValue to test. |
| 115 | @result true if value's type is the object type, otherwise false. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 116 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 117 | JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value); |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 118 | |
| 119 | /*! |
| 120 | @function |
ggaren | 0503a4b | 2006-07-18 04:33:46 +0000 | [diff] [blame] | 121 | @abstract Tests whether a JavaScript value is an object with a given class in its class chain. |
| 122 | @param ctx The execution context to use. |
| 123 | @param value The JSValue to test. |
| 124 | @param jsClass The JSClass to test against. |
| 125 | @result true if value is an object and has jsClass in its class chain, otherwise false. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 126 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 127 | JS_EXPORT bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass); |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 128 | |
christian@webkit.org | c48b89d | 2008-06-16 13:48:51 +0000 | [diff] [blame] | 129 | /* Comparing values */ |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 130 | |
| 131 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 132 | @function |
ggaren | 81d8be0 | 2006-07-13 08:56:52 +0000 | [diff] [blame] | 133 | @abstract Tests whether two JavaScript values are equal, as compared by the JS == operator. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 134 | @param ctx The execution context to use. |
ggaren | 81d8be0 | 2006-07-13 08:56:52 +0000 | [diff] [blame] | 135 | @param a The first value to test. |
| 136 | @param b The second value to test. |
| 137 | @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. |
| 138 | @result true if the two values are equal, false if they are not equal or an exception is thrown. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 139 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 140 | JS_EXPORT bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 141 | |
| 142 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 143 | @function |
| 144 | @abstract Tests whether two JavaScript values are strict equal, as compared by the JS === operator. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 145 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 146 | @param a The first value to test. |
| 147 | @param b The second value to test. |
| 148 | @result true if the two values are strict equal, otherwise false. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 149 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 150 | JS_EXPORT bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 151 | |
| 152 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 153 | @function |
ggaren | 292e70e | 2006-07-15 04:10:31 +0000 | [diff] [blame] | 154 | @abstract Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 155 | @param ctx The execution context to use. |
ggaren | 292e70e | 2006-07-15 04:10:31 +0000 | [diff] [blame] | 156 | @param value The JSValue to test. |
ggaren@apple.com | 38e1499 | 2008-01-16 05:23:06 +0000 | [diff] [blame] | 157 | @param constructor The constructor to test against. |
ggaren | 292e70e | 2006-07-15 04:10:31 +0000 | [diff] [blame] | 158 | @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. |
| 159 | @result true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 160 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 161 | JS_EXPORT bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception); |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 162 | |
christian@webkit.org | c48b89d | 2008-06-16 13:48:51 +0000 | [diff] [blame] | 163 | /* Creating values */ |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 164 | |
| 165 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 166 | @function |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 167 | @abstract Creates a JavaScript value of the undefined type. |
| 168 | @param ctx The execution context to use. |
| 169 | @result The unique undefined value. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 170 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 171 | JS_EXPORT JSValueRef JSValueMakeUndefined(JSContextRef ctx); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 172 | |
| 173 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 174 | @function |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 175 | @abstract Creates a JavaScript value of the null type. |
| 176 | @param ctx The execution context to use. |
| 177 | @result The unique null value. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 178 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 179 | JS_EXPORT JSValueRef JSValueMakeNull(JSContextRef ctx); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 180 | |
| 181 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 182 | @function |
| 183 | @abstract Creates a JavaScript value of the boolean type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 184 | @param ctx The execution context to use. |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 185 | @param boolean The bool to assign to the newly created JSValue. |
| 186 | @result A JSValue of the boolean type, representing the value of boolean. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 187 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 188 | JS_EXPORT JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool boolean); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 189 | |
| 190 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 191 | @function |
| 192 | @abstract Creates a JavaScript value of the number type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 193 | @param ctx The execution context to use. |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 194 | @param number The double to assign to the newly created JSValue. |
| 195 | @result A JSValue of the number type, representing the value of number. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 196 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 197 | JS_EXPORT JSValueRef JSValueMakeNumber(JSContextRef ctx, double number); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 198 | |
| 199 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 200 | @function |
| 201 | @abstract Creates a JavaScript value of the string type. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 202 | @param ctx The execution context to use. |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 203 | @param string The JSString to assign to the newly created JSValue. The |
ggaren | e76694c | 2006-07-11 05:37:00 +0000 | [diff] [blame] | 204 | newly created JSValue retains string, and releases it upon garbage collection. |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 205 | @result A JSValue of the string type, representing the value of string. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 206 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 207 | JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string); |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 208 | |
christian@webkit.org | c48b89d | 2008-06-16 13:48:51 +0000 | [diff] [blame] | 209 | /* Converting to primitive values */ |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 210 | |
| 211 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 212 | @function |
| 213 | @abstract Converts a JavaScript value to boolean and returns the resulting boolean. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 214 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 215 | @param value The JSValue to convert. |
ggaren | 292e70e | 2006-07-15 04:10:31 +0000 | [diff] [blame] | 216 | @result The boolean result of conversion. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 217 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 218 | JS_EXPORT bool JSValueToBoolean(JSContextRef ctx, JSValueRef value); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 219 | |
| 220 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 221 | @function |
| 222 | @abstract Converts a JavaScript value to number and returns the resulting number. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 223 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 224 | @param value The JSValue to convert. |
ggaren | 81d8be0 | 2006-07-13 08:56:52 +0000 | [diff] [blame] | 225 | @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. |
| 226 | @result The numeric result of conversion, or NaN if an exception is thrown. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 227 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 228 | JS_EXPORT double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 229 | |
| 230 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 231 | @function |
ggaren | e66ccee | 2006-07-12 08:12:08 +0000 | [diff] [blame] | 232 | @abstract Converts a JavaScript value to string and copies the result into a JavaScript string. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 233 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 234 | @param value The JSValue to convert. |
ggaren | 81d8be0 | 2006-07-13 08:56:52 +0000 | [diff] [blame] | 235 | @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. |
| 236 | @result A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 237 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 238 | JS_EXPORT JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception); |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 239 | |
| 240 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 241 | @function |
| 242 | @abstract Converts a JavaScript value to object and returns the resulting object. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 243 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 244 | @param value The JSValue to convert. |
ggaren | 81d8be0 | 2006-07-13 08:56:52 +0000 | [diff] [blame] | 245 | @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. |
ggaren | 292e70e | 2006-07-15 04:10:31 +0000 | [diff] [blame] | 246 | @result The JSObject result of conversion, or NULL if an exception is thrown. |
mjs | 1cf94d1 | 2006-06-29 23:32:47 +0000 | [diff] [blame] | 247 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 248 | JS_EXPORT JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception); |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 249 | |
christian@webkit.org | c48b89d | 2008-06-16 13:48:51 +0000 | [diff] [blame] | 250 | /* Garbage collection */ |
ggaren | 699a47c | 2006-07-05 18:07:57 +0000 | [diff] [blame] | 251 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 252 | @function |
ggaren | 0503a4b | 2006-07-18 04:33:46 +0000 | [diff] [blame] | 253 | @abstract Protects a JavaScript value from garbage collection. |
| 254 | @param ctx The execution context to use. |
| 255 | @param value The JSValue to protect. |
| 256 | @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. |
| 257 | |
| 258 | A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection. |
ggaren | 699a47c | 2006-07-05 18:07:57 +0000 | [diff] [blame] | 259 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 260 | JS_EXPORT void JSValueProtect(JSContextRef ctx, JSValueRef value); |
ggaren | 699a47c | 2006-07-05 18:07:57 +0000 | [diff] [blame] | 261 | |
| 262 | /*! |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 263 | @function |
| 264 | @abstract Unprotects a JavaScript value from garbage collection. |
mjs | 127f859 | 2006-07-17 08:14:39 +0000 | [diff] [blame] | 265 | @param ctx The execution context to use. |
ggaren | 554ad6f | 2006-07-08 02:02:47 +0000 | [diff] [blame] | 266 | @param value The JSValue to unprotect. |
| 267 | @discussion A value may be protected multiple times and must be unprotected an |
| 268 | equal number of times before becoming eligible for garbage collection. |
ggaren | 699a47c | 2006-07-05 18:07:57 +0000 | [diff] [blame] | 269 | */ |
alp@webkit.org | d8bfe3d | 2007-11-28 04:31:51 +0000 | [diff] [blame] | 270 | JS_EXPORT void JSValueUnprotect(JSContextRef ctx, JSValueRef value); |
ggaren | 699a47c | 2006-07-05 18:07:57 +0000 | [diff] [blame] | 271 | |
ggaren | 2593cdc | 2006-06-21 21:09:19 +0000 | [diff] [blame] | 272 | #ifdef __cplusplus |
| 273 | } |
| 274 | #endif |
| 275 | |
christian@webkit.org | c48b89d | 2008-06-16 13:48:51 +0000 | [diff] [blame] | 276 | #endif /* JSValueRef_h */ |