]> git.mxchange.org Git - simgear.git/blob - simgear/hla/HLADataType.cxx
hla: Fix buffer overrun in SGMath vector types.
[simgear.git] / simgear / hla / HLADataType.cxx
1 // Copyright (C) 2009 - 2012  Mathias Froehlich - Mathias.Froehlich@web.de
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Library General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16 //
17
18 #include "HLADataType.hxx"
19
20 #include "HLADataElement.hxx"
21 #include "HLADataTypeVisitor.hxx"
22
23 namespace simgear {
24
25 HLADataType::HLADataType(const std::string& name, unsigned alignment) :
26     _name(name),
27     _alignment(1)
28 {
29     setAlignment(alignment);
30 }
31
32 HLADataType::~HLADataType()
33 {
34 }
35
36 void
37 HLADataType::accept(HLADataTypeVisitor& visitor) const
38 {
39     visitor.apply(*this);
40 }
41
42 const HLABasicDataType*
43 HLADataType::toBasicDataType() const
44 {
45     return 0;
46 }
47
48 const HLAArrayDataType*
49 HLADataType::toArrayDataType() const
50 {
51     return 0;
52 }
53
54 const HLAEnumeratedDataType*
55 HLADataType::toEnumeratedDataType() const
56 {
57     return 0;
58 }
59
60 const HLAFixedRecordDataType*
61 HLADataType::toFixedRecordDataType() const
62 {
63     return 0;
64 }
65
66 const HLAVariantRecordDataType*
67 HLADataType::toVariantRecordDataType() const
68 {
69     return 0;
70 }
71
72 bool
73 HLADataType::recomputeAlignment()
74 {
75     unsigned alignment = getAlignment();
76     _recomputeAlignmentImplementation();
77     return alignment != getAlignment();
78 }
79
80 void
81 HLADataType::releaseDataTypeReferences()
82 {
83 }
84
85 void
86 HLADataType::setAlignment(unsigned alignment)
87 {
88     /// FIXME: more checks
89     if (alignment == 0)
90         _alignment = 1;
91     else
92         _alignment = alignment;
93 }
94
95 void
96 HLADataType::_recomputeAlignmentImplementation()
97 {
98 }
99
100 }