Пример #1
0
/*!
  Returns the list of objects currently available for scripting in
  this interpreter.
*/
QObjectList QSInterpreter::presentObjects() const
{
  startInterpreter();
  QObjectList *lst = interpreter()->topLevelObjects();
  stopInterpreter();
  return lst ? *lst : QObjectList();
}
Пример #2
0
/*!
  Calls the function \a function with the given \a arguments. The
  arguments are first converted into Qt Script datatypes.

  Functions which were passed to evaluate() in previous calls or which
  are defined in the current project, can be called from this
  function.

  If \a context is 0 (the default), the function is called in the
  global scope. If a \a context is given, the function is called in
  the scope of that object.

  Interpreters that belong to a project are subject to re-evaluation,
  since the code which has been passed previously into evaluate() gets
  lost when calling one of these functions. This happens when the project
  or the scripts in it are modified.
*/
QSArgument QSInterpreter::call(const QString &function,
                               const QSArgumentList &arguments,
                               QObject *context)
{
#if defined (QT_THREAD_SUPPORT) && QT_VERSION >= 0x030300
  if (context
      && context->inherits("QWidget")
      && qt_get_application_thread_id() != QThread::currentThread()) {
    qWarning("QSInterpreter::evaluate(), GUI object (%s [%s]) not allowed in non GUI thread",
             context->name(), context->className());
    return QSArgument();
  }
#endif
  running = TRUE;
  startInterpreter();
  if (function.isEmpty()) {
#if defined QT_RANGE_CHECK
    qWarning("QSInterpreter::call(), function name is empty");
#endif
    return QSArgument();
  }
  QSArgument v = d->interpreter->call(context, function, arguments);
  running = FALSE;
  stopInterpreter();
  return v;
}
Пример #3
0
/*!
  Returns all the classes declared in the fully qualified context \a
  context.

  \sa functions(), variables()
*/
QStringList QSInterpreter::classes(const QString &context) const
{
  startInterpreter();
  QSObject obj = d->interpreter->object(context);
  QStringList lst = d->interpreter->classesOf(obj);
  stopInterpreter();
  return lst;
}
Пример #4
0
/*!
  Returns all the variables declared in the fully qualified
  context \a context.

  \sa functions(), classes()
*/
QStringList QSInterpreter::variables(const QString &context, bool includeStatic, bool includeCustom,
                                     bool includeMemberVariables) const
{
  startInterpreter();
  QSObject obj = d->interpreter->object(context);
  QStringList lst = d->interpreter->variablesOf(obj, includeStatic, includeCustom,
                                                includeMemberVariables);
  stopInterpreter();
  return lst;
}
Пример #5
0
/*!
  Returns the classes in the interpreter.

  If \a flags is \c AllClasses (the default), all the classes in the
  interpreter are returned, including those declared in object
  contexts. If \a flags is \c GlobalClasses, only those classes
  declared in the global context are returned.

  \sa functions(), variables()
*/
QStringList QSInterpreter::classes(ClassFlags flags) const
{
  startInterpreter();
  QStringList lst;
  if (flags == AllClasses) {
    lst = d->interpreter->classes();
  } else {
    QSObject obj = d->interpreter->object(QString::null);
    lst = d->interpreter->classesOf(obj);
  }
  stopInterpreter();
  return lst;
}
Пример #6
0
/*!
  Returns all the script functions in the context \a context (this can
  be for example, a class or a form). If \a context is empty, the
  functions of the global context (global functions) are returned.

  \a context can be fully qualified.

  If \a flags includes \c FunctionSignatures, then each function name
  returned will be of the following form:
  \code
  functionName( typeOfArg1, typeOfArg2, ... )
  \endcode
  Otherwise just the names will be returned (which is the default).

  If \a flags includes \c IncludeMemberFunctions and \a context
  represents a class declared in script, this function will return
  both static and non-static functions; otherwise it only returns
  static functions.

  \sa classes(), variables()
*/
QStringList QSInterpreter::functions(const QString &context,
                                     uint flags) const
{
  startInterpreter();
  QSObject obj = d->interpreter->object(context);
  QStringList retVal =
    d->interpreter->functionsOf(obj,
                                flags & FunctionSignatures,
                                FALSE,
                                flags & IncludeMemberFunctions);
  stopInterpreter();
  return retVal;
}
Пример #7
0
int main(int argc, char** argv)
{
    initCommands();
    addCommand("newkey", &vault_newkey);
    addCommand("pubkey", &vault_pubkey);
    addCommand("addr", &vault_addr);
    addCommand("newwallet", &vault_newwallet);
    addCommand("importkeys", &vault_importkeys);
    addCommand("dumpkeys", &vault_dumpkeys);
    addCommand("walletkey", &vault_walletkey);
    addCommand("walletsign", &vault_walletsign);
    return startInterpreter(argc, argv);
}
Пример #8
0
/*!
  Returns TRUE if the function \a function exists; otherwise returns FALSE.

  The function can be a fully qualified in the form:
  \code
  myclass.function
  \endcode
*/
bool QSInterpreter::hasFunction(const QString &function) const
{
  startInterpreter();
  bool result;
  if (function.isEmpty()) {
#if defined( QT_CHECK_STATE )
    qWarning("QSInterpreter::hasFunction(): function name is empty");
#endif
    result = FALSE;
  } else {
    result = d->interpreter->hasFunction(function);
  }
  stopInterpreter();
  return result;
}
Пример #9
0
/*!
  Returns TRUE if the variable \a variable exists; otherwise returns FALSE.

  The variable name can be fully qualified in the form:
  \code
  myobject.otherobject.var
  \endcode
*/
bool QSInterpreter::hasVariable(const QString &variable) const
{
  startInterpreter();
  bool result;
  if (variable.isEmpty()) {
#if defined( QT_CHECK_STATE )
    qWarning("QSInterpreter::hasVariable(): variable name is empty");
#endif
    result = FALSE;
  } else {
    result = d->interpreter->hasVariable(variable);
  }
  stopInterpreter();
  return result;
}
Пример #10
0
/*!
  Returns TRUE if the class \a className exists; otherwise returns FALSE.

  The class name can be a fully qualified in the form:
  \code
  myclass.innerClass
  \endcode
*/
bool QSInterpreter::hasClass(const QString &className) const
{
  startInterpreter();
  bool result;
  if (className.isEmpty()) {
#if defined( QT_CHECK_STATE )
    qWarning("QSInterpreter::hasClass(): class name is empty");
#endif
    result = FALSE;
  } else {
    result = d->interpreter->hasClass(className);
  }
  stopInterpreter();
  return result;
}
Пример #11
0
/*!
  Returns all the classes declared in the context \a context.

  \sa functions(), variables()
*/
QStringList QSInterpreter::classes(QObject *context) const
{
  if (!context) {
#if defined( QT_RANGE_CHECK )
    qWarning("QSInterpreter::classesOf: context is null");
#endif
    return QStringList();
  }
  startInterpreter();
  QSObject obj = d->interpreter->wrap(context);
  QStringList lst;
  if (!obj.isUndefined())
    lst = d->interpreter->classesOf(obj);
  stopInterpreter();
  return lst;
}
Пример #12
0
/*!
  Returns all script functions which have been defined in the
  context \a context.

  If \a flags includes \c FunctionSignatures, then each function name
  returned will be of the following form:
  \code
  functionName( typeOfArg1, typeOfArg2, ... )
  \endcode
  Otherwise just the names will be returned (which is the default).

  \sa classes(), variables()
*/
QStringList QSInterpreter::functions(QObject *context,
                                     FunctionFlags flags) const
{
  if (!context) {
#if defined( QT_RANGE_CHECK )
    qWarning("QSInterpreter::functions: context is null");
#endif
    return QStringList();
  }
  startInterpreter();
  QStringList lst;
  QSObject obj = d->interpreter->wrap(context);
  if (!obj.isUndefined())
    lst = d->interpreter->functionsOf(obj, flags & FunctionSignatures);
  stopInterpreter();
  return lst;
}
Пример #13
0
/*!
  Returns all the variables declared in the contenxt \a context.

  \sa functions(), classes()
*/
QStringList QSInterpreter::variables(QObject *context, bool includeStatic, bool includeCustom,
                                     bool includeMemberVariables) const
{
  if (!context) {
#if defined( QT_RANGE_CHECK )
    qWarning("QSInterpreter::variablesOf: context is null");
#endif
    return QStringList();
  }
  startInterpreter();
  QSObject obj = d->interpreter->wrap(context);
  QStringList lst;
  if (!obj.isUndefined())
    lst = d->interpreter->variablesOf(obj, includeStatic, includeCustom,
                                      includeMemberVariables);
  stopInterpreter();
  return lst;
}
Пример #14
0
/*!
  Executes the string of Qt Script in \a code and returns any value
  produced by that \a code.

  This function executes the code passed in as \a code. The code can
  use and reference code (functions, classes, variables, etc.) which
  have been passed to this function previously or which are defined in
  the current project, if present. Also, application objects which have
  been added via addObject() can be accessed.

  If \a context is 0 (the default), the code is executed as global
  code. If a \a context is given, the code is executed in the context
  of that object.

  Interpreters that belong to a project are subject to re-evaluation,
  since the code which has been passed previously into evaluate() gets
  lost when calling one of these functions. This happens when the project
  or the scripts in it are modified.

  \a scriptName is used for error reporting and debugging.
*/
QSArgument QSInterpreter::evaluate(const QString &code, QObject *context,
                                   const QString &scriptName)
{
#if defined (QT_THREAD_SUPPORT) && QT_VERSION >= 0x030300
  if (context
      && context->inherits("QWidget")
      && qt_get_application_thread_id() != QThread::currentThread()) {
    qWarning("QSInterpreter::evaluate(), GUI object %s [%s] not allowed in non GUI thread",
             context->name(), context->className());
    return QSArgument();
  }
#endif
  running = TRUE;
  startInterpreter();
  QSArgument v = d->interpreter->execute(context, code, scriptName);
  running = FALSE;
  stopInterpreter();
  return v;
}