• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __ANDROID_BCINFO_BITCODETRANSLATOR_H__
18 #define __ANDROID_BCINFO_BITCODETRANSLATOR_H__
19 
20 #include <cstddef>
21 
22 namespace bcinfo {
23 
24 class BitcodeTranslator {
25  private:
26   const char *mBitcode;
27   size_t mBitcodeSize;
28   const char *mTranslatedBitcode;
29   size_t mTranslatedBitcodeSize;
30   unsigned int mVersion;
31 
32  public:
33   /**
34    * Translates \p bitcode of a particular \p version to the latest version.
35    *
36    * \param bitcode - input bitcode string.
37    * \param bitcodeSize - length of \p bitcode string (in bytes).
38    * \param version - corresponding target SDK version of \p bitcode.
39    */
40   BitcodeTranslator(const char *bitcode, size_t bitcodeSize,
41                     unsigned int version);
42 
43   ~BitcodeTranslator();
44 
45   /**
46    * Translate the supplied bitcode to the latest supported version.
47    *
48    * \return true if the bitcode was translated successfully and false if an
49    *         error occurred.
50    */
51   bool translate();
52 
53   /**
54    * \return translated bitcode.
55    */
getTranslatedBitcode()56   const char *getTranslatedBitcode() const {
57     return mTranslatedBitcode;
58   }
59 
60   /**
61    * \return size of the translated bitcode (in bytes).
62    */
getTranslatedBitcodeSize()63   size_t getTranslatedBitcodeSize() const {
64     return mTranslatedBitcodeSize;
65   }
66 };
67 
68 }  // namespace bcinfo
69 
70 #endif  // __ANDROID_BCINFO_BITCODETRANSLATOR_H__
71