OSDN Git Service

am 548d70b0: am 23966773: Rename absoluteMaxSize to maximumSize.
[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
22 #define _DALVIK_RAWDEXFILE
23
24 /*
25  * Structure representing a "raw" DEX file, in its unswapped unoptimized
26  * state.
27  */
28 typedef struct RawDexFile {
29     char*       cacheFileName;
30     DvmDex*     pDvmDex;
31 } RawDexFile;
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(const u1* pBytes, u4 length,
53     RawDexFile** ppDexFile);
54
55 /*
56  * Free a RawDexFile structure, along with any associated structures.
57  */
58 void dvmRawDexFileFree(RawDexFile* pRawDexFile);
59
60 /*
61  * Pry the DexFile out of a RawDexFile.
62  */
63 INLINE DvmDex* dvmGetRawDexFileDex(RawDexFile* pRawDexFile) {
64     return pRawDexFile->pDvmDex;
65 }
66
67 /* get full path of optimized DEX file */
68 INLINE const char* dvmGetRawDexFileCacheFileName(RawDexFile* pRawDexFile) {
69     return pRawDexFile->cacheFileName;
70 }
71
72 #endif /*_DALVIK_RAWDEXFILE*/