예제 #1
0
NPError NPP_SetWindow(NPP instance, NPWindow *window)
{
    PluginObject* obj = static_cast<PluginObject*>(instance->pdata);

    if (obj) {
        obj->lastWindow = *window;

        if (obj->logSetWindow) {
            pluginLog(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)window->height);
            obj->logSetWindow = FALSE;
        }

        if (obj->onSetWindow)
            executeScript(obj, obj->onSetWindow);

        if (obj->testWindowOpen) {
            testWindowOpen(instance);
            obj->testWindowOpen = FALSE;
        }

        if (obj->testKeyboardFocusForPlugins) {
            obj->eventLogging = true;
            executeScript(obj, "eventSender.keyDown('A');");
        }
    }
    
    return NPERR_NO_ERROR;
}
예제 #2
0
파일: main.cpp 프로젝트: UIKit0/WebkitAIR
NPError NPP_Destroy(NPP instance, NPSavedData **save)
{
    PluginObject *obj = (PluginObject*)instance->pdata;
    if (obj) {
        if (obj->testGetURLOnDestroy)
            browser->geturlnotify(obj->npp, "about:blank", "", "");

        if (obj->onStreamLoad)
            free(obj->onStreamLoad);

        if (obj->onURLNotify)
            free(obj->onURLNotify);

        if (obj->onStreamDestroy)
            free(obj->onStreamDestroy);

        if (obj->onDestroy) {
            executeScript(obj, obj->onDestroy);
            free(obj->onDestroy);
        }

        if (obj->logDestroy)
            printf("PLUGIN: NPP_Destroy\n");

        if (obj->onSetWindow)
            free(obj->onSetWindow);

        browser->releaseobject(&obj->header);
    }
    return NPERR_NO_ERROR;
}
예제 #3
0
//int webViewBridge::curBrowseWindowWidth(){return browseWindowWidth;}
//int webViewBridge::curBrowseWindowHeight(){return browseWindowHeight;}
void webViewBridge::processScript(QString func, QString parms)
{
 bResultReceived = false;
 emit executeScript( func,  parms);
 if(func == "loadOverlay")
  qDebug()<<func + " " + parms + "\n";
}
bool CMasterDAOFactorySQLite::executeScriptFile(const char *scriptFile)
{
    if( m_database==NULL ){
        throw PFEXCEPTION("[CMasterDAOFactorySQLite::executeScriptFile] No database connection.");
    }

    char                c;
    std::ostringstream  sql;
    std::ifstream       script(scriptFile);
    if( script.fail() ){
        LOG_ERROR("[CMasterDAOFactorySQLite::executeScriptFile] Error opening the script file: '%s'", scriptFile);
        return false;
    }

    while( script.good() ){
        c = (char) script.get();
        if( c!='\r' && c!='\n' && script.good() ){
            sql << c;
        }else{
            sql << ' ';
        }
    }
    script.close();

    return executeScript(sql.str());
}
예제 #5
0
void LatexTables::generateTableFromTemplate(LatexEditorView *edView,QString templateFileName,QString def,QList<QStringList> table,QString env){
	//read in js template which generates the tabular code
	QFile file(templateFileName);
	if(!file.open(QIODevice::ReadOnly| QIODevice::Text))
		return;
	QTextStream stream(&file);
	QString templateText;
	templateText = stream.readAll();
	//env
	QString envDef="var env=\""+env+"\"\n";
	//tabular column definition
	QString templateDef="var def=\""+def+"\"\n";
	//tabular content as js array
	QString tableDef="var tab=[\n";
	for(int i=0;i<table.size();i++){
		QStringList lst=table.at(i);
		QStringList::iterator it;
		for(it=lst.begin();it!=lst.end();it++){
			QString str=*it;
			str.replace("\\","\\\\");
			str.replace("\"","\\\"");
			*it=str;
		}
		tableDef+="[\""+lst.join("\",\"")+"\"]";
		if(i<table.size()-1)
			tableDef+=",\n";
	}
	tableDef+="]\n";
	//join js parts
	templateText.prepend(tableDef);
	templateText.prepend(envDef);
	templateText.prepend(templateDef);
	//generate tabular in editor
	executeScript(templateText,edView);
}
예제 #6
0
void webViewBridge::processScript(QString func)
{
 bResultReceived = false;
 myRslt = QVariant();
 myList = QVariantList();
 emit executeScript( func, "");
}
예제 #7
0
파일: lingo.cpp 프로젝트: iskrich/director
void Lingo::runTests() {
	Common::File inFile;
	Common::ArchiveMemberList fileList;
	SearchMan.listMatchingMembers(fileList, "*.lingo");

	int counter = 1;

	for (Common::ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) {
		Common::ArchiveMember       const &m      = **it;
		Common::SeekableReadStream *const  stream = m.createReadStream();
		if (stream) {
			uint size = stream->size();

			char *script = (char *)calloc(size + 1, 1);

			stream->read(script, size);

			warning("Compiling file %s of size %d, id: %d", m.getName().c_str(), size, counter);

			_hadError = false;
			addCode(script, kMovieScript, counter);

			if (!_hadError)
				executeScript(kMovieScript, counter);
			else
				warning("Skipping execution");

			free(script);

			counter++;
		}

		inFile.close();
	}
}
예제 #8
0
QScriptValue ScriptManager::getScriptObject(QString name, ScriptComponent* component) {
    if(!hasScript(name)) {
        return QScriptValue::UndefinedValue;
    }

    // save the global object and set an empty one
    QScriptValue global(mScriptEngine->globalObject());
    mScriptEngine->setGlobalObject(mScriptEngine->newObject());

    // write script members/functions as properties into global object
    // like this we have the same engine linked, so the
    executeScript(name);

    // extract the global object and reset the original one
    QScriptValue obj(mScriptEngine->globalObject());
    mScriptEngine->setGlobalObject(global);

    // Set the object's component member.
    QScriptValue componentObject = mScriptEngine->newQObject(component);
    QScriptValue prop = obj.property("component");
    if(prop.isValid()) {
        Logger::get().warning("Overriding member \"component\" in script \"" + name + "\" with ScriptComponent \"" + component->getName() + "\".");
        Logger::get().info(" > Previous Value: " + prop.toString());
        Logger::get().info(" > Previous  Type: " + QString(prop.toVariant().typeName()) );
    }
    obj.setProperty("component", componentObject);

    return obj;
}
예제 #9
0
	SEQUENCE_INTERRUPTION_LIST GrfParseFree::executeInternal(DtaScriptVariable& visibility) {
		DtaScriptVariable* pClass = visibility.getVariable(*_pClass);
		if (pClass == NULL) throw UtlException("runtime error: variable '" + _pClass->toString() + "' doesn't exist while calling procedure 'parseFree()'");
		std::string sDesignFileName = _pDesignFileName->getValue(visibility);
		std::string sInputFile = _pFileName->getValue(visibility);

		EXECUTE_FUNCTION* executeFunction = NULL;
		if (_pDesignFileName != NULL) {
			std::string sDesignFileName = _pDesignFileName->getValue(visibility);
			if ((_pCachedScript == NULL) || (_sCachedDesignFile != sDesignFileName) || ScpStream::existVirtualFile(sDesignFileName)) {
				executeFunction = DtaScript::getRegisteredScript(sDesignFileName.c_str());
				if (executeFunction == NULL) {
					if (_pCachedScript != NULL) delete _pCachedScript;
					_pCachedScript = new DtaDesignScript(getParent());
					_sCachedDesignFile = sDesignFileName;
					_pCachedScript->parseFile(sDesignFileName.c_str());
				}
			}
		}

		SEQUENCE_INTERRUPTION_LIST result = executeScript(sInputFile.c_str(), pClass, executeFunction);
		switch(result) {
			case CONTINUE_INTERRUPTION:
			case BREAK_INTERRUPTION:
			case RETURN_INTERRUPTION:
				result = NO_INTERRUPTION;
				break;
		}
		return result;
	}
