Preprocessor parsers -
Geebrox - 24.02.2018
I divided my project into modules. But there have some problems with functions, as (maybe) you know when project divided into modules you must create many functions with different names and call them from the primary file (gamemode), inventing, memorizing names and locations of all functions is hard for me. That's why I decide to create some preprocessor parsers. But I face some problems as (maybe) you know max length of function's/callback's name is 31 and there have some functions as OnPlayerClickPlayerTextDraw (length is 27) what is the barrier to add tags to them, otherwise you can meet the limitation. My question: How to truncated function's name with parsers what is sent through macros? I'm sorry for my bad English. I guess you understood my question.
These are my parsers that I already created:
PHP код:
#define ACCOUNT_MODULE_TAG_FUNCTION: _accmfn_
#define ACCOUNT_MODULE_TAG_CALLBACK: _accmcb_
#define AccountSystem:<%0:%1>%2(%3) accm@%0@%1@(%2,%3)
#define accm@call@function@(%0,%1) ACCOUNT_MODULE_TAG_FUNCTION:%0(%1)
#define accm@call@callback@(%0,%1) ACCOUNT_MODULE_TAG_CALLBACK:%0(%1)
#define accm@create@function@(%0,%1) stock ACCOUNT_MODULE_TAG_FUNCTION:%0(%1)
#define accm@create@callback@(%0,%1) \
forward ACCOUNT_MODULE_TAG_CALLBACK:%0(%1);\
public ACCOUNT_MODULE_TAG_CALLBACK:%0(%1)
AccountSystem:<create:function>SayHello()
{
print("hello");
}
main()
{
AccountSystem:<call:function>SayHello();
AccountSystem:<call:callback>OnPlayerConnect(666);
}
AccountSystem:<create:callback>OnPlayerConnect(playerid)
{
printf("OnPlayerConnect(%d)", playerid);
return 1;
}
P.S.
If you have some advises to improve my parsers, please tell me.
Re: Preprocessor parsers -
Geebrox - 24.02.2018
Quote:
Originally Posted by ******
You were complaining about being unable to remember names, so you invented a more complex syntax to remember, and you still need to remember the "AccountSystem:" prefix. If you can remember that, just remember "AS_" (short for "AccountSystem") instead. And this way you don't even need to differentiate between functions and callbacks (because why would you).
|
No, you don't understand my purpose. There are many modules which tags can be same, for example,
Account
System and
Admin
System or
Anticheat
System. With my parsers, I can understand what's exactly going on. I can understand which function of which module is calling or creating. Also, why you think that I can't remember that tags? I think it is much easier to remember than AS. If I use AS I waste time to understand what module has
AS tag. But with the tag
AccountSystem I will instantly understand that in those part of the code is calling/creating function/callback of/for Account Module.
Re: Preprocessor parsers -
Geebrox - 24.02.2018
^__up__^
Re: Preprocessor parsers -
iKarim - 24.02.2018
Why don't you just start of with samp# (c#) or sampgdk (c++) instead of PAWN then? It's totally unnecessary and ugly to implement such syntax in PAWN.
Re: Preprocessor parsers -
Geebrox - 24.02.2018
Quote:
Originally Posted by iKarim
Why don't you just start of with samp# (c#) or sampgdk (c++) instead of PAWN then? It's totally unnecessary and ugly to implement such syntax in PAWN.
|
Because I'm not as good in c# or c++ as in Pawn. Why you think that it is ugly and unnecessary can you support your arguments with some examples?
Re: Preprocessor parsers -
iKarim - 25.02.2018
Quote:
Originally Posted by Geebrox
Why you think that it is ugly and unnecessary can you support your arguments with some examples?
|
There you go:
PHP код:
AccountSystem:<create:function>SayHello()
I have never seen such syntax in various different languages, you are over complicating the syntax making it literally unknown (or strange) to anyone besides you.
But I guess what ****** said is what you are looking for, so yeah good luck.