static PyObject * ICUConverter_decode(ICUConverter *self, PyObject *args) { assert(self != NULL); const char *str; if (! PyArg_ParseTuple(args, "s", &str)) { return NULL; } if (self->pDecoder != NULL) { std::vector<MYWCHAR_T> vec; size_t strLength = strlen(str); self->pDecoder->decode(&vec, &str[0], &str[strLength]); std::string str = toUTF8String(vec); return PyString_FromStringAndSize(str.data(), str.length()); } // return None Py_INCREF(Py_None); return Py_None; }
void StateGraphViewerPanel::OnContextMenu(wxContextMenuEvent &Ev) { if (!MouseOver) return; UErrorCode Status = U_ZERO_ERROR; auto const TextTable = seec::getResource("TraceViewer", getLocale(), Status, "StateGraphViewer"); if (U_FAILURE(Status)) { wxLogDebug("Couldn't get StateGraphViewer resources."); return; } auto const TheNode = MouseOver.get(); if (auto const DV = llvm::dyn_cast<DisplayableValue>(TheNode)) { auto const ValuePtr = &(DV->getValue()); wxMenu CM{}; addValueNavigation(*this, CurrentAccess, CM, *ValuePtr, *CurrentProcess, Recording); // Allow the user to select the Value's layout engine. std::unique_lock<std::mutex> LockLayoutHandler(LayoutHandlerMutex); auto const Engines = LayoutHandler->listLayoutEnginesSupporting(*ValuePtr); LockLayoutHandler.unlock(); if (Engines.size() > 1) { auto SM = seec::makeUnique<wxMenu>(); for (auto const E : Engines) { auto const LazyName = E->getName(); if (!LazyName) continue; UErrorCode Status = U_ZERO_ERROR; auto const Name = LazyName->get(Status, getLocale()); if (U_FAILURE(Status)) continue; std::string UTF8Name; Name.toUTF8String(UTF8Name); auto const EngineID = reinterpret_cast<uintptr_t>(E); BindMenuItem( SM->Append(wxID_ANY, wxString{UTF8Name}), [=] (wxEvent &Ev) -> void { { std::lock_guard<std::mutex> LLH(this->LayoutHandlerMutex); this->LayoutHandler->setLayoutEngine(*ValuePtr, EngineID); } this->renderGraph(); }); } CM.AppendSubMenu(SM.release(), seec::getwxStringExOrEmpty(TextTable, "CMValueDisplayAs")); } PopupMenu(&CM); } else if (auto const DD = llvm::dyn_cast<DisplayableDereference>(TheNode)) { auto const ValOfPtr = &(DD->getPointer()); wxMenu CM{}; BindMenuItem( CM.Append(wxID_ANY, seec::getwxStringExOrEmpty(TextTable, "CMDereferenceUse")), [=] (wxEvent &Ev) -> void { { std::lock_guard<std::mutex> LLH(this->LayoutHandlerMutex); this->LayoutHandler->setAreaReference(*ValOfPtr); } this->renderGraph(); }); PopupMenu(&CM); } else if (auto const DF = llvm::dyn_cast<DisplayableFunctionState>(TheNode)) { wxMenu CM{}; auto const FnPtr = &(DF->getFunctionState()); BindMenuItem( CM.Append(wxID_ANY, seec::getwxStringExOrEmpty(TextTable, "CMFunctionRewindEntry")), [=] (wxEvent &Ev) -> void { raiseMovementEvent(*this, this->CurrentAccess, [=] (seec::cm::ProcessState &State) { return seec::cm::moveToFunctionEntry(*FnPtr); }); }); BindMenuItem( CM.Append(wxID_ANY, seec::getwxStringExOrEmpty(TextTable, "CMFunctionForwardExit")), [=] (wxEvent &Ev) -> void { raiseMovementEvent(*this, this->CurrentAccess, [=] (seec::cm::ProcessState &State) { return seec::cm::moveToFunctionFinished(*FnPtr); }); }); PopupMenu(&CM); } else if (auto const DA = llvm::dyn_cast<DisplayableReferencedArea>(TheNode)) { auto const Area = seec::MemoryArea(DA->getAreaStart(), DA->getAreaEnd()); auto const ValOfPtr = &(DA->getPointer()); wxMenu CM{}; // Allow the user to select the Area's layout engine. std::unique_lock<std::mutex> LLH(LayoutHandlerMutex); auto const Engines = LayoutHandler->listLayoutEnginesSupporting(Area, *ValOfPtr); LLH.unlock(); if (Engines.size() > 1) { auto SM = seec::makeUnique<wxMenu>(); for (auto const E : Engines) { auto const LazyName = E->getName(); if (!LazyName) continue; UErrorCode Status = U_ZERO_ERROR; auto const Name = LazyName->get(Status, getLocale()); if (U_FAILURE(Status)) continue; std::string UTF8Name; Name.toUTF8String(UTF8Name); auto const EngineID = reinterpret_cast<uintptr_t>(E); BindMenuItem( SM->Append(wxID_ANY, wxString{UTF8Name}), [=] (wxEvent &Ev) -> void { { std::lock_guard<std::mutex> LLH(this->LayoutHandlerMutex); this->LayoutHandler->setLayoutEngine(Area, *ValOfPtr, EngineID); } this->renderGraph(); }); } CM.AppendSubMenu(SM.release(), seec::getwxStringExOrEmpty(TextTable, "CMAreaDisplayAs")); } PopupMenu(&CM); } else { wxLogDebug("Unknown Displayable!"); } }
std:: string SYS2INNER(const std::string &systemString) { return toUTF8String(defaultDecoder.decode(systemString)); }