summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-07-15 09:00:37 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-07-15 09:00:37 (GMT)
commit54fada24d47acf7b19ec175041fabdb0b1dfe38f (patch)
tree38d479bfb224618521156a749e83cf496a347f6e /src/script
parent5e315e3ef4b992b43ac27abbf33187c6053f0435 (diff)
downloadQt-54fada24d47acf7b19ec175041fabdb0b1dfe38f.zip
Qt-54fada24d47acf7b19ec175041fabdb0b1dfe38f.tar.gz
Qt-54fada24d47acf7b19ec175041fabdb0b1dfe38f.tar.bz2
implement enumeration of custom script classes
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/qscriptclass.cpp3
-rw-r--r--src/script/bridge/qscriptclassobject.cpp15
2 files changed, 14 insertions, 4 deletions
diff --git a/src/script/api/qscriptclass.cpp b/src/script/api/qscriptclass.cpp
index 98cc834..703ba32 100644
--- a/src/script/api/qscriptclass.cpp
+++ b/src/script/api/qscriptclass.cpp
@@ -13,9 +13,6 @@
#ifndef QT_NO_SCRIPT
-// ### Q_DECLARE_METATYPE(QScriptContext*)
-Q_DECLARE_METATYPE(QScriptValueList)
-
QT_BEGIN_NAMESPACE
/*!
diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp
index 62364f3..277754e 100644
--- a/src/script/bridge/qscriptclassobject.cpp
+++ b/src/script/bridge/qscriptclassobject.cpp
@@ -16,8 +16,10 @@
#include "../api/qscriptengine.h"
#include "../api/qscriptengine_p.h"
#include "../api/qscriptclass.h"
+#include "../api/qscriptclasspropertyiterator.h"
#include "Error.h"
+#include "PropertyNameArray.h"
Q_DECLARE_METATYPE(QScriptContext*)
Q_DECLARE_METATYPE(QScriptValue)
@@ -29,6 +31,7 @@ namespace QScript
{
QString qtStringFromJSCUString(const JSC::UString &str);
+JSC::UString qtStringToJSCUString(const QString &str);
ClassObjectDelegate::ClassObjectDelegate(QScriptClass *scriptClass)
: m_scriptClass(scriptClass)
@@ -145,7 +148,17 @@ bool ClassObjectDelegate::getPropertyAttributes(const QScriptObject* object, JSC
void ClassObjectDelegate::getPropertyNames(QScriptObject* object, JSC::ExecState *exec,
JSC::PropertyNameArray &propertyNames)
{
- qWarning("Enumeration of custom script objects not implemented");
+ QScriptEnginePrivate *engine = static_cast<QScript::GlobalObject*>(exec->lexicalGlobalObject())->engine;
+ QScriptValue scriptObject = engine->scriptValueFromJSCValue(object);
+ QScriptClassPropertyIterator *it = m_scriptClass->newIterator(scriptObject);
+ if (it != 0) {
+ while (it->hasNext()) {
+ it->next();
+ QString name = it->name().toString();
+ propertyNames.add(JSC::Identifier(exec, qtStringToJSCUString(name)));
+ }
+ delete it;
+ }
QScriptObjectDelegate::getPropertyNames(object, exec, propertyNames);
}