llvm.org GIT mirror llvm / acd9619
Removing the silly CHelpers header by rolling wrap and unwrap into the C bindings headers themselves, hidden behind #ifdef __cplusplus. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42666 91177308-0d34-0410-b5e6-96231b3b80d8 Gordon Henriksen 11 years ago
5 changed file(s) with 102 addition(s) and 126 deletion(s). Raw diff Collapse all Expand all
169169 9FE25D940CAB16FB005383FC /* RegisterCoalescer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterCoalescer.cpp; sourceTree = ""; };
170170 9FE25D950CAB1724005383FC /* APFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APFloat.cpp; sourceTree = ""; };
171171 9FE25D960CAB1759005383FC /* TargetCallingConv.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TargetCallingConv.td; sourceTree = ""; };
172 9FE25D970CAB17F9005383FC /* DominatorCalculation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DominatorCalculation.h; path = ../lib/VMCore/DominatorCalculation.h; sourceTree = SOURCE_ROOT; };
173 9FE25D980CAB17F9005383FC /* DominatorInternals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DominatorInternals.cpp; path = ../lib/VMCore/DominatorInternals.cpp; sourceTree = SOURCE_ROOT; };
174172 9FE4508B0C77A77000C4FEA4 /* ARMCodeEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ARMCodeEmitter.cpp; sourceTree = ""; };
175173 9FE4508C0C77A77000C4FEA4 /* ARMGenAsmWriter.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenAsmWriter.inc; sourceTree = ""; };
176174 9FE4508D0C77A77000C4FEA4 /* ARMGenDAGISel.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenDAGISel.inc; sourceTree = ""; };
13441342 9F77937D0C73C4F400551F9C /* ConstantFold.h */,
13451343 DE66EC6008ABE86A00323D32 /* Constants.cpp */,
13461344 9FD3E5900CA0129D00E54D15 /* Core.cpp */,
1347 9FE25D970CAB17F9005383FC /* DominatorCalculation.h */,
1348 9FE25D980CAB17F9005383FC /* DominatorInternals.cpp */,
13491345 DE66EC6108ABE86A00323D32 /* Dominators.cpp */,
13501346 DE66EC6208ABE86A00323D32 /* Function.cpp */,
13511347 DE66EC6308ABE86A00323D32 /* Globals.cpp */,
+0
-104
include/llvm/Support/CHelpers.h less more
None //===-- Support/CHelpers.h - Utilities for writing C bindings -------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by the LLVM research group and is distributed under
5 // the University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // These opaque reference<-->pointer conversions are shorter and more tightly
10 // typed than writing the casts by hand in C bindings. In assert builds, they
11 // will do type checking.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_SUPPORT_CHELPERS_H
16 #define LLVM_SUPPORT_CHELPERS_H
17
18 #include "llvm/Module.h"
19 #include "llvm/Type.h"
20 #include "llvm/Value.h"
21
22 typedef struct LLVMOpaqueModule *LLVMModuleRef;
23 typedef struct LLVMOpaqueType *LLVMTypeRef;
24 typedef struct LLVMOpaqueValue *LLVMValueRef;
25
26 namespace llvm {
27 /// Opaque module conversions
28 ///
29 inline Module *unwrap(LLVMModuleRef M) {
30 return reinterpret_cast(M);
31 }
32
33 inline LLVMModuleRef wrap(Module *M) {
34 return reinterpret_cast(M);
35 }
36
37 /// Opaque type conversions
38 ///
39 inline Type *unwrap(LLVMTypeRef Ty) {
40 return reinterpret_cast(Ty);
41 }
42
43 template
44 inline T *unwrap(LLVMTypeRef Ty) {
45 return cast(unwrap(Ty));
46 }
47
48 inline Type **unwrap(LLVMTypeRef* Tys) {
49 return reinterpret_cast(Tys);
50 }
51
52 inline LLVMTypeRef wrap(const Type *Ty) {
53 return reinterpret_cast(const_cast(Ty));
54 }
55
56 inline LLVMTypeRef *wrap(const Type **Tys) {
57 return reinterpret_cast(const_cast(Tys));
58 }
59
60 /// Opaque value conversions
61 ///
62 inline Value *unwrap(LLVMValueRef Val) {
63 return reinterpret_cast(Val);
64 }
65
66 template
67 inline T *unwrap(LLVMValueRef Val) {
68 return cast(unwrap(Val));
69 }
70
71 inline Value **unwrap(LLVMValueRef *Vals) {
72 return reinterpret_cast(Vals);
73 }
74
75 template
76 inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
77 #if DEBUG
78 for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I)
79 cast(*I);
80 #endif
81 return reinterpret_cast(Vals);
82 }
83
84 inline LLVMValueRef wrap(const Value *Val) {
85 return reinterpret_cast(const_cast(Val));
86 }
87
88 inline LLVMValueRef *wrap(const Value **Vals) {
89 return reinterpret_cast(const_cast(Vals));
90 }
91
92 /// Basic block conversions
93 ///
94 inline BasicBlock *unwrap(LLVMBasicBlockRef BBRef) {
95 return reinterpret_cast(BBRef);
96 }
97
98 inline LLVMBasicBlockRef wrap(const BasicBlock *BB) {
99 return reinterpret_cast(const_cast(BB));
100 }
101 }
102
103 #endif
2222 |* with C++ due to name mangling. So in addition to C, this interface enables *|
2323 |* tools written in such languages. *|
2424 |* *|
25 |* When included into a C++ source file, also declares 'wrap' and 'unwrap' *|
26 |* helpers to perform opaque reference<-->pointer conversions. These helpers *|
27 |* are shorter and more tightly typed than writing the casts by hand when *|
28 |* authoring bindings. In assert builds, they will do runtime type checking. *|
29 |* *|
2530 \*===----------------------------------------------------------------------===*/
2631
2732 #ifndef LLVM_C_CORE_H
2833 #define LLVM_C_CORE_H
2934
3035 #ifdef __cplusplus
36
37 /* Need these includes to support the LLVM 'cast' template for the C++ 'wrap'
38 and 'unwrap' conversion functions. */
39 #include "llvm/Module.h"
40 #include "llvm/Support/LLVMBuilder.h"
41
3142 extern "C" {
3243 #endif
3344
411422
412423 #ifdef __cplusplus
413424 }
414 #endif
415
416 #endif
425
426 namespace llvm {
427 /* Opaque module conversions
428 */
429 inline Module *unwrap(LLVMModuleRef M) {
430 return reinterpret_cast(M);
431 }
432
433 inline LLVMModuleRef wrap(Module *M) {
434 return reinterpret_cast(M);
435 }
436
437 /* Opaque type conversions
438 */
439 inline Type *unwrap(LLVMTypeRef Ty) {
440 return reinterpret_cast(Ty);
441 }
442
443 template
444 inline T *unwrap(LLVMTypeRef Ty) {
445 return cast(unwrap(Ty));
446 }
447
448 inline Type **unwrap(LLVMTypeRef* Tys) {
449 return reinterpret_cast(Tys);
450 }
451
452 inline LLVMTypeRef wrap(const Type *Ty) {
453 return reinterpret_cast(const_cast(Ty));
454 }
455
456 inline LLVMTypeRef *wrap(const Type **Tys) {
457 return reinterpret_cast(const_cast(Tys));
458 }
459
460 /* Opaque value conversions
461 */
462 inline Value *unwrap(LLVMValueRef Val) {
463 return reinterpret_cast(Val);
464 }
465
466 template
467 inline T *unwrap(LLVMValueRef Val) {
468 return cast(unwrap(Val));
469 }
470
471 inline Value **unwrap(LLVMValueRef *Vals) {
472 return reinterpret_cast(Vals);
473 }
474
475 template
476 inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
477 #if DEBUG
478 for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I)
479 cast(*I);
480 #endif
481 return reinterpret_cast(Vals);
482 }
483
484 inline LLVMValueRef wrap(const Value *Val) {
485 return reinterpret_cast(const_cast(Val));
486 }
487
488 inline LLVMValueRef *wrap(const Value **Vals) {
489 return reinterpret_cast(const_cast(Vals));
490 }
491
492 /* Basic block conversions
493 */
494 inline BasicBlock *unwrap(LLVMBasicBlockRef BBRef) {
495 return reinterpret_cast(BBRef);
496 }
497
498 inline LLVMBasicBlockRef wrap(const BasicBlock *BB) {
499 return reinterpret_cast(const_cast(BB));
500 }
501
502 /* Opaque builder conversions.
503 */
504 inline LLVMBuilder *unwrap(LLVMBuilderRef B) {
505 return reinterpret_cast(B);
506 }
507
508 inline LLVMBuilderRef wrap(LLVMBuilder *B) {
509 return reinterpret_cast(B);
510 }
511 }
512
513 #endif /* !defined(__cplusplus) */
514
515 #endif /* !defined(LLVM_C_CORE_H) */
88
99 #include "llvm-c/BitWriter.h"
1010 #include "llvm/Bitcode/ReaderWriter.h"
11 #include "llvm/Support/CHelpers.h"
1211 #include
1312
1413 using namespace llvm;
1616 #include "llvm/Constants.h"
1717 #include "llvm/DerivedTypes.h"
1818 #include "llvm/GlobalVariable.h"
19 #include "llvm/Support/CHelpers.h"
20 #include "llvm/Support/LLVMBuilder.h"
2119 #include "llvm/TypeSymbolTable.h"
2220 #include
2321
2422 using namespace llvm;
25
26 namespace {
27 /// Opaque builder conversions.
28 ///
29 inline LLVMBuilder *unwrap(LLVMBuilderRef B) {
30 return reinterpret_cast(B);
31 }
32
33 inline LLVMBuilderRef wrap(LLVMBuilder *B) {
34 return reinterpret_cast(B);
35 }
36 }
3723
3824
3925 /*===-- Operations on modules ---------------------------------------------===*/