예제 #1
0
파일: mux.c 프로젝트: dzhshf/ssh-rd
void mux_notification_callback(struct am_device_notification_callback_info* info, void* context)
{
    PITMD_CONTEXT ctx = (PITMD_CONTEXT)context;
	switch (info->msg)
	{
        case ADNCI_MSG_CONNECTED:
        {
            int interfaceType = AMDeviceGetInterfaceType(info->dev);   
            int ignore = interfaceType != 1;
            fprintf(stderr, "Device connected: %s%s\n", getConnectedDeviceName(info), 
                ignore ? " - Ignoring (non-USB)" : "");
            if (!ignore) {
                s_target_device = info->dev;
                invokeCallback(ctx, EventRestoreEnter, info->dev);    
            }
        }
            break;
        case ADNCI_MSG_DISCONNECTED:
            fprintf(stderr, "Device disconnected: %s\n", getConnectedDeviceName(info));
            if (info->dev == s_target_device) {
                fprintf(stderr, "Clearing saved mux connection\n");
                s_target_device = NULL;
                muxConn = 0;
                invokeCallback(ctx, EventRestoreExit, info->dev);
            }
            break;
        default:
            break;
	}
	fflush(stderr);
}
예제 #2
0
파일: HttpServer.cpp 프로젝트: artcom/y60
 void Server::handleRequest() {
     try {
         request curRequest;
         while (_myRequestQueue.try_pop(curRequest)) {
             std::string myPath = curRequest.uri.substr(0, curRequest.uri.find_first_of("?"));  
         
             reply curReply;
         
             if (_myCallbacks.find(myPath) != _myCallbacks.end()) {
                 JSCallback myCallback = _myCallbacks[myPath]; 
                 invokeCallback( myCallback, curRequest, curReply);
             } else if (_myCallbacks.find("*") != _myCallbacks.end()) {
                 JSCallback myCallback = _myCallbacks["*"]; 
                 invokeCallback( myCallback, curRequest, curReply);
             } else {
                 curReply.status  = reply::not_found; 
                 AC_ERROR << "No callback registered for path: \"" << myPath << "\"!";
             }
             // Fill out the reply to be sent to the client.
             if (curReply.headers.find("Content-Length") == curReply.headers.end()) {
                 curReply.headers.insert(make_pair("Content-Length",
                             boost::lexical_cast<std::string>(curReply.content.size())));
             }
         
             if (curReply.headers.find("Content-Type") == curReply.headers.end()) {
                 curReply.headers.insert(make_pair("Content-Type", "text/plain"));
             }
             AC_TRACE << "JS Handler returned, queuing write for " << curRequest.conn;
             curRequest.conn->async_respond(curReply); // this is threadsafe
             curRequest.conn.reset(); // free shared_ptr
         }
     } catch (Exception e) {
         AC_ERROR << e;
     };
 }
