55 #include "idListWrapper.hh" 59 QScriptValue toScriptValueIdList(QScriptEngine *engine,
const IdList &s)
61 QScriptValue obj = engine->newObject();
62 obj.setProperty(
"size", QScriptValue(engine, (
int)s.size() ));
63 for (uint i=0; i < s.size(); i++)
64 obj.setProperty(QString::number(i), QScriptValue(engine, s[i]));
69 void fromScriptValueIdList(
const QScriptValue &obj,
IdList &s)
71 int size = obj.property(
"size").toNumber();
73 for (
int i=0; i < size; i++)
74 s.push_back( obj.property( QString::number(i) ).toNumber() );
77 QScriptValue createIdList(QScriptContext *context, QScriptEngine *engine)
81 QScriptValue callee = context->callee();
85 for (
int i=0; i < context->argumentCount(); i++)
86 s.push_back( context->argument(i).toNumber() );
88 return engine->toScriptValue(s);
91 QScriptValue idListToString(QScriptContext *context, QScriptEngine *engine)
93 int size = context->thisObject().property(
"size").toNumber();
100 result =
"[" + context->thisObject().property(
"0").toString();
102 for (
int i = 1; i < size; i++)
103 result +=
"," + context->thisObject().property( QString::number(i) ).toString();
108 return QScriptValue(engine, result);
std::vector< int > IdList
Standard Type for id Lists used for scripting.