plugins/include/functions.inc
author Scott Ehlert <ds@alliedmods.net>
Thu Apr 05 11:02:22 2007 +0000 (2007-04-05)
changeset 672 7af471aaf349
parent 635 3746a1c38c77
child 764 6f561fdaa18d
permissions -rw-r--r--
Added LANG_SERVER constant to lang.inc
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
 */
ds@621
   214
native Call_PushCell({Handle,Function,_}: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
 */
ds@621
   225
native Call_PushCellRef(&{Handle,Function,_}:value);
ds@621
   226
ds@621
   227
ds@621
   228
/**
ds@621
   229
 * Pushes a float onto the current call.
ds@621
   230
 *
ds@621
   231
 * @note Cannot be used before a call has been started.
ds@621
   232
 *
ds@621
   233
 * @param value				Floating point value to push.
ds@621
   234
 * @noreturn
ds@621
   235
 * @error					Called before a call has been started.
ds@621
   236
 */
ds@621
   237
native Call_PushFloat(Float:value);
ds@621
   238
ds@621
   239
/**
ds@621
   240
 * Pushes a float by reference onto the current call.
ds@621
   241
 *
ds@621
   242
 * @note Cannot be used before a call has been started.
ds@621
   243
 *
ds@621
   244
 * @param value				Floating point reference to push.
ds@621
   245
 * @noreturn
ds@621
   246
 * @error					Called before a call has been started.
ds@621
   247
 */
ds@621
   248
native Call_PushFloatRef(&Float:value);
ds@621
   249
ds@621
   250
/**
ds@621
   251
 * Pushes an array onto the current call.
ds@621
   252
 *
ds@621
   253
 * @note Changes to array are not copied back to caller. Use PushArrayEx() to do this.
ds@621
   254
 * @note Cannot be used before a call has been started.
ds@621
   255
 *
ds@621
   256
 * @param value				Array to push.
ds@621
   257
 * @param size				Size of array.
ds@621
   258
 * @noreturn
ds@621
   259
 * @error					Called before a call has been started.
ds@621
   260
 */
ds@621
   261
native Call_PushArray(const {Handle,Float,Function,_}:value[], size);
ds@621
   262
ds@621
   263
/**
ds@621
   264
 * Pushes an array onto the current call.
ds@621
   265
 *
ds@621
   266
 * @note Cannot be used before a call has been started.
ds@621
   267
 *
ds@621
   268
 * @param value				Array to push.
ds@621
   269
 * @param size				Size of array.
ds@621
   270
 * @param cpflags			Whether or not changes should be copied back to the input array.
ds@621
   271
 *							See SP_PARAM_* constants for details.
ds@621
   272
 * @noreturn
ds@621
   273
 * @error					Called before a call has been started.
ds@621
   274
 */
ds@621
   275
native Call_PushArrayEx({Handle,Float,Function,_}:value[], size, cpflags);
ds@621
   276
ds@621
   277
/**
ds@621
   278
 * Pushes a string onto the current call.
ds@621
   279
 *
ds@621
   280
 * @note Changes to string are not copied back to caller. Use PushStringEx() to do this.
ds@621
   281
 * @note Cannot be used before a call has been started.
ds@621
   282
 *
ds@621
   283
 * @param value				String to push.
ds@621
   284
 * @noreturn
ds@621
   285
 * @error					Called before a call has been started.
ds@621
   286
 */
ds@621
   287
native Call_PushString(const String:value[]);
ds@621
   288
ds@621
   289
/**
ds@621
   290
 * Pushes a string onto the current call.
ds@621
   291
 *
ds@621
   292
 * @note Cannot be used before a call has been started.
ds@621
   293
 *
ds@621
   294
 * @param value				String to push.
ds@621
   295
 * @param length			Length of string buffer.
ds@621
   296
 * @param szflags			Flags determining how string should be handled.
ds@621
   297
 *							See SP_PARAM_STRING_* constants for details.
ds@621
   298
 * @param cpflags			Whether or not changes should be copied back to the input array.
ds@621
   299
 *							See SP_PARAM_* constants for details.		
ds@621
   300
 * @noreturn
ds@621
   301
 * @error					Called before a call has been started.
ds@621
   302
 */
ds@621
   303
native Call_PushStringEx(String:value[], length, szflags, cpflags);
ds@621
   304
ds@621
   305
/**
ds@621
   306
 * Completes a call to a function or forward's call list.
ds@621
   307
 *
ds@621
   308
 * @note Cannot be used before a call has been started.
ds@621
   309
 *
ds@621
   310
 * @param result			Return value of function or forward's call list.		
ds@621
   311
 * @return					SP_ERROR_NONE on success, any other integer on failure.
ds@621
   312
 * @error					Called before a call has been started.
ds@621
   313
 */
ds@621
   314
native Call_Finish(&result);
ds@621
   315
ds@621
   316
/**
ds@621
   317
 * Cancels a call to a function or forward's call list.
ds@621
   318
 *
ds@621
   319
 * @note Cannot be used before a call has been started.
ds@621
   320
 *		
ds@621
   321
 * @noreturn
ds@621
   322
 * @error					Called before a call has been started.
ds@621
   323
 */
ds@621
   324
native Call_Cancel();
ds@621
   325
ds@621
   326
/**
dvander@601
   327
 * Defines a native function.
dvander@601
   328
 *
dvander@601
   329
 * It is not necessary to validate the parameter count 
dvander@601
   330
 *
dvander@601
   331
 * @param plugin			Handle of the calling plugin.
dvander@601
   332
 * @param numParams			Number of parameters passed to the native.
dvander@601
   333
 * @return 					Value for the native call to return.
dvander@601
   334
 */
dvander@601
   335
functag NativeCall public(Handle:plugin, numParams);
dvander@601
   336
dvander@601
   337
/**
dvander@601
   338
 * Creates a dynamic native.  This should only be called in AskPluginLoad(), or 
dvander@601
   339
 * else you risk not having your native shared with other plugins.
dvander@601
   340
 *
dvander@601
   341
 * @param name				Name of the dynamic native; must be unique amongst
dvander@601
   342
 *							all other registered dynamic native.s
dvander@601
   343
 * @param func				Function to use as the dynamic native.
dvander@601
   344
 * @noreturn
dvander@601
   345
 */
dvander@601
   346
native CreateNative(const String:name[], NativeCall:func);
dvander@601
   347
dvander@601
   348
/**
dvander@601
   349
 * Throws an error in the calling plugin of a native, instead of your own plugin.
dvander@601
   350
 *
dvander@601
   351
 * @param error				Error code to use.
dvander@601
   352
 * @param fmt				Error message format.
dvander@601
   353
 * @param ...				Format arguments.
dvander@601
   354
 */
ds@634
   355
native ThrowNativeError(error, const String:fmt[], any:...);
dvander@601
   356
dvander@601
   357
/**
dvander@601
   358
 * Retrieves the string length from a native parameter string.  This is useful 
dvander@601
   359
 * fetching the entire string using dynamic arrays.
dvander@601
   360
 * @note If this function succeeds, Get/SetNativeString will also succeed.
dvander@601
   361
 *
dvander@601
   362
 * @param param				Parameter number, starting from 1.
dvander@601
   363
 * @param length			Stores the length of the string.
ds@621
   364
 * @return					SP_ERROR_NONE on success, any other integer on failure.
dvander@601
   365
 * @error					Invalid parameter number or calling from a non-native function.
dvander@601
   366
 */
dvander@601
   367
native GetNativeStringLength(param, &length);
dvander@601
   368
dvander@601
   369
/**
dvander@601
   370
 * Retrieves a string from a native parameter.
dvander@601
   371
 * @note Output conditions are undefined on failure.
dvander@601
   372
 *
dvander@601
   373
 * @param param				Parameter number, starting from 1.
dvander@601
   374
 * @param buffer			Buffer to store the string in.
dvander@601
   375
 * @param maxlength			Maximum length of the buffer.
dvander@601
   376
 * @param bytes				Optionally store the number of bytes written.
dvander@601
   377
 * @return					SP_ERROR_NONE on success, any other integer on failure.
dvander@601
   378
 * @error					Invalid parameter number or calling from a non-native function.
dvander@601
   379
 */
dvander@601
   380
native GetNativeString(param, String:buffer[], maxlength, &bytes=0);
dvander@601
   381
dvander@601
   382
/**
dvander@601
   383
 * Sets a string in a native parameter.
dvander@601
   384
 * @note Output conditions are undefined on failure.
dvander@601
   385
 *
dvander@601
   386
 * @param param				Parameter number, starting from 1.
dvander@601
   387
 * @param source			Source string to use.
dvander@601
   388
 * @param maxlength			Maximum number of bytes to write.
dvander@601
   389
 * @param utf8				If false, string will not be written
dvander@601
   390
 *							with UTF8 safety.
dvander@601
   391
 * @param bytes				Optionally store the number of bytes written.
dvander@601
   392
 * @return					SP_ERROR_NONE on success, any other integer on failure.
dvander@601
   393
 * @error					Invalid parameter number or calling from a non-native function.
dvander@601
   394
 */
dvander@601
   395
native SetNativeString(param, const String:source[], maxlength, bool:utf8=true, &bytes=0);
dvander@601
   396
dvander@601
   397
/**
dvander@601
   398
 * Gets a cell from a native parameter.
dvander@601
   399
 *
dvander@601
   400
 * @param param				Parameter number, starting from 1.
dvander@601
   401
 * @return					Cell value at the parameter number.
dvander@601
   402
 * @error					Invalid parameter number or calling from a non-native function.
dvander@601
   403
 */
dvander@601
   404
native GetNativeCell(param);
dvander@601
   405
dvander@601
   406
/**
dvander@601
   407
 * Gets a cell from a native parameter, by reference.
dvander@601
   408
 *
dvander@601
   409
 * @param param				Parameter number, starting from 1.
dvander@601
   410
 * @return					Cell value at the parameter number.
dvander@601
   411
 * @error					Invalid parameter number or calling from a non-native function.
dvander@601
   412
 */
dvander@601
   413
native GetNativeCellRef(param);
dvander@601
   414
dvander@601
   415
/**
dvander@601
   416
 * Sets a cell from a native parameter, by reference.
dvander@601
   417
 *
dvander@601
   418
 * @param param				Parameter number, starting from 1.
dvander@601
   419
 * @param value				Cell value at the parameter number to set by reference.
dvander@601
   420
 * @noreturn
dvander@601
   421
 * @error					Invalid parameter number or calling from a non-native function.
dvander@601
   422
 */
ds@621
   423
native SetNativeCellRef(param, {Float,Function,Handle,_}:value);
dvander@601
   424
dvander@601
   425
/**
dvander@601
   426
 * Gets an array from a native parameter (always by reference).
dvander@601
   427
 *
dvander@601
   428
 * @param param				Parameter number, starting from 1.
dvander@601
   429
 * @param local				Local array to copy into.
dvander@601
   430
 * @param size				Maximum size of local array.
dvander@601
   431
 * @return					SP_ERROR_NONE on success, anything else on failure.
dvander@601
   432
 * @error					Invalid parameter number or calling from a non-native function.
dvander@601
   433
 */
ds@621
   434
native GetNativeArray(param, {Float,Function,Handle,_}:local[], size);
dvander@601
   435
dvander@601
   436
/**
dvander@601
   437
 * Copies a local array into a native parameter array (always by reference).
dvander@601
   438
 * 
dvander@601
   439
 * @param param				Parameter number, starting from 1.
dvander@601
   440
 * @param local				Local array to copy from.
dvander@601
   441
 * @param size				Size of the local array to copy.
dvander@601
   442
 * @return					SP_ERROR_NONE on success, anything else on failure.
dvander@601
   443
 * @error					Invalid parameter number or calling from a non-native function.
dvander@601
   444
 */
ds@621
   445
native SetNativeArray(param, const {Float,Function,Handle,_}:local[], size);
dvander@601
   446
dvander@601
   447
/**
dvander@601
   448
 * Formats a string using parameters from a native.
dvander@601
   449
 *
dvander@601
   450
 * @note All parameter indexes start at 1.
dvander@601
   451
 * @note If the input and output buffers overlap, the contents
dvander@601
   452
 *  of the output buffer at the end is undefined.
dvander@601
   453
 *
dvander@601
   454
 * @param out_param			Output parameter number to write to.  If 0, out_string is used.
dvander@601
   455
 * @param fmt_param			Format parameter number.  If 0, fmt_string is used.
dvander@601
   456
 * @param vararg_param		First variable parameter number.
dvander@601
   457
 * @param out_len			Output string buffer maximum length (always required).
dvander@601
   458
 * @param written			Optionally stores the number of bytes written.
dvander@601
   459
 * @param out_string		Output string buffer to use if out_param is not used.
dvander@601
   460
 * @param fmt_string		Format string to use if fmt_param is not used.
dvander@601
   461
 * @return					SP_ERROR_NONE on success, anything else on failure.
dvander@601
   462
 */
dvander@601
   463
native FormatNativeString(out_param, 
dvander@601
   464
						  fmt_param, 
dvander@601
   465
						  vararg_param, 
dvander@601
   466
						  out_len,
dvander@601
   467
						  &written=0,
dvander@601
   468
						  String:out_string[]="",
dvander@601
   469
						  const String:fmt_string[]="");
dvander@601
   470
dvander@601
   471
stock Float:GetNativeFloat(param, bool:byref)
dvander@601
   472
{
dvander@601
   473
	if (!byref)
dvander@601
   474
	{
dvander@601
   475
		return Float:GetNativeCell(param);
dvander@601
   476
	} else {
dvander@601
   477
		return Float:GetNativeCellRef(param);
dvander@601
   478
	}
dvander@601
   479
}
dvander@601
   480
stock Handle:GetNativeHandle(param, bool:byref)
dvander@601
   481
{
dvander@601
   482
	if (!byref)
dvander@601
   483
	{
dvander@601
   484
		return Handle:GetNativeCell(param);
dvander@601
   485
	} else {
dvander@601
   486
		return Handle:GetNativeCellRef(param);
dvander@601
   487
	}
dvander@601
   488
}