@@ -124,25 +124,25 @@ template <typename T> struct ViewArray {
124
124
125
125
namespace DirectX {
126
126
127
- template <typename T> Expected<T> readParameter (StringRef Data) {
128
- T Struct;
129
- if (sizeof (T) != Data.size ())
130
- return make_error<GenericBinaryError>(
131
- " Reading structure out of file bounds" , object_error::parse_failed);
132
-
133
- memcpy (&Struct, Data.data (), sizeof (T));
134
- // DXContainer is always little endian
135
- if (sys::IsBigEndianHost)
136
- Struct.swapBytes ();
137
- return Struct;
138
- }
139
-
140
127
struct RootParameterView {
141
128
const dxbc::RTS0::v1::RootParameterHeader &Header;
142
129
StringRef ParamData;
143
130
144
131
RootParameterView (const dxbc::RTS0::v1::RootParameterHeader &H, StringRef P)
145
132
: Header(H), ParamData(P) {}
133
+
134
+ template <typename T> Expected<T> readParameter () {
135
+ T Struct;
136
+ if (sizeof (T) != ParamData.size ())
137
+ return make_error<GenericBinaryError>(
138
+ " Reading structure out of file bounds" , object_error::parse_failed);
139
+
140
+ memcpy (&Struct, ParamData.data (), sizeof (T));
141
+ // DXContainer is always little endian
142
+ if (sys::IsBigEndianHost)
143
+ Struct.swapBytes ();
144
+ return Struct;
145
+ }
146
146
};
147
147
148
148
struct RootConstantView : RootParameterView {
@@ -152,7 +152,7 @@ struct RootConstantView : RootParameterView {
152
152
}
153
153
154
154
llvm::Expected<dxbc::RTS0::v1::RootConstants> read () {
155
- return readParameter<dxbc::RTS0::v1::RootConstants>(ParamData );
155
+ return readParameter<dxbc::RTS0::v1::RootConstants>();
156
156
}
157
157
};
158
158
@@ -168,8 +168,7 @@ struct RootDescriptorView : RootParameterView {
168
168
169
169
llvm::Expected<dxbc::RTS0::v2::RootDescriptor> read (uint32_t Version) {
170
170
if (Version == 1 ) {
171
- auto Descriptor =
172
- readParameter<dxbc::RTS0::v1::RootDescriptor>(ParamData);
171
+ auto Descriptor = readParameter<dxbc::RTS0::v1::RootDescriptor>();
173
172
if (Error E = Descriptor.takeError ())
174
173
return E;
175
174
return dxbc::RTS0::v2::RootDescriptor (*Descriptor);
@@ -178,7 +177,7 @@ struct RootDescriptorView : RootParameterView {
178
177
return make_error<GenericBinaryError>(" Invalid Root Signature version: " +
179
178
Twine (Version),
180
179
object_error::parse_failed);
181
- return readParameter<dxbc::RTS0::v2::RootDescriptor>(ParamData );
180
+ return readParameter<dxbc::RTS0::v2::RootDescriptor>();
182
181
}
183
182
};
184
183
0 commit comments