Skip to content

Commit

Permalink
Merge branch 'elfmz:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-soft committed Jul 16, 2024
2 parents ead8d89 + dd585b2 commit 58e9728
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 146 deletions.
4 changes: 4 additions & 0 deletions WinPort/src/Backend/WX/wxClipboardBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ void wxClipboardBackend::OnClipboardClose()
} else {
fprintf(stderr, "CloseClipboard without data\n");
}

#if !defined(__WXGTK__)
// it never did what supposed to, and under Ubuntu 22.04/Wayland it started to kill gnome-shell
wxTheClipboard->Flush();
#endif
/*
#if defined(__WXGTK__) && defined(__WXGTK3__) && !wxCHECK_VERSION(3, 1, 4)
typedef void *(*gtk_clipboard_get_t)(uintptr_t);
Expand Down
1 change: 1 addition & 0 deletions colorer/src/Colorer-library/src/colorer/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#else
#include "colorer/strings/legacy/strings.h"
#endif
#include "colorer/strings/XMLChLiteral.h"

/*
Logging
Expand Down
172 changes: 86 additions & 86 deletions colorer/src/Colorer-library/src/colorer/base/XmlTagDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
</catalog>
*/

const XMLCh catTagCatalog[] = u"catalog\0";
const XMLCh catTagHrcSets[] = u"hrc-sets\0";
const XMLCh catTagLocation[] = u"location\0";
const XMLCh catLocationAttrLink[] = u"link\0";
const XMLCh catTagHrdSets[] = u"hrd-sets\0";
const XMLCh catTagHrd[] = u"hrd\0";
const XMLCh catHrdAttrClass[] = u"class\0";
const XMLCh catHrdAttrName[] = u"name\0";
const XMLCh catHrdAttrDescription[] = u"description\0";
XMLCH_LITERAL(catTagCatalog, u"catalog\0");
XMLCH_LITERAL(catTagHrcSets, u"hrc-sets\0");
XMLCH_LITERAL(catTagLocation, u"location\0");
XMLCH_LITERAL(catLocationAttrLink, u"link\0");
XMLCH_LITERAL(catTagHrdSets, u"hrd-sets\0");
XMLCH_LITERAL(catTagHrd, u"hrd\0");
XMLCH_LITERAL(catHrdAttrClass, u"class\0");
XMLCH_LITERAL(catHrdAttrName, u"name\0");
XMLCH_LITERAL(catHrdAttrDescription, u"description\0");

/* hrc file
Expand Down Expand Up @@ -63,93 +63,93 @@ const XMLCh catHrdAttrDescription[] = u"description\0";
</hrc>
*/

