Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
octh_examples/src/lib.rs /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (20 sloc)
973 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![allow(non_snake_case)] | |
| #![allow(unused_variables)] | |
| extern crate octh; | |
| // https://thefullsnack.com/en/string-ffi-rust.html | |
| use std::ffi::CString; | |
| #[no_mangle] | |
| pub unsafe extern "C" fn Ghelloworld (shl: *const octh::root::octave::dynamic_library, relative: bool) -> *mut octh::root::octave_dld_function { | |
| let name = CString::new("helloworld").unwrap(); | |
| let pname = name.as_ptr() as *const octh::root::std::string; | |
| std::mem::forget(pname); | |
| let doc = CString::new("Hello World Help String").unwrap(); | |
| let pdoc = doc.as_ptr() as *const octh::root::std::string; | |
| std::mem::forget(pdoc); | |
| octh::root::octave_dld_function_create(Some(Fhelloworld), shl, pname, pdoc) | |
| } | |
| pub unsafe extern "C" fn Fhelloworld (args: *const octh::root::octave_value_list, nargout: ::std::os::raw::c_int) -> octh::root::octave_value_list { | |
| let list_ptr = ::std::ptr::null_mut(); | |
| octh::root::octave_value_list_new(list_ptr); | |
| ::std::ptr::read(list_ptr) | |
| } |