tirbofish/dropbear · commit
8a4219390dff899e7d6fcd0ecd0cd497b726884e
completed the Kotlin/Native part of the three functions, hopefully it works (haven't tested it yet).
todo: gotta work on the library loading of the project and work on more API's.
Signature present but could not be verified.
Unverified
@@ -1,17 +1,27 @@ //! Deals with Kotlin/Native library loading for different platforms. +#![allow(clippy::missing_safety_doc)] -use dropbear_engine::entity::AdoptedEntity; +use dropbear_engine::entity::{AdoptedEntity, Transform}; use std::ffi::{CStr, c_char}; -/// Looks up an entity by its string label in the given world and writes the result to `out_entity`. -/// -/// # Safety -/// -/// - `label` must be a valid null-terminated C string. -/// - `world_ptr` must be a non-null pointer to a valid, initialized `hecs::World` -/// that is not being mutably aliased (i.e., no concurrent mutable access). -/// - `out_entity` must be a non-null pointer to a `uint64_t` (`u64`) that the caller owns. -/// - The `hecs::World` must outlive the duration of this call. +/// Displays the types of errors that can be returned by the native library. +pub enum DropbearNativeError { + Success = 0, + NullPointer = -1, + QueryFailed = -2, + EntityNotFound = -3, + NoSuchComponent = -4, + NoSuchEntity = -5, + WorldInsertError = -6, + + InvalidUTF8 = -108, + /// A generic error when the library doesn't know what happened or cannot find a + /// suitable error code. + /// + /// The number `1274` comes from the total sum of the word "UnknownError" into decimal + UnknownError = -1274, +} + #[unsafe(no_mangle)] pub unsafe extern "C" fn dropbear_get_entity( label: *const c_char, @@ -20,7 +30,7 @@ pub unsafe extern "C" fn dropbear_get_entity( ) -> i32 { unsafe { if label.is_null() || world_ptr.is_null() || out_entity.is_null() { - log::warn!("dropbear_get_entity: received null pointer"); + println!("[dropbear_get_entity] [ERROR] received null pointer"); return -1; }
Large diffs are not rendered by default. Showing the first 50 of 279 lines. Show full diff