const XMLCh hrcTagHrc[] = u"hrc\0";
const XMLCh hrcHrcAttrVersion[] = u"version\0";
const XMLCh hrcTagAnnotation[] = u"annotation\0";
const XMLCh hrcTagPrototype[] = u"prototype\0";
const XMLCh hrcPrototypeAttrName[] = u"name\0";
const XMLCh hrcPrototypeAttrDescription[] = u"description\0";
const XMLCh hrcPrototypeAttrGroup[] = u"group\0";
const XMLCh hrcTagLocation[] = u"location\0";
const XMLCh hrcLocationAttrLink[] = u"link\0";
const XMLCh hrcTagFilename[] = u"filename\0";
const XMLCh hrcFilenameAttrWeight[] = u"weight\0";
const XMLCh hrcTagFirstline[] = u"firstline\0";
const XMLCh hrcFirstlineAttrWeight[] = u"weight\0";
const XMLCh hrcTagParametrs[] = u"parameters\0";
const XMLCh hrcTagParam[] = u"param\0";
const XMLCh hrcParamAttrName[] = u"name\0";
const XMLCh hrcParamAttrValue[] = u"value\0";
const XMLCh hrcParamAttrDescription[] = u"description\0";
const XMLCh hrcTagPackage[] = u"package\0";
const XMLCh hrcPackageAttrName[] = u"name\0";
const XMLCh hrcPackageAttrDescription[] = u"description\0";
const XMLCh hrcPackageAttrGroup[] = u"group\0";
const XMLCh hrcTagType[] = u"type\0";
const XMLCh hrcTypeAttrName[] = u"name\0";
const XMLCh hrcTagImport[] = u"import\0";
const XMLCh hrcImportAttrType[] = u"type\0";
const XMLCh hrcTagRegion[] = u"region\0";
const XMLCh hrcRegionAttrName[] = u"name\0";
const XMLCh hrcRegionAttrParent[] = u"parent\0";
const XMLCh hrcRegionAttrDescription[] = u"description\0";
const XMLCh hrcTagEntity[] = u"entity\0";
const XMLCh hrcEntityAttrName[] = u"name\0";
const XMLCh hrcEntityAttrValue[] = u"value\0";
const XMLCh hrcTagScheme[] = u"scheme\0";
const XMLCh hrcSchemeAttrName[] = u"name\0";
const XMLCh hrcSchemeAttrIf[] = u"if\0";
const XMLCh hrcSchemeAttrUnless[] = u"unless\0";
const XMLCh hrcTagKeywords[] = u"keywords\0";
const XMLCh hrcKeywordsAttrIgnorecase[] = u"ignorecase\0";
const XMLCh hrcKeywordsAttrPriority[] = u"priority\0";
const XMLCh hrcKeywordsAttrWorddiv[] = u"worddiv\0";
const XMLCh hrcKeywordsAttrRegion[] = u"region\0";
const XMLCh hrcTagWord[] = u"word\0";
const XMLCh hrcWordAttrName[] = u"name\0";
const XMLCh hrcWordAttrRegion[] = u"region\0";
const XMLCh hrcTagSymb[] = u"symb\0";
const XMLCh hrcSymbAttrName[] = u"name\0";
const XMLCh hrcSymbAttrRegion[] = u"region\0";
const XMLCh hrcTagRegexp[] = u"regexp\0";
const XMLCh hrcRegexpAttrMatch[] = u"match\0";
const XMLCh hrcRegexpAttrPriority[] = u"priority\0";
const XMLCh hrcRegexpAttrRegion[] = u"region\0";
const XMLCh hrcTagBlock[] = u"block\0";
const XMLCh hrcBlockAttrStart[] = u"start\0";
const XMLCh hrcBlockAttrEnd[] = u"end\0";
const XMLCh hrcBlockAttrScheme[] = u"scheme\0";
const XMLCh hrcBlockAttrPriority[] = u"priority\0";
const XMLCh hrcBlockAttrContentPriority[] = u"content-priority\0";
const XMLCh hrcBlockAttrInnerRegion[] = u"inner-region\0";
const XMLCh hrcBlockAttrMatch[] = u"match\0";
const XMLCh hrcTagInherit[] = u"inherit\0";
const XMLCh hrcInheritAttrScheme[] = u"scheme\0";
const XMLCh hrcTagVirtual[] = u"virtual\0";
const XMLCh hrcVirtualAttrScheme[] = u"scheme\0";
const XMLCh hrcVirtualAttrSubstScheme[] = u"subst-scheme\0";
XMLCH_LITERAL(hrcTagHrc, u"hrc\0");
XMLCH_LITERAL(hrcHrcAttrVersion, u"version\0");
XMLCH_LITERAL(hrcTagAnnotation, u"annotation\0");
XMLCH_LITERAL(hrcTagPrototype, u"prototype\0");
XMLCH_LITERAL(hrcPrototypeAttrName, u"name\0");
XMLCH_LITERAL(hrcPrototypeAttrDescription, u"description\0");
XMLCH_LITERAL(hrcPrototypeAttrGroup, u"group\0");
XMLCH_LITERAL(hrcTagLocation, u"location\0");
XMLCH_LITERAL(hrcLocationAttrLink, u"link\0");
XMLCH_LITERAL(hrcTagFilename, u"filename\0");
XMLCH_LITERAL(hrcFilenameAttrWeight, u"weight\0");
XMLCH_LITERAL(hrcTagFirstline, u"firstline\0");
XMLCH_LITERAL(hrcFirstlineAttrWeight, u"weight\0");
XMLCH_LITERAL(hrcTagParametrs, u"parameters\0");
XMLCH_LITERAL(hrcTagParam, u"param\0");
XMLCH_LITERAL(hrcParamAttrName, u"name\0");
XMLCH_LITERAL(hrcParamAttrValue, u"value\0");
XMLCH_LITERAL(hrcParamAttrDescription, u"description\0");
XMLCH_LITERAL(hrcTagPackage, u"package\0");
XMLCH_LITERAL(hrcPackageAttrName, u"name\0");
XMLCH_LITERAL(hrcPackageAttrDescription, u"description\0");
XMLCH_LITERAL(hrcPackageAttrGroup, u"group\0");
XMLCH_LITERAL(hrcTagType, u"type\0");
XMLCH_LITERAL(hrcTypeAttrName, u"name\0");
XMLCH_LITERAL(hrcTagImport, u"import\0");
XMLCH_LITERAL(hrcImportAttrType, u"type\0");
XMLCH_LITERAL(hrcTagRegion, u"region\0");
XMLCH_LITERAL(hrcRegionAttrName, u"name\0");
XMLCH_LITERAL(hrcRegionAttrParent, u"parent\0");
XMLCH_LITERAL(hrcRegionAttrDescription, u"description\0");
XMLCH_LITERAL(hrcTagEntity, u"entity\0");
XMLCH_LITERAL(hrcEntityAttrName, u"name\0");
XMLCH_LITERAL(hrcEntityAttrValue, u"value\0");
XMLCH_LITERAL(hrcTagScheme, u"scheme\0");
XMLCH_LITERAL(hrcSchemeAttrName, u"name\0");
XMLCH_LITERAL(hrcSchemeAttrIf, u"if\0");
XMLCH_LITERAL(hrcSchemeAttrUnless, u"unless\0");
XMLCH_LITERAL(hrcTagKeywords, u"keywords\0");
XMLCH_LITERAL(hrcKeywordsAttrIgnorecase, u"ignorecase\0");
XMLCH_LITERAL(hrcKeywordsAttrPriority, u"priority\0");
XMLCH_LITERAL(hrcKeywordsAttrWorddiv, u"worddiv\0");
XMLCH_LITERAL(hrcKeywordsAttrRegion, u"region\0");
XMLCH_LITERAL(hrcTagWord, u"word\0");
XMLCH_LITERAL(hrcWordAttrName, u"name\0");
XMLCH_LITERAL(hrcWordAttrRegion, u"region\0");
XMLCH_LITERAL(hrcTagSymb, u"symb\0");
XMLCH_LITERAL(hrcSymbAttrName, u"name\0");
XMLCH_LITERAL(hrcSymbAttrRegion, u"region\0");
XMLCH_LITERAL(hrcTagRegexp, u"regexp\0");
XMLCH_LITERAL(hrcRegexpAttrMatch, u"match\0");
XMLCH_LITERAL(hrcRegexpAttrPriority, u"priority\0");
XMLCH_LITERAL(hrcRegexpAttrRegion, u"region\0");
XMLCH_LITERAL(hrcTagBlock, u"block\0");
XMLCH_LITERAL(hrcBlockAttrStart, u"start\0");
XMLCH_LITERAL(hrcBlockAttrEnd, u"end\0");
XMLCH_LITERAL(hrcBlockAttrScheme, u"scheme\0");
XMLCH_LITERAL(hrcBlockAttrPriority, u"priority\0");
XMLCH_LITERAL(hrcBlockAttrContentPriority, u"content-priority\0");
XMLCH_LITERAL(hrcBlockAttrInnerRegion, u"inner-region\0");
XMLCH_LITERAL(hrcBlockAttrMatch, u"match\0");
XMLCH_LITERAL(hrcTagInherit, u"inherit\0");
XMLCH_LITERAL(hrcInheritAttrScheme, u"scheme\0");
XMLCH_LITERAL(hrcTagVirtual, u"virtual\0");
XMLCH_LITERAL(hrcVirtualAttrScheme, u"scheme\0");
XMLCH_LITERAL(hrcVirtualAttrSubstScheme, u"subst-scheme\0");

