OSDN Git Service

merge in klp-release history after reset to klp-dev
[android-x86/dalvik.git] / vm / RawDexFile.h
1 /*
2  * Copyright (C) 2008 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  * This represents a "raw" unswapped, unoptimized DEX file.  We don't open
18  * them directly, except to create the optimized version that we tuck in
19  * the cache area.
20  */
21 #ifndef DALVIK_RAWDEXFILE_H_
22 #define DALVIK_RAWDEXFILE_H_
23
24 /*
25  * Structure representing a "raw" DEX file, in its unswapped unoptimized
26  * state.
27  */
28 struct RawDexFile {
29     char*       cacheFileName;
30     DvmDex*     pDvmDex;
31 };
32
33 /*
34  * Open a raw ".dex" file, optimize it, and load it.
35  *
36  * On success, returns 0 and sets "*ppDexFile" to a newly-allocated DexFile.
37  * On failure, returns a meaningful error code [currently just -1].
38  */
39 int dvmRawDexFileOpen(const char* fileName, const char* odexOutputName,
40     RawDexFile** ppDexFile, bool isBootstrap);
41
42 /*
43  * Open a raw ".dex" file based on the given chunk of memory, and load
44  * it. The bytes are assumed to be owned by the caller for the
45  * purposes of memory management and further assumed to not be touched
46  * by the caller while the raw dex file remains open. The bytes *may*
47  * be modified as the result of issuing this call.
48  *
49  * On success, returns 0 and sets "*ppDexFile" to a newly-allocated DexFile.
50  * On failure, returns a meaningful error code [currently just -1].
51  */
52 int dvmRawDexFileOpenArray(u1* pBytes, u4 length, RawDexFile** ppDexFile);
53
54 /*
55  * Free a RawDexFile structure, along with any associated structures.
56  */
57 void dvmRawDexFileFree(RawDexFile* pRawDexFile);
58
59 /*
60  * Pry the DexFile out of a RawDexFile.
61  */
62 INLINE DvmDex* dvmGetRawDexFileDex(RawDexFile* pRawDexFile) {
63     return pRawDexFile->pDvmDex;
64 }
65
66 /* get full path of optimized DEX file */
67 INLINE const char* dvmGetRawDexFileCacheFileName(RawDexFile* pRawDexFile) {
68     return pRawDexFile->cacheFileName;
69 }
70
71 #endif  // DALVIK_RAWDEXFILE_H_