Skip to content

Commit 14875dd

Browse files
committed
Move to v0.6.1 by upgrading Parser and IR
1 parent e4ea167 commit 14875dd

File tree

10 files changed

+56
-19
lines changed

10 files changed

+56
-19
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15)
22

33
project(
44
Frontend.py
5-
VERSION 0.6.0
5+
VERSION 0.6.1
66
LANGUAGES CXX)
77

88
configure_file(docs/ReleaseNotes/version.in
@@ -37,7 +37,7 @@ include(FetchContent)
3737
FetchContent_Declare(
3838
IRSpecification
3939
GIT_REPOSITORY https://github.com/Tolc-Software/IntermediateRepresentation.git
40-
GIT_TAG v0.14.0)
40+
GIT_TAG v0.15.1)
4141

4242
FetchContent_MakeAvailable(IRSpecification)
4343

docs/ReleaseNotes/v0.6.1.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# News #
2+
3+
## Bindings ##
4+
5+
* Update to Parser v0.5.6 and IR v0.15.1

src/Pybind/Builders/classBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ buildClass(IR::Struct const& cppClass, Pybind::Proxy::TypeInfo& typeInfo) {
141141
pyClass.addMemberVariable(variable.m_name,
142142
variable.m_documentation,
143143
variable.m_type.m_isConst,
144-
variable.m_type.m_isStatic);
144+
variable.m_isStatic);
145145
}
146146

147147
// Add default constructor

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include_guard()
22

33
include(${modules}/GetParser.cmake)
4-
get_parser(VERSION v0.4.1)
4+
get_parser(VERSION v0.5.6)
55

66
# Set the include path for the system library in the variable
77
# We are using the standard library shipped

tests/Pybind/Builders/classBuilder.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TEST_CASE("Class with static member variables", "[classBuilder]") {
3636
IR::Type t;
3737
t.m_representation = var.type;
3838
t.m_isConst = var.isConst;
39-
t.m_isStatic = true;
39+
v.m_isStatic = true;
4040
v.m_type = t;
4141
s.m_public.m_memberVariables.push_back(v);
4242
}
@@ -163,7 +163,7 @@ TEST_CASE("Class with a constructor", "[classBuilder]") {
163163
f.m_name = s.m_name;
164164
f.m_representation = f.m_name;
165165
f.m_isStatic = false;
166-
IR::Variable v;
166+
IR::Argument v;
167167
v.m_name = 's';
168168
IR::Type t;
169169
t.m_representation = "const std::string&";
@@ -201,7 +201,7 @@ TEST_CASE("Class with functions", "[classBuilder]") {
201201
f.m_representation = f.m_name;
202202
f.m_isStatic = false;
203203

204-
IR::Variable v;
204+
IR::Argument v;
205205
v.m_name = "myVar";
206206

207207
IR::Type arg;
@@ -247,7 +247,7 @@ TEST_CASE("Class with member variables", "[classBuilder]") {
247247
IR::Type t;
248248
t.m_representation = var.type;
249249
t.m_isConst = var.isConst;
250-
t.m_isStatic = false;
250+
v.m_isStatic = false;
251251
v.m_type = t;
252252
s.m_public.m_memberVariables.push_back(v);
253253
}
@@ -282,7 +282,7 @@ TEST_CASE("Class with vector in constructor gives the correct include",
282282
IR::Type::Container c;
283283
c.m_container = IR::ContainerType::Vector;
284284
arg.m_type = c;
285-
constructor.m_arguments.push_back({"myVar", "", arg});
285+
constructor.m_arguments.push_back({"myVar", arg});
286286
s.m_public.m_functions.push_back(constructor);
287287

288288
Pybind::Proxy::TypeInfo typeInfo;
@@ -306,7 +306,7 @@ TEST_CASE("Class with vector in member function gives the correct include",
306306
IR::Type::Container c;
307307
c.m_container = IR::ContainerType::Vector;
308308
arg.m_type = c;
309-
constructor.m_arguments.push_back({"myVar", "", arg});
309+
constructor.m_arguments.push_back({"myVar", arg});
310310
s.m_public.m_functions.push_back(constructor);
311311

312312
Pybind::Proxy::TypeInfo typeInfo;

tests/Pybind/Builders/functionBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ TEST_CASE("function fails on unique_ptr argument", "[functionBuilder]") {
2323
IR::Type::Container c;
2424
c.m_container = IR::ContainerType::UniquePtr;
2525
t.m_type = c;
26-
IR::Variable v;
26+
IR::Argument v;
2727
v.m_type = t;
2828
v.m_name = "v";
2929
f.m_arguments.push_back(v);

tests/Pybind/Builders/moduleFileBuilder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ TEST_CASE(
1717
c.m_container = IR::ContainerType::Vector;
1818
returnType.m_type = c;
1919
returnType.m_isConst = false;
20-
returnType.m_isStatic = false;
2120
returnType.m_isReference = false;
2221
returnType.m_numPointers = 0;
2322
f.m_returnType = returnType;

tests/TestUtil/include/TestStage/stageFunctions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int runPythonUnittest(std::filesystem::path const& stage,
6666

6767
// Switch to stage
6868
std::filesystem::current_path(stage / "build");
69-
auto cmd = "python3 test_" + moduleName + ".py";
69+
auto cmd = "python test_" + moduleName + ".py";
7070
std::cout << cmd << '\n';
7171
auto errorCode = std::system(cmd.c_str());
7272

tests/TestUtil/include/TestUtil/parse.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
namespace TestUtil {
1111

1212
IR::Namespace parseString(std::string const& code) {
13-
auto ns = Parser::parseString(code, TestUtil::getParserConfig());
14-
REQUIRE(ns.has_value());
15-
return ns.has_value() ? ns.value() : IR::Namespace();
13+
auto parsed = Parser::parseString(code, TestUtil::getParserConfig());
14+
REQUIRE(parsed.has_value());
15+
return parsed.value();
1616
}
1717

1818
IR::Namespace parseFile(std::string const& filepath) {
19-
auto ns = Parser::parseFile(filepath, TestUtil::getParserConfig());
20-
REQUIRE(ns.has_value());
21-
return ns.has_value() ? ns.value() : IR::Namespace();
19+
auto parsed = Parser::parseFile(filepath, TestUtil::getParserConfig());
20+
REQUIRE(parsed.has_value());
21+
return parsed.value();
2222
}
2323
} // namespace TestUtil

tests/dependency.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "TestStage/paths.hpp"
2+
#include "TestUtil/pybindStage.hpp"
3+
#include <catch2/catch.hpp>
4+
#include <fmt/format.h>
5+
6+
TEST_CASE("You can refer to things as long as they are previously defined",
7+
"[dependency]") {
8+
std::string moduleName = "m";
9+
auto stage =
10+
TestUtil::PybindStage(TestStage::getRootStagePath(), moduleName);
11+
12+
auto cppCode = R"(
13+
namespace MyLib {
14+
struct Data { int i; };
15+
}
16+
17+
MyLib::Data complexFunction() {
18+
MyLib::Data d;
19+
d.i = 5;
20+
return d;
21+
}
22+
)";
23+
24+
auto pythonTestCode = fmt::format(R"(
25+
# Can call a function which depends on an inner object
26+
data = {moduleName}.complexFunction()
27+
self.assertEqual(data.i, 5)
28+
)",
29+
fmt::arg("moduleName", moduleName));
30+
31+
auto errorCode = stage.runPybindTest(cppCode, pythonTestCode);
32+
REQUIRE(errorCode == 0);
33+
}

0 commit comments

Comments
 (0)