ScummVM API documentation
lingo-utils.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef DIRECTOR_LINGO_LINGO_UTILS_H
23#define DIRECTOR_LINGO_LINGO_UTILS_H
24
25#define ARGNUMCHECK(n) \
26 if (nargs != (n)) { \
27 warning("BUILDBOT: %s: expected %d argument%s, got %d", __FUNCTION__, (n), ((n) == 1 ? "" : "s"), nargs); \
28 g_lingo->dropStack(nargs); \
29 return; \
30 }
31
32#define TYPECHECK(datum,t) \
33 if ((datum).type != (t)) { \
34 warning("BUILDBOT: %s: %s arg should be of type %s, not %s", __FUNCTION__, #datum, #t, (datum).type2str()); \
35 return; \
36 }
37
38#define TYPECHECK2(datum, t1, t2) \
39 if ((datum).type != (t1) && (datum).type != (t2)) { \
40 warning("BUILDBOT: %s: %s arg should be of type %s or %s, not %s", __FUNCTION__, #datum, #t1, #t2, (datum).type2str()); \
41 return; \
42 }
43
44#define TYPECHECK3(datum, t1, t2, t3) \
45 if ((datum).type != (t1) && (datum).type != (t2) && (datum).type != (t3)) { \
46 warning("BUILDBOT: %s: %s arg should be of type %s, %s, or %s, not %s", __FUNCTION__, #datum, #t1, #t2, #t3, (datum).type2str()); \
47 return; \
48 }
49
50#define TYPECHECK4(datum, t1, t2, t3, t4) \
51 if ((datum).type != (t1) && (datum).type != (t2) && (datum).type != (t3) && (datum).type != (t4)) { \
52 warning("BUILDBOT: %s: %s arg should be of type %s, %s, %s, or %s, not %s", __FUNCTION__, #datum, #t1, #t2, #t3, #t4, (datum).type2str()); \
53 return; \
54 }
55
56#define ARRBOUNDSCHECK(idx,array) \
57 if ((idx)-1 < 0 || (idx) > (int)(array).u.farr->arr.size()) { \
58 g_lingo->lingoError("%s: index out of bounds (%d of %d)", __FUNCTION__, (idx), (array).u.farr->arr.size()); \
59 return; \
60 }
61
62#define XOBJSTUB(methname,retval) \
63 void methname(int nargs) { \
64 g_lingo->printSTUBWithArglist(#methname, nargs); \
65 g_lingo->dropStack(nargs); \
66 g_lingo->push(Datum(retval)); \
67 }
68
69#define XOBJSTUBV(methname) \
70 void methname(int nargs) { \
71 g_lingo->printSTUBWithArglist(#methname, nargs); \
72 g_lingo->dropStack(nargs); \
73 g_lingo->push(Datum()); \
74 }
75
76#define XOBJSTUBNR(methname) \
77 void methname(int nargs) { \
78 g_lingo->printSTUBWithArglist(#methname, nargs); \
79 g_lingo->dropStack(nargs); \
80 }
81
82#endif