Commit bfc9799b authored by Carl Shapiro's avatar Carl Shapiro
Browse files

Make libdex structures tool friendly.

Previously, the struct name and its typedef name were identical.  This
confuses emacs and etags.  This change eliminates the typedef names and
removes the extern "C" wrapping the libdex header files.  To support
this change the transitive C dependencies have been made to compile as
C++ instead.

Change-Id: I7065f32d61d776f9b09c7b461adf2502268d852f
parent 093bba7f
......@@ -20,7 +20,7 @@ LOCAL_PATH:= $(call my-dir)
#
dalvikvm_src_files := \
Main.c
Main.cpp
dalvikvm_c_includes := \
$(JNI_H_INCLUDE) \
......
......@@ -48,14 +48,14 @@ static jobjectArray createStringArray(JNIEnv* env, char* const argv[], int argc)
jobjectArray result = NULL;
int i;
stringClass = (*env)->FindClass(env, "java/lang/String");
if ((*env)->ExceptionCheck(env)) {
stringClass = env->FindClass("java/lang/String");
if (env->ExceptionCheck()) {
fprintf(stderr, "Got exception while finding class String\n");
goto bail;
}
assert(stringClass != NULL);
strArray = (*env)->NewObjectArray(env, argc, stringClass, NULL);
if ((*env)->ExceptionCheck(env)) {
strArray = env->NewObjectArray(argc, stringClass, NULL);
if (env->ExceptionCheck()) {
fprintf(stderr, "Got exception while creating String array\n");
goto bail;
}
......@@ -64,14 +64,14 @@ static jobjectArray createStringArray(JNIEnv* env, char* const argv[], int argc)
for (i = 0; i < argc; i++) {
jstring argStr;
argStr = (*env)->NewStringUTF(env, argv[i]);
if ((*env)->ExceptionCheck(env)) {
argStr = env->NewStringUTF(argv[i]);
if (env->ExceptionCheck()) {
fprintf(stderr, "Got exception while allocating Strings\n");
goto bail;
}
assert(argStr != NULL);
(*env)->SetObjectArrayElement(env, strArray, i, argStr);
(*env)->DeleteLocalRef(env, argStr);
env->SetObjectArrayElement(strArray, i, argStr);
env->DeleteLocalRef(argStr);
}
/* return the array, and ensure we don't delete the local ref to it */
......@@ -79,8 +79,8 @@ static jobjectArray createStringArray(JNIEnv* env, char* const argv[], int argc)
strArray = NULL;
bail:
(*env)->DeleteLocalRef(env, stringClass);
(*env)->DeleteLocalRef(env, strArray);
env->DeleteLocalRef(stringClass);
env->DeleteLocalRef(strArray);
return result;
}
......@@ -98,7 +98,7 @@ static int methodIsPublic(JNIEnv* env, jclass clazz, jmethodID methodId)
int modifiers;
int result = JNI_FALSE;
refMethod = (*env)->ToReflectedMethod(env, clazz, methodId, JNI_FALSE);
refMethod = env->ToReflectedMethod(clazz, methodId, JNI_FALSE);
if (refMethod == NULL) {
fprintf(stderr, "Dalvik VM unable to get reflected method\n");
goto bail;
......@@ -108,19 +108,19 @@ static int methodIsPublic(JNIEnv* env, jclass clazz, jmethodID methodId)
* We now have a Method instance. We need to call
* its getModifiers() method.
*/
methodClass = (*env)->FindClass(env, "java/lang/reflect/Method");
methodClass = env->FindClass("java/lang/reflect/Method");
if (methodClass == NULL) {
fprintf(stderr, "Dalvik VM unable to find class Method\n");
goto bail;
}
getModifiersId = (*env)->GetMethodID(env, methodClass,
getModifiersId = env->GetMethodID(methodClass,
"getModifiers", "()I");
if (getModifiersId == NULL) {
fprintf(stderr, "Dalvik VM unable to find reflect.Method.getModifiers\n");
goto bail;
}
modifiers = (*env)->CallIntMethod(env, refMethod, getModifiersId);
modifiers = env->CallIntMethod(refMethod, getModifiersId);
if ((modifiers & PUBLIC) == 0) {
fprintf(stderr, "Dalvik VM: main() is not public\n");
goto bail;
......@@ -129,8 +129,8 @@ static int methodIsPublic(JNIEnv* env, jclass clazz, jmethodID methodId)
result = JNI_TRUE;
bail:
(*env)->DeleteLocalRef(env, refMethod);
(*env)->DeleteLocalRef(env, methodClass);
env->DeleteLocalRef(refMethod);
env->DeleteLocalRef(methodClass);
return result;
}
......@@ -246,13 +246,13 @@ int main(int argc, char* const argv[])
if (*cp == '.')
*cp = '/';
startClass = (*env)->FindClass(env, slashClass);
startClass = env->FindClass(slashClass);
if (startClass == NULL) {
fprintf(stderr, "Dalvik VM unable to locate class '%s'\n", slashClass);
goto bail;
}
startMeth = (*env)->GetStaticMethodID(env, startClass,
startMeth = env->GetStaticMethodID(startClass,
"main", "([Ljava/lang/String;)V");
if (startMeth == NULL) {
fprintf(stderr, "Dalvik VM unable to find static main(String[]) in '%s'\n",
......@@ -270,9 +270,9 @@ int main(int argc, char* const argv[])
/*
* Invoke main().
*/
(*env)->CallStaticVoidMethod(env, startClass, startMeth, strArray);
env->CallStaticVoidMethod(startClass, startMeth, strArray);
if (!(*env)->ExceptionCheck(env))
if (!env->ExceptionCheck())
result = 0;
bail:
......@@ -282,12 +282,12 @@ bail:
* This allows join() and isAlive() on the main thread to work
* correctly, and also provides uncaught exception handling.
*/
if ((*vm)->DetachCurrentThread(vm) != JNI_OK) {
if (vm->DetachCurrentThread() != JNI_OK) {
fprintf(stderr, "Warning: unable to detach main thread\n");
result = 1;
}
if ((*vm)->DestroyJavaVM(vm) != 0)
if (vm->DestroyJavaVM() != 0)
fprintf(stderr, "Warning: Dalvik VM did not shut down cleanly\n");
/*printf("\nDalvik VM has exited\n");*/
}
......
......@@ -18,7 +18,7 @@
LOCAL_PATH:= $(call my-dir)
dexdump_src_files := \
DexDump.c
DexDump.cpp
dexdump_c_includes := \
dalvik \
......
......@@ -52,13 +52,13 @@
static const char* gProgName = "dexdump";
typedef enum OutputFormat {
enum OutputFormat {
OUTPUT_PLAIN = 0, /* default */
OUTPUT_XML, /* fancy */
} OutputFormat;
};
/* command-line options */
struct {
struct Options {
bool checksumOnly;
bool disassemble;
bool showFileHeaders;
......@@ -69,14 +69,16 @@ struct {
const char* tempFileName;
bool exportsOnly;
bool verbose;
} gOptions;
};
struct Options gOptions;
/* basic info about a field or method */
typedef struct FieldMethodInfo {
struct FieldMethodInfo {
const char* classDescriptor;
const char* name;
const char* signature;
} FieldMethodInfo;
};
/*
* Get 2 little-endian bytes.
......@@ -150,7 +152,7 @@ static char* descriptorToDot(const char* str)
}
}
newStr = malloc(targetLen + arrayDepth * 2 +1);
newStr = (char*)malloc(targetLen + arrayDepth * 2 +1);
/* copy class name over */
int i;
......@@ -825,7 +827,7 @@ static char* indexString(DexFile* pDexFile,
* size, so we add explicit space for it here.
*/
outSize++;
buf = malloc(outSize);
buf = (char*)malloc(outSize);
if (buf == NULL) {
return NULL;
}
......@@ -1647,7 +1649,7 @@ bail:
*/
void dumpRegisterMaps(DexFile* pDexFile)
{
const u1* pClassPool = pDexFile->pRegisterMapPool;
const u1* pClassPool = (const u1*)pDexFile->pRegisterMapPool;
const u4* classOffsets;
const u1* ptr;
u4 numClasses;
......@@ -1781,15 +1783,16 @@ int process(const char* fileName)
if (gOptions.verbose)
printf("Processing '%s'...\n", fileName);
if (dexOpenAndMap(fileName, gOptions.tempFileName, &map, false) != 0)
goto bail;
if (dexOpenAndMap(fileName, gOptions.tempFileName, &map, false) != 0) {
return result;
}
mapped = true;
int flags = kDexParseVerifyChecksum;
if (gOptions.ignoreBadChecksum)
flags |= kDexParseContinueOnError;
pDexFile = dexFileParse(map.addr, map.length, flags);
pDexFile = dexFileParse((u1*)map.addr, map.length, flags);
if (pDexFile == NULL) {
fprintf(stderr, "ERROR: DEX parse failed\n");
goto bail;
......
......@@ -18,7 +18,7 @@
LOCAL_PATH:= $(call my-dir)
dexdump_src_files := \
DexList.c
DexList.cpp
dexdump_c_includes := \
dalvik \
......
......@@ -63,7 +63,7 @@ static char* descriptorToDot(const char* str)
str++; /* Skip the 'L'. */
}
newStr = malloc(at + 1); /* Add one for the '\0'. */
newStr = (char*)malloc(at + 1); /* Add one for the '\0'. */
newStr[at] = '\0';
while (at > 0) {
......@@ -217,7 +217,7 @@ int process(const char* fileName)
}
mapped = true;
pDexFile = dexFileParse(map.addr, map.length, kDexParseDefault);
pDexFile = dexFileParse((u1*)map.addr, map.length, kDexParseDefault);
if (pDexFile == NULL) {
fprintf(stderr, "Warning: DEX parse failed for '%s'\n", fileName);
goto bail;
......
......@@ -19,7 +19,7 @@
LOCAL_PATH:= $(call my-dir)
local_src_files := \
OptMain.c
OptMain.cpp
local_c_includes := \
dalvik \
......
......@@ -65,6 +65,9 @@ static int extractAndProcessZip(int zipFd, int cacheFd,
off_t dexOffset;
int err;
int result = -1;
int dexoptFlags = 0; /* bit flags, from enum DexoptFlags */
DexClassVerifyMode verifyMode = VERIFY_MODE_ALL;
DexOptimizerMode dexOptMode = OPTIMIZE_MODE_VERIFIED;
memset(&zippy, 0, sizeof(zippy));
......@@ -126,11 +129,6 @@ static int extractAndProcessZip(int zipFd, int cacheFd,
}
/* Parse the options. */
DexClassVerifyMode verifyMode = VERIFY_MODE_ALL;
DexOptimizerMode dexOptMode = OPTIMIZE_MODE_VERIFIED;
int dexoptFlags = 0; /* bit flags, from enum DexoptFlags */
if (dexoptFlagStr[0] != '\0') {
const char* opc;
const char* val;
......@@ -208,7 +206,6 @@ bail:
static int processZipFile(int zipFd, int cacheFd, const char* zipName,
const char *dexoptFlags)
{
int result = -1;
char* bcpCopy = NULL;
/*
......@@ -218,7 +215,7 @@ static int processZipFile(int zipFd, int cacheFd, const char* zipName,
const char* bcp = getenv("BOOTCLASSPATH");
if (bcp == NULL) {
LOGE("DexOptZ: BOOTCLASSPATH not set\n");
goto bail;
return -1;
}
bool isBootstrap = false;
......@@ -248,10 +245,9 @@ static int processZipFile(int zipFd, int cacheFd, const char* zipName,
isBootstrap = true;
}
result = extractAndProcessZip(zipFd, cacheFd, zipName, isBootstrap,
int result = extractAndProcessZip(zipFd, cacheFd, zipName, isBootstrap,
bcp, dexoptFlags);
bail:
free(bcpCopy);
return result;
}
......@@ -348,7 +344,7 @@ static int preopt(int argc, char* const argv[])
*/
fprintf(stderr, "Wrong number of args for --preopt (found %d)\n",
argc);
goto bail;
return -1;
}
const char* zipName = argv[2];
......@@ -359,13 +355,13 @@ static int preopt(int argc, char* const argv[])
strstr(dexoptFlags, "u=n") == NULL)
{
fprintf(stderr, "Either 'u=y' or 'u=n' must be specified\n");
goto bail;
return -1;
}
zipFd = open(zipName, O_RDONLY);
if (zipFd < 0) {
perror(argv[0]);
goto bail;
return -1;
}
outFd = open(outName, O_RDWR | O_EXCL | O_CREAT, 0666);
......@@ -427,6 +423,9 @@ static int fromDex(int argc, char* const argv[])
const char* debugFileName;
u4 crc, modWhen;
char* endp;
bool onlyOptVerifiedDex = false;
DexClassVerifyMode verifyMode;
DexOptimizerMode dexOptMode;
if (argc < 10) {
/* don't have all mandatory args */
......@@ -492,9 +491,6 @@ static int fromDex(int argc, char* const argv[])
LOGV(" bootclasspath is '%s'\n", bootClassPath);
/* start the VM partway */
bool onlyOptVerifiedDex = false;
DexClassVerifyMode verifyMode;
DexOptimizerMode dexOptMode;
/* ugh -- upgrade these to a bit field if they get any more complex */
if ((flags & DEXOPT_VERIFY_ENABLED) != 0) {
......
......@@ -4,7 +4,7 @@ LOCAL_PATH := $(my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
dvz.c
dvz.cpp
LOCAL_SHARED_LIBRARIES := \
libcutils
......
File moved
......@@ -31,12 +31,8 @@
#ifndef _LIBDEX_CMDUTILS
#define _LIBDEX_CMDUTILS
#ifdef __cplusplus
extern "C" {
#endif
/* encode the result of unzipping to a file */
typedef enum UnzipToFileResult {
enum UnzipToFileResult {
kUTFRSuccess = 0,
kUTFRGenericFailure,
kUTFRBadArgs,
......@@ -44,7 +40,7 @@ typedef enum UnzipToFileResult {
kUTFRNoClassesDex,
kUTFROutputFileProblem,
kUTFRBadZip,
} UnzipToFileResult;
};
/*
* Map the specified DEX file read-only (possibly after expanding it into a
......@@ -74,8 +70,4 @@ UnzipToFileResult dexOpenAndMap(const char* fileName, const char* tempFileName,
UnzipToFileResult dexUnzipToFile(const char* zipFileName,
const char* outFileName, bool quiet);
#ifdef __cplusplus
}
#endif
#endif /*_LIBDEX_CMDUTILS*/
......@@ -24,17 +24,13 @@
#include "DexFile.h"
#include "Leb128.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Catch handler entry, used while iterating over catch_handler_items.
*/
typedef struct DexCatchHandler {
struct DexCatchHandler {
u4 typeIdx; /* type index of the caught exception type */
u4 address; /* handler address */
} DexCatchHandler;
};
/* Get the first handler offset for the given DexCode.
* It's not 0 because the handlers list is prefixed with its size
......@@ -48,12 +44,12 @@ u4 dexGetHandlersSize(const DexCode* pCode);
* Iterator over catch handler data. This structure should be treated as
* opaque.
*/
typedef struct DexCatchIterator {
struct DexCatchIterator {
const u1* pEncodedData;
bool catchesAll;
u4 countRemaining;
DexCatchHandler handler;
} DexCatchIterator;
};
/* Initialize a DexCatchIterator to emptiness. This mostly exists to
* squelch innocuous warnings. */
......@@ -163,8 +159,4 @@ DEX_INLINE bool dexFindCatchHandler(DexCatchIterator *pIterator,
}
}
#ifdef __cplusplus
}
#endif
#endif
......@@ -24,41 +24,37 @@
#include "DexFile.h"
#include "Leb128.h"
#ifdef __cplusplus
extern "C" {
#endif
/* expanded form of a class_data_item header */
typedef struct DexClassDataHeader {
struct DexClassDataHeader {
u4 staticFieldsSize;
u4 instanceFieldsSize;
u4 directMethodsSize;
u4 virtualMethodsSize;
} DexClassDataHeader;
};
/* expanded form of encoded_field */
typedef struct DexField {
struct DexField {
u4 fieldIdx; /* index to a field_id_item */
u4 accessFlags;
} DexField;
};
/* expanded form of encoded_method */
typedef struct DexMethod {
struct DexMethod {
u4 methodIdx; /* index to a method_id_item */
u4 accessFlags;
u4 codeOff; /* file offset to a code_item */
} DexMethod;
};
/* expanded form of class_data_item. Note: If a particular item is
* absent (e.g., no static fields), then the corresponding pointer
* is set to NULL. */
typedef struct DexClassData {
struct DexClassData {
DexClassDataHeader header;
DexField* staticFields;
DexField* instanceFields;
DexMethod* directMethods;
DexMethod* virtualMethods;
} DexClassData;
};
/* Read and verify the header of a class_data_item. This updates the
* given data pointer to point past the end of the read data and
......@@ -163,8 +159,4 @@ DEX_INLINE void dexReadClassDataMethod(const u1** pData, DexMethod* pMethod,
*lastIndex = index;
}
#ifdef __cplusplus
}
#endif
#endif
......@@ -23,16 +23,12 @@
#include "DexFile.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DexDataMap {
struct DexDataMap {
u4 count; /* number of items currently in the map */
u4 max; /* maximum number of items that may be held */
u4* offsets; /* array of item offsets */
u2* types; /* corresponding array of item types */
} DexDataMap;
};
/*
* Allocate and initialize a DexDataMap. Returns NULL on failure.
......@@ -74,8 +70,4 @@ DEX_INLINE bool dexDataMapVerify0Ok(DexDataMap* map, u4 offset, u2 type) {
return dexDataMapVerify(map, offset, type);
}
#ifdef __cplusplus
}
#endif
#endif /*_LIBDEX_DEXDATAMAP*/
......@@ -109,13 +109,13 @@ static const char* readTypeIdx(const DexFile* pDexFile,
}
}
typedef struct LocalInfo {
struct LocalInfo {
const char *name;
const char *descriptor;
const char *signature;
u2 startAddress;
bool live;
} LocalInfo;
};
static void emitLocalCbIfLive(void *cnxt, int reg, u4 endAddress,
LocalInfo *localInReg, DexDebugNewLocalCb localCb)
......
......@@ -23,10 +23,6 @@
#include "DexFile.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Callback for "new position table entry".
* Returning non-0 causes the decoder to stop early.
......@@ -56,8 +52,4 @@ void dexDecodeDebugInfo(
DexDebugNewPositionCb posCb, DexDebugNewLocalCb localCb,
void* cnxt);
#ifdef __cplusplus
}
#endif
#endif /* def _LIBDEX_DEXDEBUGINFO */
......@@ -36,10 +36,6 @@
#include "vm/Common.h" // basic type defs, e.g. u1/u2/u4/u8, and LOG
#include "libdex/SysUtil.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* gcc-style inline management -- ensures we have a copy of all functions
* in the library, so code that links against us will work whether or not
......@@ -77,7 +73,7 @@ enum {
/*
* Enumeration of all the primitive types.
*/
typedef enum PrimitiveType {
enum PrimitiveType {
PRIM_NOT = 0, /* value is a reference type, not a primitive type */
PRIM_VOID = 1,
PRIM_BOOLEAN = 2,
......@@ -88,7 +84,7 @@ typedef enum PrimitiveType {
PRIM_LONG = 7,
PRIM_FLOAT = 8,
PRIM_DOUBLE = 9,
} PrimitiveType;
};
/*
* access flags and masks; the "standard" ones are all <= 0x4000
......@@ -210,7 +206,7 @@ enum {
/*
* Direct-mapped "header_item" struct.
*/
typedef struct DexHeader {
struct DexHeader {
u1 magic[8]; /* includes version number */
u4 checksum; /* adler32 checksum */
u1 signature[kSHA1DigestLen]; /* SHA-1 hash */
......@@ -234,71 +230,71 @@ typedef struct DexHeader {
u4 classDefsOff;
u4 dataSize;
u4 dataOff;
} DexHeader;
};
/*
* Direct-mapped "map_item".
*/
typedef struct DexMapItem {
u2 type; /* type code (see kDexType* above) */
u2 unused;
u4 size; /* count of items of the indicated type */
u4 offset; /* file offset to the start of data */
} DexMapItem;
struct DexMapItem {
u2 type; /* type code (see kDexType* above) */
u2 unused;
u4 size; /* count of items of the indicated type */
u4 offset; /* file offset to the start of data */
};
/*
* Direct-mapped "map_list".
*/
typedef struct DexMapList {
struct DexMapList {
u4 size; /* #of entries in list */
DexMapItem list[1]; /* entries */
} DexMapList;
};
/*
* Direct-mapped "string_id_item".
*/
typedef struct DexStringId {
u4 stringDataOff; /* file offset to string_data_item */
} DexStringId;
struct DexStringId {
u4 stringDataOff; /* file offset to string_data_item */
};
/*
* Direct-mapped "type_id_item".
*/
typedef struct DexTypeId {
struct DexTypeId {
u4 descriptorIdx; /* index into stringIds list for type descriptor */
} DexTypeId;
};
/*
* Direct-mapped "field_id_item".
*/
typedef struct DexFieldId {
struct DexFieldId {
u2 classIdx; /* index into typeIds list for defining class */
u2 typeIdx; /* index into typeIds for field type */
u4 nameIdx; /* index into stringIds for field name */
} DexFieldId;
};
/*
* Direct-mapped "method_id_item".
*/
typedef struct DexMethodId {
struct DexMethodId {
u2 classIdx; /* index into typeIds list for defining class */
u2 protoIdx; /* index into protoIds for method prototype */
u4 nameIdx; /* index into stringIds for method name */
} DexMethodId;
};
/*
* Direct-mapped "proto_id_item".
*/
typedef struct DexProtoId {
struct DexProtoId {
u4 shortyIdx; /* index into stringIds for shorty descriptor */
u4 returnTypeIdx; /* index into typeIds list for return type */
u4 parametersOff; /* file offset to type_list for parameter types */
} DexProtoId;
};
/*
* Direct-mapped "class_def_item".
*/
typedef struct DexClassDef {
struct DexClassDef {
u4 classIdx; /* index into typeIds for this class */
u4 accessFlags;
u4 superclassIdx; /* index into typeIds for superclass */
......@@ -307,22 +303,22 @@ typedef struct DexClassDef {
u4 annotationsOff; /* file offset to annotations_directory_item */
u4 classDataOff; /* file offset to class_data_item */
u4 staticValuesOff; /* file offset to DexEncodedArray */
} DexClassDef;
};
/*
* Direct-mapped "type_item".
*/
typedef struct DexTypeItem {
struct DexTypeItem {
u2 typeIdx; /* index into typeIds */
} DexTypeItem;
};
/*
* Direct-mapped "type_list".
*/
typedef struct DexTypeList {
struct DexTypeList {
u4 size; /* #of entries in list */
DexTypeItem list[1]; /* entries */
} DexTypeList;
};
/*
* Direct-mapped "code_item".
......@@ -331,7 +327,7 @@ typedef struct DexTypeList {
* "debugInfo" is used when displaying an exception stack trace or
* debugging. An offset of zero indicates that there are no entries.
*/
typedef struct DexCode {
struct DexCode {
u2 registersSize;
u2 insSize;
u2 outsSize;
......@@ -343,29 +339,29 @@ typedef struct DexCode {
/* followed by try_item[triesSize] */
/* followed by uleb128 handlersSize */
/* followed by catch_handler_item[handlersSize] */
} DexCode;
};
/*
* Direct-mapped "try_item".
*/
typedef struct DexTry {
struct DexTry {
u4 startAddr; /* start address, in 16-bit code units */
u2 insnCount; /* instruction count, in 16-bit code units */
u2 handlerOff; /* offset in encoded handler data to handlers */
} DexTry;
};
/*
* Link table. Currently undefined.
*/
typedef struct DexLink {
struct DexLink {
u1 bleargh;
} DexLink;
};
/*
* Direct-mapped "annotations_directory_item".
*/
typedef struct DexAnnotationsDirectoryItem {
struct DexAnnotationsDirectoryItem {
u4 classAnnotationsOff; /* offset to DexAnnotationSetItem */
u4 fieldsSize; /* count of DexFieldAnnotationsItem */
u4 methodsSize; /* count of DexMethodAnnotationsItem */
......@@ -373,73 +369,73 @@ typedef struct DexAnnotationsDirectoryItem {
/* followed by DexFieldAnnotationsItem[fieldsSize] */
/* followed by DexMethodAnnotationsItem[methodsSize] */
/* followed by DexParameterAnnotationsItem[parametersSize] */
} DexAnnotationsDirectoryItem;
};
/*
* Direct-mapped "field_annotations_item".
*/
typedef struct DexFieldAnnotationsItem {
struct DexFieldAnnotationsItem {
u4 fieldIdx;
u4 annotationsOff; /* offset to DexAnnotationSetItem */
} DexFieldAnnotationsItem;
};
/*
* Direct-mapped "method_annotations_item".
*/
typedef struct DexMethodAnnotationsItem {
struct DexMethodAnnotationsItem {
u4 methodIdx;
u4 annotationsOff; /* offset to DexAnnotationSetItem */
} DexMethodAnnotationsItem;
};
/*
* Direct-mapped "parameter_annotations_item".
*/
typedef struct DexParameterAnnotationsItem {
struct DexParameterAnnotationsItem {
u4 methodIdx;
u4 annotationsOff; /* offset to DexAnotationSetRefList */
} DexParameterAnnotationsItem;
};
/*
* Direct-mapped "annotation_set_ref_item".
*/
typedef struct DexAnnotationSetRefItem {
struct DexAnnotationSetRefItem {
u4 annotationsOff; /* offset to DexAnnotationSetItem */
} DexAnnotationSetRefItem;
};
/*
* Direct-mapped "annotation_set_ref_list".
*/
typedef struct DexAnnotationSetRefList {
struct DexAnnotationSetRefList {
u4 size;
DexAnnotationSetRefItem list[1];
} DexAnnotationSetRefList;
};
/*
* Direct-mapped "annotation_set_item".
*/
typedef struct DexAnnotationSetItem {
struct DexAnnotationSetItem {
u4 size;
u4 entries[1]; /* offset to DexAnnotationItem */
} DexAnnotationSetItem;
};
/*
* Direct-mapped "annotation_item".
*
* NOTE: this structure is byte-aligned.
*/
typedef struct DexAnnotationItem {
struct DexAnnotationItem {
u1 visibility;
u1 annotation[1]; /* data in encoded_annotation format */
} DexAnnotationItem;
};
/*
* Direct-mapped "encoded_array".
*
* NOTE: this structure is byte-aligned.
*/
typedef struct DexEncodedArray {
struct DexEncodedArray {
u1 array[1]; /* data in encoded_array format */
} DexEncodedArray;
};
/*
* Lookup table for classes. It provides a mapping from class name to
......@@ -450,7 +446,7 @@ typedef struct DexEncodedArray {
* a hash table with direct pointers to the items, but because it's shared
* there's less of a penalty for using a fairly sparse table.
*/
typedef struct DexClassLookup {
struct DexClassLookup {
int size; // total size, including "size"
int numEntries; // size of table[]; always power of 2
struct {
......@@ -458,7 +454,7 @@ typedef struct DexClassLookup {
int classDescriptorOffset; // in bytes, from start of DEX
int classDefOffset; // in bytes, from start of DEX
} table[1];
} DexClassLookup;
};
/*
* Header added by DEX optimization pass. Values are always written in
......@@ -468,7 +464,7 @@ typedef struct DexClassLookup {
*
* Try to keep this simple and fixed-size.
*/
typedef struct DexOptHeader {
struct DexOptHeader {
u1 magic[8]; /* includes version number */
u4 dexOffset; /* file offset of DEX header */
......@@ -482,7 +478,7 @@ typedef struct DexOptHeader {
u4 checksum; /* adler32 checksum covering deps/opt */
/* pad for 64-bit alignment if necessary */
} DexOptHeader;
};
#define DEX_OPT_FLAG_BIG (1<<1) /* swapped to big-endian */
......@@ -494,7 +490,7 @@ typedef struct DexOptHeader {
* Code should regard DexFile as opaque, using the API calls provided here
* to access specific structures.
*/
typedef struct DexFile {
struct DexFile {
/* directly-mapped "opt" header */
const DexOptHeader* pOptHeader;
......@@ -523,7 +519,7 @@ typedef struct DexFile {
/* additional app-specific data structures associated with the DEX */
//void* auxData;
} DexFile;
};
/*
* Utility function -- rounds up to the nearest power of 2.
......@@ -964,8 +960,4 @@ const char* dexGetBoxedTypeDescriptor(PrimitiveType type);
*/
PrimitiveType dexGetPrimitiveTypeFromDescriptorChar(char descriptorChar);
#ifdef __cplusplus
}
#endif
#endif /*_LIBDEX_DEXFILE*/
......@@ -30,10 +30,6 @@
#include "DexFile.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* kMaxOpcodeValue: the highest possible raw (unpacked) opcode value
*
......@@ -70,7 +66,7 @@ extern "C" {
* can find the next instruction" aren't possible. (This is
* correctable, but probably not useful.)
*/
typedef enum Opcode {
enum Opcode {
// BEGIN(libdex-opcode-enum); GENERATED AUTOMATICALLY BY opcode-gen
OP_NOP = 0x00,
OP_MOVE = 0x01,
......@@ -585,7 +581,7 @@ typedef enum Opcode {
OP_SPUT_OBJECT_VOLATILE_JUMBO = 0x1fe,
OP_THROW_VERIFICATION_ERROR_JUMBO = 0x1ff,
// END(libdex-opcode-enum)
} Opcode;
};
/*
* Macro used to generate a computed goto table for use in implementing
......@@ -1137,8 +1133,4 @@ DEX_INLINE Opcode dexOpcodeFromCodeUnit(u2 codeUnit) {
*/
const char* dexGetOpcodeName(Opcode op);
#ifdef __cplusplus
}
#endif
#endif /*_LIBDEX_DEXOPCODES*/
......@@ -24,10 +24,6 @@
#include "libdex/DexFile.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Parse the optimized data tables in the given dex file.
*
......@@ -43,8 +39,4 @@ bool dexParseOptData(const u1* data, size_t length, DexFile* pDexFile);
*/
u4 dexComputeOptChecksum(const DexOptHeader* pOptHeader);
#ifdef __cplusplus
}
#endif
#endif /* def _LIBDEX_DEXOPTDATA */
......@@ -23,10 +23,6 @@
#include "DexFile.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Single-thread single-string cache. This structure holds a pointer to
* a string which is semi-automatically manipulated by some of the
......@@ -34,11 +30,11 @@ extern "C" {
* generally return a string that is valid until the next
* time the same DexStringCache is used.
*/
typedef struct DexStringCache {
struct DexStringCache {
char* value; /* the latest value */
size_t allocatedSize; /* size of the allocated buffer, if allocated */
char buffer[120]; /* buffer used to hold small-enough results */
} DexStringCache;
};
/*
* Make sure that the given cache can hold a string of the given length,
......@@ -80,10 +76,10 @@ char* dexStringCacheAbandon(DexStringCache* pCache, const char* value);
* Method prototype structure, which refers to a protoIdx in a
* particular DexFile.
*/
typedef struct DexProto {
struct DexProto {
const DexFile* dexFile; /* file the idx refers to */
u4 protoIdx; /* index into proto_ids table of dexFile */
} DexProto;
};
/*
* Set the given DexProto to refer to the prototype of the given MethodId.
......@@ -203,12 +199,12 @@ int dexProtoCompareToParameterDescriptors(const DexProto* proto,
* Single-thread prototype parameter iterator. This structure holds a
* pointer to a prototype and its parts, along with a cursor.
*/
typedef struct DexParameterIterator {
struct DexParameterIterator {
const DexProto* proto;
const DexTypeList* parameters;
int parameterCount;
int cursor;
} DexParameterIterator;
};
/*
* Initialize the given DexParameterIterator to be at the start of the
......@@ -230,8 +226,4 @@ u4 dexParameterIteratorNextIndex(DexParameterIterator* pIterator);
const char* dexParameterIteratorNextDescriptor(
DexParameterIterator* pIterator);
#ifdef __cplusplus
}
#endif
#endif /*_LIBDEX_DEXPROTO*/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment