[wave] found_include_directive

Hi, I wanted to propose found_include_directive returning a bool. Where false would skip including the file. I need this so that I can selectively skip including files. I'm writing a dependency analysis for C++ files. Best regards, -- Felipe Magno de Almeida

I have modified it in my local copy to have this. On 5/18/07, Felipe Magno de Almeida <felipe.m.almeida@gmail.com> wrote:
Hi,
I wanted to propose found_include_directive returning a bool. Where false would skip including the file. I need this so that I can selectively skip including files. I'm writing a dependency analysis for C++ files.
Best regards, -- Felipe Magno de Almeida
-- Felipe Magno de Almeida

Felipe,
I have modified it in my local copy to have this.
That's a nice idea! Could you send me a patch, please? I'll incorporate it into the codebase. Regards Hartmut
On 5/18/07, Felipe Magno de Almeida <felipe.m.almeida@gmail.com> wrote:
Hi,
I wanted to propose found_include_directive returning a bool. Where false would skip including the file. I need this so that I can selectively skip including files. I'm writing a dependency analysis for C++ files.
Best regards, -- Felipe Magno de Almeida
-- Felipe Magno de Almeida _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On 5/18/07, Hartmut Kaiser <hartmut.kaiser@gmail.com> wrote:
Felipe,
I have modified it in my local copy to have this.
That's a nice idea! Could you send me a patch, please? I'll incorporate it into the codebase.
Sure, in the end of the message. Used cvs diff. Hope it is right.
Regards Hartmut
Index: util/cpp_iterator.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/wave/util/cpp_iterator.hpp,v retrieving revision 1.35.2.16 diff -r1.35.2.16 cpp_iterator.hpp 1205,1223c1205 < ctx.get_hooks().found_include_directive(f, include_next); < < file_path = util::impl::unescape_lit(file_path); < if (!ctx.find_include_file (file_path, dir_path, is_system, current_name)) { < BOOST_WAVE_THROW(preprocess_exception, bad_include_file, < file_path.c_str(), act_pos); < } < < fs::path native_path(file_path, fs::native); < < if (!fs::exists(native_path)) { < BOOST_WAVE_THROW(preprocess_exception, bad_include_file, < file_path.c_str(), act_pos); < } < < // test, if this file is known through a #pragma once directive < #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 < if (!ctx.has_pragma_once(native_path.native_file_string())) < #endif ---
if(ctx.get_hooks().found_include_directive(f, include_next))
1225,1251d1206 < // the new include file determines the actual current directory < ctx.set_current_directory(native_path.native_file_string().c_str()); < < // preprocess the opened file < boost::shared_ptr<base_iteration_context_type> new_iter_ctx ( < new iteration_context_type(native_path.native_file_string().c_str(), < act_pos, boost::wave::enable_prefer_pp_numbers(ctx.get_language()))); < < // call the include policy trace function < ctx.get_hooks().opened_include_file(dir_path, file_path, < ctx.get_iteration_depth(), is_system); < < // store current file position < iter_ctx->filename = act_pos.get_file(); < iter_ctx->line = act_pos.get_line(); < iter_ctx->if_block_depth = ctx.get_if_block_depth(); < < // push the old iteration context onto the stack and continue with the new < ctx.push_iteration_context(act_pos, iter_ctx); < iter_ctx = new_iter_ctx; < seen_newline = true; // fake a newline to trigger pp_directive < must_emit_line_directive = true; < < act_pos.set_file(iter_ctx->filename); // initialize file position < #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 < ctx.set_current_filename(iter_ctx->real_filename.c_str()); < #endif 1253,1254c1208,1256 < act_pos.set_line(iter_ctx->line); < act_pos.set_column(0); ---
file_path = util::impl::unescape_lit(file_path); if (!ctx.find_include_file (file_path, dir_path, is_system, current_name)) { BOOST_WAVE_THROW(preprocess_exception, bad_include_file, file_path.c_str(), act_pos); }
fs::path native_path(file_path, fs::native);
if (!fs::exists(native_path)) { BOOST_WAVE_THROW(preprocess_exception, bad_include_file, file_path.c_str(), act_pos); }
// test, if this file is known through a #pragma once directive #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 if (!ctx.has_pragma_once(native_path.native_file_string())) #endif { // the new include file determines the actual current directory ctx.set_current_directory(native_path.native_file_string().c_str());
// preprocess the opened file boost::shared_ptr<base_iteration_context_type> new_iter_ctx ( new iteration_context_type(native_path.native_file_string().c_str(), act_pos, boost::wave::enable_prefer_pp_numbers(ctx.get_language())));
// call the include policy trace function ctx.get_hooks().opened_include_file(dir_path, file_path, ctx.get_iteration_depth(), is_system);
// store current file position iter_ctx->filename = act_pos.get_file(); iter_ctx->line = act_pos.get_line(); iter_ctx->if_block_depth = ctx.get_if_block_depth();
// push the old iteration context onto the stack and continue with the new ctx.push_iteration_context(act_pos, iter_ctx); iter_ctx = new_iter_ctx; seen_newline = true; // fake a newline to trigger pp_directive must_emit_line_directive = true;
act_pos.set_file(iter_ctx->filename); // initialize file position #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 ctx.set_current_filename(iter_ctx->real_filename.c_str()); #endif
act_pos.set_line(iter_ctx->line); act_pos.set_column(0); }
-- Felipe Magno de Almeida

