Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: courgette/ensemble.h

Issue 8417045: Last small bit of refactoring. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « courgette/disassembler_win32_x86.h ('k') | courgette/ensemble_apply.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The main idea in Courgette is to do patching *under a tranformation*. The 5 // The main idea in Courgette is to do patching *under a tranformation*. The
6 // input is transformed into a new representation, patching occurs in the new 6 // input is transformed into a new representation, patching occurs in the new
7 // repesentation, and then the tranform is reversed to get the patched data. 7 // repesentation, and then the tranform is reversed to get the patched data.
8 // 8 //
9 // The idea is applied to pieces (or 'Elements') of the whole (or 'Ensemble'). 9 // The idea is applied to pieces (or 'Elements') of the whole (or 'Ensemble').
10 // Each of the elements has to go through the same set of steps in lock-step, 10 // Each of the elements has to go through the same set of steps in lock-step,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // stream 3: 126 // stream 3:
127 // correction: 127 // correction:
128 // base-file 128 // base-file
129 // element-1 129 // element-1
130 // element-2 130 // element-2
131 // ... 131 // ...
132 132
133 static const uint32 kMagic = 'C' | ('o' << 8) | ('u' << 16); 133 static const uint32 kMagic = 'C' | ('o' << 8) | ('u' << 16);
134 134
135 static const uint32 kVersion = 20110216; 135 static const uint32 kVersion = 20110216;
136
137 // Transformation method IDs. These are embedded in generated files, so
138 // never remove or change an existing id.
139 enum TransformationMethodId {
140 T_COURGETTE_WIN32_X86 = 1, // Windows 32 bit 'Portable Executable' x86.
141 };
142 }; 136 };
143 137
144 // For any transform you would implement both a TransformationPatcher and a 138 // For any transform you would implement both a TransformationPatcher and a
145 // TransformationPatchGenerator. 139 // TransformationPatchGenerator.
146 // 140 //
147 // TransformationPatcher is the interface which abstracts out the actual 141 // TransformationPatcher is the interface which abstracts out the actual
148 // transformation used on an Element. The patching itself happens outside the 142 // transformation used on an Element. The patching itself happens outside the
149 // actions of a TransformationPatcher. There are four steps. 143 // actions of a TransformationPatcher. There are four steps.
150 // 144 //
151 // The first step is an Init step. The parameters to the Init step identify the 145 // The first step is an Init step. The parameters to the Init step identify the
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // 195 //
202 class TransformationPatchGenerator { 196 class TransformationPatchGenerator {
203 public: 197 public:
204 TransformationPatchGenerator(Element* old_element, 198 TransformationPatchGenerator(Element* old_element,
205 Element* new_element, 199 Element* new_element,
206 TransformationPatcher* patcher); 200 TransformationPatcher* patcher);
207 201
208 virtual ~TransformationPatchGenerator(); 202 virtual ~TransformationPatchGenerator();
209 203
210 // Returns the TransformationMethodId that identies this transformation. 204 // Returns the TransformationMethodId that identies this transformation.
211 virtual CourgettePatchFile::TransformationMethodId Kind() = 0; 205 virtual ExecutableType Kind() = 0;
212 206
213 // Writes the parameters that will be passed to TransformationPatcher::Init. 207 // Writes the parameters that will be passed to TransformationPatcher::Init.
214 virtual Status WriteInitialParameters(SinkStream* parameter_stream) = 0; 208 virtual Status WriteInitialParameters(SinkStream* parameter_stream) = 0;
215 209
216 // Predicts the transform parameters for the |old_element|. This must match 210 // Predicts the transform parameters for the |old_element|. This must match
217 // exactly the output that will be produced by the PredictTransformParameters 211 // exactly the output that will be produced by the PredictTransformParameters
218 // method of the corresponding subclass of TransformationPatcher. This method 212 // method of the corresponding subclass of TransformationPatcher. This method
219 // is not pure. The default implementation delegates to the patcher to 213 // is not pure. The default implementation delegates to the patcher to
220 // guarantee matching output. 214 // guarantee matching output.
221 virtual Status PredictTransformParameters(SinkStreamSet* prediction); 215 virtual Status PredictTransformParameters(SinkStreamSet* prediction);
(...skipping 23 matching lines...) Expand all
245 SinkStream* reformed_element); 239 SinkStream* reformed_element);
246 240
247 protected: 241 protected:
248 Element* old_element_; 242 Element* old_element_;
249 Element* new_element_; 243 Element* new_element_;
250 TransformationPatcher* patcher_; 244 TransformationPatcher* patcher_;
251 }; 245 };
252 246
253 } // namespace 247 } // namespace
254 #endif // COURGETTE_ENSEMBLE_H_ 248 #endif // COURGETTE_ENSEMBLE_H_
OLDNEW
« no previous file with comments | « courgette/disassembler_win32_x86.h ('k') | courgette/ensemble_apply.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698