argument extracting basics

This commit is contained in:
Robin Appelman 2019-03-25 01:03:48 +01:00
commit 5b95e4370a
13 changed files with 5327 additions and 10 deletions

View file

@ -1,20 +1,38 @@
use std::intrinsics::transmute;
use ivory::*;
use ivory::externs::printf;
use ivory::zend::{ExecuteData, Value};
use ivory::zend::{ExecuteData, ZVal};
#[ivory_export]
fn hello_other(_other: String) {
printf(format!("Hello ",));
printf(format!("Hello ", ));
}
#[ivory_export]
fn hello_world() {
printf("Hello world, Rust!");
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();
let num = data.num_args();
for arg in data.args() {
printf(format!("{}\n", unsafe { arg.as_i64() }));
}
}
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],
functions: &[hello_world, hello_other, dump],
info: &[("demo extension", "enabled")]
});