Beispiel #1
0
void handleResult(LuaResult err, const LuaValue* val)
{
  LuaResult result = LUA_OK;

  switch(err) {
    case LUA_OK:
      return;

    case LUA_ERRSTACK:
      result = luaG_runerror("stack overflow");
      handleResult(result);
      return;

    case LUA_BAD_TABLE:
      result = luaG_typeerror(val, "index");
      handleResult(result);
      return;

    case LUA_BAD_INDEX_TM:
      result = luaG_typeerror(val, "invalid type in __index method");
      handleResult(result);
      return;

    case LUA_META_LOOP:
      result = luaG_runerror("loop in gettable");
      handleResult(result);
      return;

    default:
      throwError(err);
      return;
  }
}
Beispiel #2
0
l_noret luaG_ordererror (const LuaValue *p1, const LuaValue *p2) {
  LuaResult result = LUA_OK;
  const char *t1 = objtypename(p1);
  const char *t2 = objtypename(p2);
  if (t1 == t2) {
    result = luaG_runerror("attempt to compare two %s values", t1);
    handleResult(result);
  }
  else {
    result = luaG_runerror("attempt to compare %s with %s", t1, t2);
    handleResult(result);
  }
}
Beispiel #3
0
eCodes SslHelper::closeSsl(SSL* ssl)
{
    if (!ssl)
    {
        return eCodes::ST_Ok;
    }

    int ret = SSL_shutdown(ssl);

    // ret is 0 means we have sent the notify to remote. ret is 1 means
    // both sides have sent the notify. ret 0 is enought for us. so We
    // will just close the connection and not wait for the notify from
    // remote.
    if (ret == 0 || ret == 1)
    {
        return eCodes::ST_Ok;
    }

    auto code = handleResult(ssl, ret, "closeSsl");

    if (code != eCodes::ST_RetryWhenReadable &&
        code != eCodes::ST_RetryWhenWritable)
    {
        return eCodes::ST_Ok;
    }

    return code;
}
Beispiel #4
0
l_noret luaG_concaterror (StkId p1, StkId p2) {
  LuaResult result = LUA_OK;
  if (p1->isString() || p1->isNumber()) p1 = p2;
  assert(!p1->isString() && !p2->isNumber());
  result = luaG_typeerror(p1, "concatenate");
  handleResult(result);
}
Beispiel #5
0
static void collectvalidlines (LuaThread *L, LuaClosure *f) {
  THREAD_CHECK(L);
  if (f == NULL || f->isC) {
    LuaResult result = L->stack_.push_reserve2(LuaValue::Nil());
    handleResult(result);
  }
  else {
    LuaTable* t = new LuaTable();  /* new table to store active lines */
    LuaResult result = L->stack_.push_reserve2(LuaValue(t));
    handleResult(result);

    LuaValue v = LuaValue(true);
    for (int i = 0; i < (int)f->proto_->lineinfo.size(); i++) {
      /* for all lines with code */
      LuaValue key(f->proto_->lineinfo[i]);
      t->set(key, v);  /* table[line] = true */
    }
  }
}
void ServerPacketHandlerSystem::processEntities( const vector<Entity*>& p_entities )
{
	float dt = m_world->getDelta();

	m_stateSystem = static_cast<ServerStateSystem*>(
		m_world->getSystem(SystemType::ServerStateSystem));

	handleClientDisconnect();

	switch (m_stateSystem->getCurrentState())
	{
	case ServerStates::INGAME:
		{
			handleIngame();
			break;
		}
	case ServerStates::LOADING:
		{
			handleLoading();
			break;
		}
	case ServerStates::LOBBY:
		{
			handleLobby();
			break;
		}
	case ServerStates::SENTALLPACKETS:
		{
			handleSentAllPackets();
			break;
		}
	case ServerStates::RESULTS:
		{
			handleResult();
			break;
		}
	default:
		break;
	}
	/*
	if( static_cast<TimerSystem*>(m_world->getSystem(SystemType::TimerSystem))->
		checkTimeInterval(TimerIntervals::HalfSecond))
	{
		float timeStamp = m_world->getElapsedTime();

		PingPacket pingPacket;
		pingPacket.timeStamp = timeStamp;

		m_server->broadcastPacket( pingPacket.pack() );
	}
	*/
}
Beispiel #7
0
    void ImportHelper::sendCsvBuffer () {
      if (_hasError) {
        return;
      }

      map<string, string> headerFields;
      string url("/_api/import?" + getCollectionUrlPart() + "&line=" + StringUtils::itoa(_rowOffset) + "&details=true");
      SimpleHttpResult* result = _client->request(HttpRequest::HTTP_REQUEST_POST, url, _outputBuffer.c_str(), _outputBuffer.length(), headerFields);

      handleResult(result);

      _outputBuffer.clear();
      _rowOffset = _rowsRead;
    }
