Skip to content

Commit

Permalink
Merge pull request #70 from jeandudey/refactor/minor-fix
Browse files Browse the repository at this point in the history
Remove Lisp_Misc prefix from LispMiscType.
  • Loading branch information
Wilfred committed Jan 16, 2017
2 parents aa5b127 + 5034360 commit a6ff1b4
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions rust_src/src/lisp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl LispObject {
}

#[inline]
pub fn from_bool(v : bool) -> LispObject {
pub fn from_bool(v: bool) -> LispObject {
if v {
unsafe { Qt }
} else {
Expand Down Expand Up @@ -154,8 +154,8 @@ impl LispObject {
}

#[inline]
pub fn get_untaggedptr(self) -> * mut libc::c_void {
(self.to_raw() & VALMASK) as libc::intptr_t as * mut libc::c_void
pub fn get_untaggedptr(self) -> *mut libc::c_void {
(self.to_raw() & VALMASK) as libc::intptr_t as *mut libc::c_void
}
}

Expand All @@ -174,30 +174,30 @@ impl LispObject {
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub enum LispMiscType {
Lisp_Misc_Free = 0x5eab,
Lisp_Misc_Marker,
Lisp_Misc_Overlay,
Lisp_Misc_Save_Value,
Lisp_Misc_Finalizer,
Free = 0x5eab,
Marker,
Overlay,
SaveValue,
Finalizer,
}


// Lisp_Misc is a union. Now we don't really care about its variants except the
// super type layout. LispMisc is an unsized type for this, and LispMiscAny is
// super type layout. LispMisc is an unsized type for this, and LispMiscAny is
// only the header and a padding, which is consistent with the c version.
// directly creating and moving or copying this struct is simply wrong!
// If needed, we can calculate all variants size and allocate properly.

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct ExternalPtr<T>(* mut T);
pub struct ExternalPtr<T>(*mut T);

impl<T> ExternalPtr<T> {
pub fn new(p: *mut T) -> ExternalPtr<T> {
ExternalPtr(p)
}

pub fn as_ptr(&self) -> * const T {
pub fn as_ptr(&self) -> *const T {
self.0
}
}
Expand Down Expand Up @@ -275,7 +275,8 @@ impl LispObject {
#[inline]
pub fn is_fixnum(self) -> bool {
let ty = self.get_type();
(ty as u8 & ((LispType::Lisp_Int0 as u8) | !(LispType::Lisp_Int1 as u8))) == LispType::Lisp_Int0 as u8
(ty as u8 & ((LispType::Lisp_Int0 as u8) | !(LispType::Lisp_Int1 as u8))) ==
LispType::Lisp_Int0 as u8
}

/// TODO: Bignum support? (Current Emacs doesn't have it)
Expand Down Expand Up @@ -303,14 +304,14 @@ pub struct LispFloat {
}

#[repr(C)]
pub struct LispFloatChainRepr(* const LispFloat);
pub struct LispFloatChainRepr(*const LispFloat);

impl LispFloat {
pub fn as_data(&self) -> &EmacsDouble {
unsafe { &*(self.data.as_ptr() as * const EmacsDouble) }
unsafe { &*(self.data.as_ptr() as *const EmacsDouble) }
}
pub fn as_chain(&self) -> &LispFloatChainRepr {
unsafe { &*(self.data.as_ptr() as * const LispFloatChainRepr) }
unsafe { &*(self.data.as_ptr() as *const LispFloatChainRepr) }
}
}

Expand Down Expand Up @@ -717,7 +718,7 @@ pub fn CHECK_TYPE(ok: bool, predicate: LispObject, x: LispObject) {

#[allow(non_snake_case)]
pub fn MARKERP(a: LispObject) -> bool {
MISCP(a) && XMISCTYPE(a) == LispMiscType::Lisp_Misc_Marker
MISCP(a) && XMISCTYPE(a) == LispMiscType::Marker
}

#[allow(non_snake_case)]
Expand Down

0 comments on commit a6ff1b4

Please sign in to comment.