blob: 7b1cf717f777a96941c372ceeeeb1465b0c97392 [file] [log] [blame]
Eric Christophere243fd92011-04-03 22:34:07 +00001/*===-- llvm-c/Object.h - Object Lib C Iface --------------------*- C++ -*-===*/
2/* */
3/* The LLVM Compiler Infrastructure */
4/* */
5/* This file is distributed under the University of Illinois Open Source */
6/* License. See LICENSE.TXT for details. */
7/* */
8/*===----------------------------------------------------------------------===*/
9/* */
10/* This header declares the C interface to libLLVMObject.a, which */
11/* implements object file reading and writing. */
12/* */
13/* Many exotic languages can interoperate with C code but have a harder time */
14/* with C++ due to name mangling. So in addition to C, this interface enables */
15/* tools written in such languages. */
16/* */
17/*===----------------------------------------------------------------------===*/
18
19#ifndef LLVM_C_OBJECT_H
20#define LLVM_C_OBJECT_H
21
22#include "llvm-c/Core.h"
23#include "llvm/Config/llvm-config.h"
24
25#ifdef __cplusplus
26#include "llvm/Object/ObjectFile.h"
27
28extern "C" {
29#endif
30
31
32typedef struct LLVMOpaqueObjectFile *LLVMObjectFileRef;
33
34typedef struct LLVMOpaqueSectionIterator *LLVMSectionIteratorRef;
35
36LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf);
37void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile);
38
39LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile);
40void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI);
41LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile,
42 LLVMSectionIteratorRef SI);
43void LLVMMoveToNextSection(LLVMSectionIteratorRef SI);
44const char *LLVMGetSectionName(LLVMSectionIteratorRef SI);
45uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI);
46const char *LLVMGetSectionContents(LLVMSectionIteratorRef SI);
47
48
49#ifdef __cplusplus
50}
51
52namespace llvm {
53 namespace object {
54 inline ObjectFile *unwrap(LLVMObjectFileRef OF) {
55 return reinterpret_cast<ObjectFile*>(OF);
56 }
57
58 inline LLVMObjectFileRef wrap(const ObjectFile *OF) {
59 return reinterpret_cast<LLVMObjectFileRef>(const_cast<ObjectFile*>(OF));
60 }
61
Michael J. Spencer4344b1e2011-10-07 19:25:32 +000062 inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
63 return reinterpret_cast<section_iterator*>(SI);
Eric Christophere243fd92011-04-03 22:34:07 +000064 }
65
66 inline LLVMSectionIteratorRef
Michael J. Spencer4344b1e2011-10-07 19:25:32 +000067 wrap(const section_iterator *SI) {
Eric Christophere243fd92011-04-03 22:34:07 +000068 return reinterpret_cast<LLVMSectionIteratorRef>
Michael J. Spencer4344b1e2011-10-07 19:25:32 +000069 (const_cast<section_iterator*>(SI));
Eric Christophere243fd92011-04-03 22:34:07 +000070 }
71 }
72}
73
74#endif /* defined(__cplusplus) */
75
76#endif
77