feat!: introduce tree-sitter-language crate for grammar crates to depend on
Co-authored-by: Conrad <conrad@zed.dev> Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
This commit is contained in:
parent
04b9eb5700
commit
38137c71b2
9 changed files with 110 additions and 18 deletions
|
|
@ -22,6 +22,8 @@ use std::{
|
|||
sync::atomic::AtomicUsize,
|
||||
};
|
||||
|
||||
use tree_sitter_language::LanguageFn;
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
mod wasm_language;
|
||||
#[cfg(feature = "wasm")]
|
||||
|
|
@ -284,6 +286,10 @@ pub struct LossyUtf8<'a> {
|
|||
}
|
||||
|
||||
impl Language {
|
||||
pub fn new(builder: LanguageFn) -> Self {
|
||||
Self(unsafe { (builder.into_raw())() as _ })
|
||||
}
|
||||
|
||||
/// Get the ABI version number that indicates which version of the
|
||||
/// Tree-sitter CLI that was used to generate this [`Language`].
|
||||
#[doc(alias = "ts_language_version")]
|
||||
|
|
@ -406,6 +412,12 @@ impl Language {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<LanguageFn> for Language {
|
||||
fn from(value: LanguageFn) -> Self {
|
||||
Self::new(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for Language {
|
||||
fn clone(&self) -> Self {
|
||||
unsafe { Self(ffi::ts_language_copy(self.0)) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue