1/*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * (C) 2008 Maksim Orlovich <maksim@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 * Portions of this code that are (C) 2007, 2008 Apple Inc. were
21 * originally distributed under the following terms
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 *
27 * 1. Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * 2. Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in the
31 * documentation and/or other materials provided with the distribution.
32 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
33 * its contributors may be used to endorse or promote products derived
34 * from this software without specific prior written permission.
35 *
36 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
37 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
40 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
45 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 */
47#include <config-kjs.h>
48#include "JSVariableObject.h"
49
50#include "PropertyNameArray.h"
51#include "property_map.h"
52
53namespace KJS {
54
55bool JSVariableObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
56{
57 if (symbolTable->contains(propertyName.ustring().rep()))
58 return false;
59
60 return JSObject::deleteProperty(exec, propertyName);
61}
62
63void JSVariableObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, PropertyMap::PropertyMode mode)
64{
65 SymbolTable::const_iterator::Keys end = symbolTable->end().keys();
66 for (SymbolTable::const_iterator::Keys it = symbolTable->begin().keys(); it != end; ++it)
67 propertyNames.add(Identifier(it->get()));
68
69 JSObject::getOwnPropertyNames(exec, propertyNames, mode);
70}
71
72void JSVariableObject::mark()
73{
74 JSObject::mark();
75
76 if (!localStorage)
77 return;
78
79 size_t size = lengthSlot();
80 LocalStorageEntry* entries = localStorage;
81
82 for (size_t i = 0; i < size; ++i) {
83 JSValue* value = entries[i].val.valueVal;
84 if (!(entries[i].attributes & DontMark) && !value->marked())
85 value->mark();
86 }
87}
88
89} // namespace KJS
90