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