mirror of
https://github.com/denoland/deno.git
synced 2024-11-27 16:10:57 -05:00
Rename src/binding.rs -> src/libdeno.rs
This commit is contained in:
parent
32f0c37a42
commit
e7741ab97f
5 changed files with 19 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
use binding;
|
||||
use libc::c_int;
|
||||
use libdeno;
|
||||
use std::ffi::CStr;
|
||||
use std::ffi::CString;
|
||||
use std::mem;
|
||||
|
@ -208,7 +208,7 @@ pub fn v8_set_flags(args: Vec<String>) -> Vec<String> {
|
|||
// Let v8 parse the arguments it recognizes and remove them from c_argv.
|
||||
unsafe {
|
||||
// TODO(ry) Rename deno_set_flags to deno_set_v8_flags().
|
||||
binding::deno_set_flags(&mut c_argc, c_argv.as_mut_ptr());
|
||||
libdeno::deno_set_flags(&mut c_argc, c_argv.as_mut_ptr());
|
||||
};
|
||||
// If c_argc was updated we have to change the length of c_argv to match.
|
||||
c_argv.truncate(c_argc as usize);
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
use binding;
|
||||
use binding::{deno_buf, DenoC};
|
||||
use errors::DenoResult;
|
||||
use flatbuffers::FlatBufferBuilder;
|
||||
use from_c;
|
||||
|
@ -10,6 +8,8 @@ use futures::sync::oneshot;
|
|||
use hyper;
|
||||
use hyper::rt::{Future, Stream};
|
||||
use hyper::Client;
|
||||
use libdeno;
|
||||
use libdeno::{deno_buf, DenoC};
|
||||
use msg_generated::deno as msg;
|
||||
use std;
|
||||
use std::fs;
|
||||
|
@ -20,7 +20,7 @@ use tokio::prelude::future;
|
|||
use tokio::prelude::*;
|
||||
use tokio::timer::{Delay, Interval};
|
||||
|
||||
type HandlerResult = DenoResult<binding::deno_buf>;
|
||||
type HandlerResult = DenoResult<libdeno::deno_buf>;
|
||||
type Handler =
|
||||
fn(d: *const DenoC, base: msg::Base, builder: &mut FlatBufferBuilder)
|
||||
-> HandlerResult;
|
||||
|
@ -74,7 +74,7 @@ pub extern "C" fn msg_from_js(d: *const DenoC, buf: deno_buf) {
|
|||
// Set the synchronous response, the value returned from deno.send().
|
||||
// null_buf is a special case that indicates success.
|
||||
if buf != null_buf() {
|
||||
unsafe { binding::deno_set_response(d, buf) }
|
||||
unsafe { libdeno::deno_set_response(d, buf) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ fn send_base(
|
|||
args: &msg::BaseArgs,
|
||||
) {
|
||||
let buf = create_msg(builder, args);
|
||||
unsafe { binding::deno_send(d, buf) }
|
||||
unsafe { libdeno::deno_send(d, buf) }
|
||||
}
|
||||
|
||||
// https://github.com/denoland/deno/blob/golang/os.go#L100-L154
|
||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -12,12 +12,12 @@ extern crate log;
|
|||
extern crate hyper_rustls;
|
||||
extern crate ring;
|
||||
|
||||
mod binding;
|
||||
mod deno_dir;
|
||||
mod errors;
|
||||
mod flags;
|
||||
mod fs;
|
||||
pub mod handlers;
|
||||
mod libdeno;
|
||||
mod net;
|
||||
mod version;
|
||||
|
||||
|
@ -30,7 +30,7 @@ use std::ffi::CString;
|
|||
type DenoException<'a> = &'a str;
|
||||
|
||||
pub struct Deno {
|
||||
ptr: *const binding::DenoC,
|
||||
ptr: *const libdeno::DenoC,
|
||||
dir: deno_dir::DenoDir,
|
||||
rt: tokio::runtime::current_thread::Runtime,
|
||||
timers: HashMap<u32, futures::sync::oneshot::Sender<()>>,
|
||||
|
@ -43,13 +43,13 @@ static DENO_INIT: std::sync::Once = std::sync::ONCE_INIT;
|
|||
impl Deno {
|
||||
fn new(argv: Vec<String>) -> Box<Deno> {
|
||||
DENO_INIT.call_once(|| {
|
||||
unsafe { binding::deno_init() };
|
||||
unsafe { libdeno::deno_init() };
|
||||
});
|
||||
|
||||
let (flags, argv_rest) = flags::set_flags(argv);
|
||||
|
||||
let mut deno_box = Box::new(Deno {
|
||||
ptr: 0 as *const binding::DenoC,
|
||||
ptr: 0 as *const libdeno::DenoC,
|
||||
dir: deno_dir::DenoDir::new(flags.reload, None).unwrap(),
|
||||
rt: tokio::runtime::current_thread::Runtime::new().unwrap(),
|
||||
timers: HashMap::new(),
|
||||
|
@ -58,7 +58,7 @@ impl Deno {
|
|||
});
|
||||
|
||||
(*deno_box).ptr = unsafe {
|
||||
binding::deno_new(
|
||||
libdeno::deno_new(
|
||||
deno_box.as_ref() as *const _ as *const c_void,
|
||||
handlers::msg_from_js,
|
||||
)
|
||||
|
@ -75,10 +75,10 @@ impl Deno {
|
|||
let filename = CString::new(js_filename).unwrap();
|
||||
let source = CString::new(js_source).unwrap();
|
||||
let r = unsafe {
|
||||
binding::deno_execute(self.ptr, filename.as_ptr(), source.as_ptr())
|
||||
libdeno::deno_execute(self.ptr, filename.as_ptr(), source.as_ptr())
|
||||
};
|
||||
if r == 0 {
|
||||
let ptr = unsafe { binding::deno_last_exception(self.ptr) };
|
||||
let ptr = unsafe { libdeno::deno_last_exception(self.ptr) };
|
||||
let cstr = unsafe { CStr::from_ptr(ptr) };
|
||||
return Err(cstr.to_str().unwrap());
|
||||
}
|
||||
|
@ -88,12 +88,12 @@ impl Deno {
|
|||
|
||||
impl Drop for Deno {
|
||||
fn drop(&mut self) {
|
||||
unsafe { binding::deno_delete(self.ptr) }
|
||||
unsafe { libdeno::deno_delete(self.ptr) }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_c<'a>(d: *const binding::DenoC) -> &'a mut Deno {
|
||||
let ptr = unsafe { binding::deno_get_data(d) };
|
||||
pub fn from_c<'a>(d: *const libdeno::DenoC) -> &'a mut Deno {
|
||||
let ptr = unsafe { libdeno::deno_get_data(d) };
|
||||
let deno_ptr = ptr as *mut Deno;
|
||||
let deno_box = unsafe { Box::from_raw(deno_ptr) };
|
||||
Box::leak(deno_box)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
use binding;
|
||||
use libdeno;
|
||||
use std::ffi::CStr;
|
||||
|
||||
// This is the source of truth for the Deno version. Ignore the value in Cargo.toml.
|
||||
const DENO_VERSION: &str = "0.1.2";
|
||||
|
||||
pub fn print_version() {
|
||||
let v = unsafe { binding::deno_v8_version() };
|
||||
let v = unsafe { libdeno::deno_v8_version() };
|
||||
let c_str = unsafe { CStr::from_ptr(v) };
|
||||
let version = c_str.to_str().unwrap();
|
||||
println!("deno: {}", DENO_VERSION);
|
||||
|
|
Loading…
Reference in a new issue