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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
// Generated by gir (https://github.com/gtk-rs/gir @ d7c0763cacbc)
// from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)
// DO NOT EDIT

use crate::{ffi, Config, Node, Path, Rectangle, SerializeFlag, SplitStrategy, Stats};
use glib::translate::*;

//#[doc(alias = "gegl_apply_op")]
//pub fn apply_op(buffer: &Buffer, operation_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
//    unsafe { TODO: call ffi:gegl_apply_op() }
//}

//#[doc(alias = "gegl_apply_op_valist")]
//pub fn apply_op_valist(buffer: &Buffer, operation_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
//    unsafe { TODO: call ffi:gegl_apply_op_valist() }
//}

//#[doc(alias = "gegl_calloc")]
//pub fn calloc(size: usize, n_memb: i32) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_calloc() }
//}

/// Disable OpenCL
#[doc(alias = "gegl_cl_disable")]
pub fn cl_disable() {
    unsafe {
        ffi::gegl_cl_disable();
    }
}

/// Initialize and enable OpenCL, calling this function again
/// will re-enable OpenCL if it has been disabled.
///
/// # Returns
///
/// True if OpenCL was initialized
#[doc(alias = "gegl_cl_init")]
pub fn cl_init() -> Result<(), glib::Error> {
    unsafe {
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::gegl_cl_init(&mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(())
        } else {
            Err(from_glib_full(error))
        }
    }
}

/// Check if OpenCL is enabled.
///
/// # Returns
///
/// True if OpenCL is initialized and enabled
#[doc(alias = "gegl_cl_is_accelerated")]
pub fn cl_is_accelerated() -> bool {
    unsafe { from_glib(ffi::gegl_cl_is_accelerated()) }
}

/// Returns a GeglConfig object with properties that can be manipulated to control
/// GEGLs behavior.
///
/// # Returns
///
/// a [`Config`][crate::Config]
#[doc(alias = "gegl_config")]
pub fn config() -> Config {
    unsafe { from_glib_none(ffi::gegl_config()) }
}

/// Create a node chain from an unparsed commandline string.
/// ## `ops`
/// an argv style, NULL terminated array of arguments
/// ## `op_start`
/// node to pass in as input of chain
/// ## `op_end`
/// node to get processed data
/// ## `time`
/// the time to use for interpolatino of keyframed values
/// ## `rel_dim`
/// relative dimension to scale rel suffixed values by
/// ## `path_root`
/// path in filesystem to use as relative root
#[doc(alias = "gegl_create_chain")]
pub fn create_chain(
    ops: &str,
    op_start: &Node,
    op_end: &Node,
    time: f64,
    rel_dim: i32,
    path_root: &str,
) -> Result<(), glib::Error> {
    unsafe {
        let mut error = std::ptr::null_mut();
        let _ = ffi::gegl_create_chain(
            ops.to_glib_none().0,
            op_start.to_glib_none().0,
            op_end.to_glib_none().0,
            time,
            rel_dim,
            path_root.to_glib_none().0,
            &mut error,
        );
        if error.is_null() {
            Ok(())
        } else {
            Err(from_glib_full(error))
        }
    }
}

#[doc(alias = "gegl_exit")]
pub fn exit() {
    unsafe {
        ffi::gegl_exit();
    }
}

//#[doc(alias = "gegl_filter_op")]
//pub fn filter_op(source_buffer: &Buffer, operation_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option<Buffer> {
//    unsafe { TODO: call ffi:gegl_filter_op() }
//}

//#[doc(alias = "gegl_filter_op_valist")]
//pub fn filter_op_valist(source_buffer: &Buffer, operation_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option<Buffer> {
//    unsafe { TODO: call ffi:gegl_filter_op_valist() }
//}

/// Returns a value sutable to pass to the GeglBuffer constructor
/// or any other property that expects a Babl format.
/// ## `format_name`
/// A Babl format name, e.g. "RGBA float"
///
/// # Returns
///
/// the format pointer
#[doc(alias = "gegl_format")]
pub fn format(format_name: &str) -> Option<glib::Value> {
    unsafe { from_glib_full(ffi::gegl_format(format_name.to_glib_none().0)) }
}

