fixed a bug where the JIT initiated the optimized stack top boundary check with a doubly relocated address, causing a rare bug with stack operations
3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is part of the SourceMod/SourcePawn SDK. This file may only be used
8 * or modified under the Terms and Conditions of its License Agreement, which is found
9 * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins
10 * may change at any time. To view the latest information, see:
11 * http://www.sourcemod.net/license.php
16 #if defined _keyvalues_included
19 #define _keyvalues_included
22 * KeyValue data value types
26 KvData_None = 0, /**< Type could not be identified, or no type */
27 KvData_String, /**< String value */
28 KvData_Int, /**< Integer value */
29 KvData_Float, /**< Floating point value */
30 KvData_Ptr, /**< Pointer value (sometimes called "long") */
31 KvData_WString, /**< Wide string value */
32 KvData_Color, /**< Color value */
33 KvData_UInt64, /**< Large integer value */
39 * Creates a new KeyValues structure. The Handle must always be closed.
41 * @param name Name of the root section.
42 * @param firstKey If non-empty, specifies the first key value.
43 * @param firstValue If firstKey is non-empty, specifies the first key's value.
44 * @return A Handle to a new KeyValues structure.
46 native Handle:CreateKeyValues(const String:name[], const String:firstkey[]="", const String:firstValue[]="");
49 * Sets a string value of a KeyValues key.
51 * @param kv KeyValues Handle.
52 * @param key Name of the key.
53 * @param value String value.
55 * @error Invalid Handle.
57 native KvSetString(Handle:kv, const String:key[], const String:value[]);
60 * Sets an integer value of a KeyValues key.
62 * @param kv KeyValues Handle.
63 * @param key Name of the key.
64 * @param value Value number.
66 * @error Invalid Handle.
68 native KvSetNum(Handle:kv, const String:key[], value);
71 * Sets a large integer value of a KeyValues key.
73 * @param kv KeyValues Handle.
74 * @param key Name of the key.
75 * @param value Large integer value (0=High bits, 1=Low bits)
77 * @error Invalid Handle.
79 native KvSetUint64(Handle:kv, const String:key[], const value[2]);
82 * Sets a floating point value of a KeyValues key.
84 * @param kv KeyValues Handle.
85 * @param key Name of the key.
86 * @param value Floating point value.
88 * @error Invalid Handle.
90 native KvSetFloat(Handle:kv, const String:key[], Float:value);
93 * Sets a set of color values of a KeyValues key.
95 * @param kv KeyValues Handle.
96 * @param key Name of the key.
98 * @param g Green value.
99 * @param b Blue value.
100 * @param a Alpha value.
102 * @error Invalid Handle.
104 native KvSetColor(Handle:kv, const String:key[], r, g, b, a=0);
107 * Retrieves a string value from a KeyValues key.
109 * @param kv KeyValues Handle.
110 * @param key Name of the key.
111 * @param value Buffer to store key value in.
112 * @param maxlength Maximum length of the value buffer.
113 * @param defvalue Optional default value to use if the key is not found.
115 * @error Invalid Handle.
117 native KvGetString(Handle:kv, const String:key[], String:value[], maxlength, const String:defvalue[]="");
120 * Retrieves an integer value from a KeyValues key.
122 * @param kv KeyValues Handle.
123 * @param key Name of the key.
124 * @param defvalue Optional default value to use if the key is not found.
125 * @return Integer value of the key.
126 * @error Invalid Handle.
128 native KvGetNum(Handle:kv, const String:key[], defvalue=0);
131 * Retrieves a floating point value from a KeyValues key.
133 * @param kv KeyValues Handle.
134 * @param key Name of the key.
135 * @param defvalue Optional default value to use if the key is not found.
136 * @return Floating point value of the key.
137 * @error Invalid Handle.
139 native Float:KvGetFloat(Handle:kv, const String:key[], Float:defvalue=0.0);
142 * Retrieves a set of color values from a KeyValues key.
144 * @param kv KeyValues Handle.
145 * @param key Name of the key.
146 * @param r Red value, set by reference.
147 * @param g Green value, set by reference.
148 * @param b Blue value, set by reference.
149 * @param a Alpha value, set by reference.
151 * @error Invalid Handle.
153 native KvGetColor(Handle:kv, const String:key[], &r, &g, &b, &a);
156 * Retrieves a large integer value from a KeyValues key.
158 * @param kv KeyValues Handle.
159 * @param key Name of the key.
160 * @param value Array to represent the large integer.
161 * @param defvalue Optional default value to use if the key is not found.
163 * @error Invalid Handle.
165 native KvGetUint64(Handle:kv, const String:key[], value[2], defvalue[2]={0,0});
168 * Sets the current position in the KeyValues tree to the given key.
170 * @param kv KeyValues Handle.
171 * @param key Name of the key.
172 * @param create If true, and the key does not exist, it will be created.
173 * @return True if the key exists, false if it does not and was not created.
175 native bool:KvJumpToKey(Handle:kv, const String:key[], bool:create=false);
178 * Sets the current position in the KeyValues tree to the first sub key.
179 * This native adds to the internal traversal stack.
181 * @param kv KeyValues Handle.
182 * @param keyOnly If false, non-keys will be traversed (values).
183 * @return True on success, false if there was no first sub key.
184 * @error Invalid Handle.
186 native bool:KvGotoFirstSubKey(Handle:kv, bool:keyOnly=true);
189 * Sets the current position in the KeyValues tree to the next sub key.
190 * This native does NOT add to the internal traversal stack, and thus
191 * KvGoBack() is not needed for each successive call to this function.
193 * @param kv KeyValues Handle.
194 * @param keyOnly If false, non-keys will be traversed (values).
195 * @return True on success, false if there was no next sub key.
196 * @error Invalid Handle.
198 native bool:KvGotoNextKey(Handle:kv, bool:keyOnly=true);
201 * Saves the current position in the traversal stack onto the traversal
202 * stack. This can be useful if you wish to use KvGotoNextKey() and
203 * have the previous key saved for backwards traversal.
205 * @param kv KeyValues Handle.
207 * @error Invalid Handle.
209 native KvSavePosition(Handle:kv);
212 * Removes the given key from the current position.
214 * @param kv KeyValues Handle.
215 * @param key Name of the key.
216 * @return True on success, false if key did not exist.
217 * @error Invalid Handle.
219 native bool:KvDeleteKey(Handle:kv, const String:key[]);
222 * Removes the current sub-key and attempts to set the position
223 * to the sub-key after the removed one. If no such sub-key exists,
224 * the position will be the parent key in the traversal stack.
225 * Given the sub-key having position "N" in the traversal stack, the
226 * removal will always take place from position "N-1."
228 * @param kv KeyValues Handle.
229 * @return 1 if removal succeeded and there was another key.
230 * 0 if the current node was not contained in the
231 * previous node, or no previous node exists.
232 * -1 if removal succeeded and there were no more keys,
233 * thus the state is as if KvGoBack() was called.
234 * @error Invalid Handle.
236 native KvDeleteThis(Handle:kv);
239 * Jumps back to the previous position. Returns false if there are no
240 * previous positions (i.e., at the root node). This should be called
241 * once for each successful Jump call, in order to return to the top node.
242 * This function pops one node off the internal traversal stack.
244 * @param kv KeyValues Handle.
245 * @return True on success, false if there is no higher node.
246 * @error Invalid Handle.
248 native bool:KvGoBack(Handle:kv);
251 * Sets the position back to the top node, emptying the entire node
252 * traversal history. This can be used instead of looping KvGoBack()
253 * if recursive iteration is not important.
255 * @param kv KeyValues Handle.
257 * @error Invalid Handle.
259 native KvRewind(Handle:kv);
262 * Retrieves the current section name.
264 * @param kv KeyValues Handle.
265 * @param section Buffer to store the section name.
266 * @param maxlength Maximum length of the name buffer.
267 * @return True on success, false on failure.
268 * @error Invalid Handle.
270 native bool:KvGetSectionName(Handle:kv, String:section[], maxlength);
273 * Sets the current section name.
275 * @param kv KeyValues Handle.
276 * @param section Section name.
278 * @error Invalid Handle.
280 native KvSetSectionName(Handle:kv, const String:section[]);
283 * Returns the data type at a key.
285 * @param kv KeyValues Handle.
286 * @param key Key name.
287 * @return KvDataType value of the key.
288 * @error Invalid Handle.
290 native KvDataTypes:KvGetDataType(Handle:kv, const String:key[]);
293 * Converts a KeyValues tree to a file. The tree is dumped
294 * from the current position.
296 * @param kv KeyValues Handle.
297 * @param file File to dump write to.
298 * @return True on success, false otherwise.
299 * @error Invalid Handle.
301 native bool:KeyValuesToFile(Handle:kv, const String:file[]);
304 * Converts a file to a KeyValues tree. The file is read into
305 * the current position of the tree.
307 * @param kv KeyValues Handle.
308 * @param file File to read from.
309 * @return True on success, false otherwise.
310 * @error Invalid Handle.
312 native bool:FileToKeyValues(Handle:kv, const String:file[]);
315 * Sets whether or not the KeyValues parser will read escape sequences.
316 * For example, \n would be read as a literal newline. This defaults
317 * to false for new KeyValues structures.
319 * @param kv KeyValues Handle.
320 * @param useEscapes Whether or not to read escape sequences.
322 * @error Invalid Handle.
324 native KvSetEscapeSequences(Handle:kv, bool:useEscapes);
327 * Returns the position in the jump stack; I.e. the number of calls
328 * required for KvGoBack to return to the root node. If at the root node,
331 * @param kv KeyValues Handle.
332 * @return Number of non-root nodes in the jump stack.
333 * @error Invalid Handle.
335 native KvNodesInStack(Handle:kv);