summaryrefslogtreecommitdiff
path: root/src/gegl.rs
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2016-08-09 22:25:34 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2016-08-09 22:25:34 -0400
commite8ed9ace0b7e2aed2bd0c6b99a6787da411ad9cb (patch)
tree1a185a6717d99f7712ad60ff5402dd569d6b9da5 /src/gegl.rs
parent996e089f75690045ac1e9de78e8f6f91ba25cf45 (diff)
Add list_operations().
Diffstat (limited to 'src/gegl.rs')
-rw-r--r--src/gegl.rs28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/gegl.rs b/src/gegl.rs
index b03fca1..0ffdf9c 100644
--- a/src/gegl.rs
+++ b/src/gegl.rs
@@ -3,6 +3,7 @@ extern crate libc;
use gegl_ffi as ffi;
use std::ptr;
use std::ffi::CString;
+use std::ffi::CStr;
pub struct GeglContext {
_private: ()
@@ -46,15 +47,36 @@ impl Drop for GeglNode {
}
}
+pub fn list_operations() -> Vec<String> {
+ let mut num_operations: usize = 0;
+ let mut result = vec!();
+ unsafe {
+ let operations =
+ ffi::gegl_list_operations(&mut num_operations as *mut _);
+ for i in 0..(num_operations as isize) {
+ result.push(CStr::from_ptr(*operations.offset(i))
+ .to_string_lossy().to_string());
+ }
+ ffi::g_free(operations as *mut libc::c_void);
+ }
+ result
+}
+
#[cfg(test)]
mod tests {
use super::*;
use gegl_ffi as ffi;
#[test]
- fn can_create_nodes() {
+ fn implements_all_operations() {
let context = GeglContext::new();
- let node = context.new_node();
- let node2 = context.new_node();
+ assert_eq!(Vec::<String>::new(), list_operations());
}
+
+ // #[test]
+ // fn can_create_nodes() {
+ // let context = GeglContext::new();
+ // context.new_node();
+ // context.new_node();
+ // }
}