/// ## `format`
/// A Babl pointer
///
/// # Returns
///
/// the format name
#[doc(alias = "gegl_format_get_name")]
pub fn format_get_name(format: &mut glib::Value) -> Option<glib::GString> {
    unsafe { from_glib_none(ffi::gegl_format_get_name(format.to_glib_none_mut().0)) }
}

//#[doc(alias = "gegl_free")]
//pub fn free(mem: /*Unimplemented*/Option<Basic: Pointer>) {
//    unsafe { TODO: call ffi:gegl_free() }
//}

#[doc(alias = "gegl_get_version")]
#[doc(alias = "get_version")]
pub fn version() -> (i32, i32, i32) {
    unsafe {
        let mut major = std::mem::MaybeUninit::uninit();
        let mut minor = std::mem::MaybeUninit::uninit();
        let mut micro = std::mem::MaybeUninit::uninit();
        ffi::gegl_get_version(major.as_mut_ptr(), minor.as_mut_ptr(), micro.as_mut_ptr());
        (
            major.assume_init(),
            minor.assume_init(),
            micro.assume_init(),
        )
    }
}

/// Dump the bounds and format of each node in the graph to stdout.
/// ## `node`
/// The final node of the graph
#[doc(alias = "gegl_graph_dump_outputs")]
pub fn graph_dump_outputs(node: &Node) {
    unsafe {
        ffi::gegl_graph_dump_outputs(node.to_glib_none().0);
    }
}

/// Dump the region that will be rendered for each node to fulfill
/// the request.
/// ## `node`
/// The final node of the graph
/// ## `roi`
/// The request rectangle
#[doc(alias = "gegl_graph_dump_request")]
pub fn graph_dump_request(node: &Node, roi: &Rectangle) {
    unsafe {
        ffi::gegl_graph_dump_request(node.to_glib_none().0, roi.to_glib_none().0);
    }
}

/// ## `operation_type`
/// the name of the operation
///
/// # Returns
///
/// A boolean telling whether the operation is present or not. This
/// also returns true for any compat-name registered by operations.
#[doc(alias = "gegl_has_operation")]
pub fn has_operation(operation_type: &str) -> bool {
    unsafe { from_glib(ffi::gegl_has_operation(operation_type.to_glib_none().0)) }
}

//#[doc(alias = "gegl_init")]
//pub fn init(argv: /*Unimplemented*/Vec<glib::GString>) {
//    unsafe { TODO: call ffi:gegl_init() }
//}

#[doc(alias = "gegl_is_main_thread")]
pub fn is_main_thread() -> bool {
    unsafe { from_glib(ffi::gegl_is_main_thread()) }
}

///
/// # Returns
///
/// An
/// alphabetically sorted array of available operation names. This excludes any
/// compat-name registered by operations. The list should be freed with g_free
/// after use.
/// ---
/// gchar **operations;
/// guint n_operations;
/// gint i;
///
/// operations = gegl_list_operations (&n_operations);
/// g_print ("Available operations:\n");
/// for (i=0; i < n_operations; i++)
///  {
///  g_print ("\t`s`\n", operations[i]);
///  }
/// g_free (operations);
#[doc(alias = "gegl_list_operations")]
pub fn list_operations() -> Vec<glib::GString> {
    unsafe {
        let mut n_operations_p = std::mem::MaybeUninit::uninit();
        let ret = FromGlibContainer::from_glib_container_num(
            ffi::gegl_list_operations(n_operations_p.as_mut_ptr()),
            n_operations_p.assume_init() as _,
        );
        ret
    }
}

/// Load all gegl modules found in the given directory.
/// ## `path`
/// the directory to load modules from
#[doc(alias = "gegl_load_module_directory")]
pub fn load_module_directory(path: &str) {
    unsafe {
        ffi::gegl_load_module_directory(path.to_glib_none().0);
    }
}

//#[doc(alias = "gegl_malloc")]
//pub fn malloc(n_bytes: usize) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_malloc() }
//}