/* hrd file
<hrd>
<assign name="" fore="" back="" style=""/>
<assign name="" stext="" etext="" sback="" eback=""/>
</hrc>
*/
const XMLCh hrdTagHrd[] = u"hrd\0";
const XMLCh hrdTagAssign[] = u"assign\0";
const XMLCh hrdAssignAttrName[] = u"name\0";
const XMLCh hrdAssignAttrFore[] = u"fore\0";
const XMLCh hrdAssignAttrBack[] = u"back\0";
const XMLCh hrdAssignAttrStyle[] = u"style\0";
const XMLCh hrdAssignAttrSBack[] = u"sback\0";
const XMLCh hrdAssignAttrEBack[] = u"eback\0";
const XMLCh hrdAssignAttrSText[] = u"stext\0";
const XMLCh hrdAssignAttrEText[] = u"etext\0";
XMLCH_LITERAL(hrdTagHrd, u"hrd\0");
XMLCH_LITERAL(hrdTagAssign, u"assign\0");
XMLCH_LITERAL(hrdAssignAttrName, u"name\0");
XMLCH_LITERAL(hrdAssignAttrFore, u"fore\0");
XMLCH_LITERAL(hrdAssignAttrBack, u"back\0");
XMLCH_LITERAL(hrdAssignAttrStyle, u"style\0");
XMLCH_LITERAL(hrdAssignAttrSBack, u"sback\0");
XMLCH_LITERAL(hrdAssignAttrEBack, u"eback\0");
XMLCH_LITERAL(hrdAssignAttrSText, u"stext\0");
XMLCH_LITERAL(hrdAssignAttrEText, u"etext\0");

