Exemplo n.º 1
0
bool rs::jsapi::Object::Set(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) {
    JSAutoRequest ar(cx);
    auto state = Object::GetState(cx, obj);
    if (state != nullptr && state->setter != nullptr) {
        Value value(cx, vp);
        
        char nameBuffer[256];
        auto name = JSID_TO_STRING(id);                
        auto nameLength = JS_EncodeStringToBuffer(cx, name, nameBuffer, sizeof(nameBuffer) - 1);
        
        try {
            if (nameLength < sizeof(nameBuffer)) {
                nameBuffer[nameLength] = '\0';    
                state->setter(nameBuffer, value);    
            } else {
                std::vector<char> nameVector(nameLength + 1);
                nameLength = JS_EncodeStringToBuffer(cx, name, &nameVector[0], nameVector.size() - 1);
                nameVector[nameLength] = '\0';
                state->setter(&nameVector[0], value);
            }

            return true;
        } catch (const std::exception& ex) {
            JS_ReportError(cx, ex.what());
            return false;
        }
    } else {
        // TODO: what will this do to the JS?
        vp.setUndefined();
        return true;
    }
}
Exemplo n.º 2
0
MeshesTab::MeshesTab(QWidget *parent) : QWidget(parent) {
    warnDisabledPickingCheck.setChecked(true);
    warnDisabledPickingCheck.setToolTip(tr("Mesh picking is disabled if your graphics driver does not at least support OpenGL 3.0."));
    visibilityGroupLayout.addWidget(&meshInOrthoVPsCheck);
    visibilityGroupLayout.addWidget(&meshIn3DVPCheck);
    visibilityGroup.setLayout(&visibilityGroupLayout);

    static auto opacityControls = [this/* required for GCC8*/](auto & label, auto & slider, auto & spin, auto & layout, auto setter){
        slider.setRange(0, 100);
        slider.setOrientation(Qt::Horizontal);
        spin.setRange(0, 1);
        spin.setSingleStep(0.01);
        spin.setPrefix("×");
        layout.addWidget(&label);
        layout.addWidget(&slider);
        layout.addWidget(&spin);
        QObject::connect(&spin, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [&slider, setter](const double value) {
            {
                QSignalBlocker blocker{slider};
                slider.setValue(value * 100);
            }
            setter(value);
        });
        QObject::connect(&slider, static_cast<void(QSlider::*)(int)>(&QSlider::valueChanged), [&spin, setter](const int value) {
            {
                QSignalBlocker blocker{spin};
                spin.setValue(value/100.);
            }
            setter(spin.value());
        });
    };
    opacityControls(alphaLabel3d, alphaSlider3d, alphaSpin3d, alphaLayout, [](auto val){state->viewer->setMesh3dAlphaFactor(val);});
    opacityControls(alphaLabelSlicing, alphaSliderSlicing, alphaSpinSlicing, alphaLayout, [](auto val){state->viewer->setMeshSlicingAlphaFactor(val);});

    mainLayout.addWidget(&visibilityGroup);
    for (auto * sep : {&separator1, &separator2}) {
        sep->setFrameShape(QFrame::HLine);
        sep->setFrameShadow(QFrame::Sunken);
    }
    mainLayout.addWidget(&separator1);
    mainLayout.addLayout(&alphaLayout);
    mainLayout.addWidget(&separator2);
    mainLayout.addWidget(&warnDisabledPickingCheck);
    mainLayout.setAlignment(Qt::AlignTop);
    setLayout(&mainLayout);
    QObject::connect(&meshInOrthoVPsCheck, &QCheckBox::clicked, [](const bool checked) { state->viewerState->meshDisplay.setFlag(TreeDisplay::ShowInOrthoVPs, checked); });
    QObject::connect(&meshIn3DVPCheck, &QCheckBox::clicked, [](const bool checked) { state->viewerState->meshDisplay.setFlag(TreeDisplay::ShowIn3DVP, checked); });
    QObject::connect(state->viewer, &Viewer::mesh3dAlphaFactorChanged, &alphaSpin3d, &QDoubleSpinBox::setValue);
    QObject::connect(state->viewer, &Viewer::meshSlicingAlphaFactorChanged, &alphaSpinSlicing, &QDoubleSpinBox::setValue);
}
Exemplo n.º 3
0
static int KSI_CTX_setUri(KSI_CTX *ctx,
		const char *uri, const char *loginId, const char *key,
		int (*setter)(KSI_NetworkClient*, const char*, const char *, const char *)){
	int res = KSI_UNKNOWN_ERROR;

	KSI_ERR_clearErrors(ctx);
	if (ctx == NULL || uri == NULL) {
		KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
		goto cleanup;
	}

	if (ctx->isCustomNetProvider){
		KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, "Unable to set url after initial network provider replacement.");
		goto cleanup;
	}

	res = setter(ctx->netProvider, uri, loginId, key);
	if (res != KSI_OK) {
		KSI_pushError(ctx,res, NULL);
		goto cleanup;
	}

	res = KSI_OK;