//#[doc(alias = "gegl_memeq_zero")]
//pub fn memeq_zero(ptr: /*Unimplemented*/Option<Basic: Pointer>, size: usize) -> bool {
//    unsafe { TODO: call ffi:gegl_memeq_zero() }
//}

//#[doc(alias = "gegl_memset_pattern")]
//pub fn memset_pattern(dst_ptr: /*Unimplemented*/Option<Basic: Pointer>, src_ptr: /*Unimplemented*/Option<Basic: Pointer>, pattern_size: i32, count: i32) {
//    unsafe { TODO: call ffi:gegl_memset_pattern() }
//}

/// Distributes the execution of a function across multiple threads,
/// by calling it with a different index on each thread.
/// ## `max_n`
/// the maximal number of threads to use
/// ## `func`
/// the function to call
#[doc(alias = "gegl_parallel_distribute")]
pub fn parallel_distribute<P: FnMut(i32, i32)>(max_n: i32, func: P) {
    let func_data: P = func;
    unsafe extern "C" fn func_func<P: FnMut(i32, i32)>(
        i: libc::c_int,
        n: libc::c_int,
        user_data: glib::ffi::gpointer,
    ) {
        let callback = user_data as *mut P;
        (*callback)(i, n)
    }
    let func = Some(func_func::<P> as _);
    let super_callback0: &P = &func_data;
    unsafe {
        ffi::gegl_parallel_distribute(max_n, func, super_callback0 as *const _ as *mut _);
    }
}

/// Distributes the processing of a planar data-structure across
/// multiple threads, by calling the given function with different
/// sub-areas on different threads.
/// ## `area`
/// the area to process
/// ## `thread_cost`
/// the cost of using each additional thread, relative
///  to the cost of processing a single data element
/// ## `split_strategy`
/// the strategy to use for dividing the area
/// ## `func`
/// the function to call
#[doc(alias = "gegl_parallel_distribute_area")]
pub fn parallel_distribute_area<P: FnMut(&Rectangle)>(
    area: &Rectangle,
    thread_cost: f64,
    split_strategy: SplitStrategy,
    func: P,
) {
    let func_data: P = func;
    unsafe extern "C" fn func_func<P: FnMut(&Rectangle)>(
        area: *const ffi::GeglRectangle,
        user_data: glib::ffi::gpointer,
    ) {
        let area = from_glib_borrow(area);
        let callback = user_data as *mut P;
        (*callback)(&area)
    }
    let func = Some(func_func::<P> as _);
    let super_callback0: &P = &func_data;
    unsafe {
        ffi::gegl_parallel_distribute_area(
            area.to_glib_none().0,
            thread_cost,
            split_strategy.into_glib(),
            func,
            super_callback0 as *const _ as *mut _,
        );
    }
}

/// Distributes the processing of a linear data-structure across
/// multiple threads, by calling the given function with different
/// sub-ranges on different threads.
/// ## `size`
/// the total size of the data
/// ## `thread_cost`
/// the cost of using each additional thread, relative
///  to the cost of processing a single data element
/// ## `func`
/// the function to call
#[doc(alias = "gegl_parallel_distribute_range")]
pub fn parallel_distribute_range<P: FnMut(usize, usize)>(size: usize, thread_cost: f64, func: P) {
    let func_data: P = func;
    unsafe extern "C" fn func_func<P: FnMut(usize, usize)>(
        offset: libc::size_t,
        size: libc::size_t,
        user_data: glib::ffi::gpointer,
    ) {
        let callback = user_data as *mut P;
        (*callback)(offset, size)
    }
    let func = Some(func_func::<P> as _);
    let super_callback0: &P = &func_data;
    unsafe {
        ffi::gegl_parallel_distribute_range(
            size,
            thread_cost,
            func,
            super_callback0 as *const _ as *mut _,
        );
    }
}

