Ejemplo n.º 1
0
KJS::Object KstBindLegend::construct(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() == 0 || args.size() > 2) {
    return createSyntaxError(exec);
  }

  KstViewObjectPtr view = extractViewObject(exec, args[0]);
  if (!view) {
    KstViewWindow *w = extractWindow(exec, args[0]);
    if (w) {
      view = w->view();
    } else {
      return createTypeError(exec, 0);
    }
  }

  QString txt;
  if (args.size() == 2) {
    if (args[1].type() != KJS::StringType) {
      return createTypeError(exec, 1);
    }
    txt = args[1].toString(exec).qstring();
  }

  KstViewLegendPtr b = new KstViewLegend;
  view->appendChild(b.data());
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
  return KJS::Object(new KstBindLegend(exec, b));
}
KJS::Value KstBindDataSource::frameCount(KJS::ExecState *exec, const KJS::List& args) {
  QString field;

  if (args.size() == 1) {
    if (args[0].type() != KJS::StringType) {
      KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
      exec->setException(eobj);
      return KJS::Number(0);
    }
    field = args[0].toString(exec).qstring();
  } else if (args.size() != 0) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires at most one argument.");
    exec->setException(eobj);
    return KJS::Number(0);
  }

  KstDataSourcePtr s = makeSource(_d);
  if (!s) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
    exec->setException(eobj);
    return KJS::Number(0);
  }

  s->writeLock();
  int rc = s->frameCount(field);
  s->unlock();

  return KJS::Number(rc);
}
Ejemplo n.º 3
0
KJS::Value QDirImp::entryInfoList_30( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;

    int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;

      instance->entryInfoList(
       arg0,
       arg1 );
      return KJS::Value(); // Returns 'const QFileInfoList *'

}
Ejemplo n.º 4
0
KJS::Value QDirImp::encodedEntryList_26( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;

    int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;

      instance->encodedEntryList(
       arg0,
       arg1 );
      return KJS::Value(); // Returns 'QStrList'

}
Ejemplo n.º 5
0
KJS::Value QDirImp::exists_43( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

    bool arg1 = (args.size() >= 2) ? args[1].toBoolean(exec) : false;

      bool ret;
      ret = instance->exists(
       arg0,
       arg1 );
      return KJS::Boolean( ret );

}
Ejemplo n.º 6
0
KJS::Value QDirImp::match_56( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

    QString arg1 = (args.size() >= 2) ? args[1].toString(exec).qstring() : QString::null;

      bool ret;
      ret = instance->match(
       arg0,
       arg1 );
      return KJS::Boolean( ret );

}
Ejemplo n.º 7
0
KJS::Value QDirImp::absFilePath_13( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

    bool arg1 = (args.size() >= 2) ? args[1].toBoolean(exec) : false;

      QString ret;
      ret = instance->absFilePath(
       arg0,
       arg1 );
      return KJS::String( ret );

}
Ejemplo n.º 8
0
 KJS::Object QDirLoader::createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const
 {
     JSOpaqueProxy * prx;
     if ( args.size() == 0 ) {
         prx = new JSOpaqueProxy( new QDir( QDir::current() ), "QDir" );
     } else {
         QString arg0 = ( args.size() >= 1 ) ? args[ 0 ].toString( exec ).qstring() : QString::null;
         prx = new JSOpaqueProxy( new QDir( arg0 ), "QDir" );
     }
     prx->setOwner( JSProxy::JavaScript );
     KJS::Object proxyObj( prx );
     addBindings( jspart, exec, proxyObj );
     return proxyObj;
 }
