mirror of
https://github.com/hexedtech/codemp-intellij.git
synced 2024-11-21 14:44:49 +01:00
fix: include glue module
Co-authored-by: alemi <me@alemi.dev>
This commit is contained in:
parent
1b92d0052e
commit
4ed7704ff0
2 changed files with 30 additions and 24 deletions
|
@ -4,15 +4,16 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
codemp = { git = "ssh://git@github.com/codewithotherpeopleandchangenamelater/codemp.git", tag = "v0.4.5", features = ["global"] }
|
||||
codemp = { git = "ssh://git@github.com/codewithotherpeopleandchangenamelater/codemp.git", tag = "v0.4.5", features = ["global", "sync"] }
|
||||
jni = { version = "0.21.1", features = ["invocation"] }
|
||||
jni-sys = "0.3.0"
|
||||
log = "0.4.20"
|
||||
rifgen = { git = "https://github.com/Kofituo/rifgen.git", rev = "d27d9785b2febcf5527f1deb6a846be5d583f7d7"}
|
||||
|
||||
[build-dependencies]
|
||||
flapigen = "0.6.0"
|
||||
rifgen = { git = "https://github.com/Kofituo/rifgen.git", rev = "d27d9785b2febcf5527f1deb6a846be5d583f7d7"}
|
||||
|
||||
|
||||
[lib]
|
||||
crate_type = ["cdylib"]
|
||||
path = "src/main/rust/lib.rs"
|
||||
|
|
|
@ -5,58 +5,62 @@ use codemp::prelude::*;
|
|||
use rifgen::rifgen_attr::generate_interface;
|
||||
use crate::error::ErrorWrapper;
|
||||
|
||||
pub mod glue {
|
||||
include!(concat!(env!("OUT_DIR"), "/glue.rs"));
|
||||
}
|
||||
|
||||
// #[generate_interface_doc] //TODO
|
||||
struct CodeMPHandler {}
|
||||
|
||||
impl CodeMPHandler {
|
||||
#[generate_interface(constructor)]
|
||||
async fn new() -> CodeMPHandler {
|
||||
fn new() -> CodeMPHandler {
|
||||
CodeMPHandler {}
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
async fn connect(addr: String) -> Result<(), String> {
|
||||
convert(CODEMP_INSTANCE.connect(&addr).await)
|
||||
fn connect(addr: String) -> Result<(), String> {
|
||||
convert(CODEMP_INSTANCE.connect(&addr))
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
async fn join(session: String) -> Result<CursorHandler, String> {
|
||||
convert_cursor(CODEMP_INSTANCE.join(&session).await)
|
||||
fn join(session: String) -> Result<CursorHandler, String> {
|
||||
convert_cursor(CODEMP_INSTANCE.join(&session))
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
async fn create(path: String) -> Result<(), String> {
|
||||
convert(CODEMP_INSTANCE.create(&path, None).await)
|
||||
fn create(path: String) -> Result<(), String> {
|
||||
convert(CODEMP_INSTANCE.create(&path, None))
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
async fn create_with_content(path: String, content: String) -> Result<(), String> {
|
||||
convert(CODEMP_INSTANCE.create(&path, Some(&content)).await)
|
||||
fn create_with_content(path: String, content: String) -> Result<(), String> {
|
||||
convert(CODEMP_INSTANCE.create(&path, Some(&content)))
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
async fn attach(path: String) -> Result<BufferHandler, String> {
|
||||
convert_buffer(CODEMP_INSTANCE.attach(&path).await)
|
||||
fn attach(path: String) -> Result<BufferHandler, String> {
|
||||
convert_buffer(CODEMP_INSTANCE.attach(&path))
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
async fn get_cursor() -> Result<CursorHandler, String> {
|
||||
convert_cursor(CODEMP_INSTANCE.get_cursor().await)
|
||||
fn get_cursor() -> Result<CursorHandler, String> {
|
||||
convert_cursor(CODEMP_INSTANCE.get_cursor())
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
async fn get_buffer(path: String) -> Result<BufferHandler, String> {
|
||||
convert_buffer(CODEMP_INSTANCE.get_buffer(&path).await)
|
||||
fn get_buffer(path: String) -> Result<BufferHandler, String> {
|
||||
convert_buffer(CODEMP_INSTANCE.get_buffer(&path))
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
async fn leave_workspace() -> Result<(), String> {
|
||||
convert(CODEMP_INSTANCE.leave_workspace().await)
|
||||
fn leave_workspace() -> Result<(), String> {
|
||||
convert(CODEMP_INSTANCE.leave_workspace())
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
async fn disconnect_buffer(path: String) -> Result<bool, String> {
|
||||
convert(CODEMP_INSTANCE.disconnect_buffer(&path).await)
|
||||
fn disconnect_buffer(path: String) -> Result<bool, String> {
|
||||
convert(CODEMP_INSTANCE.disconnect_buffer(&path))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,24 +77,25 @@ fn convert<T>(result: Result<T, CodempError>) -> Result<T, String> {
|
|||
}
|
||||
|
||||
struct CursorHandler {
|
||||
#[allow(unused)]
|
||||
cursor: Option<Arc<CodempCursorController>>
|
||||
}
|
||||
|
||||
impl CursorHandler {
|
||||
#[generate_interface(constructor)]
|
||||
async fn new() -> CursorHandler { //TODO: this sucks but whatever
|
||||
fn new() -> CursorHandler { //TODO: this sucks but whatever
|
||||
panic!("Default constructor for CursrorHandler should never be called!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct BufferHandler {
|
||||
#[allow(unused)]
|
||||
buffer: Option<Arc<CodempBufferController>>
|
||||
}
|
||||
|
||||
impl BufferHandler {
|
||||
#[generate_interface(constructor)]
|
||||
async fn new() -> BufferHandler { //TODO: this sucks but whatever
|
||||
fn new() -> BufferHandler { //TODO: this sucks but whatever
|
||||
panic!("Default constructor for BufferHandler should never be called!")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue