[Kst] kdeextragear-2/kst/kst/extensions/js
George Staikos
staikos at kde.org
Tue Mar 29 07:17:15 CEST 2005
CVS commit by staikos:
resize() added, more exceptions added
M +37 -6 bind_vector.cpp 1.5
M +1 -1 bind_vector.h 1.5
--- kdeextragear-2/kst/kst/extensions/js/bind_vector.cpp #1.4:1.5
@@ -68,4 +68,5 @@ struct VBindings {
static VBindings Bindings[] = {
+ { "resize", &KstBindVector::resize },
{ "length", &KstBindVector::length },
{ "tagName", &KstBindVector::tagName },
@@ -94,9 +95,4 @@ KJS::Value KstBindVector::call(KJS::Exec
-KJS::Value KstBindVector::get(KJS::ExecState *exec, const KJS::Identifier &propertyName) const {
- return KstBinding::get(exec, propertyName);
-}
-
-
KJS::Value KstBindVector::getPropertyByIndex(KJS::ExecState *exec, unsigned propertyName) const {
double rc = KST::NOPOINT;
@@ -183,8 +179,14 @@ KJS::Value KstBindVector::setTagName(KJS
}
+ if (args[0].type() != KJS::StringType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return KJS::Value();
+ }
+
QString n = args[0].toString(exec).qstring();
KST::vectorList.lock().readLock();
if (!_v || *KST::vectorList.findTag(n)) {
- KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError, "Vector not found.");
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
} else {
@@ -199,3 +201,32 @@ KJS::Value KstBindVector::setTagName(KJS
+KJS::Value KstBindVector::resize(KJS::ExecState *exec, const KJS::List& args) {
+ if (args.size() != 1) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly one argument.");
+ exec->setException(eobj);
+ return KJS::Value();
+ }
+
+ if (!_v) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+ exec->setException(eobj);
+ return KJS::Value();
+ }
+
+ unsigned sz = 0;
+
+ if (args[0].type() != KJS::NumberType || !args[0].toUInt32(sz)) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return KJS::Value();
+ }
+
+ _v->writeLock();
+ _v->resize(sz);
+ _v->writeUnlock();
+
+ return KJS::Value();
+}
+
+
// vim: ts=2 sw=2 et
--- kdeextragear-2/kst/kst/extensions/js/bind_vector.h #1.4:1.5
@@ -36,8 +36,8 @@ class KstBindVector : public KstBinding
KJS::Object construct(KJS::ExecState *exec, const KJS::List& args);
KJS::Value call(KJS::ExecState *exec, KJS::Object& self, const KJS::List& args);
- KJS::Value get(KJS::ExecState *exec, const KJS::Identifier &propertyName) const;
KJS::Value getPropertyByIndex(KJS::ExecState *exec, unsigned propertyName) const;
void putPropertyByIndex(KJS::ExecState *exec, unsigned propertyName, const KJS::Value &value, int attr = KJS::None);
+ KJS::Value resize(KJS::ExecState *exec, const KJS::List& args);
KJS::Value length(KJS::ExecState *exec, const KJS::List& args);
KJS::Value tagName(KJS::ExecState *exec, const KJS::List& args);
More information about the Kst
mailing list