import collections
from paramset import input_types
from paramset import use_map
header = """
//! This module provides helpers for generating `ParamSet` structures concisely. This is useful
//! for doctests.
use crate::core::geometry::Normal3f;
use crate::core::geometry::Point2f;
use crate::core::geometry::Point3f;
use crate::core::geometry::Vector2f;
use crate::core::geometry::Vector3f;
use crate::core::paramset::ParamList;
use crate::core::paramset::ParamSet;
use crate::core::paramset::ParamSetItem;
use crate::core::paramset::Value;
use crate::core::spectrum::Spectrum;
use crate::Float;
"""
tmpl = """
/// Creates a `ParamSet` with one entry containing `name` and set to `vals`.
///
/// # Examples
/// ```
/// use pbrt::core::paramset::testutils::make_{2}_param_set;
/// {5}
/// let ps = make_{2}_param_set("value", vec![{3}]);
/// assert_eq!(ps.find_one_{2}("value", {4}), {3});
/// assert_eq!(ps.find_one_{2}("non-existent", {4}), {4});
/// ```
pub fn make_{2}_param_set(name: &str, vals: Vec<{1}>) -> ParamSet {{
vec![make_{2}(name, vals)].into()
}}
/// Creates a `ParamSetItem` with `name` set to `vals`.
pub fn make_{2}(name: &str, vals: Vec<{1}>) -> ParamSetItem {{
ParamSetItem::new(name, &Value::{0}(ParamList(vals)))
}}
"""
def gen():
for t in input_types:
use = ''
if t.wrapped_type in use_map:
use = '{}\n'.format(use_map[t.wrapped_type])
print(tmpl.format(
t.wrapped_type,
t.native_type,
t.wrapped_type.lower(),
t.example_good,
t.example_bad,
use,
))
print(header)
gen()