예제 #10
0
파일: beascript.cpp 프로젝트: bagobor/bea
	//Initialize the javascript context and expose the methods in exposer
	bool _BeaScript::init()
	{
		
		lastError = "";
		HandleScope handle_scope;

		if (globalTemplate.IsEmpty()){
			globalTemplate = v8::Persistent<v8::ObjectTemplate>::New(createGlobal());
		}
		
		//Create the context
		m_context = v8::Context::New(NULL, globalTemplate);

		Context::Scope context_scope(m_context);

		globalSandbox = v8::Persistent<v8::Object>::New(v8::Object::New()); 

		Handle<Value> vCmdLine = bea::Convert<std::vector<std::string> >::ToJS(cmdLine);

		Handle<Object> objProcess = v8::Object::New();
		objProcess->Set(v8::String::New("argv"), vCmdLine);

		m_context->Global()->Set(v8::String::New("process"), objProcess);
		
		expose();

		executeScript("./loader.js");
		CloneObject(m_context->Global(), globalSandbox);


		return true; 
	}
예제 #11
0
bool Card::recursiveExecuteScript(std::string tag)
{
    bool success = true;

    if (!this->match("ignoreChildren")) {
        // Build a stack of child cards. We can't just iterate over the
        // list in case a child's script modifies it!
        std::stack<Card *> children;
        for(CardList::iterator cardIter = attached.begin(); cardIter != attached.end(); cardIter++) {
            children.push(*cardIter);
        }

        // Recursively execute the script on each child
        while (!children.empty()) {
            Card *child = children.top();
            children.pop();
            success = child->recursiveExecuteScript(tag) && success;
        }
    }

    // Execute the script on ourself last of all
    success = executeScript(tag) && success;

    return success;
}
예제 #12
0
NPError NPP_Destroy(NPP instance, NPSavedData **save)
{
    PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
    if (obj) {
        if (obj->onDestroy) {
            executeScript(obj, obj->onDestroy);
            free(obj->onDestroy);
        }

        if (obj->onStreamLoad)
            free(obj->onStreamLoad);

        if (obj->onStreamDestroy)
            free(obj->onStreamDestroy);

        if (obj->onURLNotify)
            free(obj->onURLNotify);

        if (obj->onSetWindow)
            free(obj->onSetWindow);
        
        if (obj->logDestroy)
            pluginLog(instance, "NPP_Destroy");

        browser->releaseobject(&obj->header);
    }
    return NPERR_NO_ERROR;
}
예제 #13
0
void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyData)
{
    PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
 
     if (obj->onURLNotify)
         executeScript(obj, obj->onURLNotify);

    handleCallback(obj, url, reason, notifyData);
}
예제 #14
0
NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
{
    PluginObject* obj = (PluginObject*)instance->pdata;

    if (obj->onStreamDestroy)
        executeScript(obj, obj->onStreamDestroy);

    return NPERR_NO_ERROR;
}
예제 #15
0
static int16_t handleEventCocoa(NPP instance, PluginObject* obj, NPCocoaEvent* event)
{
    switch (event->type) {
        case NPCocoaEventWindowFocusChanged:
            
        case NPCocoaEventFocusChanged:
            if (event->data.focus.hasFocus)
                pluginLog(instance, "getFocusEvent");
            else
                pluginLog(instance, "loseFocusEvent");
            return 1;

        case NPCocoaEventDrawRect:
            return 1;

        case NPCocoaEventKeyDown:
            if (event->data.key.characters)
                pluginLog(instance, "keyDown '%c'", CFStringGetCharacterAtIndex(reinterpret_cast<CFStringRef>(event->data.key.characters), 0));
            return 1;

        case NPCocoaEventKeyUp:
            if (event->data.key.characters) {
                pluginLog(instance, "keyUp '%c'", CFStringGetCharacterAtIndex(reinterpret_cast<CFStringRef>(event->data.key.characters), 0));
                if (obj->testKeyboardFocusForPlugins) {
                    obj->eventLogging = false;
                    obj->testKeyboardFocusForPlugins = FALSE;
                    executeScript(obj, "layoutTestController.notifyDone();");
                }
            }
            return 1;

        case NPCocoaEventFlagsChanged:
            return 1;

        case NPCocoaEventMouseDown:
            pluginLog(instance, "mouseDown at (%d, %d)", 
                   (int)event->data.mouse.pluginX,
                   (int)event->data.mouse.pluginY);
            return 1;
        case NPCocoaEventMouseUp:
            pluginLog(instance, "mouseUp at (%d, %d)", 
                   (int)event->data.mouse.pluginX,
                   (int)event->data.mouse.pluginY);
            return 1;
            
        case NPCocoaEventMouseMoved:
        case NPCocoaEventMouseEntered:
        case NPCocoaEventMouseExited:
        case NPCocoaEventMouseDragged:
        case NPCocoaEventScrollWheel:
        case NPCocoaEventTextInput:
            return 1;
    }
    
    return 0;
}
예제 #16
0
void ScriptElement::executeScriptForScriptRunner(PendingScript& pendingScript)
{
    if (auto* loadableScript = pendingScript.loadableScript())
        executeScriptAndDispatchEvent(*loadableScript);
    else {
        ASSERT(!pendingScript.wasErrored());
        executeScript(ScriptSourceCode(scriptContent(), m_element.document().url(), pendingScript.startingPosition()));
        dispatchLoadEvent();
    }
}
예제 #17
0
	bool CServer::initCorutine(const char *corutineName, const char *corutineFunction, const char *resultName)
	{
		// Creo la corrutina.
		std::stringstream corutineCreate;
		corutineCreate << corutineName << " = coroutine.create(" << corutineFunction << ")";
		executeScript(corutineCreate.str().c_str());

		// Ejecuto la corrutina.
		std::stringstream corutineInit;
		corutineInit << "correct, " << resultName << " = coroutine.resume(" << corutineName << ")";
		executeScript(corutineInit.str().c_str());

		// Variable temporal para llamar a "getGlobal"
		bool result;

		// Devuelvo si la corrutina se ha ejecutado correctamente o no.
		return ScriptManager::CServer::getSingletonPtr()->getGlobal("correct", result);

	} // initCorutine
