|
14 | 14 | // KIND, either express or implied. See the License for the |
15 | 15 | // specific language governing permissions and limitations |
16 | 16 | // under the License. |
17 | | -#![allow(non_upper_case_globals)] |
18 | | -#![allow(non_camel_case_types)] |
19 | | -#![allow(non_snake_case)] |
20 | | -#![allow(dead_code)] |
21 | 17 |
|
22 | | -include!(concat!(env!("OUT_DIR"), "/bindings.rs")); |
| 18 | +use std::os::raw::{c_char, c_int, c_void}; |
| 19 | + |
| 20 | +#[repr(C)] |
| 21 | +pub struct ArrowSchema { |
| 22 | + _private: [u8; 0], |
| 23 | +} |
| 24 | + |
| 25 | +#[repr(C)] |
| 26 | +pub struct ArrowArray { |
| 27 | + _private: [u8; 0], |
| 28 | +} |
| 29 | + |
| 30 | +#[repr(C)] |
| 31 | +#[derive(Debug, Copy, Clone)] |
| 32 | +pub struct SedonaGeographyArrowUdf { |
| 33 | + pub init: Option< |
| 34 | + unsafe extern "C" fn( |
| 35 | + self_: *mut SedonaGeographyArrowUdf, |
| 36 | + arg_schema: *mut ArrowSchema, |
| 37 | + options: *const c_char, |
| 38 | + out: *mut ArrowSchema, |
| 39 | + ) -> c_int, |
| 40 | + >, |
| 41 | + pub execute: Option< |
| 42 | + unsafe extern "C" fn( |
| 43 | + self_: *mut SedonaGeographyArrowUdf, |
| 44 | + args: *mut *mut ArrowArray, |
| 45 | + n_args: i64, |
| 46 | + out: *mut ArrowArray, |
| 47 | + ) -> c_int, |
| 48 | + >, |
| 49 | + pub get_last_error: |
| 50 | + Option<unsafe extern "C" fn(self_: *mut SedonaGeographyArrowUdf) -> *const c_char>, |
| 51 | + pub release: Option<unsafe extern "C" fn(self_: *mut SedonaGeographyArrowUdf)>, |
| 52 | + pub private_data: *mut c_void, |
| 53 | +} |
| 54 | + |
| 55 | +macro_rules! declare_s2_c_udfs { |
| 56 | + ($($name:ident),*) => { |
| 57 | + $( |
| 58 | + paste::item! { |
| 59 | + pub fn [<SedonaGeographyInitUdf $name>](out: *mut SedonaGeographyArrowUdf); |
| 60 | + } |
| 61 | + )* |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +unsafe extern "C" { |
| 66 | + pub fn SedonaGeographyGlueNanoarrowVersion() -> *const c_char; |
| 67 | + pub fn SedonaGeographyGlueGeoArrowVersion() -> *const c_char; |
| 68 | + pub fn SedonaGeographyGlueOpenSSLVersion() -> *const c_char; |
| 69 | + pub fn SedonaGeographyGlueS2GeometryVersion() -> *const c_char; |
| 70 | + pub fn SedonaGeographyGlueAbseilVersion() -> *const c_char; |
| 71 | + pub fn SedonaGeographyGlueTestLinkage() -> f64; |
| 72 | + |
| 73 | + declare_s2_c_udfs!( |
| 74 | + Area, |
| 75 | + Centroid, |
| 76 | + ClosestPoint, |
| 77 | + Contains, |
| 78 | + ConvexHull, |
| 79 | + Difference, |
| 80 | + Distance, |
| 81 | + Equals, |
| 82 | + Intersection, |
| 83 | + Intersects, |
| 84 | + Length, |
| 85 | + LineInterpolatePoint, |
| 86 | + LineLocatePoint, |
| 87 | + MaxDistance, |
| 88 | + Perimeter, |
| 89 | + ShortestLine, |
| 90 | + SymDifference, |
| 91 | + Union |
| 92 | + ); |
| 93 | +} |
0 commit comments