61 #include "idListWrapper.hh" 65 QScriptValue toScriptValueIdList(QScriptEngine *engine,
const IdList &s)
67 QScriptValue obj = engine->newObject();
68 obj.setProperty(
"size", QScriptValue(engine, (
int)s.size() ));
69 for (uint i=0; i < s.size(); i++)
70 obj.setProperty(QString::number(i), QScriptValue(engine, s[i]));
75 void fromScriptValueIdList(
const QScriptValue &obj,
IdList &s)
77 int size = obj.property(
"size").toNumber();
79 for (
int i=0; i < size; i++)
80 s.push_back( obj.property( QString::number(i) ).toNumber() );
83 QScriptValue createIdList(QScriptContext *context, QScriptEngine *engine)
87 QScriptValue callee = context->callee();
91 for (
int i=0; i < context->argumentCount(); i++)
92 s.push_back( context->argument(i).toNumber() );
94 return engine->toScriptValue(s);
97 QScriptValue idListToString(QScriptContext *context, QScriptEngine *engine)
99 int size = context->thisObject().property(
"size").toNumber();
106 result =
"[" + context->thisObject().property(
"0").toString();
108 for (
int i = 1; i < size; i++)
109 result +=
"," + context->thisObject().property( QString::number(i) ).toString();
114 return QScriptValue(engine, result);
std::vector< int > IdList
Standard Type for id Lists used for scripting.