]> git.notmuchmail.org Git - notmuch/blob - bindings/ruby/defs.h
ruby: move towards more modern RTypedData
[notmuch] / bindings / ruby / defs.h
1 /* The Ruby interface to the notmuch mail library
2  *
3  * Copyright © 2010, 2011, 2012 Ali Polatel
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see https://www.gnu.org/licenses/ .
17  *
18  * Author: Ali Polatel <alip@exherbo.org>
19  */
20
21 #ifndef DEFS_H
22 #define DEFS_H
23
24 #include <notmuch.h>
25 #include <ruby.h>
26
27 extern VALUE notmuch_rb_cDatabase;
28 extern VALUE notmuch_rb_cDirectory;
29 extern VALUE notmuch_rb_cFileNames;
30 extern VALUE notmuch_rb_cQuery;
31 extern VALUE notmuch_rb_cThreads;
32 extern VALUE notmuch_rb_cThread;
33 extern VALUE notmuch_rb_cMessages;
34 extern VALUE notmuch_rb_cMessage;
35 extern VALUE notmuch_rb_cTags;
36
37 extern VALUE notmuch_rb_eBaseError;
38 extern VALUE notmuch_rb_eDatabaseError;
39 extern VALUE notmuch_rb_eMemoryError;
40 extern VALUE notmuch_rb_eReadOnlyError;
41 extern VALUE notmuch_rb_eXapianError;
42 extern VALUE notmuch_rb_eFileError;
43 extern VALUE notmuch_rb_eFileNotEmailError;
44 extern VALUE notmuch_rb_eNullPointerError;
45 extern VALUE notmuch_rb_eTagTooLongError;
46 extern VALUE notmuch_rb_eUnbalancedFreezeThawError;
47 extern VALUE notmuch_rb_eUnbalancedAtomicError;
48
49 extern ID ID_call;
50 extern ID ID_db_create;
51 extern ID ID_db_mode;
52
53 /* RSTRING_PTR() is new in ruby-1.9 */
54 #if !defined(RSTRING_PTR)
55 # define RSTRING_PTR(v) (RSTRING((v))->ptr)
56 #endif /* !defined (RSTRING_PTR) */
57
58 extern const rb_data_type_t notmuch_rb_object_type;
59
60 #define Data_Get_Notmuch_Object(obj, ptr)                                           \
61     do {                                                                            \
62         (ptr) = rb_check_typeddata ((obj), &notmuch_rb_object_type);                \
63         if (RB_UNLIKELY (!(ptr))) {                                                 \
64             VALUE cname = rb_class_name (CLASS_OF ((obj)));                         \
65             rb_raise (rb_eRuntimeError, "%"PRIsVALUE" object destroyed", cname);    \
66         }                                                                           \
67     } while (0)
68
69 #define Data_Wrap_Notmuch_Object(klass, ptr)    \
70     TypedData_Wrap_Struct ((klass), &notmuch_rb_object_type, (ptr))
71
72 #define Data_Get_Notmuch_Database(obj, ptr) \
73     Data_Get_Notmuch_Object ((obj), (ptr))
74
75 #define Data_Get_Notmuch_Directory(obj, ptr) \
76     Data_Get_Notmuch_Object ((obj), (ptr))
77
78 #define Data_Get_Notmuch_FileNames(obj, ptr) \
79     Data_Get_Notmuch_Object ((obj), (ptr))
80
81 #define Data_Get_Notmuch_Query(obj, ptr) \
82     Data_Get_Notmuch_Object ((obj), (ptr))
83
84 #define Data_Get_Notmuch_Threads(obj, ptr) \
85     Data_Get_Notmuch_Object ((obj), (ptr))
86
87 #define Data_Get_Notmuch_Messages(obj, ptr) \
88     Data_Get_Notmuch_Object ((obj), (ptr))
89
90 #define Data_Get_Notmuch_Thread(obj, ptr) \
91     Data_Get_Notmuch_Object ((obj), (ptr))
92
93 #define Data_Get_Notmuch_Message(obj, ptr) \
94     Data_Get_Notmuch_Object ((obj), (ptr))
95
96 #define Data_Get_Notmuch_Tags(obj, ptr) \
97     Data_Get_Notmuch_Object ((obj), (ptr))
98
99 /* status.c */
100 void
101 notmuch_rb_status_raise (notmuch_status_t status);
102
103 /* database.c */
104 VALUE
105 notmuch_rb_database_alloc (VALUE klass);
106
107 VALUE
108 notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE klass);
109
110 VALUE
111 notmuch_rb_database_open (int argc, VALUE *argv, VALUE klass);
112
113 VALUE
114 notmuch_rb_database_close (VALUE self);
115
116 VALUE
117 notmuch_rb_database_path (VALUE self);
118
119 VALUE
120 notmuch_rb_database_version (VALUE self);
121
122 VALUE
123 notmuch_rb_database_needs_upgrade (VALUE self);
124
125 VALUE
126 notmuch_rb_database_upgrade (VALUE self);
127
128 VALUE
129 notmuch_rb_database_begin_atomic (VALUE self);
130
131 VALUE
132 notmuch_rb_database_end_atomic (VALUE self);
133
134 VALUE
135 notmuch_rb_database_get_directory (VALUE self, VALUE pathv);
136
137 VALUE
138 notmuch_rb_database_add_message (VALUE self, VALUE pathv);
139
140 VALUE
141 notmuch_rb_database_remove_message (VALUE self, VALUE pathv);
142
143 VALUE
144 notmuch_rb_database_find_message (VALUE self, VALUE idv);
145
146 VALUE
147 notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv);
148
149 VALUE
150 notmuch_rb_database_get_all_tags (VALUE self);
151
152 VALUE
153 notmuch_rb_database_query_create (VALUE self, VALUE qstrv);
154
155 /* directory.c */
156 VALUE
157 notmuch_rb_directory_destroy (VALUE self);
158
159 VALUE
160 notmuch_rb_directory_get_mtime (VALUE self);
161
162 VALUE
163 notmuch_rb_directory_set_mtime (VALUE self, VALUE mtimev);
164
165 VALUE
166 notmuch_rb_directory_get_child_files (VALUE self);
167
168 VALUE
169 notmuch_rb_directory_get_child_directories (VALUE self);
170
171 /* filenames.c */
172 VALUE
173 notmuch_rb_filenames_destroy (VALUE self);
174
175 VALUE
176 notmuch_rb_filenames_each (VALUE self);
177
178 /* query.c */
179 VALUE
180 notmuch_rb_query_destroy (VALUE self);
181
182 VALUE
183 notmuch_rb_query_get_sort (VALUE self);
184
185 VALUE
186 notmuch_rb_query_set_sort (VALUE self, VALUE sortv);
187
188 VALUE
189 notmuch_rb_query_get_string (VALUE self);
190
191 VALUE
192 notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv);
193
194 VALUE
195 notmuch_rb_query_set_omit_excluded (VALUE self, VALUE omitv);
196
197 VALUE
198 notmuch_rb_query_search_threads (VALUE self);
199
200 VALUE
201 notmuch_rb_query_search_messages (VALUE self);
202
203 VALUE
204 notmuch_rb_query_count_messages (VALUE self);
205
206 VALUE
207 notmuch_rb_query_count_threads (VALUE self);
208
209 /* threads.c */
210 VALUE
211 notmuch_rb_threads_destroy (VALUE self);
212
213 VALUE
214 notmuch_rb_threads_each (VALUE self);
215
216 /* messages.c */
217 VALUE
218 notmuch_rb_messages_destroy (VALUE self);
219
220 VALUE
221 notmuch_rb_messages_each (VALUE self);
222
223 VALUE
224 notmuch_rb_messages_collect_tags (VALUE self);
225
226 /* thread.c */
227 VALUE
228 notmuch_rb_thread_destroy (VALUE self);
229
230 VALUE
231 notmuch_rb_thread_get_thread_id (VALUE self);
232
233 VALUE
234 notmuch_rb_thread_get_total_messages (VALUE self);
235
236 VALUE
237 notmuch_rb_thread_get_toplevel_messages (VALUE self);
238
239 VALUE
240 notmuch_rb_thread_get_messages (VALUE self);
241
242 VALUE
243 notmuch_rb_thread_get_matched_messages (VALUE self);
244
245 VALUE
246 notmuch_rb_thread_get_authors (VALUE self);
247
248 VALUE
249 notmuch_rb_thread_get_subject (VALUE self);
250
251 VALUE
252 notmuch_rb_thread_get_oldest_date (VALUE self);
253
254 VALUE
255 notmuch_rb_thread_get_newest_date (VALUE self);
256
257 VALUE
258 notmuch_rb_thread_get_tags (VALUE self);
259
260 /* message.c */
261 VALUE
262 notmuch_rb_message_destroy (VALUE self);
263
264 VALUE
265 notmuch_rb_message_get_message_id (VALUE self);
266
267 VALUE
268 notmuch_rb_message_get_thread_id (VALUE self);
269
270 VALUE
271 notmuch_rb_message_get_replies (VALUE self);
272
273 VALUE
274 notmuch_rb_message_get_filename (VALUE self);
275
276 VALUE
277 notmuch_rb_message_get_filenames (VALUE self);
278
279 VALUE
280 notmuch_rb_message_get_flag (VALUE self, VALUE flagv);
281
282 VALUE
283 notmuch_rb_message_set_flag (VALUE self, VALUE flagv, VALUE valuev);
284
285 VALUE
286 notmuch_rb_message_get_date (VALUE self);
287
288 VALUE
289 notmuch_rb_message_get_header (VALUE self, VALUE headerv);
290
291 VALUE
292 notmuch_rb_message_get_tags (VALUE self);
293
294 VALUE
295 notmuch_rb_message_add_tag (VALUE self, VALUE tagv);
296
297 VALUE
298 notmuch_rb_message_remove_tag (VALUE self, VALUE tagv);
299
300 VALUE
301 notmuch_rb_message_remove_all_tags (VALUE self);
302
303 VALUE
304 notmuch_rb_message_maildir_flags_to_tags (VALUE self);
305
306 VALUE
307 notmuch_rb_message_tags_to_maildir_flags (VALUE self);
308
309 VALUE
310 notmuch_rb_message_freeze (VALUE self);
311
312 VALUE
313 notmuch_rb_message_thaw (VALUE self);
314
315 /* tags.c */
316 VALUE
317 notmuch_rb_tags_destroy (VALUE self);
318
319 VALUE
320 notmuch_rb_tags_each (VALUE self);
321
322 /* init.c */
323 void
324 Init_notmuch (void);
325
326 #endif