Beispiel #8
0
    void ResultBuilder::captureExpectedException( Matchers::Impl::MatcherBase<std::string> const& matcher ) {

        assert( !isFalseTest( m_assertionInfo.resultDisposition ) );
        AssertionResultData data = m_data;
        data.resultType = ResultWas::Ok;
        data.reconstructedExpression = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);

        std::string actualMessage = Catch::translateActiveException();
        if( !matcher.match( actualMessage ) ) {
            data.resultType = ResultWas::ExpressionFailed;
            data.reconstructedExpression = actualMessage;
        }
        AssertionResult result( m_assertionInfo, data );
        handleResult( result );
    }
 void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher ) {
     
     assert( m_exprComponents.testFalse == false );
     AssertionResultData data = m_data;
     data.resultType = ResultWas::Ok;
     data.reconstructedExpression = m_assertionInfo.capturedExpression;
     
     std::string actualMessage = Catch::translateActiveException();
     if( !matcher.match( actualMessage ) ) {
         data.resultType = ResultWas::ExpressionFailed;
         data.reconstructedExpression = actualMessage;
     }
     AssertionResult result( m_assertionInfo, data );
     handleResult( result );
 }
Beispiel #10
0
    void ImportHelper::sendJsonBuffer (char const* str, size_t len, bool isArray) {
      if (_hasError) {
        return;
      }

      map<string, string> headerFields;
      SimpleHttpResult* result;
      if (isArray) {
        result = _client->request(HttpRequest::HTTP_REQUEST_POST, "/_api/import?type=array&" + getCollectionUrlPart() + "&details=true", str, len, headerFields);
      }
      else {
        result = _client->request(HttpRequest::HTTP_REQUEST_POST, "/_api/import?type=documents&" + getCollectionUrlPart() + "&details=true", str, len, headerFields);
      }

      handleResult(result);
    }
