~ubuntu-branches/debian/sid/freeciv/sid

« back to all changes in this revision

Viewing changes to server/scripting/script.h

  • Committer: Package Import Robot
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2011-08-28 22:40:00 UTC
  • mfrom: (1.2.19 upstream)
  • Revision ID: package-import@ubuntu.com-20110828224000-j2r1erewlem25dox
Tags: 2.3.0-1
[ Karl Goetz ]
* New upstream version.
* Fix themes_sdl_use_system_fonts.diff to apply cleanly on 2.3.0
* Massage work_around_unity_induced_breakage.diff to get it
  applying to the new codebase (The patch assumes commits made
  after 2.3.0 was tagged upstream).

[ Clint Adams ]
* Fudge build system to think there is no libtool mismatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
struct section_file;
24
24
 
25
 
/* internal api error function. */
 
25
/* internal api error functions */
26
26
int script_error(const char *fmt, ...)
27
27
    fc__attribute((__format__ (__printf__, 1, 2)));
28
28
 
29
 
/* Returns additional arguments on failure. */
30
 
#define SCRIPT_ASSERT_CAT(str1, str2) str1 ## str2
31
 
#define SCRIPT_ASSERT(check, ...)                                           \
32
 
  if (!(check)) {                                                           \
33
 
    script_error("in %s() [%s::%d]: the assertion '%s' failed.",            \
34
 
                 __FUNCTION__, __FILE__, __LINE__, #check);                 \
35
 
    return SCRIPT_ASSERT_CAT(, __VA_ARGS__);                                \
36
 
  }
 
29
int script_arg_error(int narg, const char *msg);
37
30
 
38
31
/* callback invocation function. */
39
32
bool script_callback_invoke(const char *callback_name,
44
37
/* script functions. */
45
38
bool script_init(void);
46
39
void script_free(void);
 
40
bool script_do_string(const char *str);
47
41
bool script_do_file(const char *filename);
48
42
 
49
43
/* script state i/o. */
50
44
void script_state_load(struct section_file *file);
51
45
void script_state_save(struct section_file *file);
52
46
 
 
47
 
 
48
/* Returns additional arguments on failure. */
 
49
#define SCRIPT_ASSERT_CAT(str1, str2) str1 ## str2
 
50
 
 
51
/* Script assertion (for debugging only) */
 
52
#ifdef DEBUG
 
53
#define SCRIPT_ASSERT(check, ...)                                           \
 
54
  if (!(check)) {                                                           \
 
55
    script_error("in %s() [%s::%d]: the assertion '%s' failed.",            \
 
56
                 __FUNCTION__, __FILE__, __LINE__, #check);                 \
 
57
    return SCRIPT_ASSERT_CAT(, __VA_ARGS__);                                \
 
58
  }
 
59
#else
 
60
#define SCRIPT_ASSERT(check, ...)
53
61
#endif
54
62
 
 
63
/* script_error on failed check */
 
64
#define SCRIPT_CHECK(check, msg, ...)                                       \
 
65
  if (!(check)) {                                                           \
 
66
    script_error(msg);                                                      \
 
67
    return SCRIPT_ASSERT_CAT(, __VA_ARGS__);                                \
 
68
  }
 
69
 
 
70
/* script_arg_error on failed check */
 
71
#define SCRIPT_CHECK_ARG(check, narg, msg, ...)                             \
 
72
  if (!(check)) {                                                           \
 
73
    script_arg_error(narg, msg);                                            \
 
74
    return SCRIPT_ASSERT_CAT(, __VA_ARGS__);                                \
 
75
  }
 
76
 
 
77
/* script_arg_error on nil value */
 
78
#define SCRIPT_CHECK_ARG_NIL(value, narg, type, ...)                        \
 
79
  if ((value) == NULL) {                                                    \
 
80
    script_arg_error(narg, "got 'nil', '" #type "' expected");              \
 
81
    return SCRIPT_ASSERT_CAT(, __VA_ARGS__);                                \
 
82
  }
 
83
 
 
84
/* script_arg_error on nil value */
 
85
#define SCRIPT_CHECK_SELF(value, ...)                                       \
 
86
  if ((value) == NULL) {                                                    \
 
87
    script_arg_error(1, "got 'nil' for self");                              \
 
88
    return SCRIPT_ASSERT_CAT(, __VA_ARGS__);                                \
 
89
  }
 
90
 
 
91
#endif /* FC__SCRIPT_H */
 
92