Eliminated most build errors (gcc,linux,wxGTK).

What is left is mostly:
 - warning: converting double to int
     -> add a cast/to_int or ignore
 - wrong initialization order in ctor
     -> just swap the order to match the class
 - errors about wxCursors
     -> add a function loadResourceCursor


git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@183 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-01-29 00:04:20 +00:00
parent 1cd80a3710
commit 3d9181e5f6
42 changed files with 151 additions and 125 deletions
+7 -7
View File
@@ -238,11 +238,11 @@ void instrUnary (UnaryInstructionType i, ScriptValueP& a) {
// operator on strings or doubles or ints
#define OPERATOR_SDI(OP) \
if (at == SCRIPT_STRING || bt == SCRIPT_STRING) { \
a = toScript((String)*a OP (String)*b); \
a = toScript(a->toString() OP b->toString()); \
} else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \
a = toScript((double)*a OP (double)*b); \
a = toScript((double)*a OP (double)*b); \
} else { \
a = toScript((int)*a OP (int)*b); \
a = toScript((int)*a OP (int)*b); \
} \
break
@@ -282,13 +282,13 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP&
} else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) {
a = new_intrusive2<ScriptCompose>(a, b);
} else if (at == SCRIPT_STRING || bt == SCRIPT_STRING) {
a = toScript((String)*a + (String)*b);
a = toScript(a->toString() + b->toString());
} else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) {
a = toScript((double)*a + (double)*b);
a = toScript((double)*a + (double)*b);
} else if (at == SCRIPT_INT || bt == SCRIPT_INT) {
a = toScript((int)*a + (int)*b);
a = toScript((int)*a + (int)*b);
} else {
a = toScript((String)*a + (String)*b);
a = toScript(a->toString() + b->toString());
}
break;
case I_SUB: OPERATOR_DI(-);
+5 -5
View File
@@ -56,7 +56,7 @@ class ScriptReplaceRule : public ScriptValue {
ctx.setVariable(name, toScript(value));
}
// call
inside = (String)*replacement_function->eval(ctx);
inside = replacement_function->eval(ctx)->toString();
} else {
regex.Replace(&inside, replacement, 1); // replace inside
}
@@ -92,7 +92,7 @@ SCRIPT_FUNCTION(replace_rule) {
if (replace->type() == SCRIPT_FUNCTION) {
ret->replacement_function = replace;
} else {
ret->replacement = (String)*replace;
ret->replacement = replace->toString();
}
// in_context
SCRIPT_OPTIONAL_PARAM_N(String, _("in context"), in_context) {
@@ -354,7 +354,7 @@ String replace_tag_contents(String input, const String& tag, const ScriptValueP&
// replace
ret += input.substr(0, pos); // before tag
ret += tag;
ret += *contents->eval(ctx);// new contents (call)
ret += contents->eval(ctx)->toString();// new contents (call)
ret += close_tag(tag);
// next
input = input.substr(skip_tag(input,end));
@@ -387,7 +387,7 @@ bool equal(const ScriptValue& a, const ScriptValue& b) {
} else if (at == SCRIPT_DOUBLE) {
return (double)a == (double)b;
} else if (at == SCRIPT_STRING) {
return (String)a == (String)b;
return a.toString() == b.toString();
} else if (at == SCRIPT_OBJECT) {
// HACK for ScriptObject<shared_ptr<X> >
// assumes different types are layed out the same, and that
@@ -405,7 +405,7 @@ int position_in_vector(const ScriptValueP& of, const ScriptValueP& in, const Scr
ScriptType of_t = of->type(), in_t = in->type();
if (of_t == SCRIPT_STRING || in_t == SCRIPT_STRING) {
// string finding
return (int)((String)*of).find(*in); // (int)npos == -1
return (int)of->toString().find(in->toString()); // (int)npos == -1
} else if (order_by) {
ScriptObject<Set*>* s = dynamic_cast<ScriptObject<Set*>* >(in.get());
ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(of.get());
+1 -1
View File
@@ -153,7 +153,7 @@ template <> void Reader::handle(ScriptableImage& s) {
if (starts_with(s.script.unparsed, _("script:"))) {
s.script.unparsed = s.script.unparsed.substr(7);
s.script.parse(*this);
} else if (s.script.unparsed.find_first_of('{') != String.npos) {
} else if (s.script.unparsed.find_first_of('{') != String::npos) {
s.script.parse(*this, true);
} else {
// script is a constant function
+6 -6
View File
@@ -38,10 +38,10 @@ struct Token {
String value;
bool newline; ///< Is there a newline between this token and the previous one?
inline operator == (TokenType t) const { return type == t; }
inline operator != (TokenType t) const { return type != t; }
inline operator == (const String& s) const { return type != TOK_STRING && value == s; }
inline operator != (const String& s) const { return type == TOK_STRING || value != s; }
inline bool operator == (TokenType t) const { return type == t; }
inline bool operator != (TokenType t) const { return type != t; }
inline bool operator == (const String& s) const { return type != TOK_STRING && value == s; }
inline bool operator != (const String& s) const { return type == TOK_STRING || value != s; }
};
enum OpenBrace
@@ -521,7 +521,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc
// for smart strings: "x" {{ e }} "y"
// optimize: "" + e -> e
Instruction i = script.getInstructions().back();
if (i.instr == I_PUSH_CONST && String(*script.getConstants()[i.data]).empty()) {
if (i.instr == I_PUSH_CONST && script.getConstants()[i.data]->toString().empty()) {
script.getInstructions().pop_back();
parseOper(input, script, PREC_ALL); // e
} else {
@@ -531,7 +531,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc
parseOper(input, script, PREC_NONE); // y
// optimize: e + "" -> e
i = script.getInstructions().back();
if (i.instr == I_PUSH_CONST && String(*script.getConstants()[i.data]).empty()) {
if (i.instr == I_PUSH_CONST && script.getConstants()[i.data]->toString().empty()) {
script.getInstructions().pop_back();
} else {
script.addInstruction(I_BINARY, I_ADD);
+3 -3
View File
@@ -14,7 +14,7 @@
// ----------------------------------------------------------------------------- : Store
void store(const ScriptValueP& val, String& var) { var = static_cast<String>(*val); }
void store(const ScriptValueP& val, String& var) { var = val->toString(); }
void store(const ScriptValueP& val, int& var) { var = *val; }
void store(const ScriptValueP& val, double& var) { var = *val; }
void store(const ScriptValueP& val, bool& var) { var = static_cast<int>(*val); }
@@ -25,8 +25,8 @@ void store(const ScriptValueP& val, Defaultable<Color>& var) { var.assign(*val)
// ----------------------------------------------------------------------------- : OptionalScript
OptionalScript::OptionalScript(const String& script_)
: unparsed(script_)
, script(::parse(script_))
: script(::parse(script_))
, unparsed(script_)
{}
OptionalScript::~OptionalScript() {}
+11 -5
View File
@@ -57,7 +57,12 @@ class ScriptValue : public IntrusivePtrBase {
virtual operator int() const;
/// Convert this value to a color
virtual operator Color() const;
/// Explicit overload to convert to a string
/** This is sometimes necessary, because wxString has an int constructor,
* which confuses gcc. */
inline String toString() const { return *this; }
/// Get a member variable from this value
virtual ScriptValueP getMember(const String& name) const;
/// Signal that a script depends on a member of this value
@@ -246,10 +251,11 @@ class ScriptObject : public ScriptValue {
// ----------------------------------------------------------------------------- : Creating
/// Convert a value to a script value
ScriptValueP toScript(int v);
ScriptValueP toScript(double v);
ScriptValueP toScript(const String& v);
ScriptValueP toScript(const Color& v);
ScriptValueP toScript(int v);
inline ScriptValueP toScript(long v) { return toScript((int) v); }
ScriptValueP toScript(double v);
ScriptValueP toScript(const String& v);
ScriptValueP toScript(const Color& v);
inline ScriptValueP toScript(bool v) { return v ? script_true : script_false; }
template <typename T>
inline ScriptValueP toScript(const vector<T>* v) { return new_intrusive1<ScriptCollection<vector<T> > >(v); }