Wed, 12 Feb 2014 06:15:11 +0200
- refactored enums, macros split from Main.h to Macros.h
88 | 1 | /* |
2 | Copyright 2012-2014 Santeri Piippo | |
3 | All rights reserved. | |
4 | ||
5 | Redistribution and use in source and binary forms, with or without | |
6 | modification, are permitted provided that the following conditions | |
7 | are met: | |
8 | ||
9 | 1. Redistributions of source code must retain the above copyright | |
10 | notice, this list of conditions and the following disclaimer. | |
11 | 2. Redistributions in binary form must reproduce the above copyright | |
12 | notice, this list of conditions and the following disclaimer in the | |
13 | documentation and/or other materials provided with the distribution. | |
14 | 3. The name of the author may not be used to endorse or promote products | |
15 | derived from this software without specific prior written permission. | |
16 | ||
17 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
18 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
20 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
22 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
26 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #ifndef BOTC_TYPES_H | |
30 | #define BOTC_TYPES_H | |
31 | ||
32 | #include <cstdlib> | |
33 | #include <stdexcept> | |
108
6409ece8297c
- refactored enums, macros split from Main.h to Macros.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
88
diff
changeset
|
34 | #include "Macros.h" |
88 | 35 | #include "String.h" |
36 | ||
37 | static const std::nullptr_t null = nullptr; | |
38 | ||
39 | // ============================================================================= | |
40 | // | |
108
6409ece8297c
- refactored enums, macros split from Main.h to Macros.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
88
diff
changeset
|
41 | named_enum DataType |
88 | 42 | { |
108
6409ece8297c
- refactored enums, macros split from Main.h to Macros.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
88
diff
changeset
|
43 | TYPE_Unknown = 0, |
6409ece8297c
- refactored enums, macros split from Main.h to Macros.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
88
diff
changeset
|
44 | TYPE_Void, |
6409ece8297c
- refactored enums, macros split from Main.h to Macros.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
88
diff
changeset
|
45 | TYPE_Int, |
6409ece8297c
- refactored enums, macros split from Main.h to Macros.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
88
diff
changeset
|
46 | TYPE_String, |
6409ece8297c
- refactored enums, macros split from Main.h to Macros.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
88
diff
changeset
|
47 | TYPE_Bool, |
88 | 48 | }; |
49 | ||
50 | // ============================================================================= | |
51 | // | |
52 | struct ByteMark | |
53 | { | |
54 | String name; | |
55 | int pos; | |
56 | }; | |
57 | ||
58 | // ============================================================================= | |
59 | // | |
60 | struct MarkReference | |
61 | { | |
62 | ByteMark* target; | |
63 | int pos; | |
64 | }; | |
65 | ||
66 | // ============================================================================= | |
67 | // | |
68 | class ScriptError : public std::exception | |
69 | { | |
70 | public: | |
71 | ScriptError (const String& msg) : | |
72 | mMsg (msg) {} | |
73 | ||
74 | inline const char* what() const throw() | |
75 | { | |
76 | return mMsg; | |
77 | } | |
78 | ||
79 | private: | |
80 | String mMsg; | |
81 | }; | |
82 | ||
83 | // ============================================================================= | |
84 | // | |
85 | // Get absolute value of @a | |
86 | // | |
87 | template<class T> inline T abs (T a) | |
88 | { | |
89 | return (a >= 0) ? a : -a; | |
90 | } | |
91 | ||
92 | #ifdef IN_IDE_PARSER | |
93 | using FILE = void; | |
94 | #endif | |
95 | ||
108
6409ece8297c
- refactored enums, macros split from Main.h to Macros.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
88
diff
changeset
|
96 | #endif // BOTC_TYPES_H |