cleanup:

	return res;
}
Exemplo n.º 4
0
void brute_nearest(DistanceCallback& dcb, const node<P>* query,
		v_array<d_node<P> > zero_set, ScalarType* upper_bound,
		v_array<v_array<P> > &results,
		v_array<v_array<d_node<P> > > &spare_zero_sets)
{
	if (query->num_children > 0)
	{
		v_array<d_node<P> > new_zero_set = pop(spare_zero_sets);
		node<P> * query_chi = query->children;
		brute_nearest(dcb, query_chi, zero_set, upper_bound, results, spare_zero_sets);
		ScalarType* new_upper_bound = alloc_upper();

		node<P> *child_end = query->children + query->num_children;
		for (query_chi++;query_chi != child_end; query_chi++)
		{
			setter(new_upper_bound,*upper_bound + query_chi->parent_dist);
			copy_zero_set(dcb, query_chi, new_upper_bound, zero_set, new_zero_set);
			brute_nearest(dcb, query_chi, new_zero_set, new_upper_bound, results, spare_zero_sets);
		}
		free (new_upper_bound);
		new_zero_set.index = 0;
		push(spare_zero_sets, new_zero_set);
	}
	else
	{
		v_array<P> temp;
		push(temp, query->p);
		d_node<P> *end = zero_set.elements + zero_set.index;
		for (d_node<P> *ele = zero_set.elements; ele != end ; ele++)
			if (ele->dist <= *upper_bound)
				push(temp, ele->n->p);
		push(results,temp);
	}
}
Exemplo n.º 5
0
nsresult
PeerConnectionMedia::UpdateMediaPipelines()
{
  // The GMP code is all the way on the other side of webrtc.org, and it is not
  // feasible to plumb error information all the way back. So, we set up a
  // handle to the PC (for the duration of this call) in a global variable.
  // This allows the GMP code to report errors to the PC.
  WebrtcGmpPCHandleSetter setter(mParentHandle);

  for (RefPtr<TransceiverImpl>& transceiver : mTransceivers) {
    nsresult rv = transceiver->UpdateConduit();
    if (NS_FAILED(rv)) {
      return rv;
    }

    if (!transceiver->IsVideo()) {
      rv = transceiver->SyncWithMatchingVideoConduits(mTransceivers);
      if (NS_FAILED(rv)) {
        return rv;
      }
      // TODO: If there is no audio, we should probably de-sync. However, this
      // has never been done before, and it is unclear whether it is safe...
    }
  }

  return NS_OK;
}
Exemplo n.º 6
0
void raw_match(Expr ptree, Expr arg, Env* env, Expr*(*setter)(Symbol,Env*)) {
	switch(ptree.type) {
	case IGNORE:
		break;
		
	case SYMBOL:
		*setter(ptree.sym, env) = arg;
		break;
	
	case NIL:
		if(arg.type != NIL)
			error(L"Unmatched nil in parameter tree");
		break;
	
	case PAIR:
		if(arg.type != PAIR)
			error(L"Unmatched pair in parameter tree");
		raw_match(ptree.pair[0], arg.pair[0], env, setter);
		raw_match(ptree.pair[1], arg.pair[1], env, setter);
		break;
	
	default:
		error(L"Unexpected type in parameter tree");
		break;
	}
}
Exemplo n.º 7
0
void StringPropertyHandler::setValue(QString value)
{
    if (QMetaObject::invokeMethod(_target, setter().constData(), QGenericArgument("QString", &value)))
    {
        _changed = true;
    }
}
Exemplo n.º 8
0
static int lqtL_newindexfunc (lua_State *L) {
    if (!lua_isuserdata(L, 1) && lua_islightuserdata(L, 1)) return 0;
    lua_getmetatable(L, 1);
    lua_pushliteral(L, "__set");
    lua_rawget(L, -2);
    if (lua_istable(L, -1)) {
        lua_pushvalue(L, 2);
        lua_gettable(L, -2);
        if (lua_isfunction(L, -1)) {
            lua_CFunction setter = lua_tocfunction(L, -1);
            if (!setter) return luaL_error(L, "Invalid setter %s", lua_tostring(L, 2));
            return setter(L);
        }
    }
    lua_settop(L, 3); // (=3)
    lua_getfenv(L, 1); // (+1)
    if (!lua_istable(L, -1)) {
        lua_pop(L, 1); // (+0)
        return 0;
    }
    lua_remove(L, 1); // (+0)
    lua_insert(L, 1); // (+0)
    lua_rawset(L, 1); // (-2)
    return 0;
}
Exemplo n.º 9
0
size_t TSimpleLemmer::CopyFromMystem(MystemAnalysesHandle* analyses, const Wtroka& src, TWLemmaArray& out) {
    size_t count = GET_FUNC(Lib, MystemAnalysesCount)(analyses);

    out.clear();
    out.resize(count);

    for (size_t i = 0; i != count; ++i) {
         MystemLemmaHandle* lemma = GET_FUNC(Lib, MystemLemma)(analyses, i);
         NLemmerAux::TSimpleLemmaSetter setter(out[i]);
         setter.SetLemma(GET_FUNC(Lib, MystemLemmaText)(lemma),
                         GET_FUNC(Lib, MystemLemmaTextLen)(lemma),
                         GET_FUNC(Lib, MystemLemmaForm)(lemma),
                         GET_FUNC(Lib, MystemLemmaFormLen)(lemma),
                         GET_FUNC(Lib, MystemLemmaStemGram)(lemma),
                         GET_FUNC(Lib, MystemLemmaFlexGram)(lemma),
                         GET_FUNC(Lib, MystemLemmaFlexGramNum)(lemma),
                         GET_FUNC(Lib, MystemLemmaFlexLen)(lemma),
                         GET_FUNC(Lib, MystemLemmaRuleId)(lemma),
                         GET_FUNC(Lib, MystemLemmaQuality)(lemma),
                         src);
    }

    DeleteAnalyses(analyses);
    return count;
}
Exemplo n.º 10
0
static int KSI_CTX_setTimeoutSeconds(KSI_CTX *ctx, int timeout, int (*setter)(KSI_NetworkClient*, int)){
	int res = KSI_UNKNOWN_ERROR;
	KSI_NetworkClient *client = NULL;

	KSI_ERR_clearErrors(ctx);
	if (ctx == NULL || ctx->netProvider == NULL) {
		KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
		goto cleanup;
	}

	if (ctx->isCustomNetProvider){
		KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, "Unable to set timeout after initial network provider replacement.");
		goto cleanup;
	}

	client = ctx->netProvider;

	res = setter(client, timeout);
	if (res != KSI_OK) {
		KSI_pushError(ctx,res, NULL);
		goto cleanup;
	}

	res = KSI_OK;

