mirror of
https://github.com/tribufu/sdk-rust
synced 2025-06-16 11:14:17 +00:00
Merge Rust, C and C++ SDKs (#4)
* Generate native bindings from rust crate * Add native instance and runtime statics * Update README.md
This commit is contained in:
6
include/tribufu.h
Normal file
6
include/tribufu.h
Normal file
@ -0,0 +1,6 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/api.h>
|
6
include/tribufu/api.h
Normal file
6
include/tribufu/api.h
Normal file
@ -0,0 +1,6 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/native.h>
|
25
include/tribufu/macros.h
Normal file
25
include/tribufu/macros.h
Normal file
@ -0,0 +1,25 @@
|
||||
// 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
|
||||
*/
|
38
include/tribufu/native.h
Normal file
38
include/tribufu/native.h
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
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);
|
21
include/tribufu/platform.h
Normal file
21
include/tribufu/platform.h
Normal file
@ -0,0 +1,21 @@
|
||||
// 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
|
7
include/tribufu/prelude.h
Normal file
7
include/tribufu/prelude.h
Normal file
@ -0,0 +1,7 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/macros.h>
|
||||
#include <tribufu/platform.h>
|
||||
#include <tribufu/std.h>
|
26
include/tribufu/std.h
Normal file
26
include/tribufu/std.h
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef TRIBUFU_CPP
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#endif
|
Reference in New Issue
Block a user