[C++-sig] Boost.Python v2: user-accessible from_python conversions

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Tue Jul 2 22:58:41 CEST 2002


--- David Abrahams <david.abrahams at rcn.com> wrote:
> > Would I want to use extract<T>() in a revision of struct
> > register_container_from_python_sequence posted earlier?
> 
> I don't think so; consider: what T would you extract?

T = container_element_type const& or container_element_type:

    static void* convertible(PyObject* obj_ptr)
    {
      //...
      for(std::size_t i=0;i<seq.size();i++) {
        handle<> seq_i = seq[i]; // VC6 requires step-by-step expressions
>>>>    arg_from_python<container_element_type const&> from_py(seq_i.get());
        if (!from_py.convertible()) return 0;
      }
      return obj_ptr;
    }

    static void construct(
      PyObject* obj_ptr, boost::python::converter::rvalue_stage1_data* data)
    {
      //...
      for(std::size_t i=0;i<seq.size();i++) {
        ContainerAdaptor::set_value(result, i,
>>>>    extractor<container_element_type>::get(seq[i]));
      }
    }
  };


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com





More information about the Cplusplus-sig mailing list