]>
Commit | Line | Data |
---|---|---|
4e4e5a6f A |
1 | /* |
2 | * Copyright (C) 2010 Apple 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 INC. AND ITS CONTRIBUTORS ``AS IS'' | |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
23 | * THE POSSIBILITY OF SUCH DAMAGE. | |
24 | */ | |
25 | ||
26 | #ifndef JSObjectRefPrivate_h | |
27 | #define JSObjectRefPrivate_h | |
28 | ||
29 | #include <JavaScriptCore/JSObjectRef.h> | |
30 | ||
31 | #ifdef __cplusplus | |
32 | extern "C" { | |
33 | #endif | |
34 | ||
35 | /*! | |
36 | @function | |
37 | @abstract Sets a private property on an object. This private property cannot be accessed from within JavaScript. | |
38 | @param ctx The execution context to use. | |
39 | @param object The JSObject whose private property you want to set. | |
40 | @param propertyName A JSString containing the property's name. | |
41 | @param value A JSValue to use as the property's value. This may be NULL. | |
42 | @result true if object can store private data, otherwise false. | |
43 | @discussion This API allows you to store JS values directly an object in a way that will be ensure that they are kept alive without exposing them to JavaScript code and without introducing the reference cycles that may occur when using JSValueProtect. | |
44 | ||
45 | The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private properties. | |
46 | */ | |
47 | JS_EXPORT bool JSObjectSetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value); | |
48 | ||
49 | /*! | |
50 | @function | |
51 | @abstract Gets a private property from an object. | |
52 | @param ctx The execution context to use. | |
53 | @param object The JSObject whose private property you want to get. | |
54 | @param propertyName A JSString containing the property's name. | |
55 | @result The property's value if object has the property, otherwise NULL. | |
56 | */ | |
57 | JS_EXPORT JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); | |
58 | ||
59 | /*! | |
60 | @function | |
61 | @abstract Deletes a private property from an object. | |
62 | @param ctx The execution context to use. | |
63 | @param object The JSObject whose private property you want to delete. | |
64 | @param propertyName A JSString containing the property's name. | |
65 | @result true if object can store private data, otherwise false. | |
66 | @discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data. | |
67 | */ | |
68 | JS_EXPORT bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); | |
69 | ||
70 | #ifdef __cplusplus | |
71 | } | |
72 | #endif | |
73 | ||
74 | #endif // JSObjectRefPrivate_h |