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