Skip to content

Commit

Permalink
adjust constructing sources
Browse files Browse the repository at this point in the history
  • Loading branch information
robtfm committed Jul 17, 2023
1 parent 63bc729 commit c2fed51
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/compose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,8 @@ impl Composer {
});
}

let substituted_source = self.sanitize_and_set_auto_bindings(source);

let (
PreprocessorMetaData {
name: module_name,
Expand All @@ -1493,7 +1495,7 @@ impl Composer {
_,
) = self
.preprocessor
.get_preprocessor_metadata(source, false)
.get_preprocessor_metadata(&substituted_source, false)
.map_err(|inner| ComposerError {
inner,
source: ErrSource::Constructing {
Expand Down Expand Up @@ -1547,7 +1549,7 @@ impl Composer {
),
source: ErrSource::Constructing {
path: file_path.to_owned(),
source: source.to_owned(),
source: substituted_source.to_owned(),
offset: 0,
},
})?;
Expand Down Expand Up @@ -1625,14 +1627,16 @@ impl Composer {
additional_imports,
} = desc;

let sanitized_source = self.sanitize_and_set_auto_bindings(source);

let (_, defines) = self
.preprocessor
.get_preprocessor_metadata(source, true)
.get_preprocessor_metadata(&sanitized_source, true)
.map_err(|inner| ComposerError {
inner,
source: ErrSource::Constructing {
path: file_path.to_owned(),
source: source.to_owned(),
source: sanitized_source.to_owned(),
offset: 0,
},
})?;
Expand All @@ -1643,25 +1647,24 @@ impl Composer {
meta: PreprocessorMetaData { name, imports },
} = self
.preprocessor
.preprocess(source, &shader_defs, false)
.preprocess(&sanitized_source, &shader_defs, false)
.map_err(|inner| ComposerError {
inner,
source: ErrSource::Constructing {
path: file_path.to_owned(),
source: source.to_owned(),
source: sanitized_source.to_owned(),
offset: 0,
},
})?;

let name = name.unwrap_or_default();
let substituted_source = self.sanitize_and_set_auto_bindings(source);
let substituted_source = self
.substitute_shader_string(&substituted_source, &imports)
.substitute_shader_string(&sanitized_source, &imports)
.map_err(|inner| ComposerError {
inner,
source: ErrSource::Constructing {
path: file_path.to_owned(),
source: source.to_owned(),
source: sanitized_source.to_owned(),
offset: 0,
},
})?;
Expand All @@ -1683,7 +1686,7 @@ impl Composer {
},
source: ErrSource::Constructing {
path: file_path.to_owned(),
source: substituted_source,
source: sanitized_source.to_owned(),
offset: 0,
},
});
Expand All @@ -1695,7 +1698,7 @@ impl Composer {
inner: ComposerErrorInner::ImportNotFound(import_name.clone(), offset),
source: ErrSource::Constructing {
path: file_path.to_owned(),
source: substituted_source,
source: sanitized_source,
offset: 0,
},
});
Expand Down

0 comments on commit c2fed51

Please sign in to comment.