-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpython_filter.h
More file actions
33 lines (25 loc) · 929 Bytes
/
Copy pathpython_filter.h
File metadata and controls
33 lines (25 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once
#include <pybind11/embed.h>
#include <rime/common.h>
#include <rime/filter.h>
#include <rime/gear/filter_commons.h>
#include <rime/translation.h>
namespace py = pybind11;
namespace pythonext {
class PythonFilter : public rime::Filter {
public:
PythonFilter( const rime::Ticket& ticket, py::function py_entry );
virtual rime::an<rime::Translation> Apply( rime::an<rime::Translation> translation, rime::CandidateList* candidates ) override;
void FilterFunc( rime::an<rime::Candidate> cand, rime::CandidateQueue* cand_queue );
private:
const py::function py_entry;
const py::object FilterQuery;
};
class PythonFilterTranslation : public rime::PrefetchTranslation {
public:
PythonFilterTranslation( PythonFilter* filter, rime::an<rime::Translation> translation );
protected:
virtual bool Replenish() override;
PythonFilter* const filter_;
};
} // namespace pythonext