|
Boost Users : |
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2006-06-16 21:12:05
Andreas Sæbjørnsen wrote:
> A change I have done to Wave which I have not told you about
> earlier is to
> change the behaviour of on_warning(...) in
> 'tboost/wave/util/cpp_iterator.hpp' to
> continue if a #warning directive is found, and not treat it
> like an error. I do not know
> if the CVS-version still behaves in this way. I also added a
> preprocessing hook
> on_warning(..) for the warning directive as I need to extract
> it. What do you think of this
> change? (Code Below for on_warning. Changed
> 'preprocessing_hooks.hpp' attached).
Hmmm. The 'warning_directive' preprocess_exception is recoverable. That
means you may simply continue to iterate after catching this type of
exception (see the wave driver how this may be achieved). That's the reason
why I made the warning to throw an exception (same as #error). I'm not sure
if we really should change this behaviour (even more as the driver currently
depends on that).
OTOH I like your idea to add a on_warning() pp hook function (same should be
added for #error as well). What do you think, what if we use the return
value of the on_warning() pp hook to decide, whether to throw the exception?
This way we could keep the default behaviour (throwing) but you could
enforce the non-throwing behaviour simply by returning false.
Regards Hartmut
>
> Thanks
> Andreas
>
>
> #if BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0
> //////////////////////////////////////////////////////////////
> /////////////////
> //
> // on_warning(): handle #warning directives
> //
> //////////////////////////////////////////////////////////////
> /////////////////
> template <typename ContextT>
> inline void
> pp_iterator_functor<ContextT>::on_warning(
> typename parse_tree_type::const_iterator const &begin,
> typename parse_tree_type::const_iterator const &end)
> {
> BOOST_ASSERT(ctx.get_if_block_status());
>
>
>
> // preprocess the given sequence into the provided list
> token_sequence_type expanded;
> get_token_value<result_type, parse_node_type> get_value;
>
>
>
> typename ref_transform_iterator_generator<
> get_token_value<result_type, parse_node_type>,
> typename parse_tree_type::const_iterator
> >::type first = make_ref_transform_iterator(begin, get_value);
>
>
>
> #if BOOST_WAVE_PREPROCESS_ERROR_MESSAGE_BODY != 0
> // preprocess the body of this #warning message
> token_sequence_type toexpand;
>
>
>
> std::copy(first, make_ref_transform_iterator(end, get_value),
> std::inserter(toexpand, toexpand.end()));
>
>
>
> typename token_sequence_type::iterator begin2 = toexpand.begin();
> ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
> false);
> #else
> // simply copy the body of this #warning message to the
> issued diagnostic
> // message
> std::copy(first, make_ref_transform_iterator(end, get_value),
> std::inserter(expanded, expanded.end()));
> #endif
> //AS(051706) Added an extra hook to send the warning directive
> std::cout << "The warning is: " <<
> boost::wave::util::impl::as_string(expanded).c_str()
> << std::endl;
> ctx.get_hooks().on_warning(toexpand);
>
>
>
> //AS(051606) Do not treat warning directives as errors
> #if 0
> // report the corresponding error
> BOOST_WAVE_THROW(preprocess_exception, warning_directive,
> boost::wave::util::impl::as_string(expanded).c_str(),
> act_pos);
> #endif
>
>
>
> }
> #endif // BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0
>
>
>
>
>
>
>
>
> Regards Hartmut
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net