From e7741ab97ff75187aa4f72b0ad4d62af5b3a7d04 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 4 Sep 2018 18:56:12 -0400 Subject: [PATCH] Rename src/binding.rs -> src/libdeno.rs --- src/flags.rs | 4 ++-- src/handlers.rs | 10 +++++----- src/{binding.rs => libdeno.rs} | 0 src/main.rs | 20 ++++++++++---------- src/version.rs | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) rename src/{binding.rs => libdeno.rs} (100%) diff --git a/src/flags.rs b/src/flags.rs index db04e42f70..1b6299e3c9 100644 --- a/src/flags.rs +++ b/src/flags.rs @@ -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) -> Vec { // 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); diff --git a/src/handlers.rs b/src/handlers.rs index 141cc5d137..3e6623e3da 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -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; +type HandlerResult = DenoResult; 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 diff --git a/src/binding.rs b/src/libdeno.rs similarity index 100% rename from src/binding.rs rename to src/libdeno.rs diff --git a/src/main.rs b/src/main.rs index 7d59fe03db..ab9a72f790 100644 --- a/src/main.rs +++ b/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>, @@ -43,13 +43,13 @@ static DENO_INIT: std::sync::Once = std::sync::ONCE_INIT; impl Deno { fn new(argv: Vec) -> Box { 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) diff --git a/src/version.rs b/src/version.rs index 890b4d1528..f406877701 100644 --- a/src/version.rs +++ b/src/version.rs @@ -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);