Skip to content

Commit

Permalink
Replace std::function pointer with a C style function pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedAlmaki committed Jan 30, 2025
1 parent 0f31aaf commit 53c7a22
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -39,11 +39,10 @@ AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &na
* when passed to the framework
* @return A pointer to a new AlgorithmProperty object
*/
const std::function<const AlgorithmProperty *(const std::string &, const IValidator *)> createPropertyWithValidator =
[](const std::string &name, const IValidator *validator) {
return createPropertyWithValidatorAndDirection(name, validator, Mantid::Kernel::Direction::Input);
};

static const AlgorithmProperty *(*const createPropertyWithValidator)(const std::string &, const IValidator *) =
+[](const std::string &name, const IValidator *validator) -> const AlgorithmProperty * {
return createPropertyWithValidatorAndDirection(name, validator, Mantid::Kernel::Direction::Input);
};
} // namespace

void export_AlgorithmProperty() {
@@ -56,7 +55,7 @@ void export_AlgorithmProperty() {
.def(init<const std::string &>(args("name")))
// These variants require the validator object to be cloned
.def("__init__",
make_constructor(&createPropertyWithValidator, default_call_policies(), args("name", "validator")))
make_constructor(createPropertyWithValidator, default_call_policies(), args("name", "validator")))
.def("__init__", make_constructor(&createPropertyWithValidatorAndDirection, default_call_policies(),
args("name", "validator", "direction")));
}
Original file line number Diff line number Diff line change
@@ -315,7 +315,7 @@ PyObject *getAlgorithmID(const IAlgorithm &self) {
AlgorithmID id = self.getAlgorithmID();
if (id)
return to_python_value<AlgorithmIDProxy>()(AlgorithmIDProxy(id));
return Py_NewRef(Py_None)
return Py_NewRef(Py_None);
}

//--------------------------------------------------------------------------------------

0 comments on commit 53c7a22

Please sign in to comment.