1 /**************************************************
2  *
3  * Generated by build/generate-future-functions.py.
4  *
5  * DO NOT EDIT THIS FILE.
6  *
7  *************************************************/
8 /* clang-format off */
9 
10 /*
11  * Define two sets of functions: background functions and future functions.
12 
13  * A background function like background_mongoc_cursor_next runs a driver
14  * operation on a thread.
15 
16  * A future function like future_mongoc_cursor_next launches the background
17  * operation and returns a future_t that will resolve when the operation
18  * finishes.
19  *
20  * These are used with mock_server_t so you can run the driver on a thread while
21  * controlling the server from the main thread.
22  */
23 
24 #include "mongoc-topology-private.h"
25 
26 #include "future-functions.h"
27 
28 
29 static void *
background_mongoc_bulk_operation_execute(void * data)30 background_mongoc_bulk_operation_execute (void *data)
31 {
32    future_t *future = (future_t *) data;
33    future_value_t return_value;
34 
35    return_value.type = future_value_uint32_t_type;
36 
37    future_value_set_uint32_t (
38       &return_value,
39       mongoc_bulk_operation_execute (
40          future_value_get_mongoc_bulk_operation_ptr (future_get_param (future, 0)),
41          future_value_get_bson_ptr (future_get_param (future, 1)),
42          future_value_get_bson_error_ptr (future_get_param (future, 2))
43       ));
44 
45    future_resolve (future, return_value);
46 
47    return NULL;
48 }
49 
50 static void *
background_mongoc_client_command_simple(void * data)51 background_mongoc_client_command_simple (void *data)
52 {
53    future_t *future = (future_t *) data;
54    future_value_t return_value;
55 
56    return_value.type = future_value_bool_type;
57 
58    future_value_set_bool (
59       &return_value,
60       mongoc_client_command_simple (
61          future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
62          future_value_get_const_char_ptr (future_get_param (future, 1)),
63          future_value_get_const_bson_ptr (future_get_param (future, 2)),
64          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 3)),
65          future_value_get_bson_ptr (future_get_param (future, 4)),
66          future_value_get_bson_error_ptr (future_get_param (future, 5))
67       ));
68 
69    future_resolve (future, return_value);
70 
71    return NULL;
72 }
73 
74 static void *
background_mongoc_client_read_command_with_opts(void * data)75 background_mongoc_client_read_command_with_opts (void *data)
76 {
77    future_t *future = (future_t *) data;
78    future_value_t return_value;
79 
80    return_value.type = future_value_bool_type;
81 
82    future_value_set_bool (
83       &return_value,
84       mongoc_client_read_command_with_opts (
85          future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
86          future_value_get_const_char_ptr (future_get_param (future, 1)),
87          future_value_get_const_bson_ptr (future_get_param (future, 2)),
88          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 3)),
89          future_value_get_const_bson_ptr (future_get_param (future, 4)),
90          future_value_get_bson_ptr (future_get_param (future, 5)),
91          future_value_get_bson_error_ptr (future_get_param (future, 6))
92       ));
93 
94    future_resolve (future, return_value);
95 
96    return NULL;
97 }
98 
99 static void *
background_mongoc_client_write_command_with_opts(void * data)100 background_mongoc_client_write_command_with_opts (void *data)
101 {
102    future_t *future = (future_t *) data;
103    future_value_t return_value;
104 
105    return_value.type = future_value_bool_type;
106 
107    future_value_set_bool (
108       &return_value,
109       mongoc_client_write_command_with_opts (
110          future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
111          future_value_get_const_char_ptr (future_get_param (future, 1)),
112          future_value_get_const_bson_ptr (future_get_param (future, 2)),
113          future_value_get_const_bson_ptr (future_get_param (future, 3)),
114          future_value_get_bson_ptr (future_get_param (future, 4)),
115          future_value_get_bson_error_ptr (future_get_param (future, 5))
116       ));
117 
118    future_resolve (future, return_value);
119 
120    return NULL;
121 }
122 
123 static void *
background_mongoc_client_read_write_command_with_opts(void * data)124 background_mongoc_client_read_write_command_with_opts (void *data)
125 {
126    future_t *future = (future_t *) data;
127    future_value_t return_value;
128 
129    return_value.type = future_value_bool_type;
130 
131    future_value_set_bool (
132       &return_value,
133       mongoc_client_read_write_command_with_opts (
134          future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
135          future_value_get_const_char_ptr (future_get_param (future, 1)),
136          future_value_get_const_bson_ptr (future_get_param (future, 2)),
137          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 3)),
138          future_value_get_const_bson_ptr (future_get_param (future, 4)),
139          future_value_get_bson_ptr (future_get_param (future, 5)),
140          future_value_get_bson_error_ptr (future_get_param (future, 6))
141       ));
142 
143    future_resolve (future, return_value);
144 
145    return NULL;
146 }
147 
148 static void *
background_mongoc_client_kill_cursor(void * data)149 background_mongoc_client_kill_cursor (void *data)
150 {
151    future_t *future = (future_t *) data;
152    future_value_t return_value;
153 
154    return_value.type = future_value_void_type;
155 
156    mongoc_client_kill_cursor (
157       future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
158       future_value_get_int64_t (future_get_param (future, 1)));
159 
160    future_resolve (future, return_value);
161 
162    return NULL;
163 }
164 
165 static void *
background_mongoc_collection_aggregate(void * data)166 background_mongoc_collection_aggregate (void *data)
167 {
168    future_t *future = (future_t *) data;
169    future_value_t return_value;
170 
171    return_value.type = future_value_mongoc_cursor_ptr_type;
172 
173    future_value_set_mongoc_cursor_ptr (
174       &return_value,
175       mongoc_collection_aggregate (
176          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
177          future_value_get_mongoc_query_flags_t (future_get_param (future, 1)),
178          future_value_get_const_bson_ptr (future_get_param (future, 2)),
179          future_value_get_const_bson_ptr (future_get_param (future, 3)),
180          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 4))
181       ));
182 
183    future_resolve (future, return_value);
184 
185    return NULL;
186 }
187 
188 static void *
background_mongoc_collection_count(void * data)189 background_mongoc_collection_count (void *data)
190 {
191    future_t *future = (future_t *) data;
192    future_value_t return_value;
193 
194    return_value.type = future_value_int64_t_type;
195 
196    future_value_set_int64_t (
197       &return_value,
198       mongoc_collection_count (
199          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
200          future_value_get_mongoc_query_flags_t (future_get_param (future, 1)),
201          future_value_get_const_bson_ptr (future_get_param (future, 2)),
202          future_value_get_int64_t (future_get_param (future, 3)),
203          future_value_get_int64_t (future_get_param (future, 4)),
204          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 5)),
205          future_value_get_bson_error_ptr (future_get_param (future, 6))
206       ));
207 
208    future_resolve (future, return_value);
209 
210    return NULL;
211 }
212 
213 static void *
background_mongoc_collection_count_with_opts(void * data)214 background_mongoc_collection_count_with_opts (void *data)
215 {
216    future_t *future = (future_t *) data;
217    future_value_t return_value;
218 
219    return_value.type = future_value_int64_t_type;
220 
221    future_value_set_int64_t (
222       &return_value,
223       mongoc_collection_count_with_opts (
224          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
225          future_value_get_mongoc_query_flags_t (future_get_param (future, 1)),
226          future_value_get_const_bson_ptr (future_get_param (future, 2)),
227          future_value_get_int64_t (future_get_param (future, 3)),
228          future_value_get_int64_t (future_get_param (future, 4)),
229          future_value_get_const_bson_ptr (future_get_param (future, 5)),
230          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 6)),
231          future_value_get_bson_error_ptr (future_get_param (future, 7))
232       ));
233 
234    future_resolve (future, return_value);
235 
236    return NULL;
237 }
238 
239 static void *
background_mongoc_collection_create_index_with_opts(void * data)240 background_mongoc_collection_create_index_with_opts (void *data)
241 {
242    future_t *future = (future_t *) data;
243    future_value_t return_value;
244 
245    return_value.type = future_value_bool_type;
246 
247    future_value_set_bool (
248       &return_value,
249       mongoc_collection_create_index_with_opts (
250          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
251          future_value_get_const_bson_ptr (future_get_param (future, 1)),
252          future_value_get_const_mongoc_index_opt_t (future_get_param (future, 2)),
253          future_value_get_bson_ptr (future_get_param (future, 3)),
254          future_value_get_bson_ptr (future_get_param (future, 4)),
255          future_value_get_bson_error_ptr (future_get_param (future, 5))
256       ));
257 
258    future_resolve (future, return_value);
259 
260    return NULL;
261 }
262 
263 static void *
background_mongoc_collection_find_and_modify_with_opts(void * data)264 background_mongoc_collection_find_and_modify_with_opts (void *data)
265 {
266    future_t *future = (future_t *) data;
267    future_value_t return_value;
268 
269    return_value.type = future_value_bool_type;
270 
271    future_value_set_bool (
272       &return_value,
273       mongoc_collection_find_and_modify_with_opts (
274          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
275          future_value_get_const_bson_ptr (future_get_param (future, 1)),
276          future_value_get_const_mongoc_find_and_modify_opts_ptr (future_get_param (future, 2)),
277          future_value_get_bson_ptr (future_get_param (future, 3)),
278          future_value_get_bson_error_ptr (future_get_param (future, 4))
279       ));
280 
281    future_resolve (future, return_value);
282 
283    return NULL;
284 }
285 
286 static void *
background_mongoc_collection_find_and_modify(void * data)287 background_mongoc_collection_find_and_modify (void *data)
288 {
289    future_t *future = (future_t *) data;
290    future_value_t return_value;
291 
292    return_value.type = future_value_bool_type;
293 
294    future_value_set_bool (
295       &return_value,
296       mongoc_collection_find_and_modify (
297          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
298          future_value_get_const_bson_ptr (future_get_param (future, 1)),
299          future_value_get_const_bson_ptr (future_get_param (future, 2)),
300          future_value_get_const_bson_ptr (future_get_param (future, 3)),
301          future_value_get_const_bson_ptr (future_get_param (future, 4)),
302          future_value_get_bool (future_get_param (future, 5)),
303          future_value_get_bool (future_get_param (future, 6)),
304          future_value_get_bool (future_get_param (future, 7)),
305          future_value_get_bson_ptr (future_get_param (future, 8)),
306          future_value_get_bson_error_ptr (future_get_param (future, 9))
307       ));
308 
309    future_resolve (future, return_value);
310 
311    return NULL;
312 }
313 
314 static void *
background_mongoc_collection_find_indexes(void * data)315 background_mongoc_collection_find_indexes (void *data)
316 {
317    future_t *future = (future_t *) data;
318    future_value_t return_value;
319 
320    return_value.type = future_value_mongoc_cursor_ptr_type;
321 
322    future_value_set_mongoc_cursor_ptr (
323       &return_value,
324       mongoc_collection_find_indexes (
325          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
326          future_value_get_bson_error_ptr (future_get_param (future, 1))
327       ));
328 
329    future_resolve (future, return_value);
330 
331    return NULL;
332 }
333 
334 static void *
background_mongoc_collection_stats(void * data)335 background_mongoc_collection_stats (void *data)
336 {
337    future_t *future = (future_t *) data;
338    future_value_t return_value;
339 
340    return_value.type = future_value_bool_type;
341 
342    future_value_set_bool (
343       &return_value,
344       mongoc_collection_stats (
345          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
346          future_value_get_const_bson_ptr (future_get_param (future, 1)),
347          future_value_get_bson_ptr (future_get_param (future, 2)),
348          future_value_get_bson_error_ptr (future_get_param (future, 3))
349       ));
350 
351    future_resolve (future, return_value);
352 
353    return NULL;
354 }
355 
356 static void *
background_mongoc_collection_insert(void * data)357 background_mongoc_collection_insert (void *data)
358 {
359    future_t *future = (future_t *) data;
360    future_value_t return_value;
361 
362    return_value.type = future_value_bool_type;
363 
364    future_value_set_bool (
365       &return_value,
366       mongoc_collection_insert (
367          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
368          future_value_get_mongoc_insert_flags_t (future_get_param (future, 1)),
369          future_value_get_const_bson_ptr (future_get_param (future, 2)),
370          future_value_get_const_mongoc_write_concern_ptr (future_get_param (future, 3)),
371          future_value_get_bson_error_ptr (future_get_param (future, 4))
372       ));
373 
374    future_resolve (future, return_value);
375 
376    return NULL;
377 }
378 
379 static void *
background_mongoc_collection_read_write_command_with_opts(void * data)380 background_mongoc_collection_read_write_command_with_opts (void *data)
381 {
382    future_t *future = (future_t *) data;
383    future_value_t return_value;
384 
385    return_value.type = future_value_bool_type;
386 
387    future_value_set_bool (
388       &return_value,
389       mongoc_collection_read_write_command_with_opts (
390          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
391          future_value_get_const_bson_ptr (future_get_param (future, 1)),
392          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 2)),
393          future_value_get_const_bson_ptr (future_get_param (future, 3)),
394          future_value_get_bson_ptr (future_get_param (future, 4)),
395          future_value_get_bson_error_ptr (future_get_param (future, 5))
396       ));
397 
398    future_resolve (future, return_value);
399 
400    return NULL;
401 }
402 
403 static void *
background_mongoc_collection_insert_bulk(void * data)404 background_mongoc_collection_insert_bulk (void *data)
405 {
406    future_t *future = (future_t *) data;
407    future_value_t return_value;
408 
409    return_value.type = future_value_bool_type;
410 
411    future_value_set_bool (
412       &return_value,
413       mongoc_collection_insert_bulk (
414          future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
415          future_value_get_mongoc_insert_flags_t (future_get_param (future, 1)),
416          future_value_get_const_bson_ptr_ptr (future_get_param (future, 2)),
417          future_value_get_uint32_t (future_get_param (future, 3)),
418          future_value_get_const_mongoc_write_concern_ptr (future_get_param (future, 4)),
419          future_value_get_bson_error_ptr (future_get_param (future, 5))
420       ));
421 
422    future_resolve (future, return_value);
423 
424    return NULL;
425 }
426 
427 static void *
background_mongoc_cursor_destroy(void * data)428 background_mongoc_cursor_destroy (void *data)
429 {
430    future_t *future = (future_t *) data;
431    future_value_t return_value;
432 
433    return_value.type = future_value_void_type;
434 
435    mongoc_cursor_destroy (
436       future_value_get_mongoc_cursor_ptr (future_get_param (future, 0)));
437 
438    future_resolve (future, return_value);
439 
440    return NULL;
441 }
442 
443 static void *
background_mongoc_cursor_next(void * data)444 background_mongoc_cursor_next (void *data)
445 {
446    future_t *future = (future_t *) data;
447    future_value_t return_value;
448 
449    return_value.type = future_value_bool_type;
450 
451    future_value_set_bool (
452       &return_value,
453       mongoc_cursor_next (
454          future_value_get_mongoc_cursor_ptr (future_get_param (future, 0)),
455          future_value_get_const_bson_ptr_ptr (future_get_param (future, 1))
456       ));
457 
458    future_resolve (future, return_value);
459 
460    return NULL;
461 }
462 
463 static void *
background_mongoc_client_get_database_names(void * data)464 background_mongoc_client_get_database_names (void *data)
465 {
466    future_t *future = (future_t *) data;
467    future_value_t return_value;
468 
469    return_value.type = future_value_char_ptr_ptr_type;
470 
471    future_value_set_char_ptr_ptr (
472       &return_value,
473       mongoc_client_get_database_names (
474          future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
475          future_value_get_bson_error_ptr (future_get_param (future, 1))
476       ));
477 
478    future_resolve (future, return_value);
479 
480    return NULL;
481 }
482 
483 static void *
background_mongoc_client_select_server(void * data)484 background_mongoc_client_select_server (void *data)
485 {
486    future_t *future = (future_t *) data;
487    future_value_t return_value;
488 
489    return_value.type = future_value_mongoc_server_description_ptr_type;
490 
491    future_value_set_mongoc_server_description_ptr (
492       &return_value,
493       mongoc_client_select_server (
494          future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
495          future_value_get_bool (future_get_param (future, 1)),
496          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 2)),
497          future_value_get_bson_error_ptr (future_get_param (future, 3))
498       ));
499 
500    future_resolve (future, return_value);
501 
502    return NULL;
503 }
504 
505 static void *
background_mongoc_database_command_simple(void * data)506 background_mongoc_database_command_simple (void *data)
507 {
508    future_t *future = (future_t *) data;
509    future_value_t return_value;
510 
511    return_value.type = future_value_bool_type;
512 
513    future_value_set_bool (
514       &return_value,
515       mongoc_database_command_simple (
516          future_value_get_mongoc_database_ptr (future_get_param (future, 0)),
517          future_value_get_bson_ptr (future_get_param (future, 1)),
518          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 2)),
519          future_value_get_bson_ptr (future_get_param (future, 3)),
520          future_value_get_bson_error_ptr (future_get_param (future, 4))
521       ));
522 
523    future_resolve (future, return_value);
524 
525    return NULL;
526 }
527 
528 static void *
background_mongoc_database_get_collection_names(void * data)529 background_mongoc_database_get_collection_names (void *data)
530 {
531    future_t *future = (future_t *) data;
532    future_value_t return_value;
533 
534    return_value.type = future_value_char_ptr_ptr_type;
535 
536    future_value_set_char_ptr_ptr (
537       &return_value,
538       mongoc_database_get_collection_names (
539          future_value_get_mongoc_database_ptr (future_get_param (future, 0)),
540          future_value_get_bson_error_ptr (future_get_param (future, 1))
541       ));
542 
543    future_resolve (future, return_value);
544 
545    return NULL;
546 }
547 
548 static void *
background_mongoc_gridfs_file_readv(void * data)549 background_mongoc_gridfs_file_readv (void *data)
550 {
551    future_t *future = (future_t *) data;
552    future_value_t return_value;
553 
554    return_value.type = future_value_ssize_t_type;
555 
556    future_value_set_ssize_t (
557       &return_value,
558       mongoc_gridfs_file_readv (
559          future_value_get_mongoc_gridfs_file_ptr (future_get_param (future, 0)),
560          future_value_get_mongoc_iovec_ptr (future_get_param (future, 1)),
561          future_value_get_size_t (future_get_param (future, 2)),
562          future_value_get_size_t (future_get_param (future, 3)),
563          future_value_get_uint32_t (future_get_param (future, 4))
564       ));
565 
566    future_resolve (future, return_value);
567 
568    return NULL;
569 }
570 
571 static void *
background_mongoc_gridfs_find_one(void * data)572 background_mongoc_gridfs_find_one (void *data)
573 {
574    future_t *future = (future_t *) data;
575    future_value_t return_value;
576 
577    return_value.type = future_value_mongoc_gridfs_file_ptr_type;
578 
579    future_value_set_mongoc_gridfs_file_ptr (
580       &return_value,
581       mongoc_gridfs_find_one (
582          future_value_get_mongoc_gridfs_ptr (future_get_param (future, 0)),
583          future_value_get_const_bson_ptr (future_get_param (future, 1)),
584          future_value_get_bson_error_ptr (future_get_param (future, 2))
585       ));
586 
587    future_resolve (future, return_value);
588 
589    return NULL;
590 }
591 
592 static void *
background_mongoc_gridfs_file_remove(void * data)593 background_mongoc_gridfs_file_remove (void *data)
594 {
595    future_t *future = (future_t *) data;
596    future_value_t return_value;
597 
598    return_value.type = future_value_bool_type;
599 
600    future_value_set_bool (
601       &return_value,
602       mongoc_gridfs_file_remove (
603          future_value_get_mongoc_gridfs_file_ptr (future_get_param (future, 0)),
604          future_value_get_bson_error_ptr (future_get_param (future, 1))
605       ));
606 
607    future_resolve (future, return_value);
608 
609    return NULL;
610 }
611 
612 static void *
background_mongoc_gridfs_file_seek(void * data)613 background_mongoc_gridfs_file_seek (void *data)
614 {
615    future_t *future = (future_t *) data;
616    future_value_t return_value;
617 
618    return_value.type = future_value_int_type;
619 
620    future_value_set_int (
621       &return_value,
622       mongoc_gridfs_file_seek (
623          future_value_get_mongoc_gridfs_file_ptr (future_get_param (future, 0)),
624          future_value_get_int64_t (future_get_param (future, 1)),
625          future_value_get_int (future_get_param (future, 2))
626       ));
627 
628    future_resolve (future, return_value);
629 
630    return NULL;
631 }
632 
633 static void *
background_mongoc_gridfs_file_writev(void * data)634 background_mongoc_gridfs_file_writev (void *data)
635 {
636    future_t *future = (future_t *) data;
637    future_value_t return_value;
638 
639    return_value.type = future_value_ssize_t_type;
640 
641    future_value_set_ssize_t (
642       &return_value,
643       mongoc_gridfs_file_writev (
644          future_value_get_mongoc_gridfs_file_ptr (future_get_param (future, 0)),
645          future_value_get_const_mongoc_iovec_ptr (future_get_param (future, 1)),
646          future_value_get_size_t (future_get_param (future, 2)),
647          future_value_get_uint32_t (future_get_param (future, 3))
648       ));
649 
650    future_resolve (future, return_value);
651 
652    return NULL;
653 }
654 
655 static void *
background_mongoc_gridfs_find_one_with_opts(void * data)656 background_mongoc_gridfs_find_one_with_opts (void *data)
657 {
658    future_t *future = (future_t *) data;
659    future_value_t return_value;
660 
661    return_value.type = future_value_mongoc_gridfs_file_ptr_type;
662 
663    future_value_set_mongoc_gridfs_file_ptr (
664       &return_value,
665       mongoc_gridfs_find_one_with_opts (
666          future_value_get_mongoc_gridfs_ptr (future_get_param (future, 0)),
667          future_value_get_const_bson_ptr (future_get_param (future, 1)),
668          future_value_get_const_bson_ptr (future_get_param (future, 2)),
669          future_value_get_bson_error_ptr (future_get_param (future, 3))
670       ));
671 
672    future_resolve (future, return_value);
673 
674    return NULL;
675 }
676 
677 static void *
background_mongoc_topology_select(void * data)678 background_mongoc_topology_select (void *data)
679 {
680    future_t *future = (future_t *) data;
681    future_value_t return_value;
682 
683    return_value.type = future_value_mongoc_server_description_ptr_type;
684 
685    future_value_set_mongoc_server_description_ptr (
686       &return_value,
687       mongoc_topology_select (
688          future_value_get_mongoc_topology_ptr (future_get_param (future, 0)),
689          future_value_get_mongoc_ss_optype_t (future_get_param (future, 1)),
690          future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 2)),
691          future_value_get_bson_error_ptr (future_get_param (future, 3))
692       ));
693 
694    future_resolve (future, return_value);
695 
696    return NULL;
697 }
698 
699 static void *
background_mongoc_client_get_gridfs(void * data)700 background_mongoc_client_get_gridfs (void *data)
701 {
702    future_t *future = (future_t *) data;
703    future_value_t return_value;
704 
705    return_value.type = future_value_mongoc_gridfs_ptr_type;
706 
707    future_value_set_mongoc_gridfs_ptr (
708       &return_value,
709       mongoc_client_get_gridfs (
710          future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
711          future_value_get_const_char_ptr (future_get_param (future, 1)),
712          future_value_get_const_char_ptr (future_get_param (future, 2)),
713          future_value_get_bson_error_ptr (future_get_param (future, 3))
714       ));
715 
716    future_resolve (future, return_value);
717 
718    return NULL;
719 }
720 
721 
722 
723 future_t *
future_bulk_operation_execute(mongoc_bulk_operation_ptr bulk,bson_ptr reply,bson_error_ptr error)724 future_bulk_operation_execute (
725    mongoc_bulk_operation_ptr bulk,
726    bson_ptr reply,
727    bson_error_ptr error)
728 {
729    future_t *future = future_new (future_value_uint32_t_type,
730                                   3);
731 
732    future_value_set_mongoc_bulk_operation_ptr (
733       future_get_param (future, 0), bulk);
734 
735    future_value_set_bson_ptr (
736       future_get_param (future, 1), reply);
737 
738    future_value_set_bson_error_ptr (
739       future_get_param (future, 2), error);
740 
741    future_start (future, background_mongoc_bulk_operation_execute);
742    return future;
743 }
744 
745 future_t *
future_client_command_simple(mongoc_client_ptr client,const_char_ptr db_name,const_bson_ptr command,const_mongoc_read_prefs_ptr read_prefs,bson_ptr reply,bson_error_ptr error)746 future_client_command_simple (
747    mongoc_client_ptr client,
748    const_char_ptr db_name,
749    const_bson_ptr command,
750    const_mongoc_read_prefs_ptr read_prefs,
751    bson_ptr reply,
752    bson_error_ptr error)
753 {
754    future_t *future = future_new (future_value_bool_type,
755                                   6);
756 
757    future_value_set_mongoc_client_ptr (
758       future_get_param (future, 0), client);
759 
760    future_value_set_const_char_ptr (
761       future_get_param (future, 1), db_name);
762 
763    future_value_set_const_bson_ptr (
764       future_get_param (future, 2), command);
765 
766    future_value_set_const_mongoc_read_prefs_ptr (
767       future_get_param (future, 3), read_prefs);
768 
769    future_value_set_bson_ptr (
770       future_get_param (future, 4), reply);
771 
772    future_value_set_bson_error_ptr (
773       future_get_param (future, 5), error);
774 
775    future_start (future, background_mongoc_client_command_simple);
776    return future;
777 }
778 
779 future_t *
future_client_read_command_with_opts(mongoc_client_ptr client,const_char_ptr db_name,const_bson_ptr command,const_mongoc_read_prefs_ptr read_prefs,const_bson_ptr opts,bson_ptr reply,bson_error_ptr error)780 future_client_read_command_with_opts (
781    mongoc_client_ptr client,
782    const_char_ptr db_name,
783    const_bson_ptr command,
784    const_mongoc_read_prefs_ptr read_prefs,
785    const_bson_ptr opts,
786    bson_ptr reply,
787    bson_error_ptr error)
788 {
789    future_t *future = future_new (future_value_bool_type,
790                                   7);
791 
792    future_value_set_mongoc_client_ptr (
793       future_get_param (future, 0), client);
794 
795    future_value_set_const_char_ptr (
796       future_get_param (future, 1), db_name);
797 
798    future_value_set_const_bson_ptr (
799       future_get_param (future, 2), command);
800 
801    future_value_set_const_mongoc_read_prefs_ptr (
802       future_get_param (future, 3), read_prefs);
803 
804    future_value_set_const_bson_ptr (
805       future_get_param (future, 4), opts);
806 
807    future_value_set_bson_ptr (
808       future_get_param (future, 5), reply);
809 
810    future_value_set_bson_error_ptr (
811       future_get_param (future, 6), error);
812 
813    future_start (future, background_mongoc_client_read_command_with_opts);
814    return future;
815 }
816 
817 future_t *
future_client_write_command_with_opts(mongoc_client_ptr client,const_char_ptr db_name,const_bson_ptr command,const_bson_ptr opts,bson_ptr reply,bson_error_ptr error)818 future_client_write_command_with_opts (
819    mongoc_client_ptr client,
820    const_char_ptr db_name,
821    const_bson_ptr command,
822    const_bson_ptr opts,
823    bson_ptr reply,
824    bson_error_ptr error)
825 {
826    future_t *future = future_new (future_value_bool_type,
827                                   6);
828 
829    future_value_set_mongoc_client_ptr (
830       future_get_param (future, 0), client);
831 
832    future_value_set_const_char_ptr (
833       future_get_param (future, 1), db_name);
834 
835    future_value_set_const_bson_ptr (
836       future_get_param (future, 2), command);
837 
838    future_value_set_const_bson_ptr (
839       future_get_param (future, 3), opts);
840 
841    future_value_set_bson_ptr (
842       future_get_param (future, 4), reply);
843 
844    future_value_set_bson_error_ptr (
845       future_get_param (future, 5), error);
846 
847    future_start (future, background_mongoc_client_write_command_with_opts);
848    return future;
849 }
850 
851 future_t *
future_client_read_write_command_with_opts(mongoc_client_ptr client,const_char_ptr db_name,const_bson_ptr command,const_mongoc_read_prefs_ptr read_prefs,const_bson_ptr opts,bson_ptr reply,bson_error_ptr error)852 future_client_read_write_command_with_opts (
853    mongoc_client_ptr client,
854    const_char_ptr db_name,
855    const_bson_ptr command,
856    const_mongoc_read_prefs_ptr read_prefs,
857    const_bson_ptr opts,
858    bson_ptr reply,
859    bson_error_ptr error)
860 {
861    future_t *future = future_new (future_value_bool_type,
862                                   7);
863 
864    future_value_set_mongoc_client_ptr (
865       future_get_param (future, 0), client);
866 
867    future_value_set_const_char_ptr (
868       future_get_param (future, 1), db_name);
869 
870    future_value_set_const_bson_ptr (
871       future_get_param (future, 2), command);
872 
873    future_value_set_const_mongoc_read_prefs_ptr (
874       future_get_param (future, 3), read_prefs);
875 
876    future_value_set_const_bson_ptr (
877       future_get_param (future, 4), opts);
878 
879    future_value_set_bson_ptr (
880       future_get_param (future, 5), reply);
881 
882    future_value_set_bson_error_ptr (
883       future_get_param (future, 6), error);
884 
885    future_start (future, background_mongoc_client_read_write_command_with_opts);
886    return future;
887 }
888 
889 future_t *
future_client_kill_cursor(mongoc_client_ptr client,int64_t cursor_id)890 future_client_kill_cursor (
891    mongoc_client_ptr client,
892    int64_t cursor_id)
893 {
894    future_t *future = future_new (future_value_void_type,
895                                   2);
896 
897    future_value_set_mongoc_client_ptr (
898       future_get_param (future, 0), client);
899 
900    future_value_set_int64_t (
901       future_get_param (future, 1), cursor_id);
902 
903    future_start (future, background_mongoc_client_kill_cursor);
904    return future;
905 }
906 
907 future_t *
future_collection_aggregate(mongoc_collection_ptr collection,mongoc_query_flags_t flags,const_bson_ptr pipeline,const_bson_ptr options,const_mongoc_read_prefs_ptr read_prefs)908 future_collection_aggregate (
909    mongoc_collection_ptr collection,
910    mongoc_query_flags_t flags,
911    const_bson_ptr pipeline,
912    const_bson_ptr options,
913    const_mongoc_read_prefs_ptr read_prefs)
914 {
915    future_t *future = future_new (future_value_mongoc_cursor_ptr_type,
916                                   5);
917 
918    future_value_set_mongoc_collection_ptr (
919       future_get_param (future, 0), collection);
920 
921    future_value_set_mongoc_query_flags_t (
922       future_get_param (future, 1), flags);
923 
924    future_value_set_const_bson_ptr (
925       future_get_param (future, 2), pipeline);
926 
927    future_value_set_const_bson_ptr (
928       future_get_param (future, 3), options);
929 
930    future_value_set_const_mongoc_read_prefs_ptr (
931       future_get_param (future, 4), read_prefs);
932 
933    future_start (future, background_mongoc_collection_aggregate);
934    return future;
935 }
936 
937 future_t *
future_collection_count(mongoc_collection_ptr collection,mongoc_query_flags_t flags,const_bson_ptr query,int64_t skip,int64_t limit,const_mongoc_read_prefs_ptr read_prefs,bson_error_ptr error)938 future_collection_count (
939    mongoc_collection_ptr collection,
940    mongoc_query_flags_t flags,
941    const_bson_ptr query,
942    int64_t skip,
943    int64_t limit,
944    const_mongoc_read_prefs_ptr read_prefs,
945    bson_error_ptr error)
946 {
947    future_t *future = future_new (future_value_int64_t_type,
948                                   7);
949 
950    future_value_set_mongoc_collection_ptr (
951       future_get_param (future, 0), collection);
952 
953    future_value_set_mongoc_query_flags_t (
954       future_get_param (future, 1), flags);
955 
956    future_value_set_const_bson_ptr (
957       future_get_param (future, 2), query);
958 
959    future_value_set_int64_t (
960       future_get_param (future, 3), skip);
961 
962    future_value_set_int64_t (
963       future_get_param (future, 4), limit);
964 
965    future_value_set_const_mongoc_read_prefs_ptr (
966       future_get_param (future, 5), read_prefs);
967 
968    future_value_set_bson_error_ptr (
969       future_get_param (future, 6), error);
970 
971    future_start (future, background_mongoc_collection_count);
972    return future;
973 }
974 
975 future_t *
future_collection_count_with_opts(mongoc_collection_ptr collection,mongoc_query_flags_t flags,const_bson_ptr query,int64_t skip,int64_t limit,const_bson_ptr opts,const_mongoc_read_prefs_ptr read_prefs,bson_error_ptr error)976 future_collection_count_with_opts (
977    mongoc_collection_ptr collection,
978    mongoc_query_flags_t flags,
979    const_bson_ptr query,
980    int64_t skip,
981    int64_t limit,
982    const_bson_ptr opts,
983    const_mongoc_read_prefs_ptr read_prefs,
984    bson_error_ptr error)
985 {
986    future_t *future = future_new (future_value_int64_t_type,
987                                   8);
988 
989    future_value_set_mongoc_collection_ptr (
990       future_get_param (future, 0), collection);
991 
992    future_value_set_mongoc_query_flags_t (
993       future_get_param (future, 1), flags);
994 
995    future_value_set_const_bson_ptr (
996       future_get_param (future, 2), query);
997 
998    future_value_set_int64_t (
999       future_get_param (future, 3), skip);
1000 
1001    future_value_set_int64_t (
1002       future_get_param (future, 4), limit);
1003 
1004    future_value_set_const_bson_ptr (
1005       future_get_param (future, 5), opts);
1006 
1007    future_value_set_const_mongoc_read_prefs_ptr (
1008       future_get_param (future, 6), read_prefs);
1009 
1010    future_value_set_bson_error_ptr (
1011       future_get_param (future, 7), error);
1012 
1013    future_start (future, background_mongoc_collection_count_with_opts);
1014    return future;
1015 }
1016 
1017 future_t *
future_collection_create_index_with_opts(mongoc_collection_ptr collection,const_bson_ptr keys,const_mongoc_index_opt_t opt,bson_ptr opts,bson_ptr reply,bson_error_ptr error)1018 future_collection_create_index_with_opts (
1019    mongoc_collection_ptr collection,
1020    const_bson_ptr keys,
1021    const_mongoc_index_opt_t opt,
1022    bson_ptr opts,
1023    bson_ptr reply,
1024    bson_error_ptr error)
1025 {
1026    future_t *future = future_new (future_value_bool_type,
1027                                   6);
1028 
1029    future_value_set_mongoc_collection_ptr (
1030       future_get_param (future, 0), collection);
1031 
1032    future_value_set_const_bson_ptr (
1033       future_get_param (future, 1), keys);
1034 
1035    future_value_set_const_mongoc_index_opt_t (
1036       future_get_param (future, 2), opt);
1037 
1038    future_value_set_bson_ptr (
1039       future_get_param (future, 3), opts);
1040 
1041    future_value_set_bson_ptr (
1042       future_get_param (future, 4), reply);
1043 
1044    future_value_set_bson_error_ptr (
1045       future_get_param (future, 5), error);
1046 
1047    future_start (future, background_mongoc_collection_create_index_with_opts);
1048    return future;
1049 }
1050 
1051 future_t *
future_collection_find_and_modify_with_opts(mongoc_collection_ptr collection,const_bson_ptr query,const_mongoc_find_and_modify_opts_ptr opts,bson_ptr reply,bson_error_ptr error)1052 future_collection_find_and_modify_with_opts (
1053    mongoc_collection_ptr collection,
1054    const_bson_ptr query,
1055    const_mongoc_find_and_modify_opts_ptr opts,
1056    bson_ptr reply,
1057    bson_error_ptr error)
1058 {
1059    future_t *future = future_new (future_value_bool_type,
1060                                   5);
1061 
1062    future_value_set_mongoc_collection_ptr (
1063       future_get_param (future, 0), collection);
1064 
1065    future_value_set_const_bson_ptr (
1066       future_get_param (future, 1), query);
1067 
1068    future_value_set_const_mongoc_find_and_modify_opts_ptr (
1069       future_get_param (future, 2), opts);
1070 
1071    future_value_set_bson_ptr (
1072       future_get_param (future, 3), reply);
1073 
1074    future_value_set_bson_error_ptr (
1075       future_get_param (future, 4), error);
1076 
1077    future_start (future, background_mongoc_collection_find_and_modify_with_opts);
1078    return future;
1079 }
1080 
1081 future_t *
future_collection_find_and_modify(mongoc_collection_ptr collection,const_bson_ptr query,const_bson_ptr sort,const_bson_ptr update,const_bson_ptr fields,bool _remove,bool upsert,bool _new,bson_ptr reply,bson_error_ptr error)1082 future_collection_find_and_modify (
1083    mongoc_collection_ptr collection,
1084    const_bson_ptr query,
1085    const_bson_ptr sort,
1086    const_bson_ptr update,
1087    const_bson_ptr fields,
1088    bool _remove,
1089    bool upsert,
1090    bool _new,
1091    bson_ptr reply,
1092    bson_error_ptr error)
1093 {
1094    future_t *future = future_new (future_value_bool_type,
1095                                   10);
1096 
1097    future_value_set_mongoc_collection_ptr (
1098       future_get_param (future, 0), collection);
1099 
1100    future_value_set_const_bson_ptr (
1101       future_get_param (future, 1), query);
1102 
1103    future_value_set_const_bson_ptr (
1104       future_get_param (future, 2), sort);
1105 
1106    future_value_set_const_bson_ptr (
1107       future_get_param (future, 3), update);
1108 
1109    future_value_set_const_bson_ptr (
1110       future_get_param (future, 4), fields);
1111 
1112    future_value_set_bool (
1113       future_get_param (future, 5), _remove);
1114 
1115    future_value_set_bool (
1116       future_get_param (future, 6), upsert);
1117 
1118    future_value_set_bool (
1119       future_get_param (future, 7), _new);
1120 
1121    future_value_set_bson_ptr (
1122       future_get_param (future, 8), reply);
1123 
1124    future_value_set_bson_error_ptr (
1125       future_get_param (future, 9), error);
1126 
1127    future_start (future, background_mongoc_collection_find_and_modify);
1128    return future;
1129 }
1130 
1131 future_t *
future_collection_find_indexes(mongoc_collection_ptr collection,bson_error_ptr error)1132 future_collection_find_indexes (
1133    mongoc_collection_ptr collection,
1134    bson_error_ptr error)
1135 {
1136    future_t *future = future_new (future_value_mongoc_cursor_ptr_type,
1137                                   2);
1138 
1139    future_value_set_mongoc_collection_ptr (
1140       future_get_param (future, 0), collection);
1141 
1142    future_value_set_bson_error_ptr (
1143       future_get_param (future, 1), error);
1144 
1145    future_start (future, background_mongoc_collection_find_indexes);
1146    return future;
1147 }
1148 
1149 future_t *
future_collection_stats(mongoc_collection_ptr collection,const_bson_ptr options,bson_ptr stats,bson_error_ptr error)1150 future_collection_stats (
1151    mongoc_collection_ptr collection,
1152    const_bson_ptr options,
1153    bson_ptr stats,
1154    bson_error_ptr error)
1155 {
1156    future_t *future = future_new (future_value_bool_type,
1157                                   4);
1158 
1159    future_value_set_mongoc_collection_ptr (
1160       future_get_param (future, 0), collection);
1161 
1162    future_value_set_const_bson_ptr (
1163       future_get_param (future, 1), options);
1164 
1165    future_value_set_bson_ptr (
1166       future_get_param (future, 2), stats);
1167 
1168    future_value_set_bson_error_ptr (
1169       future_get_param (future, 3), error);
1170 
1171    future_start (future, background_mongoc_collection_stats);
1172    return future;
1173 }
1174 
1175 future_t *
future_collection_insert(mongoc_collection_ptr collection,mongoc_insert_flags_t flags,const_bson_ptr document,const_mongoc_write_concern_ptr write_concern,bson_error_ptr error)1176 future_collection_insert (
1177    mongoc_collection_ptr collection,
1178    mongoc_insert_flags_t flags,
1179    const_bson_ptr document,
1180    const_mongoc_write_concern_ptr write_concern,
1181    bson_error_ptr error)
1182 {
1183    future_t *future = future_new (future_value_bool_type,
1184                                   5);
1185 
1186    future_value_set_mongoc_collection_ptr (
1187       future_get_param (future, 0), collection);
1188 
1189    future_value_set_mongoc_insert_flags_t (
1190       future_get_param (future, 1), flags);
1191 
1192    future_value_set_const_bson_ptr (
1193       future_get_param (future, 2), document);
1194 
1195    future_value_set_const_mongoc_write_concern_ptr (
1196       future_get_param (future, 3), write_concern);
1197 
1198    future_value_set_bson_error_ptr (
1199       future_get_param (future, 4), error);
1200 
1201    future_start (future, background_mongoc_collection_insert);
1202    return future;
1203 }
1204 
1205 future_t *
future_collection_read_write_command_with_opts(mongoc_collection_ptr collection,const_bson_ptr command,const_mongoc_read_prefs_ptr read_prefs,const_bson_ptr opts,bson_ptr reply,bson_error_ptr error)1206 future_collection_read_write_command_with_opts (
1207    mongoc_collection_ptr collection,
1208    const_bson_ptr command,
1209    const_mongoc_read_prefs_ptr read_prefs,
1210    const_bson_ptr opts,
1211    bson_ptr reply,
1212    bson_error_ptr error)
1213 {
1214    future_t *future = future_new (future_value_bool_type,
1215                                   6);
1216 
1217    future_value_set_mongoc_collection_ptr (
1218       future_get_param (future, 0), collection);
1219 
1220    future_value_set_const_bson_ptr (
1221       future_get_param (future, 1), command);
1222 
1223    future_value_set_const_mongoc_read_prefs_ptr (
1224       future_get_param (future, 2), read_prefs);
1225 
1226    future_value_set_const_bson_ptr (
1227       future_get_param (future, 3), opts);
1228 
1229    future_value_set_bson_ptr (
1230       future_get_param (future, 4), reply);
1231 
1232    future_value_set_bson_error_ptr (
1233       future_get_param (future, 5), error);
1234 
1235    future_start (future, background_mongoc_collection_read_write_command_with_opts);
1236    return future;
1237 }
1238 
1239 future_t *
future_collection_insert_bulk(mongoc_collection_ptr collection,mongoc_insert_flags_t flags,const_bson_ptr_ptr documents,uint32_t n_documents,const_mongoc_write_concern_ptr write_concern,bson_error_ptr error)1240 future_collection_insert_bulk (
1241    mongoc_collection_ptr collection,
1242    mongoc_insert_flags_t flags,
1243    const_bson_ptr_ptr documents,
1244    uint32_t n_documents,
1245    const_mongoc_write_concern_ptr write_concern,
1246    bson_error_ptr error)
1247 {
1248    future_t *future = future_new (future_value_bool_type,
1249                                   6);
1250 
1251    future_value_set_mongoc_collection_ptr (
1252       future_get_param (future, 0), collection);
1253 
1254    future_value_set_mongoc_insert_flags_t (
1255       future_get_param (future, 1), flags);
1256 
1257    future_value_set_const_bson_ptr_ptr (
1258       future_get_param (future, 2), documents);
1259 
1260    future_value_set_uint32_t (
1261       future_get_param (future, 3), n_documents);
1262 
1263    future_value_set_const_mongoc_write_concern_ptr (
1264       future_get_param (future, 4), write_concern);
1265 
1266    future_value_set_bson_error_ptr (
1267       future_get_param (future, 5), error);
1268 
1269    future_start (future, background_mongoc_collection_insert_bulk);
1270    return future;
1271 }
1272 
1273 future_t *
future_cursor_destroy(mongoc_cursor_ptr cursor)1274 future_cursor_destroy (
1275    mongoc_cursor_ptr cursor)
1276 {
1277    future_t *future = future_new (future_value_void_type,
1278                                   1);
1279 
1280    future_value_set_mongoc_cursor_ptr (
1281       future_get_param (future, 0), cursor);
1282 
1283    future_start (future, background_mongoc_cursor_destroy);
1284    return future;
1285 }
1286 
1287 future_t *
future_cursor_next(mongoc_cursor_ptr cursor,const_bson_ptr_ptr doc)1288 future_cursor_next (
1289    mongoc_cursor_ptr cursor,
1290    const_bson_ptr_ptr doc)
1291 {
1292    future_t *future = future_new (future_value_bool_type,
1293                                   2);
1294 
1295    future_value_set_mongoc_cursor_ptr (
1296       future_get_param (future, 0), cursor);
1297 
1298    future_value_set_const_bson_ptr_ptr (
1299       future_get_param (future, 1), doc);
1300 
1301    future_start (future, background_mongoc_cursor_next);
1302    return future;
1303 }
1304 
1305 future_t *
future_client_get_database_names(mongoc_client_ptr client,bson_error_ptr error)1306 future_client_get_database_names (
1307    mongoc_client_ptr client,
1308    bson_error_ptr error)
1309 {
1310    future_t *future = future_new (future_value_char_ptr_ptr_type,
1311                                   2);
1312 
1313    future_value_set_mongoc_client_ptr (
1314       future_get_param (future, 0), client);
1315 
1316    future_value_set_bson_error_ptr (
1317       future_get_param (future, 1), error);
1318 
1319    future_start (future, background_mongoc_client_get_database_names);
1320    return future;
1321 }
1322 
1323 future_t *
future_client_select_server(mongoc_client_ptr client,bool for_writes,const_mongoc_read_prefs_ptr prefs,bson_error_ptr error)1324 future_client_select_server (
1325    mongoc_client_ptr client,
1326    bool for_writes,
1327    const_mongoc_read_prefs_ptr prefs,
1328    bson_error_ptr error)
1329 {
1330    future_t *future = future_new (future_value_mongoc_server_description_ptr_type,
1331                                   4);
1332 
1333    future_value_set_mongoc_client_ptr (
1334       future_get_param (future, 0), client);
1335 
1336    future_value_set_bool (
1337       future_get_param (future, 1), for_writes);
1338 
1339    future_value_set_const_mongoc_read_prefs_ptr (
1340       future_get_param (future, 2), prefs);
1341 
1342    future_value_set_bson_error_ptr (
1343       future_get_param (future, 3), error);
1344 
1345    future_start (future, background_mongoc_client_select_server);
1346    return future;
1347 }
1348 
1349 future_t *
future_database_command_simple(mongoc_database_ptr database,bson_ptr command,const_mongoc_read_prefs_ptr read_prefs,bson_ptr reply,bson_error_ptr error)1350 future_database_command_simple (
1351    mongoc_database_ptr database,
1352    bson_ptr command,
1353    const_mongoc_read_prefs_ptr read_prefs,
1354    bson_ptr reply,
1355    bson_error_ptr error)
1356 {
1357    future_t *future = future_new (future_value_bool_type,
1358                                   5);
1359 
1360    future_value_set_mongoc_database_ptr (
1361       future_get_param (future, 0), database);
1362 
1363    future_value_set_bson_ptr (
1364       future_get_param (future, 1), command);
1365 
1366    future_value_set_const_mongoc_read_prefs_ptr (
1367       future_get_param (future, 2), read_prefs);
1368 
1369    future_value_set_bson_ptr (
1370       future_get_param (future, 3), reply);
1371 
1372    future_value_set_bson_error_ptr (
1373       future_get_param (future, 4), error);
1374 
1375    future_start (future, background_mongoc_database_command_simple);
1376    return future;
1377 }
1378 
1379 future_t *
future_database_get_collection_names(mongoc_database_ptr database,bson_error_ptr error)1380 future_database_get_collection_names (
1381    mongoc_database_ptr database,
1382    bson_error_ptr error)
1383 {
1384    future_t *future = future_new (future_value_char_ptr_ptr_type,
1385                                   2);
1386 
1387    future_value_set_mongoc_database_ptr (
1388       future_get_param (future, 0), database);
1389 
1390    future_value_set_bson_error_ptr (
1391       future_get_param (future, 1), error);
1392 
1393    future_start (future, background_mongoc_database_get_collection_names);
1394    return future;
1395 }
1396 
1397 future_t *
future_gridfs_file_readv(mongoc_gridfs_file_ptr file,mongoc_iovec_ptr iov,size_t iovcnt,size_t min_bytes,uint32_t timeout_msec)1398 future_gridfs_file_readv (
1399    mongoc_gridfs_file_ptr file,
1400    mongoc_iovec_ptr iov,
1401    size_t iovcnt,
1402    size_t min_bytes,
1403    uint32_t timeout_msec)
1404 {
1405    future_t *future = future_new (future_value_ssize_t_type,
1406                                   5);
1407 
1408    future_value_set_mongoc_gridfs_file_ptr (
1409       future_get_param (future, 0), file);
1410 
1411    future_value_set_mongoc_iovec_ptr (
1412       future_get_param (future, 1), iov);
1413 
1414    future_value_set_size_t (
1415       future_get_param (future, 2), iovcnt);
1416 
1417    future_value_set_size_t (
1418       future_get_param (future, 3), min_bytes);
1419 
1420    future_value_set_uint32_t (
1421       future_get_param (future, 4), timeout_msec);
1422 
1423    future_start (future, background_mongoc_gridfs_file_readv);
1424    return future;
1425 }
1426 
1427 future_t *
future_gridfs_find_one(mongoc_gridfs_ptr gridfs,const_bson_ptr query,bson_error_ptr error)1428 future_gridfs_find_one (
1429    mongoc_gridfs_ptr gridfs,
1430    const_bson_ptr query,
1431    bson_error_ptr error)
1432 {
1433    future_t *future = future_new (future_value_mongoc_gridfs_file_ptr_type,
1434                                   3);
1435 
1436    future_value_set_mongoc_gridfs_ptr (
1437       future_get_param (future, 0), gridfs);
1438 
1439    future_value_set_const_bson_ptr (
1440       future_get_param (future, 1), query);
1441 
1442    future_value_set_bson_error_ptr (
1443       future_get_param (future, 2), error);
1444 
1445    future_start (future, background_mongoc_gridfs_find_one);
1446    return future;
1447 }
1448 
1449 future_t *
future_gridfs_file_remove(mongoc_gridfs_file_ptr file,bson_error_ptr error)1450 future_gridfs_file_remove (
1451    mongoc_gridfs_file_ptr file,
1452    bson_error_ptr error)
1453 {
1454    future_t *future = future_new (future_value_bool_type,
1455                                   2);
1456 
1457    future_value_set_mongoc_gridfs_file_ptr (
1458       future_get_param (future, 0), file);
1459 
1460    future_value_set_bson_error_ptr (
1461       future_get_param (future, 1), error);
1462 
1463    future_start (future, background_mongoc_gridfs_file_remove);
1464    return future;
1465 }
1466 
1467 future_t *
future_gridfs_file_seek(mongoc_gridfs_file_ptr file,int64_t delta,int whence)1468 future_gridfs_file_seek (
1469    mongoc_gridfs_file_ptr file,
1470    int64_t delta,
1471    int whence)
1472 {
1473    future_t *future = future_new (future_value_int_type,
1474                                   3);
1475 
1476    future_value_set_mongoc_gridfs_file_ptr (
1477       future_get_param (future, 0), file);
1478 
1479    future_value_set_int64_t (
1480       future_get_param (future, 1), delta);
1481 
1482    future_value_set_int (
1483       future_get_param (future, 2), whence);
1484 
1485    future_start (future, background_mongoc_gridfs_file_seek);
1486    return future;
1487 }
1488 
1489 future_t *
future_gridfs_file_writev(mongoc_gridfs_file_ptr file,const_mongoc_iovec_ptr iov,size_t iovcnt,uint32_t timeout_msec)1490 future_gridfs_file_writev (
1491    mongoc_gridfs_file_ptr file,
1492    const_mongoc_iovec_ptr iov,
1493    size_t iovcnt,
1494    uint32_t timeout_msec)
1495 {
1496    future_t *future = future_new (future_value_ssize_t_type,
1497                                   4);
1498 
1499    future_value_set_mongoc_gridfs_file_ptr (
1500       future_get_param (future, 0), file);
1501 
1502    future_value_set_const_mongoc_iovec_ptr (
1503       future_get_param (future, 1), iov);
1504 
1505    future_value_set_size_t (
1506       future_get_param (future, 2), iovcnt);
1507 
1508    future_value_set_uint32_t (
1509       future_get_param (future, 3), timeout_msec);
1510 
1511    future_start (future, background_mongoc_gridfs_file_writev);
1512    return future;
1513 }
1514 
1515 future_t *
future_gridfs_find_one_with_opts(mongoc_gridfs_ptr gridfs,const_bson_ptr filter,const_bson_ptr opts,bson_error_ptr error)1516 future_gridfs_find_one_with_opts (
1517    mongoc_gridfs_ptr gridfs,
1518    const_bson_ptr filter,
1519    const_bson_ptr opts,
1520    bson_error_ptr error)
1521 {
1522    future_t *future = future_new (future_value_mongoc_gridfs_file_ptr_type,
1523                                   4);
1524 
1525    future_value_set_mongoc_gridfs_ptr (
1526       future_get_param (future, 0), gridfs);
1527 
1528    future_value_set_const_bson_ptr (
1529       future_get_param (future, 1), filter);
1530 
1531    future_value_set_const_bson_ptr (
1532       future_get_param (future, 2), opts);
1533 
1534    future_value_set_bson_error_ptr (
1535       future_get_param (future, 3), error);
1536 
1537    future_start (future, background_mongoc_gridfs_find_one_with_opts);
1538    return future;
1539 }
1540 
1541 future_t *
future_topology_select(mongoc_topology_ptr topology,mongoc_ss_optype_t optype,const_mongoc_read_prefs_ptr read_prefs,bson_error_ptr error)1542 future_topology_select (
1543    mongoc_topology_ptr topology,
1544    mongoc_ss_optype_t optype,
1545    const_mongoc_read_prefs_ptr read_prefs,
1546    bson_error_ptr error)
1547 {
1548    future_t *future = future_new (future_value_mongoc_server_description_ptr_type,
1549                                   4);
1550 
1551    future_value_set_mongoc_topology_ptr (
1552       future_get_param (future, 0), topology);
1553 
1554    future_value_set_mongoc_ss_optype_t (
1555       future_get_param (future, 1), optype);
1556 
1557    future_value_set_const_mongoc_read_prefs_ptr (
1558       future_get_param (future, 2), read_prefs);
1559 
1560    future_value_set_bson_error_ptr (
1561       future_get_param (future, 3), error);
1562 
1563    future_start (future, background_mongoc_topology_select);
1564    return future;
1565 }
1566 
1567 future_t *
future_client_get_gridfs(mongoc_client_ptr client,const_char_ptr db,const_char_ptr prefix,bson_error_ptr error)1568 future_client_get_gridfs (
1569    mongoc_client_ptr client,
1570    const_char_ptr db,
1571    const_char_ptr prefix,
1572    bson_error_ptr error)
1573 {
1574    future_t *future = future_new (future_value_mongoc_gridfs_ptr_type,
1575                                   4);
1576 
1577    future_value_set_mongoc_client_ptr (
1578       future_get_param (future, 0), client);
1579 
1580    future_value_set_const_char_ptr (
1581       future_get_param (future, 1), db);
1582 
1583    future_value_set_const_char_ptr (
1584       future_get_param (future, 2), prefix);
1585 
1586    future_value_set_bson_error_ptr (
1587       future_get_param (future, 3), error);
1588 
1589    future_start (future, background_mongoc_client_get_gridfs);
1590    return future;
1591 }
1592 
1593