@@ -31,23 +31,9 @@ struct load_to_string final
31
31
template <typename PositionT>
32
32
static void init_iterators (IterContextT& iter_ctx, PositionT const & act_pos, boost::wave::language_support language)
33
33
{
34
- using iterator_type = typename IterContextT::iterator_type;
35
-
36
- std::string filepath (iter_ctx.filename .begin (),iter_ctx.filename .end ());
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 located then must be possible to open!
48
- assert (result);
49
- iter_ctx.instring = *result;
34
+ iter_ctx.instring = iter_ctx.ctx .get_located_include_content ();
50
35
36
+ using iterator_type = IterContextT::iterator_type;
51
37
iter_ctx.first = iterator_type (iter_ctx.instring .begin (),iter_ctx.instring .end (),PositionT (iter_ctx.filename ),language);
52
38
iter_ctx.last = iterator_type ();
53
39
}
@@ -83,6 +69,7 @@ struct preprocessing_hooks final : public boost::wave::context_policies::default
83
69
m_logger.log (" Pre-processor error: Bad include file.\n '%s' does not exist." , nbl::system::ILogger::ELL_ERROR, file_path.c_str ());
84
70
return false ;
85
71
}
72
+ ctx.set_located_include_content (std::move (*result));
86
73
// TODO:
87
74
native_name = file_path;
88
75
return true ;
@@ -149,29 +136,6 @@ struct preprocessing_hooks final : public boost::wave::context_policies::default
149
136
IShader::E_SHADER_STAGE m_pragmaStage;
150
137
};
151
138
152
- class include_paths final
153
- {
154
- public:
155
- inline include_paths () : current_dir() {}
156
-
157
- // Nabla Additions Start
158
- system::path get_current_directory () const
159
- {
160
- return current_dir;
161
- }
162
- void set_current_directory (char const * path_)
163
- {
164
- namespace fs = nbl::system;
165
- fs::path filepath (path_);
166
- fs::path filename = current_dir.is_absolute () ? filepath : (current_dir / filepath);
167
- current_dir = filename.parent_path ();
168
- }
169
- // Nabla Additions End
170
-
171
- private:
172
- system::path current_dir;
173
- };
174
-
175
139
class context : private boost ::noncopyable
176
140
{
177
141
private:
@@ -364,10 +328,24 @@ class context : private boost::noncopyable
364
328
}
365
329
366
330
// Nabla Additions Start
367
- // return the directory of the currently preprocessed file
368
331
system::path get_current_directory () const
369
332
{
370
- return includes.get_current_directory ();
333
+ return current_dir;
334
+ }
335
+ void set_current_directory (char const * path_)
336
+ {
337
+ namespace fs = nbl::system;
338
+ fs::path filepath (path_);
339
+ fs::path filename = current_dir.is_absolute () ? filepath : (current_dir / filepath);
340
+ current_dir = filename.parent_path ();
341
+ }
342
+ void set_located_include_content (core::string&& content)
343
+ {
344
+ located_include_content = std::move (content);
345
+ }
346
+ const core::string& get_located_include_content () const
347
+ {
348
+ return located_include_content;
371
349
}
372
350
// Nabla Additions End
373
351
@@ -385,7 +363,7 @@ class context : private boost::noncopyable
385
363
return ;
386
364
387
365
nbl::system::path fpath (filename);
388
- includes. set_current_directory (fpath.string ().c_str ());
366
+ set_current_directory (fpath.string ().c_str ());
389
367
has_been_initialized = true ; // execute once
390
368
}
391
369
@@ -395,12 +373,6 @@ class context : private boost::noncopyable
395
373
return macros.is_defined (begin, end);
396
374
}
397
375
398
- // maintain include paths (helper functions)
399
- void set_current_directory (char const * path_)
400
- {
401
- includes.set_current_directory (path_);
402
- }
403
-
404
376
// conditional compilation contexts
405
377
bool get_if_block_status () const { return ifblocks.get_status (); }
406
378
bool get_if_block_some_part_status () const
@@ -477,8 +449,13 @@ class context : private boost::noncopyable
477
449
bool has_been_initialized; // set cwd once
478
450
std::string current_relative_filename; // real relative name of current preprocessed file
479
451
452
+ // Nabla Additions Start
453
+ // these are temporaries!
454
+ system::path current_dir;
455
+ core::string located_include_content;
456
+ // Nabla Additions End
457
+
480
458
boost::wave::util::if_block_stack ifblocks; // conditional compilation contexts
481
- include_paths includes; // lists of include directories to search
482
459
iteration_context_stack_type iter_ctxs; // iteration contexts
483
460
macromap_type macros; // map of defined macros
484
461
boost::wave::language_support language; // supported language/extensions
0 commit comments