1dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block/* 2dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * Copyright (C) 2010 Apple Inc. All rights reserved. 3dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * 4dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * Redistribution and use in source and binary forms, with or without 5dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * modification, are permitted provided that the following conditions 6dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * are met: 7dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * 1. Redistributions of source code must retain the above copyright 8dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * notice, this list of conditions and the following disclaimer. 9dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * 2. Redistributions in binary form must reproduce the above copyright 10dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * notice, this list of conditions and the following disclaimer in the 11dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * documentation and/or other materials provided with the distribution. 12dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * 13dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * THE POSSIBILITY OF SUCH DAMAGE. 24dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block */ 25dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 26dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#ifndef JSObjectRefPrivate_h 27dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#define JSObjectRefPrivate_h 28dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 29dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include <JavaScriptCore/JSObjectRef.h> 30dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 31dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#ifdef __cplusplus 32dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockextern "C" { 33dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#endif 34dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 35dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block/*! 36dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @function 37dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @abstract Sets a private property on an object. This private property cannot be accessed from within JavaScript. 38dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param ctx The execution context to use. 39dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param object The JSObject whose private property you want to set. 40dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param propertyName A JSString containing the property's name. 41dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param value A JSValue to use as the property's value. This may be NULL. 42dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @result true if object can store private data, otherwise false. 43dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @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. 44dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 45dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private properties. 46dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block */ 47dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve BlockJS_EXPORT bool JSObjectSetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value); 48dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 49dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block/*! 50dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @function 51dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @abstract Gets a private property from an object. 52dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param ctx The execution context to use. 53dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param object The JSObject whose private property you want to get. 54dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param propertyName A JSString containing the property's name. 55dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @result The property's value if object has the property, otherwise NULL. 56dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block */ 57dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve BlockJS_EXPORT JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 58dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 59dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block/*! 60dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @function 61dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @abstract Deletes a private property from an object. 62dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param ctx The execution context to use. 63dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param object The JSObject whose private property you want to delete. 64dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @param propertyName A JSString containing the property's name. 65dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @result true if object can store private data, otherwise false. 66dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block @discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data. 67dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block */ 68dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve BlockJS_EXPORT bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); 69dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 70dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#ifdef __cplusplus 71dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 72dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#endif 73dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 74dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#endif // JSObjectRefPrivate_h 75