|
dvander@601
|
1 |
/** |
|
dvander@601
|
2 |
* vim: set ts=4 : |
|
dvander@601
|
3 |
* =============================================================== |
|
dvander@601
|
4 |
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. |
|
dvander@601
|
5 |
* =============================================================== |
|
dvander@601
|
6 |
* |
|
dvander@601
|
7 |
* This file is part of the SourceMod/SourcePawn SDK. This file may only be used |
|
dvander@601
|
8 |
* or modified under the Terms and Conditions of its License Agreement, which is found |
|
dvander@601
|
9 |
* in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins |
|
dvander@601
|
10 |
* may change at any time. To view the latest information, see: |
|
dvander@601
|
11 |
* http://www.sourcemod.net/license.php |
|
dvander@601
|
12 |
* |
|
dvander@601
|
13 |
* Version: $Id$ |
|
dvander@601
|
14 |
*/ |
|
dvander@601
|
15 |
|
|
ds@621
|
16 |
#define SP_PARAMFLAG_BYREF (1<<0) /**< Internal use only. */ |
|
ds@621
|
17 |
|
|
ds@621
|
18 |
/** |
|
ds@621
|
19 |
* Describes the various ways to pass parameters to functions or forwards. |
|
ds@621
|
20 |
*/ |
|
ds@621
|
21 |
enum ParamType |
|
ds@621
|
22 |
{ |
|
ds@621
|
23 |
Param_Any = 0, /**< Any data type can be pushed */ |
|
ds@621
|
24 |
Param_Cell = (1<<1), /**< Only basic cells can be pushed */ |
|
ds@621
|
25 |
Param_Float = (2<<1), /**< Only floats can be pushed */ |
|
ds@621
|
26 |
Param_String = (3<<1)|SP_PARAMFLAG_BYREF, /**< Only strings can be pushed */ |
|
ds@621
|
27 |
Param_Array = (4<<1)|SP_PARAMFLAG_BYREF, /**< Only arrays can be pushed */ |
|
ds@621
|
28 |
Param_VarArgs = (5<<1), /**< Same as "..." in plugins, anything can be pushed, but it will always be byref */ |
|
ds@621
|
29 |
Param_CellByRef = (1<<1)|SP_PARAMFLAG_BYREF, /**< Only a cell by reference can be pushed */ |
|
ds@621
|
30 |
Param_FloatByRef = (2<<1)|SP_PARAMFLAG_BYREF /**< Only a float by reference can be pushed */ |
|
ds@621
|
31 |
}; |
|
ds@621
|
32 |
|
|
ds@621
|
33 |
/** |
|
ds@621
|
34 |
* Defines how a forward iterates through plugin functions. |
|
ds@621
|
35 |
*/ |
|
ds@621
|
36 |
enum ExecType |
|
ds@621
|
37 |
{ |
|
ds@621
|
38 |
ET_Ignore = 0, /**< Ignore all return values, return 0 */ |
|
ds@621
|
39 |
ET_Single = 1, /**< Only return the last exec, ignore all others */ |
|
ds@621
|
40 |
ET_Event = 2, /**< Acts as an event with the Actions defined in core.inc, no mid-Stops allowed, returns highest */ |
|
ds@621
|
41 |
ET_Hook = 3 /**< Acts as a hook with the Actions defined in core.inc, mid-Stops allowed, returns highest */ |
|
ds@621
|
42 |
}; |
|
ds@621
|
43 |
|
|
ds@621
|
44 |
/** |
|
ds@621
|
45 |
* @section Flags that are used with Call_PushArrayEx() and Call_PushStringEx() |
|
ds@621
|
46 |
*/ |
|
ds@621
|
47 |
#define SM_PARAM_COPYBACK (1<<0) /**< Copy an array/reference back after call */ |
|
ds@621
|
48 |
#define SM_PARAM_STRING_UTF8 (1<<0) /**< String should be UTF-8 handled */ |
|
ds@621
|
49 |
#define SM_PARAM_STRING_COPY (1<<1) /**< String should be copied into the plugin */ |
|
ds@621
|
50 |
|
|
ds@621
|
51 |
/** |
|
ds@621
|
52 |
* @endsection |
|
ds@621
|
53 |
*/ |
|
ds@621
|
54 |
|
|
ds@621
|
55 |
/** |
|
ds@621
|
56 |
* @section Error codes |
|
ds@621
|
57 |
*/ |
|
dvander@601
|
58 |
#define SP_ERROR_NONE 0 /**< No error occurred */ |
|
dvander@601
|
59 |
#define SP_ERROR_FILE_FORMAT 1 /**< File format unrecognized */ |
|
dvander@601
|
60 |
#define SP_ERROR_DECOMPRESSOR 2 /**< A decompressor was not found */ |
|
dvander@601
|
61 |
#define SP_ERROR_HEAPLOW 3 /**< Not enough space left on the heap */ |
|
dvander@601
|
62 |
#define SP_ERROR_PARAM 4 /**< Invalid parameter or parameter type */ |
|
dvander@601
|
63 |
#define SP_ERROR_INVALID_ADDRESS 5 /**< A memory address was not valid */ |
|
dvander@601
|
64 |
#define SP_ERROR_NOT_FOUND 6 /**< The object in question was not found */ |
|
dvander@601
|
65 |
#define SP_ERROR_INDEX 7 /**< Invalid index parameter */ |
|
dvander@601
|
66 |
#define SP_ERROR_STACKLOW 8 /**< Nnot enough space left on the stack */ |
|
dvander@601
|
67 |
#define SP_ERROR_NOTDEBUGGING 9 /**< Debug mode was not on or debug section not found */ |
|
dvander@601
|
68 |
#define SP_ERROR_INVALID_INSTRUCTION 10 /**< Invalid instruction was encountered */ |
|
dvander@601
|
69 |
#define SP_ERROR_MEMACCESS 11 /**< Invalid memory access */ |
|
dvander@601
|
70 |
#define SP_ERROR_STACKMIN 12 /**< Stack went beyond its minimum value */ |
|
dvander@601
|
71 |
#define SP_ERROR_HEAPMIN 13 /**< Heap went beyond its minimum value */ |
|
dvander@601
|
72 |
#define SP_ERROR_DIVIDE_BY_ZERO 14 /**< Division by zero */ |
|
dvander@601
|
73 |
#define SP_ERROR_ARRAY_BOUNDS 15 /**< Array index is out of bounds */ |
|
dvander@601
|
74 |
#define SP_ERROR_INSTRUCTION_PARAM 16 /**< Instruction had an invalid parameter */ |
|
dvander@601
|
75 |
#define SP_ERROR_STACKLEAK 17 /**< A native leaked an item on the stack */ |
|
dvander@601
|
76 |
#define SP_ERROR_HEAPLEAK 18 /**< A native leaked an item on the heap */ |
|
dvander@601
|
77 |
#define SP_ERROR_ARRAY_TOO_BIG 19 /**< A dynamic array is too big */ |
|
dvander@601
|
78 |
#define SP_ERROR_TRACKER_BOUNDS 20 /**< Tracker stack is out of bounds */ |
|
dvander@601
|
79 |
#define SP_ERROR_INVALID_NATIVE 21 /**< Native was pending or invalid */ |
|
dvander@601
|
80 |
#define SP_ERROR_PARAMS_MAX 22 /**< Maximum number of parameters reached */ |
|
dvander@601
|
81 |
#define SP_ERROR_NATIVE 23 /**< Error originates from a native */ |
|
dvander@601
|
82 |
#define SP_ERROR_NOT_RUNNABLE 24 /**< Function or plugin is not runnable */ |
|
dvander@601
|
83 |
#define SP_ERROR_ABORTED 25 /**< Function call was aborted */ |
|
dvander@601
|
84 |
|
|
dvander@601
|
85 |
/** |
|
ds@621
|
86 |
* @endsection |
|
ds@621
|
87 |
*/ |
|
ds@621
|
88 |
|
|
ds@621
|
89 |
/** |
|
ds@621
|
90 |
* Gets a function id from a function name. |
|
ds@621
|
91 |
* |
|
ds@621
|
92 |
* @param plugin Handle of the plugin that contains the function. |
|
ds@621
|
93 |
Pass INVALID_HANDLE to search in the calling plugin. |
|
ds@621
|
94 |
* @param name Name of the function. |
|
ds@621
|
95 |
* @return Function id or INVALID_FUNCTION if not found. |
|
ds@621
|
96 |
* @error Invalid or corrupt plugin handle. |
|
ds@621
|
97 |
*/ |
|
ds@621
|
98 |
native Function:GetFunctionByName(Handle:plugin, const String:name[]); |
|
ds@621
|
99 |
|
|
ds@621
|
100 |
/** |
|
ds@621
|
101 |
* Creates a global forward. |
|
ds@621
|
102 |
* |
|
ds@621
|
103 |
* @note The name used to create the forward is used as its public function in all target plugins. |
|
ds@621
|
104 |
* @note This is ideal for global, static forwards that are never changed. |
|
ds@635
|
105 |
* @note Global forwards cannot be cloned. |
|
ds@635
|
106 |
* @note Use CloseHandle() to destroy these. |
|
ds@621
|
107 |
* |
|
ds@621
|
108 |
* @param name Name of public function to use in forward. |
|
ds@621
|
109 |
* @param type Execution type to be used. |
|
ds@621
|
110 |
* @param ... Variable number of parameter types (up to 32). |
|
ds@621
|
111 |
* @return Handle to new global forward. |
|
ds@621
|
112 |
* @error More than 32 paramater types passed. |
|
ds@621
|
113 |
*/ |
|
ds@634
|
114 |
native Handle:CreateGlobalForward(const String:name[], ExecType:type, ParamType:...); |
|
ds@621
|
115 |
|
|
ds@621
|
116 |
/** |
|
ds@621
|
117 |
* Creates a private forward. |
|
ds@621
|
118 |
* |
|
ds@621
|
119 |
* @note No functions are automatically added. Use AddToForward() to do this. |
|
ds@635
|
120 |
* @note Private forwards can be cloned. |
|
ds@635
|
121 |
* @note Use CloseHandle() to destroy these. |
|
ds@621
|
122 |
* |
|
ds@621
|
123 |
* @param type Execution type to be used. |
|
ds@621
|
124 |
* @param ... Variable number of parameter types (up to 32). |
|
ds@621
|
125 |
* @return Handle to new private forward. |
|
ds@621
|
126 |
* @error More than 32 paramater types passed. |
|
ds@621
|
127 |
*/ |
|
ds@634
|
128 |
native Handle:CreateForward(ExecType:type, ParamType:...); |
|
ds@621
|
129 |
|
|
ds@621
|
130 |
/** |
|
ds@621
|
131 |
* Returns the number of functions in a global or private forward's call list. |
|
ds@621
|
132 |
* |
|
ds@621
|
133 |
* @param fwd Handle to global or private forward. |
|
ds@621
|
134 |
* @return Number of functions in forward. |
|
ds@621
|
135 |
* @error Invalid or corrupt forward handle. |
|
ds@621
|
136 |
*/ |
|
ds@621
|
137 |
native GetForwardFunctionCount(Handle:fwd); |
|
ds@621
|
138 |
|
|
ds@621
|
139 |
/** |
|
ds@621
|
140 |
* Adds a function to a private forward's call list. |
|
ds@621
|
141 |
* |
|
ds@621
|
142 |
* @note Cannot be used during an incompleted call. |
|
ds@621
|
143 |
* |
|
ds@621
|
144 |
* @param fwd Handle to private forward. |
|
ds@621
|
145 |
* @param plugin Handle of the plugin that contains the function. |
|
ds@621
|
146 |
* Pass INVALID_HANDLE to specify the calling plugin. |
|
ds@621
|
147 |
* @param func Function to add to forward. |
|
ds@621
|
148 |
* @return True on success, false otherwise. |
|
ds@621
|
149 |
* @error Invalid or corrupt private forward handle, invalid or corrupt plugin handle, or invalid function. |
|
ds@621
|
150 |
*/ |
|
ds@621
|
151 |
native bool:AddToForward(Handle:fwd, Handle:plugin, Function:func); |
|
ds@621
|
152 |
|
|
ds@621
|
153 |
/** |
|
ds@621
|
154 |
* Removes a function from a private forward's call list. |
|
ds@621
|
155 |
* |
|
ds@621
|
156 |
* @note Only removes one instance. |
|
ds@621
|
157 |
* @note Functions will be removed automatically if their parent plugin is unloaded. |
|
ds@621
|
158 |
* |
|
ds@621
|
159 |
* @param fwd Handle to private forward. |
|
ds@621
|
160 |
* @param plugin Handle of the plugin that contains the function. |
|
ds@621
|
161 |
* Pass INVALID_HANDLE to specify the calling plugin. |
|
ds@621
|
162 |
* @param func Function to remove from forward. |
|
ds@621
|
163 |
* @return True on success, false otherwise. |
|
ds@621
|
164 |
* @error Invalid or corrupt private forward handle, invalid or corrupt plugin handle, or invalid function. |
|
ds@621
|
165 |
*/ |
|
ds@621
|
166 |
native bool:RemoveFromForward(Handle:fwd, Handle:plugin, Function:func); |
|
ds@621
|
167 |
|
|
ds@621
|
168 |
/** |
|
ds@621
|
169 |
* Removes all instances of a plugin from a private forward's call list. |
|
ds@621
|
170 |
* |
|
ds@621
|
171 |
* @note Functions will be removed automatically if their parent plugin is unloaded. |
|
ds@621
|
172 |
* |
|
ds@621
|
173 |
* @param fwd Handle to private forward. |
|
ds@621
|
174 |
* @param plugin Handle of the plugin to remove instances of. |
|
ds@621
|
175 |
* Pass INVALID_HANDLE to specify the calling plugin. |
|
ds@621
|
176 |
* @return Number of functions removed from forward. |
|
ds@621
|
177 |
* @error Invalid or corrupt private forward handle or invalid or corrupt plugin handle. |
|
ds@621
|
178 |
*/ |
|
ds@621
|
179 |
native RemoveAllFromForward(Handle:fwd, Handle:plugin); |
|
ds@621
|
180 |
|
|
ds@621
|
181 |
/** |
|
ds@621
|
182 |
* Starts a call to functions in a forward's call list. |
|
ds@621
|
183 |
* |
|
ds@621
|
184 |
* @note Cannot be used during an incompleted call. |
|
ds@621
|
185 |
* |
|
ds@621
|
186 |
* @param fwd Handle to global or private forward. |
|
ds@621
|
187 |
* @noreturn |
|
ds@621
|
188 |
* @error Invalid or corrupt forward handle or called before another call has completed. |
|
ds@621
|
189 |
*/ |
|
ds@621
|
190 |
native Call_StartForward(Handle:fwd); |
|
ds@621
|
191 |
|
|
ds@621
|
192 |
/** |
|
ds@621
|
193 |
* Starts a call to a function. |
|
ds@621
|
194 |
* |
|
ds@621
|
195 |
* @note Cannot be used during an incompleted call. |
|
ds@621
|
196 |
* |
|
ds@621
|
197 |
* @param plugin Handle of the plugin that contains the function. |
|
ds@621
|
198 |
* Pass INVALID_HANDLE to specify the calling plugin. |
|
ds@621
|
199 |
* @param func Function to call. |
|
ds@621
|
200 |
* @noreturn |
|
ds@621
|
201 |
* @error Invalid or corrupt plugin handle, invalid function, or called before another call has completed. |
|
ds@621
|
202 |
*/ |
|
ds@621
|
203 |
native Call_StartFunction(Handle:plugin, Function:func); |
|
ds@621
|
204 |
|
|
ds@621
|
205 |
/** |
|
ds@621
|
206 |
* Pushes a cell onto the current call. |
|
ds@621
|
207 |
* |
|
ds@621
|
208 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
209 |
* |
|
ds@621
|
210 |
* @param value Cell value to push. |
|
ds@621
|
211 |
* @noreturn |
|
ds@621
|
212 |
* @error Called before a call has been started. |
|
ds@621
|
213 |
*/ |
|
dvander@815
|
214 |
native Call_PushCell(any:value); |
|
ds@621
|
215 |
|
|
ds@621
|
216 |
/** |
|
ds@621
|
217 |
* Pushes a cell by reference onto the current call. |
|
ds@621
|
218 |
* |
|
ds@621
|
219 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
220 |
* |
|
ds@621
|
221 |
* @param value Cell reference to push. |
|
ds@621
|
222 |
* @noreturn |
|
ds@621
|
223 |
* @error Called before a call has been started. |
|
ds@621
|
224 |
*/ |
|
dvander@815
|
225 |
native Call_PushCellRef(&any:value); |
|
ds@621
|
226 |
|
|
ds@621
|
227 |
/** |
|
ds@621
|
228 |
* Pushes a float onto the current call. |
|
ds@621
|
229 |
* |
|
ds@621
|
230 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
231 |
* |
|
ds@621
|
232 |
* @param value Floating point value to push. |
|
ds@621
|
233 |
* @noreturn |
|
ds@621
|
234 |
* @error Called before a call has been started. |
|
ds@621
|
235 |
*/ |
|
ds@621
|
236 |
native Call_PushFloat(Float:value); |
|
ds@621
|
237 |
|
|
ds@621
|
238 |
/** |
|
ds@621
|
239 |
* Pushes a float by reference onto the current call. |
|
ds@621
|
240 |
* |
|
ds@621
|
241 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
242 |
* |
|
ds@621
|
243 |
* @param value Floating point reference to push. |
|
ds@621
|
244 |
* @noreturn |
|
ds@621
|
245 |
* @error Called before a call has been started. |
|
ds@621
|
246 |
*/ |
|
ds@621
|
247 |
native Call_PushFloatRef(&Float:value); |
|
ds@621
|
248 |
|
|
ds@621
|
249 |
/** |
|
ds@621
|
250 |
* Pushes an array onto the current call. |
|
ds@621
|
251 |
* |
|
ds@621
|
252 |
* @note Changes to array are not copied back to caller. Use PushArrayEx() to do this. |
|
ds@621
|
253 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
254 |
* |
|
ds@621
|
255 |
* @param value Array to push. |
|
ds@621
|
256 |
* @param size Size of array. |
|
ds@621
|
257 |
* @noreturn |
|
ds@621
|
258 |
* @error Called before a call has been started. |
|
ds@621
|
259 |
*/ |
|
dvander@815
|
260 |
native Call_PushArray(const any:value[], size); |
|
ds@621
|
261 |
|
|
ds@621
|
262 |
/** |
|
ds@621
|
263 |
* Pushes an array onto the current call. |
|
ds@621
|
264 |
* |
|
ds@621
|
265 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
266 |
* |
|
ds@621
|
267 |
* @param value Array to push. |
|
ds@621
|
268 |
* @param size Size of array. |
|
ds@621
|
269 |
* @param cpflags Whether or not changes should be copied back to the input array. |
|
ds@621
|
270 |
* See SP_PARAM_* constants for details. |
|
ds@621
|
271 |
* @noreturn |
|
ds@621
|
272 |
* @error Called before a call has been started. |
|
ds@621
|
273 |
*/ |
|
dvander@815
|
274 |
native Call_PushArrayEx(any:value[], size, cpflags); |
|
ds@621
|
275 |
|
|
ds@621
|
276 |
/** |
|
ds@621
|
277 |
* Pushes a string onto the current call. |
|
ds@621
|
278 |
* |
|
ds@621
|
279 |
* @note Changes to string are not copied back to caller. Use PushStringEx() to do this. |
|
ds@621
|
280 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
281 |
* |
|
ds@621
|
282 |
* @param value String to push. |
|
ds@621
|
283 |
* @noreturn |
|
ds@621
|
284 |
* @error Called before a call has been started. |
|
ds@621
|
285 |
*/ |
|
ds@621
|
286 |
native Call_PushString(const String:value[]); |
|
ds@621
|
287 |
|
|
ds@621
|
288 |
/** |
|
ds@621
|
289 |
* Pushes a string onto the current call. |
|
ds@621
|
290 |
* |
|
ds@621
|
291 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
292 |
* |
|
ds@621
|
293 |
* @param value String to push. |
|
ds@621
|
294 |
* @param length Length of string buffer. |
|
ds@621
|
295 |
* @param szflags Flags determining how string should be handled. |
|
ds@621
|
296 |
* See SP_PARAM_STRING_* constants for details. |
|
ds@621
|
297 |
* @param cpflags Whether or not changes should be copied back to the input array. |
|
ds@621
|
298 |
* See SP_PARAM_* constants for details. |
|
ds@621
|
299 |
* @noreturn |
|
ds@621
|
300 |
* @error Called before a call has been started. |
|
ds@621
|
301 |
*/ |
|
ds@621
|
302 |
native Call_PushStringEx(String:value[], length, szflags, cpflags); |
|
ds@621
|
303 |
|
|
ds@621
|
304 |
/** |
|
ds@621
|
305 |
* Completes a call to a function or forward's call list. |
|
ds@621
|
306 |
* |
|
ds@621
|
307 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
308 |
* |
|
ds@621
|
309 |
* @param result Return value of function or forward's call list. |
|
ds@621
|
310 |
* @return SP_ERROR_NONE on success, any other integer on failure. |
|
ds@621
|
311 |
* @error Called before a call has been started. |
|
ds@621
|
312 |
*/ |
|
dvander@982
|
313 |
native Call_Finish(&any:result=0); |
|
ds@621
|
314 |
|
|
ds@621
|
315 |
/** |
|
ds@621
|
316 |
* Cancels a call to a function or forward's call list. |
|
ds@621
|
317 |
* |
|
ds@621
|
318 |
* @note Cannot be used before a call has been started. |
|
ds@621
|
319 |
* |
|
ds@621
|
320 |
* @noreturn |
|
ds@621
|
321 |
* @error Called before a call has been started. |
|
ds@621
|
322 |
*/ |
|
ds@621
|
323 |
native Call_Cancel(); |
|
ds@621
|
324 |
|
|
ds@621
|
325 |
/** |
|
dvander@601
|
326 |
* Defines a native function. |
|
dvander@601
|
327 |
* |
|
dvander@601
|
328 |
* It is not necessary to validate the parameter count |
|
dvander@601
|
329 |
* |
|
dvander@601
|
330 |
* @param plugin Handle of the calling plugin. |
|
dvander@601
|
331 |
* @param numParams Number of parameters passed to the native. |
|
dvander@601
|
332 |
* @return Value for the native call to return. |
|
dvander@601
|
333 |
*/ |
|
dvander@601
|
334 |
functag NativeCall public(Handle:plugin, numParams); |
|
dvander@601
|
335 |
|
|
dvander@601
|
336 |
/** |
|
dvander@601
|
337 |
* Creates a dynamic native. This should only be called in AskPluginLoad(), or |
|
dvander@601
|
338 |
* else you risk not having your native shared with other plugins. |
|
dvander@601
|
339 |
* |
|
dvander@601
|
340 |
* @param name Name of the dynamic native; must be unique amongst |
|
dvander@764
|
341 |
* all other registered dynamic natives. |
|
dvander@601
|
342 |
* @param func Function to use as the dynamic native. |
|
dvander@601
|
343 |
* @noreturn |
|
dvander@601
|
344 |
*/ |
|
dvander@601
|
345 |
native CreateNative(const String:name[], NativeCall:func); |
|
dvander@601
|
346 |
|
|
dvander@601
|
347 |
/** |
|
dvander@601
|
348 |
* Throws an error in the calling plugin of a native, instead of your own plugin. |
|
dvander@601
|
349 |
* |
|
dvander@601
|
350 |
* @param error Error code to use. |
|
dvander@601
|
351 |
* @param fmt Error message format. |
|
dvander@601
|
352 |
* @param ... Format arguments. |
|
dvander@601
|
353 |
*/ |
|
ds@634
|
354 |
native ThrowNativeError(error, const String:fmt[], any:...); |
|
dvander@601
|
355 |
|
|
dvander@601
|
356 |
/** |
|
dvander@601
|
357 |
* Retrieves the string length from a native parameter string. This is useful |
|
dvander@601
|
358 |
* fetching the entire string using dynamic arrays. |
|
dvander@601
|
359 |
* @note If this function succeeds, Get/SetNativeString will also succeed. |
|
dvander@601
|
360 |
* |
|
dvander@601
|
361 |
* @param param Parameter number, starting from 1. |
|
dvander@601
|
362 |
* @param length Stores the length of the string. |
|
ds@621
|
363 |
* @return SP_ERROR_NONE on success, any other integer on failure. |
|
dvander@601
|
364 |
* @error Invalid parameter number or calling from a non-native function. |
|
dvander@601
|
365 |
*/ |
|
dvander@601
|
366 |
native GetNativeStringLength(param, &length); |
|
dvander@601
|
367 |
|
|
dvander@601
|
368 |
/** |
|
dvander@601
|
369 |
* Retrieves a string from a native parameter. |
|
dvander@601
|
370 |
* @note Output conditions are undefined on failure. |
|
dvander@601
|
371 |
* |
|
dvander@601
|
372 |
* @param param Parameter number, starting from 1. |
|
dvander@601
|
373 |
* @param buffer Buffer to store the string in. |
|
dvander@601
|
374 |
* @param maxlength Maximum length of the buffer. |
|
dvander@601
|
375 |
* @param bytes Optionally store the number of bytes written. |
|
dvander@601
|
376 |
* @return SP_ERROR_NONE on success, any other integer on failure. |
|
dvander@601
|
377 |
* @error Invalid parameter number or calling from a non-native function. |
|
dvander@601
|
378 |
*/ |
|
dvander@601
|
379 |
native GetNativeString(param, String:buffer[], maxlength, &bytes=0); |
|
dvander@601
|
380 |
|
|
dvander@601
|
381 |
/** |
|
dvander@601
|
382 |
* Sets a string in a native parameter. |
|
dvander@601
|
383 |
* @note Output conditions are undefined on failure. |
|
dvander@601
|
384 |
* |
|
dvander@601
|
385 |
* @param param Parameter number, starting from 1. |
|
dvander@601
|
386 |
* @param source Source string to use. |
|
dvander@601
|
387 |
* @param maxlength Maximum number of bytes to write. |
|
dvander@601
|
388 |
* @param utf8 If false, string will not be written |
|
dvander@601
|
389 |
* with UTF8 safety. |
|
dvander@601
|
390 |
* @param bytes Optionally store the number of bytes written. |
|
dvander@601
|
391 |
* @return SP_ERROR_NONE on success, any other integer on failure. |
|
dvander@601
|
392 |
* @error Invalid parameter number or calling from a non-native function. |
|
dvander@601
|
393 |
*/ |
|
dvander@601
|
394 |
native SetNativeString(param, const String:source[], maxlength, bool:utf8=true, &bytes=0); |
|
dvander@601
|
395 |
|
|
dvander@601
|
396 |
/** |
|
dvander@601
|
397 |
* Gets a cell from a native parameter. |
|
dvander@601
|
398 |
* |
|
dvander@601
|
399 |
* @param param Parameter number, starting from 1. |
|
dvander@601
|
400 |
* @return Cell value at the parameter number. |
|
dvander@601
|
401 |
* @error Invalid parameter number or calling from a non-native function. |
|
dvander@601
|
402 |
*/ |
|
ds@872
|
403 |
native any:GetNativeCell(param); |
|
dvander@601
|
404 |
|
|
dvander@601
|
405 |
/** |
|
dvander@601
|
406 |
* Gets a cell from a native parameter, by reference. |
|
dvander@601
|
407 |
* |
|
dvander@601
|
408 |
* @param param Parameter number, starting from 1. |
|
dvander@601
|
409 |
* @return Cell value at the parameter number. |
|
dvander@601
|
410 |
* @error Invalid parameter number or calling from a non-native function. |
|
dvander@601
|
411 |
*/ |
|
ds@872
|
412 |
native any:GetNativeCellRef(param); |
|
dvander@601
|
413 |
|
|
dvander@601
|
414 |
/** |
|
dvander@601
|
415 |
* Sets a cell from a native parameter, by reference. |
|
dvander@601
|
416 |
* |
|
dvander@601
|
417 |
* @param param Parameter number, starting from 1. |
|
dvander@601
|
418 |
* @param value Cell value at the parameter number to set by reference. |
|
dvander@601
|
419 |
* @noreturn |
|
dvander@601
|
420 |
* @error Invalid parameter number or calling from a non-native function. |
|
dvander@601
|
421 |
*/ |
|
dvander@815
|
422 |
native SetNativeCellRef(param, any:value); |
|
dvander@601
|
423 |
|
|
dvander@601
|
424 |
/** |
|
dvander@601
|
425 |
* Gets an array from a native parameter (always by reference). |
|
dvander@601
|
426 |
* |
|
dvander@601
|
427 |
* @param param Parameter number, starting from 1. |
|
dvander@601
|
428 |
* @param local Local array to copy into. |
|
dvander@601
|
429 |
* @param size Maximum size of local array. |
|
dvander@601
|
430 |
* @return SP_ERROR_NONE on success, anything else on failure. |
|
dvander@601
|
431 |
* @error Invalid parameter number or calling from a non-native function. |
|
dvander@601
|
432 |
*/ |
|
dvander@815
|
433 |
native GetNativeArray(param, any:local[], size); |
|
dvander@601
|
434 |
|
|
dvander@601
|
435 |
/** |
|
dvander@601
|
436 |
* Copies a local array into a native parameter array (always by reference). |
|
dvander@601
|
437 |
* |
|
dvander@601
|
438 |
* @param param Parameter number, starting from 1. |
|
dvander@601
|
439 |
* @param local Local array to copy from. |
|
dvander@601
|
440 |
* @param size Size of the local array to copy. |
|
dvander@601
|
441 |
* @return SP_ERROR_NONE on success, anything else on failure. |
|
dvander@601
|
442 |
* @error Invalid parameter number or calling from a non-native function. |
|
dvander@601
|
443 |
*/ |
|
dvander@815
|
444 |
native SetNativeArray(param, const any:local[], size); |
|
dvander@601
|
445 |
|
|
dvander@601
|
446 |
/** |
|
dvander@601
|
447 |
* Formats a string using parameters from a native. |
|
dvander@601
|
448 |
* |
|
dvander@601
|
449 |
* @note All parameter indexes start at 1. |
|
dvander@601
|
450 |
* @note If the input and output buffers overlap, the contents |
|
dvander@601
|
451 |
* of the output buffer at the end is undefined. |
|
dvander@601
|
452 |
* |
|
dvander@601
|
453 |
* @param out_param Output parameter number to write to. If 0, out_string is used. |
|
dvander@601
|
454 |
* @param fmt_param Format parameter number. If 0, fmt_string is used. |
|
dvander@601
|
455 |
* @param vararg_param First variable parameter number. |
|
dvander@601
|
456 |
* @param out_len Output string buffer maximum length (always required). |
|
dvander@601
|
457 |
* @param written Optionally stores the number of bytes written. |
|
dvander@601
|
458 |
* @param out_string Output string buffer to use if out_param is not used. |
|
dvander@601
|
459 |
* @param fmt_string Format string to use if fmt_param is not used. |
|
dvander@601
|
460 |
* @return SP_ERROR_NONE on success, anything else on failure. |
|
dvander@601
|
461 |
*/ |
|
dvander@601
|
462 |
native FormatNativeString(out_param, |
|
dvander@601
|
463 |
fmt_param, |
|
dvander@601
|
464 |
vararg_param, |
|
dvander@601
|
465 |
out_len, |
|
dvander@601
|
466 |
&written=0, |
|
dvander@601
|
467 |
String:out_string[]="", |
|
dvander@601
|
468 |
const String:fmt_string[]=""); |
|
dvander@601
|
469 |
|
|
ds@872
|
470 |
/** |
|
ds@872
|
471 |
* Backwards compatibility stock - use GetNativeCell or GetNativeCellRef |
|
ds@872
|
472 |
* |
|
ds@872
|
473 |
* @deprecated |
|
ds@872
|
474 |
*/ |
|
ds@1268
|
475 |
#pragma deprecated Use GetNativeCell() or GetNativeCellRef() instead |
|
dvander@601
|
476 |
stock Float:GetNativeFloat(param, bool:byref) |
|
dvander@601
|
477 |
{ |
|
dvander@601
|
478 |
if (!byref) |
|
dvander@601
|
479 |
{ |
|
dvander@601
|
480 |
return Float:GetNativeCell(param); |
|
dvander@601
|
481 |
} else { |
|
dvander@601
|
482 |
return Float:GetNativeCellRef(param); |
|
dvander@601
|
483 |
} |
|
dvander@601
|
484 |
} |
|
ds@872
|
485 |
|
|
ds@872
|
486 |
/** |
|
ds@872
|
487 |
* Backwards compatibility stock - use GetNativeCell or GetNativeCellRef |
|
ds@872
|
488 |
* |
|
ds@872
|
489 |
* @deprecated |
|
ds@872
|
490 |
*/ |
|
ds@1268
|
491 |
#pragma deprecated Use GetNativeCell() or GetNativeCellRef() instead |
|
dvander@601
|
492 |
stock Handle:GetNativeHandle(param, bool:byref) |
|
dvander@601
|
493 |
{ |
|
dvander@601
|
494 |
if (!byref) |
|
dvander@601
|
495 |
{ |
|
dvander@601
|
496 |
return Handle:GetNativeCell(param); |
|
dvander@601
|
497 |
} else { |
|
dvander@601
|
498 |
return Handle:GetNativeCellRef(param); |
|
dvander@601
|
499 |
} |
|
dvander@601
|
500 |
} |