@@ -34,22 +34,22 @@ struct load_file_or_builtin_to_string
3434 using iterator_type = typename IterContextT::iterator_type;
3535
3636 std::string filepath (iter_ctx.filename .begin (), iter_ctx.filename .end ());
37- auto inclFinder = iter_ctx.ctx .get_hooks ().m_includeFinder ;
38- if (inclFinder)
39- {
40- std::optional<std::string> result;
41- system::path requestingSourceDir (iter_ctx.ctx .get_current_directory ().string ());
42- if (iter_ctx.type == IterContextT::base_type::file_type::system_header) // is it a sys include (#include <...>)?
43- result = inclFinder->getIncludeStandard (requestingSourceDir, filepath);
44- else // regular #include "..."
45- result = inclFinder->getIncludeRelative (requestingSourceDir, filepath);
46-
47- if (!result)
48- BOOST_WAVE_THROW_CTX (iter_ctx.ctx , boost::wave::preprocess_exception,
49- bad_include_file, iter_ctx.filename .c_str (), act_pos);
50- auto & res_str = *result;
51- iter_ctx.instring = res_str;
52- }
37+ const auto inclFinder = iter_ctx.ctx .get_hooks ().m_includeFinder ;
38+ assert (inclFinder);
39+
40+ std::optional<std::string> result;
41+ system::path requestingSourceDir (iter_ctx.ctx .get_current_directory ().string ());
42+ if (iter_ctx.type == IterContextT::base_type::file_type::system_header) // is it a sys include (#include <...>)?
43+ result = inclFinder->getIncludeStandard (requestingSourceDir, filepath);
44+ else // regular #include "..."
45+ result = inclFinder->getIncludeRelative (requestingSourceDir, filepath);
46+
47+ if (!result)
48+ BOOST_WAVE_THROW_CTX (iter_ctx.ctx , boost::wave::preprocess_exception,
49+ bad_include_file, iter_ctx.filename .c_str (), act_pos);
50+ auto & res_str = *result;
51+ iter_ctx.instring = res_str;
52+
5353 iter_ctx.first = iterator_type (
5454 iter_ctx.instring .begin (), iter_ctx.instring .end (),
5555 PositionT (iter_ctx.filename ), language);
@@ -75,7 +75,9 @@ struct custom_preprocessing_hooks : public boost::wave::context_policies::defaul
7575 template <typename ContextT>
7676 bool locate_include_file (ContextT& ctx, std::string& file_path, bool is_system, char const * current_name, std::string& dir_path, std::string& native_name)
7777 {
78- // on builtin return true
78+ if (!m_includeFinder)
79+ return false ;
80+
7981 dir_path = ctx.get_current_directory ().string ();
8082 std::optional<std::string> result;
8183 if (is_system) {
@@ -96,10 +98,11 @@ struct custom_preprocessing_hooks : public boost::wave::context_policies::defaul
9698
9799 // interpretation of #pragma's of the form 'wave option[(value)]'
98100 template <typename ContextT, typename ContainerT>
99- bool
100- interpret_pragma (ContextT const & ctx, ContainerT& pending,
101- typename ContextT::token_type const & option, ContainerT const & values,
102- typename ContextT::token_type const & act_token)
101+ bool interpret_pragma (
102+ ContextT const & ctx, ContainerT& pending,
103+ typename ContextT::token_type const & option, ContainerT const & values,
104+ typename ContextT::token_type const & act_token
105+ )
103106 {
104107 auto optionStr = option.get_value ().c_str ();
105108 if (strcmp (optionStr, " shader_stage" ) == 0 )
@@ -121,7 +124,7 @@ struct custom_preprocessing_hooks : public boost::wave::context_policies::defaul
121124 auto found = stageFromIdent.find (shaderStageIdentifier);
122125 if (found == stageFromIdent.end ())
123126 {
124- m_logger.log (" Pre-processor error:\n Malformed shader_stage pragma. Unknown stage '%s'" , nbl::system::ILogger::ELL_ERROR, shaderStageIdentifier);
127+ m_logger.log (" Pre-processor error:\n Malformed shader_stage pragma. Unknown stage '%s'" , nbl::system::ILogger::ELL_ERROR, shaderStageIdentifier. c_str () );
125128 return false ;
126129 }
127130 valueIter++;
@@ -135,11 +138,14 @@ struct custom_preprocessing_hooks : public boost::wave::context_policies::defaul
135138 return false ;
136139 }
137140
138-
139141 template <typename ContextT, typename ContainerT>
140- bool found_error_directive (ContextT const & ctx, ContainerT const & message) {
141- m_logger.log (" Pre-processor error:\n %s" , nbl::system::ILogger::ELL_ERROR, message);
142- return true ;
142+ bool found_error_directive (ContextT const & ctx, ContainerT const & message)
143+ {
144+ std::ostringstream stream;
145+ for (const auto & token : message)
146+ stream << token.get_value ();
147+ m_logger.log (" Pre-processor encountered error directive:\n %s" , nbl::system::ILogger::ELL_ERROR, stream.str ().c_str ());
148+ return false ;
143149 }
144150};
145151
0 commit comments