Skip to content

Commit

Permalink
Update function documentation and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronj0 committed Apr 12, 2024
1 parent 423b3e1 commit 22c1e0d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
7 changes: 5 additions & 2 deletions include/clang/Interpreter/CppInterOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,11 @@ namespace Cpp {
CPPINTEROP_API void GetClassMethods(TCppScope_t klass,
std::vector<TCppFunction_t>& methods);

///\returns Template function pointer list to add proxies for
/// un-instantiated/non-overloaded templated methods
/// Template function pointer list to add proxies for un-instantiated/
/// non-overloaded templated methods
///\param[in] klass - Pointer to the scope/class under which the methods have
/// to be retrieved
///\param[out] methods - Vector of methods in the class
CPPINTEROP_API void
GetFunctionTemplatedDecls(TCppScope_t klass,
std::vector<TCppFunction_t>& methods);
Expand Down
6 changes: 3 additions & 3 deletions lib/Interpreter/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,10 +993,10 @@ namespace Cpp {
if (func->getNumParams() != arg_types.size())
continue;

// TODO : first score based on the type similarity before forcing
// FIXME : first score based on the type similarity before forcing
// instantiation try instantiating
TCppFunction_t instantiated = InstantiateTemplate(
candidate, arg_types.data(), arg_types.size());
TCppFunction_t instantiated =
InstantiateTemplate(candidate, arg_types.data(), arg_types.size());
if (instantiated)
return instantiated;

Expand Down
16 changes: 8 additions & 8 deletions unittests/CppInterOp/FunctionReflectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,14 @@ TEST(FunctionReflectionTest, ExistsFunctionTemplate) {
EXPECT_FALSE(Cpp::ExistsFunctionTemplate("f", Decls[2]));
}

// TEST(ScopeReflectionTest, InstantiateTemplateFunctionFromString) {
// Cpp::CreateInterpreter();
// std::string code = R"(#include <memory>)";
// Interp->process(code);
// const char* str = "std::make_unique<int,int>";
// auto* Instance1 = (Decl*)Cpp::InstantiateTemplateFunctionFromString(str);
// EXPECT_TRUE(Instance1);
// }
TEST(FunctionReflectionTest, InstantiateTemplateFunctionFromString) {
Cpp::CreateInterpreter();
std::string code = R"(#include <memory>)";
Interp->process(code);
const char* str = "std::make_unique<int,int>";
auto* Instance1 = (Decl*)Cpp::InstantiateTemplateFunctionFromString(str);
EXPECT_TRUE(Instance1);
}

TEST(FunctionReflectionTest, InstantiateFunctionTemplate) {
std::vector<Decl*> Decls;
Expand Down

0 comments on commit 22c1e0d

Please sign in to comment.