source: webkit/trunk/JavaScriptCore/kjs/PropertyNameArray.h@ 34861

Last change on this file since 34861 was 34611, checked in by [email protected], 17 years ago

Trying to fix Windows build.

  • kjs/PropertyNameArray.h:
  • kjs/identifier.cpp: Include ExecState.h
  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1// -*- mode: c++; c-basic-offset: 4 -*-
2/*
3 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
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 */
21
22#ifndef PropertyNameArray_h
23#define PropertyNameArray_h
24
25#include "ExecState.h"
26#include "identifier.h"
27#include <wtf/HashSet.h>
28#include <wtf/Vector.h>
29
30namespace KJS {
31
32 class PropertyNameArray {
33 public:
34 typedef Identifier ValueType;
35 typedef Vector<Identifier>::const_iterator const_iterator;
36
37 PropertyNameArray(JSGlobalData* globalData) : m_globalData(globalData) {}
38 PropertyNameArray(ExecState* exec) : m_globalData(&exec->globalData()) {}
39
40 void add(const Identifier& identifier) { add(identifier.ustring().rep()); }
41 void add(UString::Rep*);
42 void addKnownUnique(UString::Rep* identifier) { m_vector.append(Identifier(m_globalData, identifier)); }
43
44 const_iterator begin() const { return m_vector.begin(); }
45 const_iterator end() const { return m_vector.end(); }
46
47 size_t size() const { return m_vector.size(); }
48
49 Identifier& operator[](unsigned i) { return m_vector[i]; }
50 const Identifier& operator[](unsigned i) const { return m_vector[i]; }
51
52 Identifier* releaseIdentifiers() { return size() ? m_vector.releaseBuffer() : 0; }
53
54 private:
55 typedef HashSet<UString::Rep*, PtrHash<UString::Rep*> > IdentifierSet;
56
57 Vector<Identifier, 20> m_vector;
58 IdentifierSet m_set;
59 JSGlobalData* m_globalData;
60 };
61
62} // namespace KJS
63
64#endif // PropertyNameArray_h
Note: See TracBrowser for help on using the repository browser.