예제 #18
0
/**
 * @brief Wrapper around executeScript to catch more errors
 */
QVariant HTMLWidget::runScript(const QString& scriptCode)
{
    KMAP_ASSERT(d->isReady);

    if (!d->isReady)
        return QVariant();

//     kDebug()<<scriptCode;
    return executeScript(scriptCode);
}
예제 #19
0
void ScriptElement::execute(CachedScript* cachedScript)
{
    ASSERT(!m_willBeParserExecuted);
    ASSERT(cachedScript);
    if (cachedScript->errorOccurred())
        dispatchErrorEvent();
    else if (!cachedScript->wasCanceled()) {
        executeScript(ScriptSourceCode(cachedScript));
        dispatchLoadEvent();
    }
    cachedScript->removeClient(this);
}
예제 #20
0
void ScriptLoader::execute(ScriptResource* resource)
{
    ASSERT(!m_willBeParserExecuted);
    ASSERT(resource);
    if (resource->errorOccurred()) {
        dispatchErrorEvent();
    } else if (!resource->wasCanceled()) {
        executeScript(ScriptSourceCode(resource));
        dispatchLoadEvent();
    }
    resource->removeClient(this);
}
예제 #21
0
파일: beascript.cpp 프로젝트: bagobor/bea
	//Initialize the javascript context and load a script file into it
	bool _BeaScript::loadScript( const char* fileName )
	{
		v8::Locker locker; 
		if (!init())
			return false; 

	
		HandleScope scope; 
		Handle<Value> v = executeScript(fileName);

		return !v.IsEmpty();
	}
