2024-08-06 23:30:00 +02:00
|
|
|
package mp.code;
|
|
|
|
|
|
|
|
import mp.code.data.TextChange;
|
2024-08-07 02:43:25 +02:00
|
|
|
import mp.code.exceptions.CodeMPException;
|
2024-08-06 23:30:00 +02:00
|
|
|
|
|
|
|
public class BufferController {
|
|
|
|
private final long ptr;
|
|
|
|
|
|
|
|
BufferController(long ptr) {
|
|
|
|
this.ptr = ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static native String get_name(long self);
|
|
|
|
public String getName() {
|
|
|
|
return get_name(this.ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static native String get_content(long self);
|
|
|
|
public String getContent() {
|
|
|
|
return get_content(this.ptr);
|
|
|
|
}
|
|
|
|
|
2024-08-07 02:43:25 +02:00
|
|
|
private static native TextChange try_recv(long self) throws CodeMPException;
|
|
|
|
public TextChange tryRecv() throws CodeMPException {
|
2024-08-06 23:30:00 +02:00
|
|
|
return try_recv(this.ptr);
|
|
|
|
}
|
|
|
|
|
2024-08-07 02:43:25 +02:00
|
|
|
private static native void send(long self, TextChange change) throws CodeMPException;
|
|
|
|
public void send(TextChange change) throws CodeMPException {
|
2024-08-06 23:30:00 +02:00
|
|
|
send(this.ptr, change);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static native void free(long self);
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings("removal")
|
2024-08-07 02:43:25 +02:00
|
|
|
protected void finalize() {
|
2024-08-06 23:30:00 +02:00
|
|
|
free(this.ptr);
|
|
|
|
}
|
|
|
|
}
|