pub(crate) fn cond_create_enum_conversion(
    module: &mut Module,
    typename: &str,
    enumerators: &[(String, i64)]
) {
    let compu_method_find = module.compu_method.iter().find(|item| item.name == typename);
    if compu_method_find.is_none() {
        let mut new_compu_method = CompuMethod::new(
            typename.to_string(),
            format!("Conversion table for enum {}", typename),
            ConversionType::TabVerb,
            "%.4".to_string(),
            "".to_string()
        );
        new_compu_method.compu_tab_ref = Some(CompuTabRef::new(typename.to_string()));
        module.compu_method.push(new_compu_method);

        let compu_vtab_find = module
            .compu_vtab
            .iter()
            .find(|item| item.name == typename);
        let compu_vtab_range_find = module
            .compu_vtab_range
            .iter()
            .find(|item| item.name == typename);

        if compu_vtab_find.is_none() && compu_vtab_range_find.is_none() {
            let mut new_compu_vtab = CompuVtab::new(
                typename.to_string(),
                format!("Conversion table for enum {}", typename),
                ConversionType::TabVerb,
                enumerators.len() as u16
            );
            for (name, value) in enumerators {
                new_compu_vtab.value_pairs.push(
                    ValuePairsStruct::new(*value as f64, name.to_owned())
                );
            }
            module.compu_vtab.push(new_compu_vtab);
        }
    }
}
// create a COMPU_METHOD and a COMPU_VTAB for the typename of an enum
create a COMPU_METHOD and a COMPU_VTAB for the typename of an enum
create a COMPU_METHOD and a COMPU_VTAB for the typename of an enum
pub(crate) fn cond_create_enum_conversion(
    module: &mut Module,
    typename: &str,
    enumerators: &[(String, i64)]
) {
    let compu_method_find = module.compu_method.iter().find(|item| item.name == typename);
    if compu_method_find.is_none() {
        let mut new_compu_method = CompuMethod::new(
            typename.to_string(),
            format!("Conversion table for enum {}", typename),
            ConversionType::TabVerb,
            "%.4".to_string(),
            "".to_string()
        );
        new_compu_method.compu_tab_ref = Some(CompuTabRef::new(typename.to_string()));
        module.compu_method.push(new_compu_method);
        let compu_vtab_find = module
            .compu_vtab
            .iter()
            .find(|item| item.name == typename);
        let compu_vtab_range_find = module
            .compu_vtab_range
            .iter()
            .find(|item| item.name == typename);
        if compu_vtab_find.is_none() && compu_vtab_range_find.is_none() {
            let mut new_compu_vtab = CompuVtab::new(
                typename.to_string(),
                format!("Conversion table for enum {}", typename),
                ConversionType::TabVerb,
                enumerators.len() as u16
            );
            for (name, value) in enumerators {
                new_compu_vtab.value_pairs.push(
                    ValuePairsStruct::new(*value as f64, name.to_owned())
                );
            }
            module.compu_vtab.push(new_compu_vtab);
        }
    }
}
pub ( crate ) fn cond_create_enum_conversion ( module : & mut Module , typename : & str , enumerators : & [ ( String , i64 ) ] ) { let compu_method_find = module . compu_method . iter ( ) . find ( | item | item . name == typename ) ; if compu_method_find . is_none ( ) { let mut new_compu_method = CompuMethod :: new ( typename . to_string ( ) , format ! ( " " typename ) , ConversionType :: TabVerb , " " . to_string ( ) , " " . to_string ( ) ) ; new_compu_method . compu_tab_ref = Some ( CompuTabRef :: new ( typename . to_string ( ) ) ) ; module . compu_method . push ( new_compu_method ) ; let compu_vtab_find = module . compu_vtab . iter ( ) . find ( | item | item . name == typename ) ; let compu_vtab_range_find = module . compu_vtab_range . iter ( ) . find ( | item | item . name == typename ) ; if compu_vtab_find . is_none ( ) && compu_vtab_range_find . is_none ( ) { let mut new_compu_vtab = CompuVtab :: new ( typename . to_string ( ) , format ! ( " " typename ) , ConversionType :: TabVerb , enumerators . len ( ) as u16 ) ; for ( name , value ) in enumerators { new_compu_vtab . value_pairs . push ( ValuePairsStruct :: new ( * value as f64 , name . to_owned ( ) ) ) ; } module . compu_vtab . push ( new_compu_vtab ) ; } } }
create a COMPU_METHOD and a COMPU_VTAB for the typename of an enum
create a COMPU_METHOD and a COMPU_VTAB for the typename of an enum
module
&mut Module
typename
&str
enumerators
&[(String, i64)]