Changeset 15096 in webkit for trunk/JavaScriptCore/API
- Timestamp:
- Jun 29, 2006, 4:32:47 PM (19 years ago)
- Location:
- trunk/JavaScriptCore/API
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.h
r14951 r15096 45 45 // Returns true for successful execution, false for uncaught exception. 46 46 // returnValue will contain value of last evaluated statement or exception value. 47 /*! 48 @function JSEvaluate 49 Evaluates a string of JavaScript code 50 @param context execution context to use 51 @param thisValue object to use as the "this" value, or NULL to use the global object as "this" 52 @param script a string containing the script source code 53 @param sourceURL URL to the file containing the source, or NULL - this is only used for error reporting 54 @param startingLineNumber starting line number in the source at sourceURL - this is only used for error reporting 55 @param returnValue result of evaluation if successful, or value of exception 56 @result true if evaluation succeeded, false if an uncaught exception or error occured 57 */ 47 58 bool JSEvaluate(JSContextRef context, JSValueRef thisValue, JSCharBufferRef script, JSCharBufferRef sourceURL, int startingLineNumber, JSValueRef* returnValue); 59 60 /*! 61 @function JSCheckSyntax 62 Checks for syntax errors in a string of JavaScript code 63 @param context execution context to use 64 @param script a string containing the script source code 65 @result true if the script is syntactically correct, false otherwise 66 67 */ 48 68 bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script); 49 69 50 70 // Garbage collection 71 /*! 72 @function JSGCProtect 73 Protect a JavaScript value from garbage collection; a value may be 74 protected multiple times and must be unprotected an equal number of 75 times to become collectable again. 76 */ 51 77 void JSGCProtect(JSValueRef value); 78 79 /*! 80 @function JSGCProtect 81 Stop protecting a JavaScript value from garbage collection; a value may be 82 protected multiple times and must be unprotected an equal number of 83 times to become collectable again. 84 */ 52 85 void JSGCUnprotect(JSValueRef value); 86 87 /*! 88 @function JSGCCollect 89 Immediately perform a JavaScript garbage collection. JavaScript 90 values that are on the machine stack, in a register, protected, set 91 as the global object of any interpreter, or reachable from any such 92 value will not be collected. It is not normally necessary to call 93 this function directly; the JS runtime will garbage collect as 94 needed. 95 */ 53 96 void JSGCCollect(void); 54 97 -
trunk/JavaScriptCore/API/JSValueRef.h
r14951 r15096 30 30 #include "JSBase.h" 31 31 32 // Value types 32 /*! 33 @enum JSTypeCode 34 A constant identifying the type of a particular JSValueRef. 35 @constant kJSTypeUndefined the unique undefined value 36 @constant kJSTypeNull the unique null value 37 @constant kJSBoolean a primitive boolean value, one of true or false 38 @constant kJSTypeNumber a primitive number value 39 @constant kJSTypeString a primitive string value 40 @constant kJSTypeObject an object (meaning this JSValueRef is a JSObjectRef 41 */ 33 42 typedef enum { 34 43 kJSTypeUndefined, … … 44 53 #endif 45 54 55 /*! 56 @function JSValueGetType 57 Get the type code for a particular JavaScript value 58 @param value the JS value for which the type should be determined 59 @result a type code identifying the type 60 */ 46 61 JSTypeCode JSValueGetType(JSValueRef value); 47 62 63 /*! 64 @function JSValueIsUndefined 65 Determine if value is of type undefined 66 @param value the JS value to check for undefined type 67 @result true if the value is undefined, false otherwise 68 */ 48 69 bool JSValueIsUndefined(JSValueRef value); 70 71 /*! 72 @function JSValueIsNull 73 Determine if value is of type null 74 @param value the JS value to check for null type 75 @result true if the value is null, false otherwise 76 */ 49 77 bool JSValueIsNull(JSValueRef value); 78 79 /*! 80 @function JSValueIsBoolean 81 Determine if value is of type boolean 82 @param value the JS value to check for boolean type 83 @result true if the value is a boolean, false otherwise 84 */ 50 85 bool JSValueIsBoolean(JSValueRef value); 86 87 /*! 88 @function JSValueIsNumber 89 Determine if value is of type number 90 @param value the JS value to check for number type 91 @result true if the value is a number, false otherwise 92 */ 51 93 bool JSValueIsNumber(JSValueRef value); 94 95 /*! 96 @function JSValueIsString 97 Determine if value is of type string 98 @param value the JS value to check for string type 99 @result true if the value is a string, false otherwise 100 */ 52 101 bool JSValueIsString(JSValueRef value); 102 103 /*! 104 @function JSValueIsObject 105 Determine if value is of type object 106 @param value the JS value to check for object type 107 @result true if the value is an object, false otherwise 108 */ 53 109 bool JSValueIsObject(JSValueRef value); 54 110 55 111 // Comparing values 112 113 /*! 114 @function JSValueIsEqual 115 Check if two values are equal by JavaScript rules, as if compared by the JS == operator 116 @param context the execution context to use 117 @param a the first value to compare 118 @param b the second value to compare 119 @result true if the two values are equal, false otherwise 120 */ 56 121 bool JSValueIsEqual(JSContextRef context, JSValueRef a, JSValueRef b); 122 123 /*! 124 @function JSValueIsStrictEqual 125 Check if two values are strict equal by JavaScript rules, as if compared by the JS === operator 126 @param context the execution context to use 127 @param a the first value to compare 128 @param b the second value to compare 129 @result true if the two values are strict equal, false otherwise 130 */ 57 131 bool JSValueIsStrictEqual(JSContextRef context, JSValueRef a, JSValueRef b); 132 133 /*! 134 @function JSValueIsInstanceOf 135 Check if a value is an instance of a particular object; generally this means the object 136 was used as the constructor for that instance 137 @param context the execution context to use 138 @param value the possible instance 139 @param object the possible constructor 140 @result true if value is an instance of object 141 */ 58 142 bool JSValueIsInstanceOf(JSValueRef value, JSObjectRef object); 59 143 60 144 // Creating values 145 146 /*! 147 @function JSUndefinedMake 148 Make a value of the undefined type. 149 @result The unique undefined value. 150 */ 61 151 JSValueRef JSUndefinedMake(void); 152 153 /*! 154 @function JSNullMake 155 Make a value of the null type. 156 @result the unique null value 157 */ 62 158 JSValueRef JSNullMake(void); 159 160 /*! 161 @function JSBooleanMake 162 Make a value of the boolean type. 163 @param value whether the returned value should be true or false 164 @result a JS true or false boolean value, as appropriate 165 */ 166 63 167 JSValueRef JSBooleanMake(bool value); 168 169 /*! 170 @function JSNumberMake 171 Make a value of the number type. 172 @param value the numberic value of the number to make 173 @result a JS number corresponding to value 174 */ 64 175 JSValueRef JSNumberMake(double value); 176 177 /*! 178 @function JSStringMake 179 Make a value of the string type. 180 @param buffer the internal string contents for the string value 181 @result a JS string value that has the value of the buffer 182 */ 65 183 JSValueRef JSStringMake(JSCharBufferRef buffer); 66 184 67 185 // Converting to primitive values 186 187 /*! 188 @function JSValueToBoolean 189 Convert a JavaScript value to boolean and get the boolean value 190 @param context the execution context to use 191 @param value the value to convert to boolean 192 @result the boolean result of conversion 193 */ 68 194 bool JSValueToBoolean(JSContextRef context, JSValueRef value); 69 double JSValueToNumber(JSContextRef context, JSValueRef value); // 0.0 if conversion fails 70 JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value); // Error object if conversion fails 71 JSCharBufferRef JSValueCopyStringValue(JSContextRef context, JSValueRef value); // Empty string if conversion fails 195 196 /*! 197 @function JSValueToNumber 198 Convert a JavaScript value to number and get the numeric value 199 @param context the execution context to use 200 @param value the value to convert to number 201 @result the boolean result of conversion, or 0 on failure 202 */ 203 double JSValueToNumber(JSContextRef context, JSValueRef value); 204 205 /*! 206 @function JSValueCopyStringValue 207 Convert a JavaScript value to string and get the value as a string 208 @param context the execution context to use 209 @param value the value to convert to string 210 @result the string result of conversion, or empty string on failure 211 */ 212 JSCharBufferRef JSValueCopyStringValue(JSContextRef context, JSValueRef value); 213 214 /*! 215 @function JSValueToObject 216 Convert a JavaScript value to object and return the resulting object 217 @param context the execution context to use 218 @param value the value to convert to string 219 @result the string result of conversion, or error object on failure 220 */ 221 JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value); 72 222 73 223 #ifdef __cplusplus
Note:
See TracChangeset
for help on using the changeset viewer.