Skip to content

Commit

Permalink
Merge branch 'janvidar/visual_studio_2010_work'
Browse files Browse the repository at this point in the history
  • Loading branch information
modelrockettier committed Feb 9, 2020
2 parents 12042be + dd3a8b3 commit 22b0e6c
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 6 deletions.
17 changes: 16 additions & 1 deletion src/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,36 @@ def _write_default_impl(self, option):

def _write_apply_impl(self, option):
s = "\tif (!strcmp(key, \"%s\"))\n\t{\n" % option.name
s_type = option.otype
s_default = option.default
s_min_str = ""
s_max_str = ""
if option.otype == "int":
s_type = "integer"
s_min = "0"
s_max = "0"
if (option.check_min):
s += "\t\tmin = %s;\n" % option.check_min
if (option.check_min != "0"):
s_min_str = ", min=%s" % option.check_min
s_min = "&min"
if (option.check_max):
s += "\t\tmax = %s;\n" % option.check_max
s_max_str = ", max=%s" % option.check_max
s_max = "&max"
s+= "\t\tif (!apply_integer(key, data, &config->%s, %s, %s))\n" % (option.name, s_min, s_max)
elif option.otype == "boolean":
s += "\t\tif (!apply_boolean(key, data, &config->%s))\n" % option.name
elif option.is_string:
s_default = "\\\"%s\\\"" % option.default
s += "\t\tif (!apply_string(key, data, &config->%s, (char*) \"\"))\n" % option.name
s += "\t\t{\n\t\t\tLOG_ERROR(\"Configuration parse error on line %d\", line_count);\n\t\t\treturn -1;\n\t\t}\n\t\treturn 0;\n\t}\n\n"
s += "\t\t{\n"
s += "\t\t\tLOG_ERROR(\"Configuration parse error on line %d\", line_count);\n"
s += "\t\t\tLOG_ERROR(\"\\\"%s\\\" (%s), default=%s%s%s\");\n" % (option.name, s_type, s_default, s_min_str, s_max_str)
s += "\t\t\treturn -1;\n"
s += "\t\t}\n"
s += "\t\treturn 0;\n"
s += "\t}\n\n"
self.f.write(s)

def _write_free_impl(self, option):
Expand Down
Loading

0 comments on commit 22b0e6c

Please sign in to comment.