Skip to content

Commit

Permalink
Consolidate function into list module and fix incorrect function sign…
Browse files Browse the repository at this point in the history
…ature
  • Loading branch information
mfeckie committed Jan 14, 2017
1 parent de795e2 commit f829daf
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 41 deletions.
20 changes: 0 additions & 20 deletions rust_src/src/atom.rs

This file was deleted.

5 changes: 2 additions & 3 deletions rust_src/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ mod cons;
mod strings;
mod symbols;
mod globals;
mod atom;

use lisp::LispSubr;

Expand All @@ -43,9 +42,10 @@ extern "C" {
#[no_mangle]
pub extern "C" fn rust_init_syms() {
unsafe {
defsubr(&*atom::Satom);
defsubr(&*list::Satom);
defsubr(&*list::Slistp);
defsubr(&*list::Snlistp);
defsubr(&*list::Snull);
defsubr(&*math::Smod);
defsubr(&*math::Splus);
defsubr(&*math::Sminus);
Expand All @@ -63,6 +63,5 @@ pub extern "C" fn rust_init_syms() {
defsubr(&*cons::Scar);
defsubr(&*strings::Sstringp);
defsubr(&*strings::Seq);
defsubr(&*strings::Snull);
}
}
35 changes: 33 additions & 2 deletions rust_src/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@ extern crate libc;
use lisp::{LispObject, LispSubr, Qnil, Qt, VectorLikeHeader, PvecType, PSEUDOVECTOR_AREA_BITS};
use cons::{CONSP, NILP};

fn Fatom(object: LispObject) -> LispObject {
if CONSP(object) {
Qnil
} else {
unsafe { Qt }
}
}

defun!("atom", Fatom, Satom, 1, 1, ptr::null(),
"Return t if OBJECT is not a cons cell. This includes nil. (fn OBJECT)");

fn Fnull(object: LispObject) -> LispObject {
if object == Qnil {
unsafe {
Qt
}
} else {
Qnil
}
}

defun!("null", Fnull, Snull, 1, 1, ptr::null(), "Return t if OBJECT is nil, and return nil otherwise.
(fn OBJECT)");



fn Flistp(object: LispObject) -> LispObject {
if CONSP(object) || NILP(object) {
unsafe { Qt }
Expand All @@ -19,7 +46,9 @@ defun!("listp",
Slistp,
1, 1,
ptr::null(),
"Return t if OBJECT is a list, that is, a cons cell or nil. Otherwise, return nil.");
"Return t if OBJECT is a list, that is, a cons cell or nil. Otherwise, return nil.
(fn OBJECT)");

fn Fnlistp(object: LispObject) -> LispObject {
if CONSP(object) || NILP (object) {
Expand All @@ -34,4 +63,6 @@ defun!("nlistp",
Snlistp,
1, 1,
ptr::null(),
"Return t if OBJECT is not a list. Lists include nil. ");
"Return t if OBJECT is not a list. Lists include nil.
(fn OBJECT)");
14 changes: 0 additions & 14 deletions rust_src/src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,3 @@ fn Feq (firstObject: LispObject, secondObject: LispObject) -> LispObject {
defun!("eq", Feq, Seq, 2, 2, ptr::null(), "Return t if the two args are the same Lisp object.
(fn OBJECT OBJECT)");

fn Fnull(object: LispObject) -> LispObject {
if object == Qnil {
unsafe {
Qt
}
} else {
Qnil
}
}

defun!("null", Fnull, Snull, 1, 1, ptr::null(), "Return t if OBJECT is nil, and return nil otherwise.
(fn OBJECT)");
4 changes: 2 additions & 2 deletions src/lisp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1277,8 +1277,8 @@ Lisp_Object Fsetcar(Lisp_Object, Lisp_Object);
Lisp_Object Fsetcdr(Lisp_Object, Lisp_Object);
Lisp_Object Fcar(Lisp_Object);
Lisp_Object Fatom(Lisp_Object);
Lisp_Object Flistp(Lisp_Object, Lisp_Object);
Lisp_Object Fnlistp(Lisp_Object, Lisp_Object);
Lisp_Object Flistp(Lisp_Object);
Lisp_Object Fnlistp(Lisp_Object);

/* In a string or vector, the sign bit of the `size' is the gc mark bit. */

Expand Down

0 comments on commit f829daf

Please sign in to comment.