1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

Wrap rust at 80 columns.

This commit is contained in:
Ryan Dahl 2018-07-19 21:06:48 -04:00
parent c67d98eb7f
commit a7bf154cb8
5 changed files with 28 additions and 9 deletions

View file

@ -37,7 +37,11 @@ extern "C" {
js_source: *const c_char,
) -> c_int;
pub fn deno_handle_msg_from_js(d: *const DenoC, buf: deno_buf);
pub fn deno_reply_error(d: *const DenoC, cmd_id: uint32_t, msg: *const c_char);
pub fn deno_reply_error(
d: *const DenoC,
cmd_id: uint32_t,
msg: *const c_char,
);
pub fn deno_reply_null(d: *const DenoC, cmd_id: uint32_t);
pub fn deno_reply_code_fetch(
d: *const DenoC,

View file

@ -164,7 +164,8 @@ fn test_resolve_module() {
for &test in test_cases.iter() {
let module_specifier = String::from(test.0);
let containing_file = String::from(test.1);
let (module_name, filename) = resolve_module(&module_specifier, &containing_file).unwrap();
let (module_name, filename) =
resolve_module(&module_specifier, &containing_file).unwrap();
assert_eq!(module_name, test.2);
assert_eq!(filename, test.3);
}
@ -184,7 +185,8 @@ pub extern "C" fn handle_code_fetch(
let result = resolve_module(&module_specifier, &containing_file);
if result.is_err() {
let err = result.unwrap_err();
let errmsg = format!("{} {} {}", err, module_specifier, containing_file);
let errmsg =
format!("{} {} {}", err, module_specifier, containing_file);
let errmsg_c = as_cstring(&errmsg);
unsafe { deno_reply_error(d, cmd_id, errmsg_c.as_ptr()) };
return;

View file

@ -8,8 +8,10 @@ use std::ffi::CString;
use std::ptr;
mod binding;
use binding::{deno_delete, deno_execute, deno_handle_msg_from_js, deno_init, deno_last_exception,
deno_new, deno_set_flags, DenoC};
use binding::{
deno_delete, deno_execute, deno_handle_msg_from_js, deno_init,
deno_last_exception, deno_new, deno_set_flags, DenoC,
};
// Pass the command line arguments to v8.
// Returns a vector of command line arguments that v8 did not understand.
@ -58,10 +60,16 @@ impl Deno {
Deno { ptr: ptr }
}
fn execute(&mut self, js_filename: &str, js_source: &str) -> Result<(), DenoException> {
fn execute(
&mut self,
js_filename: &str,
js_source: &str,
) -> Result<(), DenoException> {
let filename = CString::new(js_filename).unwrap();
let source = CString::new(js_source).unwrap();
let r = unsafe { deno_execute(self.ptr, filename.as_ptr(), source.as_ptr()) };
let r = unsafe {
deno_execute(self.ptr, filename.as_ptr(), source.as_ptr())
};
if r == 0 {
let ptr = unsafe { deno_last_exception(self.ptr) };
let cstr = unsafe { CStr::from_ptr(ptr) };

View file

@ -8,6 +8,8 @@ root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
third_party_path = os.path.join(root_path, "third_party")
prettier = os.path.join(third_party_path, "node_modules", "prettier",
"bin-prettier.js")
tools_path = os.path.join(root_path, "tools")
rustfmt_config = os.path.join(tools_path, "rustfmt.toml")
os.chdir(root_path)
# TODO(ry) Install clang-format in third_party.
@ -24,5 +26,7 @@ run(["node", prettier, "--write"] + glob("js/*.js") + glob("js/*.ts") +
rustfmt_extra_args = []
if 'RUSTFMT_FLAGS' in os.environ:
rustfmt_extra_args += os.environ['RUSTFMT_FLAGS'].split()
run(["rustfmt", "--write-mode", "overwrite"] + rustfmt_extra_args +
glob("src/*.rs"))
run([
"rustfmt", "--config-path", rustfmt_config, "--error-on-unformatted",
"--write-mode", "overwrite"
] + rustfmt_extra_args + glob("src/*.rs"))

1
tools/rustfmt.toml Normal file
View file

@ -0,0 +1 @@
max_width = 80