summaryrefslogtreecommitdiff
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
parent996e089f75690045ac1e9de78e8f6f91ba25cf45 (diff)
Add list_operations().
-rw-r--r--src/gegl.rs28
-rw-r--r--src/gegl_ffi.rs8
2 files changed, 32 insertions, 4 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();
+ // }
}
diff --git a/src/gegl_ffi.rs b/src/gegl_ffi.rs
index 093fc3b..a477603 100644
--- a/src/gegl_ffi.rs
+++ b/src/gegl_ffi.rs
@@ -25,10 +25,16 @@ extern {
pub fn gegl_node_link(source: *mut CGeglNode,
sink: *mut CGeglNode);
pub fn gegl_node_process(node: *mut CGeglNode);
- pub fn g_object_unref(object: *mut libc::c_void);
pub fn gegl_exit();
pub fn gegl_buffer_new(extent: *mut libc::c_void, format: *mut libc::c_void)
-> *mut GeglBuffer;
pub fn gegl_buffer_get_extent(buffer: *const libc::c_void) ->
*const GeglRectangle;
+
+
+ pub fn g_object_unref(object: *mut libc::c_void);
+ pub fn g_free(object: *mut libc::c_void);
+
+ pub fn gegl_list_operations(num_operations: *mut usize)
+ -> *mut *const libc::c_char;
}