1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! Facilities for working with `v8::Function`s.

use std::os::raw::c_void;
use call::CCallback;
use raw::Local;

extern "C" {

    /// Mutates the `out` argument provided to refer to a newly created `v8::Function`. Returns
    /// `false` if the value couldn't be created.
    #[link_name = "Neon_Fun_New"]
    pub fn new(out: &mut Local, isolate: *mut c_void, callback: CCallback) -> bool;

    /// Mutates the `out` argument provided to refer to a newly created `v8::FunctionTemplate`.
    /// Returns `false` if the value couldn't be created.
    #[link_name = "Neon_Fun_Template_New"]
    pub fn new_template(out: &mut Local, isolate: *mut c_void, callback: CCallback) -> bool;

    /// Gets the reference to the `v8::Local<v8::External>` handle provided.
    #[link_name = "Neon_Fun_GetDynamicCallback"]
    pub fn get_dynamic_callback(obj: Local) -> *mut c_void;

    /// Calls the function provided (`fun`) and mutates the `out` argument provided to refer to the
    /// result of the function call. Returns `false` if the result of the call was empty.
    #[link_name = "Neon_Fun_Call"]
    pub fn call(out: &mut Local, isolate: *mut c_void, fun: Local, this: Local, argc: i32, argv: *mut c_void) -> bool;

    /// Makes a constructor call to with the function provided (`fun`) and mutates the `out`
    /// argument provided to refer to the result of the constructor call. Returns `false` if the
    /// result of the call was empty.
    #[link_name = "Neon_Fun_Construct"]
    pub fn construct(out: &mut Local, isolate: *mut c_void, fun: Local, argc: i32, argv: *mut c_void) -> bool;

}