Added some more classes for ScriptErrors;

Added split_text function, which is the 'opposite' of break_text;
Script code "f\n(stuff)" now parses as "f;stuff" instead of a function call, "f(stuff)";
Fixed bug in cursor movement, which caused the closing > of a tag at end of input to be overwritten.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1175 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-08-27 18:44:59 +00:00
parent 9abfdd171c
commit dc9405e441
9 changed files with 104 additions and 44 deletions
+8 -4
View File
@@ -79,9 +79,12 @@ class ScriptDelayedError : public ScriptValue {
ScriptError error; // the error message
};
inline ScriptValueP delayError(const String& m) {
inline ScriptValueP delay_error(const String& m) {
return new_intrusive1<ScriptDelayedError>(ScriptError(m));
}
inline ScriptValueP delay_error(const ScriptError& error) {
return new_intrusive1<ScriptDelayedError>(error);
}
// ----------------------------------------------------------------------------- : Iterators
@@ -93,6 +96,7 @@ struct ScriptIterator : public ScriptValue {
/// Return the next item for this iterator, or ScriptValueP() if there is no such item
virtual ScriptValueP next(ScriptValueP* key_out = nullptr) = 0;
virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const;
};
// make an iterator over a range
@@ -161,7 +165,7 @@ ScriptValueP get_member(const map<String,V>& m, const String& name) {
if (it != m.end()) {
return to_script(it->second);
} else {
return delayError(_ERROR_2_("has no member", _TYPE_("collection"), name));
return delay_error(ScriptErrorNoMember(_TYPE_("collection"), name));
}
}
@@ -171,7 +175,7 @@ ScriptValueP get_member(const IndexMap<K,V>& m, const String& name) {
if (it != m.end()) {
return to_script(*it);
} else {
return delayError(_ERROR_2_("has no member", _TYPE_("collection"), name));
return delay_error(ScriptErrorNoMember(_TYPE_("collection"), name));
}
}
@@ -389,7 +393,7 @@ inline ScriptValueP to_script(const Defaultable<T>& v) { return to_script(v());
template <typename T> inline T from_script (const ScriptValueP& value) {
ScriptObject<T>* o = dynamic_cast<ScriptObject<T>*>(value.get());
if (!o) {
throw ScriptError(_ERROR_2_("can't convert", value->typeName(), _TYPE_("object" )));
throw ScriptErrorConversion(value->typeName(), _TYPE_("object" ));
}
return o->getValue();
}