[Scummvm-cvs-logs] SF.net SVN: scummvm:[34788] scummvm/trunk/gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Oct 13 00:23:36 CEST 2008


Revision: 34788
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34788&view=rev
Author:   fingolfin
Date:     2008-10-12 22:23:35 +0000 (Sun, 12 Oct 2008)

Log Message:
-----------
Removing dead code

Removed Paths:
-------------
    scummvm/trunk/gui/eval.cpp
    scummvm/trunk/gui/eval.h

Deleted: scummvm/trunk/gui/eval.cpp
===================================================================
--- scummvm/trunk/gui/eval.cpp	2008-10-12 22:14:30 UTC (rev 34787)
+++ scummvm/trunk/gui/eval.cpp	2008-10-12 22:23:35 UTC (rev 34788)
@@ -1,333 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/system.h"
-#include "gui/eval.h"
-#include "gui/widget.h"
-#include "gui/newgui.h"
-
-#include "graphics/scaler.h"
-
-namespace GUI {
-
-static bool isdelim(char c) {
-	return strchr(" ;,+-<>/*%^=()", c) != 0 || c == 9 || c == '\n' || !c;
-}
-
-Eval::Eval() {
-	loadConstants();
-}
-
-Eval::~Eval() {
-	_vars.clear();
-	_aliases.clear();
-}
-
-int Eval::eval(const String &input, const String &section, const String &name, int startpos) {
-	int result;
-
-	debug(5, "%s=%s", name.c_str(), input.c_str());
-
-	strncpy(_input, input.c_str(), 256);
-	_section = section;
-	_name = name;
-	_startpos = startpos;
-
-	_pos = 0;
-
-	getToken();
-
-	if (_tokenType == tString)
-		return EVAL_STRING_VAR;
-
-	if (!*_token)
-		exprError(eBadExpr);
-
-	level2(&result);
-
-	debug(5, "Result: %d", result);
-
-	return result;
-}
-
-void Eval::level2(int *result) {
-	char op;
-	int hold;
-
-	level3(result);
-
-	while ((op = *_token) == '+' || op == '-') {
-		getToken();
-		level3(&hold);
-		arith(op, result, &hold);
-	}
-}
-
-void Eval::level3(int *result) {
-	char op;
-	int hold;
-
-	level4(result);
-
-	while ((op = *_token) == '*' || op == '/' || op == '%') {
-		getToken();
-		level4(&hold);
-		arith(op, result, &hold);
-	}
-}
-
-void Eval::level4(int *result) {
-	char op;
-
-	op = 0;
-	if ((_tokenType == tDelimiter) && (*_token == '+' || *_token == '-')) {
-		op = *_token;
-		getToken();
-	}
-
-	level5(result);
-
-	if (op)
-		unary(op, result);
-}
-
-void Eval::level5(int *result) {
-	if ((*_token == '(') && (_tokenType == tDelimiter)) {
-		getToken();
-
-		level2(result);
-
-		if (*_token != ')')
-			exprError(eUnclosedBracket);
-		getToken();
-	} else {
-		primitive(result);
-	}
-}
-
-void Eval::primitive(int *result) {
-	if (*_token == ')')
-		exprError(eExtraBracket);
-
-	switch (_tokenType) {
-	case tVariable:
-		*result = getVar_(_token);
-		if (*result == EVAL_UNDEF_VAR)
-			exprError(eUndefVar);
-		getToken();
-		return;
-	case tNumber:
-		*result = atoi(_token);
-		getToken();
-		return;
-	default:
-		exprError(eSyntaxError);
-	}
-}
-
-void Eval::arith(char op, int *r, int *h) {
-	switch (op) {
-	case '-':
-		*r = *r - *h;
-		break;
-	case '+':
-		*r = *r + *h;
-		break;
-	case '*':
-		*r = *r * *h;
-		break;
-	case '/':
-		*r = (*r) / (*h);
-		break;
-	case '%':
-		*r = (*r) % (*h);
-		break;
-	}
-}
-
-void Eval::unary(char op, int *r) {
-	if (op == '-')
-		*r = -(*r);
-}
-
-void Eval::getToken() {
-	char *temp;
-
-	_tokenType = tNone;
-	temp = _token;
-
-	if (_input[_pos] == 0) {
-		*_token = 0;
-		_tokenType = tDelimiter;
-		return;
-	}
-	while (isspace(_input[_pos]))
-		_pos++;
-
-	if (_input[_pos] == '"') {
-		_pos++;
-		while (_input[_pos] != '"' && _input[_pos] != '\n')
-			*temp++ = _input[_pos++];
-
-		if (_input[_pos] == '\n')
-			exprError(eMissingQuote);
-
-		_pos++;
-		*temp = 0;
-
-		_tokenType = tString;
-		return;
-	}
-
-	if (isdigit(_input[_pos])) {
-		while (!isdelim(_input[_pos]))
-			*temp++ = _input[_pos++];
-		*temp = 0;
-
-		_tokenType = tNumber;
-		return;
-	}
-
-	if (isalpha(_input[_pos])) {
-		while (!isdelim(_input[_pos]))
-			*temp++ = _input[_pos++];
-		*temp = 0;
-		_tokenType = tVariable;
-		return;
-	}
-
-	if (!_tokenType && isdelim(_input[_pos])) {
-		*temp++ = _input[_pos++];
-		*temp = 0;
-		_tokenType = tDelimiter;
-	}
-}
-
-void Eval::exprError(EvalErrors err) {
-	static const char *errors[] = {
-		"Syntax error",
-		"Extra ')'",
-		"Missing ')'",
-		"Bad expression",
-		"Undefined variable",
-		"Missing '\"'"
-	};
-
-	error("%s in section [%s] expression: \"%s\" start is at: %d near token '%s'",
-		  errors[err], _section.c_str(), _name.c_str(), _pos + _startpos, _token);
-}
-
-struct BuiltinConsts {
-	const char *name;
-	int value;
-};
-
-static const BuiltinConsts builtinConsts[] = {
-	{"kButtonWidth", GUI::kButtonWidth},
-	{"kButtonHeight", GUI::kButtonHeight},
-	{"kSliderWidth", GUI::kSliderWidth},
-	{"kSliderHeight", GUI::kSliderHeight},
-
-	{"kBigButtonWidth", GUI::kBigButtonWidth},
-	{"kBigButtonHeight", GUI::kBigButtonHeight},
-	{"kBigSliderWidth", GUI::kBigSliderWidth},
-	{"kBigSliderHeight", GUI::kBigSliderHeight},
-
-	{"kNormalWidgetSize", GUI::kNormalWidgetSize},
-	{"kBigWidgetSize", GUI::kBigWidgetSize},
-
-	{"kThumbnailWidth", kThumbnailWidth},
-
-	{"kTextAlignLeft", kTextAlignLeft},
-	{"kTextAlignRight", kTextAlignRight},
-	{"kTextAlignCenter", kTextAlignCenter},
-
-	{"kFontStyleBold", Theme::kFontStyleBold},
-	{"kFontStyleNormal", Theme::kFontStyleNormal},
-	{"kFontStyleItalic", Theme::kFontStyleItalic},
-
-	{"kFontStyleFixedBold", Theme::kFontStyleFixedBold},
-	{"kFontStyleFixedNormal", Theme::kFontStyleFixedNormal},
-	{"kFontStyleFixedItalic", Theme::kFontStyleFixedItalic},
-
-	{"kShadingNone", Theme::kShadingNone},
-	{"kShadingDim", Theme::kShadingDim},
-	{"kShadingLuminance", Theme::kShadingLuminance},
-
-	{"false", 0},
-	{"true", 1},
-	{NULL, 0}
-};
-
-void Eval::loadConstants() {
-	int i;
-
-	for (i = 0; builtinConsts[i].name; i++)
-		_vars[builtinConsts[i].name] = builtinConsts[i].value;
-}
-
-int Eval::getBuiltinVar(const char *s) {
-	if (!strcmp(s, "w"))
-		return g_system->getOverlayWidth();
-
-	if (!strcmp(s, "h"))
-		return g_system->getOverlayHeight();
-
-	return EVAL_UNDEF_VAR;
-}
-
-int Eval::getVar_(const Common::String &s, bool includeAliases) {
-	int val;
-
-	val = getBuiltinVar(s.c_str());
-
-	if (val != EVAL_UNDEF_VAR)
-		return val;
-
-	const Common::String *var = &s;
-	if (includeAliases) {
-		AliasesMap::const_iterator itera = _aliases.find(s);
-		if (itera != _aliases.end())
-			var = &(itera->_value);
-	}
-
-	VariablesMap::const_iterator iterv = _vars.find(*var);
-	if (iterv != _vars.end())
-		return iterv->_value;
-
-	return EVAL_UNDEF_VAR;
-}
-
-void Eval::setVar(const String &section, const String &name, const String &value) {
-	_vars[name.c_str() + 4] = eval(value, section, name, 0);
-}
-
-void Eval::reset() {
-	_vars.clear();
-	_aliases.clear();
-	loadConstants();
-}
-
-} // end of namespace GUI

