mirror of
https://github.com/icewind1991/ivory.git
synced 2026-06-03 10:44:09 +02:00
argument unpacking
This commit is contained in:
parent
e4874998f9
commit
d1f2500b31
3 changed files with 79 additions and 41 deletions
|
|
@ -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")]
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue