NumProc :: NumProc (weak_ptr<PDE> apde, const Flags & flags) : NGS_Object (shared_ptr<PDE> (apde)->GetMeshAccess(int(flags.GetNumFlag("mesh",1))-1), "numproc"), pde(apde) { if (flags.StringFlagDefined ("name")) SetName (flags.GetStringFlag ("name","")); }
bool isOn(Flags flags) const { if (flags.isOn(ModifierFlag::NONE)) { return (value_ | ModifierFlag::NONE.get()) == flags.get(); } else { return (value_ & flags.get()) == flags.get(); } }
void RocketServerFrameContext::sendPayload(Payload&& payload, Flags flags) { DCHECK(connection_); DCHECK(flags.next() || flags.complete()); auto buf = PayloadFrame(streamId_, std::move(payload), flags).serialize(); connection_->send(std::move(buf)); }
Flags& Flags::remove(ModifierFlag flag) { // We consider the following case. // (ModifierFlag::SHIFT_L | ModifierFlag::SHIFT_R).remove(ModifierFlag::SHIFT_L). // // The value of SHIFT_L and SHIFT_R is below. // // ModifierFlag::SHIFT_L : 0x20002 // ModifierFlag::SHIFT_R : 0x20004 // // So, the correct value of above case is 0x20004 (SHIFT_R). // // If we remove bits simple way (value_ &= ~flags), // the result value becomes 0x00004. It's not right. // // Therefore, we save the old value, and restore the necessary bits from it. // Flags old = *this; // keep ModifierFlag::NUMPAD. value_ &= ~(flag.getRawBits()); auto& pairs = KeyCodeModifierFlagPairs::getPairs(); for (size_t i = 0; i < pairs.size(); ++i) { ModifierFlag f = pairs[i].getModifierFlag(); if (f == flag) continue; if (!old.isOn(f)) continue; value_ |= f.getRawBits(); } return *this; }
/** WebItemCollection **/ WebItemCollection::WebItemCollection(const tj::shared::String& fn, const tj::shared::String& dn, const tj::shared::String& contentType): WebItemResource(fn,dn,contentType, 0) { Flags<WebItem::Permission> perms; perms.Set(WebItem::PermissionGet, true); perms.Set(WebItem::PermissionPropertyRead, true); SetPermissions(perms); }
// キーが押されて離された。 LRESULT OnWindowKeyUpMessage(HWND /*hWnd*/, UINT /*msg*/, WPARAM wParam, LPARAM lParam) { WindowKeyMessageParameters params(wParam, lParam); switch (params.GetVirtKey()) { case VK_F2: _flags = _flags.not(INVALID_MESH_DRAW); break; case VK_F3: _flags = _flags.not(INVALID_BONE_DRAW); break; case VK_F4: _motionTimer.Reset(); _motionTimer.Start(); break; case VK_F5: _pmd.SetMotionLoop(!_pmd.GetMotionLoop()); break; case VK_F6: if (_pmd.IsNoInterpolation()) { _pmd.SwitchToLinearInterpolation(); } else if (_pmd.IsLinearInterpolation()) { _pmd.SwitchToUseParameterInterpolation(); } else if (_pmd.IsUseParameterInterpolation()) { _pmd.SwitchToNoInterpolation(); } break; } return 0; }
void ListHookedKeyboard::setcapslock_timer_callback(OSObject* owner, IOTimerEventSource* sender) { ListHookedKeyboard& self = ListHookedKeyboard::instance(); if (Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_passthrough_capslock_led_status)) return; Flags flags = FlagStatus::globalFlagStatus().makeFlags(); for (Item* p = static_cast<Item*>(self.list_.safe_front()); p; p = static_cast<Item*>(p->getnext())) { if (!p->isReplaced()) continue; // Don't call setAlphaLock on devices which have non-Apple driver. if (p->getDeviceType() != DeviceType::APPLE_INTERNAL && p->getDeviceType() != DeviceType::APPLE_EXTERNAL) { continue; } IOHIKeyboard* kbd = OSDynamicCast(IOHIKeyboard, p->get()); if (!kbd) continue; { GlobalLock::ScopedUnlock lk; // We call setAlphaLock to match a state of CapsLock of the hardware with remapped CapsLock. if (flags.isOn(ModifierFlag::CAPSLOCK)) { if (!kbd->alphaLock()) { kbd->setAlphaLock(true); } } else { if (kbd->alphaLock()) { kbd->setAlphaLock(false); } } } } }
Error ProcessMachCore::GetMemoryRegionInfo(addr_t load_addr, MemoryRegionInfo ®ion_info) { region_info.Clear(); const VMRangeToPermissions::Entry *permission_entry = m_core_range_infos.FindEntryThatContainsOrFollows(load_addr); if (permission_entry) { if (permission_entry->Contains(load_addr)) { region_info.GetRange().SetRangeBase(permission_entry->GetRangeBase()); region_info.GetRange().SetRangeEnd(permission_entry->GetRangeEnd()); const Flags permissions(permission_entry->data); region_info.SetReadable(permissions.Test(ePermissionsReadable) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); region_info.SetWritable(permissions.Test(ePermissionsWritable) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); region_info.SetExecutable(permissions.Test(ePermissionsExecutable) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); } else if (load_addr < permission_entry->GetRangeBase()) { region_info.GetRange().SetRangeBase(load_addr); region_info.GetRange().SetRangeEnd(permission_entry->GetRangeBase()); region_info.SetReadable(MemoryRegionInfo::eNo); region_info.SetWritable(MemoryRegionInfo::eNo); region_info.SetExecutable(MemoryRegionInfo::eNo); } return Error(); } return Error("invalid address"); }
TEST(Flags, stripFN) { Flags mask = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R; Flags flags = mask; EXPECT_EQ(mask, flags.stripFN()); flags.add(ModifierFlag::FN); EXPECT_EQ(mask, flags.stripFN()); }
Flags FlagStatus::makeFlags(void) { Flags flags; for (int i = 0; item_[i].flag_ != ModifierFlag::NONE; ++i) { flags.add(item_[i].makeFlag()); } return flags; }
Flags FlagStatus::makeFlags(void) const { Flags flags; for (size_t i = 0; i < item_.size(); ++i) { if (item_[i].sum(false) > 0) { flags.add(item_[i].flag_); } } return flags; }
void KeyCode::reverseNormalizeKey(KeyCode& key, Flags& flags, EventType eventType, KeyboardType keyboardType) { if (! Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_disable_numpad_hack)) { for (unsigned int i = 0; i < sizeof(fnkeyhack) / sizeof(fnkeyhack[0]); ++i) { if (fnkeyhack[i].reverse(key, flags, eventType)) break; } } if (keyboardType == KeyboardType::POWERBOOK || keyboardType == KeyboardType::POWERBOOK_G4 || keyboardType == KeyboardType::POWERBOOK_G4_TI) { if (key == KeyCode::ENTER) { key = KeyCode::ENTER_POWERBOOK; } } // ------------------------------------------------------------ // Don't add ModifierFlag::FN automatically for F-keys, PageUp/PageDown/Home/End and Forward Delete. // // PageUp/PageDown/Home/End and Forward Delete are entered by fn+arrow, fn+delete normally, // And, from Cocoa Application, F-keys and PageUp,... keys have Fn modifier // even if Fn key is not pressed actually. // So, it's natural adding ModifierFlag::FN to these keys. // However, there is a reason we must not add ModifierFlag::FN to there keys. // // Mission Control may have "fn" as shortcut key. // If we add ModifierFlag::FN here, // "XXX to PageUp" launches Mission Control because Mission Control recognizes fn key was pressed. // // It's not intended behavior from users. // Therefore, we don't add ModifierFlag::FN for these keys. // ------------------------------------------------------------ // set ModifierFlag::KEYPAD, ModifierFlag::CURSOR flags.stripCURSOR().stripKEYPAD(); // Note: KEYPAD_CLEAR, KEYPAD_COMMA have no ModifierFlag::KEYPAD bit. if (key == KeyCode::KEYPAD_0 || key == KeyCode::KEYPAD_1 || key == KeyCode::KEYPAD_2 || key == KeyCode::KEYPAD_3 || key == KeyCode::KEYPAD_4 || key == KeyCode::KEYPAD_5 || key == KeyCode::KEYPAD_6 || key == KeyCode::KEYPAD_7 || key == KeyCode::KEYPAD_8 || key == KeyCode::KEYPAD_9 || key == KeyCode::KEYPAD_DOT || key == KeyCode::KEYPAD_MULTIPLY || key == KeyCode::KEYPAD_PLUS || key == KeyCode::KEYPAD_SLASH || key == KeyCode::KEYPAD_MINUS || key == KeyCode::KEYPAD_EQUAL) { flags.add(ModifierFlag::KEYPAD); } if (key == KeyCode::CURSOR_UP || key == KeyCode::CURSOR_DOWN || key == KeyCode::CURSOR_LEFT || key == KeyCode::CURSOR_RIGHT) { flags.add(ModifierFlag::CURSOR); } }
MyVTKOutput<D>::MyVTKOutput(const Array<shared_ptr<CoefficientFunction>> & a_coefs, const Flags & flags, shared_ptr<MeshAccess> ama) : MyVTKOutput(ama, a_coefs, flags.GetStringListFlag("fieldnames" ), flags.GetStringFlag("filename","output"), (int) flags.GetNumFlag("subdivision", 0), (int) flags.GetNumFlag("only_element", -1), flags.GetDefineFlag("nocache")) {;}
TEST(Flags, remove) { { Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R; Flags removed = ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R; EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_L)); } { Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::SHIFT_R | ModifierFlag::CURSOR | ModifierFlag::EXTRA2 | ModifierFlag::NONE; Flags removed = ModifierFlag::SHIFT_R | ModifierFlag::CURSOR | ModifierFlag::EXTRA2 | ModifierFlag::NONE; EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_L)); removed = ModifierFlag::SHIFT_R | ModifierFlag::NONE; EXPECT_EQ(removed, flags.remove(ModifierFlag::CURSOR | ModifierFlag::EXTRA2)); removed = 0; EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_R | ModifierFlag::NONE)); removed = 0; EXPECT_EQ(removed, flags.remove(ModifierFlag::OPTION_L | ModifierFlag::COMMAND_R)); } { // chain Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::SHIFT_R | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R; Flags removed = ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R; EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_L).remove(ModifierFlag::SHIFT_R)); } }
TEST(Flags, add) { Flags mask = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R; Flags flags = mask; EXPECT_EQ(mask, flags.stripFN()); flags.add(ModifierFlag::OPTION_L); EXPECT_EQ(mask | ModifierFlag::OPTION_L, flags); flags.add(ModifierFlag::NONE); EXPECT_EQ(mask | ModifierFlag::OPTION_L | ModifierFlag::NONE, flags); }
// 描画。 void Draw() { if (_flags.is(FRAME_SKIP) || _device.IsScreenOccluded()) { // noop } else { _renderer.Clear(true, true, false, Color::BLUE); D3DXMATRIX mWorld; { _pmd.SetMotion(_motionTimer.GetTime() * 1.0f); //D3DXMatrixIdentity(&mWorld); static float angle = 0.f; // angle += _frameRateController.GetElapsedTime() * 0.5f; D3DXMatrixRotationY(&mWorld, angle); _pmd.SetWorldMatrix(mWorld); if (!_flags.is(INVALID_MESH_DRAW)) _pmd.Draw(_renderer); if (!_flags.is(INVALID_BONE_DRAW)) _pmd.DrawBone(_renderer); } int y = 0, h = _device.GetFontHeight(_renderer.GetDefaultFont()); _renderer.DrawText(0, y, Color::GREEN, _T("FPS=%.2f (%.2fms)"), _frameRateController.GetCurrentFPS(), _frameRateController.GetElapsedTime() * 1000.f ); y += h; _renderer.DrawText(0, y, Color::WHITE, _T("Frame=%u / Time=%.2f"), _pmd.GetMotionKeyFrame(), _pmd.GetMotionTime()); y += h; _renderer.DrawText(0, y, Color::WHITE, _T("[F2] メッシュ描画=") TFMT_BOOL, format_bool(!_flags.is(INVALID_MESH_DRAW))); y += h; _renderer.DrawText(0, y, Color::WHITE, _T("[F3] ボーン描画=") TFMT_BOOL, format_bool(!_flags.is(INVALID_BONE_DRAW))); y += h; _renderer.DrawText(0, y, Color::WHITE, _T("[F4] モーションリスタート")); y += h; _renderer.DrawText(0, y, Color::WHITE, _T("[F5] モーションループ=") TFMT_BOOL, format_bool(_pmd.GetMotionLoop())); y += h; const TCHAR* pInterpolationMethod = _T("無し"); if (_pmd.IsLinearInterpolation()) pInterpolationMethod = _T("線形補間"); if (_pmd.IsUseParameterInterpolation()) pInterpolationMethod = _T("パラメータ使用(ベジェ曲線+線形補間)"); _renderer.DrawText(0, y, Color::WHITE, _T("[F6] モーション補間=%s"), pInterpolationMethod); y += h; } _renderer.Present(); }
NumProcLinearHyperbolic (shared_ptr<PDE> apde, const Flags & flags) : NumProc (apde), timer_element("convection - time element"), timer_facet("convection - time facet"), timer_mass("convection - time mass") { gfu = apde->GetGridFunction (flags.GetStringFlag ("gridfunction", "u")); cfflow = apde->GetCoefficientFunction (flags.GetStringFlag ("flow", "flow")); dt = flags.GetNumFlag ("dt", 0.001); tend = flags.GetNumFlag ("tend", 1); }
// キーが押されて離された。 LRESULT OnWindowKeyUpMessage(HWND /*hWnd*/, UINT /*msg*/, WPARAM wParam, LPARAM lParam) { WindowKeyMessageParameters params(wParam, lParam); if (params.GetVirtKey() == VK_F2) { _flags = _flags.not(INVALID_MESH_DRAW); } if (params.GetVirtKey() == VK_F3) { _flags = _flags.not(INVALID_BONE_DRAW); } return 0; }
TEST(Flags, isVirtualModifiersOn) { Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R; EXPECT_FALSE(flags.isVirtualModifiersOn()); flags = 0; EXPECT_FALSE(flags.isVirtualModifiersOn()); flags = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R | ModifierFlag::NONE; EXPECT_TRUE(flags.isVirtualModifiersOn()); flags = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R | ModifierFlag::EXTRA3; EXPECT_TRUE(flags.isVirtualModifiersOn()); }
void SplineGeometry::LoadData(std::istream& infile) { MESHIT_LOG_INFO("Load 2D Geometry"); Point2d x; char buf[50], ch; std::string keyword; std::string flag; int nb_domains = 0; TestComment(infile); // refinement factor infile >> elto0; while (infile.good()) { TestComment(infile); infile >> keyword; ch = TestComment(infile); if (keyword == "points") { std::vector<GeomPoint> points; std::vector<PointIndex> point_ids; size_t point_id; size_t nb_points = 0; while (!isalpha(static_cast<int>(ch))) { infile >> point_id; // point ids are 1-based if (point_id > nb_points) nb_points = point_id; point_ids.push_back(point_id); infile >> x.X() >> x.Y() >> ch; Flags flags; while (ch == '-') { infile >> flag; flags.SetCommandLineFlag(flag); ch = TestComment(infile); } infile.unget(); ch = TestComment(infile); points.push_back(GeomPoint(x, flags.GetNumFlag("ref", 1.0), flags.GetNumFlag("maxh", 1e99))); } geompoints.resize(nb_points); for (size_t i = 0; i < nb_points; i++) { geompoints[point_ids[i] - 1] = points[i]; } } else if (keyword == "segments") {
void KeyboardRepeat::set(EventType eventType, Flags flags, ConsumerKeyCode key) { if (! queue_) return; if (key == ConsumerKeyCode::VK_NONE) return; if (eventType == EventType::UP) { goto cancel; } else if (eventType == EventType::DOWN) { if (! key.isRepeatable()) { goto cancel; } cancel(); primitive_add(eventType, flags, key); primitive_start(Config::get_repeat_consumer_initial_wait(), Config::get_repeat_consumer_wait()); IOLOG_DEVEL("KeyboardRepeat::set consumer key:%d flags:0x%x\n", key.get(), flags.get()); } else { goto cancel; } return; cancel: cancel(); }
// 描画。 void Draw() { if (_flags.is(FRAME_SKIP) || _device.IsScreenOccluded()) { // noop } else { _renderer.Clear(true, true, false, Color::BLUE); DrawSprite(); DrawModel(); int y = 0, h = _device.GetFontHeight(_renderer.GetDefaultFont()); _renderer.DrawText(0, y, Color::WHITE, _T("Test")); y += h; _renderer.DrawText(0, y, Color::GREEN, _T("FPS=%.2f (%.2fms)"), _frameRateController.GetCurrentFPS(), _frameRateController.GetElapsedTime() * 1000.f ); y += h; } _renderer.Present(); }
void KeyboardRepeat::set(EventType eventType, Flags flags, ConsumerKeyCode key, int delayUntilRepeat, int keyRepeat) { if (key == ConsumerKeyCode::VK_NONE) return; if (eventType == EventType::UP) { goto cancel; } else if (eventType == EventType::DOWN) { if (!key.isRepeatable()) { goto cancel; } cancel(); primitive_add(eventType, flags, key); primitive_start(delayUntilRepeat, keyRepeat); IOLOG_DEVEL("KeyboardRepeat::set consumer key:%d flags:0x%x\n", key.get(), flags.get()); } else { goto cancel; } return; cancel: cancel(); }
ScopedTemporaryFlagsChanger(Flags toFlags) { count_ = new int[MAXNUM]; if (! count_) return; for (int i = 0;; ++i) { count_[i] = 0; ModifierFlag flag = getFlag(i); if (flag == ModifierFlag::NONE) break; // ---------------------------------------- // reset flag while (! makeFlags().isOn(flag)) { temporary_increase(flag); ++count_[i]; } while (makeFlags().isOn(flag)) { temporary_decrease(flag); --count_[i]; } // ---------------------------------------- // set a flag if (toFlags.isOn(flag)) { temporary_increase(flag); ++count_[i]; } } }
// ------------------------------------------------------------ bool EventType::isKeyDownOrModifierDown(KeyCode key, Flags flags) const { if (*this == EventType::DOWN) return true; if (*this == EventType::MODIFY) { return flags.isOn(key.getModifierFlag()); } return false; }
int main(int argc, char** argv) { GOOGLE_PROTOBUF_VERIFY_VERSION; Flags flags; Try<flags::Warnings> load = flags.load(None(), argc, argv); if (load.isError()) { cerr << flags.usage(load.error()) << endl; return EXIT_FAILURE; } if (flags.help) { cout << flags.usage() << endl; return EXIT_SUCCESS; } // Log any flag warnings. foreach (const flags::Warning& warning, load->warnings) { LOG(WARNING) << warning.message; } if (flags.pid.isNone()) { cerr << flags.usage("Missing required option --pid") << endl; return EXIT_FAILURE; } Try<ResourceStatistics> statistics = mesos::internal::usage(flags.pid.get()); if (statistics.isError()) { cerr << "Failed to get usage: " << statistics.error() << endl; return EXIT_FAILURE; } if (flags.recordio) { Try<Nothing> write = protobuf::write(STDOUT_FILENO, statistics.get()); if (write.isError()) { cerr << "Failed to write record: " << write.error() << endl; return EXIT_FAILURE; } } else { cout << stringify(JSON::protobuf(statistics.get())) << endl; } return EXIT_SUCCESS; }
void KeyCode::normalizeKey(KeyCode& key, Flags& flags, EventType eventType, KeyboardType keyboardType) { // We can drop NUMPAD flags, because we'll set these flags at reverseNormalizeKey. flags.stripNUMPAD(); for (unsigned int i = 0; i < sizeof(fnkeyhack) / sizeof(fnkeyhack[0]); ++i) { if (fnkeyhack[i].normalize(key, flags, eventType)) break; } }
// ====================================================================== void EventOutputQueue::FireKey::fire(const Params_KeyboardEventCallBack& params) { if (VirtualKey::handle(params)) return; // ---------------------------------------- if (params.key == KeyCode::VK_MODIFIER_EXTRA1 || params.key == KeyCode::VK_MODIFIER_EXTRA2 || params.key == KeyCode::VK_MODIFIER_EXTRA3 || params.key == KeyCode::VK_MODIFIER_EXTRA4 || params.key == KeyCode::VK_MODIFIER_EXTRA5) return; // ------------------------------------------------------------ KeyCode newkeycode = params.key; Flags newflags = params.flags; KeyCode::reverseNormalizeKey(newkeycode, newflags, params.eventType, params.keyboardType); newflags.stripEXTRA(); // skip no-outputable keycodes. // Note: check before FireModifiers to avoid meaningless modifier event. if (newkeycode == KeyCode::VK_NONE || newkeycode == KeyCode::VK_PSEUDO_KEY) { return; } FireModifiers::fire(newflags, params.keyboardType); if (params.eventType == EventType::DOWN || params.eventType == EventType::UP) { Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(params.eventType, newflags, newkeycode, params.charCode, params.charSet, params.origCharCode, params.origCharSet, params.keyboardType, params.repeat)); if (ptr) { EventOutputQueue::push(*ptr); } if (! params.repeat) { if (params.eventType == EventType::DOWN) { PressDownKeys::add(newkeycode, params.keyboardType); } else { PressDownKeys::remove(newkeycode, params.keyboardType); } } } }
void Log::WriteMessage(const std::string &message) { // Make a copy of our stream shared pointer in case someone disables our log // while we are logging and releases the stream auto stream_sp = GetStream(); if (!stream_sp) return; Flags options = GetOptions(); if (options.Test(LLDB_LOG_OPTION_THREADSAFE)) { static std::recursive_mutex g_LogThreadedMutex; std::lock_guard<std::recursive_mutex> guard(g_LogThreadedMutex); *stream_sp << message; stream_sp->flush(); } else { *stream_sp << message; stream_sp->flush(); } }
FlagStatus::FlagStatus(Flags flags) { initialize(); for (size_t i = 0; i < item_.size(); ++i) { if (flags.isOn(item_[i].flag_)) { item_[i].increase(); } } }