📄 jsobjectref.h
字号:
*/JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0;/*! @function @abstract Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor. @param ctx The execution context to use. @param argumentCount An integer count of the number of arguments in arguments. @param arguments A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0. @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. @result A JSObject that is a RegExp. */JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0;/*!@function@abstract Creates a function with a given script as its body.@param ctx The execution context to use.@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.@param parameterCount An integer count of the number of parameter names in parameterNames.@param parameterNames A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0.@param body A JSString containing the script to use as the function's body.@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.@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.@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.@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.@discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.*/JS_EXPORT JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);/*!@function@abstract Gets an object's prototype.@param ctx The execution context to use.@param object A JSObject whose prototype you want to get.@result A JSValue that is the object's prototype.*/JS_EXPORT JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object);/*!@function@abstract Sets an object's prototype.@param ctx The execution context to use.@param object The JSObject whose prototype you want to set.@param value A JSValue to set as the object's prototype.*/JS_EXPORT void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value);/*!@function@abstract Tests whether an object has a given property.@param object The JSObject to test.@param propertyName A JSString containing the property's name.@result true if the object has a property whose name matches propertyName, otherwise false.*/JS_EXPORT bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);/*!@function@abstract Gets a property from an object.@param ctx The execution context to use.@param object The JSObject whose property you want to get.@param propertyName A JSString containing the property's name.@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.@result The property's value if object has the property, otherwise the undefined value.*/JS_EXPORT JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);/*!@function@abstract Sets a property on an object.@param ctx The execution context to use.@param object The JSObject whose property you want to set.@param propertyName A JSString containing the property's name.@param value A JSValue to use as the property's value.@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.@param attributes A logically ORed set of JSPropertyAttributes to give to the property.*/JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception);/*!@function@abstract Deletes a property from an object.@param ctx The execution context to use.@param object The JSObject whose property you want to delete.@param propertyName A JSString containing the property's name.@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.@result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).*/JS_EXPORT bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);/*!@function@abstract Gets a property from an object by numeric index.@param ctx The execution context to use.@param object The JSObject whose property you want to get.@param propertyIndex An integer value that is the property's name.@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.@result The property's value if object has the property, otherwise the undefined value.@discussion Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties.*/JS_EXPORT JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception);/*!@function@abstract Sets a property on an object by numeric index.@param ctx The execution context to use.@param object The JSObject whose property you want to set.@param propertyIndex The property's name as a number.@param value A JSValue to use as the property's value.@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.@discussion Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties.*/JS_EXPORT void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception);/*!@function@abstract Gets an object's private data.@param object A JSObject whose private data you want to get.@result A void* that is the object's private data, if the object has private data, otherwise NULL.*/JS_EXPORT void* JSObjectGetPrivate(JSObjectRef object);/*!@function@abstract Sets a pointer to private data on an object.@param object The JSObject whose private data you want to set.@param data A void* to set as the object's private data.@result true if object can store private data, otherwise false.@discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data.*/JS_EXPORT bool JSObjectSetPrivate(JSObjectRef object, void* data);/*!@function@abstract Tests whether an object can be called as a function.@param ctx The execution context to use.@param object The JSObject to test.@result true if the object can be called as a function, otherwise false.*/JS_EXPORT bool JSObjectIsFunction(JSContextRef ctx, JSObjectRef object);/*!@function@abstract Calls an object as a function.@param ctx The execution context to use.@param object The JSObject to call as a function.@param thisObject The object to use as "this," or NULL to use the global object as "this."@param argumentCount An integer count of the number of arguments in arguments.@param arguments A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0.@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.@result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function.*/JS_EXPORT JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);/*!@function@abstract Tests whether an object can be called as a constructor.@param ctx The execution context to use.@param object The JSObject to test.@result true if the object can be called as a constructor, otherwise false.*/JS_EXPORT bool JSObjectIsConstructor(JSContextRef ctx, JSObjectRef object);/*!@function@abstract Calls an object as a constructor.@param ctx The execution context to use.@param object The JSObject to call as a constructor.@param argumentCount An integer count of the number of arguments in arguments.@param arguments A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0.@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.@result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.*/JS_EXPORT JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);/*!@function@abstract Gets the names of an object's enumerable properties.@param ctx The execution context to use.@param object The object whose property names you want to get.@result A JSPropertyNameArray containing the names object's enumerable properties. Ownership follows the Create Rule.*/JS_EXPORT JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object);/*!@function@abstract Retains a JavaScript property name array.@param array The JSPropertyNameArray to retain.@result A JSPropertyNameArray that is the same as array.*/JS_EXPORT JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array);/*!@function@abstract Releases a JavaScript property name array.@param array The JSPropetyNameArray to release.*/JS_EXPORT void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array);/*!@function@abstract Gets a count of the number of items in a JavaScript property name array.@param array The array from which to retrieve the count.@result An integer count of the number of names in array.*/JS_EXPORT size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array);/*!@function@abstract Gets a property name at a given index in a JavaScript property name array.@param array The array from which to retrieve the property name.@param index The index of the property name to retrieve.@result A JSStringRef containing the property name.*/JS_EXPORT JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index);/*!@function@abstract Adds a property name to a JavaScript property name accumulator.@param accumulator The accumulator object to which to add the property name.@param propertyName The property name to add.*/JS_EXPORT void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef accumulator, JSStringRef propertyName);#ifdef __cplusplus}#endif#endif /* JSObjectRef_h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -