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

Port category-table and category-table-p to rust #282

Merged
merged 1 commit into from Aug 5, 2017
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -1316,6 +1316,7 @@ extern "C" {
pub static Qframe: Lisp_Object;
pub static Qvector: Lisp_Object;
pub static Qchar_table: Lisp_Object;
pub static Qcategory_table: Lisp_Object;
pub static Qbool_vector: Lisp_Object;
pub static Qhash_table: Lisp_Object;
pub static Qthread: Lisp_Object;
@@ -0,0 +1,22 @@
//! Routines to deal with category tables.

use remacs_macros::lisp_fn;
use remacs_sys::Qcategory_table;
use lisp::LispObject;
use threads::ThreadState;

/// Return t if ARG is a category table.
#[lisp_fn]
fn category_table_p(arg: LispObject) -> LispObject {
LispObject::from_bool(arg.as_char_table().map_or(false, |table| {
LispObject::from_raw(table.purpose).eq(unsafe { LispObject::from_raw(Qcategory_table) })
}))
}

/// Return the current category table.
/// This is the one specified by the current buffer.
#[lisp_fn]
fn category_table() -> LispObject {
let buffer_ref = ThreadState::current_buffer();
LispObject::from_raw(buffer_ref.category_table)
}
@@ -48,6 +48,7 @@ mod process;
mod fonts;
mod threads;
mod chartable;
mod category;

#[cfg(all(not(test), target_os = "macos"))]
use alloc_unexecmacosx::OsxUnexecAlloc;
@@ -126,6 +127,9 @@ pub use buffers::Fcurrent_buffer;
// used in chartab.c
pub use chartable::Fset_char_table_parent;

// used in category.c
pub use category::Fcategory_table_p;

// Used in process.c
pub use str2sig::str2sig;
pub use process::Fget_process;
@@ -264,6 +268,8 @@ pub extern "C" fn rust_init_syms() {
defsubr(&*chartable::Schar_table_subtype);
defsubr(&*chartable::Schar_table_parent);
defsubr(&*chartable::Sset_char_table_parent);
defsubr(&*category::Scategory_table_p);
defsubr(&*category::Scategory_table);

defsubr(&*floatfns::Sisnan);
defsubr(&*floatfns::Sacos);
@@ -173,16 +173,6 @@ it defaults to the current buffer's category table. */)

/* Category-table staff. */

DEFUN ("category-table-p", Fcategory_table_p, Scategory_table_p, 1, 1, 0,
doc: /* Return t if ARG is a category table. */)
(Lisp_Object arg)
{
if (CHAR_TABLE_P (arg)
&& EQ (XCHAR_TABLE (arg)->purpose, Qcategory_table))
return Qt;
return Qnil;
}

/* If TABLE is nil, return the current category table. If TABLE is
not nil, check the validity of TABLE as a category table. If
valid, return TABLE itself, but if not valid, signal an error of
@@ -197,14 +187,6 @@ check_category_table (Lisp_Object table)
return table;
}

DEFUN ("category-table", Fcategory_table, Scategory_table, 0, 0, 0,
doc: /* Return the current category table.
This is the one specified by the current buffer. */)
(void)
{
return BVAR (current_buffer, category_table);
}

DEFUN ("standard-category-table", Fstandard_category_table,
Sstandard_category_table, 0, 0, 0,
doc: /* Return the standard category table.
@@ -504,8 +486,6 @@ See the documentation of the variable `word-combining-categories'. */);
defsubr (&Sdefine_category);
defsubr (&Scategory_docstring);
defsubr (&Sget_unused_category);
defsubr (&Scategory_table_p);
defsubr (&Scategory_table);
defsubr (&Sstandard_category_table);
defsubr (&Scopy_category_table);
defsubr (&Smake_category_table);
ProTip! Use n and p to navigate between commits in a pull request.