aboutsummaryrefslogtreecommitdiff
path: root/xapian.i.in
diff options
context:
space:
mode:
Diffstat (limited to 'xapian.i.in')
-rw-r--r--xapian.i.in33
1 files changed, 32 insertions, 1 deletions
diff --git a/xapian.i.in b/xapian.i.in
index ff4ce80..bc9991c 100644
--- a/xapian.i.in
+++ b/xapian.i.in
@@ -1,5 +1,5 @@
/* guile-xapian --- Guile bindings for Xapian
- * Copyright © 2020, 2023 Arun Isaac <arunisaac@systemreboot.net>
+ * Copyright © 2020, 2023–2024 Arun Isaac <arunisaac@systemreboot.net>
* Copyright © 2021, 2022 Bob131 <bob@bob131.so>
*
* This file is part of guile-xapian.
@@ -141,3 +141,34 @@
return new Xapian::Query (op_, slot, range_lower, range_upper);
}
}
+
+// Child class of Xapian::FieldProcessor that calls back to a
+// user-specified Scheme procedure to process fields.
+%{
+ class GuileXapianFieldProcessorWrapper
+ : public Xapian::FieldProcessor {
+ private:
+ SCM proc;
+ public:
+ GuileXapianFieldProcessorWrapper(SCM _proc) {
+ proc = _proc;
+ }
+ Xapian::Query operator()(const std::string &str) {
+ void *ptr;
+ int res = SWIG_ConvertPtr(scm_call_1(proc, scm_from_utf8_string(str.c_str())),
+ &ptr,
+ SWIGTYPE_p_Xapian__Query,
+ 0);
+ return *((Xapian::Query*)ptr);
+ }
+ };
+%}
+
+class GuileXapianFieldProcessorWrapper
+: public Xapian::FieldProcessor
+{
+ public:
+ GuileXapianFieldProcessorWrapper(SCM);
+ ~GuileXapianFieldProcessorWrapper();
+ Xapian::Query operator()(std::string const&);
+};