Skip to content

Commit

Permalink
Merge pull request #69 from alliedmodders/pragma-newdecls
Browse files Browse the repository at this point in the history
Add #pragma newdecls required|optional.
  • Loading branch information
dvander committed Jul 5, 2014
2 parents bfc65b0 + 96bbd4d commit 3f220bc
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 258 deletions.
5 changes: 3 additions & 2 deletions plugins/nextmap.sp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
* Version: $Id$
*/

#pragma semicolon 1

#include <sourcemod>
#include "include/nextmap.inc"

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
name = "Nextmap",
Expand Down
5 changes: 3 additions & 2 deletions plugins/sounds.sp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
* Version: $Id$
*/

#pragma semicolon 1

#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
name = "Sound Commands",
Expand Down
17 changes: 15 additions & 2 deletions sourcepawn/compiler/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int pc_compile(int argc, char *argv[])
char codepage[MAXCODEPAGE+1];
FILE *binf;
void *inpfmark;
int lcl_packstr,lcl_needsemicolon,lcl_tabsize;
int lcl_packstr,lcl_needsemicolon,lcl_tabsize,lcl_require_newdecls;
#if !defined SC_LIGHT
int hdrsize=0;
#endif
Expand Down Expand Up @@ -252,6 +252,7 @@ int pc_compile(int argc, char *argv[])
sc_ctrlchar_org=sc_ctrlchar;
lcl_packstr=sc_packstr;
lcl_needsemicolon=sc_needsemicolon;
lcl_require_newdecls=sc_require_newdecls;
lcl_tabsize=sc_tabsize;
#if !defined NO_CODEPAGE
if (!cp_set(codepage)) /* set codepage */
Expand Down Expand Up @@ -359,6 +360,7 @@ int pc_compile(int argc, char *argv[])
sc_ctrlchar=sc_ctrlchar_org;
sc_packstr=lcl_packstr;
sc_needsemicolon=lcl_needsemicolon;
sc_require_newdecls=lcl_require_newdecls;
sc_tabsize=lcl_tabsize;
errorset(sRESET,0);
/* reset the source file */
Expand Down Expand Up @@ -428,6 +430,7 @@ int pc_compile(int argc, char *argv[])
sc_ctrlchar=sc_ctrlchar_org;
sc_packstr=lcl_packstr;
sc_needsemicolon=lcl_needsemicolon;
sc_require_newdecls=lcl_require_newdecls;
sc_tabsize=lcl_tabsize;
errorset(sRESET,0);
/* reset the source file */
Expand Down Expand Up @@ -772,6 +775,7 @@ static void initglobals(void)
sc_packstr=TRUE; /* strings are packed by default */
sc_compress=FALSE; /* always disable compact encoding! */
sc_needsemicolon=FALSE;/* semicolon required to terminate expressions? */
sc_require_newdecls = FALSE;
sc_dataalign=sizeof(cell);
pc_stksize=sDEF_AMXSTACK;/* default stack size */
pc_amxlimit=0; /* no limit on size of the abstract machine */
Expand Down Expand Up @@ -3317,6 +3321,9 @@ static int parse_old_decl(declinfo_t *decl, int flags)
parse_old_array_dims(decl, flags);
}

if (sc_require_newdecls)
error(147);

return TRUE;
}

Expand Down Expand Up @@ -3599,7 +3606,13 @@ symbol *parse_inline_function(methodmap_t *map, const typeinfo_t *type, const ch
if (is_native) {
target = funcstub(tMETHODMAP, &decl, thistag);
} else {
if (!newfunc(&decl, thistag, FALSE, FALSE, TRUE, &target))
int lcl_require_newdecls = sc_require_newdecls;

sc_require_newdecls = TRUE;
int ok = newfunc(&decl, thistag, FALSE, FALSE, TRUE, &target);
sc_require_newdecls = lcl_require_newdecls;

if (!ok)
return NULL;
if (!target || (target->usage & uFORWARD)) {
error(10);
Expand Down
20 changes: 10 additions & 10 deletions sourcepawn/compiler/sc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,12 +1110,6 @@ static int command(void)
}
}
} /* if */
#if 0 /* more unused */
} else if (strcmp(str,"pack")==0) {
cell val;
preproc_expr(&val,NULL); /* default = packed/unpacked */
sc_packstr=(int)val;
#endif
} else if (strcmp(str,"rational")==0) {
char name[sNAMEMAX+1];
cell digits=0;
Expand Down Expand Up @@ -1151,10 +1145,16 @@ static int command(void)
cell val;
preproc_expr(&val,NULL);
sc_needsemicolon=(int)val;
} else if (strcmp(str, "require_newdecls")==0) {
cell val;
preproc_expr(&val,NULL);
sc_require_newdecls = (int)val;
} else if (strcmp(str, "newdecls")==0) {
while (*lptr<=' ' && *lptr!='\0')
lptr++;
if (strncmp((char *)lptr, "required", 8) == 0)
sc_require_newdecls = 1;
else if (strncmp((char *)lptr, "optional", 8) == 0)
sc_require_newdecls = 0;
else
error(146);
lptr=(unsigned char*)strchr((char*)lptr,'\0'); /* skip to end (ignore "extra characters on line") */
} else if (strcmp(str,"tabsize")==0) {
cell val;
preproc_expr(&val,NULL);
Expand Down
Loading

0 comments on commit 3f220bc

Please sign in to comment.