<commit_before>use std::os;
use std::from_str::FromStr;

#[deriving(Eq)]
enum ConfigOption {
    Unsupported,
    Disabled,
    Enabled
}

impl ConfigOption {
    fn enabled(&self) -> bool {
        match *self {
            Enabled => true,
            _ => false
        }
    }
}

pub struct Config {
    max_size: uint,
    drawlist_count: uint,
    hmd_size: f32,
    bindless: ConfigOption,
    instanced: ConfigOption,
    profile: ConfigOption,
    opencl: ConfigOption
}

fn get_setting_option(name: &str, default: ConfigOption) -> ConfigOption {
   let is_set = match os::getenv(name) {
        Some(s) => {
            let s: ~str = s.chars().map(|c| c.to_lowercase()).collect();
            match s.as_slice() {
                "true" => Some(true),
                "enabled" => Some(true),
                "1" => Some(true),
                "false" => Some(false),
                "disabled" => Some(false),
                "0" => Some(false),
                _ => None
            }
        }
        None => None
    };

    match is_set {
        Some(true) => Enabled,
        Some(false) => Disabled,
        None => default
    }
}

fn check_gl_version(gl_version: (uint, uint), min: (uint, uint), if_supported: ConfigOption) -> ConfigOption {
    let (m_major, m_minor) = min;
    let (gl_major, gl_minor) = gl_version;

    if gl_major > m_major {
        if_supported
    } else if gl_major == m_major && gl_minor >= m_minor {
        if_supported
    } else {
        Unsupported
    }
}

fn get_setting_from_str<T: FromStr>(name: &str, default: T) -> T {
    let str_value = match os::getenv(name) {
        Some(s) => s,
        None => return default
    };

    match FromStr::from_str(str_value) {
        Some(v) => v,
        None => default
    }
}

impl Config
{
    pub fn new(gl_version: (uint, uint)) -> Config {
        Config {
            hmd_size: get_setting_from_str("HMD_SIZE", 1.5f32),
            max_size: get_setting_from_str("MAX_OBJECTS", 64u*1024),
            drawlist_count: get_setting_from_str("DRAWLIST_COUNT", 2u),
            opencl: get_setting_option("OPENCL_SUPPORT", Enabled),<commit_msg>updated config for drawlist of 3<commit_after>use std::os;
use std::from_str::FromStr;

#[deriving(Eq)]
enum ConfigOption {
    Unsupported,
    Disabled,
    Enabled
}

impl ConfigOption {
    fn enabled(&self) -> bool {
        match *self {
            Enabled => true,
            _ => false
        }
    }
}

pub struct Config {
    max_size: uint,
    drawlist_count: uint,
    hmd_size: f32,
    bindless: ConfigOption,
    instanced: ConfigOption,
    profile: ConfigOption,
    opencl: ConfigOption
}

fn get_setting_option(name: &str, default: ConfigOption) -> ConfigOption {
   let is_set = match os::getenv(name) {
        Some(s) => {
            let s: ~str = s.chars().map(|c| c.to_lowercase()).collect();
            match s.as_slice() {
                "true" => Some(true),
                "enabled" => Some(true),
                "1" => Some(true),
                "false" => Some(false),
                "disabled" => Some(false),
                "0" => Some(false),
                _ => None
            }
        }
        None => None
    };

    match is_set {
        Some(true) => Enabled,
        Some(false) => Disabled,
        None => default
    }
}

fn check_gl_version(gl_version: (uint, uint), min: (uint, uint), if_supported: ConfigOption) -> ConfigOption {
    let (m_major, m_minor) = min;
    let (gl_major, gl_minor) = gl_version;

    if gl_major > m_major {
        if_supported
    } else if gl_major == m_major && gl_minor >= m_minor {
        if_supported
    } else {
        Unsupported
    }
}

fn get_setting_from_str<T: FromStr>(name: &str, default: T) -> T {
    let str_value = match os::getenv(name) {
        Some(s) => s,
        None => return default
    };

    match FromStr::from_str(str_value) {
        Some(v) => v,
        None => default
    }
}

impl Config
{
    pub fn new(gl_version: (uint, uint)) -> Config {
        Config {
            hmd_size: get_setting_from_str("HMD_SIZE", 1.5f32),
            max_size: get_setting_from_str("MAX_OBJECTS", 64u*1024),
            drawlist_count: get_setting_from_str("DRAWLIST_COUNT", 3u),
            opencl: get_setting_option("OPENCL_SUPPORT", Enabled),
{'fraction_non_alphanumeric': 0.1302433371958285, 'fraction_numerical': 0.007184241019698725, 'mean_word_length': 2.078459343794579, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, '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': '4796401', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1406, 'n_words': 308}