예제 #22
0
파일: main.cpp 프로젝트: UIKit0/WebkitAIR
NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
{
    PluginObject* obj = (PluginObject*)instance->pdata;

    if (obj->onStreamDestroy)
        executeScript(obj, obj->onStreamDestroy);

    if (obj->testDocumentOpenInDestroyStream) {
        testDocumentOpen(instance);
    }

    return NPERR_NO_ERROR;
}
void WebApplicationWindow::notifyAppAboutFocusState(bool focus)
{
    qDebug() << "DEBUG: We become" << (focus ? "focused" : "unfocused");

    QString action = focus ? "stageActivated" : "stageDeactivated";

    emit focusChanged();

    if (mTrustScope == TrustScopeSystem)
        executeScript(QString("if (window.Mojo && Mojo.%1) Mojo.%1()").arg(action));

    mApplication->changeActivityFocus(focus);
}
예제 #24
0
bool ScriptController::executeIfJavaScriptURL(const KURL& url, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
{
    if (!protocolIsJavaScript(url))
        return false;

    if (!m_frame->page()
        || !m_frame->page()->javaScriptURLsAreAllowed()
        || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs()
        || m_frame->inViewSourceMode())
        return true;

    // We need to hold onto the Frame here because executing script can
    // destroy the frame.
    RefPtr<Frame> protector(m_frame);
    RefPtr<Document> ownerDocument(m_frame->document());

    const int javascriptSchemeLength = sizeof("javascript:") - 1;

    String decodedURL = decodeURLEscapeSequences(url.string());
    ScriptValue result = executeScript(decodedURL.substring(javascriptSchemeLength));

    // If executing script caused this frame to be removed from the page, we
    // don't want to try to replace its document!
    if (!m_frame->page())
        return true;

    String scriptResult;
#if USE(JSC)
    JSDOMWindowShell* shell = windowShell(mainThreadNormalWorld());
    JSC::ExecState* exec = shell->window()->globalExec();
    if (!result.getString(exec, scriptResult))
        return true;
#else
    if (!result.getString(scriptResult))
        return true;
#endif

    // FIXME: We should always replace the document, but doing so
    //        synchronously can cause crashes:
    //        http://bugs.webkit.org/show_bug.cgi?id=16782
    if (shouldReplaceDocumentIfJavaScriptURL == ReplaceDocumentIfJavaScriptURL) {
        // We're still in a frame, so there should be a DocumentLoader.
        ASSERT(m_frame->document()->loader());
        
        // DocumentWriter::replaceDocument can cause the DocumentLoader to get deref'ed and possible destroyed,
        // so protect it with a RefPtr.
        if (RefPtr<DocumentLoader> loader = m_frame->document()->loader())
            loader->writer()->replaceDocument(scriptResult, ownerDocument.get());
    }
    return true;
}
예제 #25
0
commandDialog::commandDialog(commandHandler *comHandler, QWidget *parent) : QDialog(parent)
{
    this->commands = comHandler;
    this->textOutput = new textOutputDisplay(this);
    this->commandInput = new commandInputWidget(this->commands,this);
    QVBoxLayout *commandLayout = new QVBoxLayout(this);
    commandLayout->addWidget(this->textOutput);
    commandLayout->addWidget(this->commandInput);
    connect(this->commandInput,SIGNAL(executeScript(QString)),this->commands,SLOT(evaluateScript(QString)));
    connect(this->commands,SIGNAL(generatedError(QString)),this->textOutput,SLOT(addError(QString)));
    connect(this->commands,SIGNAL(generatedInfo(QString)),this->textOutput,SLOT(addInfo(QString)));
    this->commandInput->updateAutocompletion();
    this->hide();
}
예제 #26
0
	bool CServer::resumeCorutine(const char *corutineName, const char *resultName, const char *param)
	{
		// Ejecuto la corrutina
		std::stringstream corutineResume;
		corutineResume << "correct, " << resultName << " = coroutine.resume(" << corutineName << ", " << param <<")";
		executeScript(corutineResume.str().c_str());

		// Variable temporal para llamar a "getGlobal"
		bool result;

		// Devuelvo si la corrutina se ha ejecutado correctamente o no.
		return ScriptManager::CServer::getSingletonPtr()->getGlobal("correct", result);

	} // resumeCorutine
예제 #27
0
파일: main.cpp 프로젝트: UIKit0/WebkitAIR
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16_t *stype)
{
    PluginObject* obj = (PluginObject*)instance->pdata;

    if (obj->returnErrorFromNewStream)
        return NPERR_GENERIC_ERROR;

    obj->stream = stream;
    *stype = NP_ASFILEONLY;

    if (obj->onStreamLoad)
        executeScript(obj, obj->onStreamLoad);

    return NPERR_NO_ERROR;
}
예제 #28
0
파일: lingo.cpp 프로젝트: RobLoach/scummvm
void Lingo::processEvent(LEvent event, int entityId) {
	if (!_eventHandlerTypes.contains(event))
		error("processEvent: Unknown event %d for entity %d", event, entityId);

	ScriptType st = event2script(event);

	if (st != kNoneScript) {
		executeScript(st, entityId + 1);
	} else if (_handlers.contains(_eventHandlerTypes[event])) {
		call(_eventHandlerTypes[event], 0);
		pop();
	} else {
		warning("---- Handler %s is not set", _eventHandlerTypes[event]);
		debugC(8, kDebugLingoExec, "STUB: processEvent(%s) for %d", _eventHandlerTypes[event], entityId);
	}
}
예제 #29
0
static void
doOneImage(FILE *          const ifP,
           struct script * const scriptP)  {

    pixel ** pixels;
    pixval maxval;
    int rows, cols;
    
    pixels = ppm_readppm(ifP, &cols, &rows, &maxval);
    
    executeScript(scriptP, pixels, cols, rows, maxval);
    
    ppm_writeppm(stdout, pixels, cols, rows, maxval, 0);
    
    ppm_freearray(pixels, rows);
}
예제 #30
0
void ScriptLoader::execute()
{
    ASSERT(!m_willBeParserExecuted);
    ASSERT(m_pendingScript.resource());
    bool errorOccurred = false;
    ScriptSourceCode source = m_pendingScript.getSource(KURL(), errorOccurred);
    RefPtrWillBeRawPtr<Element> element = m_pendingScript.releaseElementAndClear();
    ALLOW_UNUSED_LOCAL(element);
    if (errorOccurred) {
        dispatchErrorEvent();
    } else if (!m_resource->wasCanceled()) {
        executeScript(source);
        dispatchLoadEvent();
    }
    m_resource = 0;
}