Long Function Names -
IllidanS4 - 16.10.2018
Purpose
Normally, Pawn function names cannot exceed 31 characters. This is a limitation of both the compiler and the execution engine, which discards AMX programs with longer function names. This plugin removes this limitation of the AMX engine and allows scripts with longer names (of native functions, public functions, and public variables) to execute normally, without modifications to the names themselves. Other scripts will be unaffected by this plugin.
Other plugins may use this plugin to register natives or call public functions with long names. No special API is required to make this work, since the majority of the AMX API can work with any length. However, you should always use
amx_NameLength to retrieve the maximum length used by the script.
You will need a compiler supporting longer function names. Check out my
fork which increases the length to 63.
Please note that some Pawn libraries may not work properly with longer identifiers. In this case, you either need to configure them in some way to increase the limit, or contact the author.
Example
pawn Code:
#include <a_samp>
forward VeryLongPublicFunctionNameExceeding31Characters();
public VeryLongPublicFunctionNameExceeding31Characters()
{
print("hello!");
}
public OnFilterScriptInit()
{
CallLocalFunction("VeryLongPublicFunctionNameExceeding31Characters", "");
}
Re: Long Function Names -
KinderClans - 16.10.2018
If there is a limit of 31 characters, there must be a reason, no?
Also i don't like long function names, they're useless and confusing. But that's my opinion.
Someone else will find this useful. Good job.
Re: Long Function Names -
IllidanS4 - 16.10.2018
Quote:
Originally Posted by KinderClans
If there is a limit of 31 characters, there must be a reason, no?
Also i don't like long function names, they're useless and confusing. But that's my opinion.
Someone else will find this useful. Good job.
|
The limit is completely arbitrary; in older versions of AMX, the size of a record was fixed, but now all names are located in the name table which is just a pool of variable-length strings. The only functions in the API that depend on on the limit are
amx_Init,
amx_Cleanup,
amx_FindNative,
amx_FindPublic, and
amx_FindPubVar. All of these functions except for
amx_Cleanup are hooked by this plugin, removing the dependency.
The limit might have been useful for C programmers in times where variable-length arrays needed explicit destruction, so they could simply allocate 32 characters on the stack, without worrying about the deallocation, and know that all names fit inside, but since there is
amx_NameLength (which you should use according to the
GCA), you can dynamically allocate the buffer in C++ (or use
alloca) based on the length.
In my opinion, arbitrary bounds based on no real limitations are bad, but there might be another reason for this. Certain mechanisms that work with already existing names might need to "expand" them a little bit (
mangling for example), so if there is a function
SetPlayerChatBubbleForPlayer (28 characters), turning it into
SetPlayerChatBubbleForPlayer@6uuSufi (36 characters) is already over the limit.
You could argue that using abbreviated forms instead of the componenets fixes this (
SetPlChBubbleFPl), but I'd rather not have my code turned into WINAPI, thank you.
Re: Long Function Names -
GangstaSunny. - 16.10.2018
Yap, the most the like to "who is using over 31 characters?!".
I meet this a few times.
+rep, nice work dude.
Re: Long Function Names -
SyS - 16.10.2018
nice and useful
Re: Long Function Names -
Peek - 16.10.2018
Thanks that will definitely come in handy, I happen to be looking for something like this yesterday.
Re: Long Function Names -
Gammix - 16.10.2018
Now i no longer have to create abbreviations while hooking function names like OnPlayerClickPlayerTextDraw etc.
++rep;
Re: Long Function Names -
Whyd - 16.10.2018
Just what i needed, genius!
Re: Long Function Names -
Spoookymon - 27.10.2018
(h) it.
Is it's possible to increase include file limit, what i mean is that it's limited to 30 caharcters.
Ex:
(Works)
#include "A/BC/ZXC/Asdfghjklzx/Abc1.pwn"
#include "A/BC/ZXC/Asdfghjklzx/Abc2.pwn"
(Abcd2.pwn will not be included)
#include "A/BC/ZXC/Asdfghjklzx/Abcd1.pwn"
#include "A/BC/ZXC/Asdfghjklzx/Abcd2.pwn"
Re: Long Function Names -
RogueDrifter - 27.10.2018
Quote:
Originally Posted by Gammix
Now i no longer have to create abbreviations while hooking function names like OnPlayerClickPlayerTextDraw etc.
++rep;
|
Exactly, good job!
Re: Long Function Names -
IllidanS4 - 27.10.2018
Quote:
Originally Posted by Spoookymon
(h) it.
Is it's possible to increase include file limit, what i mean is that it's limited to 30 caharcters.
Ex:
(Works)
#include "A/BC/ZXC/Asdfghjklzx/Abc1.pwn"
#include "A/BC/ZXC/Asdfghjklzx/Abc2.pwn"
(Abcd2.pwn will not be included)
#include "A/BC/ZXC/Asdfghjklzx/Abcd1.pwn"
#include "A/BC/ZXC/Asdfghjklzx/Abcd2.pwn"
|
This is out of scope for this plugin; you can post this as an issue on the compiler GitHub repository.