Changeset 15096 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
Jun 29, 2006, 4:32:47 PM (19 years ago)
Author:
mjs
Message:

Reviewed by Geoff.


  • add headerdoc comments to some of the new JS API headers
  • API/JSBase.h:
  • API/JSValueRef.h:
Location:
trunk/JavaScriptCore/API
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSBase.h

    r14951 r15096  
    4545// Returns true for successful execution, false for uncaught exception.
    4646// 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*/
    4758bool 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*/
    4868bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script);
    4969
    5070// 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*/
    5177void 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*/
    5285void 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*/
    5396void JSGCCollect(void);
    5497
  • trunk/JavaScriptCore/API/JSValueRef.h

    r14951 r15096  
    3030#include "JSBase.h"
    3131
    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*/
    3342typedef enum {
    3443    kJSTypeUndefined,
     
    4453#endif
    4554
     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*/
    4661JSTypeCode JSValueGetType(JSValueRef value);
    4762
     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*/
    4869bool 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*/
    4977bool 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*/
    5085bool 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*/
    5193bool 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*/
    52101bool 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*/
    53109bool JSValueIsObject(JSValueRef value);
    54110
    55111// 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*/
    56121bool 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*/
    57131bool 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*/
    58142bool JSValueIsInstanceOf(JSValueRef value, JSObjectRef object);
    59143
    60144// Creating values
     145
     146/*!
     147  @function JSUndefinedMake
     148  Make a value of the undefined type.
     149  @result The unique undefined value.
     150*/
    61151JSValueRef JSUndefinedMake(void);
     152
     153/*!
     154  @function JSNullMake
     155  Make a value of the null type.
     156  @result the unique null value
     157*/
    62158JSValueRef 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
    63167JSValueRef 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*/
    64175JSValueRef 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*/
    65183JSValueRef JSStringMake(JSCharBufferRef buffer);
    66184
    67185// 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*/
    68194bool 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*/
     203double 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*/
     212JSCharBufferRef 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*/
     221JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value);
    72222
    73223#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.