From e2611cdea2e3fadbb0475e5692179c009312a57c Mon Sep 17 00:00:00 2001 From: Aniruddha Adak Date: Sat, 14 Mar 2026 00:46:24 +0530 Subject: [PATCH] fix: Move runtime codes to own separate header file (fixes #697) --- include/CppInterOp/CppInterOpRuntime.h | 22 ++++++++++++++++++++++ lib/CppInterOp/CppInterOp.cpp | 11 +---------- 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 include/CppInterOp/CppInterOpRuntime.h diff --git a/include/CppInterOp/CppInterOpRuntime.h b/include/CppInterOp/CppInterOpRuntime.h new file mode 100644 index 000000000..22358fe44 --- /dev/null +++ b/include/CppInterOp/CppInterOpRuntime.h @@ -0,0 +1,22 @@ +//===--- CppInterOpRuntime.h - Runtime codes for language interoperability ---*- C++ -*-===// +// +// Part of the compiler-research project, under the Apache License v2.0 with +// LLVM Exceptions. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef CPPINTEROP_CPPINTEROPRUNTIME_H +#define CPPINTEROP_CPPINTEROPRUNTIME_H + +namespace __internal_CppInterOp { +template +struct function; + +template +struct function { + using result_type = Res; +}; +} // namespace __internal_CppInterOp + +#endif // CPPINTEROP_CPPINTEROPRUNTIME_H \ No newline at end of file diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index dd76109df..22d4b188a 100644 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -3413,16 +3413,7 @@ TInterp_t CreateInterpreter(const std::vector& Args /*={}*/, if (GetLanguage(I) != InterpreterLanguage::C) { I->declare(R"( - namespace __internal_CppInterOp { - template - struct function; - template - struct function { - typedef Res result_type; - }; - } // namespace __internal_CppInterOp - )"); - } + #include sInterpreters->emplace_back(I, /*Owned=*/true);