]> git.cworth.org Git - notmuch/blob - bindings/ruby/defs.h
ruby: add unlikely hint
[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 #define Data_Get_Notmuch_Object(obj, ptr)                                           \
59     do {                                                                            \
60         (ptr) = rb_data_object_get ((obj));                                         \
61         if (RB_UNLIKELY (!(ptr))) {                                                 \
62             VALUE cname = rb_class_name (CLASS_OF ((obj)));                         \
63             rb_raise (rb_eRuntimeError, "%"PRIsVALUE" object destroyed", cname);    \
64         }                                                                           \
65     } while (0)
66
67 #define Data_Get_Notmuch_Database(obj, ptr) \
68     Data_Get_Notmuch_Object ((obj), (ptr))
69
70 #define Data_Get_Notmuch_Directory(obj, ptr) \
71     Data_Get_Notmuch_Object ((obj), (ptr))
72
73 #define Data_Get_Notmuch_FileNames(obj, ptr) \
74     Data_Get_Notmuch_Object ((obj), (ptr))
75
76 #define Data_Get_Notmuch_Query(obj, ptr) \
77     Data_Get_Notmuch_Object ((obj), (ptr))
78
79 #define Data_Get_Notmuch_Threads(obj, ptr) \
80     Data_Get_Notmuch_Object ((obj), (ptr))
81
82 #define Data_Get_Notmuch_Messages(obj, ptr) \
83     Data_Get_Notmuch_Object ((obj), (ptr))
84
85 #define Data_Get_Notmuch_Thread(obj, ptr) \
86     Data_Get_Notmuch_Object ((obj), (ptr))
87
88 #define Data_Get_Notmuch_Message(obj, ptr) \
89     Data_Get_Notmuch_Object ((obj), (ptr))
90
91 #define Data_Get_Notmuch_Tags(obj, ptr) \
92     Data_Get_Notmuch_Object ((obj), (ptr))
93
94 /* status.c */
95 void
96 notmuch_rb_status_raise (notmuch_status_t status);
97
98 /* database.c */
99 VALUE
100 notmuch_rb_database_alloc (VALUE klass);
101
102 VALUE
103 notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE klass);
104
105 VALUE
106 notmuch_rb_database_open (int argc, VALUE *argv, VALUE klass);
107
108 VALUE
109 notmuch_rb_database_close (VALUE self);
110
111 VALUE
112 notmuch_rb_database_path (VALUE self);
113
114 VALUE
115 notmuch_rb_database_version (VALUE self);
116
117 VALUE
118 notmuch_rb_database_needs_upgrade (VALUE self);
119
120 VALUE
121 notmuch_rb_database_upgrade (VALUE self);
122
123 VALUE
124 notmuch_rb_database_begin_atomic (VALUE self);
125
126 VALUE
127 notmuch_rb_database_end_atomic (VALUE self);
128
129 VALUE
130 notmuch_rb_database_get_directory (VALUE self, VALUE pathv);
131
132 VALUE
133 notmuch_rb_database_add_message (VALUE self, VALUE pathv);
134
135 VALUE
136 notmuch_rb_database_remove_message (VALUE self, VALUE pathv);
137
138 VALUE
139 notmuch_rb_database_find_message (VALUE self, VALUE idv);
140
141 VALUE
142 notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv);
143
144 VALUE
145 notmuch_rb_database_get_all_tags (VALUE self);
146
147 VALUE
148 notmuch_rb_database_query_create (VALUE self, VALUE qstrv);
149
150 /* directory.c */
151 VALUE
152 notmuch_rb_directory_destroy (VALUE self);
153
154 VALUE
155 notmuch_rb_directory_get_mtime (VALUE self);
156
157 VALUE
158 notmuch_rb_directory_set_mtime (VALUE self, VALUE mtimev);
159
160 VALUE
161 notmuch_rb_directory_get_child_files (VALUE self);
162
163 VALUE
164 notmuch_rb_directory_get_child_directories (VALUE self);
165
166 /* filenames.c */
167 VALUE
168 notmuch_rb_filenames_destroy (VALUE self);
169
170 VALUE
171 notmuch_rb_filenames_each (VALUE self);
172
173 /* query.c */
174 VALUE
175 notmuch_rb_query_destroy (VALUE self);
176
177 VALUE
178 notmuch_rb_query_get_sort (VALUE self);
179
180 VALUE
181 notmuch_rb_query_set_sort (VALUE self, VALUE sortv);
182
183 VALUE
184 notmuch_rb_query_get_string (VALUE self);
185
186 VALUE
187 notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv);
188
189 VALUE
190 notmuch_rb_query_set_omit_excluded (VALUE self, VALUE omitv);
191
192 VALUE
193 notmuch_rb_query_search_threads (VALUE self);
194
195 VALUE
196 notmuch_rb_query_search_messages (VALUE self);
197
198 VALUE
199 notmuch_rb_query_count_messages (VALUE self);
200
201 VALUE
202 notmuch_rb_query_count_threads (VALUE self);
203
204 /* threads.c */
205 VALUE
206 notmuch_rb_threads_destroy (VALUE self);
207
208 VALUE
209 notmuch_rb_threads_each (VALUE self);
210
211 /* messages.c */
212 VALUE
213 notmuch_rb_messages_destroy (VALUE self);
214
215 VALUE
216 notmuch_rb_messages_each (VALUE self);
217
218 VALUE
219 notmuch_rb_messages_collect_tags (VALUE self);
220
221 /* thread.c */
222 VALUE
223 notmuch_rb_thread_destroy (VALUE self);
224
225 VALUE
226 notmuch_rb_thread_get_thread_id (VALUE self);
227
228 VALUE
229 notmuch_rb_thread_get_total_messages (VALUE self);
230
231 VALUE
232 notmuch_rb_thread_get_toplevel_messages (VALUE self);
233
234 VALUE
235 notmuch_rb_thread_get_messages (VALUE self);
236
237 VALUE
238 notmuch_rb_thread_get_matched_messages (VALUE self);
239
240 VALUE
241 notmuch_rb_thread_get_authors (VALUE self);
242
243 VALUE
244 notmuch_rb_thread_get_subject (VALUE self);
245
246 VALUE
247 notmuch_rb_thread_get_oldest_date (VALUE self);
248
249 VALUE
250 notmuch_rb_thread_get_newest_date (VALUE self);
251
252 VALUE
253 notmuch_rb_thread_get_tags (VALUE self);
254
255 /* message.c */
256 VALUE
257 notmuch_rb_message_destroy (VALUE self);
258
259 VALUE
260 notmuch_rb_message_get_message_id (VALUE self);
261
262 VALUE
263 notmuch_rb_message_get_thread_id (VALUE self);
264
265 VALUE
266 notmuch_rb_message_get_replies (VALUE self);
267
268 VALUE
269 notmuch_rb_message_get_filename (VALUE self);
270
271 VALUE
272 notmuch_rb_message_get_filenames (VALUE self);
273
274 VALUE
275 notmuch_rb_message_get_flag (VALUE self, VALUE flagv);
276
277 VALUE
278 notmuch_rb_message_set_flag (VALUE self, VALUE flagv, VALUE valuev);
279
280 VALUE
281 notmuch_rb_message_get_date (VALUE self);
282
283 VALUE
284 notmuch_rb_message_get_header (VALUE self, VALUE headerv);
285
286 VALUE
287 notmuch_rb_message_get_tags (VALUE self);
288
289 VALUE
290 notmuch_rb_message_add_tag (VALUE self, VALUE tagv);
291
292 VALUE
293 notmuch_rb_message_remove_tag (VALUE self, VALUE tagv);
294
295 VALUE
296 notmuch_rb_message_remove_all_tags (VALUE self);
297
298 VALUE
299 notmuch_rb_message_maildir_flags_to_tags (VALUE self);
300
301 VALUE
302 notmuch_rb_message_tags_to_maildir_flags (VALUE self);
303
304 VALUE
305 notmuch_rb_message_freeze (VALUE self);
306
307 VALUE
308 notmuch_rb_message_thaw (VALUE self);
309
310 /* tags.c */
311 VALUE
312 notmuch_rb_tags_destroy (VALUE self);
313
314 VALUE
315 notmuch_rb_tags_each (VALUE self);
316
317 /* init.c */
318 void
319 Init_notmuch (void);
320
321 #endif