Removing the silly CHelpers header by rolling wrap and unwrap into the C
authorGordon Henriksen <gordonhenriksen@mac.com>
Fri, 5 Oct 2007 23:59:36 +0000 (23:59 +0000)
committerGordon Henriksen <gordonhenriksen@mac.com>
Fri, 5 Oct 2007 23:59:36 +0000 (23:59 +0000)
bindings headers themselves, hidden behind #ifdef __cplusplus.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42666 91177308-0d34-0410-b5e6-96231b3b80d8

Xcode/LLVM.xcodeproj/project.pbxproj
include/llvm-c/Core.h
include/llvm/Support/CHelpers.h [deleted file]
lib/Bitcode/Writer/BitWriter.cpp
lib/VMCore/Core.cpp

index 600a9cc6550b80eb55f7b9d39671471f9b4cbec0..a195dbda59029bef3887276805ec2aba904fb4ce 100644 (file)
                9FE25D940CAB16FB005383FC /* RegisterCoalescer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterCoalescer.cpp; sourceTree = "<group>"; };
                9FE25D950CAB1724005383FC /* APFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APFloat.cpp; sourceTree = "<group>"; };
                9FE25D960CAB1759005383FC /* TargetCallingConv.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TargetCallingConv.td; sourceTree = "<group>"; };
-               9FE25D970CAB17F9005383FC /* DominatorCalculation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DominatorCalculation.h; path = ../lib/VMCore/DominatorCalculation.h; sourceTree = SOURCE_ROOT; };
-               9FE25D980CAB17F9005383FC /* DominatorInternals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DominatorInternals.cpp; path = ../lib/VMCore/DominatorInternals.cpp; sourceTree = SOURCE_ROOT; };
                9FE4508B0C77A77000C4FEA4 /* ARMCodeEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ARMCodeEmitter.cpp; sourceTree = "<group>"; };
                9FE4508C0C77A77000C4FEA4 /* ARMGenAsmWriter.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenAsmWriter.inc; sourceTree = "<group>"; };
                9FE4508D0C77A77000C4FEA4 /* ARMGenDAGISel.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenDAGISel.inc; sourceTree = "<group>"; };
                                9F77937D0C73C4F400551F9C /* ConstantFold.h */,
                                DE66EC6008ABE86A00323D32 /* Constants.cpp */,
                                9FD3E5900CA0129D00E54D15 /* Core.cpp */,
-                               9FE25D970CAB17F9005383FC /* DominatorCalculation.h */,
-                               9FE25D980CAB17F9005383FC /* DominatorInternals.cpp */,
                                DE66EC6108ABE86A00323D32 /* Dominators.cpp */,
                                DE66EC6208ABE86A00323D32 /* Function.cpp */,
                                DE66EC6308ABE86A00323D32 /* Globals.cpp */,
index 47b89aa513e7f8c3481faed9d712473970d732fa..fb01b8373520001891a9c064c75efce317c7457e 100644 (file)
 |* with C++ due to name mangling. So in addition to C, this interface enables *|
 |* tools written in such languages.                                           *|
 |*                                                                            *|
+|* When included into a C++ source file, also declares 'wrap' and 'unwrap'    *|
+|* helpers to perform opaque reference<-->pointer conversions. These helpers  *|
+|* are shorter and more tightly typed than writing the casts by hand when     *|
+|* authoring bindings. In assert builds, they will do runtime type checking.  *|
+|*                                                                            *|
 \*===----------------------------------------------------------------------===*/
 
 #ifndef LLVM_C_CORE_H
 #define LLVM_C_CORE_H
 
 #ifdef __cplusplus
+
+/* Need these includes to support the LLVM 'cast' template for the C++ 'wrap' 
+   and 'unwrap' conversion functions. */
+#include "llvm/Module.h"
+#include "llvm/Support/LLVMBuilder.h"
+
 extern "C" {
 #endif
 
@@ -412,6 +423,94 @@ LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
 
 #ifdef __cplusplus
 }
-#endif
 