/*
* attributes value
*/
const XMLCh value_low[] = u"low\0";
const XMLCh value_yes[] = u"yes\0";
XMLCH_LITERAL(value_low, u"low\0");
XMLCH_LITERAL(value_yes, u"yes\0");

#endif // COLORER_XMLTAGDEFS_H
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,13 @@ void StyledHRDMapper::setRegionDefine(const UnicodeString& name, const RegionDef
return;

const StyledRegion* new_region = StyledRegion::cast(rd);
RegionDefine* rd_new = new StyledRegion(*new_region);
auto rd_new = std::make_unique<StyledRegion>(*new_region);

auto rd_old_it = regionDefines.find(name);
if (rd_old_it == regionDefines.end()) {
std::pair<UnicodeString, RegionDefine*> pp(name, rd_new);
regionDefines.emplace(pp);
regionDefines.emplace(name, std::move(rd_new));
}
else {
rd_old_it->second.reset(rd_new);
rd_old_it->second = std::move(rd_new);
}
}
20 changes: 10 additions & 10 deletions colorer/src/Colorer-library/src/colorer/parsers/FileTypeImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ std::vector<UnicodeString> FileType::Impl::enumParams() const
const UnicodeString* FileType::Impl::getParamDescription(const UnicodeString& param_name) const
{
auto tp = paramsHash.find(param_name);
if (tp != paramsHash.end() && tp->second.description.has_value()) {
return &tp->second.description.value();
if (tp != paramsHash.end() && tp->second.description) {
return tp->second.description.get();
}
return nullptr;
}
Expand All @@ -63,8 +63,8 @@ const UnicodeString* FileType::Impl::getParamValue(const UnicodeString& param_na
{
auto tp = paramsHash.find(param_name);
if (tp != paramsHash.end()) {
if (tp->second.user_value && tp->second.user_value.has_value()) {
return &tp->second.user_value.value();
if (tp->second.user_value && tp->second.user_value) {
return tp->second.user_value.get();
}
return &tp->second.value;
}
Expand Down Expand Up @@ -99,24 +99,24 @@ const UnicodeString* FileType::Impl::getParamDefaultValue(const UnicodeString& p
const UnicodeString* FileType::Impl::getParamUserValue(const UnicodeString& param_name) const
{
auto tp = paramsHash.find(param_name);
if (tp != paramsHash.end() && tp->second.user_value.has_value()) {
return &tp->second.user_value.value();
if (tp != paramsHash.end() && tp->second.user_value) {
return tp->second.user_value.get();
}
return nullptr;
}

TypeParameter& FileType::Impl::addParam(const UnicodeString& param_name, const UnicodeString& value)
{
auto [it, status] = paramsHash.emplace(param_name, TypeParameter(param_name, value));
return it->second;
auto it = paramsHash.emplace(param_name, TypeParameter(param_name, value));
return it.first->second;
}

void FileType::Impl::setParamValue(const UnicodeString& param_name, const UnicodeString* value)
{
auto tp = paramsHash.find(param_name);
if (tp != paramsHash.end()) {
if (value) {
tp->second.user_value.emplace(*value);
tp->second.user_value.reset(new UnicodeString(*value));
}
else {
tp->second.user_value.reset();
Expand Down Expand Up @@ -156,7 +156,7 @@ void FileType::Impl::setParamDescription(const UnicodeString& param_name,
{
auto tp = paramsHash.find(param_name);
if (tp != paramsHash.end()) {
tp->second.description.emplace(*t_description);
tp->second.description.reset(new UnicodeString(*t_description));
}
else {
throw FileTypeException("Don`t set value " + *t_description +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef COLORER_FILETYPEIMPL_H
#define COLORER_FILETYPEIMPL_H

#include <optional>
#include <unordered_map>
#include <vector>
#include "colorer/FileType.h"
Expand All @@ -19,11 +18,11 @@ class TypeParameter
/* parameter name*/
UnicodeString name;
/* parameter description*/
std::optional<UnicodeString> description;
std::unique_ptr<UnicodeString> description;
/* default value*/
UnicodeString value;
/* user value*/
std::optional<UnicodeString> user_value;
std::unique_ptr<UnicodeString> user_value;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ void HrcLibrary::Impl::addPrototypeDetectParam(const xercesc::DOMElement* elem,
auto weight = elem->getAttribute(hrcFilenameAttrWeight);
if (!UStr::isEmpty(weight)) {
try {
auto w = xercesc::XMLDouble(weight);
xercesc::XMLDouble w(weight);
if (w.getValue() < 0) {
logger->warn(
"Weight must be greater than 0. Current value {0}. Default value will be used. Current "
Expand Down Expand Up @@ -401,7 +401,7 @@ void HrcLibrary::Impl::addPrototypeParameters(const xercesc::DOMNode* elem,
auto& tp =
current_parse_prototype->pimpl->addParam(UnicodeString(name), UnicodeString(value));
if (!UStr::isEmpty(descr)) {
tp.description.emplace(descr);
tp.description.reset(new UnicodeString(descr));
}
}
else {
Expand Down Expand Up @@ -816,7 +816,7 @@ const XMLCh* HrcLibrary::Impl::getElementText(const xercesc::DOMElement* blkel)

void HrcLibrary::Impl::parseSchemeKeywords(SchemeImpl* scheme, const xercesc::DOMElement* elem)
{
XMLCh rg_tmpl[] = u"region\0";
XMLCH_ARRAY(rg_tmpl, u"region\0");
const Region* region = getNCRegion(elem, rg_tmpl);
if (region == nullptr) {
logger->error(
Expand Down Expand Up @@ -938,7 +938,7 @@ size_t HrcLibrary::Impl::getSchemeKeywordsCount(const xercesc::DOMNode* elem)

void HrcLibrary::Impl::loadRegions(SchemeNodeRegexp* node, const xercesc::DOMElement* el)
{
XMLCh rg_tmpl[] = u"region\0\0";
XMLCH_ARRAY(rg_tmpl, u"region\0\0");

if (el) {
if (node->region == nullptr) {
Expand All @@ -959,7 +959,7 @@ void HrcLibrary::Impl::loadRegions(SchemeNodeRegexp* node, const xercesc::DOMEle
void HrcLibrary::Impl::loadRegions(SchemeNodeBlock* node, const xercesc::DOMElement* el,
bool start_element)
{
XMLCh rg_tmpl[] = u"region\0\0";
XMLCH_ARRAY(rg_tmpl, u"region\0\0");

if (el) {
if (node->region == nullptr) {
Expand Down Expand Up @@ -992,7 +992,7 @@ void HrcLibrary::Impl::loadBlockRegions(SchemeNodeBlock* node, const xercesc::DO
{
// regions as attributes in main block element

XMLCh rg_tmpl[] = u"region\0\0\0";
XMLCH_ARRAY(rg_tmpl, u"region\0\0\0");

node->region = getNCRegion(el, rg_tmpl);
for (int i = 0; i < REGIONS_NUM; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SchemeNode
{
public:
enum class SchemeNodeType { SNT_RE, SNT_BLOCK, SNT_KEYWORDS, SNT_INHERIT };
static constexpr std::string_view schemeNodeTypeNames[] = {"RE", "BLOCK", "KEYWORDS", "INHERIT"};
static constexpr const char *schemeNodeTypeNames[] = {"RE", "BLOCK", "KEYWORDS", "INHERIT"};

SchemeNodeType type;

Expand Down
16 changes: 16 additions & 0 deletions colorer/src/Colorer-library/src/colorer/strings/XMLChLiteral.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef COLORER_XMLCHLITERAL_H
#define COLORER_XMLCHLITERAL_H

// crutch for a case when Xerces has XMLCh be alias for uint16_t instead of char16_t

static_assert(sizeof(char16_t) == sizeof(XMLCh), "XMLCh must be 16-bit type");

struct XMLChLiteral
{
const char16_t *value;
inline operator const XMLCh *() const { return (const XMLCh *)value; }
};

# define XMLCH_LITERAL(name, value) constexpr const XMLChLiteral name{value};
# define XMLCH_ARRAY(name, value) XMLCh name[sizeof(value) / sizeof(char16_t)]; memcpy(name, value, sizeof(name));
#endif // COLORER_XMLCHLITERAL_H
Loading

0 comments on commit 58e9728

Please sign in to comment.