src/script/objtype.h

Tue, 03 Feb 2015 04:03:19 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Tue, 03 Feb 2015 04:03:19 +0200
branch
scripting
changeset 923
e15a577a0bfe
child 925
2f316b57b508
permissions
-rw-r--r--

- now parses to tokens

923
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 - 2015 Teemu Piippo
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #pragma once
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "../main.h"
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 namespace Script
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 {
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 class Type
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 {
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 public:
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 Type();
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 virtual QString asString() const = 0;
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 };
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 class BasicType : public Type
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 {
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 public:
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 enum Kind
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 {
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 VAR, // mixed
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 INT,
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 REAL,
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 STRING,
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 TYPE, // heh
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 OBJECT,
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 };
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 QString asString() const override;
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 Kind kind() const { return m_kind; }
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 private:
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 Kind m_kind;
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 };
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 class ContainerType : public Type
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 {
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 public:
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 enum Kind
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 {
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 ARRAY,
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 TUPLE,
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 MATRIX
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 };
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 ContainerType (Kind kind, int n1, int n2) :
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 m_kind (kind), m_n1 (n1), m_n2 (n2) {}
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 QString asString() const override;
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 Kind kind() const { return m_kind; }
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 int n1() const { return m_n1; }
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 int n2() const { return m_n1; }
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 QSharedPointer<Type> elementType() const { return m_elementType; }
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 private:
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 Kind m_kind;
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 QSharedPointer<Type> m_elementType;
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 int m_n1;
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 int m_n2;
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 };
e15a577a0bfe - now parses to tokens
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 }

mercurial