Skip to content

Commit

Permalink
Add support for querying the syntaxdot version
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldk authored and Daniël de Kok committed Feb 2, 2021
1 parent 227788b commit c0c7fe4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 110 deletions.
125 changes: 16 additions & 109 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ prost-build = "0.6"
pretty_assertions = "0.6"

[features]
model-tests = []
model-tests = []

[patch.crates-io]
tch = { git = "https://github.com/LaurentMazare/tch-rs.git" }
7 changes: 7 additions & 0 deletions include/syntaxdot.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ void syntaxdot_set_num_intraop_threads(int32_t n_threads);
*/
void syntaxdot_set_num_intraop_threads(int32_t n_threads);

/**
* Get the syntaxdot version.
*
* The returned string must not be deallocated.
*/
char const *syntaxdot_version();

/**
* Free a <tt>ByteBuffer</tt>.
* @param buf The buffer to free.
Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ use annotator::Annotator;

mod error;
use error::AnnotatorError;
use std::ffi::CString;
use std::os::raw::c_char;

pub mod sentences;

mod util;

lazy_static! {
static ref ANNOTATORS: ConcurrentHandleMap<Annotator> = ConcurrentHandleMap::new();
static ref SYNTAXDOT_VERSION: CString = CString::new(syntaxdot::VERSION).unwrap();
}

define_bytebuffer_destructor!(syntaxdot_free_bytebuffer);
Expand Down Expand Up @@ -81,6 +84,14 @@ pub extern "C" fn syntaxdot_set_num_intraop_threads(n_threads: i32) {
tch::set_num_threads(n_threads);
}

/// Get the syntaxdot version.
///
/// The returned string must not be deallocated.
#[no_mangle]
pub extern "C" fn syntaxdot_version() -> *const c_char {
SYNTAXDOT_VERSION.as_ptr()
}

#[cfg(test)]
mod tests {
use std::ffi::CString;
Expand Down

0 comments on commit c0c7fe4

Please sign in to comment.