Skip to content

Commit

Permalink
Fix size_t -> uint32_t compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sammycage committed Sep 14, 2024
1 parent d6b745e commit 396ba5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions source/svgparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ struct Rule {

class RuleData {
public:
RuleData(const Selector& selector, const DeclarationList& declarations, uint32_t specificity, uint32_t position)
RuleData(const Selector& selector, const DeclarationList& declarations, size_t specificity, size_t position)
: m_selector(selector), m_declarations(declarations), m_specificity(specificity), m_position(position)
{}

bool isLessThan(const RuleData& rule) const { return std::tie(m_specificity, m_position) < std::tie(rule.m_specificity, rule.m_position); }

const Selector& selector() const { return m_selector; }
const DeclarationList& declarations() const { return m_declarations; }
uint32_t specificity() const { return m_specificity; }
uint32_t position() const { return m_position; }
size_t specificity() const { return m_specificity; }
size_t position() const { return m_position; }

bool match(const SVGElement* element) const;

Expand All @@ -93,8 +93,8 @@ class RuleData {

Selector m_selector;
DeclarationList m_declarations;
uint32_t m_specificity;
uint32_t m_position;
size_t m_specificity;
size_t m_position;
};

inline bool operator<(const RuleData& a, const RuleData& b) { return a.isLessThan(b); }
Expand Down Expand Up @@ -303,7 +303,7 @@ class StyleSheet {
static bool parseSimpleSelector(std::string_view& input, SimpleSelector& simpleSelector);

RuleDataList m_rules;
uint32_t m_position{0};
size_t m_position{0};
};

bool StyleSheet::parseSheet(std::string_view input)
Expand Down Expand Up @@ -332,7 +332,7 @@ bool StyleSheet::parseSheet(std::string_view input)
if(!parseRule(input, rule))
return false;
for(const auto& selector : rule.selectors) {
uint32_t specificity = 0;
size_t specificity = 0;
for(const auto& simpleSelector : selector) {
specificity += (simpleSelector.id == ElementID::Star) ? 0x0 : 0x1;
for(const auto& attributeSelector : simpleSelector.attributeSelectors) {
Expand Down
14 changes: 7 additions & 7 deletions source/svgtextelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ struct SVGCharacterPosition {
std::optional<float> rotate;
};

using SVGCharacterPositions = std::map<uint32_t, SVGCharacterPosition>;
using SVGCharacterPositions = std::map<size_t, SVGCharacterPosition>;

struct SVGTextPosition {
SVGTextPosition(const SVGNode* node, uint32_t startOffset, uint32_t endOffset)
SVGTextPosition(const SVGNode* node, size_t startOffset, size_t endOffset)
: node(node), startOffset(startOffset), endOffset(endOffset)
{}

const SVGNode* node;
uint32_t startOffset;
uint32_t endOffset;
size_t startOffset;
size_t endOffset;
};

using SVGTextPositionList = std::vector<SVGTextPosition>;

struct SVGTextFragment {
explicit SVGTextFragment(const SVGTextPositioningElement* element) : element(element) {}
const SVGTextPositioningElement* element;
uint32_t offset = 0;
uint32_t length = 0;
size_t offset = 0;
size_t length = 0;
float x = 0;
float y = 0;
float angle = 0;
Expand All @@ -60,7 +60,7 @@ class SVGTextFragmentsBuilder {
SVGTextFragmentList& m_fragments;
SVGCharacterPositions m_characterPositions;
SVGTextPositionList m_textPositions;
uint32_t m_characterOffset = 0;
size_t m_characterOffset = 0;
float m_x = 0;
float m_y = 0;
};
Expand Down

0 comments on commit 396ba5e

Please sign in to comment.