Ejemplo n.º 9
0
KJS::Value KstBindDataVector::changeFrames(KJS::ExecState *exec, const KJS::List& args) {
  KstRVectorPtr v = makeDataVector(_d);
  if (!v) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
    exec->setException(eobj);
    return KJS::Undefined();
  }

  if (args.size() > 1) {
    if (args[0].type() != KJS::NumberType ||
        args[1].type() != KJS::NumberType) {
      KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
      exec->setException(eobj);
      return KJS::Undefined();
    }

    KstWriteLocker wl(v);
    int start = d2i(args[0].toNumber(exec));
    int count = d2i(args[1].toNumber(exec));
    int skip = v->doSkip() ? v->skip() : -1;
    bool ave = v->doAve();

    if (args.size() > 2) {
      if (args[2].type() != KJS::NumberType) {
        KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
        exec->setException(eobj);
        return KJS::Undefined();
      }

      skip = d2i(args[2].toNumber(exec));

      if (args.size() > 3) {
        if (args[3].type() != KJS::BooleanType) {
          KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
          exec->setException(eobj);
          return KJS::Undefined();
        }

        ave = d2i(args[3].toBoolean(exec));
      }
    }

    v->changeFrames(start, count, skip, skip >= 0, ave);
    return KJS::Undefined();
  }

  KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError);
  exec->setException(eobj);
  return KJS::Undefined();
}
KJS::Object KstBindDataSource::construct(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() < 1) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError);
    exec->setException(eobj);
    return KJS::Object();
  }

  if (args[0].type() != KJS::StringType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return KJS::Object();
  }

  QString file = args[0].toString(exec).qstring();
  QString type;

  if (args.size() == 2) {
    if (args[1].type() != KJS::StringType) {
      KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
      exec->setException(eobj);
      return KJS::Object();
    }
    type = args[1].toString(exec).qstring();
  }

  bool newSource = false;
  KST::dataSourceList.lock().readLock();
  KstDataSourcePtr ds = *KST::dataSourceList.findFileName(file);
  KST::dataSourceList.lock().unlock();

  if (!ds) {
    ds = KstDataSource::loadSource(file, type);
    newSource = true;
  }

  if (!ds) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
    exec->setException(eobj);
    return KJS::Object();
  }

  if (newSource) {
    KST::dataSourceList.lock().writeLock();
    KST::dataSourceList.append(ds);
    KST::dataSourceList.lock().unlock();
  }

  return KJS::Object(new KstBindDataSource(exec, ds));
}
Ejemplo n.º 11
0
KJS::Value QDirImp::entryList_28( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;

    int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;

      QStringList ret;
      ret = instance->entryList(
       arg0,
       arg1 );

       return convertToValue( exec, ret );

}
Ejemplo n.º 12
0
KJS::Value QDirImp::entryInfoList_31( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

    int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;

    int arg2 = (args.size() >= 3) ? args[2].toInteger(exec) : -1;

      instance->entryInfoList(
       arg0,
       arg1,
       arg2 );
      return KJS::Value(); // Returns 'const QFileInfoList *'

}
Ejemplo n.º 13
0
KJS::Value KstBindCurve::yMinusErrorPoint(KJS::ExecState *exec, const KJS::List& args) {
  KstVCurvePtr d = makeCurve(_d);
  if (!d) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
    exec->setException(eobj);
    return KJS::Undefined();
  }

  if (args.size() != 1) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly one argument.");
    exec->setException(eobj);
    return KJS::Undefined();
  }

  unsigned i = 0;
  if (args[0].type() != KJS::NumberType || !args[0].toUInt32(i)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return KJS::Undefined();
  }

  KstReadLocker rl(d);
  double x, y, e;
  d->getEYMinusPoint(i, x, y, e);
  return KJS::Number(e);
}
KJS::Value KstBindDataSource::samplesPerFrame(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::Number(0);
  }

  if (args[0].type() != KJS::StringType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return KJS::Number(0);
  }

  KstDataSourcePtr s = makeSource(_d);
  if (!s) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
    exec->setException(eobj);
    return KJS::Number(0);
  }

  s->writeLock();
  int rc = s->samplesPerFrame(args[0].toString(exec).qstring());
  s->unlock();

  return KJS::Number(rc);
}
KJS::Value KstBindDataSource::isValidField(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::Boolean(false);
  }

  if (args[0].type() != KJS::StringType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return KJS::Boolean(false);
  }

  KstDataSourcePtr s = makeSource(_d);
  if (!s) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
    exec->setException(eobj);
    return KJS::Boolean(false);
  }

  s->writeLock();
  bool rc = s->isValidField(args[0].toString(exec).qstring());
  s->unlock();

  return KJS::Boolean(rc);
}
Ejemplo n.º 16
0
KJS::Value KstBindKst::loadScript(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() != 1) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError);
    exec->setException(eobj);
    return KJS::Undefined();
  }

  if (args[0].type() != KJS::StringType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return KJS::Undefined();
  }

  QString fn = args[0].toString(exec).qstring();
  if (!QFile::exists(fn)) { // One day make this support KIO FIXME
    return KJS::Boolean(false);
  }

  if (_ext->part()->runFile(fn)) {
    // FIXME: add to the script registry
  } else {
    KJS::Completion c = _ext->part()->completion();
    if (!c.isNull()) {
      QString err = c.toString(_ext->part()->globalExec()).qstring();
      KstDebug::self()->log(i18n("Error running script %1: %2").arg(fn).arg(err), KstDebug::Error);
    } else {
      KstDebug::self()->log(i18n("Unknown error running script %1.").arg(fn), KstDebug::Error);
    }
    return KJS::Boolean(false);
  }

  return KJS::Boolean(true);
}
Ejemplo n.º 17
0
KJS::Value QDirImp::match_55( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QStringList arg0;
    if ( args.size() >= 1 ) {
      // TODO: populate the list
    }

    QString arg1 = (args.size() >= 2) ? args[1].toString(exec).qstring() : QString::null;

      bool ret;
      ret = instance->match(
       arg0,
       arg1 );
      return KJS::Boolean( ret );

}
Ejemplo n.º 18
0
KJS::Value KstBindDebug::clearNewError(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() != 0) {
    return createSyntaxError(exec);
  }

  KstDebug::self()->clearHasNewError();
  return KJS::Undefined();
}
Ejemplo n.º 19
0
KJS::Value QDirImp::rename_42( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

    QString arg1 = (args.size() >= 2) ? args[1].toString(exec).qstring() : QString::null;

    bool arg2 = (args.size() >= 3) ? args[2].toBoolean(exec) : false;

      bool ret;
      ret = instance->rename(
       arg0,
       arg1,
       arg2 );
      return KJS::Boolean( ret );

}
Ejemplo n.º 20
0
KJS::Value QDirImp::entryList_29( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

    int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;

    int arg2 = (args.size() >= 3) ? args[2].toInteger(exec) : -1;

      QStringList ret;
      ret = instance->entryList(
       arg0,
       arg1,
       arg2 );

       return convertToValue( exec, ret );

}
Ejemplo n.º 21
0
KJS::Object KstBindPoint::construct(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() == 0) {
    return KJS::Object(new KstBindPoint(exec, 0, 0));
  }

  if (args.size() != 2) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError);
    exec->setException(eobj);
    return KJS::Object();
  }

  if (args[0].type() != KJS::NumberType || args[1].type() != KJS::NumberType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return KJS::Object();
  }

  return KJS::Object(new KstBindPoint(exec, args[0].toNumber(exec), args[1].toNumber(exec)));
}
Ejemplo n.º 22
0
KJS::Value KstBindKst::purge(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() != 0) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError);
    exec->setException(eobj);
    return KJS::Undefined();
  }

  KstApp::inst()->document()->purge();
  return KJS::Undefined();
}
Ejemplo n.º 23
0
KJS::Value QDirImp::setNameFilter_17( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

      instance->setNameFilter(
       arg0 );
      return KJS::Value(); // Returns void

}
Ejemplo n.º 24
0
KJS::Value QDirImp::setMatchAllDirs_23( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    bool arg0 = (args.size() >= 1) ? args[0].toBoolean(exec) : false;

      instance->setMatchAllDirs(
       arg0 );
      return KJS::Value(); // Returns void

}
Ejemplo n.º 25
0
KJS::Value QDirImp::setSorting_21( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;

      instance->setSorting(
       arg0 );
      return KJS::Value(); // Returns void

}
Ejemplo n.º 26
0
KJS::Value QDirImp::convertSeparators_45( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

      QString ret;
      ret = instance->convertSeparators(
       arg0 );
      return KJS::String( ret );

}
Ejemplo n.º 27
0
KJS::Value QDirImp::cleanDirPath_57( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

      QString ret;
      ret = instance->cleanDirPath(
       arg0 );
      return KJS::String( ret );

}
Ejemplo n.º 28
0
KJS::Value QDirImp::isRelativePath_58( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;

      bool ret;
      ret = instance->isRelativePath(
       arg0 );
      return KJS::Boolean( ret );

}
Ejemplo n.º 29
0
KJS::Object KstBindWindow::construct(KJS::ExecState *exec, const KJS::List& args) {
  QString name;
  if (args.size() > 1) {
    return createSyntaxError(exec);
  }

  if (args.size() == 1) {
    if (args[0].type() != KJS::StringType) {
      return createTypeError(exec, 0);
    }
    name = args[0].toString(exec).qstring();
  }

  name = KstApp::inst()->newWindow(name);
  KstViewWindow *w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(name));
  if (!w) {
    return createGeneralError(exec, i18n("Failed to create new tab."));
  }

  return KJS::Object(new KstBindWindow(exec, w));
}
Ejemplo n.º 30
0
KJS::Value KstBindDebug::debug(KJS::ExecState *exec, const KJS::List& args) {
  if (args.size() != 1) {
    return createSyntaxError(exec);
  }

  if (args[0].type() != KJS::StringType) {
    return createTypeError(exec, 0);
  }

  KstDebug::self()->log(args[0].toString(exec).qstring(), KstDebug::Debug);
  return KJS::Undefined();
}