|
| 1 | +/** |
| 2 | + * vim: set ts=4 : |
| 3 | + * ============================================================================= |
| 4 | + * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. |
| 5 | + * ============================================================================= |
| 6 | + * |
| 7 | + * This file is part of the SourceMod/SourcePawn SDK. |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify it under |
| 10 | + * the terms of the GNU General Public License, version 3.0, as published by the |
| 11 | + * Free Software Foundation. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | + * details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU General Public License along with |
| 19 | + * this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + * |
| 21 | + * As a special exception, AlliedModders LLC gives you permission to link the |
| 22 | + * code of this program (as well as its derivative works) to "Half-Life 2," the |
| 23 | + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
| 24 | + * by the Valve Corporation. You must obey the GNU General Public License in |
| 25 | + * all respects for all other code used. Additionally, AlliedModders LLC grants |
| 26 | + * this exception to all derivative works. AlliedModders LLC defines further |
| 27 | + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
| 28 | + * or <http://www.sourcemod.net/license.php>. |
| 29 | + * |
| 30 | + * Version: $Id$ |
| 31 | + */ |
| 32 | + |
| 33 | +#if defined _handles_included |
| 34 | + #endinput |
| 35 | +#endif |
| 36 | +#define _handles_included |
| 37 | + |
| 38 | +/** |
| 39 | + * Preset Handle values. |
| 40 | + */ |
| 41 | +enum Handle // Tag disables introducing "Handle" as a symbol. |
| 42 | +{ |
| 43 | + INVALID_HANDLE = 0 |
| 44 | +}; |
| 45 | + |
| 46 | + |
| 47 | +/** |
| 48 | + * Closes a Handle. If the handle has multiple copies open, |
| 49 | + * it is not destroyed unless all copies are closed. |
| 50 | + * |
| 51 | + * @note Closing a Handle has a different meaning for each Handle type. Make |
| 52 | + * sure you read the documentation on whatever provided the Handle. |
| 53 | + * |
| 54 | + * @param hndl Handle to close. |
| 55 | + * @error Invalid handles will cause a run time error. |
| 56 | + */ |
| 57 | +native void CloseHandle(Handle hndl); |
| 58 | + |
| 59 | +/** |
| 60 | + * Clones a Handle. When passing handles in between plugins, caching handles |
| 61 | + * can result in accidental invalidation when one plugin releases the Handle, or is its owner |
| 62 | + * is unloaded from memory. To prevent this, the Handle may be "cloned" with a new owner. |
| 63 | + * |
| 64 | + * @note Usually, you will be cloning Handles for other plugins. This means that if you clone |
| 65 | + * the Handle without specifying the new owner, it will assume the identity of your original |
| 66 | + * calling plugin, which is not very useful. You should either specify that the receiving |
| 67 | + * plugin should clone the handle on its own, or you should explicitly clone the Handle |
| 68 | + * using the receiving plugin's identity Handle. |
| 69 | + * |
| 70 | + * @param hndl Handle to clone/duplicate. |
| 71 | + * @param plugin Optional Handle to another plugin to mark as the new owner. |
| 72 | + * If no owner is passed, the owner becomes the calling plugin. |
| 73 | + * @return Handle on success, INVALID_HANDLE if not cloneable. |
| 74 | + * @error Invalid handles will cause a run time error. |
| 75 | + */ |
| 76 | +native Handle CloneHandle(Handle hndl, Handle plugin=INVALID_HANDLE); |
| 77 | + |
| 78 | +methodmap Handle __nullable__ { |
| 79 | + public native ~Handle(); |
| 80 | + |
| 81 | + /** |
| 82 | + * Closes a Handle. If the handle has multiple copies open, |
| 83 | + * it is not destroyed unless all copies are closed. |
| 84 | + * |
| 85 | + * @note Closing a Handle has a different meaning for each Handle type. Make |
| 86 | + * sure you read the documentation on whatever provided the Handle. |
| 87 | + * |
| 88 | + * @error Invalid handles will cause a run time error. |
| 89 | + */ |
| 90 | + public native void Close(); |
| 91 | + |
| 92 | + /** |
| 93 | + * Clones a Handle. When passing handles in between plugins, caching handles |
| 94 | + * can result in accidental invalidation when one plugin releases the Handle, or is its owner |
| 95 | + * is unloaded from memory. To prevent this, the Handle may be "cloned" with a new owner. |
| 96 | + * |
| 97 | + * @note Usually, you will be cloning Handles for other plugins. This means that if you clone |
| 98 | + * the Handle without specifying the new owner, it will assume the identity of your original |
| 99 | + * calling plugin, which is not very useful. You should either specify that the receiving |
| 100 | + * plugin should clone the handle on its own, or you should explicitly clone the Handle |
| 101 | + * using the receiving plugin's identity Handle. |
| 102 | + * |
| 103 | + * @param plugin Optional Handle to another plugin to mark as the new owner. |
| 104 | + * If no owner is passed, the owner becomes the calling plugin. |
| 105 | + * @return Handle on success, INVALID_HANDLE if not cloneable. |
| 106 | + * @error Invalid handles will cause a run time error. |
| 107 | + */ |
| 108 | + public native Handle Clone(Handle plugin=INVALID_HANDLE); |
| 109 | +}; |
| 110 | + |
| 111 | +/** |
| 112 | + * Do not use this function. Returns if a Handle and its contents |
| 113 | + * are readable, whereas INVALID_HANDLE only checks for the absence |
| 114 | + * of a Handle. |
| 115 | + * |
| 116 | + * This function is intended only for tests where the validity of a |
| 117 | + * Handle can absolutely not be known. |
| 118 | + * |
| 119 | + * Do not use this to check the return values of functions, or to |
| 120 | + * check if timers should be closed (except in very rare cases). |
| 121 | + * This function is for very specific usage and using it for general |
| 122 | + * purpose routines can and will hide very subtle bugs. |
| 123 | + * |
| 124 | + * @param hndl Handle to test for validity. |
| 125 | + * @return True if handle is valid, false otherwise. |
| 126 | + * @deprecated Do not use this function. |
| 127 | + */ |
| 128 | +#pragma deprecated Do not use this function. |
| 129 | +native bool IsValidHandle(Handle hndl); |
0 commit comments