cleanup:

	return res;
}
Exemplo n.º 11
0
void getAndSetIf(bool conditionalValue, Function&& setter, Keys&&... keys) {
    auto current = get<DataType, Traits>(keys...);
    if (current == conditionalValue) {
        current = not conditionalValue;
        setter();
        set<DataType, Traits>(current, std::forward<Keys>(keys)...);
    }
}
Exemplo n.º 12
0
 void setCouponPricer(
               const Leg& leg,
               const boost::shared_ptr<FloatingRateCouponPricer>& pricer) {
     PricerSetter setter(pricer);
     for (Size i=0; i<leg.size(); ++i) {
         leg[i]->accept(setter);
     }
 }
Exemplo n.º 13
0
static int
set_ttymode(int fd, conmode *t, void (*setter)(conmode *, void *), void *arg)
{
    conmode r;
    if (!getattr(fd, t)) return 0;
    r = *t;
    setter(&r, arg);
    return setattr(fd, &r);
}
void playsingle_controller::linger()
{
	LOG_NG << "beginning end-of-scenario linger\n";
	browse_ = true;
	linger_ = true;

	// If we need to set the status depending on the completion state
	// the key to it is here.
	gui_->set_game_mode(game_display::LINGER_SP);

	// this is actually for after linger mode is over -- we don't
	// want to stay stuck in linger state when the *next* scenario
	// is over.
	set_completion setter(gamestate_,"running");

	// change the end-turn button text to its alternate label
	gui_->get_theme().refresh_title2("button-endturn", "title2");
	gui_->invalidate_theme();
	gui_->redraw_everything();

	// End all unit moves
	for (unit_map::iterator u = units_.begin(); u != units_.end(); ++u) {
		u->set_user_end_turn(true);
	}

	start_pass_scenario_anim(get_end_level_data().result);

	try {
		// Same logic as single-player human turn, but
		// *not* the same as multiplayer human turn.
		gui_->enable_menu("endturn", true);
		while(!end_turn_) {
			// Reset the team number to make sure we're the right team.
			player_number_ = first_player_;
			play_slice();
			gui_->draw();
		}
	} catch(game::load_game_exception& lge) {
		// Loading a new game is effectively a quit.
		if (lge.game != "") {
			gamestate_ = game_state();
		}
		throw lge;
	}

	if (gui_->pass_scenario_anim_id() != -1) {
		gui_->erase_screen_anim(gui_->pass_scenario_anim_id());
	}

	// revert the end-turn button text to its normal label
	gui_->get_theme().refresh_title2("button-endturn", "title");
	gui_->invalidate_theme();
	gui_->redraw_everything();
	gui_->set_game_mode(game_display::RUNNING);

	LOG_NG << "ending end-of-scenario linger\n";
}
Exemplo n.º 15
0
  void addTag(const char *tag, const QString& value) {
    GstTagSetter *s = setter();
    if (!s) {
      return;
    }

    gst_tag_setter_add_tags(s, GST_TAG_MERGE_REPLACE, tag, value.toUtf8().data(), NULL);

    gst_object_unref(s);
  }