Deleted: scummvm/trunk/gui/eval.h
===================================================================
--- scummvm/trunk/gui/eval.h	2008-10-12 22:14:30 UTC (rev 34787)
+++ scummvm/trunk/gui/eval.h	2008-10-12 22:23:35 UTC (rev 34788)
@@ -1,125 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef GUI_EVAL_H
-#define GUI_EVAL_H
-
-#include "common/str.h"
-#include "common/hashmap.h"
-#include "common/hash-str.h"
-
-namespace GUI {
-
-using Common::String;
-using Common::HashMap;
-
-enum {
-	EVAL_UNDEF_VAR  = -13375,
-	EVAL_STRING_VAR = -13376
-};
-
-class Eval {
-public:
-	Eval();
-	~Eval();
-
-	int eval(const String &input, const String &section, const String &name, int startpos);
-	void setVar(const String &section, const String &name, const String &value);
-
-	void setParent(const String &name);
-
-	void setVar(const String &name, int val) { _vars[name] = val; }
-	void setStringVar(const String &name, const String &val) { _strings[name] = val; }
-	void setAlias(const Common::String &name, const String &val) { _aliases[name] = val; }
-
-	int getVar(const Common::String &s) { return getVar_(s); }
-	int getVar(const Common::String &s, int def) {
-		int val = getVar_(s);
-		return (val == EVAL_UNDEF_VAR) ? def : val;
-	}
-
-	const String &getStringVar(const Common::String &name) { return _strings[name]; }
-
-	uint getNumVars() { return _vars.size(); }
-
-	void reset();
-
-	char *lastToken() { return _token; }
-
-	typedef HashMap<String, int> VariablesMap;
-	typedef HashMap<String, String> AliasesMap;
-	typedef HashMap<String, String> StringsMap;
-
-private:
-	enum TokenTypes {
-		tNone,
-		tDelimiter,
-		tVariable,
-		tNumber,
-		tString
-	};
-
-	enum EvalErrors {
-		eSyntaxError,
-		eExtraBracket,
-		eUnclosedBracket,
-		eBadExpr,
-		eUndefVar,
-		eMissingQuote
-	};
-
-
-	void getToken();
-	void level2(int *);
-	void level3(int *);
-	void level4(int *);
-	void level5(int *);
-	void primitive(int *);
-	void arith(char op, int *r, int *h);
-	void unary(char op, int *r);
-	void exprError(EvalErrors error);
-	int getVar_(const Common::String &s, bool includeAliases = true);
-	int getBuiltinVar(const char *s);
-	void loadConstants();
-
-	char _input[256];
-	String _section;
-	String _name;
-
-	int _startpos;
-
-	TokenTypes _tokenType;
-	int _pos;
-
-	char _token[256];
-
-	AliasesMap _aliases;
-	VariablesMap _vars;
-	StringsMap _strings;
-};
-
-} // end of namespace GUI
-
-#endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list