예제 #3
0
void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg)
{
    if (!canInvokeCallback())
        return;

    v8::HandleScope handleScope(m_isolate);

    v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get());
    if (v8Context.IsEmpty())
        return;

    v8::Context::Scope scope(v8Context);
    v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, v8::Handle<v8::Object>(), m_isolate);
    if (testInterfaceEmptyArgHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return;
    }
    v8::Handle<v8::Value> stringArgHandle = v8String(m_isolate, stringArg);
    if (stringArgHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return;
    }
    v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle, stringArgHandle };

    invokeCallback(m_callback.newLocal(m_isolate), 2, argv, executionContext(), m_isolate);
}
bool V8MetadataCallback::handleEvent(Metadata* metadata)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> metadataHandle = toV8(metadata);
    if (metadataHandle.IsEmpty()) {
        CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        metadataHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
}
bool V8RTCErrorCallback::handleEvent(const String& errorInformation)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> errorInformationHandle = deprecatedV8String(errorInformation);
    if (errorInformationHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        errorInformationHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
}
예제 #6
0
bool V8NavigatorUserMediaSuccessCallback::handleEvent(LocalMediaStream* stream)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> streamHandle = toV8(stream);
    if (streamHandle.IsEmpty()) {
        CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        streamHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
}
예제 #7
0
void Conn::onRead(const boost::system::error_code& error, std::shared_ptr< boost::asio::streambuf > rd_buf) {
	if( unlikely(error) ) {
		log_func("[iproto_conn] %s:%u read error: %s", ep.address().to_string().c_str(), ep.port(), error.message().c_str() );
		dismissCallbacks(CB_ERR);
		if( error != boost::asio::error::operation_aborted ) {
			reconnect();
		}
		return;
	}
	if( unlikely(!rd_buf) )
		rd_buf.reset(new boost::asio::streambuf);
	if( LOG_DEBUG )
		log_func("[iproto_conn] %s:%u onRead rd_buf->size=%zu", ep.address().to_string().c_str(), ep.port(), rd_buf->size());
	while( rd_buf->size() >= sizeof(Header) ) {
		const PacketPtr *buf = boost::asio::buffer_cast< const PacketPtr * >( rd_buf->data() );
		if( LOG_DEBUG )
			log_func("[iproto_conn] %s:%u onRead buffer iproto packet hdr: len=%u sync=%u msg=%u", ep.address().to_string().c_str(), ep.port(),
				buf->hdr.len, buf->hdr.sync, buf->hdr.msg);
		size_t want_read = sizeof(Header)+buf->hdr.len;
		if( want_read <= rd_buf->size() ) {
			invokeCallback(buf->hdr.sync, RequestResult(CB_OK, Packet(buf)) );
			rd_buf->consume( sizeof(Header) + buf->hdr.len );
		}else{
			size_t rd = want_read - rd_buf->size();
			if( LOG_DEBUG )
				log_func("[iproto_conn] %s:%u onRead want_read=%zu", ep.address().to_string().c_str(), ep.port(), rd);
			boost::asio::async_read(sock, *rd_buf, boost::asio::transfer_at_least(rd),
				boost::bind(&Conn::onRead, shared_from_this(), boost::asio::placeholders::error, rd_buf) );
			return;
		}
	}
	if( likely(sock.is_open()) )
		boost::asio::async_read(sock, *rd_buf, boost::asio::transfer_at_least(sizeof(Header)-rd_buf->size()),
			boost::bind(&Conn::onRead, shared_from_this(), boost::asio::placeholders::error, rd_buf) );
}
예제 #8
0
void Conn::onTimeout(const boost::system::error_code& error, uint32_t sync, std::shared_ptr< boost::asio::deadline_timer > timer) {
	if( unlikely(!error && timer) ) {
		if( LOG_DEBUG )
			log_func("[iproto_conn] %s:%u Packet with sync=%u timed out", ep.address().to_string().c_str(), ep.port(), sync);
		invokeCallback(sync, RequestResult(CB_TIMEOUT));
	}
}
예제 #9
0
bool V8TestCallback::callbackWithTestObjectParam(TestObj* class2Param, const String& strArg)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param, v8::Handle<v8::Object>(), v8Context->GetIsolate());
    if (class2ParamHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }
    v8::Handle<v8::Value> strArgHandle = v8String(strArg, v8Context->GetIsolate());
    if (strArgHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        class2ParamHandle,
        strArgHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext());
}
예제 #10
0
bool V8TestCallback::callbackWithSequence(Vector<RefPtr<TestObj> > sequenceParam)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> sequenceParamHandle = v8Array(sequenceParam, v8Context->GetIsolate());
    if (sequenceParamHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        sequenceParamHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
}
예제 #11
0
bool V8TestCallback::callbackWithStringList(RefPtr<DOMStringList> listParam)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> listParamHandle = toV8(listParam, v8::Handle<v8::Object>(), v8Context->GetIsolate());
    if (listParamHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        listParamHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
}
예제 #12
0
void Conn::invokeCallback(uint32_t sync, RequestResult &&req_res) {
	auto it = callbacks_map.find(sync);
	if( it != callbacks_map.end() )
		invokeCallback(it, std::forward<RequestResult>(req_res));
	else if( LOG_DEBUG )
		log_func("[iproto_conn] %s:%u invokeCallback: Packet with sync=%u not found", ep.address().to_string().c_str(), ep.port(), sync);
}
예제 #13
0
void JSKitGeolocation::handleTimeout()
{
    qCDebug(l) << "positioning timeout";

    if (_watches.empty()) {
        qCWarning(l) << "got position timeout but no one is watching";
        _source->stopUpdates();
        return;
    }

    QJSValue obj = buildPositionErrorObject(TIMEOUT, "timeout");

    for (auto it = _watches.begin(); it != _watches.end(); /*no adv*/) {
        if (it->timer.hasExpired(it->timeout)) {
            qCDebug(l) << "positioning timeout for watch" << it->watchId
                             << ", watch is" << it->timer.elapsed() << "ms old, timeout is" << it->timeout;
            invokeCallback(it->errorCallback, obj);

            if (it->once) {
                it = _watches.erase(it);
            } else {
                it->timer.restart();
                ++it;
            }
        } else {
            ++it;
        }
    }

    QMetaObject::invokeMethod(this, "updateTimeouts", Qt::QueuedConnection);
}
예제 #14
0
bool V8AudioBufferCallback::handleEvent(AudioBuffer* audioBuffer)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> audioBufferHandle = toV8(audioBuffer);
    if (audioBufferHandle.IsEmpty()) {
        CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        audioBufferHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
}
bool V8SQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLResultSet* resultSet)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> transactionHandle = toV8(transaction);
    if (transactionHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }
    v8::Handle<v8::Value> resultSetHandle = toV8(resultSet);
    if (resultSetHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        transactionHandle,
        resultSetHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext());
}
bool V8SQLTransactionSyncCallback::handleEvent(SQLTransactionSync* transaction)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> transactionHandle = toV8(transaction);
    if (transactionHandle.IsEmpty()) {
        CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        transactionHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
}
예제 #17
0
	/*static*/
	LRESULT CALLBACK Win32MenuItemImpl::handleMenuClick(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
	{
		if(message == WM_COMMAND)
		{
			int wmId = LOWORD(wParam);

			if(wmId == webInspectorMenuItemID)
			{
				Win32UserWindow *wuw = Win32UserWindow::FromWindow(hWnd);

				if(wuw)
				{
					wuw->ShowWebInspector();
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return invokeCallback(wmId);
			}
		}

		return FALSE;
	}
void V8CustomPositionErrorCallback::handleEvent(PositionError* error)
{
    v8::HandleScope handleScope;

    // ActiveDOMObject will null our pointer to the ScriptExecutionContext when it goes away.
    ScriptExecutionContext* scriptContext = scriptExecutionContext();
    if (!scriptContext)
        return;

    // The lookup of the proxy will fail if the Frame has been detached.
    V8Proxy* proxy = V8Proxy::retrieve(scriptContext);
    if (!proxy)
        return;

    v8::Handle<v8::Context> context = proxy->context();
    if (context.IsEmpty())
        return;

    v8::Context::Scope scope(context);

    v8::Handle<v8::Value> argv[] = {
        toV8(error)
    };

    // Protect the script context until the callback returns.
    RefPtr<ScriptExecutionContext> protector(scriptContext);

    bool callbackReturnValue = false;
    invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptContext);
}
예제 #19
0
void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptValue thisValue, const String& stringArg)
{
    if (!canInvokeCallback())
        return;

    v8::Isolate* isolate = m_scriptState->isolate();
    if (m_scriptState->contextIsEmpty())
        return;

    ScriptState::Scope scope(m_scriptState.get());
    v8::Handle<v8::Value> thisHandle = thisValue.v8Value();
    if (thisHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return;
    }
    ASSERT(thisHandle->IsObject());
    v8::Handle<v8::Value> stringArgHandle = v8String(isolate, stringArg);
    if (stringArgHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return;
    }
    v8::Handle<v8::Value> argv[] = { stringArgHandle };

    invokeCallback(m_callback.newLocal(isolate), v8::Handle<v8::Object>::Cast(thisHandle), 1, argv, executionContext(), isolate);
}
bool V8PositionErrorCallback::handleEvent(PositionError* error)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> errorHandle = toV8(error);
    if (errorHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        errorHandle
    };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
}
bool V8TestCallback::callbackWithTestInterfaceEmptyArg(TestInterfaceEmpty* class2Arg, const String& strArg)
{
    if (!canInvokeCallback())
        return true;

    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    v8::HandleScope handleScope(isolate);

    v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get());
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);
    v8::Handle<v8::Value> class2ArgHandle = toV8(class2Arg, v8::Handle<v8::Object>(), isolate);
    if (class2ArgHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }
    v8::Handle<v8::Value> strArgHandle = v8String(strArg, isolate);
    if (strArgHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }
    v8::Handle<v8::Value> argv[] = { class2ArgHandle, strArgHandle };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, executionContext(), isolate);
}
예제 #22
0
void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg)
{
    if (!canInvokeCallback())
        return;

    v8::Isolate* isolate = m_scriptState->isolate();
    if (m_scriptState->contextIsEmpty())
        return;

    ScriptState::Scope scope(m_scriptState.get());
    v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, v8::Handle<v8::Object>(), isolate);
    if (testInterfaceEmptyArgHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return;
    }
    v8::Handle<v8::Value> stringArgHandle = v8String(isolate, stringArg);
    if (stringArgHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return;
    }
    v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle, stringArgHandle };

    invokeCallback(m_callback.newLocal(isolate), 2, argv, executionContext(), isolate);
}
bool V8SQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
{
    if (!canInvokeCallback())
        return true;

    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    v8::HandleScope handleScope(isolate);

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> transactionHandle = toV8(transaction, v8::Handle<v8::Object>(), v8Context->GetIsolate());
    v8::Handle<v8::Value> errorHandle = toV8(error, v8::Handle<v8::Object>(), isolate);
    if (transactionHandle.IsEmpty() || errorHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        transactionHandle,
        errorHandle
    };

    bool callbackReturnValue = false;
    // Step 6: If the error callback returns false, then move on to the next
    // statement, if any, or onto the next overall step otherwise. Otherwise,
    // the error callback did not return false, or there was no error callback.
    // Jump to the last step in the overall steps.
    return invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, scriptExecutionContext(), isolate) || callbackReturnValue;
}
bool V8TestCallback::callbackWithThisArg(ScriptValue thisValue, int arg)
{
    if (!canInvokeCallback())
        return true;

    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    v8::HandleScope handleScope(isolate);

    v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get());
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);
    v8::Handle<v8::Value> thisHandle = thisValue.v8Value();
    if (thisHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }
    ASSERT(thisHandle->IsObject());
    v8::Handle<v8::Value> argHandle = v8::Integer::New(arg, isolate);
    if (argHandle.IsEmpty()) {
        if (!isScriptControllerTerminating())
            CRASH();
        return true;
    }
    v8::Handle<v8::Value> argv[] = { argHandle };

    bool callbackReturnValue = false;
    return !invokeCallback(m_callback.newLocal(isolate), v8::Handle<v8::Object>::Cast(thisHandle), 1, argv, callbackReturnValue, executionContext(), isolate);
}
bool V8SQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
{
    if (!canInvokeCallback())
        return true;

    v8::HandleScope handleScope;

    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
    if (v8Context.IsEmpty())
        return true;

    v8::Context::Scope scope(v8Context);

    v8::Handle<v8::Value> transactionHandle = toV8(transaction);
    v8::Handle<v8::Value> errorHandle = toV8(error);
    if (transactionHandle.IsEmpty() || errorHandle.IsEmpty()) {
        CRASH();
        return true;
    }

    v8::Handle<v8::Value> argv[] = {
        transactionHandle,
        errorHandle
    };

    bool callbackReturnValue = false;
    // Step 6: If the error callback returns false, then move on to the next
    // statement, if any, or onto the next overall step otherwise. Otherwise,
    // the error callback did not return false, or there was no error callback.
    // Jump to the last step in the overall steps.
    return invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext()) || callbackReturnValue;
}
예제 #26
0
JSValueRef EJApp::loadModuleWithId(NSString * moduleId, JSValueRef module, JSValueRef exports)
{
    NSString * path = NSStringMake(moduleId->getCString() + string(".js"));
    NSString * script = NSString::createWithContentsOfFile(pathForResource(path)->getCString());

    if( !script ) {
        NSLog("Error: Can't Find Module %s", moduleId->getCString() );
        return NULL;
    }

    NSLog("Loading Module: %s", moduleId->getCString() );

    JSStringRef scriptJS = JSStringCreateWithUTF8CString(script->getCString());
    JSStringRef pathJS = JSStringCreateWithUTF8CString(path->getCString());
    JSStringRef parameterNames[] = {
        JSStringCreateWithUTF8CString("module"),
        JSStringCreateWithUTF8CString("exports"),
    };

    JSValueRef exception = NULL;
    JSObjectRef func = JSObjectMakeFunction( jsGlobalContext, NULL, 2,  parameterNames, scriptJS, pathJS, 0, &exception );

    JSStringRelease( scriptJS );
    JSStringRelease( pathJS );
    JSStringRelease(parameterNames[0]);
    JSStringRelease(parameterNames[1]);

    if( exception ) {
        logException(exception, jsGlobalContext);
        return NULL;
    }

    JSValueRef params[] = { module, exports };
    return invokeCallback(func, NULL, 2, params);
}
bool V8CustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
{
    v8::HandleScope handleScope;

    v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get());
    if (context.IsEmpty())
        return true;

    v8::Context::Scope scope(context);

    v8::Handle<v8::Value> argv[] = {
        V8Proxy::ToV8Object(V8ClassIndex::SQLTRANSACTION, transaction),
        V8Proxy::ToV8Object(V8ClassIndex::SQLERROR, error)
    };

    // Protect the frame until the callback returns.
    RefPtr<Frame> protector(m_frame);

    bool callbackReturnValue = false;
    // Step 6: If the error callback returns false, then move on to the next
    // statement, if any, or onto the next overall step otherwise. Otherwise,
    // the error callback did not return false, or there was no error callback.
    // Jump to the last step in the overall steps.
    return invokeCallback(m_callback, 2, argv, callbackReturnValue) && !callbackReturnValue;
}
예제 #28
0
/**
* \ingroup atomvm
* \b atomvmEventSend
*
* This function is to be used by the atom virtual machine.
*
* This function if for synchronization between multiple
* atom vms.
*
*
* @return void.
*/
void
atomvmEventSend  ()
{
    PATOMVM                     patomvm = getAtomvm () ;
    ATOMVM_CALLBACK             callback ;

    invokeCallback (patomvm, callbackEventSend, (PATOMVM_CALLBACK)&callback) ;
}
예제 #29
0
/**
* \ingroup atomvm
* \b atomvmInterruptWait
*
* This function is to be used by the atom virtual machine.
*
* This function if for synchronization between multiple
* atom vms.
*
*
* @return void.
*/
void
atomvmInterruptWait  ()
{
    PATOMVM                     patomvm = getAtomvm () ;
    ATOMVM_CALLBACK             callback ;

    invokeCallback (patomvm, callbackInterruptWait, (PATOMVM_CALLBACK)&callback) ;
}
void MediaQueryListListener::queryChanged(MediaQueryList* query)
{
    if (m_scriptState->contextIsEmpty())
        return;
    ScriptState::Scope scope(m_scriptState.get());
    v8::Handle<v8::Value> args[] = { toV8(query, m_scriptState->context()->Global(), m_scriptState->isolate()) };
    invokeCallback(m_scriptState.get(), v8::Handle<v8::Function>::Cast(m_function.v8Value()), WTF_ARRAY_LENGTH(args), args);
}