Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
napi: Move napi_env and napi_value to opaque_types.
Browse files Browse the repository at this point in the history
Internal change to prepare for the arkui native node napi bindings

Signed-off-by: Jonathan Schwender <[email protected]>
jschwe committed Jan 9, 2025

Verified

This commit was signed with the committer’s verified signature.
jschwe Jonathan Schwender
1 parent db399f5 commit 590fa68
Showing 5 changed files with 18 additions and 12 deletions.
10 changes: 10 additions & 0 deletions components/opaque-types/src/opaque_types.rs
Original file line number Diff line number Diff line change
@@ -4,6 +4,16 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

#[repr(C)]
pub struct napi_env__ {
_unused: [u8; 0],
}
pub type napi_env = *mut napi_env__;
#[repr(C)]
pub struct napi_value__ {
_unused: [u8; 0],
}
pub type napi_value = *mut napi_value__;
#[repr(C)]
pub struct OH_NativeBuffer {
_unused: [u8; 0],
1 change: 1 addition & 0 deletions components/opaque-types/wrapper.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "napi/native_api.h"
#include "native_buffer/native_buffer.h"
#include "multimedia/image_framework/image/pixelmap_native.h"
#include "multimedia/image_framework/image_pixel_map_mdk.h"
1 change: 1 addition & 0 deletions scripts/generator/src/main.rs
Original file line number Diff line number Diff line change
@@ -258,6 +258,7 @@ fn get_bindings_config(api_version: u32) -> Vec<BindingConf> {
.no_copy("napi_extended_error_info")
.no_copy("napi_node_version")
.no_copy("napi_module")
.raw_line("pub use ohos_sys_opaque_types::{napi_env, napi_value};")
}),
},
BindingConf {
6 changes: 5 additions & 1 deletion scripts/generator/src/opaque_types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub(crate) static OPAQUE_TYPES: [&str; 9] = [
pub(crate) static OPAQUE_TYPES: [&str; 13] = [
"OH_PixelmapNative",
"NativePixelMap_",
"OH_NativeBuffer",
@@ -8,4 +8,8 @@ pub(crate) static OPAQUE_TYPES: [&str; 9] = [
"OHNativeWindowBuffer",
"ArkUI_AccessibilityProvider",
"OH_NativeColorSpaceManager",
"napi_env",
"napi_env__",
"napi_value",
"napi_value__",
];
12 changes: 1 addition & 11 deletions src/napi/napi_ffi.rs
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
pub use ohos_sys_opaque_types::{napi_env, napi_value};

pub const NAPI_VERSION: u32 = 8;
pub const NAPI_VERSION_EXPERIMENTAL: u32 = 2147483647;
@@ -82,16 +83,6 @@ impl napi_task_priority {
pub struct napi_task_priority(pub ::core::ffi::c_uint);
pub type char16_t = u16;
#[repr(C)]
pub struct napi_env__ {
_unused: [u8; 0],
}
pub type napi_env = *mut napi_env__;
#[repr(C)]
pub struct napi_value__ {
_unused: [u8; 0],
}
pub type napi_value = *mut napi_value__;
#[repr(C)]
pub struct napi_ref__ {
_unused: [u8; 0],
}
@@ -298,7 +289,6 @@ pub type napi_finalize = ::core::option::Option<
),
>;
#[repr(C)]
#[derive(Debug)]
pub struct napi_property_descriptor {
pub utf8name: *const ::core::ffi::c_char,
pub name: napi_value,

0 comments on commit 590fa68

Please sign in to comment.