Reenable test.
[wine-gecko.git] / db / mork / src / morkIntMap.cpp
blob196d19a76211932f8b298779c9ec25e838159c19
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1999
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef _MDB_
39 #include "mdb.h"
40 #endif
42 #ifndef _MORK_
43 #include "mork.h"
44 #endif
46 #ifndef _MORKNODE_
47 #include "morkNode.h"
48 #endif
50 #ifndef _MORKENV_
51 #include "morkEnv.h"
52 #endif
54 #ifndef _MORKMAP_
55 #include "morkMap.h"
56 #endif
58 #ifndef _MORKINTMAP_
59 #include "morkIntMap.h"
60 #endif
62 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
64 // ````` ````` ````` ````` `````
65 // { ===== begin morkNode interface =====
67 /*public virtual*/ void
68 morkIntMap::CloseMorkNode(morkEnv* ev) // CloseIntMap() only if open
70 if ( this->IsOpenNode() )
72 this->MarkClosing();
73 this->CloseIntMap(ev);
74 this->MarkShut();
78 /*public virtual*/
79 morkIntMap::~morkIntMap() // assert CloseIntMap() executed earlier
81 MORK_ASSERT(this->IsShutNode());
84 /*public non-poly*/
85 morkIntMap::morkIntMap(morkEnv* ev,
86 const morkUsage& inUsage, mork_size inValSize,
87 nsIMdbHeap* ioHeap, nsIMdbHeap* ioSlotHeap, mork_bool inHoldChanges)
88 : morkMap(ev, inUsage, ioHeap, sizeof(mork_u4), inValSize,
89 morkIntMap_kStartSlotCount, ioSlotHeap, inHoldChanges)
91 if ( ev->Good() )
92 mNode_Derived = morkDerived_kIntMap;
95 /*public non-poly*/ void
96 morkIntMap::CloseIntMap(morkEnv* ev) // called by CloseMorkNode();
98 if ( this )
100 if ( this->IsNode() )
102 this->CloseMap(ev);
103 this->MarkShut();
105 else
106 this->NonNodeError(ev);
108 else
109 ev->NilPointerError();
112 // } ===== end morkNode methods =====
113 // ````` ````` ````` ````` `````
115 // { ===== begin morkMap poly interface =====
116 /*virtual*/ mork_bool // *((mork_u4*) inKeyA) == *((mork_u4*) inKeyB)
117 morkIntMap::Equal(morkEnv* ev, const void* inKeyA, const void* inKeyB) const
119 MORK_USED_1(ev);
120 return *((const mork_u4*) inKeyA) == *((const mork_u4*) inKeyB);
123 /*virtual*/ mork_u4 // some integer function of *((mork_u4*) inKey)
124 morkIntMap::Hash(morkEnv* ev, const void* inKey) const
126 MORK_USED_1(ev);
127 return *((const mork_u4*) inKey);
129 // } ===== end morkMap poly interface =====
131 mork_bool
132 morkIntMap::AddInt(morkEnv* ev, mork_u4 inKey, void* ioAddress)
133 // the AddInt() method return value equals ev->Good().
135 if ( ev->Good() )
137 this->Put(ev, &inKey, &ioAddress,
138 /*key*/ (void*) 0, /*val*/ (void*) 0, (mork_change**) 0);
141 return ev->Good();
144 mork_bool
145 morkIntMap::CutInt(morkEnv* ev, mork_u4 inKey)
147 return this->Cut(ev, &inKey, /*key*/ (void*) 0, /*val*/ (void*) 0,
148 (mork_change**) 0);
151 void*
152 morkIntMap::GetInt(morkEnv* ev, mork_u4 inKey)
153 // Note the returned val does NOT have an increase in refcount for this.
155 void* val = 0; // old val in the map
156 this->Get(ev, &inKey, /*key*/ (void*) 0, &val, (mork_change**) 0);
158 return val;
161 mork_bool
162 morkIntMap::HasInt(morkEnv* ev, mork_u4 inKey)
163 // Note the returned val does NOT have an increase in refcount for this.
165 return this->Get(ev, &inKey, /*key*/ (void*) 0, /*val*/ (void*) 0,
166 (mork_change**) 0);
169 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
171 #ifdef MORK_POINTER_MAP_IMPL
173 // ````` ````` ````` ````` `````
174 // { ===== begin morkNode interface =====
176 /*public virtual*/ void
177 morkPointerMap::CloseMorkNode(morkEnv* ev) // ClosePointerMap() only if open
179 if ( this->IsOpenNode() )
181 this->MarkClosing();
182 this->ClosePointerMap(ev);
183 this->MarkShut();
187 /*public virtual*/
188 morkPointerMap::~morkPointerMap() // assert ClosePointerMap() executed earlier
190 MORK_ASSERT(this->IsShutNode());
193 /*public non-poly*/
194 morkPointerMap::morkPointerMap(morkEnv* ev,
195 const morkUsage& inUsage, nsIMdbHeap* ioHeap, nsIMdbHeap* ioSlotHeap)
196 : morkMap(ev, inUsage, ioHeap, sizeof(void*), sizeof(void*),
197 morkPointerMap_kStartSlotCount, ioSlotHeap,
198 /*inHoldChanges*/ morkBool_kFalse)
200 if ( ev->Good() )
201 mNode_Derived = morkDerived_kPointerMap;
204 /*public non-poly*/ void
205 morkPointerMap::ClosePointerMap(morkEnv* ev) // called by CloseMorkNode();
207 if ( this )
209 if ( this->IsNode() )
211 this->CloseMap(ev);
212 this->MarkShut();
214 else
215 this->NonNodeError(ev);
217 else
218 ev->NilPointerError();
221 // } ===== end morkNode methods =====
222 // ````` ````` ````` ````` `````
224 // { ===== begin morkMap poly interface =====
225 /*virtual*/ mork_bool // *((void**) inKeyA) == *((void**) inKeyB)
226 morkPointerMap::Equal(morkEnv* ev, const void* inKeyA, const void* inKeyB) const
228 MORK_USED_1(ev);
229 return *((const void**) inKeyA) == *((const void**) inKeyB);
232 /*virtual*/ mork_u4 // some integer function of *((mork_u4*) inKey)
233 morkPointerMap::Hash(morkEnv* ev, const void* inKey) const
235 MORK_USED_1(ev);
236 return *((const mork_u4*) inKey);
238 // } ===== end morkMap poly interface =====
240 mork_bool
241 morkPointerMap::AddPointer(morkEnv* ev, void* inKey, void* ioAddress)
242 // the AddPointer() method return value equals ev->Good().
244 if ( ev->Good() )
246 this->Put(ev, &inKey, &ioAddress,
247 /*key*/ (void*) 0, /*val*/ (void*) 0, (mork_change**) 0);
250 return ev->Good();
253 mork_bool
254 morkPointerMap::CutPointer(morkEnv* ev, void* inKey)
256 return this->Cut(ev, &inKey, /*key*/ (void*) 0, /*val*/ (void*) 0,
257 (mork_change**) 0);
260 void*
261 morkPointerMap::GetPointer(morkEnv* ev, void* inKey)
262 // Note the returned val does NOT have an increase in refcount for this.
264 void* val = 0; // old val in the map
265 this->Get(ev, &inKey, /*key*/ (void*) 0, &val, (mork_change**) 0);
267 return val;
270 mork_bool
271 morkPointerMap::HasPointer(morkEnv* ev, void* inKey)
272 // Note the returned val does NOT have an increase in refcount for this.
274 return this->Get(ev, &inKey, /*key*/ (void*) 0, /*val*/ (void*) 0,
275 (mork_change**) 0);
277 #endif /*MORK_POINTER_MAP_IMPL*/
280 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789