diff --git a/config/cbindgen.toml b/config/cbindgen.toml deleted file mode 100644 index a71366a..0000000 --- a/config/cbindgen.toml +++ /dev/null @@ -1,157 +0,0 @@ -language = "C" -header = "// Copyright (c) Tribufu. All Rights Reserved.\n// SPDX-License-Identifier: MIT" -pragma_once = true -include_version = false -namespaces = [] -using_namespaces = [] -sys_includes = ["tribufu/prelude.h"] -includes = [] -no_includes = true -cpp_compat = false -braces = "NextLine" -line_length = 100 -tab_width = 4 -documentation = true -documentation_style = "doxy" -style = "tag" - -[defines] -"debug_assertions" = "TRIBUFU_DEBUG" -"not(debug_assertions)" = "TRIBUFU_RELEASE" -"panic = abort" = "TRIBUFU_PANIC_ABORT" -"panic = unwind" = "TRIBUFU_PANIC_UNWIND" -"proc_macro" = "TRIBUFU_PROC_MACRO" -"target_arch = aarch64" = "TRIBUFU_AARCH64" -"target_arch = arm" = "TRIBUFU_ARM" -"target_arch = armV7" = "TRIBUFU_ARMV7" -"target_arch = armv4t" = "TRIBUFU_ARMV4T" -"target_arch = armv6" = "TRIBUFU_ARMV6" -"target_arch = armv7a" = "TRIBUFU_ARMV7A" -"target_arch = armv7s" = "TRIBUFU_ARMV7S" -"target_arch = avr" = "TRIBUFU_AVR" -"target_arch = bpfeb" = "TRIBUFU_BPFEB" -"target_arch = bpfel" = "TRIBUFU_BPFEL" -"target_arch = hexagon" = "TRIBUFU_HEXAGON" -"target_arch = i386" = "TRIBUFU_I386" -"target_arch = i586" = "TRIBUFU_I586" -"target_arch = i686" = "TRIBUFU_I686" -"target_arch = m68k" = "TRIBUFU_M68K" -"target_arch = mips" = "TRIBUFU_MIPS" -"target_arch = mipsel" = "TRIBUFU_MIPSEL" -"target_arch = msp430" = "TRIBUFU_MSP430" -"target_arch = powerpc" = "TRIBUFU_POWERPC" -"target_arch = powerpc64" = "TRIBUFU_POWERPC64" -"target_arch = powerpc64l" = "TRIBUFU_POWERPC64L" -"target_arch = riscv32gc" = "TRIBUFU_RISCV32GC" -"target_arch = s390x" = "TRIBUFU_S390X" -"target_arch = sparc" = "TRIBUFU_SPARC" -"target_arch = sparc64" = "TRIBUFU_SPARC64" -"target_arch = thumbv4t" = "TRIBUFU_THUMBV4T" -"target_arch = thumbv7a" = "TRIBUFU_THUMBV7A" -"target_arch = thumbv7neon" = "TRIBUFU_THUMBV7NEON" -"target_arch = wasm32" = "TRIBUFU_WASM32" -"target_arch = wasm64" = "TRIBUFU_WASM64" -"target_arch = x86" = "TRIBUFU_X86" -"target_arch = x86_64" = "TRIBUFU_X86_64" -"target_endian = big" = "TRIBUFU_BIG_ENDIAN" -"target_endian = little" = "TRIBUFU_LITTLE_ENDIAN" -"target_env = gnu" = "TRIBUFU_GNU" -"target_env = msvc" = "TRIBUFU_MSVC" -"target_env = musl" = "TRIBUFU_MUSL" -"target_env = sgx" = "TRIBUFU_SGX" -"target_family = unix" = "TRIBUFU_UNIX" -"target_family = wasm" = "TRIBUFU_WASM" -"target_family = windows" = "TRIBUFU_MICROSOFT" -"target_feature = avx" = "TRIBUFU_AVX" -"target_feature = avx2" = "TRIBUFU_AVX2" -"target_feature = crt-static" = "TRIBUFU_CRTSTATIC" -"target_feature = rdrand" = "TRIBUFU_RDRAND" -"target_feature = sse" = "TRIBUFU_SSE" -"target_feature = sse2" = "TRIBUFU_SSE2" -"target_feature = sse4.1" = "TRIBUFU_SSE41" -"target_has_atomic = 128" = "TRIBUFU_ATOMIC_128" -"target_has_atomic = 16" = "TRIBUFU_ATOMIC_16" -"target_has_atomic = 32" = "TRIBUFU_ATOMIC_32" -"target_has_atomic = 64" = "TRIBUFU_ATOMIC_64" -"target_has_atomic = 8" = "TRIBUFU_ATOMIC_8" -"target_has_atomic = ptr" = "TRIBUFU_ATOMIC_PTR" -"target_os = android" = "TRIBUFU_ANDROID" -"target_os = dragonfly" = "TRIBUFU_DRAGONFLY" -"target_os = freebsd" = "TRIBUFU_FREEBSD" -"target_os = ios" = "TRIBUFU_IOS" -"target_os = linux" = "TRIBUFU_LINUX" -"target_os = macos" = "TRIBUFU_MACOS" -"target_os = netbsd" = "TRIBUFU_NETBSD" -"target_os = openbsd" = "TRIBUFU_OPENBSD" -"target_os = windows" = "TRIBUFU_WINDOWS" -"target_pointer_width = 16" = "TRIBUFU_POINTER_16" -"target_pointer_width = 32" = "TRIBUFU_POINTER_32" -"target_pointer_width = 64" = "TRIBUFU_POINTER_64" -"target_vendor = apple" = "TRIBUFU_APPLE" -"target_vendor = fortanix" = "TRIBUFU_FORTANIX" -"target_vendor = pc" = "TRIBUFU_MICROSOFT" -"target_vendor = unknown" = "TRIBUFU_UNKNOWN" - -[export] -include = [] -exclude = [] -item_types = ["enums", "structs", "typedefs", "functions"] -renaming_overrides_prefixing = false - -[layout] -packed = "PACKED" -aligned_n = "ALIGNED" - -[fn] -prefix = "TRIBUFU_API" -args = "horizontal" -must_use = "MUST_USE_FUNC" -no_return = "NO_RETURN" -rename_args = "None" -sort_by = "Name" - -[struct] -rename_fields = "None" -must_use = "MUST_USE_STRUCT" -derive_constructor = true -derive_eq = false -derive_neq = false -derive_lt = false -derive_lte = false -derive_gt = false -derive_gte = false - -[enum] -rename_variants = "None" -add_sentinel = false -prefix_with_name = false -enum_class = false -derive_helper_methods = false -derive_const_casts = false -derive_mut_casts = false -must_use = "MUST_USE_ENUM" -derive_tagged_enum_destructor = false -derive_tagged_enum_copy_constructor = false -derive_tagged_enum_copy_assignment = false -private_default_tagged_enum_constructor = false - -[const] -allow_static_const = true -allow_constexpr = false -sort_by = "Name" - -[macro_expansion] -bitflags = true - -[parse] -parse_deps = true -include = [] -exclude = [] -clean = false -extra_bindings = [] - -[parse.expand] -crates = [] -all_features = true -default_features = true -features = [] diff --git a/examples/c/main.c b/examples/c/main.c deleted file mode 100644 index 8ed17df..0000000 --- a/examples/c/main.c +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#include -#include - -int main(int argc, char **argv) -{ - tribufu_api_initialize(); - char *version = tribufu_api_get_user_agent(); - printf("%s\n", version); - tribufu_free_string(version); - tribufu_api_shutdown(); - return 0; -} diff --git a/examples/c/premake5.lua b/examples/c/premake5.lua deleted file mode 100644 index d66728c..0000000 --- a/examples/c/premake5.lua +++ /dev/null @@ -1,212 +0,0 @@ ---- @diagnostic disable: undefined-global - -project "example_c" - location "." - kind "ConsoleApp" - language "C" - - targetdir("../../bin/%{cfg.platform}") - objdir("../../target/%{cfg.buildcfg}/obj/%{prj.name}/%{cfg.platform}") - - files - { - "./**.c", - "./**.h", - "../../include/**.h", - } - - vpaths - { - ["Sources"] = { "./**.c" }, - ["Headers"] = { "./**.h", "../../include/**.h" }, - } - - includedirs - { - "../../include", - } - - libdirs - { - "../../bin/%{cfg.platform}", - } - - -- Profile - - filter { "configurations:debug" } - runtime "Debug" - symbols "On" - - defines - { - "DEBUG", - "TRACE", - "TRIBUFU_DEBUG", - "TRIBUFU_TRACE", - } - - filter { "configurations:release" } - runtime "Release" - optimize "On" - - defines - { - "RELEASE", - "TRIBUFU_RELEASE", - } - - -- Platform - - filter { "platforms:win-*" } - system "windows" - systemversion "latest" - staticruntime "On" - toolset "msc" - - defines - { - "TRIBUFU_DESKTOP", - "TRIBUFU_DYNAMIC", - "TRIBUFU_LIBRARY", - "TRIBUFU_WINDOWS", - } - - links - { - "tribufu_sdk.lib", - } - - prelinkcommands - { - } - - postbuildcommands - { - } - - filter { "platforms:osx-*" } - system "macosx" - systemversion "10.15" - toolset "clang" - - defines - { - "TRIBUFU_APPLE", - "TRIBUFU_DESKTOP", - "TRIBUFU_DYNAMIC", - "TRIBUFU_LIBRARY", - "TRIBUFU_MAC", - } - - links - { - "tribufu_sdk", - } - - prelinkcommands - { - } - - postbuildcommands - { - } - - filter { "platforms:linux-*" } - system "linux" - toolset "gcc" - - defines - { - "TRIBUFU_DESKTOP", - "TRIBUFU_DYNAMIC", - "TRIBUFU_LIBRARY", - "TRIBUFU_LINUX", - "TRIBUFU_UNIX", - } - - links - { - "tribufu_sdk", - } - - prelinkcommands - { - } - - postbuildcommands - { - } - - filter { "platforms:android-*" } - system "android" - toolset "clang" - - defines - { - "TRIBUFU_ANDROID", - "TRIBUFU_DYNAMIC", - "TRIBUFU_LIBRARY", - "TRIBUFU_MOBILE", - "TRIBUFU_UNIX", - } - - links - { - "tribufu_sdk", - } - - prelinkcommands - { - } - - postbuildcommands - { - } - - filter { "platforms:ios-*" } - system "ios" - systemversion "13.0" - toolset "clang" - - defines - { - "TRIBUFU_APPLE", - "TRIBUFU_IOS", - "TRIBUFU_LIBRARY", - "TRIBUFU_MOBILE", - "TRIBUFU_MONOLITHIC", - } - - links - { - "tribufu_sdk", - } - - -- Architecture - - filter { "platforms:*-x86" } - architecture "x86" - - defines - { - "TRIBUFU_32BITS", - "TRIBUFU_X86", - } - - filter { "platforms:*-x64" } - architecture "x64" - - defines - { - "TRIBUFU_64BITS", - "TRIBUFU_X64", - } - - filter { "platforms:*-arm64" } - architecture "ARM64" - - defines - { - "TRIBUFU_64BITS", - "TRIBUFU_ARM64", - } diff --git a/examples/cpp/main.cpp b/examples/cpp/main.cpp deleted file mode 100644 index 4fabc92..0000000 --- a/examples/cpp/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#include -#include - -int main(int argc, char **argv) -{ - tribufu_api_initialize(); - const char *version = tribufu_api_get_user_agent(); - std::cout << version << std::endl; - tribufu_free_string((char *)version); - tribufu_api_shutdown(); - return 0; -} diff --git a/examples/cpp/premake5.lua b/examples/cpp/premake5.lua deleted file mode 100644 index 02dcddd..0000000 --- a/examples/cpp/premake5.lua +++ /dev/null @@ -1,213 +0,0 @@ ---- @diagnostic disable: undefined-global - -project "example_cpp" - location "." - kind "ConsoleApp" - language "C++" - cppdialect "C++20" - - targetdir("../../bin/%{cfg.platform}") - objdir("../../target/%{cfg.buildcfg}/obj/%{prj.name}/%{cfg.platform}") - - files - { - "./**.cpp", - "./**.h", - "../../include/**.h", - } - - vpaths - { - ["Sources"] = { "./**.cpp" }, - ["Headers"] = { "./**.h", "../../include/**.h" }, - } - - includedirs - { - "../../include", - } - - libdirs - { - "../../bin/%{cfg.platform}", - } - - -- Profile - - filter { "configurations:debug" } - runtime "Debug" - symbols "On" - - defines - { - "DEBUG", - "TRACE", - "TRIBUFU_DEBUG", - "TRIBUFU_TRACE", - } - - filter { "configurations:release" } - runtime "Release" - optimize "On" - - defines - { - "RELEASE", - "TRIBUFU_RELEASE", - } - - -- Platform - - filter { "platforms:win-*" } - system "windows" - systemversion "latest" - staticruntime "On" - toolset "msc" - - defines - { - "TRIBUFU_DESKTOP", - "TRIBUFU_DYNAMIC", - "TRIBUFU_LIBRARY", - "TRIBUFU_WINDOWS", - } - - links - { - "tribufu_sdk.lib", - } - - prelinkcommands - { - } - - postbuildcommands - { - } - - filter { "platforms:osx-*" } - system "macosx" - systemversion "10.15" - toolset "clang" - - defines - { - "TRIBUFU_APPLE", - "TRIBUFU_DESKTOP", - "TRIBUFU_DYNAMIC", - "TRIBUFU_LIBRARY", - "TRIBUFU_MAC", - } - - links - { - "tribufu_sdk", - } - - prelinkcommands - { - } - - postbuildcommands - { - } - - filter { "platforms:linux-*" } - system "linux" - toolset "gcc" - - defines - { - "TRIBUFU_DESKTOP", - "TRIBUFU_DYNAMIC", - "TRIBUFU_LIBRARY", - "TRIBUFU_LINUX", - "TRIBUFU_UNIX", - } - - links - { - "tribufu_sdk", - } - - prelinkcommands - { - } - - postbuildcommands - { - } - - filter { "platforms:android-*" } - system "android" - toolset "clang" - - defines - { - "TRIBUFU_ANDROID", - "TRIBUFU_DYNAMIC", - "TRIBUFU_LIBRARY", - "TRIBUFU_MOBILE", - "TRIBUFU_UNIX", - } - - links - { - "tribufu_sdk", - } - - prelinkcommands - { - } - - postbuildcommands - { - } - - filter { "platforms:ios-*" } - system "ios" - systemversion "13.0" - toolset "clang" - - defines - { - "TRIBUFU_APPLE", - "TRIBUFU_IOS", - "TRIBUFU_LIBRARY", - "TRIBUFU_MOBILE", - "TRIBUFU_MONOLITHIC", - } - - links - { - "tribufu_sdk", - } - - -- Architecture - - filter { "platforms:*-x86" } - architecture "x86" - - defines - { - "TRIBUFU_32BITS", - "TRIBUFU_X86", - } - - filter { "platforms:*-x64" } - architecture "x64" - - defines - { - "TRIBUFU_64BITS", - "TRIBUFU_X64", - } - - filter { "platforms:*-arm64" } - architecture "ARM64" - - defines - { - "TRIBUFU_64BITS", - "TRIBUFU_ARM64", - } diff --git a/include/tribufu.h b/include/tribufu.h deleted file mode 100644 index fa4aae6..0000000 --- a/include/tribufu.h +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -#pragma once - -#include diff --git a/include/tribufu/api.h b/include/tribufu/api.h deleted file mode 100644 index d31c339..0000000 --- a/include/tribufu/api.h +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -#pragma once - -#include diff --git a/include/tribufu/macros.h b/include/tribufu/macros.h deleted file mode 100644 index 9e73b9b..0000000 --- a/include/tribufu/macros.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#ifdef __cplusplus -#define TRIBUFU_CPP -#endif - -#ifndef EXTERN_C -#ifdef TRIBUFU_CPP -#define EXTERN_C extern "C" -#else -#define EXTERN_C -#endif -#endif - -#define TRIBUFU_API EXTERN_C - -/* -#ifdef TRIBUFU_LIBRARY -#define TRIBUFU_API DLLEXPORT -#else -#define TRIBUFU_API DLLIMPORT -#endif -*/ diff --git a/include/tribufu/native.h b/include/tribufu/native.h deleted file mode 100644 index cd63a1c..0000000 --- a/include/tribufu/native.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -#pragma once - -#include - -typedef void TribufuApiGetUserInfoCallbackData; - -typedef void (*TribufuApiGetUserInfoCallback)(void*, const TribufuApiGetUserInfoCallbackData*); - -/** - * Gets the user agent string for the Tribufu API. - */ -TRIBUFU_API const char *tribufu_api_get_user_agent(void); - -TRIBUFU_API void tribufu_api_get_user_info(void *context, TribufuApiGetUserInfoCallback callback); - -/** - * Gets the version of the Tribufu API. - */ -TRIBUFU_API const char *tribufu_api_get_version(void); - -/** - * Initialize the Tribufu API instance. - * - * This must be called before any other API functions. - */ -TRIBUFU_API bool tribufu_api_initialize(void); - -/** - * Shutdown the Tribufu API instance. - * - * This must be called when the API is no longer needed. - */ -TRIBUFU_API void tribufu_api_shutdown(void); - -TRIBUFU_API void tribufu_free_string(char *ptr); diff --git a/include/tribufu/platform.h b/include/tribufu/platform.h deleted file mode 100644 index 7aeeccc..0000000 --- a/include/tribufu/platform.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#ifdef _WIN32 -#ifndef DLLEXPORT -#define DLLEXPORT __declspec(dllexport) -#endif -#ifndef DLLIMPORT -#define DLLIMPORT __declspec(dllimport) -#endif -#endif - -#ifdef __MACH__ || __APPLE__ || __linux__ || __FreeBSD__ || __ANDROID__ -#ifndef DLLEXPORT -#define DLLEXPORT __attribute__((visibility("default"))) -#endif -#ifndef DLLIMPORT -#define DLLIMPORT __attribute__((visibility("default"))) -#endif -#endif diff --git a/include/tribufu/prelude.h b/include/tribufu/prelude.h deleted file mode 100644 index b141b38..0000000 --- a/include/tribufu/prelude.h +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include -#include diff --git a/include/tribufu/std.h b/include/tribufu/std.h deleted file mode 100644 index 1da1e53..0000000 --- a/include/tribufu/std.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. - -#pragma once - -#include -#include -#include -#include -#include - -#ifdef TRIBUFU_CPP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif diff --git a/premake5.lua b/premake5.lua deleted file mode 100644 index b986cda..0000000 --- a/premake5.lua +++ /dev/null @@ -1,31 +0,0 @@ ---- @diagnostic disable: undefined-global - -workspace "tribufu" - location "." - configurations { "debug", "release" } - -if _ACTION == "vs2022" then - platforms { - "win-arm64", - "win-x64", - "win-x86", - } -end - -if _ACTION == "gmake2" then - platforms { - "linux-arm64", - "linux-x64", - "linux-x86", - } -end - -if _ACTION == "xcode4" then - platforms { - "osx-arm64", - "osx-x64", - } -end - -include "examples/c" -include "examples/cpp" diff --git a/scripts/cbindgen.ps1 b/scripts/cbindgen.ps1 deleted file mode 100644 index 360bbe5..0000000 --- a/scripts/cbindgen.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env sh - -cbindgen --config ./config/cbindgen.toml --crate tribufu-sdk --output ./include/tribufu/native.h diff --git a/scripts/unix/premake.sh b/scripts/unix/premake.sh deleted file mode 100644 index 3fb5e5e..0000000 --- a/scripts/unix/premake.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env sh - -if [ "$(expr substr $(uname -s) 1 5)" = "Linux" ] -then - ./vendor/premake-core/linux/premake5 gmake2 - -elif [ "$(uname)" = "Darwin" ] -then - ./vendor/premake-core/mac/premake5 xcode4 -fi diff --git a/scripts/windows/build.ps1 b/scripts/windows/build.ps1 index f36a716..100a3fa 100644 --- a/scripts/windows/build.ps1 +++ b/scripts/windows/build.ps1 @@ -2,11 +2,3 @@ echo "Building for win-x64" cargo build --workspace - -New-Item "bin/win-x64" -ItemType Directory -Force -Remove-Item -Path "bin/win-x64/*" -Force -Recurse - -Copy-Item -Path "target/debug/tribufu_sdk.dll.lib" -Destination "bin/win-x64/tribufu_sdk.lib" -Copy-Item -Path "target/debug/tribufu_sdk.dll" -Destination "bin/win-x64/tribufu_sdk.dll" - -#msbuild /p:Configuration="debug" /p:Platform="win-x64" diff --git a/scripts/windows/premake.bat b/scripts/windows/premake.bat deleted file mode 100644 index 5488708..0000000 --- a/scripts/windows/premake.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -call .\vendor\premake-core\windows\premake5.exe vs2022 diff --git a/src/native/Cargo.toml b/src/native/Cargo.toml deleted file mode 100644 index 2a2ac70..0000000 --- a/src/native/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "tribufu-sdk" -version = "0.0.0" -description = "Tribufu Native" -repository = "https://github.com/tribufu/tribufu-rust" -authors = ["Tribufu "] -license = "UNLICENSED" -edition = "2021" -publish = false - -[lib] -name = "tribufu_sdk" -crate-type = ["rlib", "cdylib", "staticlib"] -path = "lib.rs" - -[dependencies] -tribufu = { path = "../../" } -futures = "0.3.31" -libc = "0.2.172" -once_cell = "1.19.0" -tokio = { version = "1.45.1", features = ["full"] } diff --git a/src/native/api.rs b/src/native/api.rs deleted file mode 100644 index 7f55162..0000000 --- a/src/native/api.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: UNLICENSED - -use crate::models::{TribufuApiCallbackContext, TribufuApiGetUserInfoCallback}; -use futures::lock::Mutex; -use libc::{c_char, c_void}; -use once_cell::sync::Lazy; -use std::ffi::CString; -use std::ptr; -use tokio::runtime::Runtime; -use tribufu::apis::tribufu_generated_api::TribufuGeneratedApiClient; -use tribufu::TribufuApi; - -static INSTANCE: Lazy>> = Lazy::new(|| Mutex::new(None)); -static RUNTIME: Lazy = Lazy::new(|| Runtime::new().unwrap()); - -/// Gets the version of the Tribufu API. -#[no_mangle] -pub extern "C" fn tribufu_api_get_version() -> *const c_char { - CString::new(TribufuApi::get_version()).unwrap().into_raw() -} - -/// Gets the user agent string for the Tribufu API. -#[no_mangle] -pub extern "C" fn tribufu_api_get_user_agent() -> *const c_char { - CString::new(TribufuApi::get_user_agent()) - .unwrap() - .into_raw() -} - -/// Initialize the Tribufu API instance. -/// -/// This must be called before any other API functions. -#[no_mangle] -pub extern "C" fn tribufu_api_initialize() -> bool { - let api = TribufuApi::from_env_or_default(None); - - if INSTANCE.try_lock().is_none() { - return false; - } - - let mut instance = INSTANCE.try_lock().unwrap(); - *instance = Some(api); - - true -} - -/// Shutdown the Tribufu API instance. -/// -/// This must be called when the API is no longer needed. -#[no_mangle] -pub extern "C" fn tribufu_api_shutdown() { - if INSTANCE.try_lock().is_none() { - return; - } - - let mut instance = INSTANCE.try_lock().unwrap(); - *instance = None; -} - -#[no_mangle] -#[allow(unused_variables)] -pub extern "C" fn tribufu_api_get_user_info( - context: *mut c_void, - callback: TribufuApiGetUserInfoCallback, -) { - let context = TribufuApiCallbackContext(context); - - RUNTIME.spawn(async move { - let mut instance = INSTANCE.lock().await; - if instance.is_none() { - callback(context.as_ptr(), ptr::null()); - return; - } - - let api = instance.as_mut(); - if api.is_none() { - callback(context.as_ptr(), ptr::null()); - return; - } - - let api = api.unwrap(); - - // TODO: Implement logic here - - callback(context.as_ptr(), ptr::null()); - }); -} diff --git a/src/native/lib.rs b/src/native/lib.rs deleted file mode 100644 index aa68739..0000000 --- a/src/native/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: UNLICENSED - -#![allow(dead_code)] - -pub mod api; -pub mod mem; -pub mod models; diff --git a/src/native/mem.rs b/src/native/mem.rs deleted file mode 100644 index 945f5e5..0000000 --- a/src/native/mem.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: UNLICENSED - -use std::ffi::CString; -use std::os::raw::c_char; - -#[no_mangle] -pub extern "C" fn tribufu_free_string(ptr: *mut c_char) { - if ptr.is_null() { - return; - } - - unsafe { - let _ = CString::from_raw(ptr); - } -} diff --git a/src/native/models.rs b/src/native/models.rs deleted file mode 100644 index b1076c2..0000000 --- a/src/native/models.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -use libc::c_void; - -pub struct TribufuApiCallbackContext(pub(crate) *mut c_void); - -impl TribufuApiCallbackContext { - pub(crate) fn as_ptr(&self) -> *mut c_void { - self.0 - } -} - -unsafe impl Send for TribufuApiCallbackContext {} -unsafe impl Sync for TribufuApiCallbackContext {} - -pub type TribufuApiGetUserInfoCallbackData = c_void; -pub type TribufuApiGetUserInfoCallback = - extern "C" fn(*mut c_void, *const TribufuApiGetUserInfoCallbackData); diff --git a/vendor/premake-core/LICENSE.txt b/vendor/premake-core/LICENSE.txt deleted file mode 100644 index 63962d7..0000000 --- a/vendor/premake-core/LICENSE.txt +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2003-2022 Jason Perkins and individual contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of Premake nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/premake-core/linux/libluasocket.so b/vendor/premake-core/linux/libluasocket.so deleted file mode 100644 index 92ced02..0000000 Binary files a/vendor/premake-core/linux/libluasocket.so and /dev/null differ diff --git a/vendor/premake-core/linux/premake5 b/vendor/premake-core/linux/premake5 deleted file mode 100644 index bcb51ce..0000000 Binary files a/vendor/premake-core/linux/premake5 and /dev/null differ diff --git a/vendor/premake-core/mac/libluasocket.dylib b/vendor/premake-core/mac/libluasocket.dylib deleted file mode 100644 index 337fa41..0000000 Binary files a/vendor/premake-core/mac/libluasocket.dylib and /dev/null differ diff --git a/vendor/premake-core/mac/premake5 b/vendor/premake-core/mac/premake5 deleted file mode 100644 index 48daa61..0000000 Binary files a/vendor/premake-core/mac/premake5 and /dev/null differ diff --git a/vendor/premake-core/windows/luasocket.dll b/vendor/premake-core/windows/luasocket.dll deleted file mode 100644 index 5768400..0000000 Binary files a/vendor/premake-core/windows/luasocket.dll and /dev/null differ diff --git a/vendor/premake-core/windows/luasocket.exp b/vendor/premake-core/windows/luasocket.exp deleted file mode 100644 index a7f2ae7..0000000 Binary files a/vendor/premake-core/windows/luasocket.exp and /dev/null differ diff --git a/vendor/premake-core/windows/luasocket.lib b/vendor/premake-core/windows/luasocket.lib deleted file mode 100644 index 5110174..0000000 Binary files a/vendor/premake-core/windows/luasocket.lib and /dev/null differ diff --git a/vendor/premake-core/windows/luasocket.pdb b/vendor/premake-core/windows/luasocket.pdb deleted file mode 100644 index 9db9e2f..0000000 Binary files a/vendor/premake-core/windows/luasocket.pdb and /dev/null differ diff --git a/vendor/premake-core/windows/premake5.exe b/vendor/premake-core/windows/premake5.exe deleted file mode 100644 index 1a637aa..0000000 Binary files a/vendor/premake-core/windows/premake5.exe and /dev/null differ diff --git a/vendor/premake-core/windows/premake5.pdb b/vendor/premake-core/windows/premake5.pdb deleted file mode 100644 index ca0aaee..0000000 Binary files a/vendor/premake-core/windows/premake5.pdb and /dev/null differ