Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename neon-sys to neon-runtime #183

Merged
merged 2 commits into from
Feb 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "neon-sys"
name = "neon-runtime"
version = "0.1.11"
authors = ["Dave Herman <dherman@mozilla.com>"]
description = "Exposes Node and V8 C++ API's for use by Neon."
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/internal/js/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ 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)]
pub struct JsBuffer(raw::Local);

impl JsBuffer {
pub fn new<'a, T: Scope<'a>>(_: &mut T, size: u32) -> VmResult<Handle<'a, JsBuffer>> {
build(|out| { unsafe { neon_sys::buffer::new(out, size) } })
build(|out| { unsafe { neon_runtime::buffer::new(out, size) } })
}
}

Expand All @@ -26,7 +26,7 @@ impl Managed for JsBuffer {

impl ValueInternal for JsBuffer {
fn is_typeof<Other: Value>(other: Other) -> bool {
unsafe { neon_sys::tag::is_buffer(other.to_raw()) }
unsafe { neon_runtime::tag::is_buffer(other.to_raw()) }
}
}

Expand All @@ -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
}
Expand Down
44 changes: 22 additions & 22 deletions src/internal/js/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -31,7 +31,7 @@ impl<T: Class> Kernel<()> for MethodKernel<T> {
if !this.is_a::<T>() {
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;
Expand All @@ -44,7 +44,7 @@ impl<T: Class> Kernel<()> for MethodKernel<T> {
}

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 {
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -117,7 +117,7 @@ impl<T: Class> Kernel<*mut c_void> for AllocateKernel<T> {
}

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 {
Expand Down Expand Up @@ -152,7 +152,7 @@ impl<T: Class> Kernel<bool> for ConstructKernel<T> {
}

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 {
Expand Down Expand Up @@ -255,11 +255,11 @@ pub trait ClassInternal: Class {
None => (mem::transmute(ConstructorCallKernel::unimplemented::<Self> 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::<Self::Internals>);
let metadata_pointer = neon_runtime::class::create_base(isolate,
allocate_callback, allocate_kernel,
construct_callback, construct_kernel,
call_callback, call_kernel,
drop_internals::<Self::Internals>);

if metadata_pointer.is_null() {
return Err(Throw);
Expand All @@ -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<JsValue> = 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);
}
}
Expand All @@ -299,7 +299,7 @@ impl<T: Class> ClassInternal for T { }
impl<T: Class> ValueInternal for T {
fn is_typeof<Other: Value>(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::<T>()) {
Expand Down Expand Up @@ -329,22 +329,22 @@ pub struct ClassMetadata {
impl ClassMetadata {
pub unsafe fn class<'a, T: Class, U: Scope<'a>>(&self, scope: &mut U) -> Handle<'a, JsClass<T>> {
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
})
}

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<T: Class> JsClass<T> {
pub fn check<U: Value>(&self, v: Handle<U>, msg: &str) -> JsResult<T> {
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)
Expand All @@ -354,7 +354,7 @@ impl<T: Class> JsClass<T> {
pub fn constructor<'a, U: Scope<'a>>(&self, _: &mut U) -> JsResult<'a, JsFunction<T>> {
build(|out| {
unsafe {
neon_sys::class::constructor(out, self.to_raw())
neon_runtime::class::constructor(out, self.to_raw())
}
})
}
Expand All @@ -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)
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/internal/js/error.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -11,7 +11,7 @@ use scope::Scope;

pub fn throw<'a, T: Value, U>(v: Handle<'a, T>) -> VmResult<U> {
unsafe {
neon_sys::error::throw(v.to_raw());
neon_runtime::error::throw(v.to_raw());
}
Err(Throw)
}
Expand All @@ -28,7 +28,7 @@ impl Managed for JsError {

impl ValueInternal for JsError {
fn is_typeof<Other: Value>(other: Other) -> bool {
unsafe { neon_sys::tag::is_error(other.to_raw()) }
unsafe { neon_runtime::tag::is_error(other.to_raw()) }
}
}

Expand All @@ -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
Expand All @@ -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)
Expand Down
Loading