argument unpacking

This commit is contained in:
Robin Appelman 2019-03-27 22:27:33 +01:00
commit d1f2500b31
3 changed files with 79 additions and 41 deletions

View file

@ -2,11 +2,11 @@ use std::intrinsics::transmute;
use ivory::*;
use ivory::externs::printf;
use ivory::zend::{ExecuteData, ZVal, PhpVal};
use ivory::zend::{ExecuteData, PhpVal, ZVal};
#[ivory_export]
fn hello_other(_other: String) {
printf(format!("Hello ", ));
fn hello_other(other: String) {
printf(format!("Hello {}", other));
}
#[ivory_export]
@ -14,24 +14,9 @@ fn hello_world() {
printf("Hello world, Rust2!");
}
#[no_mangle]
pub extern "C" fn dump(data: *const ExecuteData, retval: *mut ZVal) {
let data: &ExecuteData = unsafe { data.as_ref() }.unwrap();
for arg in data.args() {
printf(format!("{:?}\n", arg));
}
}
const FUNCTION_META_DUMP: ::ivory::zend::FunctionMeta = ::ivory::zend::FunctionMeta {
name: { concat!("dump", "\0").as_ptr() as *const ::libc::c_char },
func: dump,
args: &[],
};
ivory_module!({
name: "demo",
version: "0.0.1",
functions: &[hello_world, hello_other, dump],
functions: &[hello_world, hello_other],
info: &[("demo extension", "enabled")]
});