15 #ifndef MLIR_CAPI_WRAP_H 16 #define MLIR_CAPI_WRAP_H 25 #define DEFINE_C_API_PTR_METHODS(name, cpptype) \ 26 static inline name wrap(cpptype *cpp) { return name{cpp}; } \ 27 static inline cpptype *unwrap(name c) { \ 28 return static_cast<cpptype *>(c.ptr); \ 31 #define DEFINE_C_API_METHODS(name, cpptype) \ 32 static inline name wrap(cpptype cpp) { \ 33 return name{cpp.getAsOpaquePointer()}; \ 35 static inline cpptype unwrap(name c) { \ 36 return cpptype::getFromOpaquePointer(c.ptr); \ 39 template <
typename CppTy,
typename CTy>
43 std::is_same<decltype(
unwrap(std::declval<CTy>())), CppTy>::
value,
44 "incompatible C and C++ types");
49 assert(storage.empty() &&
"expected to populate storage");
50 storage.reserve(size);
51 for (
size_t i = 0; i < size; ++i)
52 storage.push_back(
unwrap(*(first + i)));
56 #endif // MLIR_CAPI_WRAP_H
static constexpr const bool value
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)