@@ -34,22 +34,22 @@ struct load_file_or_builtin_to_string
34
34
using iterator_type = typename IterContextT::iterator_type;
35
35
36
36
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
+
53
53
iter_ctx.first = iterator_type (
54
54
iter_ctx.instring .begin (), iter_ctx.instring .end (),
55
55
PositionT (iter_ctx.filename ), language);
@@ -75,7 +75,9 @@ struct custom_preprocessing_hooks : public boost::wave::context_policies::defaul
75
75
template <typename ContextT>
76
76
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)
77
77
{
78
- // on builtin return true
78
+ if (!m_includeFinder)
79
+ return false ;
80
+
79
81
dir_path = ctx.get_current_directory ().string ();
80
82
std::optional<std::string> result;
81
83
if (is_system) {
@@ -96,10 +98,11 @@ struct custom_preprocessing_hooks : public boost::wave::context_policies::defaul
96
98
97
99
// interpretation of #pragma's of the form 'wave option[(value)]'
98
100
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
+ )
103
106
{
104
107
auto optionStr = option.get_value ().c_str ();
105
108
if (strcmp (optionStr, " shader_stage" ) == 0 )
@@ -121,7 +124,7 @@ struct custom_preprocessing_hooks : public boost::wave::context_policies::defaul
121
124
auto found = stageFromIdent.find (shaderStageIdentifier);
122
125
if (found == stageFromIdent.end ())
123
126
{
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 () );
125
128
return false ;
126
129
}
127
130
valueIter++;
@@ -135,11 +138,14 @@ struct custom_preprocessing_hooks : public boost::wave::context_policies::defaul
135
138
return false ;
136
139
}
137
140
138
-
139
141
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 ;
143
149
}
144
150
};
145
151
0 commit comments