Skip to content

Commit 799bc83

Browse files
committed
Move runtime template code to CPPInterOpRuntime.h
1 parent 63fe46d commit 799bc83

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

lib/CppInterOp/CppInterOp.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#include "CppInterOp/CppInterOp.h"
1111

12+
#include "CppInterOpRuntime.h"
13+
1214
#include "Compatibility.h"
1315

1416
#include "clang/AST/Attrs.inc"
@@ -3268,14 +3270,7 @@ TInterp_t CreateInterpreter(const std::vector<const char*>& Args /*={}*/,
32683270
}
32693271

32703272
I->declare(R"(
3271-
namespace __internal_CppInterOp {
3272-
template <typename Signature>
3273-
struct function;
3274-
template <typename Res, typename... ArgTypes>
3275-
struct function<Res(ArgTypes...)> {
3276-
typedef Res result_type;
3277-
};
3278-
} // namespace __internal_CppInterOp
3273+
#include "CppInterOpRuntime.h"
32793274
)");
32803275

32813276
sInterpreters->emplace_back(I, /*Owned=*/true);

lib/CppInterOp/CppInterOpRuntime.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef CPPINTEROP_RUNTIME_H
2+
#define CPPINTEROP_RUNTIME_H
3+
4+
// This header contains runtime utilities previously injected into the
5+
// interpreter using I->declare(). It is now provided as a real header so that
6+
// the interpreter can load it on startup.
7+
8+
namespace __internal_CppInterOp {
9+
10+
template <typename Signature>
11+
struct function;
12+
template <typename Res, typename... ArgTypes>
13+
struct function<Res(ArgTypes...)> {
14+
using result_type = Res;
15+
};
16+
17+
} // namespace __internal_CppInterOp
18+
19+
#endif // CPPINTEROP_RUNTIME_H

0 commit comments

Comments
 (0)