source: webkit/trunk/JavaScriptCore/kjs/identifier.h@ 20204

Last change on this file since 20204 was 17483, checked in by ap, 19 years ago

2006-10-31 Vladimir Olexa <[email protected]>

Reviewed by Geoff.

http://bugs.webkit.org/show_bug.cgi?id=4166
Function object does not support caller property

Test: fast/js/caller-property.html

  • kjs/function.cpp: (KJS::FunctionImp::callerGetter): added (KJS::FunctionImp::getOwnPropertySlot): added if statement to handle callerGetter()
  • kjs/function.h: added callerGetter() declaration
  • kjs/identifier.h: added caller property macro
  • tests/mozilla/expected.html:
  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
1/*
2 * This file is part of the KDE libraries
3 * Copyright (C) 2003 Apple Computer, Inc
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 KJS_IDENTIFIER_H
23#define KJS_IDENTIFIER_H
24
25#include "ustring.h"
26
27namespace KJS {
28
29 class Identifier {
30 friend class PropertyMap;
31 public:
32 static void init();
33
34 Identifier() { }
35 Identifier(const char* s) : _ustring(add(s)) { }
36 Identifier(const UChar* s, int length) : _ustring(add(s, length)) { }
37 explicit Identifier(UString::Rep* rep) : _ustring(add(rep)) { }
38 explicit Identifier(const UString& s) : _ustring(add(s.rep())) { }
39
40 const UString& ustring() const { return _ustring; }
41 DOM::DOMString domString() const;
42
43 const UChar* data() const { return _ustring.data(); }
44 int size() const { return _ustring.size(); }
45
46 const char* ascii() const { return _ustring.ascii(); }
47
48 static Identifier from(unsigned y) { return Identifier(UString::from(y)); }
49
50 bool isNull() const { return _ustring.isNull(); }
51 bool isEmpty() const { return _ustring.isEmpty(); }
52
53 uint32_t toUInt32(bool* ok) const { return _ustring.toUInt32(ok); }
54 uint32_t toStrictUInt32(bool* ok) const { return _ustring.toStrictUInt32(ok); }
55 unsigned toArrayIndex(bool* ok) const { return _ustring.toArrayIndex(ok); }
56 double toDouble() const { return _ustring.toDouble(); }
57
58 static const Identifier& null();
59
60 friend bool operator==(const Identifier&, const Identifier&);
61 friend bool operator!=(const Identifier&, const Identifier&);
62
63 friend bool operator==(const Identifier&, const char*);
64
65 static void remove(UString::Rep* );
66
67 static bool equal(const UString::Rep*, const char*);
68 static bool equal(const UString::Rep*, const UChar*, int length);
69 static bool equal(const UString::Rep*, const UString::Rep*);
70
71 private:
72 UString _ustring;
73
74 static bool equal(const Identifier& a, const Identifier& b)
75 { return a._ustring.rep() == b._ustring.rep(); }
76 static bool equal(const Identifier& a, const char* b)
77 { return equal(a._ustring.rep(), b); }
78
79 static PassRefPtr<UString::Rep> add(const char*);
80 static PassRefPtr<UString::Rep> add(const UChar*, int length);
81 static PassRefPtr<UString::Rep> add(UString::Rep*);
82 };
83
84#ifndef KJS_IDENTIFIER_HIDE_GLOBALS
85 extern const Identifier nullIdentifier;
86
87 inline const Identifier& Identifier::null()
88 { return nullIdentifier; }
89#endif
90
91 inline bool operator==(const Identifier& a, const Identifier& b)
92 { return Identifier::equal(a, b); }
93
94 inline bool operator!=(const Identifier& a, const Identifier& b)
95 { return !Identifier::equal(a, b); }
96
97 inline bool operator==(const Identifier& a, const char* b)
98 { return Identifier::equal(a, b); }
99
100 // List of property names, passed to a macro so we can do set them up various
101 // ways without repeating the list.
102 #define KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(macro) \
103 macro(arguments) \
104 macro(callee) \
105 macro(caller) \
106 macro(constructor) \
107 macro(fromCharCode) \
108 macro(length) \
109 macro(message) \
110 macro(name) \
111 macro(prototype) \
112 macro(toLocaleString) \
113 macro(toString) \
114 macro(toFixed) \
115 macro(toExponential) \
116 macro(toPrecision) \
117 macro(valueOf)
118
119 // Define external global variables for all property names above (and one more).
120#ifndef KJS_IDENTIFIER_HIDE_GLOBALS
121 extern const Identifier specialPrototypePropertyName;
122
123 #define KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) extern const Identifier name ## PropertyName;
124 KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
125 #undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
126#endif
127
128} // namespace KJS
129
130#endif // KJS_IDENTIFIER_H
Note: See TracBrowser for help on using the repository browser.