-#endif
+namespace llvm {
+  /* Opaque module conversions
+   */ 
+  inline Module *unwrap(LLVMModuleRef M) {
+    return reinterpret_cast<Module*>(M);
+  }
+  
+  inline LLVMModuleRef wrap(Module *M) {
+    return reinterpret_cast<LLVMModuleRef>(M);
+  }
+  
+  /* Opaque type conversions
+   */ 
+  inline Type *unwrap(LLVMTypeRef Ty) {
+    return reinterpret_cast<Type*>(Ty);
+  }
+  
+  template<typename T>
+  inline T *unwrap(LLVMTypeRef Ty) {
+    return cast<T>(unwrap(Ty));
+  }
+  
+  inline Type **unwrap(LLVMTypeRef* Tys) {
+    return reinterpret_cast<Type**>(Tys);
+  }
+  
+  inline LLVMTypeRef wrap(const Type *Ty) {
+    return reinterpret_cast<LLVMTypeRef>(const_cast<Type*>(Ty));
+  }
+  
+  inline LLVMTypeRef *wrap(const Type **Tys) {
+    return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
+  }
+  
+  /* Opaque value conversions
+   */ 
+  inline Value *unwrap(LLVMValueRef Val) {
+    return reinterpret_cast<Value*>(Val);
+  }
+  
+  template<typename T>
+  inline T *unwrap(LLVMValueRef Val) {
+    return cast<T>(unwrap(Val));
+  }
+
+  inline Value **unwrap(LLVMValueRef *Vals) {
+    return reinterpret_cast<Value**>(Vals);
+  }
+  
+  template<typename T>
+  inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
+    #if DEBUG
+    for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I)
+      cast<T>(*I);
+    #endif
+    return reinterpret_cast<T**>(Vals);
+  }
+  
+  inline LLVMValueRef wrap(const Value *Val) {
+    return reinterpret_cast<LLVMValueRef>(const_cast<Value*>(Val));
+  }
+  
+  inline LLVMValueRef *wrap(const Value **Vals) {
+    return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
+  }
+  
+  /* Basic block conversions
+   */ 
+  inline BasicBlock *unwrap(LLVMBasicBlockRef BBRef) {
+    return reinterpret_cast<BasicBlock*>(BBRef);
+  }
+  
+  inline LLVMBasicBlockRef wrap(const BasicBlock *BB) {
+    return reinterpret_cast<LLVMBasicBlockRef>(const_cast<BasicBlock*>(BB));
+  }
+  
+  /* Opaque builder conversions.
+   */ 
+  inline LLVMBuilder *unwrap(LLVMBuilderRef B) {
+    return reinterpret_cast<LLVMBuilder*>(B);
+  }
+  
+  inline LLVMBuilderRef wrap(LLVMBuilder *B) {
+    return reinterpret_cast<LLVMBuilderRef>(B);
+  }
+}
+
+#endif /* !defined(__cplusplus) */
+
+#endif /* !defined(LLVM_C_CORE_H) */
diff --git a/include/llvm/Support/CHelpers.h b/include/llvm/Support/CHelpers.h
deleted file mode 100644 (file)
index 0ae7503..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-//===-- Support/CHelpers.h - Utilities for writing C bindings -------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-// 
-// These opaque reference<-->pointer conversions are shorter and more tightly
-// typed than writing the casts by hand in C bindings. In assert builds, they
-// will do type checking.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_CHELPERS_H
-#define LLVM_SUPPORT_CHELPERS_H
-
-#include "llvm/Module.h"
-#include "llvm/Type.h"
-#include "llvm/Value.h"
-
-typedef struct LLVMOpaqueModule *LLVMModuleRef;
-typedef struct LLVMOpaqueType *LLVMTypeRef;
-typedef struct LLVMOpaqueValue *LLVMValueRef;
-
-namespace llvm {
-  /// Opaque module conversions
-  /// 
-  inline Module *unwrap(LLVMModuleRef M) {
-    return reinterpret_cast<Module*>(M);
-  }
-  
-  inline LLVMModuleRef wrap(Module *M) {
-    return reinterpret_cast<LLVMModuleRef>(M);
-  }
-  
-  /// Opaque type conversions
-  /// 
-  inline Type *unwrap(LLVMTypeRef Ty) {
-    return reinterpret_cast<Type*>(Ty);
-  }
-  
-  template<typename T>
-  inline T *unwrap(LLVMTypeRef Ty) {
-    return cast<T>(unwrap(Ty));
-  }
-  
-  inline Type **unwrap(LLVMTypeRef* Tys) {
-    return reinterpret_cast<Type**>(Tys);
-  }
-  
-  inline LLVMTypeRef wrap(const Type *Ty) {
-    return reinterpret_cast<LLVMTypeRef>(const_cast<Type*>(Ty));
-  }
-  
-  inline LLVMTypeRef *wrap(const Type **Tys) {
-    return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
-  }
-  
-  /// Opaque value conversions
-  /// 
-  inline Value *unwrap(LLVMValueRef Val) {
-    return reinterpret_cast<Value*>(Val);
-  }
-  
-  template<typename T>
-  inline T *unwrap(LLVMValueRef Val) {
-    return cast<T>(unwrap(Val));
-  }
-
-  inline Value **unwrap(LLVMValueRef *Vals) {
-    return reinterpret_cast<Value**>(Vals);
-  }
-  
-  template<typename T>
-  inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
-    #if DEBUG
-    for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I)
-      cast<T>(*I);
-    #endif
-    return reinterpret_cast<T**>(Vals);
-  }
-  
-  inline LLVMValueRef wrap(const Value *Val) {
-    return reinterpret_cast<LLVMValueRef>(const_cast<Value*>(Val));
-  }
-  
-  inline LLVMValueRef *wrap(const Value **Vals) {
-    return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
-  }
-  
-  /// Basic block conversions
-  /// 
-  inline BasicBlock *unwrap(LLVMBasicBlockRef BBRef) {
-    return reinterpret_cast<BasicBlock*>(BBRef);
-  }
-  
-  inline LLVMBasicBlockRef wrap(const BasicBlock *BB) {
-    return reinterpret_cast<LLVMBasicBlockRef>(const_cast<BasicBlock*>(BB));
-  }
-}
-
-#endif
index b2e7ac2ec0f02fa91093ffc13681699e9b420528..8f562e98d9f1ea86b3407481ba589f12e905ce8c 100644 (file)
@@ -9,7 +9,6 @@
 
 #include "llvm-c/BitWriter.h"
 #include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Support/CHelpers.h"
 #include <fstream>
 
 using namespace llvm;
index f35951d45b0947943949d7eee9ceeda60690239e..b6a825462ae10361988c0046c90f40600703e50c 100644 (file)
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/GlobalVariable.h"
-#include "llvm/Support/CHelpers.h"
-#include "llvm/Support/LLVMBuilder.h"
 #include "llvm/TypeSymbolTable.h"
 #include <cassert>
 
 using namespace llvm;
 
-namespace {
-  /// Opaque builder conversions.
-  /// 
-  inline LLVMBuilder *unwrap(LLVMBuilderRef B) {
-    return reinterpret_cast<LLVMBuilder*>(B);
-  }
-  
-  inline LLVMBuilderRef wrap(LLVMBuilder *B) {
-    return reinterpret_cast<LLVMBuilderRef>(B);
-  }
-}
-
 
 /*===-- Operations on modules ---------------------------------------------===*/