Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / tools / relocation_packer / src / leb128.h
index 7ae5710..6cc2d7c 100644 (file)
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// LEB128 encoder and decoder for packed R_ARM_RELATIVE relocations.
+// LEB128 encoder and decoder for packed relative relocations.
 //
-// Run-length encoded R_ARM_RELATIVE relocations consist of a large number
+// Run-length encoded relative relocations consist of a large number
 // of pairs of relatively small positive integer values.  Encoding these as
 // LEB128 saves space.
 //
 #define TOOLS_RELOCATION_PACKER_SRC_LEB128_H_
 
 #include <stdint.h>
-#include <unistd.h>
 #include <vector>
 
+#include "elf_traits.h"
+
 namespace relocation_packer {
 
 // Encode packed words as a LEB128 byte stream.
 class Leb128Encoder {
  public:
+  // Explicit (but empty) constructor and destructor, for chromium-style.
+  Leb128Encoder();
+  ~Leb128Encoder();
+
   // Add a value to the encoding stream.
   // |value| is the unsigned int to add.
-  void Enqueue(uint32_t value);
+  void Enqueue(ELF::Xword value);
 
   // Add a vector of values to the encoding stream.
   // |values| is the vector of unsigned ints to add.
-  void EnqueueAll(const std::vector<uint32_t>& values);
+  void EnqueueAll(const std::vector<ELF::Xword>& values);
 
   // Retrieve the encoded representation of the values.
   // |encoding| is the returned vector of encoded data.
@@ -44,15 +49,17 @@ class Leb128Decoder {
  public:
   // Create a new decoder for the given encoded stream.
   // |encoding| is the vector of encoded data.
-  explicit Leb128Decoder(const std::vector<uint8_t>& encoding)
-      : encoding_(encoding), cursor_(0) { }
+  explicit Leb128Decoder(const std::vector<uint8_t>& encoding);
+
+  // Explicit (but empty) destructor, for chromium-style.
+  ~Leb128Decoder();
 
   // Retrieve the next value from the encoded stream.
-  uint32_t Dequeue();
+  ELF::Xword Dequeue();
 
   // Retrieve all remaining values from the encoded stream.
   // |values| is the vector of decoded data.
-  void DequeueAll(std::vector<uint32_t>* values);
+  void DequeueAll(std::vector<ELF::Xword>* values);
 
  private:
   // Encoded LEB128 stream.