mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Added Alignment, Defaultable and Scriptable types, needed some reflection tweaks for the last two.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@17 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -242,7 +242,7 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
|
||||
// Get a variable (almost as normal)
|
||||
case I_GET_VAR: {
|
||||
ScriptValueP value = variables[i.data].value;
|
||||
if (!value) value = scriptNil; // no errors here
|
||||
if (!value) value = script_nil; // no errors here
|
||||
stack.push_back(value);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -283,9 +283,9 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec) {
|
||||
if (minPrec <= PREC_UNARY && token == _("not")) {
|
||||
parseOper(input, script, PREC_UNARY, I_UNARY, I_NOT); // unary not
|
||||
} else if (token == _("true")) {
|
||||
script.addInstruction(I_PUSH_CONST, scriptTrue); // boolean constant : true
|
||||
script.addInstruction(I_PUSH_CONST, script_true); // boolean constant : true
|
||||
} else if (token == _("false")) {
|
||||
script.addInstruction(I_PUSH_CONST, scriptFalse); // boolean constant : false
|
||||
script.addInstruction(I_PUSH_CONST, script_false); // boolean constant : false
|
||||
} else if (token == _("if")) {
|
||||
// if AAA then BBB else CCC
|
||||
unsigned int jmpElse, jmpEnd;
|
||||
@@ -300,7 +300,7 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec) {
|
||||
if (input.read() == _("else")) { // else
|
||||
parseOper(input, script, PREC_SET); // CCC
|
||||
} else {
|
||||
script.addInstruction(I_PUSH_CONST, scriptNil);
|
||||
script.addInstruction(I_PUSH_CONST, script_nil);
|
||||
}
|
||||
script.comeFrom(jmpEnd); // lbl_end:
|
||||
} else if (token == _("for")) {
|
||||
@@ -315,7 +315,7 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec) {
|
||||
expectToken(input, _("in")); // in
|
||||
parseOper(input, script, PREC_SET); // BBB
|
||||
script.addInstruction(I_UNARY, I_ITERATOR_C); // iterator_collection
|
||||
script.addInstruction(I_PUSH_CONST, scriptNil); // push nil
|
||||
script.addInstruction(I_PUSH_CONST, script_nil); // push nil
|
||||
lblStart = script.getLabel(); // lbl_start:
|
||||
script.addInstruction(I_LOOP, 0xFFFF); // loop
|
||||
expectToken(input, _("do")); // do
|
||||
@@ -333,7 +333,7 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec) {
|
||||
expectToken(input, _("to")); // to
|
||||
parseOper(input, script, PREC_SET); // CCC
|
||||
script.addInstruction(I_BINARY, I_ITERATOR_R); // iterator_range
|
||||
script.addInstruction(I_PUSH_CONST, scriptNil); // push nil
|
||||
script.addInstruction(I_PUSH_CONST, script_nil); // push nil
|
||||
lblStart = script.getLabel(); // lbl_start:
|
||||
script.addInstruction(I_LOOP, 0xFFFF); // loop
|
||||
expectToken(input, _("do")); // do
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <script/value.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(Script);
|
||||
DECLARE_INTRUSIVE_POINTER_TYPE(Script);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Instructions
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ ScriptValueP ScriptValue::next() { throw InternalError(_("Can't co
|
||||
ScriptValueP ScriptValue::makeIterator() const { throw ScriptError( _("Can't convert from ")+typeName()+_(" to collection")); }
|
||||
|
||||
void ScriptValue::signalDependent(Context&, const Dependency&, const String& name) {}
|
||||
ScriptValueP ScriptValue::dependencies( Context&, const Dependency&) const { return scriptNil; }
|
||||
ScriptValueP ScriptValue::dependencies( Context&, const Dependency&) const { return script_nil; }
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Iterators
|
||||
@@ -81,8 +81,8 @@ ScriptValueP toScript(int v) {
|
||||
}
|
||||
|
||||
// use integers to represent true/false
|
||||
ScriptValueP scriptTrue = toScript((int)true);
|
||||
ScriptValueP scriptFalse = toScript((int)false);
|
||||
ScriptValueP script_true = toScript((int)true);
|
||||
ScriptValueP script_false = toScript((int)false);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Doubles
|
||||
@@ -165,10 +165,11 @@ class ScriptNil : public ScriptValue {
|
||||
virtual operator String() const { return wxEmptyString; }
|
||||
virtual operator double() const { return 0.0; }
|
||||
virtual operator int() const { return 0; }
|
||||
virtual ScriptValueP eval(Context&) const { return script_nil; } // nil() == nil
|
||||
};
|
||||
|
||||
/// The preallocated nil value
|
||||
ScriptValueP scriptNil(new ScriptNil);
|
||||
ScriptValueP script_nil(new ScriptNil);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -28,9 +28,7 @@ class Dependency;
|
||||
|
||||
// ----------------------------------------------------------------------------- : ScriptValue
|
||||
|
||||
//DECLARE_POINTER_TYPE(ScriptValue);
|
||||
class ScriptValue;
|
||||
typedef boost::intrusive_ptr<ScriptValue> ScriptValueP;
|
||||
DECLARE_INTRUSIVE_POINTER_TYPE(ScriptValue);
|
||||
|
||||
enum ScriptType
|
||||
{ SCRIPT_NIL
|
||||
@@ -104,9 +102,9 @@ inline void intrusive_ptr_release(ScriptValue* p) {
|
||||
}
|
||||
}
|
||||
|
||||
extern ScriptValueP scriptNil; ///< The preallocated nil value
|
||||
extern ScriptValueP scriptTrue; ///< The preallocated true value
|
||||
extern ScriptValueP scriptFalse; ///< The preallocated false value
|
||||
extern ScriptValueP script_nil; ///< The preallocated nil value
|
||||
extern ScriptValueP script_true; ///< The preallocated true value
|
||||
extern ScriptValueP script_false; ///< The preallocated false value
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Iterators
|
||||
@@ -191,7 +189,7 @@ ScriptValueP toScript(int v);
|
||||
ScriptValueP toScript(double v);
|
||||
ScriptValueP toScript(const String& v);
|
||||
ScriptValueP toScript(const Color& v);
|
||||
inline ScriptValueP toScript(bool v) { return v ? scriptTrue : scriptFalse; }
|
||||
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); }
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user