11#include < pybind11/pybind11.h>
22
3+ #include " fields/field_definition.h"
34#include " fields/field_update.h"
45#include " fields/type.h"
56#include " fields/type_registry.h"
67#include " fields/input_field.h"
8+ #include " fields/subtraction.h"
79
810
911// ----------------
@@ -14,23 +16,51 @@ namespace py = pybind11;
1416
1517PYBIND11_MODULE (aika, m)
1618{
17- py::class_<FieldUpdate>(m, " FieldUpdate" )
18- .def (py::init<ProcessingPhase&, QueueInterceptor*>());
19-
20- py::class_<Type>(m, " Type" )
21- .def (py::init<TypeRegistry*, const std::string&>())
22- .def (" __str__" , [](const Type &t) {
23- return t.toString ();
24- })
25- .def (" inputField" , [](const Type &ref, const std::string &name) {
26- return new InputField (
27- const_cast <Type*>(&ref),
28- name
29- );
30- });
31-
32- py::class_<TypeRegistry>(m, " TypeRegistry" )
33- .def (py::init<>())
34- .def (" getType" , &TypeRegistry::getType)
35- .def (" registerType" , &TypeRegistry::registerType);
19+ // Bind Relation
20+ py::class_<Relation>(m, " Relation" );
21+
22+ py::class_<FieldUpdate>(m, " FieldUpdate" )
23+ .def (py::init<ProcessingPhase&, QueueInterceptor*>());
24+
25+ // Bind FieldDefinition first
26+ py::class_<FieldDefinition>(m, " FieldDefinition" )
27+ .def (" in" , &FieldDefinition::in, py::return_value_policy::reference_internal,
28+ py::arg (" relation" ), py::arg (" input" ), py::arg (" arg" ))
29+ .def (" out" , &FieldDefinition::out, py::return_value_policy::reference_internal,
30+ py::arg (" relation" ), py::arg (" output" ), py::arg (" arg" ));
31+
32+ // Bind AbstractFunctionDefinition (inherits from FieldDefinition)
33+ py::class_<AbstractFunctionDefinition, FieldDefinition>(m, " AbstractFunctionDefinition" );
34+
35+ // Bind Subtraction (inherits from AbstractFunctionDefinition)
36+ py::class_<Subtraction, AbstractFunctionDefinition>(m, " Subtraction" );
37+
38+ py::class_<InputField>(m, " InputField" )
39+ .def (py::init<Type*, const std::string &>())
40+ .def (" __str__" , [](const InputField &f) {
41+ return f.toString ();
42+ });
43+
44+ py::class_<Type>(m, " Type" )
45+ .def (py::init<TypeRegistry*, const std::string&>())
46+ .def (" __str__" , [](const Type &t) {
47+ return t.toString ();
48+ })
49+ .def (" inputField" , [](const Type &ref, const std::string &name) {
50+ return new InputField (
51+ const_cast <Type*>(&ref),
52+ name
53+ );
54+ }, py::return_value_policy::take_ownership)
55+ .def (" sub" , [](const Type &ref, const std::string &name) {
56+ return new Subtraction (
57+ const_cast <Type*>(&ref),
58+ name
59+ );
60+ }, py::return_value_policy::take_ownership);
61+
62+ py::class_<TypeRegistry>(m, " TypeRegistry" )
63+ .def (py::init<>())
64+ .def (" getType" , &TypeRegistry::getType)
65+ .def (" registerType" , &TypeRegistry::registerType);
3666}
0 commit comments