diff --git a/core/logic/smn_handles.cpp b/core/logic/smn_handles.cpp index d0834594..a7e910a1 100644 --- a/core/logic/smn_handles.cpp +++ b/core/logic/smn_handles.cpp @@ -53,6 +53,10 @@ static cell_t sm_IsValidHandle(IPluginContext *pContext, const cell_t *params) static cell_t sm_CloseHandle(IPluginContext *pContext, const cell_t *params) { Handle_t hndl = static_cast(params[1]); + + if (!hndl) + return 0; + HandleSecurity sec; sec.pIdentity = NULL; diff --git a/core/smn_keyvalues.cpp b/core/smn_keyvalues.cpp index 5da08c76..5fa49582 100644 --- a/core/smn_keyvalues.cpp +++ b/core/smn_keyvalues.cpp @@ -797,6 +797,32 @@ static cell_t smn_FileToKeyValues(IPluginContext *pCtx, const cell_t *params) return g_HL2.KVLoadFromFile(kv, basefilesystem, path); } +static cell_t smn_StringToKeyValues(IPluginContext *pCtx, const cell_t *params) +{ + Handle_t hndl = static_cast(params[1]); + HandleError herr; + HandleSecurity sec; + KeyValueStack *pStk; + KeyValues *kv; + + sec.pOwner = NULL; + sec.pIdentity = g_pCoreIdent; + + if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) + != HandleError_None) + { + return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); + } + + char *buffer; + char *resourceName; + pCtx->LocalToString(params[2], &buffer); + pCtx->LocalToString(params[3], &resourceName); + + kv = pStk->pCurRoot.front(); + return kv->LoadFromBuffer(resourceName, buffer); +} + static cell_t smn_KvSetEscapeSequences(IPluginContext *pCtx, const cell_t *params) { Handle_t hndl = static_cast(params[1]); @@ -1101,6 +1127,7 @@ REGISTER_NATIVES(keyvaluenatives) {"KvGetDataType", smn_KvGetDataType}, {"KeyValuesToFile", smn_KeyValuesToFile}, {"FileToKeyValues", smn_FileToKeyValues}, + {"StringToKeyValues", smn_StringToKeyValues}, {"KvSetEscapeSequences", smn_KvSetEscapeSequences}, {"KvDeleteThis", smn_KvDeleteThis}, {"KvDeleteKey", smn_KvDeleteKey}, @@ -1113,4 +1140,4 @@ REGISTER_NATIVES(keyvaluenatives) {"KvGetVector", smn_KvGetVector}, {"KvSetVector", smn_KvSetVector}, {NULL, NULL} -}; +}; \ No newline at end of file diff --git a/plugins/include/adt_array.inc b/plugins/include/adt_array.inc index 48d43be6..f13a1e1a 100644 --- a/plugins/include/adt_array.inc +++ b/plugins/include/adt_array.inc @@ -68,7 +68,7 @@ stock ByteCountToCells(size) * NOT be auto-intialized. * @return New Handle to the array object. */ -native Handle:CreateArray(blocksize=1, startsize=0); +native ArrayList:CreateArray(blocksize=1, startsize=0); /** * Clears an array of all entries. This is the same as ResizeArray(0). @@ -281,3 +281,27 @@ native FindStringInArray(Handle:array, const String:item[]); * @error Invalid Handle */ native FindValueInArray(Handle:array, any:item); + +methodmap ArrayList < Handle { + public ArrayList() = CreateArray; + public Clear() = ClearArray; + public Clone() = CloneArray; + public Resize() = ResizeArray; + public Push() = PushArrayCell; + public PushString() = PushArrayString; + public PushArray() = PushArrayArray; + public Get() = GetArrayCell; + public GetString() = GetArrayString; + public GetArray() = GetArrayArray; + public Set() = SetArrayCell; + public SetString() = SetArrayString; + public SetArray() = SetArrayArray; + public ShiftUp() = ShiftArrayUp; + public Erase() = RemoveFromArray; + public SwapAt() = SwapArrayItems; + public FindString() = FindStringInArray; + public FindValue() = FindValueInArray; + property int Length { + public get() = GetArraySize; + } +}; diff --git a/plugins/include/clients.inc b/plugins/include/clients.inc index 3627e971..174ca0ad 100644 --- a/plugins/include/clients.inc +++ b/plugins/include/clients.inc @@ -80,7 +80,7 @@ forward bool:OnClientConnect(client, String:rejectmsg[], maxlen); * @param client Client index. * @noreturn */ -forward OnClientConnected(client); +forward void OnClientConnected(client); /** * Called when a client is entering the game. @@ -96,7 +96,7 @@ forward OnClientConnected(client); * @param client Client index. * @noreturn */ -forward OnClientPutInServer(client); +forward void OnClientPutInServer(client); /** * Called when a client is disconnecting from the server. @@ -104,7 +104,7 @@ forward OnClientPutInServer(client); * @param client Client index. * @noreturn */ -forward OnClientDisconnect(client); +forward void OnClientDisconnect(client); /** * Called when a client is disconnected from the server. @@ -112,7 +112,7 @@ forward OnClientDisconnect(client); * @param client Client index. * @noreturn */ -forward OnClientDisconnect_Post(client); +forward void OnClientDisconnect_Post(client); /** * Called when a client is sending a command. @@ -132,7 +132,7 @@ forward Action:OnClientCommand(client, args); * @param client Client index. * @noreturn */ -forward OnClientSettingsChanged(client); +forward void OnClientSettingsChanged(client); /** * Called when a client receives a Steam ID. The state of a client's @@ -145,7 +145,7 @@ forward OnClientSettingsChanged(client); * @param auth Client auth string. * @noreturn */ -forward OnClientAuthorized(client, const String:auth[]); +forward void OnClientAuthorized(client, const String:auth[]); /** * Called once a client is authorized and fully in-game, but @@ -180,7 +180,7 @@ forward Action:OnClientPreAdminCheck(client); * @param client Client index. * @noreturn */ -forward OnClientPostAdminFilter(client); +forward void OnClientPostAdminFilter(client); /** * Called once a client is authorized and fully in-game, and @@ -192,7 +192,7 @@ forward OnClientPostAdminFilter(client); * @param client Client index. * @noreturn */ -forward OnClientPostAdminCheck(client); +forward void OnClientPostAdminCheck(client); /** * This function will be deprecated in a future release. Use the MaxClients variable instead. diff --git a/plugins/include/console.inc b/plugins/include/console.inc index f7dd9900..215c124b 100644 --- a/plugins/include/console.inc +++ b/plugins/include/console.inc @@ -968,4 +968,4 @@ forward Action:OnClientSayCommand(client, const String:command[], const String:s * @param sArgs Chat argument string. * */ -forward OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]); +forward void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs); diff --git a/plugins/include/keyvalues.inc b/plugins/include/keyvalues.inc index c607d7d3..d293ecae 100644 --- a/plugins/include/keyvalues.inc +++ b/plugins/include/keyvalues.inc @@ -360,6 +360,18 @@ native bool:KeyValuesToFile(Handle:kv, const String:file[]); */ native bool:FileToKeyValues(Handle:kv, const String:file[]); +/** + * Converts a given string to a KeyValues tree. The string is read into + * the current postion of the tree. + * + * @param kv KeyValues Handle. + * @param buffer String buffer to load into the KeyValues. + * @param resourceName The resource name of the KeyValues, used for error tracking purposes. + * @return True on success, false otherwise. + * @error Invalid Handle. + */ +native bool:StringToKeyValues(Handle:kv, const String:buffer[], const String:resourceName[]="StringToKeyValues"); + /** * Sets whether or not the KeyValues parser will read escape sequences. * For example, \n would be read as a literal newline. This defaults diff --git a/plugins/include/mapchooser.inc b/plugins/include/mapchooser.inc index 9f660454..1b89fdeb 100644 --- a/plugins/include/mapchooser.inc +++ b/plugins/include/mapchooser.inc @@ -98,12 +98,12 @@ native bool:EndOfMapVoteEnabled(); * Called when mapchooser removes a nomination from its list. * Nominations cleared on map start will not trigger this forward */ -forward OnNominationRemoved(const String:map[], owner); +forward void OnNominationRemoved(const char[] map, int owner); /** * Called when mapchooser starts a Map Vote. */ -forward OnMapVoteStarted(); +forward void OnMapVoteStarted(); public SharedPlugin:__pl_mapchooser = diff --git a/plugins/include/menus.inc b/plugins/include/menus.inc index 0b3bf50a..7c9551a4 100644 --- a/plugins/include/menus.inc +++ b/plugins/include/menus.inc @@ -152,7 +152,7 @@ enum MenuSource * @param param2 Second action parameter (usually the item). * @noreturn */ -functag public MenuHandler(Handle:menu, MenuAction:action, param1, param2); +functag public MenuHandler(Menu:menu, MenuAction:action, param1, param2); /** * Creates a new, empty menu using the default style. @@ -164,7 +164,7 @@ functag public MenuHandler(Handle:menu, MenuAction:action, param1, param2); * the only default actions. * @return A new menu Handle. */ -native Handle:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT); +native Menu:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT); /** * Displays a menu to a client. @@ -453,7 +453,7 @@ native GetMenuOptionFlags(Handle:menu); * @noreturn * @error Invalid Handle. */ -native SetMenuOptionFlags(Handle:menu, flags); +native void SetMenuOptionFlags(Handle:menu, flags); /** * Returns whether a vote is in progress. @@ -528,7 +528,7 @@ stock bool:VoteMenuToAll(Handle:menu, time, flags=0) * defines. * @noreturn */ -functag public VoteHandler(Handle:menu, +functag public VoteHandler(Menu:menu, num_votes, num_clients, const client_info[][2], @@ -546,6 +546,61 @@ functag public VoteHandler(Handle:menu, */ native SetVoteResultCallback(Handle:menu, VoteHandler:callback); +methodmap Menu < Handle { + public Menu() = CreateMenu; + public Display() = DisplayMenu; + public DisplayAt() = DisplayMenuAtItem; + public AddItem() = AddMenuItem; + public InsertItem() = InsertMenuItem; + public RemoveItem() = RemoveMenuItem; + public RemoveAllItems() = RemoveAllMenuItems; + public GetItem() = GetMenuItem; + public GetTitle() = GetMenuTitle; + public SetTitle() = SetMenuTitle; + public ToPanel() = CreatePanelFromMenu; + public Cancel() = CancelMenu; + public DisplayVote() = VoteMenu; + public DisplayVoteToAll() = VoteMenuToAll; + + property int Pagination { + public get() = GetMenuPagination; + public set(int value) { + SetMenuPagination(this, value); + } + } + property int OptionFlags { + public get() = GetMenuOptionFlags; + public set() = SetMenuOptionFlags; + } + property bool ExitButton { + public get() = GetMenuExitButton; + public set(bool value) { + SetMenuExitButton(this, value); + } + } + property bool ExitBackButton { + public get() = GetMenuExitBackButton; + public set(bool value) { + SetMenuExitBackButton(this, value); + } + } + + public SetNoVoteButton() = SetMenuNoVoteButton; + public SetVoteResultCallback() = SetVoteResultCallback; + + property int ItemCount { + public get() = GetMenuItemCount; + } + property Handle Style { + public get() = GetMenuStyle; + } + property int SelectionPosition { + public get() { + return GetMenuSelectionPosition(); + } + } +}; + /** * Returns the number of seconds you should "wait" before displaying * a publicly invocable menu. This number is the time remaining until diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index 6b1f8d48..eea83eba 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -172,7 +172,7 @@ forward void OnMapStart(); /** * Called right before a map ends. */ -forward OnMapEnd(); +forward void OnMapEnd(); /** * Called when the map has loaded, servercfgfile (server.cfg) has been @@ -201,20 +201,20 @@ forward void OnConfigsExecuted(); * * @noreturn */ -forward OnAutoConfigsBuffered(); +forward void OnAutoConfigsBuffered(); /** * @deprecated Use OnConfigsExecuted() instead. */ #pragma deprecated Use OnConfigsExecuted() instead -forward OnServerCfg(); +forward void OnServerCfg(); /** * Called after all plugins have been loaded. This is called once for * every plugin. If a plugin late loads, it will be called immediately * after OnPluginStart(). */ -forward OnAllPluginsLoaded(); +forward void OnAllPluginsLoaded(); /** * Returns the calling plugin's Handle. @@ -461,7 +461,7 @@ native GetExtensionFileStatus(const String:name[], String:error[]="", maxlength= * * @param name Library name. */ -forward OnLibraryAdded(const String:name[]); +forward void OnLibraryAdded(const String:name[]); /** * Called right before a library is removed that the current plugin references @@ -470,7 +470,7 @@ forward OnLibraryAdded(const String:name[]); * * @param name Library name. */ -forward OnLibraryRemoved(const String:name[]); +forward void OnLibraryRemoved(const String:name[]); #define MAPLIST_FLAG_MAPSFOLDER (1<<0) /**< On failure, use all maps in the maps folder. */ #define MAPLIST_FLAG_CLEARARRAY (1<<1) /**< If an input array is specified, clear it before adding. */ @@ -564,7 +564,7 @@ forward bool:OnClientFloodCheck(client); * @param blocked True if client flooded last "say", false otherwise. * @noreturn */ -forward OnClientFloodResult(client, bool:blocked); +forward void OnClientFloodResult(client, bool:blocked); /** * Feature types. diff --git a/plugins/nominations.sp b/plugins/nominations.sp index daca5c9b..1cf6078f 100644 --- a/plugins/nominations.sp +++ b/plugins/nominations.sp @@ -35,8 +35,9 @@ #include #pragma semicolon 1 +#pragma newdecls required -public Plugin:myinfo = +public Plugin myinfo = { name = "Map Nominations", author = "AlliedModders LLC", @@ -45,12 +46,12 @@ public Plugin:myinfo = url = "http://www.sourcemod.net/" }; -new Handle:g_Cvar_ExcludeOld = INVALID_HANDLE; -new Handle:g_Cvar_ExcludeCurrent = INVALID_HANDLE; +Handle g_Cvar_ExcludeOld = null; +Handle g_Cvar_ExcludeCurrent = null; -new Handle:g_MapList = INVALID_HANDLE; -new Handle:g_MapMenu = INVALID_HANDLE; -new g_mapFileSerial = -1; +Menu g_MapMenu = null; +Handle g_MapList = null; +int g_mapFileSerial = -1; #define MAPSTATUS_ENABLED (1<<0) #define MAPSTATUS_DISABLED (1<<1) @@ -58,14 +59,14 @@ new g_mapFileSerial = -1; #define MAPSTATUS_EXCLUDE_PREVIOUS (1<<3) #define MAPSTATUS_EXCLUDE_NOMINATED (1<<4) -new Handle:g_mapTrie; +StringMap g_mapTrie = null; -public OnPluginStart() +public void OnPluginStart() { LoadTranslations("common.phrases"); LoadTranslations("nominations.phrases"); - new arraySize = ByteCountToCells(33); + int arraySize = ByteCountToCells(33); g_MapList = CreateArray(arraySize); g_Cvar_ExcludeOld = CreateConVar("sm_nominate_excludeold", "1", "Specifies if the current map should be excluded from the Nominations list", 0, true, 0.00, true, 1.0); @@ -75,10 +76,10 @@ public OnPluginStart() RegAdminCmd("sm_nominate_addmap", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_nominate_addmap - Forces a map to be on the next mapvote."); - g_mapTrie = CreateTrie(); + g_mapTrie = StringMap(); } -public OnConfigsExecuted() +public void OnConfigsExecuted() { if (ReadMapList(g_MapList, g_mapFileSerial, @@ -95,12 +96,12 @@ public OnConfigsExecuted() BuildMapMenu(); } -public OnNominationRemoved(const String:map[], owner) +public void OnNominationRemoved(const char[] map, int owner) { - new status; + int status; /* Is the map in our list? */ - if (!GetTrieValue(g_mapTrie, map, status)) + if (!g_mapTrie.GetValue(map, status)) { return; } @@ -111,10 +112,10 @@ public OnNominationRemoved(const String:map[], owner) return; } - SetTrieValue(g_mapTrie, map, MAPSTATUS_ENABLED); + g_mapTrie.SetValue(map, MAPSTATUS_ENABLED); } -public Action:Command_Addmap(client, args) +public Action Command_Addmap(int client, int args) { if (args < 1) { @@ -122,18 +123,18 @@ public Action:Command_Addmap(client, args) return Plugin_Handled; } - decl String:mapname[64]; + char mapname[64]; GetCmdArg(1, mapname, sizeof(mapname)); - new status; - if (!GetTrieValue(g_mapTrie, mapname, status)) + int status; + if (!g_mapTrie.GetValue(mapname, status)) { ReplyToCommand(client, "%t", "Map was not found", mapname); return Plugin_Handled; } - new NominateResult:result = NominateMap(mapname, true, 0); + NominateResult result = NominateMap(mapname, true, 0); if (result > Nominate_Replaced) { @@ -144,7 +145,7 @@ public Action:Command_Addmap(client, args) } - SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); + g_mapTrie.SetValue(mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); ReplyToCommand(client, "%t", "Map Inserted", mapname); @@ -153,7 +154,7 @@ public Action:Command_Addmap(client, args) return Plugin_Handled; } -public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]) +public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs) { if (!client) { @@ -162,7 +163,7 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg if (strcmp(sArgs, "nominate", false) == 0) { - new ReplySource:old = SetCmdReplySource(SM_REPLY_TO_CHAT); + ReplySource old = SetCmdReplySource(SM_REPLY_TO_CHAT); AttemptNominate(client); @@ -170,7 +171,7 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg } } -public Action:Command_Nominate(client, args) +public Action Command_Nominate(int client, int args) { if (!client) { @@ -183,11 +184,11 @@ public Action:Command_Nominate(client, args) return Plugin_Handled; } - decl String:mapname[64]; + char mapname[64]; GetCmdArg(1, mapname, sizeof(mapname)); - new status; - if (!GetTrieValue(g_mapTrie, mapname, status)) + int status; + if (!g_mapTrie.GetValue(mapname, status)) { ReplyToCommand(client, "%t", "Map was not found", mapname); return Plugin_Handled; @@ -213,7 +214,7 @@ public Action:Command_Nominate(client, args) return Plugin_Handled; } - new NominateResult:result = NominateMap(mapname, false, client); + NominateResult result = NominateMap(mapname, false, client); if (result > Nominate_Replaced) { @@ -231,43 +232,39 @@ public Action:Command_Nominate(client, args) /* Map was nominated! - Disable the menu item and update the trie */ - SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); + g_mapTrie.SetValue(mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); - decl String:name[64]; + char name[64]; GetClientName(client, name, sizeof(name)); PrintToChatAll("[SM] %t", "Map Nominated", name, mapname); return Plugin_Continue; } -AttemptNominate(client) +void AttemptNominate(int client) { - SetMenuTitle(g_MapMenu, "%T", "Nominate Title", client); - DisplayMenu(g_MapMenu, client, MENU_TIME_FOREVER); + g_MapMenu.SetTitle("%T", "Nominate Title", client); + g_MapMenu.Display(client, MENU_TIME_FOREVER); return; } -BuildMapMenu() +void BuildMapMenu() { - if (g_MapMenu != INVALID_HANDLE) - { - CloseHandle(g_MapMenu); - g_MapMenu = INVALID_HANDLE; - } + delete g_MapMenu; - ClearTrie(g_mapTrie); + g_mapTrie.Clear(); - g_MapMenu = CreateMenu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem); + g_MapMenu = Menu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem); - decl String:map[64]; + char map[64]; - new Handle:excludeMaps = INVALID_HANDLE; - decl String:currentMap[32]; + ArrayList excludeMaps; + char currentMap[32]; if (GetConVarBool(g_Cvar_ExcludeOld)) { - excludeMaps = CreateArray(ByteCountToCells(33)); + excludeMaps = ArrayList(ByteCountToCells(33)); GetExcludeMapList(excludeMaps); } @@ -277,9 +274,9 @@ BuildMapMenu() } - for (new i = 0; i < GetArraySize(g_MapList); i++) + for (int i = 0; i < GetArraySize(g_MapList); i++) { - new status = MAPSTATUS_ENABLED; + int status = MAPSTATUS_ENABLED; GetArrayString(g_MapList, i, map, sizeof(map)); @@ -294,36 +291,33 @@ BuildMapMenu() /* Dont bother with this check if the current map check passed */ if (GetConVarBool(g_Cvar_ExcludeOld) && status == MAPSTATUS_ENABLED) { - if (FindStringInArray(excludeMaps, map) != -1) + if (excludeMaps.FindString(map) != -1) { status = MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_PREVIOUS; } } - AddMenuItem(g_MapMenu, map, map); - SetTrieValue(g_mapTrie, map, status); + g_MapMenu.AddItem(map, map); + g_mapTrie.SetValue(map, status); } - - SetMenuExitButton(g_MapMenu, true); - if (excludeMaps != INVALID_HANDLE) - { - CloseHandle(excludeMaps); - } + g_MapMenu.ExitButton = true; + + delete excludeMaps; } -public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2) +public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int param2) { switch (action) { case MenuAction_Select: { - decl String:map[64], String:name[64]; - GetMenuItem(menu, param2, map, sizeof(map)); + char map[64], name[64]; + menu.GetItem(param2, map, sizeof(map)); GetClientName(param1, name, 64); - new NominateResult:result = NominateMap(map, false, param1); + NominateResult result = NominateMap(map, false, param1); /* Don't need to check for InvalidMap because the menu did that already */ if (result == Nominate_AlreadyInVote) @@ -337,7 +331,7 @@ public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2) return 0; } - SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); + g_mapTrie.SetValue(map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); if (result == Nominate_Replaced) { @@ -350,12 +344,12 @@ public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2) case MenuAction_DrawItem: { - decl String:map[64]; - GetMenuItem(menu, param2, map, sizeof(map)); + char map[64]; + menu.GetItem(param2, map, sizeof(map)); - new status; + int status; - if (!GetTrieValue(g_mapTrie, map, status)) + if (!g_mapTrie.GetValue(map, status)) { LogError("Menu selection of item not in trie. Major logic problem somewhere."); return ITEMDRAW_DEFAULT; @@ -372,18 +366,18 @@ public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2) case MenuAction_DisplayItem: { - decl String:map[64]; - GetMenuItem(menu, param2, map, sizeof(map)); + char map[64]; + menu.GetItem(param2, map, sizeof(map)); - new status; + int status; - if (!GetTrieValue(g_mapTrie, map, status)) + if (!g_mapTrie.GetValue(map, status)) { LogError("Menu selection of item not in trie. Major logic problem somewhere."); return 0; } - decl String:display[100]; + char display[100]; if ((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED) { diff --git a/plugins/testsuite/keyvalues.sp b/plugins/testsuite/keyvalues.sp new file mode 100644 index 00000000..bef02fe7 --- /dev/null +++ b/plugins/testsuite/keyvalues.sp @@ -0,0 +1,58 @@ + +#include + +public Plugin:myinfo = +{ + name = "KeyValues test", + author = "AlliedModders LLC", + description = "KeyValues test", + version = SOURCEMOD_VERSION, + url = "http://www.sourcemod.net/" +}; + + +public OnPluginStart() +{ + RegServerCmd("test_keyvalues", RunTests); +} + +public Action:RunTests(argc) +{ + new String:validKv[] = + "\"root\" \ + { \ + \"child\" \"value\" \ + \"subkey\" { \ + subchild subvalue \ + subfloat 1.0 \ + } \ + }"; + + new Handle:kv = CreateKeyValues(""); + + if (!StringToKeyValues(kv, validKv)) + ThrowError("Valid kv not read correctly!"); + + decl String:value[128]; + KvGetString(kv, "child", value, sizeof(value)); + + if (!StrEqual(value, "value")) + ThrowError("Child kv should have 'value' but has: '%s'", value); + + if (!KvJumpToKey(kv, "subkey")) + ThrowError("No sub kv subkey exists!"); + + KvGetString(kv, "subchild", value, sizeof(value)); + + if (!StrEqual(value, "subvalue")) + ThrowError("Subkv subvalue should have 'subvalue' but has: '%s'", value); + + new Float:subfloat = KvGetFloat(kv, "subfloat"); + + if (subfloat != 1.0) + ThrowError( "Subkv subfloat should have 1.0 but has: %f", subfloat) + + CloseHandle(kv); + + PrintToServer("KeyValue tests passed!"); +} diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index d4426084..f1350e04 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -171,6 +171,7 @@ typedef struct s_symbol { #define iREFFUNC 10 #define iVARARGS 11 /* function specified ... as argument(s) */ #define iPROXY 12 /* proxies to another symbol. */ +#define iACCESSOR 13 /* property accessor via a methodmap_method_t */ /* Possible entries for "usage" * @@ -240,6 +241,8 @@ typedef struct s_symbol { #define sSTATEVAR 3 /* criterion to find variables (sSTATEVAR implies a global variable) */ +struct methodmap_method_s; + typedef struct value_s { symbol *sym; /* symbol in symbol table, NULL for (constant) expression */ cell constval; /* value of the constant expression (if ident==iCONSTEXPR) @@ -250,6 +253,9 @@ typedef struct value_s { * iEXPRESSION or iREFERENCE */ char boolresult; /* boolean result for relational operators */ cell *arrayidx; /* last used array indices, for checking self assignment */ + + /* when ident == iACCESSOR */ + struct methodmap_method_s *accessor; } value; /* Wrapper around value + l/rvalue bit. */ @@ -731,6 +737,10 @@ SC_FUNC void charalign(void); SC_FUNC void addconst(cell value); SC_FUNC void setheap_save(cell value); SC_FUNC void stradjust(regid reg); +SC_FUNC void invoke_getter(struct methodmap_method_s *method); +SC_FUNC void invoke_setter(struct methodmap_method_s *method, int save); +SC_FUNC void inc_pri(); +SC_FUNC void dec_pri(); /* Code generation functions for arithmetic operators. * diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 5a439463..593df220 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -3668,9 +3668,10 @@ int parse_property_accessor(const typeinfo_t *type, methodmap_t *map, methodmap_ return FALSE; } - int getter = TRUE; + int getter = (strcmp(ident.name, "get") == 0); + int setter = (strcmp(ident.name, "set") == 0); - if (strcmp(ident.name, "get") != 0) { + if (!getter && !setter) { error(125); return FALSE; } @@ -3692,19 +3693,36 @@ int parse_property_accessor(const typeinfo_t *type, methodmap_t *map, methodmap_ else if (target->ident != iFUNCTN) error(10); } else { + typeinfo_t voidtype; char tmpname[METHOD_NAMEMAX + 1]; strcpy(tmpname, method->name); - strcat(tmpname, ".get"); - target = parse_inline_function(map, type, tmpname, is_native, FALSE, FALSE); + if (getter) + strcat(tmpname, ".get"); + else + strcat(tmpname, ".set"); + + const typeinfo_t *ret_type; + if (getter) { + ret_type = type; + } else { + make_primitive(&voidtype, pc_tag_void); + ret_type = &voidtype; + } + + target = parse_inline_function(map, ret_type, tmpname, is_native, FALSE, FALSE); } if (!target) return FALSE; - if (method->getter) { + if (getter && method->getter) { error(126, "getter", method->name); return FALSE; } + if (setter && method->setter) { + error(126, "setter", method->name); + return FALSE; + } if (getter) { method->getter = target; @@ -3712,17 +3730,43 @@ int parse_property_accessor(const typeinfo_t *type, methodmap_t *map, methodmap_ // Cannot have extra arguments. if (target->dim.arglist[0].ident && target->dim.arglist[1].ident) error(127); - } - // Must return the same tag as the property. - if (type->tag != target->tag) { - const char *kind = getter ? "getter" : "setter"; - error(128, "getter", map->name, type_to_name(type->tag)); - } + if (!check_this_tag(map, target)) { + error(108, layout_spec_name(map->spec), map->name); + return FALSE; + } - if (!check_this_tag(map, target)) { - error(108, layout_spec_name(map->spec), map->name); - return FALSE; + // Must return the same tag as the property. + if (type->tag != target->tag) { + const char *kind = getter ? "getter" : "setter"; + error(128, "getter", map->name, type_to_name(type->tag)); + } + } else { + method->setter = target; + + if (!check_this_tag(map, target)) { + error(108, layout_spec_name(map->spec), map->name); + return FALSE; + } + + // Must have one extra argument taking the return type. + arginfo *arg = &target->dim.arglist[1]; + if (arg->ident == 0 || + arg->ident != iVARIABLE || + arg->hasdefault || + arg->numtags != 1 || + arg->tags[0] != type->tag) + { + error(150, pc_tagname(type->tag)); + return FALSE; + } + if (target->dim.arglist[2].ident) { + error(150, pc_tagname(type->tag)); + return FALSE; + } + + if (target->tag != pc_tag_void) + error(151); } needtoken(tTERM); @@ -3752,10 +3796,8 @@ methodmap_method_t *parse_property(methodmap_t *map) return method; while (!matchtoken('}')) { - if (!parse_property_accessor(&type, map,method)) { - if (!consume_line()) - return NULL; - } + if (!parse_property_accessor(&type, map,method)) + lexclr(TRUE); } needtoken(tTERM); @@ -4106,14 +4148,28 @@ static void dodelete() zap = FALSE; int popaddr = FALSE; + methodmap_method_t *accessor = NULL; if (sval.lvalue) { if (zap) { - if (sval.val.ident == iARRAYCELL || sval.val.ident == iARRAYCHAR) { - // Address is in pri so we have to save it. - pushreg(sPRI); - popaddr = TRUE; + switch (sval.val.ident) { + case iACCESSOR: + // rvalue() removes iACCESSOR so we store it locally. + accessor = sval.val.accessor; + if (!accessor->setter) { + zap = FALSE; + break; + } + pushreg(sPRI); + popaddr = TRUE; + break; + case iARRAYCELL: + case iARRAYCHAR: + pushreg(sPRI); + popaddr = TRUE; + break; } } + rvalue(&sval.val); } @@ -4134,7 +4190,10 @@ static void dodelete() // Store 0 back. ldconst(0, sPRI); - store(&sval.val); + if (accessor) + invoke_setter(accessor, FALSE); + else + store(&sval.val); } markexpr(sEXPR, NULL, 0); @@ -5385,17 +5444,22 @@ static int declargs(symbol *sym, int chkshadow, const int *thistag) fpublic = (sym->usage & (uPUBLIC|uSTOCK))!=0; if (thistag && *thistag != -1) { - // Allocate space for a new argument, then terminate. - sym->dim.arglist = (arginfo *)realloc(sym->dim.arglist, (argcnt + 2) * sizeof(arginfo)); - memset(&sym->dim.arglist[argcnt + 1], 0, sizeof(arginfo)); + arginfo *argptr; + if ((sym->usage & uPROTOTYPED) == 0) { + // Allocate space for a new argument, then terminate. + sym->dim.arglist = (arginfo *)realloc(sym->dim.arglist, (argcnt + 2) * sizeof(arginfo)); + memset(&sym->dim.arglist[argcnt + 1], 0, sizeof(arginfo)); - arginfo *argptr = &sym->dim.arglist[argcnt]; - memset(argptr, 0, sizeof(*argptr)); - strcpy(argptr->name, "this"); - argptr->ident = iVARIABLE; - argptr->tags = malloc(sizeof(int)); - argptr->tags[0] = *thistag; - argptr->numtags = 1; + argptr = &sym->dim.arglist[argcnt]; + memset(argptr, 0, sizeof(*argptr)); + strcpy(argptr->name, "this"); + argptr->ident = iVARIABLE; + argptr->tags = malloc(sizeof(int)); + argptr->tags[0] = *thistag; + argptr->numtags = 1; + } else { + argptr = &sym->dim.arglist[0]; + } symbol *sym = addvariable2( argptr->name, @@ -5453,42 +5517,40 @@ static int declargs(symbol *sym, int chkshadow, const int *thistag) if (decl.name[0] == PUBLIC_CHAR) error(56,name); /* function arguments cannot be public */ - if (1) { - if (decl.type.ident == iARRAY) - decl.type.ident = iREFARRAY; - /* Stack layout: - * base + 0*sizeof(cell) == previous "base" - * base + 1*sizeof(cell) == function return address - * base + 2*sizeof(cell) == number of arguments - * base + 3*sizeof(cell) == first argument of the function - * So the offset of each argument is "(argcnt+3) * sizeof(cell)". - */ - doarg(&decl,(argcnt+3)*sizeof(cell),fpublic,chkshadow,&arg); + if (decl.type.ident == iARRAY) + decl.type.ident = iREFARRAY; + /* Stack layout: + * base + 0*sizeof(cell) == previous "base" + * base + 1*sizeof(cell) == function return address + * base + 2*sizeof(cell) == number of arguments + * base + 3*sizeof(cell) == first argument of the function + * So the offset of each argument is "(argcnt+3) * sizeof(cell)". + */ + doarg(&decl,(argcnt+3)*sizeof(cell),fpublic,chkshadow,&arg); - if ((sym->usage & uPUBLIC) && arg.hasdefault) - error(59,name); /* arguments of a public function may not have a default value */ + if ((sym->usage & uPUBLIC) && arg.hasdefault) + error(59,name); /* arguments of a public function may not have a default value */ - if ((sym->usage & uPROTOTYPED)==0) { - /* redimension the argument list, add the entry */ - sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo)); - if (sym->dim.arglist==0) - error(163); /* insufficient memory */ - memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */ - sym->dim.arglist[argcnt]=arg; - } else { - /* check the argument with the earlier definition */ - if (argcnt>oldargcnt || !argcompare(&sym->dim.arglist[argcnt],&arg)) - error(25); /* function definition does not match prototype */ - /* may need to free default array argument and the tag list */ - if (arg.ident==iREFARRAY && arg.hasdefault) - free(arg.defvalue.array.data); - else if ((arg.ident==iVARIABLE - && ((arg.hasdefault & uSIZEOF)!=0 || (arg.hasdefault & uTAGOF)!=0)) || (arg.hasdefault & uCOUNTOF)!=0) - free(arg.defvalue.size.symname); - free(arg.tags); - } /* if */ - argcnt++; - } + if ((sym->usage & uPROTOTYPED)==0) { + /* redimension the argument list, add the entry */ + sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo)); + if (sym->dim.arglist==0) + error(163); /* insufficient memory */ + memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */ + sym->dim.arglist[argcnt]=arg; + } else { + /* check the argument with the earlier definition */ + if (argcnt>oldargcnt || !argcompare(&sym->dim.arglist[argcnt],&arg)) + error(25); /* function definition does not match prototype */ + /* may need to free default array argument and the tag list */ + if (arg.ident==iREFARRAY && arg.hasdefault) + free(arg.defvalue.array.data); + else if ((arg.ident==iVARIABLE + && ((arg.hasdefault & uSIZEOF)!=0 || (arg.hasdefault & uTAGOF)!=0)) || (arg.hasdefault & uCOUNTOF)!=0) + free(arg.defvalue.size.symname); + free(arg.tags); + } /* if */ + argcnt++; } while (matchtoken(',')); /* if the next token is not ",", it should be ")" */ needtoken(')'); diff --git a/sourcepawn/compiler/sc2.c b/sourcepawn/compiler/sc2.c index ec41659d..b1ae61b9 100644 --- a/sourcepawn/compiler/sc2.c +++ b/sourcepawn/compiler/sc2.c @@ -2752,6 +2752,7 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_ case iARRAYCHAR: case iEXPRESSION: case iVARARGS: + case iACCESSOR: default: assert(0); break; diff --git a/sourcepawn/compiler/sc3.c b/sourcepawn/compiler/sc3.c index 07dfbd71..c15e30bd 100644 --- a/sourcepawn/compiler/sc3.c +++ b/sourcepawn/compiler/sc3.c @@ -363,7 +363,7 @@ static int matchobjecttags(int formaltag, int actualtag, int flags) if (formaltag & FUNCTAG) return TRUE; - error(150, pc_tagname(formaltag)); + error(154, pc_tagname(formaltag)); return FALSE; } @@ -1214,8 +1214,8 @@ static int hier14(value *lval1) if (!lvalue) return error(22); /* must be lvalue */ /* may not change "constant" parameters */ - assert(lval1->sym!=NULL); - if ((lval1->sym->usage & uCONST)!=0) + assert(lval1->sym || lval1->accessor); + if (lval1->sym && (lval1->sym->usage & uCONST) != 0) return error(22); /* assignment to const argument */ sc_allowproccall=FALSE; /* may no longer use "procedure call" syntax */ @@ -1245,6 +1245,19 @@ static int hier14(value *lval1) if (same) error(226,lval3.sym->name); /* self-assignment */ } /* if */ + } else if (lval1->ident == iACCESSOR) { + pushreg(sPRI); + if (oper) { + rvalue(lval1); + plnge2(oper,hier14,lval1,&lval2); + } else { + if (hier14(&lval2)) + rvalue(&lval2); /* instead of plnge2(). */ + else if (lval2.ident==iVARIABLE) + lval2.ident=iEXPRESSION;/* mark as "rvalue" if it is not an "lvalue" */ + checkfunction(&lval2); + } + popreg(sALT); } else { if (oper){ rvalue(lval1); @@ -1557,23 +1570,43 @@ static int hier2(value *lval) case tINC: /* ++lval */ if (!hier2(lval)) return error(22); /* must be lvalue */ - assert(lval->sym!=NULL); - if ((lval->sym->usage & uCONST)!=0) - return error(22); /* assignment to const argument */ - if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag)) - inc(lval); /* increase variable first */ - rvalue(lval); /* and read the result into PRI */ + if (lval->ident != iACCESSOR) { + assert(lval->sym!=NULL); + if ((lval->sym->usage & uCONST)!=0) + return error(22); /* assignment to const argument */ + if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag)) + inc(lval); /* increase variable first */ + rvalue(lval); /* and read the result into PRI */ + } else { + pushreg(sPRI); + invoke_getter(lval->accessor); + if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag)) + inc_pri(); + popreg(sALT); + invoke_setter(lval->accessor, TRUE); + lval->ident = iEXPRESSION; + } sideeffect=TRUE; return FALSE; /* result is no longer lvalue */ case tDEC: /* --lval */ if (!hier2(lval)) return error(22); /* must be lvalue */ - assert(lval->sym!=NULL); - if ((lval->sym->usage & uCONST)!=0) - return error(22); /* assignment to const argument */ - if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag)) - dec(lval); /* decrease variable first */ - rvalue(lval); /* and read the result into PRI */ + if (lval->ident != iACCESSOR) { + assert(lval->sym!=NULL); + if ((lval->sym->usage & uCONST)!=0) + return error(22); /* assignment to const argument */ + if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag)) + dec(lval); /* decrease variable first */ + rvalue(lval); /* and read the result into PRI */ + } else { + pushreg(sPRI); + invoke_getter(lval->accessor); + if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag)) + dec_pri(); + popreg(sALT); + invoke_setter(lval->accessor, TRUE); + lval->ident = iEXPRESSION; + } sideeffect=TRUE; return FALSE; /* result is no longer lvalue */ case '~': /* ~ (one's complement) */ @@ -1834,41 +1867,67 @@ static int hier2(value *lval) case tINC: /* lval++ */ if (!lvalue) return error(22); /* must be lvalue */ - assert(lval->sym!=NULL); - if ((lval->sym->usage & uCONST)!=0) - return error(22); /* assignment to const argument */ - /* on incrementing array cells, the address in PRI must be saved for - * incremening the value, whereas the current value must be in PRI - * on exit. - */ - saveresult= (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR); - if (saveresult) - pushreg(sPRI); /* save address in PRI */ - rvalue(lval); /* read current value into PRI */ - if (saveresult) - swap1(); /* save PRI on the stack, restore address in PRI */ - if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag)) - inc(lval); /* increase variable afterwards */ - if (saveresult) - popreg(sPRI); /* restore PRI (result of rvalue()) */ + if (lval->ident != iACCESSOR) { + assert(lval->sym!=NULL); + if ((lval->sym->usage & uCONST)!=0) + return error(22); /* assignment to const argument */ + /* on incrementing array cells, the address in PRI must be saved for + * incremening the value, whereas the current value must be in PRI + * on exit. + */ + saveresult= (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR); + if (saveresult) + pushreg(sPRI); /* save address in PRI */ + rvalue(lval); /* read current value into PRI */ + if (saveresult) + swap1(); /* save PRI on the stack, restore address in PRI */ + if (!check_userop(user_inc,lval->tag,0,1,lval,&lval->tag)) + inc(lval); /* increase variable afterwards */ + if (saveresult) + popreg(sPRI); /* restore PRI (result of rvalue()) */ + } else { + pushreg(sPRI); // save obj + invoke_getter(lval->accessor); + swap1(); // pri = obj, stack = [oldval] + pushreg(sPRI); // pri = obj, stack = [oldval, obj] + if (!check_userop(user_inc, lval->tag, 0, 1, lval, &lval->tag)) + inc_pri(); + popreg(sALT); + invoke_setter(lval->accessor, FALSE); + popreg(sPRI); + lval->ident = iEXPRESSION; + } sideeffect=TRUE; return FALSE; /* result is no longer lvalue */ case tDEC: /* lval-- */ if (!lvalue) return error(22); /* must be lvalue */ - assert(lval->sym!=NULL); - if ((lval->sym->usage & uCONST)!=0) - return error(22); /* assignment to const argument */ - saveresult= (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR); - if (saveresult) - pushreg(sPRI); /* save address in PRI */ - rvalue(lval); /* read current value into PRI */ - if (saveresult) - swap1(); /* save PRI on the stack, restore address in PRI */ - if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag)) - dec(lval); /* decrease variable afterwards */ - if (saveresult) - popreg(sPRI); /* restore PRI (result of rvalue()) */ + if (lval->ident != iACCESSOR) { + assert(lval->sym!=NULL); + if ((lval->sym->usage & uCONST)!=0) + return error(22); /* assignment to const argument */ + saveresult= (lval->ident==iARRAYCELL || lval->ident==iARRAYCHAR); + if (saveresult) + pushreg(sPRI); /* save address in PRI */ + rvalue(lval); /* read current value into PRI */ + if (saveresult) + swap1(); /* save PRI on the stack, restore address in PRI */ + if (!check_userop(user_dec,lval->tag,0,1,lval,&lval->tag)) + dec(lval); /* decrease variable afterwards */ + if (saveresult) + popreg(sPRI); /* restore PRI (result of rvalue()) */ + } else { + pushreg(sPRI); // save obj + invoke_getter(lval->accessor); + swap1(); // pri = obj, stack = [oldval] + pushreg(sPRI); // pri = obj, stack = [oldval, obj] + if (!check_userop(user_dec, lval->tag, 0, 1, lval, &lval->tag)) + dec_pri(); + popreg(sALT); + invoke_setter(lval->accessor, FALSE); + popreg(sPRI); + lval->ident = iEXPRESSION; + } sideeffect=TRUE; return FALSE; /* This is temporarily disabled because we detect it automatically. @@ -1896,28 +1955,6 @@ static int hier2(value *lval) } /* switch */ } -static void invoke_getter(methodmap_t *map, methodmap_method_t *method, svalue *thisval) -{ - if (thisval->lvalue) - rvalue(&thisval->val); - - // push.pri - // push.c 1 - // sysreq.c N 1 - // stack 8 - pushreg(sPRI); - markexpr(sPARM, NULL, 0); - { - pushval(1); - ffcall(method->getter, NULL, 1); - markusage(method->getter, uREAD); - } - markexpr(sEXPR, NULL, 0); - - // We can't tell whether gets are effectful, but they really shouldn't be. - sideeffect = TRUE; -} - /* hier1 * * The highest hierarchy level: it looks for pointer and array indices @@ -1945,6 +1982,10 @@ static int hier1(value *lval1) restart: sym=cursym; if (matchtoken('[') || matchtoken('{') || matchtoken('(') || matchtoken('.')) { + if (lvalue && lval1->ident == iACCESSOR) { + rvalue(lval1); + lvalue = FALSE; + } tok=tokeninfo(&val,&st); /* get token read by matchtoken() */ magic_string = (sym && (sym->tag == pc_tag_string && sym->dim.array.level == 0)); if (sym==NULL && symtok!=tSYMBOL) { @@ -2151,17 +2192,27 @@ restart: if ((method = methodmap_find_method(map, lexstr)) == NULL) error(105, map->name, lexstr); - if (method && method->getter) { - invoke_getter(map, method, &thisval); + if (method && (method->getter || method->setter)) { + if (lvalue) + rvalue(lval1); clear_value(lval1); - lval1->ident = iEXPRESSION; + lval1->ident = iACCESSOR; lval1->tag = method->getter->tag; - lvalue = FALSE; + lval1->accessor = method; + lvalue = TRUE; goto restart; } if (!method || !method->target) { error(105, map->name, lexstr); + + // Fetch a fake function so errors aren't as crazy. + char tmpname[METHOD_NAMEMAX + 1]; + strcpy(tmpname, map->name); + strcat(tmpname, "."); + strcat(tmpname, lexstr); + tmpname[sNAMEMAX] = '\0'; + sym = fetchfunc(tmpname); } else { implicitthis = &thisval; sym = method->target; @@ -2229,7 +2280,7 @@ restart: } else { lval1->constval=(code_addr<<1)|0; snprintf(faketag, sizeof(faketag)-1, "$Func!%d", code_addr); - error(149); + error(153); } lval1->tag=pc_addtag_flags(faketag, FIXEDTAG|FUNCTAG); oldsym->usage |= uREAD; @@ -2361,6 +2412,7 @@ static void clear_value(value *lval) lval->tag=0; lval->ident=0; lval->boolresult=FALSE; + lval->accessor=NULL; /* do not clear lval->arrayidx, it is preset in hier14() */ /* do not clear lval->cmptag */ } @@ -2586,6 +2638,10 @@ static int nesting=0; lvalue = implicitthis->lvalue; } else { lvalue = hier14(&lval); + if (lvalue && lval.ident == iACCESSOR) { + rvalue(&lval); + lvalue = FALSE; + } } assert(sc_status==statFIRST || arg[argidx].ident == 0 || arg[argidx].tags!=NULL); switch (arg[argidx].ident) { diff --git a/sourcepawn/compiler/sc4.c b/sourcepawn/compiler/sc4.c index de82317a..fe0ba809 100644 --- a/sourcepawn/compiler/sc4.c +++ b/sourcepawn/compiler/sc4.c @@ -1,3 +1,4 @@ +// vim: set ts=8 sts=2 sw=2 tw=99 et: /* Pawn compiler - code generation (unoptimized "assembler" code) * * Copyright (c) ITB CompuPhase, 1997-2006 @@ -29,6 +30,7 @@ #include #endif #include "sc.h" +#include "sctracker.h" static int fcurseg; /* the file number (fcurrent) for the active segment */ @@ -407,6 +409,10 @@ SC_FUNC void rvalue(value *lval) outval(sym->addr,TRUE); markusage(sym,uREAD); code_idx+=opcodes(1)+opargs(1); + } else if (lval->ident==iACCESSOR) { + invoke_getter(lval->accessor); + lval->ident=iEXPRESSION; + lval->accessor=NULL; } else { /* direct or stack relative fetch */ assert(sym!=NULL); @@ -490,6 +496,8 @@ SC_FUNC void store(value *lval) stgwrite("\tsref.pri "); outval(sym->addr,TRUE); code_idx+=opcodes(1)+opargs(1); + } else if (lval->ident==iACCESSOR) { + invoke_setter(lval->accessor, TRUE); } else { assert(sym!=NULL); markusage(sym,uWRITTEN); @@ -1240,6 +1248,17 @@ SC_FUNC void nooperation(void) code_idx+=opcodes(1); } +SC_FUNC void inc_pri() +{ + stgwrite("\tinc.pri\n"); + code_idx+=opcodes(1); +} + +SC_FUNC void dec_pri() +{ + stgwrite("\tdec.pri\n"); + code_idx+=opcodes(1); +} /* increment symbol */ @@ -1382,3 +1401,37 @@ SC_FUNC void outval(cell val,int newline) if (newline) stgwrite("\n"); } + +SC_FUNC void invoke_getter(methodmap_method_t *method) +{ + if (!method->getter) { + error(149, method->name); + return; + } + + // push.c 1 + // sysreq.c N 1 + // stack 8 + pushreg(sPRI); + pushval(1); + ffcall(method->getter, NULL, 1); + markusage(method->getter, uREAD); +} + +SC_FUNC void invoke_setter(methodmap_method_t *method, int save) +{ + if (!method->setter) { + error(152, method->name); + return; + } + + if (save) + pushreg(sPRI); + pushreg(sPRI); + pushreg(sALT); + pushval(2); + ffcall(method->setter, NULL, 2); + if (save) + popreg(sPRI); + markusage(method->setter, uREAD); +} diff --git a/sourcepawn/compiler/sc5.scp b/sourcepawn/compiler/sc5.scp index 0fcb6127..23c1a275 100644 --- a/sourcepawn/compiler/sc5.scp +++ b/sourcepawn/compiler/sc5.scp @@ -31,14 +31,14 @@ SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned ch #define SCPACK_TABLE errstr_table /*-*SCPACK start of pair table, do not change or remove this line */ unsigned char errstr_table [][2] = { - {101,32}, {116,32}, {111,110}, {115,32}, {100,32}, {97,114}, {105,110}, {116,105}, {37,115}, {101,114}, {110,111}, {97,110}, {135,130}, {97,108}, {101,110}, {114,101}, - {117,110}, {111,114}, {34,136}, {146,34}, {138,129}, {121,32}, {115,105}, {115,116}, {100,101}, {97,116}, {101,132}, {109,142}, {32,147}, {41,10}, {109,98}, {116,104}, - {114,97}, {117,115}, {144,99}, {98,108}, {162,140}, {145,32}, {102,164}, {97,32}, {116,121}, {101,120}, {99,139}, {118,141}, {111,108}, {170,148}, {112,101}, {115,121}, - {175,158}, {133,160}, {176,172}, {115,10}, {115,150}, {103,32}, {116,111}, {105,132}, {103,117}, {184,155}, {137,32}, {97,163}, {133,185}, {102,134}, {171,183}, {99,104}, - {161,129}, {166,32}, {134,190}, {109,192}, {104,97}, {111,102}, {117,108}, {105,131}, {44,32}, {109,101}, {99,116}, {98,128}, {97,140}, {177,149}, {109,97}, {101,100}, - {99,130}, {37,131}, {118,133}, {112,143}, {178,156}, {110,32}, {197,32}, {105,187}, {210,215}, {99,111}, {101,131}, {130,32}, {99,108}, {118,128}, {152,189}, {102,105}, - {111,112}, {97,131}, {188,129}, {168,174}, {100,105}, {97,115}, {108,128}, {112,128}, {136,10}, {156,10}, {109,153}, {151,153}, {116,97}, {168,231}, {119,105}, {216,128}, - {224,137}, {101,10}, {212,157}, {34,32}, {196,221}, {40,242}, {150,122}, {208,151}, {139,32}, {141,32}, {110,97}, {101,108}, {139,132}, {102,145}, {134,32} + {101,32}, {116,32}, {111,110}, {115,32}, {100,32}, {97,114}, {105,110}, {116,105}, {101,114}, {37,115}, {110,111}, {97,110}, {101,110}, {135,130}, {97,108}, {114,101}, + {117,110}, {111,114}, {34,137}, {146,34}, {121,32}, {138,129}, {115,105}, {115,116}, {100,101}, {97,116}, {101,132}, {109,140}, {32,147}, {41,10}, {109,98}, {116,104}, + {117,115}, {114,97}, {145,32}, {144,99}, {98,108}, {163,141}, {102,165}, {101,120}, {97,32}, {116,121}, {99,139}, {118,142}, {111,108}, {169,112}, {170,149}, {115,121}, + {175,158}, {136,32}, {133,161}, {176,172}, {115,10}, {115,150}, {103,32}, {116,111}, {103,117}, {105,132}, {184,155}, {133,186}, {160,129}, {97,164}, {109,188}, {101,131}, + {102,134}, {101,10}, {44,32}, {171,185}, {99,104}, {166,32}, {134,195}, {104,97}, {111,102}, {117,108}, {99,116}, {105,131}, {98,128}, {97,141}, {178,148}, {110,32}, + {109,97}, {101,100}, {167,112}, {99,130}, {37,131}, {118,133}, {179,156}, {200,32}, {105,189}, {213,216}, {109,101}, {99,111}, {111,112}, {137,10}, {130,32}, {99,108}, + {118,128}, {187,129}, {152,192}, {102,105}, {97,131}, {173,128}, {220,136}, {116,97}, {100,105}, {119,105}, {97,115}, {108,128}, {156,10}, {109,153}, {151,153}, {217,128}, + {214,157}, {199,224}, {40,240}, {150,122}, {211,151}, {34,32}, {138,32}, {139,32}, {142,32}, {159,32}, {110,97}, {115,101}, {116,117}, {139,132}, {210,143} }; /*-*SCPACK end of pair table, do not change or remove this line */ @@ -168,7 +168,7 @@ static char *errmsg[] = { /*122*/ "expected type expression\n", /*123*/ "fully-qualified name \"%s\" is too long, would be truncated to \"%s\"\n", /*124*/ "unexpected token, expected method or property\n", -/*125*/ "expected \"native\" or \"get\"\n", +/*125*/ "expected \"native\", \"get\", or \"set\"\n", /*126*/ "%s for %s already exists\n", /*127*/ "property getters cannot accept extra arguments\n", /*128*/ "%s must have the same return type as property %s (%s)\n", @@ -192,159 +192,167 @@ static char *errmsg[] = { /*146*/ "#pragma newdecls must be required or optional\n", /*147*/ "new-style declarations are required\n", /*148*/ "cannot assign null to a non-nullable type\n", -/*149*/ "cannot use non-public functions as callbacks\n", -/*150*/ "cannot assign INVALID_FUNCTION to a non-function type\n", +/*149*/ "no getter found for property %s\n", +/*150*/ "setter must take exactly one extra argument with type %s\n", +/*151*/ "setter must return void\n", +/*152*/ "no setter found for property %s\n", +/*153*/ "cannot use non-public functions as callbacks\n", +/*154*/ "cannot assign INVALID_FUNCTION to a non-function type\n", #else - "\251\256\312\232\266k\216:\234\310bu\201fo\220\204\223\012", - "\202l\225\247s\206g\346\353e\233\201(\245\251\323\264\202) \252 f\254low ea\277 \042c\345e\042\012", - "\230\334\205\314 \326\247loc\371\357\303ap\256\205 \376\247\331mpo\220\204\243ock\012", - "\246\234 \307\224imple\233t\317\012", - "\301\316\225\224\364\274t\263", - "\303\313a\264gn\232\266 \370\261y\012", - "\360\231\245\255\313\217\336\317\012", - "\303\313\247\367\213\201\251\323\264\202; \345sum\232z\211o\012", - "\302\315\366\200(nega\207ve\310z\211o \245ou\201\326bo\220ds\235", - "\302\301\245\230\334\205\314\012", - "\302out\226d\200\246\263", - "\302\301c\215l\310\224\247\276add\217s\263", - "\212 \216tr\225po\206\201(\212 pu\243ic \246s\235", - "\302\353e\233t; \224\376s\356t\277\012", - "\042\230fa\306t\363c\345\200\303\313\237\200l\345\201c\345\200\376s\356t\277 \353e\233t\012", - "m\306\207p\346\230fa\306t\203\376\042s\356t\277\042\012", - "\220\336\232\324\012", - "\206i\207\215iz\314 d\231\247\251ce\317\203\230\334\205\232\366\361", - "\224\247lab\373:\351", - "\302\262 \372m\200\223\012", - "\262 \215\217ad\225\336\317:\351", - "\303\313l\253u\200(n\202-\367\213t\235", - "\315a\264gn\233\201\303\313\226mp\346a\264gn\233t\012", - "\042b\217ak\363\245\042\320t\206ue\363\307ou\201\326\320t\251t\012", - "\301head\206\265\344ff\211\203from pro\266\343\012", - "\212 \352\277\206\265\042#if...\042\012", - "\302\277\205a\312\272\367\213t\012", - "\302subscrip\201(\224\370\315\245\266o m\213\225subscripts):\351", - "\302\251\323\264\202\310\345sum\232z\211o\012", - "\331mpo\220\204\353e\233\201\224\334os\232a\201\237\200\216\204\326\337\346(\227\205t\232a\201l\206\200%d\235", - "\220k\212w\325\344\217c\207v\361", - "\315\206\230x ou\201\326bo\220d\203(\357\223\235", - "\315\303\313\206\230x\232(\357\223\235", - "\342do\332\224\364\247\230fa\306\201\253u\200(\342%d\235", - "\342\355mis\352\277 (\342%d\235", - "empt\225\353e\233t\012", - "\302\227r\206\265(po\264\243\225n\202-t\211m\206\231\232\227r\206g\235", - "\251t\240 \277\205a\312\211\203\333l\206\361", - "\367\213\201\262 \304\203\212 \366\361", - "duplic\231\200\042c\345e\363lab\373 (\253u\200%d\235", - "\302\373lip\226s\310\315\366\200\307\224k\212wn\012", - "\302\331\236\206\314 \326\334\345\203s\256ci\337\211\263", - "\277\205a\312\272\367\213\201\251ce\317\203r\213g\200f\245pack\232\227r\206g\012", - "po\226\214\371p\205a\311t\211\203\303\323c\317\200\215l \372m\232p\205a\311t\211\263", - "\266o m\213\225\301\274t\263", - "\220k\212w\325\315\366\200(\357\223\235", - "\315\366\332do \224\352\277\310\245\230\227\206\314 \315\307\266o sm\215l\012", - "\315(\203do \224\352\277\012", - "\302l\206\200\320t\206u\314\012", - "\302r\213g\361", - "\302subscript\310\241\200\042[ ]\363\360\231\221\203\333\316j\245\344\233\226\202\263", - "m\306\207-\344\233\226\202\371\261y\203\303\313f\306l\225\206i\207\215iz\317\012", - "\251ce\317\206\265\316ximum nu\236\272\326\344\233\226\202\263", - "\220\352\277\232\334os\206\265b\240c\200(\042}\042\235", - "\227\205\201\326\301bod\225\356\237ou\201\301head\211\012", - "\261ys\310loc\371\330\332\374\301\274t\203\255\313pu\243ic (\357\223\235", - "\220\275ish\232\251\323\264\333be\375\200\331mpil\272\344\217c\207v\361", - "duplic\231\200\274t; sam\200\342\307p\345s\232t\356c\361", - "\301\342\316\225\224\364\247\230fa\306\201\253u\200(\357\223\235", - "m\306\207p\346\042#\373se\363\344\217c\207v\332betwe\216 \042#if ... #\216\344f\042\012", - "\042#\373seif\363\344\217c\207\335f\254low\203\370\042#\373se\363\344\217c\207v\361", - "nu\236\272\326\360\213d\203do\332\224\337\201\237\200\360\231\221\012", - "\301\217s\306\201\354\265\326\360\231\221\234 \303\313\223\012", - "\255\277\213g\200\323\336\232\360\231\221\263", - "\301\342\316\225\202l\225\364\247s\206g\346\354\265(\342%d\235", - "\301\342\316\225\224\313\247\217f\211\216c\200\342\245\370\315(\342\223\235", - "\357\255\313bo\237 \247\217f\211\216c\200\374\370\315(\357\223\235", - "\302\240\214\371nu\236\272\323ci\226\333\376#p\240g\316\012", - "\240\214\371nu\236\272\375\316\201\215\217ad\225\336\317\012", - "\240\214\371nu\236\272supp\221\201w\341\224\216\273\317\012", - "\241\211-\336\232\360\231\245\303\313\230\334\205\232be\375\200\241\200(\246\234\235", - "\042\366e\305\363\360\231\245\307\302\333\042\246\363\262\263", - "\301\342\303\313\370\315(\342\223\235", - "#\336\200p\231t\211\325\303\227\205\201\356\237 \370\215p\304be\207c \277\205a\312\211\012", - "\206pu\201l\206\200\266o l\202\265(aft\272subs\207tu\214s\235", - "\257n\354x \211r\245\376\237\200\251\323\264\202\310\245\302\301c\215l\012", - "m\215\375m\232UTF-8 \216\331d\206g\310\245c\221rupt\232\337le: \350", - "\301\241\332bo\237 \042\217turn\363\374\042\217tur\325<\253ue>\042\012", - "\206\320\226\227\216\201\217tur\325\343\203(\315& n\202-\261y\235", - "\220k\212w\325\262\310\245\224\247\367\213\201\262 \365", - "\255\354k\200\247\354\265\341\247\230fa\306\201\253u\200f\245\370\206\230x\232\315p\205a\311t\272\365", - "\241\211-\336\232\360\231\221\203\374\372\207\335\246\203\316\225\224\364\353e\263", - "\247\301\245\357\316\225\202l\225b\373\202\265\266 \247s\206g\346au\266\352\333\365", - "\353\200\320fli\312: \202\200\326\237\200\353\332\307\215\217ad\225a\264gn\232\266 a\212\237\272imple\233t\314 \365", - "\212 \353\332\205\200\336\232f\245\324\012", - "\220k\212w\325au\266\352\202\351", - "\220k\212w\325\353\200\223 f\245au\266\352\202\351", - "pu\243ic \330\332\374loc\371\330\332\316\225\224\364\353\332\365", - "\353\200\330\332\316\225\224\313\206i\207\215iz\232\365", - "pu\243ic \246\203\316\225\224\217tur\325\261y\203\365", - "a\236i\270ou\203\367\213t; \354\265ov\211rid\200\307\217qui\217\204\365", - "nu\236\272\326\274t\203do\332\224\352\277 \336i\214\012", - "\251\256\312\232\354\265\372m\200id\216\207\337\211\012", - "\301\216um\211\314 \217qui\217\203\220iqu\200\354g\012", - "\255\364\217qui\217\204p\205a\311t\211\203aft\272\340\214\371p\205a\311t\211\263", - "\331\306\204\224\275\204\311\236\211\234 \376\227ruc\201\223\012", - "\324 do\332\224\364\247\352\277\206\265\343\012", - "\355\223 sho\306\204\313\223 \376new-\227y\346\230\334\205\314\263", - "\321sho\306\204\224\364\370\251plici\201\217tur\325\343\012", - "\301pro\266\343\203do \224\352\277\012", - "s\256cif\225ei\237\272\215l \344\233\226\202\203\245\202l\225\237\200l\345\201\344\233\226\202\012", - "\255\275\204\321\350", - "\321w\341\215\217ad\225\336\232\333\237\307\350", - "\255\275\204\213\225\311\237od\203f\245\350", - "\255\275\204\311\237o\204\245pr\360t\225\210.\350", - "\255c\215l \311\237od\203\333\370\261y\012", - "\255c\215l \311\237od\203\333\247\246\012", - "\311\237o\204\303\364\247\337rs\201\342\331mpa\207\243\200\356\237 \237\200\321\355(\210\235", - "\321\372m\200\303\227\205\201\356\237 \370upp\211c\345\200lett\211\012", - "\321\304\203\215\217ad\225be\216 \336\232(\323vio\241l\225se\216 \341\210\235", - "\251\256\312\232id\216\207\337\272- d\267you \375ge\201\247\343?\012", - "\367ru\312\245\301\303\217tur\325\354\265\350", - "\255\336\200\367ru\312\245\375\234; \215\217ad\225\251i\227\203\341\247\350", - "miss\206\265\343\310\245\321\303\364\237\200sam\200\372m\200\341\321\223\012", - "\255\241\200\230lete\310\321\321\304\203\212 \230\227ru\312\221\012", - "\212 \311\237od\316p \245\334\345\203w\341fo\220\204f\245\350", - "\212 \230\227ru\312\245w\341fo\220\204f\245\321\350", - "\230\227ru\312\221\203\303\313\372\207\335\246\263", - "\230\227ru\312\221\203\255\364\251t\240 \274t\263", - "\311\237od\316p \374\334\345\203\226gn\231u\217\203\303\241\200new-\227y\346\355\230\334\205\314\263", - "\255s\256cif\225\315\344\233\226\202\203\333bo\237 \355\374\372\311\012", - "\251\256\312\232\355\251\323\264\202\012", - "f\306ly-qu\215i\337\232\372m\200\223 \307\266o l\202g\310wo\306\204\313tr\242\231\232\266\351", - "\220\251\256\312\232\266k\216\310\251\256\312\232\311\237o\204\245pr\360\250\012", - "\251\256\312\232\042\372\207ve\363\245\042get\042\012", - "\321f\245\321\215\217ad\225\251i\227\263", - "pr\360t\225gett\211\203\255accep\201\251t\240 \274t\263", - "\321\303\364\237\200sam\200\217tur\325\355\341pr\360t\225\321(\210\235", - "\255mix \311\237od\316p\203\374\334\345s\332\356\237 \206h\211it\213c\361", - "\255\331\211c\200\246\203\266 \253ue\263", - "\255\331\211c\200objec\201\355\321\266 n\202-objec\201\355\350", - "\255\331\211c\200n\202-objec\201\355\321\266 objec\201\355\350", - "\255\331\211c\200\220\217l\231\232objec\201\343\203\321\374\350", - "\355mis\352\277 (\321\374\210\235", - "\255\241\200\370objec\201\376\247m\306\207-\354\265s\373e\312\221\012", - "\261y\203\205\200\224supp\221t\232\341\217tur\325\343\263", - "\255mix \217f\211\216c\200\374\315\343\263", - "\320s\201w\341s\256ci\337\232t\356c\361", - "\331\306\204\224\275\204\355\223\012", - "new-\227y\346\315\343\203\255s\256cif\225\344\233\226\333\366\332\341p\205\201\326\237eir \343\012", - "\372\207ves\310\375w\205ds\310\374pu\243ic \246\203\255\217tur\325\261y\263", - "\302\355\230\334\205\314\012", - "new-\227y\346\230\334\205\314\203sho\306\204\224\364\042new\042\012", - "vo\267\255\313\241\232\341\247\357\343\012", - "\302\355\251\323\264\202\012", - "#p\240gm\247new\230\334\203\303\313\217qui\217\204\245\340\214\215\012", - "new-\227y\346\230\334\205\314\203\205\200\217qui\217d\012", - "\255a\264g\325n\306l \266 \247n\202-n\306l\273\200\343\012", - "\255\241\200n\202-pu\243ic \246\203\341c\215lback\263", - "\255a\264g\325INVALID_FUNCTION \266 \247n\202-\301\343\012" + "\322e\312\232\267k\214:\234\302bu\201fo\220\204\223\012", + "\202l\224\250s\206g\353\356e\233\201(\242\376\265\202) \252 f\254low ea\304 \042c\352e\042\012", + "\230\337\205\315 \327\250loc\370\357\276appe\205 \206 \250\333mpo\220\204\244ock\012", + "\246\234 \313\225imple\233t\321\012", + "\305\320\224\225\361\273t\264", + "\276\314a\265gn\232\267 \367\262y\012", + "\346\231\242\256\314\217\342\321\012", + "\276\314\250\364\213\201\376\265\202; \352sum\232z\210o\012", + "\306\316\363\200(nega\207ve\302z\210o \242ou\201\327bo\220ds\235", + "\306\305\242\230\337\205\315\012", + "\306out\226d\200\246\264", + "\306\305c\216l\302\225\250\303add\217s\264", + "\366\214tr\224po\206\201(\366pu\244ic \246s\235", + "\306\356e\233t; \225\206 s\351t\304\012", + "\042\230fa\311t\365c\352\200\276\314\237\200l\352\201c\352\200\206 s\351t\304 \356e\233t\012", + "m\311\207p\353\230fa\311t\203\206 \042s\351t\304\042\012", + "\220\342\232\326\012", + "\206i\207\216iz\315 d\231\250\247ce\321\203\230\337\205\232\363\301", + "\225\250label:\354", + "\306\263 \372m\200\223\012", + "\263 \216\217ad\224\342\321:\354", + "\276\314l\253u\200(n\202-\364\213t\235", + "\316a\265gn\233\201\276\314\226mp\353a\265gn\233t\012", + "\042b\217ak\365\242\042\323t\206ue\365\313ou\201\327\323t\247t\012", + "\305head\206\266\350ff\210\203from pro\267\255\301", + "\366\355\304\206\266\042#if...\042\012", + "\306\304\205a\312\261\364\213t\012", + "\306subscrip\201(\225\367\316\242\267o m\213\224subscripts):\354", + "\306\376\265\202\302\352sum\232z\210o\012", + "\333mpo\220\204\356e\233\201\225\337os\232a\201\237\200\214\204\327\343\353(\227\205t\232a\201l\206\200%d\235", + "\220k\212w\317\350\217c\207v\301", + "\316\206\230x ou\201\327bo\220d\203(\357\223\235", + "\316\276\314\206\230x\232(\357\223\235", + "\341do\277\225\361\250\230fa\311\201\253u\200(\341%d\235", + "\341\345mis\355\304 (\341%d\235", + "empt\224\356e\233t\012", + "\306\227r\206\266(po\265\244\224n\202-t\210m\206\231\232\227r\206g\235", + "\247t\241 \304\205a\312\210\203\336l\206\301", + "\364\213\201\263 \307\203\366\363\301", + "duplic\231\200\042c\352e\365label (\253u\200%d\235", + "\306ellip\226s\302\316\363\200\313\225k\212wn\012", + "\306\333\236\206\315 \327\337\352\203speci\343\210\264", + "\304\205a\312\261\364\213\201\247ce\321\203r\213g\200f\242pack\232\227r\206g\012", + "po\226\215\370p\205a\332t\210\203\276p\217c\321\200\216l \372m\232p\205a\332t\210\264", + "\267o m\213\224\305\273t\264", + "\220k\212w\317\316\363\200(\357\223\235", + "\316\363\277do \225\355\304\302\242\230\227\206\315 \316\313\267o sm\216l\012", + "\316(\203do \225\355\304\012", + "\306l\206\200\323t\206u\315\012", + "\306r\213g\301", + "\306subscript\302\240\200\042[ ]\365\346\231\221\203\336\320j\242\350\233\226\202\264", + "m\311\207-\350\233\226\202\370\262y\203\276\314f\311l\224\206i\207\216iz\321\012", + "\247ce\321\206\266\320ximum nu\236\261\327\350\233\226\202\264", + "\220\355\304\232\337os\206\266b\241c\200(\042}\042\235", + "\227\205\201\327\305bod\224\351\237ou\201\305head\210\012", + "\262ys\302loc\370\331\277\375\305\273t\203\256\314pu\244ic (\357\223\235", + "\220\300ish\232\376\265\336bef\221\200\333mpil\261\350\217c\207v\301", + "duplic\231\200\273t; sam\200\341\313p\352s\232t\351c\301", + "\305\341\320\224\225\361\250\230fa\311\201\253u\200(\357\223\235", + "m\311\207p\353\042#el\373\365\350\217c\207v\277betwe\214 \042#if ... #\214\350f\042\012", + "\042#el\373if\365\350\217c\207\340f\254low\203\367\042#el\373\365\350\217c\207v\301", + "nu\236\261\327\346\213d\203do\277\225\343\201\237\200\346\231\221\012", + "\305\217s\311\201\347\266\327\346\231\221\234 \276\314\223\012", + "\256\304\213g\200p\217\342\232\346\231\221\264", + "\305\341\320\224\202l\224\361\250s\206g\353\347\266(\341%d\235", + "\305\341\320\224\225\314\250\217f\210\214c\200\341\242\367\316(\341\223\235", + "\357\256\314bo\371\250\217f\210\214c\200\375\367\316(\357\223\235", + "\306\241\215\370nu\236\261p\217ci\226\336\206 #p\241g\320\012", + "\241\215\370nu\236\261f\221\320\201\216\217ad\224\342\321\012", + "\241\215\370nu\236\261supp\221\201w\344\225\214\275\321\012", + "\240\210-\342\232\346\231\242\276\314\230\337\205\232bef\221\200\240\200(\246\234\235", + "\042\363e\310\365\346\231\242\313\306\336\042\246\365\263\264", + "\305\341\276\314\367\316(\341\223\235", + "#\342\200p\231t\210\317\276\227\205\201\351\371\367\216p\307be\207c \304\205a\312\210\012", + "\206pu\201l\206\200\267o l\202\266(aft\261subs\207\374\215s\235", + "\257n\347x \210r\242\206 \237\200\376\265\202\302\242\306\305c\216l\012", + "m\216f\221m\232UTF-8 \214\333d\206g\302\242c\221rupt\232\343le: \335", + "\305\240\277bo\371\042\217\374rn\365\375\042\217\374r\317<\253ue>\042\012", + "\206\323\226\227\214\201\217\374r\317\255\277(\316& n\202-\262y\235", + "\220k\212w\317\263\302\242\225\250\364\213\201\263 \362", + "\256\347k\200\250\347\266\344\250\230fa\311\201\253u\200f\242\367\206\230x\232\316p\205a\332t\261\362", + "\240\210-\342\232\346\231\221\203\375\372\207\340\246\203\320\224\225\361\356e\264", + "\250\305\242\357\320\224\202l\224bel\202\266\267 \250s\206g\353au\267\355\336\362", + "\356\200\323fli\312: \202\200\327\237\200\356\277\313\216\217ad\224a\265gn\232\267 a\212\237\261imple\233t\315 \362", + "\366\356\277\205\200\342\232f\242\326\012", + "\220k\212w\317au\267\355\202\354", + "\220k\212w\317\356\200\223 f\242au\267\355\202\354", + "pu\244ic \331\277\375loc\370\331\277\320\224\225\361\356\277\362", + "\356\200\331\277\320\224\225\314\206i\207\216iz\232\362", + "pu\244ic \246\203\320\224\225\217\374r\317\262y\203\362", + "a\236i\270ou\203\364\213t; \347\266ov\210rid\200\313\217qui\217\204\362", + "nu\236\261\327\273t\203do\277\225\355\304 \342i\215\012", + "\322e\312\232\347\266\372m\200id\214\207\343\210\012", + "\305\214um\210\315 \217qui\217\203\220iqu\200\347g\012", + "\256\361\217qui\217\204p\205a\332t\210\203aft\261\334\215\370p\205a\332t\210\264", + "\333\311\204\225\300\204\332\236\210\234 \206 \227ruc\201\223\012", + "\326 do\277\225\361\250\355\304\206\266\255\301", + "\345\223 sho\311\204\314\223 \206 new-\227y\353\230\337\205\315\264", + "\324sho\311\204\225\361\367\322lici\201\217\374r\317\255\301", + "\305pro\267\255\277do \225\355\304\012", + "specif\224ei\237\261\216l \350\233\226\202\203\242\202l\224\237\200l\352\201\350\233\226\202\012", + "\256\300\204\324\335", + "\324w\344\216\217ad\224\342\232\336\237\313\335", + "\256\300\204\213\224\332\237od\203f\242\335", + "\256\300\204\332\237o\204\242pr\346t\224\211.\335", + "\256c\216l \332\237od\203\336\367\262y\012", + "\256c\216l \332\237od\203\336\250\246\012", + "\332\237o\204\276\361\250\343rs\201\341\333mpa\207\244\200\351\371\237\200\324\345(\211\235", + "\324\372m\200\276\227\205\201\351\371\367upp\210c\352\200lett\210\012", + "\324\307\203\216\217ad\224be\214 \342\232(p\217vio\240l\224\373\214 \344\211\235", + "\322e\312\232id\214\207\343\261- d\271you f\221ge\201\250\255e?\012", + "\364ru\312\242\305\276\217\374r\317\347\266\335", + "\256\342\200\364ru\312\242f\221\234; \216\217ad\224\247i\227\203\344\250\335", + "miss\206\266\255e\302\242\324\276\361\237\200sam\200\372m\200\344\324\223\012", + "\256\240\200\230lete\302\324\324\307\203\366\230\227ru\312\221\012", + "\366\332\237od\320p \242\337\352\203w\344fo\220\204f\242\335", + "\366\230\227ru\312\242w\344fo\220\204f\242\324\335", + "\230\227ru\312\221\203\276\314\372\207\340\246\264", + "\230\227ru\312\221\203\256\361\247t\241 \273t\264", + "\332\237od\320p \375\337\352\203\226gn\231u\217\203\276\240\200new-\227y\353\345\230\337\205\315\264", + "\256specif\224\316\350\233\226\202\203\336bo\371\345\375\372m\301", + "\322e\312\232\345\376\265\202\012", + "f\311ly-qu\216i\343\232\372m\200\223 \313\267o l\202g\302wo\311\204\314tr\243\231\232\267\354", + "\220\322e\312\232\267k\214\302\322e\312\232\332\237o\204\242pr\346\251\012", + "\322e\312\232\042\372\207ve\042\302\042get\042\302\242\042\373t\042\012", + "\324f\242\324\216\217ad\224\247i\227\264", + "pr\346t\224gett\210\203\256accep\201\247t\241 \273t\264", + "\324\276\361\237\200sam\200\217\374r\317\345\344pr\346t\224\324(\211\235", + "\256mix \332\237od\320p\203\375\337\352s\277\351\371\206h\210it\213c\301", + "\256\333\210c\200\246\203\267 \253ue\264", + "\256\333\210c\200objec\201\345\324\267 n\202-objec\201\345\335", + "\256\333\210c\200n\202-objec\201\345\324\267 objec\201\345\335", + "\256\333\210c\200\220\217l\231\232objec\201\255\277\324\375\335", + "\345mis\355\304 (\324\375\211\235", + "\256\240\200\367objec\201\206 \250m\311\207-\347\266\373le\312\221\012", + "\262y\203\205\200\225supp\221t\232\344\217\374r\317\255e\264", + "\256mix \217f\210\214c\200\375\316\255e\264", + "\323s\201w\344speci\343\232t\351c\301", + "\333\311\204\225\300\204\345\223\012", + "new-\227y\353\316\255\277\256specif\224\350\233\226\336\363\277\344p\205\201\327\237eir \255\301", + "\372\207ves\302f\221w\205ds\302\375pu\244ic \246\203\256\217\374r\317\262y\264", + "\306\345\230\337\205\315\012", + "new-\227y\353\230\337\205\315\203sho\311\204\225\361\042new\042\012", + "vo\271\256\314\240\232\344\250\357\255\301", + "\306\345\376\265\202\012", + "#p\241gm\250new\230\337\203\276\314\217qui\217\204\242\334\215\216\012", + "new-\227y\353\230\337\205\315\203\205\200\217qui\217d\012", + "\256a\265g\317n\311l \267 \250n\202-n\311l\275\200\255\301", + "\366gett\261fo\220\204f\242pr\346t\224\335", + "\373tt\261\276\347k\200\247a\312l\224\202\200\247t\241 \341\351\371\345\335", + "\373tt\261\276\217\374r\317void\012", + "\366\373tt\261fo\220\204f\242pr\346t\224\335", + "\256\240\200n\202-pu\244ic \246\203\344c\216lback\264", + "\256a\265g\317INVALID_FUNCTION \267 \250n\202-\305\255\301" #endif }; @@ -369,18 +377,18 @@ static char *fatalmsg[] = { /*170*/ "assertion failed: %s\n", /*171*/ "user error: %s\n", #else - "\255\217a\204from \337le:\351", - "\255writ\200\266 \337le:\351", - "t\273\200ov\211flow:\351", - "\206suf\337ci\216\201\311m\221y\012", - "\302\345se\236l\272\206\227ruc\214\351", - "num\211ic ov\211flow\310\251ce\317\206\265capaci\250\012", - "\331mpil\232scrip\201\251ce\317\203\237\200\316ximum \311m\221\225\366\200(%l\204bytes\235", - "\266o m\213\225\211r\245\311ssag\332\333\202\200l\206\361", - "\331\230pag\200\316pp\206\265\337\346\224fo\220d\012", - "\302p\231h:\351", - "\345s\211\214 fail\317: \350", - "\241\272\211r\221: \350" + "\256\217a\204from \343le:\354", + "\256writ\200\267 \343le:\354", + "t\275\200ov\210flow:\354", + "\206suf\343ci\214\201\332m\221y\012", + "\306\352\373\236l\261\206\227ruc\215\354", + "num\210ic ov\210flow\302\247ce\321\206\266capaci\251\012", + "\333mpil\232scrip\201\247ce\321\203\237\200\320ximum \332m\221\224\363\200(%l\204bytes\235", + "\267o m\213\224\210r\242\332ssag\277\336\202\200l\206\301", + "\333\230pag\200\320pp\206\266\343\353\225fo\220d\012", + "\306p\231h:\354", + "\352s\210\215 fail\321: \335", + "\240\261\210r\221: \335" #endif }; @@ -424,43 +432,43 @@ static char *warnmsg[] = { /*235*/ "public function lacks forward declaration (symbol \"%s\")\n", /*236*/ "unknown parameter in substitution (incorrect #define pattern)\n" #else - "\324 \307tr\242\231\232\266 %\204\277\205a\312\211\263", - "\217\336i\214 \326\367\213t/\316cro \365", - "nu\236\272\326\274t\203do\332\224\352\277 \336i\214\012", - "\262 \307nev\272\241\317:\351", - "\262 \307a\264gn\232\247\253u\200\237a\201\307nev\272\241\317:\351", - "\217d\220d\213\201\331\230: \367\213\201\251\323\264\333\307z\211o\012", - "\217d\220d\213\201te\227: \367\213\201\251\323\264\333\307n\202-z\211o\012", - "\220k\212w\325#p\240g\316\012", - "\301\356\237 \354\265\217s\306\201\241\232be\375\200\336i\214\310\375c\206\265\217p\205s\361", - "\246\234 sho\306\204\217tur\325\247\253u\361", - "po\264\243\200\241\200\326\262 be\375\200\206i\207\215iz\314:\351", - "po\264\243\225\220\206t\216\230\204a\264gn\233t\012", - "po\264\243\225\220\206t\216\230\204bit\356s\200\360\314\012", - "\354\265mis\352\277\012", - "po\264\243\225\247\042\367\363\315\342w\341\206t\216\230d:\351", - "\251\323\264\333\304\203\212 effe\312\012", - "ne\227\232\331m\233t\012", - "loos\200\206d\216t\314\012", - "\254\204\227y\346pro\266\343\203\241\232\356\237 \340\214\371semic\254umn\263", - "loc\371\357\223 s\304dow\203\247\357a\201\247\323c\317\206\265lev\373\012", - "\251\323\264\333\356\237 \354\265ov\211rid\200\303ap\256\205 betwe\216 p\205\216\237ese\263", - "lab\373 \372m\200\223 s\304dow\203\354\265\372\311\012", - "nu\236\272\326\344git\203\251ce\317\203\240\214\371nu\236\272\323ci\226\202\012", - "\217d\220d\213\201\042\366e\305\042: \342\366\200\307\215way\2031 \365", - "\206\230t\211m\206\231\200\315\366\200\376\042\366e\305\363\251\323\264\333\365", - "\220\217a\277\273\200\331\230\012", - "\247\357\307a\264gn\232\266 its\373f \365", - "m\221\200\206i\207\215iz\211\203\237\370\216um \337\373d\263", - "l\216g\237 \326\206i\207\215iz\272\251ce\317\203\366\200\326\237\200\216um \337\373d\012", - "\206\230x \354\265mis\352\277 \365", - "\212 imple\233t\314 f\245\353\200\223 \376\246\234\310\212 f\215l-back\012", - "\353\200s\256ci\337c\314 \333\375w\205\204\230\334\205\314 \307ig\212\217d\012", - "outpu\201\337\346\307writt\216\310bu\201\356\237 \331mpac\201\216\331d\206\265\344s\273\317\012", - "\353\200\357\223 s\304dow\203\247glob\371\330\361", - "\324 \307m\205k\232\341\230\323c\231\317: \350", - "pu\243ic \301lack\203\375w\205\204\230\334\205\314 \365", - "\220k\212w\325p\205a\311t\272\376subs\207tu\214 (\206c\221\217c\201#\336\200p\231t\211n\235" + "\326 \313tr\243\231\232\267 %\204\304\205a\312\210\264", + "\217\342i\215 \327\364\213t/\320cro \362", + "nu\236\261\327\273t\203do\277\225\355\304 \342i\215\012", + "\263 \313nev\261\240\321:\354", + "\263 \313a\265gn\232\250\253u\200\237a\201\313nev\261\240\321:\354", + "\217d\220d\213\201\333\230: \364\213\201\376\265\336\313z\210o\012", + "\217d\220d\213\201te\227: \364\213\201\376\265\336\313n\202-z\210o\012", + "\220k\212w\317#p\241g\320\012", + "\305\351\371\347\266\217s\311\201\240\232bef\221\200\342i\215\302f\221c\206\266\217p\205s\301", + "\246\234 sho\311\204\217\374r\317\250\253u\301", + "po\265\244\200\240\200\327\263 bef\221\200\206i\207\216iz\315:\354", + "po\265\244\224\220\206t\214\230\204a\265gn\233t\012", + "po\265\244\224\220\206t\214\230\204bit\351s\200\346\315\012", + "\347\266mis\355\304\012", + "po\265\244\224\250\042\364\365\316\341w\344\206t\214\230d:\354", + "\376\265\336\307\203\366effe\312\012", + "ne\227\232\333m\233t\012", + "loos\200\206d\214t\315\012", + "\254\204\227y\353pro\267\255\277\240\232\351\371\334\215\370\373mic\254umn\264", + "loc\370\357\223 s\307dow\203\250\357a\201\250p\217c\321\206\266level\012", + "\376\265\336\351\371\347\266ov\210rid\200\276appe\205 betwe\214 p\205\214\237e\373\264", + "label \372m\200\223 s\307dow\203\347\266\372m\301", + "nu\236\261\327\350git\203\247ce\321\203\241\215\370nu\236\261p\217ci\226\202\012", + "\217d\220d\213\201\042\363e\310\042: \341\363\200\313\216way\2031 \362", + "\206\230t\210m\206\231\200\316\363\200\206 \042\363e\310\365\376\265\336\362", + "\220\217a\304\275\200\333\230\012", + "\250\357\313a\265gn\232\267 it\373lf \362", + "m\221\200\206i\207\216iz\210\203\237\367\214um \343eld\264", + "l\214g\371\327\206i\207\216iz\261\247ce\321\203\363\200\327\237\200\214um \343eld\012", + "\206\230x \347\266mis\355\304 \362", + "\366imple\233t\315 f\242\356\200\223 \206 \246\234\302\366f\216l-back\012", + "\356\200speci\343c\315 \336f\221w\205\204\230\337\205\315 \313ig\212\217d\012", + "outpu\201\343\353\313writt\214\302bu\201\351\371\333mpac\201\214\333d\206\266\350s\275\321\012", + "\356\200\357\223 s\307dow\203\250glob\370\331\301", + "\326 \313m\205k\232\344\230p\217c\231\321: \335", + "pu\244ic \305lack\203f\221w\205\204\230\337\205\315 \362", + "\220k\212w\317p\205a\332t\261\206 subs\207\374\215 (\206c\221\217c\201#\342\200p\231t\210n\235" #endif }; diff --git a/tools/buildbot/PackageScript b/tools/buildbot/PackageScript index ae2396c5..59da49fe 100644 --- a/tools/buildbot/PackageScript +++ b/tools/buildbot/PackageScript @@ -413,6 +413,7 @@ CopyFiles('plugins/testsuite', 'addons/sourcemod/scripting/testsuite', 'structtest.sp', 'tf2-test.sp', 'tries.sp', + 'keyvalues.sp', ] ) CopyFiles('plugins/basecommands', 'addons/sourcemod/scripting/basecommands',