Thanks. Your suggested change is incorporated into the version in Boost CVS HEAD now. Regards Hartmut
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Felipe Magno de Almeida Sent: Friday, May 18, 2007 9:52 PM To: boost@lists.boost.org Subject: Re: [boost] [wave] found_include_directive
On 5/18/07, Hartmut Kaiser <hartmut.kaiser@gmail.com> wrote:
Felipe,
I have modified it in my local copy to have this.
That's a nice idea! Could you send me a patch, please? I'll incorporate it into the codebase.
Sure, in the end of the message. Used cvs diff. Hope it is right.
Regards Hartmut
Index: util/cpp_iterator.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/wave/util/cpp_iterator.hpp,v retrieving revision 1.35.2.16 diff -r1.35.2.16 cpp_iterator.hpp 1205,1223c1205 < ctx.get_hooks().found_include_directive(f, include_next); < < file_path = util::impl::unescape_lit(file_path); < if (!ctx.find_include_file (file_path, dir_path, is_system, current_name)) { < BOOST_WAVE_THROW(preprocess_exception, bad_include_file, < file_path.c_str(), act_pos); < } < < fs::path native_path(file_path, fs::native); < < if (!fs::exists(native_path)) { < BOOST_WAVE_THROW(preprocess_exception, bad_include_file, < file_path.c_str(), act_pos); < } < < // test, if this file is known through a #pragma once directive < #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 < if (!ctx.has_pragma_once(native_path.native_file_string())) < #endif ---
if(ctx.get_hooks().found_include_directive(f, include_next))
1225,1251d1206 < // the new include file determines the actual current directory < ctx.set_current_directory(native_path.native_file_string().c_str()); < < // preprocess the opened file < boost::shared_ptr<base_iteration_context_type> new_iter_ctx ( < new iteration_context_type(native_path.native_file_string().c_str(), < act_pos, boost::wave::enable_prefer_pp_numbers(ctx.get_language()))); < < // call the include policy trace function < ctx.get_hooks().opened_include_file(dir_path, file_path, < ctx.get_iteration_depth(), is_system); < < // store current file position < iter_ctx->filename = act_pos.get_file(); < iter_ctx->line = act_pos.get_line(); < iter_ctx->if_block_depth = ctx.get_if_block_depth(); < < // push the old iteration context onto the stack and continue with the new < ctx.push_iteration_context(act_pos, iter_ctx); < iter_ctx = new_iter_ctx; < seen_newline = true; // fake a newline to trigger pp_directive < must_emit_line_directive = true; < < act_pos.set_file(iter_ctx->filename); // initialize file position < #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 < ctx.set_current_filename(iter_ctx->real_filename.c_str()); < #endif 1253,1254c1208,1256 < act_pos.set_line(iter_ctx->line); < act_pos.set_column(0); ---
file_path = util::impl::unescape_lit(file_path); if (!ctx.find_include_file (file_path, dir_path,
is_system, current_name)) {
BOOST_WAVE_THROW(preprocess_exception, bad_include_file, file_path.c_str(), act_pos); }
fs::path native_path(file_path, fs::native);
if (!fs::exists(native_path)) { BOOST_WAVE_THROW(preprocess_exception, bad_include_file, file_path.c_str(), act_pos); }
// test, if this file is known through a #pragma once directive #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 if (!ctx.has_pragma_once(native_path.native_file_string())) #endif { // the new include file determines the actual current
directory
ctx.set_current_directory(native_path.native_file_string().c_str());
// preprocess the opened file boost::shared_ptr<base_iteration_context_type> new_iter_ctx ( new
iteration_context_type(native_path.native_file_string().c_str(),
act_pos, boost::wave::enable_prefer_pp_numbers(ctx.get_language())));
// call the include policy trace function ctx.get_hooks().opened_include_file(dir_path, file_path, ctx.get_iteration_depth(), is_system);
// store current file position iter_ctx->filename = act_pos.get_file(); iter_ctx->line = act_pos.get_line(); iter_ctx->if_block_depth = ctx.get_if_block_depth();
// push the old iteration context onto the stack and
continue with the new
ctx.push_iteration_context(act_pos, iter_ctx); iter_ctx = new_iter_ctx; seen_newline = true; // fake a newline to
trigger pp_directive
must_emit_line_directive = true;
act_pos.set_file(iter_ctx->filename); //
initialize file position
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0 ctx.set_current_filename(iter_ctx->real_filename.c_str()); #endif
act_pos.set_line(iter_ctx->line); act_pos.set_column(0); }
-- Felipe Magno de Almeida _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Felipe Magno de Almeida
-
Hartmut Kaiser