File indexing completed on 2024-05-12 15:43:25
0001 /* 0002 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 0003 * (C) 2008 Maksim Orlovich <maksim@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 * 0020 * Portions of this code that are (C) 2007, 2008 Apple Inc. were 0021 * originally distributed under the following terms 0022 * 0023 * Redistribution and use in source and binary forms, with or without 0024 * modification, are permitted provided that the following conditions 0025 * are met: 0026 * 0027 * 1. Redistributions of source code must retain the above copyright 0028 * notice, this list of conditions and the following disclaimer. 0029 * 2. Redistributions in binary form must reproduce the above copyright 0030 * notice, this list of conditions and the following disclaimer in the 0031 * documentation and/or other materials provided with the distribution. 0032 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 0033 * its contributors may be used to endorse or promote products derived 0034 * from this software without specific prior written permission. 0035 * 0036 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 0037 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 0038 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 0039 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 0040 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 0041 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 0042 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 0043 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0044 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0045 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0046 */ 0047 #include "JSVariableObject.h" 0048 0049 #include "PropertyNameArray.h" 0050 #include "property_map.h" 0051 0052 namespace KJS 0053 { 0054 0055 bool JSVariableObject::deleteProperty(ExecState *exec, const Identifier &propertyName) 0056 { 0057 if (symbolTable->contains(propertyName.ustring().rep())) { 0058 return false; 0059 } 0060 0061 return JSObject::deleteProperty(exec, propertyName); 0062 } 0063 0064 void JSVariableObject::getOwnPropertyNames(ExecState *exec, PropertyNameArray &propertyNames, PropertyMap::PropertyMode mode) 0065 { 0066 SymbolTable::const_iterator::Keys end = symbolTable->end().keys(); 0067 for (SymbolTable::const_iterator::Keys it = symbolTable->begin().keys(); it != end; ++it) { 0068 propertyNames.add(Identifier(it->get())); 0069 } 0070 0071 JSObject::getOwnPropertyNames(exec, propertyNames, mode); 0072 } 0073 0074 void JSVariableObject::mark() 0075 { 0076 JSObject::mark(); 0077 0078 if (!localStorage) { 0079 return; 0080 } 0081 0082 size_t size = lengthSlot(); 0083 LocalStorageEntry *entries = localStorage; 0084 0085 for (size_t i = 0; i < size; ++i) { 0086 JSValue *value = entries[i].val.valueVal; 0087 if (!(entries[i].attributes & DontMark) && !JSValue::marked(value)) { 0088 JSValue::mark(value); 0089 } 0090 } 0091 } 0092 0093 } // namespace KJS