static void createContextGLX(JNIEnv *env, X11PeerInfo *peer_info, X11Context *context_info, GLXContext shared_context) {
	XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info);
	if (vis_info == NULL)
		return;
	GLXContext context = lwjgl_glXCreateContext(peer_info->display, vis_info, shared_context, True);
	XFree(vis_info);
	if (!checkContext(env, peer_info->display, context))
		return;
	context_info->context = context;
}
Exemplo n.º 2
0
QScriptValue File::js_makePath(QScriptContext *context, QScriptEngine *engine)
{
    Q_UNUSED(engine);
    if (Q_UNLIKELY(context->argumentCount() < 1)) {
        return context->throwError(QScriptContext::SyntaxError,
                                   Tr::tr("makePath expects 1 argument"));
    }

    const auto se = static_cast<ScriptEngine *>(engine);
    const DubiousContextList dubiousContexts({ DubiousContext(EvalContext::PropertyEvaluation) });
    se->checkContext(QLatin1String("File.makePath()"), dubiousContexts);

    return QDir::root().mkpath(context->argument(0).toString());
}
Exemplo n.º 3
0
QScriptValue File::js_move(QScriptContext *context, QScriptEngine *engine)
{
    Q_UNUSED(engine);
    if (Q_UNLIKELY(context->argumentCount() < 2)) {
        return context->throwError(QScriptContext::SyntaxError,
                                   Tr::tr("move expects 2 arguments"));
    }

    const auto se = static_cast<ScriptEngine *>(engine);
    const DubiousContextList dubiousContexts({ DubiousContext(EvalContext::PropertyEvaluation) });
    se->checkContext(QLatin1String("File.move()"), dubiousContexts);

    const QString sourceFile = context->argument(0).toString();
    const QString targetFile = context->argument(1).toString();
    const bool overwrite = context->argumentCount() > 2 ? context->argument(2).toBool() : true;

    if (Q_UNLIKELY(QFileInfo(sourceFile).isDir()))
        return context->throwError(QString(QLatin1String("Could not move '%1' to '%2': "
                                                         "Source file path is a directory."))
                                   .arg(sourceFile, targetFile));

    if (Q_UNLIKELY(QFileInfo(targetFile).isDir())) {
        return context->throwError(QString(QLatin1String("Could not move '%1' to '%2': "
                                                         "Destination file path is a directory."))
                                   .arg(sourceFile, targetFile));
    }

    QFile f(targetFile);
    if (overwrite && f.exists() && !f.remove())
        return context->throwError(QString(QLatin1String("Could not move '%1' to '%2': %3"))
                                   .arg(sourceFile, targetFile, f.errorString()));

    if (QFile::exists(targetFile))
        return context->throwError(QString(QLatin1String("Could not move '%1' to '%2': "
                                                         "Destination file exists."))
                                   .arg(sourceFile, targetFile));

    QFile f2(sourceFile);
    if (Q_UNLIKELY(!f2.rename(targetFile)))
        return context->throwError(QString(QLatin1String("Could not move '%1' to '%2': %3"))
                                   .arg(sourceFile, targetFile, f2.errorString()));
    return true;
}
Exemplo n.º 4
0
QScriptValue File::js_remove(QScriptContext *context, QScriptEngine *engine)
{
    Q_UNUSED(engine);
    if (Q_UNLIKELY(context->argumentCount() < 1)) {
        return context->throwError(QScriptContext::SyntaxError,
                                   Tr::tr("remove expects 1 argument"));
    }

    const auto se = static_cast<ScriptEngine *>(engine);
    const DubiousContextList dubiousContexts({ DubiousContext(EvalContext::PropertyEvaluation) });
    se->checkContext(QLatin1String("File.remove()"), dubiousContexts);

    QString fileName = context->argument(0).toString();

    QString errorMessage;
    if (Q_UNLIKELY(!removeFileRecursion(QFileInfo(fileName), &errorMessage)))
        return context->throwError(errorMessage);
    return true;
}
ScriptCached *CacheReader::readCacheFile(FileHandle *objFile,
                                         FileHandle *infoFile,
                                         Script *S) {
  // Check file handle
  if (!objFile || objFile->getFD() < 0 ||
      !infoFile || infoFile->getFD() < 0) {
    return NULL;
  }

  mObjFile = objFile;
  mInfoFile = infoFile;

  // Allocate ScriptCached object
  mpResult.reset(new (nothrow) ScriptCached(S));

  if (!mpResult) {
    LOGE("Unable to allocate ScriptCached object.\n");
    return NULL;
  }

  bool result = checkFileSize()
             && readHeader()
             && checkHeader()
             && checkMachineIntType()
             && checkSectionOffsetAndSize()
             && readStringPool()
             && checkStringPool()
             && readDependencyTable()
             && checkDependency()
             && readExportVarList()
             && readExportFuncList()
             && readPragmaList()
             && readFuncTable()
             && readObjectSlotList()
             && readContext()
             && checkContext()
             //&& readRelocationTable()
             //&& relocate()
             ;

  return result ? mpResult.take() : NULL;
}
Exemplo n.º 6
0
QScriptValue File::js_directoryEntries(QScriptContext *context, QScriptEngine *engine)
{
    Q_UNUSED(engine);
    if (Q_UNLIKELY(context->argumentCount() < 2)) {
        return context->throwError(QScriptContext::SyntaxError,
                                   Tr::tr("directoryEntries expects 2 arguments"));
    }

    const auto se = static_cast<ScriptEngine *>(engine);
    const DubiousContextList dubiousContexts({
            DubiousContext(EvalContext::PropertyEvaluation, DubiousContext::SuggestMoving)
    });
    se->checkContext(QLatin1String("File.directoryEntries()"), dubiousContexts);

    const QString path = context->argument(0).toString();
    const auto filters = static_cast<QDir::Filters>(context->argument(1).toUInt32());
    QDir dir(path);
    const QStringList entries = dir.entryList(filters, QDir::Name);
    se->addDirectoryEntriesResult(path, filters, entries);
    return qScriptValueFromSequence(engine, entries);
}
static void createContextGLX13(JNIEnv *env, X11PeerInfo *peer_info, X11Context *context_info, jobject attribs, GLXContext shared_context) {
	GLXFBConfig *config = getFBConfigFromPeerInfo(env, peer_info);
	if (config == NULL)
		return;
	GLXContext context;
	if (attribs) {
		const int *attrib_list = (const int *)(*env)->GetDirectBufferAddress(env, attribs);
		context = lwjgl_glXCreateContextAttribsARB(peer_info->display, *config, shared_context, True, attrib_list);
	} else {
		int render_type;
		if (lwjgl_glXGetFBConfigAttrib(peer_info->display, *config, GLX_RENDER_TYPE, &render_type) != 0) {
			throwException(env, "Could not get GLX_RENDER_TYPE attribute");
			return;
		}
		int context_render_type = (render_type & GLX_RGBA_FLOAT_BIT) != 0 ? GLX_RGBA_FLOAT_TYPE : GLX_RGBA_TYPE;
		context = lwjgl_glXCreateNewContext(peer_info->display, *config, context_render_type, shared_context, True);
	}
	XFree(config);
	if (!checkContext(env, peer_info->display, context))
		return;
	context_info->context = context;
}