duk_sys/
lib.rs

1//! An auto-generated wrapper around the [Duktape][1] library.
2//!
3//! The API of this wrapper is not stable, and currently exposes
4//! transient library APIs.
5//!
6//! [1]: http://duktape.org/
7#![allow(non_camel_case_types, non_snake_case)]
8
9extern crate libc;
10#[cfg(any(feature = "debug", feature = "trace", feature = "spam"))]
11#[macro_use]
12extern crate log;
13
14mod ffi;
15
16pub use ffi::*;
17
18#[cfg(any(feature = "debug", feature = "trace", feature = "spam"))]
19#[no_mangle]
20unsafe extern "C" fn __duktape_sys_debug_write(
21    _: libc::c_long,
22    file: *const libc::c_char,
23    line: libc::c_long,
24    func: *const libc::c_char,
25    msg: *const libc::c_char,
26) {
27    if log_enabled!(log::Level::Trace) {
28        let file_str = ::std::ffi::CStr::from_ptr(file).to_string_lossy();
29
30        let target = format!("{} {}", module_path!(), file_str);
31        if log_enabled!(target: &target, log::Level::Trace) {
32            let func_str = ::std::ffi::CStr::from_ptr(func).to_string_lossy();
33            let msg_str = ::std::ffi::CStr::from_ptr(msg).to_string_lossy();
34            trace!(
35                target: &target,
36                "{} ({}.{}:{})",
37                msg_str,
38                file_str,
39                func_str,
40                line
41            );
42        }
43    }
44}