source: webkit/trunk/JavaScriptCore/runtime/Protect.h@ 39554

Last change on this file since 39554 was 39554, checked in by [email protected], 16 years ago

Bug 23080: Remove last vestiges of KJS references

<https://bugs.webkit.org/show_bug.cgi?id=23080>

Reviewed by Darin Adler.

Also updated Apple copyright statements.

  • DerivedSources.make: Changed bison "kjsyy" prefix to "jscyy".
  • GNUmakefile.am: Ditto.
  • JavaScriptCore.pri: Ditto. Also changed KJSBISON to JSCBISON and kjsbison to jscbison.
  • JavaScriptCoreSources.bkl: Changed JSCORE_KJS_SOURCES to JSCORE_JSC_SOURCES.
  • jscore.bkl: Ditto.
  • create_hash_table: Updated copyright and removed old comment.
  • parser/Grammar.y: Changed "kjsyy" prefix to "jscyy" prefix.
  • parser/Lexer.cpp: Ditto. Also changed KJS_DEBUG_LEX to JSC_DEBUG_LEX. (jscyylex): (JSC::Lexer::lex):
  • parser/Parser.cpp: Ditto. (JSC::Parser::parse):
  • pcre/dftables: Changed "kjs_pcre_" prefix to "jsc_pcre_".
  • pcre/pcre_compile.cpp: Ditto. (getOthercaseRange): (encodeUTF8): (compileBranch): (calculateCompiledPatternLength):
  • pcre/pcre_exec.cpp: Ditto. (matchRef): (getUTF8CharAndIncrementLength): (match):
  • pcre/pcre_internal.h: Ditto. (toLowerCase): (flipCase): (classBitmapForChar): (charTypeForChar):
  • pcre/pcre_tables.cpp: Ditto.
  • pcre/pcre_ucp_searchfuncs.cpp: Ditto. (jsc_pcre_ucp_othercase):
  • pcre/pcre_xclass.cpp: Ditto. (getUTF8CharAndAdvancePointer): (jsc_pcre_xclass):
  • runtime/Collector.h: Updated header guards using the clean-header-guards script.
  • runtime/CollectorHeapIterator.h: Added missing header guard.
  • runtime/Identifier.h: Updated header guards.
  • runtime/JSFunction.h: Fixed end-of-namespace comment.
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::reset): Renamed "kjsprint" debug function to "jscprint". Changed implementation method from globalFuncKJSPrint() to globalFuncJSCPrint().
  • runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncJSCPrint): Renamed from globalFuncKJSPrint().
  • runtime/JSGlobalObjectFunctions.h: Ditto.
  • runtime/JSImmediate.h: Updated header guards.
  • runtime/JSLock.h: Ditto.
  • runtime/JSType.h: Ditto.
  • runtime/JSWrapperObject.h: Ditto.
  • runtime/Lookup.h: Ditto.
  • runtime/Operations.h: Ditto.
  • runtime/Protect.h: Ditto.
  • runtime/RegExp.h: Ditto.
  • runtime/UString.h: Ditto.
  • tests/mozilla/js1_5/Array/regress-157652.js: Changed "KJS" reference in comment to "JSC".
  • wrec/CharacterClassConstructor.cpp: Change "kjs_pcre_" function prefixes to "jsc_pcre_". (JSC::WREC::CharacterClassConstructor::put): (JSC::WREC::CharacterClassConstructor::flush):
  • wtf/unicode/Unicode.h: Change "KJS_" header guard to "WTF_".
  • wtf/unicode/icu/UnicodeIcu.h: Ditto.
  • wtf/unicode/qt4/UnicodeQt4.h: Ditto.
  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1/*
2 * Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21
22#ifndef Protect_h
23#define Protect_h
24
25#include "JSCell.h"
26#include "Collector.h"
27
28namespace JSC {
29
30 inline void gcProtect(JSCell* val)
31 {
32 Heap::heap(val)->protect(val);
33 }
34
35 inline void gcUnprotect(JSCell* val)
36 {
37 Heap::heap(val)->unprotect(val);
38 }
39
40 inline void gcProtectNullTolerant(JSCell* val)
41 {
42 if (val)
43 gcProtect(val);
44 }
45
46 inline void gcUnprotectNullTolerant(JSCell* val)
47 {
48 if (val)
49 gcUnprotect(val);
50 }
51
52 inline void gcProtect(JSValue* value)
53 {
54 if (JSImmediate::isImmediate(value))
55 return;
56 gcProtect(asCell(value));
57 }
58
59 inline void gcUnprotect(JSValue* value)
60 {
61 if (JSImmediate::isImmediate(value))
62 return;
63 gcUnprotect(asCell(value));
64 }
65
66 inline void gcProtectNullTolerant(JSValue* value)
67 {
68 if (!value || JSImmediate::isImmediate(value))
69 return;
70 gcProtect(asCell(value));
71 }
72
73 inline void gcUnprotectNullTolerant(JSValue* value)
74 {
75 if (!value || JSImmediate::isImmediate(value))
76 return;
77 gcUnprotect(asCell(value));
78 }
79
80 // FIXME: Share more code with RefPtr template? The only differences are the ref/deref operation
81 // and the implicit conversion to raw pointer
82 template <class T> class ProtectedPtr {
83 public:
84 ProtectedPtr() : m_ptr(0) { }
85 ProtectedPtr(T* ptr);
86 ProtectedPtr(const ProtectedPtr&);
87 ~ProtectedPtr();
88
89 template <class U> ProtectedPtr(const ProtectedPtr<U>&);
90
91 T* get() const { return m_ptr; }
92 operator T*() const { return m_ptr; }
93 T* operator->() const { return m_ptr; }
94
95 bool operator!() const { return !m_ptr; }
96
97 ProtectedPtr& operator=(const ProtectedPtr&);
98 ProtectedPtr& operator=(T*);
99
100 private:
101 T* m_ptr;
102 };
103
104 template <class T> ProtectedPtr<T>::ProtectedPtr(T* ptr)
105 : m_ptr(ptr)
106 {
107 gcProtectNullTolerant(m_ptr);
108 }
109
110 template <class T> ProtectedPtr<T>::ProtectedPtr(const ProtectedPtr& o)
111 : m_ptr(o.get())
112 {
113 gcProtectNullTolerant(m_ptr);
114 }
115
116 template <class T> ProtectedPtr<T>::~ProtectedPtr()
117 {
118 gcUnprotectNullTolerant(m_ptr);
119 }
120
121 template <class T> template <class U> ProtectedPtr<T>::ProtectedPtr(const ProtectedPtr<U>& o)
122 : m_ptr(o.get())
123 {
124 gcProtectNullTolerant(m_ptr);
125 }
126
127 template <class T> ProtectedPtr<T>& ProtectedPtr<T>::operator=(const ProtectedPtr<T>& o)
128 {
129 T* optr = o.m_ptr;
130 gcProtectNullTolerant(optr);
131 gcUnprotectNullTolerant(m_ptr);
132 m_ptr = optr;
133 return *this;
134 }
135
136 template <class T> inline ProtectedPtr<T>& ProtectedPtr<T>::operator=(T* optr)
137 {
138 gcProtectNullTolerant(optr);
139 gcUnprotectNullTolerant(m_ptr);
140 m_ptr = optr;
141 return *this;
142 }
143
144 template <class T> inline bool operator==(const ProtectedPtr<T>& a, const ProtectedPtr<T>& b) { return a.get() == b.get(); }
145 template <class T> inline bool operator==(const ProtectedPtr<T>& a, const T* b) { return a.get() == b; }
146 template <class T> inline bool operator==(const T* a, const ProtectedPtr<T>& b) { return a == b.get(); }
147
148 template <class T> inline bool operator!=(const ProtectedPtr<T>& a, const ProtectedPtr<T>& b) { return a.get() != b.get(); }
149 template <class T> inline bool operator!=(const ProtectedPtr<T>& a, const T* b) { return a.get() != b; }
150 template <class T> inline bool operator!=(const T* a, const ProtectedPtr<T>& b) { return a != b.get(); }
151
152} // namespace JSC
153
154#endif // Protect_h
Note: See TracBrowser for help on using the repository browser.