Skip to main content

aviutl2_sys/
module2.rs

1//! スクリプトモジュール ヘッダーファイル for AviUtl ExEdit2
2//! By KENくん
3
4#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
5
6use std::ffi::c_void;
7use std::os::raw::{c_char, c_double, c_int};
8
9use crate::plugin2::EDIT_SECTION;
10
11/// 引数の型種別
12#[repr(i32)]
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
14pub enum PARAM_TYPE {
15    NONE = -1,
16    NIL = 0,
17    BOOLEAN = 1,
18    LIGHTUSERDATA = 2,
19    NUMBER = 3,
20    STRING = 4,
21    TABLE = 5,
22    FUNCTION = 6,
23    USERDATA = 7,
24    THREAD = 8,
25}
26
27/// スクリプトモジュール引数構造体
28#[repr(C)]
29#[derive(Debug, Clone, Copy)]
30pub struct SCRIPT_MODULE_PARAM {
31    /// 引数の数を取得する
32    ///
33    /// # Returns
34    ///
35    /// 引数の数
36    pub get_param_num: unsafe extern "C" fn() -> c_int,
37
38    /// 引数を整数で取得する
39    ///
40    /// # Arguments
41    ///
42    /// * `index` - 引数の位置(0〜)
43    ///
44    /// # Returns
45    ///
46    /// 引数の値 (取得出来ない場合は0)
47    pub get_param_int: unsafe extern "C" fn(index: c_int) -> c_int,
48
49    /// 引数を浮動小数点で取得する
50    ///
51    /// # Arguments
52    ///
53    /// * `index` - 引数の位置(0〜)
54    ///
55    /// # Returns
56    ///
57    /// 引数の値 (取得出来ない場合は0)
58    pub get_param_double: unsafe extern "C" fn(index: c_int) -> c_double,
59
60    /// 引数を文字列(UTF-8)で取得する
61    ///
62    /// # Arguments
63    ///
64    /// * `index` - 引数の位置(0〜)
65    ///
66    /// # Returns
67    ///
68    /// 引数の値 (取得出来ない場合はnullptr)
69    pub get_param_string: unsafe extern "C" fn(index: c_int) -> *const c_char,
70
71    /// 引数をデータのポインタで取得する
72    ///
73    /// # Arguments
74    ///
75    /// * `index` - 引数の位置(0〜)
76    ///
77    /// # Returns
78    ///
79    /// 引数の値 (取得出来ない場合はnullptr)
80    pub get_param_data: unsafe extern "C" fn(index: c_int) -> *mut c_void,
81
82    /// 引数の連想配列要素を整数で取得する
83    ///
84    /// # Arguments
85    ///
86    /// * `index` - 引数の位置(0〜)
87    /// * `key` - キー名(UTF-8)
88    ///
89    /// # Returns
90    ///
91    /// 引数の値 (取得出来ない場合は0)
92    pub get_param_table_int: unsafe extern "C" fn(index: c_int, key: *const c_char) -> c_int,
93
94    /// 引数の連想配列要素を浮動小数点で取得する
95    ///
96    /// # Arguments
97    ///
98    /// * `index` - 引数の位置(0〜)
99    /// * `key` - キー名(UTF-8)
100    ///
101    /// # Returns
102    ///
103    /// 引数の値 (取得出来ない場合は0)
104    pub get_param_table_double: unsafe extern "C" fn(index: c_int, key: *const c_char) -> c_double,
105
106    /// 引数の連想配列要素を文字列(UTF-8)で取得する
107    ///
108    /// # Arguments
109    ///
110    /// * `index` - 引数の位置(0〜)
111    /// * `key` - キー名(UTF-8)
112    ///
113    /// # Returns
114    ///
115    /// 引数の値 (取得出来ない場合はnullptr)
116    pub get_param_table_string:
117        unsafe extern "C" fn(index: c_int, key: *const c_char) -> *const c_char,
118
119    /// 引数の配列要素の数を取得する
120    ///
121    /// # Arguments
122    ///
123    /// * `index` - 引数の位置(0〜)
124    ///
125    /// # Returns
126    ///
127    /// 配列要素の数
128    pub get_param_array_num: unsafe extern "C" fn(index: c_int) -> c_int,
129
130    /// 引数の配列要素を整数で取得する
131    ///
132    /// # Arguments
133    ///
134    /// * `index` - 引数の位置(0〜)
135    /// * `key` - 配列のインデックス(0〜)
136    ///
137    /// # Returns
138    ///
139    /// 引数の値 (取得出来ない場合は0)
140    pub get_param_array_int: unsafe extern "C" fn(index: c_int, key: c_int) -> c_int,
141
142    /// 引数の配列要素を浮動小数点で取得する
143    ///
144    /// # Arguments
145    ///
146    /// * `index` - 引数の位置(0〜)
147    /// * `key` - 配列のインデックス(0〜)
148    ///
149    /// # Returns
150    ///
151    /// 引数の値 (取得出来ない場合は0)
152    pub get_param_array_double: unsafe extern "C" fn(index: c_int, key: c_int) -> c_double,
153
154    /// 引数の配列要素を文字列(UTF-8)で取得する
155    ///
156    /// # Arguments
157    ///
158    /// * `index` - 引数の位置(0〜)
159    /// * `key` - 配列のインデックス(0〜)
160    ///
161    /// # Returns
162    ///
163    /// 引数の値 (取得出来ない場合はnullptr)
164    pub get_param_array_string: unsafe extern "C" fn(index: c_int, key: c_int) -> *const c_char,
165
166    /// 整数の戻り値を追加する
167    ///
168    /// # Arguments
169    ///
170    /// * `value` - 戻り値
171    pub push_result_int: unsafe extern "C" fn(value: c_int),
172
173    /// 浮動小数点の戻り値を追加する
174    ///
175    /// # Arguments
176    ///
177    /// * `value` - 戻り値
178    pub push_result_double: unsafe extern "C" fn(value: c_double),
179
180    /// 文字列(UTF-8)の戻り値を追加する
181    ///
182    /// # Arguments
183    ///
184    /// * `value` - 戻り値
185    pub push_result_string: unsafe extern "C" fn(value: *const c_char),
186
187    /// データのポインタの戻り値を追加する
188    ///
189    /// # Arguments
190    ///
191    /// * `value` - 戻り値
192    pub push_result_data: unsafe extern "C" fn(value: *const c_void),
193
194    /// 整数連想配列の戻り値を追加する
195    ///
196    /// # Arguments
197    ///
198    /// * `key` - キー名(UTF-8)の配列
199    /// * `value` - 戻り値の配列
200    /// * `num` - 配列の要素数
201    pub push_result_table_int:
202        unsafe extern "C" fn(key: *const *const c_char, value: *const c_int, num: c_int),
203
204    /// 浮動小数点連想配列の戻り値を追加する
205    ///
206    /// # Arguments
207    ///
208    /// * `key` - キー名(UTF-8)の配列
209    /// * `value` - 戻り値の配列
210    /// * `num` - 配列の要素数
211    pub push_result_table_double:
212        unsafe extern "C" fn(key: *const *const c_char, value: *const c_double, num: c_int),
213
214    /// 文字列(UTF-8)連想配列の戻り値を追加する
215    ///
216    /// # Arguments
217    ///
218    /// * `key` - キー名(UTF-8)の配列
219    /// * `value` - 戻り値の配列
220    /// * `num` - 配列の要素数
221    pub push_result_table_string:
222        unsafe extern "C" fn(key: *const *const c_char, value: *const *const c_char, num: c_int),
223
224    /// 整数配列の戻り値を追加する
225    ///
226    /// # Arguments
227    ///
228    /// * `value` - 戻り値の配列
229    /// * `num` - 配列の要素数
230    pub push_result_array_int: unsafe extern "C" fn(value: *const c_int, num: c_int),
231
232    /// 浮動小数点配列の戻り値を追加する
233    ///
234    /// # Arguments
235    ///
236    /// * `value` - 戻り値の配列
237    /// * `num` - 配列の要素数
238    pub push_result_array_double: unsafe extern "C" fn(value: *const c_double, num: c_int),
239
240    /// 文字列(UTF-8)配列の戻り値を追加する
241    ///
242    /// # Arguments
243    ///
244    /// * `value` - 戻り値の配列
245    /// * `num` - 配列の要素数
246    pub push_result_array_string: unsafe extern "C" fn(value: *const *const c_char, num: c_int),
247
248    /// エラーメッセージを設定する
249    /// 呼び出された関数をエラー終了する場合に設定します
250    ///
251    /// # Arguments
252    ///
253    /// * `message` - エラーメッセージ(UTF-8)
254    pub set_error: unsafe extern "C" fn(message: *const c_char),
255
256    /// 引数をブール値で取得する
257    ///
258    /// # Arguments
259    ///
260    /// * `index` - 引数の位置(0〜)
261    ///
262    /// # Returns
263    ///
264    /// 引数の値 (取得出来ない場合はfalse)
265    pub get_param_boolean: unsafe extern "C" fn(index: c_int) -> bool,
266
267    /// ブール値の戻り値を追加する
268    ///
269    /// # Arguments
270    ///
271    /// * `value` - 戻り値
272    pub push_result_boolean: unsafe extern "C" fn(value: bool),
273
274    /// 引数の連想配列要素をブール値で取得する
275    ///
276    /// # Arguments
277    ///
278    /// * `index` - 引数の位置(0〜)
279    /// * `key` - キー名(UTF-8)
280    ///
281    /// # Returns
282    ///
283    /// 引数の値 (取得出来ない場合はfalse)
284    pub get_param_table_boolean: unsafe extern "C" fn(index: c_int, key: *const c_char) -> bool,
285
286    /// ブール値配列の戻り値を追加する
287    ///
288    /// # Arguments
289    ///
290    /// * `value` - 戻り値の配列
291    /// * `num` - 配列の要素数
292    pub push_result_array_boolean: unsafe extern "C" fn(value: *const bool, num: c_int),
293
294    /// ブール値連想配列の戻り値を追加する
295    ///
296    /// # Arguments
297    ///
298    /// * `key` - キー名(UTF-8)の配列
299    /// * `value` - 戻り値の配列
300    /// * `num` - 配列の要素数
301    pub push_result_table_boolean:
302        unsafe extern "C" fn(key: *const *const c_char, value: *const bool, num: c_int),
303
304    /// 編集セクション関数
305    pub edit: *mut EDIT_SECTION,
306
307    /// 関数を戻り値として追加する
308    pub push_result_function: unsafe extern "C" fn(
309        func: unsafe extern "C" fn(smp: *mut SCRIPT_MODULE_PARAM),
310        userdata: *mut c_void,
311    ),
312
313    /// 新しい関数に差し替えるので廃止します
314    pub deprecated_push_result_meta_table: unsafe extern "C" fn(
315        func_getter: unsafe extern "C" fn(smp: *mut SCRIPT_MODULE_PARAM),
316        func_setter: unsafe extern "C" fn(smp: *mut SCRIPT_MODULE_PARAM),
317        userdata: *mut c_void,
318    ),
319
320    /// 任意のユーザーデータのポインタ
321    pub userdata: *mut c_void,
322
323    /// メタテーブルの戻り値を追加する
324    pub push_result_meta_table: unsafe extern "C" fn(
325        meta_method_functions: *const META_METHOD_FUNCTION,
326        userdata: *mut c_void,
327    ),
328
329    /// 引数のメタテーブルのuserdataのポインタを取得する
330    pub get_param_meta_table: unsafe extern "C" fn(
331        index: c_int,
332        meta_method_functions: *mut META_METHOD_FUNCTION,
333    ) -> *mut c_void,
334
335    /// 引数の型を取得します
336    pub get_param_type: unsafe extern "C" fn(index: c_int) -> PARAM_TYPE,
337}
338
339/// メタメソッド定義構造体
340#[repr(C)]
341#[derive(Debug, Clone, Copy)]
342pub struct META_METHOD_FUNCTION {
343    /// メタメソッド名
344    pub method: *const c_char,
345    /// コールバック関数
346    pub func: unsafe extern "C" fn(smp: *mut SCRIPT_MODULE_PARAM),
347}
348
349/// スクリプトモジュール関数定義構造体
350#[repr(C)]
351#[derive(Debug, Clone, Copy)]
352pub struct SCRIPT_MODULE_FUNCTION {
353    /// 関数名
354    pub name: *const u16,
355    /// 関数へのポインタ
356    pub func: unsafe extern "C" fn(smp: *mut SCRIPT_MODULE_PARAM),
357}
358
359/// スクリプトモジュール構造体
360#[repr(C)]
361#[derive(Debug, Clone, Copy)]
362pub struct SCRIPT_MODULE_TABLE {
363    /// スクリプトモジュールの情報
364    pub information: *const u16,
365    /// 登録する関数の一覧 (SCRIPT_MODULE_FUNCTIONを列挙して関数名がnullの要素で終端したリストへのポインタ)
366    pub functions: *const SCRIPT_MODULE_FUNCTION,
367}