Simplified compilation of 'assert' pseudo function;

Added remove_duplicates flag to sort_list function;
Fixed documentation of <size:> tag

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1028 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-07-22 22:46:04 +00:00
parent 4a8c4ba14b
commit 13a37f4734
11 changed files with 146 additions and 65 deletions
+27 -2
View File
@@ -27,8 +27,9 @@ ScriptValueP ScriptValue::eval(Context&) const { return delay
ScriptValueP ScriptValue::next() { throw InternalError(_("Can't convert from ")+typeName()+_(" to iterator")); }
ScriptValueP ScriptValue::makeIterator(const ScriptValueP&) const { return delayError(_ERROR_2_("can't convert", typeName(), _TYPE_("collection"))); }
int ScriptValue::itemCount() const { throw ScriptError(_ERROR_2_("can't convert", typeName(), _TYPE_("collection"))); }
String ScriptValue::toCode() const { return *this; }
CompareWhat ScriptValue::compareAs(String& compare_str, void const*& compare_ptr) const {
compare_str = toString();
compare_str = toCode();
return COMPARE_AS_STRING;
}
ScriptValueP ScriptValue::getMember(const String& name) const {
@@ -322,12 +323,36 @@ class ScriptNil : public ScriptValue {
virtual operator double() const { return 0.0; }
virtual operator int() const { return 0; }
virtual operator bool() const { return false; }
virtual ScriptValueP eval(Context&) const { return script_nil; } // nil() == nil
virtual ScriptValueP eval(Context& ctx) const {
// nil(input) == input
return ctx.getVariable(SCRIPT_VAR_input);
}
};
/// The preallocated nil value
ScriptValueP script_nil(new ScriptNil);
// ----------------------------------------------------------------------------- : Collection base
String ScriptCollectionBase::toCode() const {
String ret = _("[");
bool first = true;
#ifdef USE_INTRUSIVE_PTR
// we can just turn this into a ScriptValueP
// TODO: remove thisP alltogether
ScriptValueP it = makeIterator(ScriptValueP(const_cast<ScriptValue*>((ScriptValue*)this)));
#else
#error "makeIterator needs a ScriptValueP :("
#endif
while (ScriptValueP v = it->next()) {
if (!first) ret += _(",");
first = false;
ret += v->toCode();
}
ret += _("]");
return ret;
}
// ----------------------------------------------------------------------------- : Custom collection
// Iterator over a custom collection