Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propagate log reference when loading style module #1518

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libosmscout-map/include/osmscoutmap/oss/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
#include <osmscout/TypeConfig.h>

#include <osmscout/io/File.h>

#include <osmscout/util/String.h>
#include <osmscout/util/Transformation.h>
#include <osmscout/log/Logger.h>


#include <osmscoutmap/oss/Scanner.h>

#include <osmscoutmap/StyleConfig.h>
Expand Down
30 changes: 16 additions & 14 deletions libosmscout-map/parser/OSS/OSS.atg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <osmscout/util/String.h>
#include <osmscout/util/Transformation.h>
#include <osmscout/log/Logger.h>

COMPILER OSS

Expand Down Expand Up @@ -95,7 +96,7 @@ void AddFeatureToFilter(StyleFilter& filter,
if (!filter.FiltersByType() ||
filter.HasType(type)) {
// Add type only if the filter either has no types or
// if the the type is already filtered
// if the type is already filtered
resultTypes.Set(type);
}
}
Expand Down Expand Up @@ -180,7 +181,8 @@ PRODUCTIONS

bool success=config.Load(moduleFileName,
colorPostprocessor,
true);
true,
errors->log);

if (!success) {
std::string e="Cannot load module '"+moduleFileName+"'";
Expand Down Expand Up @@ -1407,18 +1409,18 @@ PRODUCTIONS
ATTRIBUTEVALUE<PartialStyleBase& style, const StyleAttributeDescriptor& descriptor>
=
(.
ValueType valueType=ValueType::NO_VALUE;
bool negate=false;
std::string ident;
std::string subIdent;
std::string stringValue;
std::string function;
double factor=-1;
std::string unit;
std::string number;
std::list<std::string> numberList;
Color color;
StyleConstantRef constant;
ValueType valueType=ValueType::NO_VALUE;
bool negate=false;
std::string ident;
std::string subIdent;
std::string stringValue;
std::string function;
double factor=-1;
std::string unit;
std::string number;
std::vector<std::string> numberList;
Color color;
StyleConstantRef constant;
.)

(
Expand Down
17 changes: 10 additions & 7 deletions libosmscout-map/parser/OSS/Parser.frame
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ public:

public:
std::list<Err> errors;
bool hasErrors;
bool hasErrors=false;
Log log;

public:
Errors();
explicit Errors(const Log &log);
void SynErr(int line, int col, int n);
void Error(int line, int col, const char *s);
void Warning(int line, int col, const char *s);
Expand Down Expand Up @@ -80,7 +81,8 @@ public:
Parser(Scanner *scanner,
const std::string& filename,
StyleConfig& config,
osmscout::ColorPostprocessor colorPostprocessor=nullptr);
osmscout::ColorPostprocessor colorPostprocessor=nullptr,
const Log &log=osmscout::log);
~Parser();

void SemErr(const char* msg);
Expand Down Expand Up @@ -237,7 +239,8 @@ void Parser::Parse()
Parser::Parser(Scanner *scanner,
const std::string& filename,
StyleConfig& config,
osmscout::ColorPostprocessor colorPostprocessor)
osmscout::ColorPostprocessor colorPostprocessor,
const Log &log)
: filename(filename),
config(config)
{
Expand All @@ -247,7 +250,7 @@ Parser::Parser(Scanner *scanner,
minErrDist = 2;
errDist = minErrDist;
this->scanner = scanner;
errors = new Errors();
errors = new Errors(log);
this->colorPostprocessor=colorPostprocessor;
}

Expand Down Expand Up @@ -276,8 +279,8 @@ osmscout::Color Parser::PostprocessColor(const osmscout::Color& color) const
}
}

Errors::Errors()
: hasErrors(false)
Errors::Errors(const Log &log)
: log(log)
{
// no code
}
Expand Down
3 changes: 2 additions & 1 deletion libosmscout-map/src/osmscoutmap/oss/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ void Parser::IMPORT() {

bool success=config.Load(moduleFileName,
colorPostprocessor,
true);
true,
errors->log);

if (!success) {
std::string e="Cannot load module '"+moduleFileName+"'";
Expand Down