/// Creates a new [`glib::ParamSpec`][crate::glib::ParamSpec] instance specifying a [`AudioFragment`][crate::AudioFragment] property.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_audio_fragment")]
pub fn param_spec_audio_fragment(
    name: &str,
    nick: &str,
    blurb: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_audio_fragment(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

/// Creates a new [`glib::ParamSpec`][crate::glib::ParamSpec] instance specifying a [`Color`][crate::Color] property.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `default_color_string`
/// the default value for the property specified
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_color_from_string")]
pub fn param_spec_color_from_string(
    name: &str,
    nick: &str,
    blurb: &str,
    default_color_string: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_color_from_string(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            default_color_string.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

//#[doc(alias = "gegl_param_spec_curve")]
//pub fn param_spec_curve(name: &str, nick: &str, blurb: &str, default_curve: /*Ignored*/&Curve, flags: glib::ParamFlags) -> Option<glib::ParamSpec> {
//    unsafe { TODO: call ffi:gegl_param_spec_curve() }
//}

/// Creates a new `GeglParamSpecDouble` instance.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `minimum`
/// minimum value for the property specified
/// ## `maximum`
/// maximum value for the property specified
/// ## `default_value`
/// default value for the property specified
/// ## `ui_minimum`
/// minimum value a user should be allowed to input
/// ## `ui_maximum`
/// maximum value a user should be allowed to input
/// ## `ui_gamma`
/// the gamma that should be used when adjusting the value
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_double")]
pub fn param_spec_double(
    name: &str,
    nick: &str,
    blurb: &str,
    minimum: f64,
    maximum: f64,
    default_value: f64,
    ui_minimum: f64,
    ui_maximum: f64,
    ui_gamma: f64,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_double(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            minimum,
            maximum,
            default_value,
            ui_minimum,
            ui_maximum,
            ui_gamma,
            flags.into_glib(),
        ))
    }
}

/// Creates a new `GeglParamSpecEnum` instance.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `enum_type`
/// the enum type to get valid values from
/// ## `default_value`
/// default value for the property specified
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_enum")]
pub fn param_spec_enum(
    name: &str,
    nick: &str,
    blurb: &str,
    enum_type: glib::types::Type,
    default_value: i32,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_enum(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            enum_type.into_glib(),
            default_value,
            flags.into_glib(),
        ))
    }
}

