summaryrefslogtreecommitdiff
path: root/src/libdeno.rs
blob: c7a03e3bb2217a2195f65bf6f15b83d8d5d0f7bf (plain)
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
35
36
37
38
39
40
41
42
43
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
#![allow(dead_code)]
extern crate libc;
use libc::c_char;
use libc::c_int;
use libc::c_void;

#[repr(C)]
pub struct isolate {
  _unused: [u8; 0],
}

#[repr(C)]
#[derive(PartialEq)]
pub struct deno_buf {
  pub alloc_ptr: *mut u8,
  pub alloc_len: usize,
  pub data_ptr: *mut u8,
  pub data_len: usize,
}

type DenoRecvCb = unsafe extern "C" fn(
  d: *const isolate,
  req_id: i32,
  buf: deno_buf,
  data_buf: deno_buf,
);

extern "C" {
  pub fn deno_init();
  pub fn deno_v8_version() -> *const c_char;
  pub fn deno_set_v8_flags(argc: *mut c_int, argv: *mut *mut c_char);
  pub fn deno_new(data: *const c_void, cb: DenoRecvCb) -> *const isolate;
  pub fn deno_delete(i: *const isolate);
  pub fn deno_last_exception(i: *const isolate) -> *const c_char;
  pub fn deno_get_data(i: *const isolate) -> *const c_void;
  pub fn deno_respond(i: *const isolate, req_id: i32, buf: deno_buf);
  pub fn deno_execute(
    i: *const isolate,
    js_filename: *const c_char,
    js_source: *const c_char,
  ) -> c_int;
}