<commit_before>use analysis;
use analysis::rust_type::rust_type;
use analysis::type_kind::TypeKind;
use env::Env;
use library;
use traits::*;

pub trait TranslateFromGlib {
    fn translate_from_glib_as_function(&self, env: &Env,
        func: &analysis::functions::Info) -> (String, String);
}

impl TranslateFromGlib for library::Parameter {
    fn translate_from_glib_as_function(&self,
        env: &Env, func: &analysis::functions::Info) -> (String, String) {
        let kind = TypeKind::of(&env.library, self.typ);
        if func.kind == library::FunctionKind::Constructor {
            let rust_type = rust_type(env, self.typ);
            if rust_type.as_str() != func.class_name.as_str() {
                let from_glib_xxx = from_glib_xxx(self.transfer);
                (
                    format!("{}::{}", rust_type.as_str(), from_glib_xxx.0),
                    format!("{}.downcast_unchecked()",from_glib_xxx.1)
                )
            } else {
                ("TODO:constructors_body ".into(), String::new())
            }
        } else {
            match kind {
                TypeKind::Converted => ("from_glib(".into(), ")".into()),
                TypeKind::Direct |
                    TypeKind::Enumeration => (String::new(), String::new()),
                //TODO: check gtk_dialog_get_content_area <type name="Box" c:type="GtkWidget*"/>
                TypeKind::Object => from_glib_xxx(self.transfer),
                _ => (format!("TODO {:?}:", kind), String::new()),<commit_msg>Make Option<String> return value conversion<commit_after>use analysis;
use analysis::rust_type::rust_type;
use analysis::type_kind::TypeKind;
use env::Env;
use library;
use traits::*;

pub trait TranslateFromGlib {
    fn translate_from_glib_as_function(&self, env: &Env,
        func: &analysis::functions::Info) -> (String, String);
}

impl TranslateFromGlib for library::Parameter {
    fn translate_from_glib_as_function(&self,
        env: &Env, func: &analysis::functions::Info) -> (String, String) {
        let kind = TypeKind::of(&env.library, self.typ);
        if func.kind == library::FunctionKind::Constructor {
            let rust_type = rust_type(env, self.typ);
            if rust_type.as_str() != func.class_name.as_str() {
                let from_glib_xxx = from_glib_xxx(self.transfer);
                (
                    format!("{}::{}", rust_type.as_str(), from_glib_xxx.0),
                    format!("{}.downcast_unchecked()",from_glib_xxx.1)
                )
            } else {
                ("TODO:constructors_body ".into(), String::new())
            }
        } else {
            match kind {
                TypeKind::Converted => ("from_glib(".into(), ")".into()),
                TypeKind::Direct |
                    TypeKind::Enumeration => (String::new(), String::new()),
                //TODO: check gtk_dialog_get_content_area <type name="Box" c:type="GtkWidget*"/>
                TypeKind::Pointer | //Checked only for Option<String>
                    TypeKind::Object => from_glib_xxx(self.transfer),
                _ => (format!("TODO {:?}:", kind), String::new()),
{'fraction_non_alphanumeric': 0.15362595419847327, 'fraction_numerical': 0.001272264631043257, 'mean_word_length': 2.4221980413492927, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4872879', 'n_tokens_mistral': 940, 'n_tokens_neox': 918, 'n_words': 170}