Remove a bunch of debugging printfs and add verbosity levels
This commit is contained in:
parent
17df0d4adf
commit
41327c92fd
5 changed files with 46 additions and 44 deletions
|
@ -18,6 +18,9 @@
|
||||||
#include "writer_png.h"
|
#include "writer_png.h"
|
||||||
|
|
||||||
|
|
||||||
|
int verbosity = 0;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(const char *progname)
|
usage(const char *progname)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +78,7 @@ main(int argc,
|
||||||
outfile = optarg;
|
outfile = optarg;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
/* TODO: Verbosity levels. */
|
++verbosity;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +91,10 @@ main(int argc,
|
||||||
|
|
||||||
infile = argv[optind];
|
infile = argv[optind];
|
||||||
|
|
||||||
|
if (outfile.empty()) {
|
||||||
|
outfile = "charles_out.png";
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse YAML files. */
|
/* Parse YAML files. */
|
||||||
YAMLReader reader(scene);
|
YAMLReader reader(scene);
|
||||||
for (int i = optind; i < argc; i++) {
|
for (int i = optind; i < argc; i++) {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "yaml.h"
|
#include "yaml.h"
|
||||||
|
|
||||||
|
#include "charles.hh"
|
||||||
#include "reader_yaml.hh"
|
#include "reader_yaml.hh"
|
||||||
|
|
||||||
#include "yaml/parsers.hh"
|
#include "yaml/parsers.hh"
|
||||||
|
@ -71,7 +72,7 @@ YAMLReader::read_file(const std::string& filename)
|
||||||
yaml_parser_t parser;
|
yaml_parser_t parser;
|
||||||
yaml_parser_initialize(&parser);
|
yaml_parser_initialize(&parser);
|
||||||
|
|
||||||
printf("Reading file: %s\n", filename.c_str());
|
printf("Reading %s\n", filename.c_str());
|
||||||
yaml_parser_set_input_file(&parser, yaml_infile);
|
yaml_parser_set_input_file(&parser, yaml_infile);
|
||||||
|
|
||||||
yaml::ParserStack parsers;
|
yaml::ParserStack parsers;
|
||||||
|
@ -85,45 +86,47 @@ YAMLReader::read_file(const std::string& filename)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event.type) {
|
if (verbosity >= 4) {
|
||||||
case YAML_NO_EVENT:
|
switch (event.type) {
|
||||||
printf("YAML_NO_EVENT\n");
|
case YAML_NO_EVENT:
|
||||||
break;
|
printf("YAML_NO_EVENT\n");
|
||||||
|
break;
|
||||||
|
|
||||||
case YAML_STREAM_START_EVENT:
|
case YAML_STREAM_START_EVENT:
|
||||||
printf("YAML_STREAM_START_EVENT\n");
|
printf("YAML_STREAM_START_EVENT\n");
|
||||||
break;
|
break;
|
||||||
case YAML_STREAM_END_EVENT:
|
case YAML_STREAM_END_EVENT:
|
||||||
printf("YAML_STREAM_END_EVENT\n");
|
printf("YAML_STREAM_END_EVENT\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YAML_DOCUMENT_START_EVENT:
|
case YAML_DOCUMENT_START_EVENT:
|
||||||
printf("YAML_DOCUMENT_START_EVENT\n");
|
printf("YAML_DOCUMENT_START_EVENT\n");
|
||||||
break;
|
break;
|
||||||
case YAML_DOCUMENT_END_EVENT:
|
case YAML_DOCUMENT_END_EVENT:
|
||||||
printf("YAML_DOCUMENT_END_EVENT\n");
|
printf("YAML_DOCUMENT_END_EVENT\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YAML_ALIAS_EVENT:
|
case YAML_ALIAS_EVENT:
|
||||||
printf("YAML_ALIAS_EVENT\n");
|
printf("YAML_ALIAS_EVENT\n");
|
||||||
break;
|
break;
|
||||||
case YAML_SCALAR_EVENT:
|
case YAML_SCALAR_EVENT:
|
||||||
printf("YAML_SCALAR_EVENT\n");
|
printf("YAML_SCALAR_EVENT\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YAML_SEQUENCE_START_EVENT:
|
case YAML_SEQUENCE_START_EVENT:
|
||||||
printf("YAML_SEQUENCE_START_EVENT\n");
|
printf("YAML_SEQUENCE_START_EVENT\n");
|
||||||
break;
|
break;
|
||||||
case YAML_SEQUENCE_END_EVENT:
|
case YAML_SEQUENCE_END_EVENT:
|
||||||
printf("YAML_SEQUENCE_END_EVENT\n");
|
printf("YAML_SEQUENCE_END_EVENT\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YAML_MAPPING_START_EVENT:
|
case YAML_MAPPING_START_EVENT:
|
||||||
printf("YAML_MAPPING_START_EVENT\n");
|
printf("YAML_MAPPING_START_EVENT\n");
|
||||||
break;
|
break;
|
||||||
case YAML_MAPPING_END_EVENT:
|
case YAML_MAPPING_END_EVENT:
|
||||||
printf("YAML_MAPPING_END_EVENT\n");
|
printf("YAML_MAPPING_END_EVENT\n");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == YAML_DOCUMENT_START_EVENT) {
|
if (event.type == YAML_DOCUMENT_START_EVENT) {
|
||||||
|
@ -135,7 +138,6 @@ YAMLReader::read_file(const std::string& filename)
|
||||||
if (!parsers.empty()) {
|
if (!parsers.empty()) {
|
||||||
parsers.top()->HandleEvent(event);
|
parsers.top()->HandleEvent(event);
|
||||||
if (parsers.top()->GetDone()) {
|
if (parsers.top()->GetDone()) {
|
||||||
printf("parser done\n");
|
|
||||||
delete parsers.top();
|
delete parsers.top();
|
||||||
parsers.pop();
|
parsers.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,6 @@ ObjectParser::HandleKeyEvent(const std::string& key)
|
||||||
{"radius", RadiusSection}
|
{"radius", RadiusSection}
|
||||||
};
|
};
|
||||||
|
|
||||||
printf("%s: got key = %s", __PRETTY_FUNCTION__, key.c_str());
|
|
||||||
|
|
||||||
if (sSections.count(key) > 0) {
|
if (sSections.count(key) > 0) {
|
||||||
mSection = sSections.at(key);
|
mSection = sSections.at(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@ void
|
||||||
ScalarMappingParser::HandleEvent(yaml_event_t& event)
|
ScalarMappingParser::HandleEvent(yaml_event_t& event)
|
||||||
{
|
{
|
||||||
if (mShouldExpectKey && event.type == YAML_MAPPING_START_EVENT) {
|
if (mShouldExpectKey && event.type == YAML_MAPPING_START_EVENT) {
|
||||||
printf("%s: start scalar mapping: tag = %s\n", __PRETTY_FUNCTION__,
|
|
||||||
event.data.mapping_start.tag);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (mShouldExpectKey && event.type == YAML_MAPPING_END_EVENT) {
|
else if (mShouldExpectKey && event.type == YAML_MAPPING_END_EVENT) {
|
||||||
|
|
|
@ -96,11 +96,9 @@ SceneParser::HandleObjectsEvent(yaml_event_t& event)
|
||||||
{
|
{
|
||||||
if (event.type == YAML_SEQUENCE_START_EVENT) {
|
if (event.type == YAML_SEQUENCE_START_EVENT) {
|
||||||
/* Ignore sequence-start for now. */
|
/* Ignore sequence-start for now. */
|
||||||
printf("start objects\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (event.type == YAML_SEQUENCE_END_EVENT) {
|
else if (event.type == YAML_SEQUENCE_END_EVENT) {
|
||||||
printf("end objects\n");
|
|
||||||
mSection = NoSection;
|
mSection = NoSection;
|
||||||
SetShouldExpectKey(true);
|
SetShouldExpectKey(true);
|
||||||
return;
|
return;
|
||||||
|
@ -111,7 +109,6 @@ SceneParser::HandleObjectsEvent(yaml_event_t& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("start object\n");
|
|
||||||
GetParsers().push(new ObjectParser(GetScene(), GetParsers()));
|
GetParsers().push(new ObjectParser(GetScene(), GetParsers()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue