From: Mikko Rasa Date: Mon, 11 Jun 2007 06:33:22 +0000 (+0000) Subject: Require mspcore instead of mspmisc X-Git-Tag: 1.0~29 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9094bc6a657e5587e7e17827c35e3fd388fb91ec;p=libs%2Fdatafile.git Require mspcore instead of mspmisc Remove C-style casts Report location with "Wrong number of arguments" errors --- diff --git a/Build b/Build index ea1921e..5c826b0 100644 --- a/Build +++ b/Build @@ -3,7 +3,7 @@ package "mspparser" version "0.2"; description "Mikkosoft Productions datafile parser"; - require "mspmisc"; + require "mspcore"; library "mspparser" { diff --git a/source/input.h b/source/input.h index e1b2d87..f5cd3ed 100644 --- a/source/input.h +++ b/source/input.h @@ -18,7 +18,7 @@ public: int get(); int peek(); unsigned get_line_number() const { return line; } - operator bool() const { return (bool)in; } + operator bool() const { return in; } private: std::istream ∈ unsigned line; diff --git a/source/loader.h b/source/loader.h index c6936f9..39a50d0 100644 --- a/source/loader.h +++ b/source/loader.h @@ -8,7 +8,7 @@ Distributed under the LGPL #include #include -#include +#include "error.h" #include "parser.h" #include "statement.h" #include "value.h" @@ -37,7 +37,7 @@ public: LoaderFunc0(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=0) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=0) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(); }; private: @@ -53,7 +53,7 @@ public: LoaderFunc1(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=1) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=1) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get()); } private: @@ -69,7 +69,7 @@ public: LoaderFunc2(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=2) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=2) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get()); } private: @@ -85,7 +85,7 @@ public: LoaderFunc3(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=3) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=3) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get()); } private: @@ -101,7 +101,7 @@ public: LoaderFunc4(FuncType f): func(f) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=4) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=4) throw TypeError(st.get_location()+": Wrong number of arguments"); (dynamic_cast(l).*func)(st.args[0].get(), st.args[1].get(), st.args[2].get(), st.args[3].get()); } private: @@ -117,7 +117,7 @@ public: LoadValue(PointerType p): ptr(p) { } void execute(Loader &l, const Statement &st) const { - if(st.args.size()!=1) throw TypeError("Wrong number of arguments"); + if(st.args.size()!=1) throw TypeError(st.get_location()+": Wrong number of arguments"); dynamic_cast(l).get_object().*ptr=st.args[0].get(); } private: diff --git a/source/parser.h b/source/parser.h index c8b7ece..9b847c6 100644 --- a/source/parser.h +++ b/source/parser.h @@ -21,7 +21,7 @@ class Parser public: Parser(std::istream &, const std::string &); Statement parse(); - operator bool() const { return (bool)in; } + operator bool() const { return in; } private: Input in; std::string src;