Exemplo n.º 16
0
  void addTag(const char *tag, GstDateTime *value) {
    GstTagSetter *s = setter();
    if (!s) {
      return;
    }

    gst_tag_setter_add_tags(s, GST_TAG_MERGE_REPLACE, tag, value, NULL);

    gst_object_unref(s);
  }
Exemplo n.º 17
0
void playsingle_controller::linger()
{
	mouse_handler_.do_right_click(false);

	browse_ = true;
	linger_ = true;

	// If we need to set the status depending on the completion state
	// the key to it is here.
	gui_->set_game_mode(game_display::LINGER_SP);

	// this is actually for after linger mode is over -- we don't
	// want to stay stuck in linger state when the *next* scenario
	// is over.
	set_completion setter(gamestate_,"running");

	// change the end-turn button text to its alternate label
	gui_->redraw_everything();

	// button be reconstruct.
	if (lobby->chat.ready()) {
		refresh_chat_button(*gui_, "misc/network-disconnected.png");
	}

	start_pass_scenario_anim(get_end_level_data().result);

	try {
		// Same logic as single-player human turn, but
		// *not* the same as multiplayer human turn.
		gui_->set_theme_object_active("endturn", true);
		while(!end_turn_) {
			// Reset the team number to make sure we're the right team.
			player_number_ = first_player_;
			play_slice();
			gui_->draw();
		}
	} catch(game::load_game_exception& lge) {
		// Loading a new game is effectively a quit.
		if (lge.game != "") {
			gamestate_ = game_state();
		}
		throw lge;
	}

	if (gui_->pass_scenario_anim_id() != -1) {
		gui_->erase_area_anim(gui_->pass_scenario_anim_id());
	}

	// revert the end-turn button text to its normal label
	gui_->redraw_everything();
	gui_->set_game_mode(game_display::RUNNING);

	LOG_NG << "ending end-of-scenario linger\n";
}
void FunctionKeyframeNavigator::toggle() {
  if (!m_curve) return;
  int frame    = getCurrentFrame();
  double value = m_curve->getValue(frame);
  if (m_curve->isKeyframe(frame))
    KeyframeSetter::removeKeyframeAt(m_curve.getPointer(), frame);
  else {
    KeyframeSetter setter(m_curve.getPointer());
    setter.createKeyframe(frame);
  }
}
Exemplo n.º 19
0
static void set_random(Tox *m, bool (*setter)(Tox *, const uint8_t *, size_t, TOX_ERR_SET_INFO *), size_t length)
{
    VLA(uint8_t, text, length);
    uint32_t i;

    for (i = 0; i < length; ++i) {
        text[i] = rand();
    }

    setter(m, text, SIZEOF_VLA(text), 0);
}
Exemplo n.º 20
0
static void set_random(Tox *m, bool (*setter)(Tox *, const uint8_t *, size_t, Tox_Err_Set_Info *), size_t length)
{
    VLA(uint8_t, text, length);
    uint32_t i;

    for (i = 0; i < length; ++i) {
        text[i] = random_u08();
    }

    setter(m, text, SIZEOF_VLA(text), nullptr);
}
Exemplo n.º 21
0
GetterSetter* GetterSetter::withGetter(VM& vm, JSGlobalObject* globalObject, JSObject* newGetter)
{
    if (isGetterNull()) {
        setGetter(vm, globalObject, newGetter);
        return this;
    }
    
    GetterSetter* result = GetterSetter::create(vm, globalObject);
    result->setGetter(vm, globalObject, newGetter);
    result->setSetter(vm, globalObject, setter());
    return result;
}
Exemplo n.º 22
0
void CModelViewRender::LoadModel()
{
    ASSERT(GetDocument() != NULL);
    CString strPath = GetDocument()->GetPathName();
    LPCTSTR szPath = strPath;
    TCHAR extStr[_MAX_EXT];
    TCHAR fileName[_MAX_FNAME];
    _tsplitpath(szPath, NULL, NULL, fileName, extStr);

    if (strPath.IsEmpty())
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel shouldn't have been called with NULL path\n"), __FILE__, __LINE__);
        return;
    }

    StdString szFilename = fileName;
    szFilename += extStr;
    m_hszModelName = szFilename;

    CFileVersionSetter setter( _T("2.5") );

    if (0 == _tcsicmp(extStr, _T(".cfg")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath, _T("Filepath"));
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("Cal3DRenderObject"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            FillAnimationList();
            pArchive->Close();
        }
    }
    else if (0 == _tcsicmp(extStr, _T(".hrc")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath);
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("CHierarchicalModel"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            pArchive->Close();
        }
    }
    else
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel was passed %s extension, which is not recognized\n"), __FILE__, __LINE__, extStr);
    }
}
void LLOcclusionCullingGroup::setOcclusionState(eOcclusionState state, S32 mode) 
{
	if (mode > STATE_MODE_SINGLE)
	{
		if (mode == STATE_MODE_DIFF)
		{
			LLSpatialSetOcclusionStateDiff setter(state);
			setter.traverse(mOctreeNode);
		}
		else if (mode == STATE_MODE_BRANCH)
		{
			LLSpatialSetOcclusionState setter(state);
			setter.traverse(mOctreeNode);
		}
		else
		{
			for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
			{
				mOcclusionState[i] |= state;

				if ((state & DISCARD_QUERY) && mOcclusionQuery[i])
				{
					releaseOcclusionQueryObjectName(mOcclusionQuery[i]);
					mOcclusionQuery[i] = 0;
				}
			}
		}
	}
	else
	{
		mOcclusionState[LLViewerCamera::sCurCameraID] |= state;
		if ((state & DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID])
		{
			releaseOcclusionQueryObjectName(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
			mOcclusionQuery[LLViewerCamera::sCurCameraID] = 0;
		}
	}
}
Exemplo n.º 24
0
void internal_batch_nearest_neighbor(DistanceCallback& dcb, const node<P> *query,
		v_array<v_array<d_node<P> > > &cover_sets,
		v_array<d_node<P> > &zero_set,
		int current_scale,
		int max_scale,
		ScalarType* upper_bound,
		v_array<v_array<P> > &results,
		v_array<v_array<v_array<d_node<P> > > > &spare_cover_sets,
		v_array<v_array<d_node<P> > > &spare_zero_sets)
{
	if (current_scale > max_scale) // All remaining points are in the zero set.
		brute_nearest(dcb, query, zero_set, upper_bound, results, spare_zero_sets);
	else
		if (query->scale <= current_scale && query->scale != 100)
			// Our query has too much scale.  Reduce.
		{
			node<P> *query_chi = query->children;
			v_array<d_node<P> > new_zero_set = pop(spare_zero_sets);
			v_array<v_array<d_node<P> > > new_cover_sets = get_cover_sets(spare_cover_sets);
			ScalarType* new_upper_bound = alloc_upper();

			node<P> *child_end = query->children + query->num_children;
			for (query_chi++; query_chi != child_end; query_chi++)
			{
				setter(new_upper_bound,*upper_bound + query_chi->parent_dist);
				copy_zero_set(dcb, query_chi, new_upper_bound, zero_set, new_zero_set);
				copy_cover_sets(dcb, query_chi, new_upper_bound, cover_sets, new_cover_sets,
						current_scale, max_scale);
				internal_batch_nearest_neighbor(dcb, query_chi, new_cover_sets, new_zero_set,
						current_scale, max_scale, new_upper_bound,
						results, spare_cover_sets, spare_zero_sets);
			}
			free (new_upper_bound);
			new_zero_set.index = 0;
			push(spare_zero_sets, new_zero_set);
			push(spare_cover_sets, new_cover_sets);
			internal_batch_nearest_neighbor(dcb, query->children, cover_sets, zero_set,
					current_scale, max_scale, upper_bound, results,
					spare_cover_sets, spare_zero_sets);
		}
		else // reduce cover set scale
		{
			halfsort(cover_sets[current_scale]);
			descend(dcb, query, upper_bound, current_scale, max_scale,cover_sets, zero_set);
			cover_sets[current_scale++].index = 0;
			internal_batch_nearest_neighbor(dcb, query, cover_sets, zero_set,
					current_scale, max_scale, upper_bound, results,
					spare_cover_sets, spare_zero_sets);
		}
}
Exemplo n.º 25
0
//---------------------------------------------------------------------------
CPinyinInputMethod::CPinyinInputMethod()
{
    HanziModel.clear();
    QDateTime dt = QDateTime::currentDateTime();
    QSettings setter(":/pinyin/pinyinEx.ini", QSettings::IniFormat);

    key = setter.value("pyKey", key).toStringList();
    val = setter.value("pyVal", val).toStringList();
    if (key.size() <= 1)
    {
        QMessageBox::warning( 0, tr("pinyin"), tr("Can't load!") );
        return;
    }
}
Exemplo n.º 26
0
void playsingle_controller::linger()
{
    LOG_NG << "beginning end-of-scenario linger\n";
    browse_ = true;
    linger_ = true;

    // If we need to set the status depending on the completion state
    // the key to it is here.
    gui_->set_game_mode(game_display::LINGER_SP);

    // this is actually for after linger mode is over -- we don't
    // want to stay stuck in linger state when the *next* scenario
    // is over.
    set_completion setter(saved_game_,"running");

    // change the end-turn button text to its alternate label
    gui_->get_theme().refresh_title2("button-endturn", "title2");
    gui_->invalidate_theme();
    gui_->redraw_everything();

    // End all unit moves
    gamestate_.board_.set_all_units_user_end_turn();
    try {
        // Same logic as single-player human turn, but
        // *not* the same as multiplayer human turn.
        end_turn_enable(true);
        end_turn_ = false;
        while(!end_turn_) {
            // Reset the team number to make sure we're the right team.
            player_number_ = first_player_;
            play_slice();
            gui_->draw();
        }
    } catch(const game::load_game_exception &) {
        // Loading a new game is effectively a quit.
        if ( game::load_game_exception::game != "" ) {
            saved_game_ = saved_game();
        }
        throw;
    }

    // revert the end-turn button text to its normal label
    gui_->get_theme().refresh_title2("button-endturn", "title");
    gui_->invalidate_theme();
    gui_->redraw_everything();
    gui_->set_game_mode(game_display::RUNNING);

    LOG_NG << "ending end-of-scenario linger\n";
}
Exemplo n.º 27
0
int main()
{
    setter();
    saver();
    clearer();
    start_counter();
    loader();
    stop_counter();
    dumper();
    clearer();
    start_counter();
    loader_mem();
    stop_counter();
    dumper();
}
Exemplo n.º 28
0
pdb_class *try_to_find_from_rt(ea_t ea, char **name, bool *free_name)
{
  pdb_class *res = NULL;
  if ( !ea || ea == BADADDR )
   return NULL;
  // check for ref to const parent CRunTime class from DLL
  ea_t rt = check_for_cruntimeclass2(ea);
  if ( rt )
  {
    res = try_find_by_name(rt, name, free_name, false);
    if ( res )
     return res;
  }
  // check for ref to base CRunTime class
  rt = check_for_cruntimeclass(ea);
  if ( rt )
  {
    res = try_find_by_name(rt, name, free_name);
    if ( res )
     return res;
  }
  size_t len;
  // check for name from static CRunTime class
  if ( !rt )
  {
    len = check_for_RTStruct(ea);
    rt = ea;
  }
  else
   len = check_for_RTStruct(rt);
  if ( len )
  {
    *name = (char *)qalloc(len + 1);
    get_many_bytes(get_long(rt), *name, len);
    (*name)[len] = 0;
    setter(*name, rt, 0, true);
    res = p_pool->find_class(*name);
    if ( res )
    {
     *free_name = true;
     return res;
    }
    qfree(*name);
    // lets check all hierarchy
    res = try_to_find_from_rt(get_long(rt + 0x10), name, free_name);
  }
  return res;
}
Exemplo n.º 29
0
//------------------------------------------------------------------------
// GetBoundingMetrics
//
//------------------------------------------------------------------------
nsresult 
nsATSUIToolkit::GetBoundingMetrics(
  const PRUnichar *aCharPt, 
  PRUint32 aLen, 
  nsBoundingMetrics &oBoundingMetrics,
  short aSize, short aFontNum,
  PRBool aBold, PRBool aItalic, 
  nscolor aColor)
{
  if(!nsATSUIUtils::IsAvailable())
    return NS_ERROR_NOT_INITIALIZED;

  StPortSetter setter(mPort);

  ATSUTextLayout aTxtLayout;
  StartDraw(aCharPt, aLen, aSize, aFontNum, aBold, aItalic, aColor, aTxtLayout);
  if(nsnull == aTxtLayout)
    return NS_ERROR_FAILURE;

  OSStatus err = noErr;
  Rect rect;
  ATSUTextMeasurement width;

  if((err = ATSUMeasureTextImage(aTxtLayout, 
    kATSUFromTextBeginning, kATSUToTextEnd, 0, 0, &rect)) != noErr)
  {
    NS_WARNING("ATSUMeasureTextImage failed");
    return NS_ERROR_FAILURE;
  }

  // return the values in points, the caller will convert them into twips
  oBoundingMetrics.leftBearing = rect.left;
  oBoundingMetrics.rightBearing = rect.right;
  oBoundingMetrics.ascent = -rect.top;
  oBoundingMetrics.descent = rect.bottom;

  err = ::ATSUGetUnjustifiedBounds(aTxtLayout, kATSUFromTextBeginning,
                                   kATSUToTextEnd, NULL, &width, NULL, NULL);
  if (err != noErr)
  {
    oBoundingMetrics.width = oBoundingMetrics.rightBearing;
  }
  else
    oBoundingMetrics.width = FixRound(width);

  return NS_OK;
}
Exemplo n.º 30
0
    void setCouponPricers(
            const Leg& leg,
            const std::vector<boost::shared_ptr<FloatingRateCouponPricer> >&
                                                                    pricers) {
        Size nCashFlows = leg.size();
        QL_REQUIRE(nCashFlows>0, "no cashflows");

        Size nPricers = pricers.size();
        QL_REQUIRE(nCashFlows >= nPricers,
                   "mismatch between leg size (" << nCashFlows <<
                   ") and number of pricers (" << nPricers << ")");

        for (Size i=0; i<nCashFlows; ++i) {
            PricerSetter setter(i<nPricers ? pricers[i] : pricers[nPricers-1]);
            leg[i]->accept(setter);
        }
    }