src/script/objtype.h

Sat, 22 Aug 2015 13:04:58 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 22 Aug 2015 13:04:58 +0300
branch
scripting
changeset 942
afbd122f3eff
parent 925
2f316b57b508
permissions
-rw-r--r--

Commit work on scripting

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
925
2f316b57b508 - added/corrected license headers
Teemu Piippo <crimsondusk64@gmail.com>
parents: 923
diff changeset
3 * Copyright (C) 2015 Teemu Piippo
923
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 {
942
afbd122f3eff Commit work on scripting
Teemu Piippo <crimsondusk64@gmail.com>
parents: 925
diff changeset
24 class ObjectType
923
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:
942
afbd122f3eff Commit work on scripting
Teemu Piippo <crimsondusk64@gmail.com>
parents: 925
diff changeset
27 ObjectType();
923
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
942
afbd122f3eff Commit work on scripting
Teemu Piippo <crimsondusk64@gmail.com>
parents: 925
diff changeset
31 class BasicType : public ObjectType
923
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
942
afbd122f3eff Commit work on scripting
Teemu Piippo <crimsondusk64@gmail.com>
parents: 925
diff changeset
51 class ContainerType : public ObjectType
923
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; }
942
afbd122f3eff Commit work on scripting
Teemu Piippo <crimsondusk64@gmail.com>
parents: 925
diff changeset
68 QSharedPointer<ObjectType> elementType() const { return m_elementType; }
923
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;
942
afbd122f3eff Commit work on scripting
Teemu Piippo <crimsondusk64@gmail.com>
parents: 925
diff changeset
72 QSharedPointer<ObjectType> m_elementType;
923
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