2018-07-23 14:46:30 -04:00
|
|
|
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
2018-07-18 16:44:09 -04:00
|
|
|
use libc::c_char;
|
|
|
|
use libc::c_int;
|
|
|
|
use libc::c_void;
|
2018-11-29 22:03:00 -05:00
|
|
|
use std::ptr::null_mut;
|
2018-07-18 16:44:09 -04:00
|
|
|
|
|
|
|
#[repr(C)]
|
2018-09-22 08:47:44 -04:00
|
|
|
pub struct isolate {
|
2018-07-19 21:14:32 -04:00
|
|
|
_unused: [u8; 0],
|
2018-07-18 16:44:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[repr(C)]
|
2018-10-23 19:39:31 -04:00
|
|
|
#[derive(Clone, PartialEq)]
|
2018-07-18 16:44:09 -04:00
|
|
|
pub struct deno_buf {
|
2018-07-23 14:13:12 -04:00
|
|
|
pub alloc_ptr: *mut u8,
|
|
|
|
pub alloc_len: usize,
|
|
|
|
pub data_ptr: *mut u8,
|
|
|
|
pub data_len: usize,
|
2018-07-18 16:44:09 -04:00
|
|
|
}
|
|
|
|
|
2018-11-29 22:03:00 -05:00
|
|
|
impl deno_buf {
|
|
|
|
pub fn empty() -> Self {
|
2018-11-30 03:30:49 -05:00
|
|
|
Self {
|
2018-11-29 22:03:00 -05:00
|
|
|
alloc_ptr: null_mut(),
|
|
|
|
alloc_len: 0,
|
|
|
|
data_ptr: null_mut(),
|
|
|
|
data_len: 0,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-27 17:33:10 -04:00
|
|
|
type DenoRecvCb = unsafe extern "C" fn(
|
2018-10-08 05:04:33 -04:00
|
|
|
user_data: *mut c_void,
|
2018-09-27 17:33:10 -04:00
|
|
|
req_id: i32,
|
|
|
|
buf: deno_buf,
|
|
|
|
data_buf: deno_buf,
|
|
|
|
);
|
2018-07-18 16:44:09 -04:00
|
|
|
|
|
|
|
extern "C" {
|
2018-07-19 21:14:32 -04:00
|
|
|
pub fn deno_init();
|
|
|
|
pub fn deno_v8_version() -> *const c_char;
|
2018-09-22 08:47:44 -04:00
|
|
|
pub fn deno_set_v8_flags(argc: *mut c_int, argv: *mut *mut c_char);
|
2018-10-24 02:17:10 -04:00
|
|
|
pub fn deno_new(
|
|
|
|
snapshot: deno_buf,
|
|
|
|
shared: deno_buf,
|
|
|
|
cb: DenoRecvCb,
|
|
|
|
) -> *const isolate;
|
2018-09-22 08:47:44 -04:00
|
|
|
pub fn deno_delete(i: *const isolate);
|
|
|
|
pub fn deno_last_exception(i: *const isolate) -> *const c_char;
|
2018-10-12 14:22:52 -04:00
|
|
|
pub fn deno_check_promise_errors(i: *const isolate);
|
2018-10-07 17:48:06 -04:00
|
|
|
pub fn deno_respond(
|
|
|
|
i: *const isolate,
|
|
|
|
user_data: *mut c_void,
|
|
|
|
req_id: i32,
|
|
|
|
buf: deno_buf,
|
|
|
|
);
|
2018-07-19 21:14:32 -04:00
|
|
|
pub fn deno_execute(
|
2018-09-22 08:47:44 -04:00
|
|
|
i: *const isolate,
|
2018-10-07 17:48:06 -04:00
|
|
|
user_data: *mut c_void,
|
2018-07-19 21:14:32 -04:00
|
|
|
js_filename: *const c_char,
|
|
|
|
js_source: *const c_char,
|
|
|
|
) -> c_int;
|
2018-07-18 16:44:09 -04:00
|
|
|
}
|