Compiler: Add #pragma deprecated.
This is based on SM, including patch to support macros/constants (https://hg.alliedmods.net/sourcemod-central/rev/ef8dd1cddc35). Updated also some pawn includes to use this new pragma.
This commit is contained in:
parent
09303625fb
commit
520493fab1
|
@ -128,6 +128,7 @@ typedef struct s_symbol {
|
|||
char vclass; /* sLOCAL if "addr" refers to a local symbol */
|
||||
char ident; /* see below for possible values */
|
||||
char usage; /* see below for possible values */
|
||||
char flags; /* see below for possible values */
|
||||
int compound; /* compound level (braces nesting level) */
|
||||
int tag; /* tagname id */
|
||||
int fieldtag; /* enumeration fields, where a size is attached to the field */
|
||||
|
@ -221,6 +222,8 @@ typedef struct s_symbol {
|
|||
*/
|
||||
#define uRETNONE 0x10
|
||||
|
||||
#define flgDEPRECATED 0x01 /* symbol is deprecated (avoid use) */
|
||||
|
||||
#define uTAGOF 0x40 /* set in the "hasdefault" field of the arginfo struct */
|
||||
#define uSIZEOF 0x80 /* set in the "hasdefault" field of the arginfo struct */
|
||||
|
||||
|
@ -270,6 +273,8 @@ typedef struct s_stringpair {
|
|||
char *first;
|
||||
char *second;
|
||||
int matchlength;
|
||||
char flags;
|
||||
char *documentation;
|
||||
} stringpair;
|
||||
|
||||
/* macros for code generation */
|
||||
|
@ -783,6 +788,7 @@ SC_VDECL int sc_rationaltag; /* tag for rational numbers */
|
|||
SC_VDECL int rational_digits; /* number of fractional digits */
|
||||
SC_VDECL int sc_allowproccall;/* allow/detect tagnames in lex() */
|
||||
SC_VDECL short sc_is_utf8; /* is this source file in UTF-8 encoding */
|
||||
SC_VDECL char *pc_deprecate; /* if non-NULL, mark next declaration as deprecated */
|
||||
|
||||
SC_VDECL constvalue sc_automaton_tab; /* automaton table */
|
||||
SC_VDECL constvalue sc_state_tab; /* state table */
|
||||
|
|
11222
compiler/libpc300/sc1.c
11222
compiler/libpc300/sc1.c
File diff suppressed because it is too large
Load Diff
|
@ -850,6 +850,7 @@ static int command(void)
|
|||
char *str;
|
||||
int index;
|
||||
cell code_index;
|
||||
size_t len;
|
||||
|
||||
while (*lptr<=' ' && *lptr!='\0')
|
||||
lptr+=1;
|
||||
|
@ -1003,6 +1004,19 @@ static int command(void)
|
|||
error(27); /* invalid character constant */
|
||||
sc_ctrlchar=(char)val;
|
||||
} /* if */
|
||||
}
|
||||
else if (strcmp(str, "deprecated") == 0) {
|
||||
while (*lptr <= ' ' && *lptr != '\0')
|
||||
lptr++;
|
||||
len = strlen((char*)lptr);
|
||||
pc_deprecate = (char*)malloc(len + 1);
|
||||
if (pc_deprecate != NULL)
|
||||
{
|
||||
strcpy(pc_deprecate, (char*)lptr);
|
||||
if (pc_deprecate[len - 1] == '\n') /* remove extra \n as already appended in .scp file */
|
||||
pc_deprecate[len-1] = '\0';
|
||||
}
|
||||
lptr = (unsigned char*)strchr((char*)lptr, '\0'); /* skip to end (ignore "extra characters on line") */
|
||||
} else if (strcmp(str,"dynamic")==0) {
|
||||
preproc_expr(&sc_stksize,NULL);
|
||||
} else if ( !strcmp(str,"library") ||
|
||||
|
@ -2658,6 +2672,7 @@ SC_FUNC symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag,i
|
|||
entry.ident=(char)ident;
|
||||
entry.tag=tag;
|
||||
entry.usage=(char)usage;
|
||||
entry.flags=0;
|
||||
entry.compound=0; /* may be overridden later */
|
||||
entry.states=NULL;
|
||||
entry.fnumber=-1; /* assume global visibility (ignored for local symbols) */
|
||||
|
|
|
@ -1862,6 +1862,11 @@ static int nesting=0;
|
|||
assert(nest_stkusage==0);
|
||||
#endif
|
||||
|
||||
if ((sym->flags & flgDEPRECATED)!=0) {
|
||||
char *ptr= (sym->documentation!=NULL) ? sym->documentation : "";
|
||||
error(233,sym->name,ptr); /* deprecated (probably a native function) */
|
||||
} /* if */
|
||||
|
||||
/* run through the arguments */
|
||||
arg=sym->dim.arglist;
|
||||
assert(arg!=NULL);
|
||||
|
|
|
@ -290,6 +290,7 @@ static char *warnmsg[] = {
|
|||
/*230*/ "no implementation for state \"%s\" / function \"%s\", no fall-back\n",
|
||||
/*231*/ "state specification on forward declaration is ignored\n",
|
||||
/*232*/ "output file is written, but with compact encoding disabled\n"
|
||||
/*233*/ "symbol \"%s\" is marked as deprecated: %s\n",
|
||||
#else
|
||||
"\345 \274tr\240\226\233\277 %\206\273\337c\367\305",
|
||||
"\222\323i\231\300\344\224t/\314cr\375\364",
|
||||
|
|
|
@ -276,6 +276,26 @@ SC_FUNC stringpair *insert_subst(char *pattern,char *substitution,int prefixlen)
|
|||
if ((cur=insert_stringpair(&substpair,pattern,substitution,prefixlen))==NULL)
|
||||
error(103); /* insufficient memory (fatal error) */
|
||||
adjustindex(*pattern);
|
||||
|
||||
if (pc_deprecate != NULL) {
|
||||
assert(cur != NULL);
|
||||
cur->flags |= flgDEPRECATED;
|
||||
if (sc_status == statWRITE) {
|
||||
if (cur->documentation != NULL) {
|
||||
free(cur->documentation);
|
||||
cur->documentation = NULL;
|
||||
} /* if */
|
||||
cur->documentation = pc_deprecate;
|
||||
}
|
||||
else {
|
||||
free(pc_deprecate);
|
||||
} /* if */
|
||||
pc_deprecate = NULL;
|
||||
}
|
||||
else {
|
||||
cur->flags = 0;
|
||||
cur->documentation = NULL;
|
||||
} /* if */
|
||||
return cur;
|
||||
}
|
||||
|
||||
|
@ -288,6 +308,24 @@ SC_FUNC stringpair *find_subst(char *name,int length)
|
|||
item=substindex[(int)*name-'A'];
|
||||
if (item!=NULL)
|
||||
item=find_stringpair(item,name,length);
|
||||
|
||||
if (item && (item->flags & flgDEPRECATED) != 0)
|
||||
{
|
||||
static char macro[128];
|
||||
char *rem, *msg = (item->documentation != NULL) ? item->documentation : "";
|
||||
strncpy(macro, item->first, sizeof(macro));
|
||||
macro[sizeof(macro) - 1] = '\0';
|
||||
|
||||
/* If macro contains an opening parentheses and a percent sign, then assume that
|
||||
* it takes arguments and remove them from the warning message.
|
||||
*/
|
||||
if ((rem = strchr(macro, '(')) != NULL && strchr(macro, '%') > rem)
|
||||
{
|
||||
*rem = '\0';
|
||||
}
|
||||
|
||||
error(233, macro, msg); /* deprecated (macro/constant) */
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ SC_VDEFINE int sc_rationaltag=0; /* tag for rational numbers */
|
|||
SC_VDEFINE int rational_digits=0; /* number of fractional digits */
|
||||
SC_VDEFINE int sc_allowproccall=0; /* allow/detect tagnames in lex() */
|
||||
SC_VDEFINE short sc_is_utf8=FALSE; /* is this source file in UTF-8 encoding */
|
||||
SC_VDEFINE char *pc_deprecate = NULL;/* if non-null, mark next declaration as deprecated */
|
||||
SC_VDEFINE int sc_showincludes=0; /* show include files */
|
||||
|
||||
SC_VDEFINE constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */
|
||||
|
|
|
@ -2535,6 +2535,7 @@ native plugin_flags(hdr=0, plid=-1);
|
|||
*
|
||||
* @noreturn
|
||||
*/
|
||||
#pragma deprecated Module dependency is now automatically handled by the compiler. This forward is no longer called.
|
||||
forward plugin_modules();
|
||||
|
||||
/**
|
||||
|
@ -2545,6 +2546,7 @@ forward plugin_modules();
|
|||
*
|
||||
* @noreturn
|
||||
*/
|
||||
#pragma deprecated Module dependency is now automatically handled by the compiler. This native has no effect.
|
||||
native require_module(const module[]);
|
||||
|
||||
/**
|
||||
|
@ -2556,6 +2558,7 @@ native require_module(const module[]);
|
|||
*
|
||||
* @return 1 if the server is 64 bit, 0 otherwise
|
||||
*/
|
||||
#pragma deprecated AMXX is not shipping 64bits builds anymore. This native is basically guaranteed to return 0.
|
||||
native is_amd64_server();
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,7 +62,7 @@ native bool:geoip_code3_ex(const ip[], result[4]);
|
|||
*
|
||||
* @return 1 on a successful lookup, 0 otherwise.
|
||||
*/
|
||||
//#pragma deprecated Use geoip_code2_ex() instead.
|
||||
#pragma deprecated Use geoip_code2_ex() instead.
|
||||
native geoip_code2(const ip[], ccode[3]);
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ native geoip_code2(const ip[], ccode[3]);
|
|||
*
|
||||
* @return 1 on a successful lookup, 0 otherwise.
|
||||
*/
|
||||
//#pragma deprecated Use geoip_code3() instead.
|
||||
#pragma deprecated Use geoip_code3() instead.
|
||||
native geoip_code3(const ip[], result[4]);
|
||||
|
||||
/**
|
||||
|
|
|
@ -543,6 +543,7 @@ forward client_spawn(id);
|
|||
* @param Damage The amount of damage being done.
|
||||
* @param DamageType The damage type being done (bitmask).
|
||||
*/
|
||||
#pragma deprecated It is suggested to use hamsandwich for this action instead.
|
||||
native ns_takedamage(IDVictim, IDInflictor, IDAttacker, Float:Damage, DamageType);
|
||||
|
||||
/**
|
||||
|
|
|
@ -711,7 +711,7 @@ native strncmp(const string1[], const string2[], num, bool:ignorecase=false);
|
|||
* Backwards compatibility stock - use argbreak or argparse.
|
||||
* @deprecated this function does not work properly.
|
||||
*/
|
||||
//#pragma deprecated Use argbreak() instead
|
||||
#pragma deprecated Use argbreak() instead
|
||||
stock strbreak(const text[], Left[], leftLen, Right[], rightLen)
|
||||
{
|
||||
return argbreak(text, Left, leftLen, Right, rightLen);
|
||||
|
|
Loading…
Reference in New Issue
Block a user