1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef DIRECTOR_LINGO_LINGO_UTILS_H
24 #define DIRECTOR_LINGO_LINGO_UTILS_H
25 
26 #define ARGNUMCHECK(n) \
27 	if (nargs != (n)) { \
28 		warning("%s: expected %d argument%s, got %d", __FUNCTION__, (n), ((n) == 1 ? "" : "s"), nargs); \
29 		g_lingo->dropStack(nargs); \
30 		return; \
31 	}
32 
33 #define TYPECHECK(datum,t) \
34 	if ((datum).type != (t)) { \
35 		warning("%s: %s arg should be of type %s, not %s", __FUNCTION__, #datum, #t, (datum).type2str()); \
36 		return; \
37 	}
38 
39 #define TYPECHECK2(datum, t1, t2)	\
40 	if ((datum).type != (t1) && (datum).type != (t2)) { \
41 		warning("%s: %s arg should be of type %s or %s, not %s", __FUNCTION__, #datum, #t1, #t2, (datum).type2str()); \
42 		return; \
43 	}
44 
45 #define TYPECHECK3(datum, t1, t2, t3)	\
46 	if ((datum).type != (t1) && (datum).type != (t2) && (datum).type != (t3)) { \
47 		warning("%s: %s arg should be of type %s, %s, or %s, not %s", __FUNCTION__, #datum, #t1, #t2, #t3, (datum).type2str()); \
48 		return; \
49 	}
50 
51 #define ARRBOUNDSCHECK(idx,array) \
52 	if ((idx)-1 < 0 || (idx) > (int)(array).u.farr->arr.size()) { \
53 		warning("%s: index out of bounds (%d of %d)", __FUNCTION__, (idx), (array).u.farr->arr.size()); \
54 		return; \
55 	}
56 
57 #endif
58