/// Creates a new `GeglParamSpecFilePath` instance.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `no_validate`
/// true if the string should be validated with g_utf8_validate
/// ## `null_ok`
/// true if the string can be NULL
/// ## `default_value`
/// default value for the property specified
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_file_path")]
pub fn param_spec_file_path(
    name: &str,
    nick: &str,
    blurb: &str,
    no_validate: bool,
    null_ok: bool,
    default_value: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_file_path(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            no_validate.into_glib(),
            null_ok.into_glib(),
            default_value.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

/// Creates a new `GeglParamSpecFormat` instance specifying a Babl format.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_format")]
pub fn param_spec_format(
    name: &str,
    nick: &str,
    blurb: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_format(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

/// Creates a new `GeglParamSpecInt` instance.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `minimum`
/// minimum value for the property specified
/// ## `maximum`
/// maximum value for the property specified
/// ## `default_value`
/// default value for the property specified
/// ## `ui_minimum`
/// minimum value a user should be allowed to input
/// ## `ui_maximum`
/// maximum value a user should be allowed to input
/// ## `ui_gamma`
/// the gamma that should be used when adjusting the value
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_int")]
pub fn param_spec_int(
    name: &str,
    nick: &str,
    blurb: &str,
    minimum: i32,
    maximum: i32,
    default_value: i32,
    ui_minimum: i32,
    ui_maximum: i32,
    ui_gamma: f64,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_int(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            minimum,
            maximum,
            default_value,
            ui_minimum,
            ui_maximum,
            ui_gamma,
            flags.into_glib(),
        ))
    }
}

/// Creates a new [`glib::ParamSpec`][crate::glib::ParamSpec] instance specifying a [`Path`][crate::Path] property.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `default_path`
/// the default value for the property specified
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_path")]
pub fn param_spec_path(
    name: &str,
    nick: &str,
    blurb: &str,
    default_path: &Path,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_path(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            default_path.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

/// Creates a new `GeglParamSpecSeed` instance specifying an integer random seed.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_seed")]
pub fn param_spec_seed(
    name: &str,
    nick: &str,
    blurb: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_seed(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

/// Creates a new `GeglParamSpecString` instance.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `no_validate`
/// true if the string should be validated with g_utf8_validate
/// ## `null_ok`
/// true if the string can be NULL
/// ## `default_value`
/// default value for the property specified
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_string")]
pub fn param_spec_string(
    name: &str,
    nick: &str,
    blurb: &str,
    no_validate: bool,
    null_ok: bool,
    default_value: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_string(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            no_validate.into_glib(),
            null_ok.into_glib(),
            default_value.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

/// Creates a new `GeglParamSpecUri` instance.
/// ## `name`
/// canonical name of the property specified
/// ## `nick`
/// nick name for the property specified
/// ## `blurb`
/// description of the property specified
/// ## `no_validate`
/// true if the string should be validated with g_utf8_validate
/// ## `null_ok`
/// true if the string can be NULL
/// ## `default_value`
/// default value for the property specified
/// ## `flags`
/// flags for the property specified
///
/// # Returns
///
/// a newly created parameter specification
#[doc(alias = "gegl_param_spec_uri")]
pub fn param_spec_uri(
    name: &str,
    nick: &str,
    blurb: &str,
    no_validate: bool,
    null_ok: bool,
    default_value: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_uri(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            no_validate.into_glib(),
            null_ok.into_glib(),
            default_value.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

//#[doc(alias = "gegl_render_op")]
//pub fn render_op(source_buffer: &Buffer, target_buffer: &Buffer, operation_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
//    unsafe { TODO: call ffi:gegl_render_op() }
//}

//#[doc(alias = "gegl_render_op_valist")]
//pub fn render_op_valist(source_buffer: &Buffer, target_buffer: &Buffer, operation_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
//    unsafe { TODO: call ffi:gegl_render_op_valist() }
//}

/// Resets the cumulative data gathered by the [`Stats`][crate::Stats] object returned
/// by [`stats()`][crate::stats()].
#[doc(alias = "gegl_reset_stats")]
pub fn reset_stats() {
    unsafe {
        ffi::gegl_reset_stats();
    }
}

//#[doc(alias = "gegl_scratch_alloc")]
//pub fn scratch_alloc(size: usize) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_scratch_alloc() }
//}

//#[doc(alias = "gegl_scratch_alloc0")]
//pub fn scratch_alloc0(size: usize) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_scratch_alloc0() }
//}

//#[doc(alias = "gegl_scratch_free")]
//pub fn scratch_free(ptr: /*Unimplemented*/Option<Basic: Pointer>) {
//    unsafe { TODO: call ffi:gegl_scratch_free() }
//}

/// ## `start`
/// first node in chain to serialize
/// ## `end`
/// last node in chain to serialize
/// ## `basepath`
/// top-level absolute path to turn into relative root
/// ## `serialize_flags`
/// anded together combination of:
/// GEGL_SERIALIZE_TRIM_DEFAULTS, GEGL_SERIALIZE_VERSION, GEGL_SERIALIZE_INDENT.
#[doc(alias = "gegl_serialize")]
pub fn serialize(
    start: &Node,
    end: &Node,
    basepath: &str,
    serialize_flags: SerializeFlag,
) -> Option<glib::GString> {
    unsafe {
        from_glib_full(ffi::gegl_serialize(
            start.to_glib_none().0,
            end.to_glib_none().0,
            basepath.to_glib_none().0,
            serialize_flags.into_glib(),
        ))
    }
}

/// Returns a GeglStats object with properties that can be read to monitor
/// GEGL statistics.
///
/// # Returns
///
/// a [`Stats`][crate::Stats]
#[doc(alias = "gegl_stats")]
pub fn stats() -> Option<Stats> {
    unsafe { from_glib_none(ffi::gegl_stats()) }
}

//#[doc(alias = "gegl_try_malloc")]
//pub fn try_malloc(n_bytes: usize) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_try_malloc() }
//}