Beispiel #11
0
LuaResult luaG_errormsg2 ( const char* message ) {
  LuaThread *L = thread_L;

  LuaString* s = L->l_G->strings_->Create(message);
  LuaValue error_arg = LuaValue(s);

  if (L->errfunc != 0) {  /* is there an error handling function? */
    StkId errfunc = L->stack_.atIndex(L->errfunc);
    if (!errfunc->isFunction()) throwError(LUA_ERRERR);

    L->stack_.push_nocheck(*errfunc);
    L->stack_.push_nocheck(error_arg);

    LuaResult result = L->stack_.reserve2(0);
    handleResult(result);
    luaD_call(L, 1, 1, 0);  /* call it */
    return LUA_ERRRUN;
  }
  else {
    L->stack_.push_nocheck(error_arg);
    return LUA_ERRRUN;
  }
}
Beispiel #12
0
l_noret luaG_errormsg () {
  LuaThread *L = thread_L;

  LuaValue error_arg = L->stack_.at(-1);
  L->stack_.pop();

  if (L->errfunc != 0) {  /* is there an error handling function? */
    StkId errfunc = L->stack_.atIndex(L->errfunc);
    if (!errfunc->isFunction()) throwError(LUA_ERRERR);

    L->stack_.push_nocheck(*errfunc);
    L->stack_.push_nocheck(error_arg);

    LuaResult result = L->stack_.reserve2(0);
    handleResult(result);
    luaD_call(L, 1, 1, 0);  /* call it */
    throwError(LUA_ERRRUN);
  }
  else {
    L->stack_.push_nocheck(error_arg);
    throwError(LUA_ERRRUN);
  }
}
Beispiel #13
0
int lua_getinfo (LuaThread *L, const char *what, LuaDebug *ar) {
  THREAD_CHECK(L);
  int status;
  LuaClosure *cl;
  LuaStackFrame *ci;
  StkId func;
  if (*what == '>') {
    ci = NULL;
    func = L->stack_.top_ - 1;
    api_check(func->isFunction(), "function expected");
    what++;  /* skip the '>' */
    L->stack_.pop();  /* pop function */
  }
  else {
    ci = ar->i_ci;
    func = ci->getFunc();
    assert(ci->getFunc()->isFunction());
  }
  cl = NULL;

  if(func->isCClosure()) cl = func->getCClosure();
  if(func->isLClosure()) cl = func->getLClosure();

  status = auxgetinfo(L, what, ar, cl, ci);
  
  LuaResult result = LUA_OK;
  if (strchr(what, 'f')) {
    result = L->stack_.push_reserve2(*func);
  }
  handleResult(result);

  if (strchr(what, 'L')) {
    collectvalidlines(L, cl);
  }

  return status;
}
Beispiel #14
0
 void ResultBuilder::endExpression( DecomposedExpression const& expr ) {
     AssertionResult result = build( expr );
     handleResult( result );
 }
Beispiel #15
0
DetectorState::DetectorState(QObject *parent, Recorder *rec) : QObject(parent), tracker(0.2,0.5,60.0,15,15)
{
    recorder = rec;
    resetState();

    map_result[UNKNOWN] = {"At least one object found positive: saved video",true};
    map_result[AIRPLANE] = {"Object was airplane: removed video",false};
    map_result[BIRD] = {"Object was bird: removed video",false};
    map_result[MIN_POSITIVE_NOT_REACHED] = {"Minimum required positive detections not met: removed video",false};
    map_result[ALL_NEGATIVE] = {"All found objects negative: removed video",false};
    qRegisterMetaType<DetectorState::DetectionResult>();
    connect(this,SIGNAL(foundDetectionResult(DetectorState::DetectionResult)),this,SLOT(handleResult(DetectorState::DetectionResult)));

}
 void ResultBuilder::captureExpression() {
     AssertionResult result = build();
     handleResult( result );
 }
int main(int argc, char* argv[])
{
	if (argc != 4 && argc != 5) {
		printf("Wrong number of arguments.\n");
		return 1;
	}

	// seed RNG
	time_t seconds = time(NULL);
	srand(seconds);

	//debug
	num_dirty_meters = 0;
	num_clean_meters = 0;

	num_user_meters = atoi(argv[1]);
	num_inspector_meters = atoi(argv[2]);
	prob_dirty_meter = atof(argv[3]);
	prob_meter_flip = 0.0;

	if (argc == 5) {
		prob_meter_flip = atof(argv[4]);
	}

	init_simlib();

	maxatr = 4;

	init_model();

	int should_run = 1;
	while (should_run) {
		timing();

		switch (next_event_type) {
			case EVENT_BEGIN_INSPECTION:
				handleInspection();
				break;
			case EVENT_CLEAN_RESULT:
				handleResult(next_event_type);
				break;
			case EVENT_DIRTY_RESULT:
				handleResult(next_event_type);
				break;
			case EVENT_CLEAN_INSPECTOR:
				handleResult(next_event_type);
				break;
			case EVENT_DIRTY_INSPECTOR:
				handleResult(next_event_type);
				break;
			case EVENT_END_SIMULATION:
				should_run = 0;
				break;
			default:
				printf("Unrecognized Event Type\n");
				return 1;
		}
	}

	report();


	return 0;
}