From 6a6e6916c8e618757723160bcdbf7a5191aac2b5 Mon Sep 17 00:00:00 2001 From: Dave Herman Date: Thu, 2 Feb 2017 10:37:18 -0800 Subject: [PATCH 1/2] Resolves #169. --- Cargo.toml | 8 ++++---- crates/{neon-sys => neon-runtime}/Cargo.toml | 2 +- crates/{neon-sys => neon-runtime}/LICENSE-APACHE | 0 crates/{neon-sys => neon-runtime}/LICENSE-MIT | 0 crates/{neon-sys => neon-runtime}/binding.gyp | 0 crates/{neon-sys => neon-runtime}/build.rs | 0 crates/{neon-sys => neon-runtime}/package.json | 0 crates/{neon-sys => neon-runtime}/src/array.rs | 0 crates/{neon-sys => neon-runtime}/src/buffer.rs | 0 crates/{neon-sys => neon-runtime}/src/call.rs | 0 crates/{neon-sys => neon-runtime}/src/class.rs | 0 crates/{neon-sys => neon-runtime}/src/convert.rs | 0 crates/{neon-sys => neon-runtime}/src/error.rs | 0 crates/{neon-sys => neon-runtime}/src/fun.rs | 0 crates/{neon-sys => neon-runtime}/src/lib.rs | 0 crates/{neon-sys => neon-runtime}/src/mem.rs | 0 crates/{neon-sys => neon-runtime}/src/module.rs | 0 crates/{neon-sys => neon-runtime}/src/neon.cc | 0 crates/{neon-sys => neon-runtime}/src/neon.h | 0 .../{neon-sys => neon-runtime}/src/neon_class_metadata.h | 0 crates/{neon-sys => neon-runtime}/src/neon_string.h | 0 crates/{neon-sys => neon-runtime}/src/object.rs | 0 crates/{neon-sys => neon-runtime}/src/primitive.rs | 0 crates/{neon-sys => neon-runtime}/src/raw.rs | 0 crates/{neon-sys => neon-runtime}/src/scope.rs | 0 crates/{neon-sys => neon-runtime}/src/string.rs | 0 crates/{neon-sys => neon-runtime}/src/tag.rs | 0 27 files changed, 5 insertions(+), 5 deletions(-) rename crates/{neon-sys => neon-runtime}/Cargo.toml (94%) rename crates/{neon-sys => neon-runtime}/LICENSE-APACHE (100%) rename crates/{neon-sys => neon-runtime}/LICENSE-MIT (100%) rename crates/{neon-sys => neon-runtime}/binding.gyp (100%) rename crates/{neon-sys => neon-runtime}/build.rs (100%) rename crates/{neon-sys => neon-runtime}/package.json (100%) rename crates/{neon-sys => neon-runtime}/src/array.rs (100%) rename crates/{neon-sys => neon-runtime}/src/buffer.rs (100%) rename crates/{neon-sys => neon-runtime}/src/call.rs (100%) rename crates/{neon-sys => neon-runtime}/src/class.rs (100%) rename crates/{neon-sys => neon-runtime}/src/convert.rs (100%) rename crates/{neon-sys => neon-runtime}/src/error.rs (100%) rename crates/{neon-sys => neon-runtime}/src/fun.rs (100%) rename crates/{neon-sys => neon-runtime}/src/lib.rs (100%) rename crates/{neon-sys => neon-runtime}/src/mem.rs (100%) rename crates/{neon-sys => neon-runtime}/src/module.rs (100%) rename crates/{neon-sys => neon-runtime}/src/neon.cc (100%) rename crates/{neon-sys => neon-runtime}/src/neon.h (100%) rename crates/{neon-sys => neon-runtime}/src/neon_class_metadata.h (100%) rename crates/{neon-sys => neon-runtime}/src/neon_string.h (100%) rename crates/{neon-sys => neon-runtime}/src/object.rs (100%) rename crates/{neon-sys => neon-runtime}/src/primitive.rs (100%) rename crates/{neon-sys => neon-runtime}/src/raw.rs (100%) rename crates/{neon-sys => neon-runtime}/src/scope.rs (100%) rename crates/{neon-sys => neon-runtime}/src/string.rs (100%) rename crates/{neon-sys => neon-runtime}/src/tag.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 2a1c21f18..c3cccecc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,13 +10,13 @@ license = "MIT/Apache-2.0" exclude = ["neon.jpg"] build = "build.rs" -# Sharing the name of the library produced by neon-sys (which will be -# renamed to `neon-runtime` -- see issue #169) allows the `build.rs` -# script for Neon projects to find the path to `node.lib` in Windows. +# Sharing the name of the library produced by neon-runtime allows the +# `build.rs` script for Neon projects to find the path to `node.lib` +# in Windows. # # See also: http://doc.crates.io/build-script.html#the-links-manifest-key links = "neon-runtime" [dependencies] cslice = "0.2" -neon-sys = { version = "=0.1.11", path = "crates/neon-sys" } +neon-runtime = { version = "=0.1.11", path = "crates/neon-runtime" } diff --git a/crates/neon-sys/Cargo.toml b/crates/neon-runtime/Cargo.toml similarity index 94% rename from crates/neon-sys/Cargo.toml rename to crates/neon-runtime/Cargo.toml index ceeade77d..8b516217c 100644 --- a/crates/neon-sys/Cargo.toml +++ b/crates/neon-runtime/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "neon-sys" +name = "neon-runtime" version = "0.1.11" authors = ["Dave Herman "] description = "Exposes Node and V8 C++ API's for use by Neon." diff --git a/crates/neon-sys/LICENSE-APACHE b/crates/neon-runtime/LICENSE-APACHE similarity index 100% rename from crates/neon-sys/LICENSE-APACHE rename to crates/neon-runtime/LICENSE-APACHE diff --git a/crates/neon-sys/LICENSE-MIT b/crates/neon-runtime/LICENSE-MIT similarity index 100% rename from crates/neon-sys/LICENSE-MIT rename to crates/neon-runtime/LICENSE-MIT diff --git a/crates/neon-sys/binding.gyp b/crates/neon-runtime/binding.gyp similarity index 100% rename from crates/neon-sys/binding.gyp rename to crates/neon-runtime/binding.gyp diff --git a/crates/neon-sys/build.rs b/crates/neon-runtime/build.rs similarity index 100% rename from crates/neon-sys/build.rs rename to crates/neon-runtime/build.rs diff --git a/crates/neon-sys/package.json b/crates/neon-runtime/package.json similarity index 100% rename from crates/neon-sys/package.json rename to crates/neon-runtime/package.json diff --git a/crates/neon-sys/src/array.rs b/crates/neon-runtime/src/array.rs similarity index 100% rename from crates/neon-sys/src/array.rs rename to crates/neon-runtime/src/array.rs diff --git a/crates/neon-sys/src/buffer.rs b/crates/neon-runtime/src/buffer.rs similarity index 100% rename from crates/neon-sys/src/buffer.rs rename to crates/neon-runtime/src/buffer.rs diff --git a/crates/neon-sys/src/call.rs b/crates/neon-runtime/src/call.rs similarity index 100% rename from crates/neon-sys/src/call.rs rename to crates/neon-runtime/src/call.rs diff --git a/crates/neon-sys/src/class.rs b/crates/neon-runtime/src/class.rs similarity index 100% rename from crates/neon-sys/src/class.rs rename to crates/neon-runtime/src/class.rs diff --git a/crates/neon-sys/src/convert.rs b/crates/neon-runtime/src/convert.rs similarity index 100% rename from crates/neon-sys/src/convert.rs rename to crates/neon-runtime/src/convert.rs diff --git a/crates/neon-sys/src/error.rs b/crates/neon-runtime/src/error.rs similarity index 100% rename from crates/neon-sys/src/error.rs rename to crates/neon-runtime/src/error.rs diff --git a/crates/neon-sys/src/fun.rs b/crates/neon-runtime/src/fun.rs similarity index 100% rename from crates/neon-sys/src/fun.rs rename to crates/neon-runtime/src/fun.rs diff --git a/crates/neon-sys/src/lib.rs b/crates/neon-runtime/src/lib.rs similarity index 100% rename from crates/neon-sys/src/lib.rs rename to crates/neon-runtime/src/lib.rs diff --git a/crates/neon-sys/src/mem.rs b/crates/neon-runtime/src/mem.rs similarity index 100% rename from crates/neon-sys/src/mem.rs rename to crates/neon-runtime/src/mem.rs diff --git a/crates/neon-sys/src/module.rs b/crates/neon-runtime/src/module.rs similarity index 100% rename from crates/neon-sys/src/module.rs rename to crates/neon-runtime/src/module.rs diff --git a/crates/neon-sys/src/neon.cc b/crates/neon-runtime/src/neon.cc similarity index 100% rename from crates/neon-sys/src/neon.cc rename to crates/neon-runtime/src/neon.cc diff --git a/crates/neon-sys/src/neon.h b/crates/neon-runtime/src/neon.h similarity index 100% rename from crates/neon-sys/src/neon.h rename to crates/neon-runtime/src/neon.h diff --git a/crates/neon-sys/src/neon_class_metadata.h b/crates/neon-runtime/src/neon_class_metadata.h similarity index 100% rename from crates/neon-sys/src/neon_class_metadata.h rename to crates/neon-runtime/src/neon_class_metadata.h diff --git a/crates/neon-sys/src/neon_string.h b/crates/neon-runtime/src/neon_string.h similarity index 100% rename from crates/neon-sys/src/neon_string.h rename to crates/neon-runtime/src/neon_string.h diff --git a/crates/neon-sys/src/object.rs b/crates/neon-runtime/src/object.rs similarity index 100% rename from crates/neon-sys/src/object.rs rename to crates/neon-runtime/src/object.rs diff --git a/crates/neon-sys/src/primitive.rs b/crates/neon-runtime/src/primitive.rs similarity index 100% rename from crates/neon-sys/src/primitive.rs rename to crates/neon-runtime/src/primitive.rs diff --git a/crates/neon-sys/src/raw.rs b/crates/neon-runtime/src/raw.rs similarity index 100% rename from crates/neon-sys/src/raw.rs rename to crates/neon-runtime/src/raw.rs diff --git a/crates/neon-sys/src/scope.rs b/crates/neon-runtime/src/scope.rs similarity index 100% rename from crates/neon-sys/src/scope.rs rename to crates/neon-runtime/src/scope.rs diff --git a/crates/neon-sys/src/string.rs b/crates/neon-runtime/src/string.rs similarity index 100% rename from crates/neon-sys/src/string.rs rename to crates/neon-runtime/src/string.rs diff --git a/crates/neon-sys/src/tag.rs b/crates/neon-runtime/src/tag.rs similarity index 100% rename from crates/neon-sys/src/tag.rs rename to crates/neon-runtime/src/tag.rs From 6318879052638bea0cde03fe71a3b2830f88dfad Mon Sep 17 00:00:00 2001 From: Dave Herman Date: Thu, 2 Feb 2017 11:06:47 -0800 Subject: [PATCH 2/2] replace neon_sys with neon_runtime in the source --- src/internal/js/binary.rs | 10 ++--- src/internal/js/class.rs | 44 ++++++++++---------- src/internal/js/error.rs | 28 ++++++------- src/internal/js/mod.rs | 86 +++++++++++++++++++-------------------- src/internal/mem.rs | 6 +-- src/internal/scope.rs | 18 ++++---- src/internal/vm.rs | 30 +++++++------- src/lib.rs | 2 +- src/macro_internal/mod.rs | 4 +- 9 files changed, 114 insertions(+), 114 deletions(-) diff --git a/src/internal/js/binary.rs b/src/internal/js/binary.rs index 05f640656..3655203aa 100644 --- a/src/internal/js/binary.rs +++ b/src/internal/js/binary.rs @@ -5,8 +5,8 @@ use internal::mem::{Handle, Managed}; use internal::vm::{Lock, LockState}; use scope::Scope; use cslice::CMutSlice; -use neon_sys; -use neon_sys::raw; +use neon_runtime; +use neon_runtime::raw; #[repr(C)] #[derive(Clone, Copy)] @@ -14,7 +14,7 @@ pub struct JsBuffer(raw::Local); impl JsBuffer { pub fn new<'a, T: Scope<'a>>(_: &mut T, size: u32) -> VmResult> { - build(|out| { unsafe { neon_sys::buffer::new(out, size) } }) + build(|out| { unsafe { neon_runtime::buffer::new(out, size) } }) } } @@ -26,7 +26,7 @@ impl Managed for JsBuffer { impl ValueInternal for JsBuffer { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_buffer(other.to_raw()) } + unsafe { neon_runtime::tag::is_buffer(other.to_raw()) } } } @@ -39,7 +39,7 @@ impl<'a> Lock for &'a mut JsBuffer { unsafe fn expose(self, state: &mut LockState) -> Self::Internals { let mut result = mem::uninitialized(); - neon_sys::buffer::data(&mut result, self.to_raw()); + neon_runtime::buffer::data(&mut result, self.to_raw()); state.use_buffer(result); result } diff --git a/src/internal/js/class.rs b/src/internal/js/class.rs index b89a9d1f1..98a84d322 100644 --- a/src/internal/js/class.rs +++ b/src/internal/js/class.rs @@ -3,8 +3,8 @@ use std::mem; use std::marker::PhantomData; use std::os::raw::c_void; use std::ptr::null_mut; -use neon_sys; -use neon_sys::raw; +use neon_runtime; +use neon_runtime::raw; use internal::mem::{Handle, HandleInternal, Managed}; use internal::scope::{Scope, ScopeInternal, RootScopeInternal}; use internal::vm::{Isolate, IsolateInternal, JsResult, VmResult, FunctionCall, CallbackInfo, Lock, LockState, Throw, This, Kernel}; @@ -31,7 +31,7 @@ impl Kernel<()> for MethodKernel { if !this.is_a::() { if let Ok(metadata) = T::metadata(call.scope) { unsafe { - neon_sys::class::throw_this_error(mem::transmute(call.scope.isolate()), metadata.pointer); + neon_runtime::class::throw_this_error(mem::transmute(call.scope.isolate()), metadata.pointer); } } return; @@ -44,7 +44,7 @@ impl Kernel<()> for MethodKernel { } unsafe fn from_wrapper(h: raw::Local) -> Self { - MethodKernel(mem::transmute(neon_sys::fun::get_kernel(h))) + MethodKernel(mem::transmute(neon_runtime::fun::get_kernel(h))) } fn as_ptr(self) -> *mut c_void { @@ -64,7 +64,7 @@ impl ConstructorCallKernel { let mut scope = info.scope(); if let Ok(metadata) = T::metadata(&mut scope) { unsafe { - neon_sys::class::throw_call_error(mem::transmute(scope.isolate()), metadata.pointer); + neon_runtime::class::throw_call_error(mem::transmute(scope.isolate()), metadata.pointer); } } return; @@ -84,7 +84,7 @@ impl Kernel<()> for ConstructorCallKernel { } unsafe fn from_wrapper(h: raw::Local) -> Self { - ConstructorCallKernel(mem::transmute(neon_sys::class::get_call_kernel(h))) + ConstructorCallKernel(mem::transmute(neon_runtime::class::get_call_kernel(h))) } fn as_ptr(self) -> *mut c_void { @@ -117,7 +117,7 @@ impl Kernel<*mut c_void> for AllocateKernel { } unsafe fn from_wrapper(h: raw::Local) -> Self { - AllocateKernel(mem::transmute(neon_sys::class::get_allocate_kernel(h))) + AllocateKernel(mem::transmute(neon_runtime::class::get_allocate_kernel(h))) } fn as_ptr(self) -> *mut c_void { @@ -152,7 +152,7 @@ impl Kernel for ConstructKernel { } unsafe fn from_wrapper(h: raw::Local) -> Self { - ConstructKernel(mem::transmute(neon_sys::class::get_construct_kernel(h))) + ConstructKernel(mem::transmute(neon_runtime::class::get_construct_kernel(h))) } fn as_ptr(self) -> *mut c_void { @@ -255,11 +255,11 @@ pub trait ClassInternal: Class { None => (mem::transmute(ConstructorCallKernel::unimplemented:: as usize), null_mut()) }; - let metadata_pointer = neon_sys::class::create_base(isolate, - allocate_callback, allocate_kernel, - construct_callback, construct_kernel, - call_callback, call_kernel, - drop_internals::); + let metadata_pointer = neon_runtime::class::create_base(isolate, + allocate_callback, allocate_kernel, + construct_callback, construct_kernel, + call_callback, call_kernel, + drop_internals::); if metadata_pointer.is_null() { return Err(Throw); @@ -269,16 +269,16 @@ pub trait ClassInternal: Class { // v8::FunctionTemplate has a finalizer that will delete it. let class_name = descriptor.name; - if !neon_sys::class::set_name(isolate, metadata_pointer, class_name.as_ptr(), class_name.len() as u32) { + if !neon_runtime::class::set_name(isolate, metadata_pointer, class_name.as_ptr(), class_name.len() as u32) { return Err(Throw); } for (name, method) in descriptor.methods { let method: Handle = try!(build(|out| { let (method_callback, method_kernel) = method.export(); - neon_sys::fun::new_template(out, isolate, method_callback, method_kernel) + neon_runtime::fun::new_template(out, isolate, method_callback, method_kernel) })); - if !neon_sys::class::add_method(isolate, metadata_pointer, name.as_ptr(), name.len() as u32, method.to_raw()) { + if !neon_runtime::class::add_method(isolate, metadata_pointer, name.as_ptr(), name.len() as u32, method.to_raw()) { return Err(Throw); } } @@ -299,7 +299,7 @@ impl ClassInternal for T { } impl ValueInternal for T { fn is_typeof(value: Other) -> bool { let mut isolate: Isolate = unsafe { - mem::transmute(neon_sys::call::current_isolate()) + mem::transmute(neon_runtime::call::current_isolate()) }; let map = isolate.class_map(); match map.get(&TypeId::of::()) { @@ -329,7 +329,7 @@ pub struct ClassMetadata { impl ClassMetadata { pub unsafe fn class<'a, T: Class, U: Scope<'a>>(&self, scope: &mut U) -> Handle<'a, JsClass> { let mut local: raw::Local = mem::zeroed(); - neon_sys::class::metadata_to_class(&mut local, mem::transmute(scope.isolate()), self.pointer); + neon_runtime::class::metadata_to_class(&mut local, mem::transmute(scope.isolate()), self.pointer); Handle::new(JsClass { handle: local, phantom: PhantomData @@ -337,14 +337,14 @@ impl ClassMetadata { } pub unsafe fn has_instance(&self, value: raw::Local) -> bool { - neon_sys::class::has_instance(self.pointer, value) + neon_runtime::class::has_instance(self.pointer, value) } } impl JsClass { pub fn check(&self, v: Handle, msg: &str) -> JsResult { let local = v.to_raw(); - if unsafe { neon_sys::class::check(self.to_raw(), local) } { + if unsafe { neon_runtime::class::check(self.to_raw(), local) } { Ok(Handle::new(T::from_raw(local))) } else { JsError::throw(Kind::TypeError, msg) @@ -354,7 +354,7 @@ impl JsClass { pub fn constructor<'a, U: Scope<'a>>(&self, _: &mut U) -> JsResult<'a, JsFunction> { build(|out| { unsafe { - neon_sys::class::constructor(out, self.to_raw()) + neon_runtime::class::constructor(out, self.to_raw()) } }) } @@ -364,7 +364,7 @@ impl<'a, T: Class> Lock for &'a mut T { type Internals = &'a mut T::Internals; unsafe fn expose(self, _: &mut LockState) -> Self::Internals { - let ptr: *mut c_void = neon_sys::class::get_instance_internals(self.to_raw()); + let ptr: *mut c_void = neon_runtime::class::get_instance_internals(self.to_raw()); mem::transmute(ptr) } } diff --git a/src/internal/js/error.rs b/src/internal/js/error.rs index 717a9dcf2..16ec9db8f 100644 --- a/src/internal/js/error.rs +++ b/src/internal/js/error.rs @@ -1,8 +1,8 @@ use std::mem; use std::ffi::CString; -use neon_sys; -use neon_sys::raw; +use neon_runtime; +use neon_runtime::raw; use internal::vm::{Throw, VmResult}; use internal::js::{Value, ValueInternal, Object, ToJsString, build}; @@ -11,7 +11,7 @@ use scope::Scope; pub fn throw<'a, T: Value, U>(v: Handle<'a, T>) -> VmResult { unsafe { - neon_sys::error::throw(v.to_raw()); + neon_runtime::error::throw(v.to_raw()); } Err(Throw) } @@ -28,7 +28,7 @@ impl Managed for JsError { impl ValueInternal for JsError { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_error(other.to_raw()) } + unsafe { neon_runtime::tag::is_error(other.to_raw()) } } } @@ -55,11 +55,11 @@ impl JsError { unsafe { let raw = msg.to_raw(); match kind { - Kind::Error => neon_sys::error::new_error(out, raw), - Kind::TypeError => neon_sys::error::new_type_error(out, raw), - Kind::ReferenceError => neon_sys::error::new_reference_error(out, raw), - Kind::RangeError => neon_sys::error::new_range_error(out, raw), - Kind::SyntaxError => neon_sys::error::new_syntax_error(out, raw) + Kind::Error => neon_runtime::error::new_error(out, raw), + Kind::TypeError => neon_runtime::error::new_type_error(out, raw), + Kind::ReferenceError => neon_runtime::error::new_reference_error(out, raw), + Kind::RangeError => neon_runtime::error::new_range_error(out, raw), + Kind::SyntaxError => neon_runtime::error::new_syntax_error(out, raw) } } true @@ -71,11 +71,11 @@ impl JsError { unsafe { let ptr = mem::transmute(msg.as_ptr()); match kind { - Kind::Error => neon_sys::error::throw_error_from_cstring(ptr), - Kind::TypeError => neon_sys::error::throw_type_error_from_cstring(ptr), - Kind::ReferenceError => neon_sys::error::throw_reference_error_from_cstring(ptr), - Kind::RangeError => neon_sys::error::throw_range_error_from_cstring(ptr), - Kind::SyntaxError => neon_sys::error::throw_syntax_error_from_cstring(ptr) + Kind::Error => neon_runtime::error::throw_error_from_cstring(ptr), + Kind::TypeError => neon_runtime::error::throw_type_error_from_cstring(ptr), + Kind::ReferenceError => neon_runtime::error::throw_reference_error_from_cstring(ptr), + Kind::RangeError => neon_runtime::error::throw_range_error_from_cstring(ptr), + Kind::SyntaxError => neon_runtime::error::throw_syntax_error_from_cstring(ptr) } } Err(Throw) diff --git a/src/internal/js/mod.rs b/src/internal/js/mod.rs index 0d294e0d9..bad3ac80d 100644 --- a/src/internal/js/mod.rs +++ b/src/internal/js/mod.rs @@ -5,9 +5,9 @@ pub mod class; use std::mem; use std::os::raw::c_void; use std::marker::PhantomData; -use neon_sys; -use neon_sys::raw; -use neon_sys::tag::Tag; +use neon_runtime; +use neon_runtime::raw; +use neon_runtime::tag::Tag; use internal::mem::{Handle, HandleInternal, Managed}; use internal::scope::{Scope, RootScopeInternal}; use internal::vm::{VmResult, Throw, JsResult, Isolate, IsolateInternal, CallbackInfo, Call, This, Kernel}; @@ -59,7 +59,7 @@ impl SuperType for JsObject { /// The trait shared by all JavaScript values. pub trait Value: ValueInternal { fn to_string<'a, T: Scope<'a>>(self, _: &mut T) -> JsResult<'a, JsString> { - build(|out| { unsafe { neon_sys::convert::to_string(out, self.to_raw()) } }) + build(|out| { unsafe { neon_runtime::convert::to_string(out, self.to_raw()) } }) } fn as_value<'a, T: Scope<'a>>(self, _: &mut T) -> Handle<'a, JsValue> { @@ -110,7 +110,7 @@ unsafe impl This for JsValue { impl<'a> Handle<'a, JsValue> { pub fn variant(self) -> Variant<'a> { - match unsafe { neon_sys::tag::of(self.to_raw()) } { + match unsafe { neon_runtime::tag::of(self.to_raw()) } { Tag::Null => Variant::Null(JsNull::new()), Tag::Undefined => Variant::Undefined(JsUndefined::new()), Tag::Boolean => Variant::Boolean(Handle::new(JsBoolean(self.to_raw()))), @@ -158,7 +158,7 @@ unsafe impl This for JsUndefined { fn as_this(_: raw::Local) -> Self { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::primitive::undefined(&mut local); + neon_runtime::primitive::undefined(&mut local); JsUndefined(local) } } @@ -166,7 +166,7 @@ unsafe impl This for JsUndefined { impl ValueInternal for JsUndefined { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_undefined(other.to_raw()) } + unsafe { neon_runtime::tag::is_undefined(other.to_raw()) } } } @@ -178,7 +178,7 @@ impl JsUndefinedInternal for JsUndefined { fn new_internal<'a>() -> Handle<'a, JsUndefined> { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::primitive::undefined(&mut local); + neon_runtime::primitive::undefined(&mut local); Handle::new(JsUndefined(local)) } } @@ -205,7 +205,7 @@ impl Managed for JsNull { impl ValueInternal for JsNull { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_null(other.to_raw()) } + unsafe { neon_runtime::tag::is_null(other.to_raw()) } } } @@ -217,7 +217,7 @@ impl JsNullInternal for JsNull { fn new_internal<'a>() -> Handle<'a, JsNull> { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::primitive::null(&mut local); + neon_runtime::primitive::null(&mut local); Handle::new(JsNull(local)) } } @@ -244,7 +244,7 @@ impl Managed for JsBoolean { impl ValueInternal for JsBoolean { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_boolean(other.to_raw()) } + unsafe { neon_runtime::tag::is_boolean(other.to_raw()) } } } @@ -256,7 +256,7 @@ impl JsBooleanInternal for JsBoolean { fn new_internal<'a>(b: bool) -> Handle<'a, JsBoolean> { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::primitive::boolean(&mut local, b); + neon_runtime::primitive::boolean(&mut local, b); Handle::new(JsBoolean(local)) } } @@ -265,7 +265,7 @@ impl JsBooleanInternal for JsBoolean { impl JsBoolean { pub fn value(self) -> bool { unsafe { - neon_sys::primitive::boolean_value(self.to_raw()) + neon_runtime::primitive::boolean_value(self.to_raw()) } } } @@ -285,24 +285,24 @@ impl Managed for JsString { impl ValueInternal for JsString { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_string(other.to_raw()) } + unsafe { neon_runtime::tag::is_string(other.to_raw()) } } } impl JsString { pub fn size(self) -> isize { unsafe { - neon_sys::string::utf8_len(self.to_raw()) + neon_runtime::string::utf8_len(self.to_raw()) } } pub fn value(self) -> String { unsafe { - let capacity = neon_sys::string::utf8_len(self.to_raw()); + let capacity = neon_runtime::string::utf8_len(self.to_raw()); let mut buffer: Vec = Vec::with_capacity(capacity as usize); let p = buffer.as_mut_ptr(); mem::forget(buffer); - let len = neon_sys::string::data(p, capacity, self.to_raw()); + let len = neon_runtime::string::data(p, capacity, self.to_raw()); String::from_raw_parts(p, len as usize, capacity as usize) } } @@ -369,7 +369,7 @@ impl JsStringInternal for JsString { }; unsafe { let mut local: raw::Local = mem::zeroed(); - if neon_sys::string::new(&mut local, isolate.to_raw(), ptr, len) { + if neon_runtime::string::new(&mut local, isolate.to_raw(), ptr, len) { Some(Handle::new(JsString(local))) } else { None @@ -401,7 +401,7 @@ impl Managed for JsInteger { impl ValueInternal for JsInteger { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_integer(other.to_raw()) } + unsafe { neon_runtime::tag::is_integer(other.to_raw()) } } } @@ -413,7 +413,7 @@ impl JsIntegerInternal for JsInteger { fn new_internal<'a>(isolate: Isolate, i: i32) -> Handle<'a, JsInteger> { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::primitive::integer(&mut local, isolate.to_raw(), i); + neon_runtime::primitive::integer(&mut local, isolate.to_raw(), i); Handle::new(JsInteger(local)) } } @@ -422,19 +422,19 @@ impl JsIntegerInternal for JsInteger { impl JsInteger { pub fn is_u32(self) -> bool { unsafe { - neon_sys::primitive::is_u32(self.to_raw()) + neon_runtime::primitive::is_u32(self.to_raw()) } } pub fn is_i32(self) -> bool { unsafe { - neon_sys::primitive::is_i32(self.to_raw()) + neon_runtime::primitive::is_i32(self.to_raw()) } } pub fn value(self) -> i64 { unsafe { - neon_sys::primitive::integer_value(self.to_raw()) + neon_runtime::primitive::integer_value(self.to_raw()) } } } @@ -460,7 +460,7 @@ impl Managed for JsNumber { impl ValueInternal for JsNumber { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_number(other.to_raw()) } + unsafe { neon_runtime::tag::is_number(other.to_raw()) } } } @@ -472,7 +472,7 @@ impl JsNumberInternal for JsNumber { fn new_internal<'a>(isolate: Isolate, v: f64) -> Handle<'a, JsNumber> { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::primitive::number(&mut local, isolate.to_raw(), v); + neon_runtime::primitive::number(&mut local, isolate.to_raw(), v); Handle::new(JsNumber(local)) } } @@ -481,7 +481,7 @@ impl JsNumberInternal for JsNumber { impl JsNumber { pub fn value(self) -> f64 { unsafe { - neon_sys::primitive::number_value(self.to_raw()) + neon_runtime::primitive::number_value(self.to_raw()) } } } @@ -505,7 +505,7 @@ unsafe impl This for JsObject { impl ValueInternal for JsObject { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_object(other.to_raw()) } + unsafe { neon_runtime::tag::is_object(other.to_raw()) } } } @@ -517,33 +517,33 @@ pub trait Key { impl Key for u32 { unsafe fn get(self, out: &mut raw::Local, obj: raw::Local) -> bool { - neon_sys::object::get_index(out, obj, self) + neon_runtime::object::get_index(out, obj, self) } unsafe fn set(self, out: &mut bool, obj: raw::Local, val: raw::Local) -> bool { - neon_sys::object::set_index(out, obj, self, val) + neon_runtime::object::set_index(out, obj, self, val) } } impl<'a, K: Value> Key for Handle<'a, K> { unsafe fn get(self, out: &mut raw::Local, obj: raw::Local) -> bool { - neon_sys::object::get(out, obj, self.to_raw()) + neon_runtime::object::get(out, obj, self.to_raw()) } unsafe fn set(self, out: &mut bool, obj: raw::Local, val: raw::Local) -> bool { - neon_sys::object::set(out, obj, self.to_raw(), val) + neon_runtime::object::set(out, obj, self.to_raw(), val) } } impl<'a> Key for &'a str { unsafe fn get(self, out: &mut raw::Local, obj: raw::Local) -> bool { let (ptr, len) = lower_str_unwrap(self); - neon_sys::object::get_string(out, obj, ptr, len) + neon_runtime::object::get_string(out, obj, ptr, len) } unsafe fn set(self, out: &mut bool, obj: raw::Local, val: raw::Local) -> bool { let (ptr, len) = lower_str_unwrap(self); - neon_sys::object::set_string(out, obj, ptr, len, val) + neon_runtime::object::set_string(out, obj, ptr, len, val) } } @@ -554,7 +554,7 @@ pub trait Object: Value { } fn get_own_property_names<'a, T: Scope<'a>>(self, _: &mut T) -> JsResult<'a, JsArray> { - build(|out| { unsafe { neon_sys::object::get_own_property_names(out, self.to_raw()) } }) + build(|out| { unsafe { neon_runtime::object::get_own_property_names(out, self.to_raw()) } }) } fn set(self, key: K, val: Handle) -> VmResult { @@ -576,7 +576,7 @@ pub trait JsObjectInternal { impl JsObjectInternal for JsObject { fn new_internal<'a>() -> Handle<'a, JsObject> { - JsObject::build(|out| { unsafe { neon_sys::object::new(out) } }) + JsObject::build(|out| { unsafe { neon_runtime::object::new(out) } }) } fn build<'a, F: FnOnce(&mut raw::Local)>(init: F) -> Handle<'a, JsObject> { @@ -617,7 +617,7 @@ impl Managed for JsArray { impl ValueInternal for JsArray { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_array(other.to_raw()) } + unsafe { neon_runtime::tag::is_array(other.to_raw()) } } } @@ -629,7 +629,7 @@ impl JsArrayInternal for JsArray { fn new_internal<'a>(isolate: Isolate, len: u32) -> Handle<'a, JsArray> { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::array::new(&mut local, isolate.to_raw(), len); + neon_runtime::array::new(&mut local, isolate.to_raw(), len); Handle::new(JsArray(local)) } } @@ -652,7 +652,7 @@ impl JsArray { pub fn len(self) -> u32 { unsafe { - neon_sys::array::len(self.to_raw()) + neon_runtime::array::len(self.to_raw()) } } } @@ -684,7 +684,7 @@ impl Kernel<()> for FunctionKernel { } unsafe fn from_wrapper(h: raw::Local) -> Self { - FunctionKernel(mem::transmute(neon_sys::fun::get_kernel(h))) + FunctionKernel(mem::transmute(neon_runtime::fun::get_kernel(h))) } fn as_ptr(self) -> *mut c_void { @@ -713,7 +713,7 @@ impl JsFunction { unsafe { let isolate: *mut c_void = mem::transmute(scope.isolate().to_raw()); let (callback, kernel) = FunctionKernel(f).export(); - neon_sys::fun::new(out, isolate, callback, kernel) + neon_runtime::fun::new(out, isolate, callback, kernel) } }) } @@ -729,7 +729,7 @@ impl JsFunction { let (isolate, argc, argv) = try!(unsafe { prepare_call(scope, &mut args) }); build(|out| { unsafe { - neon_sys::fun::call(out, isolate, self.to_raw(), this.to_raw(), argc, argv) + neon_runtime::fun::call(out, isolate, self.to_raw(), this.to_raw(), argc, argv) } }) } @@ -742,7 +742,7 @@ impl JsFunction { let (isolate, argc, argv) = try!(unsafe { prepare_call(scope, &mut args) }); build(|out| { unsafe { - neon_sys::fun::construct(out, isolate, self.to_raw(), argc, argv) + neon_runtime::fun::construct(out, isolate, self.to_raw(), argc, argv) } }) } @@ -763,6 +763,6 @@ impl Managed for JsFunction { impl ValueInternal for JsFunction { fn is_typeof(other: Other) -> bool { - unsafe { neon_sys::tag::is_function(other.to_raw()) } + unsafe { neon_runtime::tag::is_function(other.to_raw()) } } } diff --git a/src/internal/mem.rs b/src/internal/mem.rs index 49ccf688a..b3560a672 100644 --- a/src/internal/mem.rs +++ b/src/internal/mem.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; -use neon_sys; -use neon_sys::raw; +use neon_runtime; +use neon_runtime::raw; use internal::js::{Value, SuperType}; use internal::js::error::{JsError, Kind}; use internal::vm::{JsResult, Lock, LockState}; @@ -28,7 +28,7 @@ impl<'a, T: Value + 'a> Handle<'a, T> { impl<'a, T: Managed + 'a> PartialEq for Handle<'a, T> { fn eq(&self, other: &Self) -> bool { - unsafe { neon_sys::mem::same_handle(self.to_raw(), other.to_raw()) } + unsafe { neon_runtime::mem::same_handle(self.to_raw(), other.to_raw()) } } } diff --git a/src/internal/scope.rs b/src/internal/scope.rs index 9afdac3ad..e33e669a8 100644 --- a/src/internal/scope.rs +++ b/src/internal/scope.rs @@ -2,8 +2,8 @@ use std::mem; use std::os::raw::c_void; use std::marker::PhantomData; use std::cell::RefCell; -use neon_sys; -use neon_sys::raw; +use neon_runtime; +use neon_runtime::raw; use internal::mem::{Handle, HandleInternal}; use internal::js::Value; use internal::vm::{Isolate, IsolateInternal}; @@ -48,7 +48,7 @@ impl<'a, 'outer> ChainedScope<'a, 'outer> { pub fn escape(&self, local: Handle<'a, T>) -> Handle<'outer, T> { unsafe { let mut result_local: raw::Local = mem::zeroed(); - neon_sys::scope::escape(&mut result_local, self.v8, local.to_raw()); + neon_runtime::scope::escape(&mut result_local, self.v8, local.to_raw()); Handle::new(T::from_raw(result_local)) } } @@ -69,19 +69,19 @@ impl<'a> RootScopeInternal<'a> for RootScope<'a> { } fn with) -> T>(&'a mut self, f: F) -> T { - debug_assert!(unsafe { neon_sys::scope::size() } <= mem::size_of::()); - debug_assert!(unsafe { neon_sys::scope::alignment() } <= mem::align_of::()); + debug_assert!(unsafe { neon_runtime::scope::size() } <= mem::size_of::()); + debug_assert!(unsafe { neon_runtime::scope::alignment() } <= mem::align_of::()); let mut v8_scope = raw::HandleScope::new(); unsafe { - neon_sys::scope::enter(&mut v8_scope, self.isolate().to_raw()); + neon_runtime::scope::enter(&mut v8_scope, self.isolate().to_raw()); } let result = f(self); unsafe { - neon_sys::scope::exit(&mut v8_scope); + neon_runtime::scope::exit(&mut v8_scope); } result @@ -141,7 +141,7 @@ fn chain<'a, T, S, F>(outer: &S, f: F) -> T let closure: *mut c_void = mem::transmute(closure); let callback: extern "C" fn(&mut c_void, *mut c_void, *mut c_void, *mut c_void) = mem::transmute(callback); let this: *mut c_void = mem::transmute(outer); - neon_sys::scope::chained(out, closure, callback, this); + neon_runtime::scope::chained(out, closure, callback, this); } { *outer.active_cell().borrow_mut() = true; } } @@ -164,7 +164,7 @@ fn nest<'me, T, S, F>(outer: &'me S, f: F) -> T let closure: *mut c_void = mem::transmute(closure); let callback: extern "C" fn(&mut c_void, *mut c_void, *mut c_void) = mem::transmute(callback); let isolate: *mut c_void = mem::transmute(outer.isolate()); - neon_sys::scope::nested(out, closure, callback, isolate); + neon_runtime::scope::nested(out, closure, callback, isolate); } { *outer.active_cell().borrow_mut() = true; } } diff --git a/src/internal/vm.rs b/src/internal/vm.rs index 7cd5c0d32..c7d896715 100644 --- a/src/internal/vm.rs +++ b/src/internal/vm.rs @@ -4,8 +4,8 @@ use std::marker::PhantomData; use std::collections::{HashSet, HashMap}; use std::os::raw::c_void; use cslice::CMutSlice; -use neon_sys; -use neon_sys::raw; +use neon_runtime; +use neon_runtime::raw; use internal::scope::{Scope, RootScope, RootScopeInternal}; use internal::js::{JsValue, Value, Object, JsObject, JsFunction}; use internal::js::class::ClassMetadata; @@ -57,14 +57,14 @@ impl IsolateInternal for Isolate { } fn class_map(&mut self) -> &mut ClassMap { - let mut ptr: *mut c_void = unsafe { neon_sys::class::get_class_map(self.to_raw()) }; + let mut ptr: *mut c_void = unsafe { neon_runtime::class::get_class_map(self.to_raw()) }; if ptr.is_null() { let b: Box = Box::new(ClassMap::new()); let raw = Box::into_raw(b); ptr = unsafe { mem::transmute(raw) }; let free_map: *mut c_void = unsafe { mem::transmute(drop_class_map as usize) }; unsafe { - neon_sys::class::set_class_map(self.to_raw(), ptr, free_map); + neon_runtime::class::set_class_map(self.to_raw(), ptr, free_map); } } unsafe { mem::transmute(ptr) } @@ -85,20 +85,20 @@ impl CallbackInfo { pub fn data<'a>(&self) -> Handle<'a, JsValue> { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::call::data(&self.info, &mut local); + neon_runtime::call::data(&self.info, &mut local); Handle::new(JsValue::from_raw(local)) } } pub fn scope(&self) -> RootScope { RootScope::new(unsafe { - mem::transmute(neon_sys::call::get_isolate(mem::transmute(self))) + mem::transmute(neon_runtime::call::get_isolate(mem::transmute(self))) }) } pub fn set_return<'a, 'b, T: Value>(&'a self, value: Handle<'b, T>) { unsafe { - neon_sys::call::set_return(&self.info, value.to_raw()) + neon_runtime::call::set_return(&self.info, value.to_raw()) } } @@ -114,7 +114,7 @@ impl CallbackInfo { } fn kind(&self) -> CallKind { - if unsafe { neon_sys::call::is_construct(mem::transmute(self)) } { + if unsafe { neon_runtime::call::is_construct(mem::transmute(self)) } { CallKind::Construct } else { CallKind::Call @@ -123,7 +123,7 @@ impl CallbackInfo { pub fn len(&self) -> i32 { unsafe { - neon_sys::call::len(&self.info) + neon_runtime::call::len(&self.info) } } @@ -133,7 +133,7 @@ impl CallbackInfo { } unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::call::get(&self.info, i, &mut local); + neon_runtime::call::get(&self.info, i, &mut local); Some(Handle::new(JsValue::from_raw(local))) } } @@ -144,7 +144,7 @@ impl CallbackInfo { } unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::call::get(&self.info, i, &mut local); + neon_runtime::call::get(&self.info, i, &mut local); Ok(Handle::new(JsValue::from_raw(local))) } } @@ -152,7 +152,7 @@ impl CallbackInfo { pub fn this<'b, T: Scope<'b>>(&self, _: &mut T) -> raw::Local { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::call::this(mem::transmute(&self.info), &mut local); + neon_runtime::call::this(mem::transmute(&self.info), &mut local); local } } @@ -160,7 +160,7 @@ impl CallbackInfo { pub fn callee<'a, T: Scope<'a>>(&self, _: &mut T) -> Handle<'a, JsFunction> { unsafe { let mut local: raw::Local = mem::zeroed(); - neon_sys::call::callee(mem::transmute(&self.info), &mut local); + neon_runtime::call::callee(mem::transmute(&self.info), &mut local); Handle::new(JsFunction::from_raw(local)) } } @@ -173,13 +173,13 @@ pub struct Module<'a> { impl<'a> Module<'a> { pub fn initialize(exports: Handle, init: fn(Module) -> VmResult<()>) { - let mut scope = RootScope::new(unsafe { mem::transmute(neon_sys::object::get_isolate(exports.to_raw())) }); + let mut scope = RootScope::new(unsafe { mem::transmute(neon_runtime::object::get_isolate(exports.to_raw())) }); unsafe { let kernel: *mut c_void = mem::transmute(init); let callback: extern "C" fn(*mut c_void, *mut c_void, *mut c_void) = mem::transmute(module_callback as usize); let exports: raw::Local = exports.to_raw(); let scope: *mut c_void = mem::transmute(&mut scope); - neon_sys::module::exec_kernel(kernel, callback, exports, scope); + neon_runtime::module::exec_kernel(kernel, callback, exports, scope); } } } diff --git a/src/lib.rs b/src/lib.rs index 9a0898ee9..1825f7ddc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ //! The `neon` crate provides the entire [Neon](https://www.neon-bindings.com/) API. -extern crate neon_sys; +extern crate neon_runtime; extern crate cslice; mod internal; diff --git a/src/macro_internal/mod.rs b/src/macro_internal/mod.rs index 70329f86e..7f979bca4 100644 --- a/src/macro_internal/mod.rs +++ b/src/macro_internal/mod.rs @@ -4,7 +4,7 @@ // Used by the class macro. pub use internal::js::class::{AllocateKernel, ConstructKernel, ConstructorCallKernel, MethodKernel}; -// An alias for neon_sys so macros can refer to it. +// An alias for neon_runtime so macros can refer to it. pub mod sys { - pub use neon_sys::*; + pub use neon_runtime::*; }