Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: 0.14互換APIを追加 #650

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 23 additions & 1 deletion crates/voicevox_core_c_api/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,21 @@ after_includes = """
#else // __cplusplus
#include <stdbool.h>
#include <stdint.h>
#endif // __cplusplus"""
#endif // __cplusplus

#if defined(__cplusplus)
#define DEPRECATED [[deprecated]]
#define DEPRECATED_WITH_NOTE(msg) [[deprecated(msg)]]
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#define DEPRECATED_WITH_NOTE(msg) __declspec(deprecated(msg))
#elif defined(__GNUC__)
#define DEPRECATED __attribute__((deprecated))
#define DEPRECATED_WITH_NOTE(msg) __attribute__((deprecated(msg)))
#else
#define DEPRECATED
#define DEPRECATED_WITH_NOTE(msg)
#endif"""

# Code Style Options

Expand All @@ -69,9 +83,17 @@ prefix = """
__declspec(dllimport)
#endif"""
args = "vertical"
deprecated = "DEPRECATED"
deprecated_with_note = "DEPRECATED_WITH_NOTE({})"

[struct]
deprecated = "DEPRECATED"
deprecated_with_note = "DEPRECATED_WITH_NOTE({})"

[enum]
rename_variants = "ScreamingSnakeCase"
deprecated = "DEPRECATED"
deprecated_with_note = "DEPRECATED_WITH_NOTE({})"

# Options for how your Rust library should be parsed

Expand Down
53 changes: 48 additions & 5 deletions crates/voicevox_core_c_api/include/voicevox_core.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/voicevox_core_c_api/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl From<VoicevoxAccelerationMode> for voicevox_core::AccelerationMode {
}
}

impl Default for VoicevoxInitializeOptions {
impl Default for VoicevoxInitializeSynthesizerOptions {
fn default() -> Self {
let options = voicevox_core::InitializeOptions::default();
Self {
Expand All @@ -124,8 +124,8 @@ impl Default for VoicevoxInitializeOptions {
}
}

impl From<VoicevoxInitializeOptions> for voicevox_core::InitializeOptions {
fn from(value: VoicevoxInitializeOptions) -> Self {
impl From<VoicevoxInitializeSynthesizerOptions> for voicevox_core::InitializeOptions {
fn from(value: VoicevoxInitializeSynthesizerOptions) -> Self {
voicevox_core::InitializeOptions {
acceleration_mode: value.acceleration_mode.into(),
cpu_num_threads: value.cpu_num_threads,
Expand Down
10 changes: 6 additions & 4 deletions crates/voicevox_core_c_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod drop_check;
mod helpers;
mod result_code;
mod slice_owner;
mod v014_compatible_engine;
use self::drop_check::C_STRING_DROP_CHECKER;
use self::helpers::*;
use self::result_code::VoicevoxResultCode;
Expand Down Expand Up @@ -200,7 +201,7 @@ pub enum VoicevoxAccelerationMode {

/// ::voicevox_synthesizer_new_with_initialize のオプション。
#[repr(C)]
pub struct VoicevoxInitializeOptions {
pub struct VoicevoxInitializeSynthesizerOptions {
/// ハードウェアアクセラレーションモード
acceleration_mode: VoicevoxAccelerationMode,
/// CPU利用数を指定
Expand All @@ -211,8 +212,9 @@ pub struct VoicevoxInitializeOptions {
/// デフォルトの初期化オプションを生成する
/// @return デフォルト値が設定された初期化オプション
#[no_mangle]
pub extern "C" fn voicevox_make_default_initialize_options() -> VoicevoxInitializeOptions {
VoicevoxInitializeOptions::default()
pub extern "C" fn voicevox_make_default_initialize_synthesizer_options(
) -> VoicevoxInitializeSynthesizerOptions {
VoicevoxInitializeSynthesizerOptions::default()
}

/// voicevoxのバージョンを取得する。
Expand Down Expand Up @@ -337,7 +339,7 @@ pub struct VoicevoxSynthesizer {
#[no_mangle]
pub unsafe extern "C" fn voicevox_synthesizer_new_with_initialize(
open_jtalk: &OpenJtalkRc,
options: VoicevoxInitializeOptions,
options: VoicevoxInitializeSynthesizerOptions,
out_synthesizer: NonNull<Box<VoicevoxSynthesizer>>,
) -> VoicevoxResultCode {
into_result_code_with_error((|| {
Expand Down
26 changes: 26 additions & 0 deletions crates/voicevox_core_c_api/src/v014_compatible_engine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use super::*;

/// ::voicevox_initialize のオプション。
#[deprecated(note = "VoicevoxInitializeSynthesizerOptions を使ってください。")]
#[repr(C)]
pub struct VoicevoxInitializeOptions {
/// ハードウェアアクセラレーションモード
acceleration_mode: VoicevoxAccelerationMode,
/// CPU利用数を指定
/// 0を指定すると環境に合わせたCPUが利用される
cpu_num_threads: u16,
/// 全てのモデルを読み込む
load_all_models: bool,
/// open_jtalkの辞書ディレクトリ
open_jtalk_dict_dir: *const c_char,
}

#[no_mangle]
#[deprecated(note = "voicevox_synthesizer_new_with_initialize を使ってください。")]
/// 初期化する。
///
/// @param [in] options オプション
/// @returns 結果コード
pub extern "C" fn voicevox_initialize(options: VoicevoxInitializeOptions) -> VoicevoxResultCode {
todo!()
}
2 changes: 1 addition & 1 deletion crates/xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition.workspace = true
publish.workspace = true

[dependencies]
cbindgen = "0.24.3"
cbindgen = "0.26.0"
clap.workspace = true
color-eyre = "0.6.2"
eyre = "0.6.8"
Expand Down
3 changes: 3 additions & 0 deletions docs/0.14_to_0.15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 0.14 から 0.15 への移行

TODO
Loading