pub enum TypeRepr {
CType {
specs: CTypeSpecs,
derived: Vec<CDerivedType>,
source: CTypeSource,
},
RustType {
repr: RustTypeRepr,
source: RustTypeSource,
},
Inferred(InferredType),
}Expand description
型表現(出所情報を含む)
Variants§
CType
C 言語の型(CHeader, Apidoc, InlineFn 共通)
Fields
specs: CTypeSpecs型指定子(int, char, struct X, など)
derived: Vec<CDerivedType>派生型(ポインタ、配列など)
source: CTypeSource出所(デバッグ用)
RustType
Rust バインディングからの型(syn::Type 由来)
Inferred(InferredType)
推論で導出
Implementations§
Source§impl TypeRepr
impl TypeRepr
Sourcepub fn source_display(&self) -> &'static str
pub fn source_display(&self) -> &'static str
出所の表示用文字列を取得
Sourcepub fn is_fn_param_source(&self) -> bool
pub fn is_fn_param_source(&self) -> bool
void 型かどうかを判定
ポインタを含まない void 型の場合に true を返す。
void * は false を返す(有効なポインタ型のため)。
bindings.rs の FnParam ソースかどうか
Sourcepub fn confidence_tier(&self) -> u8
pub fn confidence_tier(&self) -> u8
型情報の確度 Tier を返す
- Tier 1: bindings.rs (bindgen生成、変更不可)
- Tier 2: C ヘッダー宣言 / inline 関数パラメータ (変更不可)
- Tier 3: apidoc (embed.fnc 等、参考情報)
- Tier 4: 推論結果 (変更可能)
pub fn is_void(&self) -> bool
Sourcepub fn make_outer_pointer_mut(&mut self)
pub fn make_outer_pointer_mut(&mut self)
最外ポインタの is_const を true に変更する 最外ポインタの is_const を false に変更する(must-mut 用)
pub fn make_outer_pointer_const(&mut self)
Sourcepub fn is_pointer_type(&self) -> bool
pub fn is_pointer_type(&self) -> bool
ポインタ型かどうか (has_outer_pointer のエイリアス)。
Inferred ラッパは resolved_type() を経由して中身を再帰参照する点で
has_outer_pointer と挙動が異なる (本メソッドは構造的「実体型」判定に
使う)。has_outer_pointer 自体は既存の使用箇所が Inferred を別扱い
しているため挙動を変えない。
Sourcepub fn is_void_pointer(&self) -> bool
pub fn is_void_pointer(&self) -> bool
void * / *mut c_void / *const c_void かどうかを 構造的に 判定する。
文字列 contains("void") ではなく specs/derived の構造で判定するので、
*mut struct void_table のような偽陽性に引っかからない。
Inferred ラッパは resolved_type() 経由で中身を再帰参照する。
Sourcepub fn is_concrete_pointer(&self) -> bool
pub fn is_concrete_pointer(&self) -> bool
具体的なポインタ (void * ではないポインタ型) かどうか
Sourcepub fn has_outer_pointer(&self) -> bool
pub fn has_outer_pointer(&self) -> bool
最外ポインタを持つかどうか
既存呼出側の挙動を変えないため Inferred は false を返す
(再帰判定が必要な場合は is_pointer_type を使うこと)。
Sourcepub fn from_apidoc_string(s: &str, interner: &StringInterner) -> Self
pub fn from_apidoc_string(s: &str, interner: &StringInterner) -> Self
Apidoc の型文字列から TypeRepr を作成
Sourcepub fn from_rust_string(s: &str) -> Self
pub fn from_rust_string(s: &str) -> Self
Rust 形式の型文字列から TypeRepr を作成
*mut T, *const T, c_int などの Rust 形式の型文字列をパースする。
rust_decl.rs からの型情報の読み込みに使用する。
Sourcepub fn from_unified_type(ut: &UnifiedType, interner: &StringInterner) -> Self
pub fn from_unified_type(ut: &UnifiedType, interner: &StringInterner) -> Self
構造ベース: UnifiedType から TypeRepr を直接構築する。
bindings.rs (syn::File) → RustField.uty (UnifiedType) で得た
構造化情報を、文字列を経由せず TypeRepr に変換する。
Pointer / Array / Named / 基本型は CType として表現し、
FnPtr / Verbatim / Unknown は表現できないので RustType の
Unknown(canonical_string) にフォールバックする。
Source は CTypeSource::Apidoc { raw } で記録する (tier 3 相当)。
bindings は本来 tier 1 だが、本メソッドの呼出元 (anonymous union
メンバ解決) は元の C-side フィールド型を補完する用途なので、tier 3
で十分。tier 1 が必要な経路ができたら別 source variant を追加する。
Sourcepub fn from_decl(
specs: &DeclSpecs,
declarator: &Declarator,
_interner: &StringInterner,
) -> Self
pub fn from_decl( specs: &DeclSpecs, declarator: &Declarator, _interner: &StringInterner, ) -> Self
DeclSpecs と Declarator から TypeRepr を作成
C ヘッダーのパース結果から直接 TypeRepr を生成する。 fields_dict.rs でのフィールド型収集に使用する。
Sourcepub fn from_type_name(type_name: &TypeName, interner: &StringInterner) -> Self
pub fn from_type_name(type_name: &TypeName, interner: &StringInterner) -> Self
TypeName (パーサー出力) から TypeRepr を作成
parser::parse_type_from_string の結果から TypeRepr を生成する。
from_apidoc_string の代替として使用し、完全な C パーサーを活用する。
Sourcepub fn from_c_type_string(
s: &str,
interner: &StringInterner,
files: &FileRegistry,
typedefs: &HashSet<InternedStr>,
) -> Self
pub fn from_c_type_string( s: &str, interner: &StringInterner, files: &FileRegistry, typedefs: &HashSet<InternedStr>, ) -> Self
C 型文字列から TypeRepr を作成(パーサー版)
parser.rs の parse_type_from_string を使用して完全な C パーサーで解析する。
files と typedefs が必要なため、SemanticAnalyzer など型情報が揃っている
コンテキストでの使用を推奨。
パースに失敗した場合は from_apidoc_string と同じ簡易パーサーにフォールバックする。
Sourcepub fn to_display_string(&self, interner: &StringInterner) -> String
pub fn to_display_string(&self, interner: &StringInterner) -> String
後方互換: 文字列に変換(デバッグ用)
Sourcepub fn to_rust_string(&self, interner: &StringInterner) -> String
pub fn to_rust_string(&self, interner: &StringInterner) -> String
Rust コード生成用の型文字列に変換
Source§impl TypeRepr
impl TypeRepr
Sourcepub fn pointee_name(&self) -> Option<InternedStr>
pub fn pointee_name(&self) -> Option<InternedStr>
ポインタ型の参照先の構造体/typedef 名を InternedStr で取得
PtrMember (->) の base 型から構造体名を抽出するために使用。
例: *mut SV → Some(SV), XPVHV * → Some(XPVHV)
Sourcepub fn type_name(&self) -> Option<InternedStr>
pub fn type_name(&self) -> Option<InternedStr>
非ポインタ型の構造体/typedef 名を InternedStr で取得
Member (.) の base 型から構造体名を抽出するために使用。
例: union _xhvnameu → Some(_xhvnameu), SV → Some(SV)