-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2f1cbd
commit 31a4f05
Showing
6 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::ptr::null_mut; | ||
use std::sync::Arc; | ||
|
||
use jni::JNIEnv; | ||
use jni::objects::JClass; | ||
use jni::sys::{jboolean, jdoubleArray, jlong}; | ||
use surrealdb::sql::{Geometry, Value}; | ||
|
||
use crate::{get_value_instance, new_double_point}; | ||
use crate::error::SurrealError; | ||
|
||
#[no_mangle] | ||
pub extern "system" fn Java_com_surrealdb_Geometry_isPoint<'local>( | ||
mut env: JNIEnv<'local>, | ||
_class: JClass<'local>, | ||
id: jlong, | ||
) -> jboolean { | ||
let value = get_value_instance!(&mut env, id, ||false as jboolean); | ||
if let Value::Geometry(g) = value.as_ref() { | ||
g.is_point() as jboolean | ||
} else { | ||
SurrealError::NullPointerException("Thing").exception(&mut env, || false as jboolean) | ||
} | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "system" fn Java_com_surrealdb_Geometry_getPoint<'local>( | ||
mut env: JNIEnv<'local>, | ||
_class: JClass<'local>, | ||
id: jlong, | ||
) -> jdoubleArray { | ||
let value = get_value_instance!(&mut env, id, ||null_mut()); | ||
if let Value::Geometry(g) = value.as_ref() { | ||
if let Geometry::Point(pt) = &g { | ||
return new_double_point!(&mut env, pt, ||null_mut()); | ||
} | ||
} | ||
SurrealError::NullPointerException("Geometry/Point").exception(&mut env, || null_mut()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ mod object; | |
mod array; | ||
mod thing; | ||
mod id; | ||
mod geometry; | ||
|
||
|
||
static TOKIO_RUNTIME: Lazy<Runtime> = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters