Skip to content

Commit 59d67ae

Browse files
Fixes
1 parent 4cf75c1 commit 59d67ae

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/fields/relation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ int Relation::getRelationId() const {
99
return relationId;
1010
}
1111

12-
void Relation::setReversed(Relation* reversed) {
13-
this->reversed = reversed;
12+
void Relation::setReversed(Relation* rev) {
13+
reversed = rev;
1414
}
1515

1616
Relation* Relation::getReverse() {

src/fields/type_registry_python.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#include <pybind11/pybind11.h>
22

3+
#include "fields/relation.h"
34
#include "fields/field_definition.h"
45
#include "fields/field_update.h"
56
#include "fields/type.h"
67
#include "fields/type_registry.h"
78
#include "fields/input_field.h"
89
#include "fields/subtraction.h"
10+
#include "fields/test_type.h"
911

1012

1113
// ----------------
@@ -17,7 +19,16 @@ namespace py = pybind11;
1719
PYBIND11_MODULE(aika, m)
1820
{
1921
// Bind Relation
20-
py::class_<Relation>(m, "Relation");
22+
py::class_<Relation>(m, "Relation")
23+
.def("setReversed", [](Relation &rel, Relation* reversed) {
24+
rel.setReversed(reversed);
25+
});
26+
27+
py::class_<RelationOne, Relation>(m, "RelationOne")
28+
.def(py::init<int, const std::string&>());
29+
30+
py::class_<RelationMany, Relation>(m, "RelationMany")
31+
.def(py::init<int, const std::string&>());
2132

2233
py::class_<FieldUpdate>(m, "FieldUpdate")
2334
.def(py::init<ProcessingPhase&, QueueInterceptor*>());
@@ -59,6 +70,9 @@ PYBIND11_MODULE(aika, m)
5970
);
6071
}, py::return_value_policy::take_ownership);
6172

73+
py::class_<TestType, Type>(m, "TestType")
74+
.def(py::init<TypeRegistry*, const std::string&>());
75+
6276
py::class_<TypeRegistry>(m, "TypeRegistry")
6377
.def(py::init<>())
6478
.def("getType", &TypeRegistry::getType)

tests/subtraction-test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ def test_something(self):
66
self.assertEqual(True, False) # add assertion here
77

88
def testSubtraction(self):
9+
TEST_RELATION_FROM = aika.RelationOne(1, "TEST_FROM")
10+
TEST_RELATION_TO = aika.RelationOne(2, "TEST_TO")
11+
TEST_RELATION_TO.setReversed(TEST_RELATION_FROM)
12+
TEST_RELATION_FROM.setReversed(TEST_RELATION_TO)
13+
914
registry = aika.TypeRegistry()
1015

1116
typeA = aika.TestType(registry, "A")

0 commit comments

Comments
 (0)