dmsc/java/classes/
gateway.rs

1//! Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
2//!
3//! This file is part of DMSC.
4//! The DMSC project belongs to the Dunimd Team.
5//!
6//! Licensed under the Apache License, Version 2.0 (the "License");
7//! You may not use this file except in compliance with the License.
8//! You may obtain a copy of the License at
9//!
10//!     http://www.apache.org/licenses/LICENSE-2.0
11//!
12//! Unless required by applicable law or agreed to in writing, software
13//! distributed under the License is distributed on an "AS IS" BASIS,
14//! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15//! See the License for the specific language governing permissions and
16//! limitations under the License.
17
18//! # Gateway Module JNI Bindings
19//!
20//! JNI bindings for DMSC gateway classes.
21
22use jni::JNIEnv;
23use jni::objects::JClass;
24use jni::sys::jlong;
25use crate::gateway::{DMSCGateway, DMSCGatewayConfig};
26
27#[no_mangle]
28pub extern "system" fn Java_com_dunimd_dmsc_gateway_DMSCGateway_new0(
29    _env: JNIEnv,
30    _class: JClass,
31) -> jlong {
32    let gateway = Box::new(DMSCGateway::new());
33    Box::into_raw(gateway) as jlong
34}
35
36#[no_mangle]
37pub extern "system" fn Java_com_dunimd_dmsc_gateway_DMSCGateway_free0(
38    _env: JNIEnv,
39    _class: JClass,
40    ptr: jlong,
41) {
42    if ptr != 0 {
43        unsafe {
44            let _ = Box::from_raw(ptr as *mut DMSCGateway);
45        }
46    }
47}
48
49#[no_mangle]
50pub extern "system" fn Java_com_dunimd_dmsc_gateway_DMSCGatewayConfig_new0(
51    _env: JNIEnv,
52    _class: JClass,
53) -> jlong {
54    let config = Box::new(DMSCGatewayConfig::default());
55    Box::into_raw(config) as jlong
56}
57
58#[no_mangle]
59pub extern "system" fn Java_com_dunimd_dmsc_gateway_DMSCGatewayConfig_free0(
60    _env: JNIEnv,
61    _class: JClass,
62    ptr: jlong,
63) {
64    if ptr != 0 {
65        unsafe {
66            let _ = Box::from_raw(ptr as *mut DMSCGatewayConfig);
67        }
68    }
69}