Skip to content

Commit

Permalink
libcore: NumberValue constants and various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 4fe8da4 commit 1b7e3cc
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
6 changes: 3 additions & 3 deletions doomsday/libs/core/include/de/data/binarytree.h
Expand Up @@ -507,9 +507,9 @@ class BinaryTree
String text = String::format("%i nodes, %i leafs", nodeCount(), leafCount());
if (!isLeaf())
{
text += stringf(" (balance is %zu:%zu)",
hasRight() ? right().height() : 0,
hasLeft() ? left().height() : 0);
text += String::format(" (balance is %zu:%zu)",
hasRight() ? right().height() : 0,
hasLeft() ? left().height() : 0);
}
return text;
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/core/include/de/data/block.h
Expand Up @@ -99,7 +99,7 @@ class DE_PUBLIC Block
inline bool isEmpty() const { return size() == 0; }

Block &append(Byte b);
Block &append(const char *str, int len);
Block &append(const void *data, int len);
Block &prepend(const Block &);
void remove(size_t pos, size_t len = 1);
void removeAll(Byte b);
Expand Down
8 changes: 7 additions & 1 deletion doomsday/libs/core/include/de/data/numbervalue.h
Expand Up @@ -69,7 +69,7 @@ class DE_PUBLIC NumberValue : public Value
explicit NumberValue(unsigned long initialUnsignedInteger, SemanticHints semantic = UInt);
explicit NumberValue(bool initialBoolean);

void setSemanticHints(SemanticHints hints);
void setSemanticHints(SemanticHints hints);
SemanticHints semanticHints() const;

/**
Expand All @@ -95,6 +95,12 @@ class DE_PUBLIC NumberValue : public Value
void operator >> (Writer &to) const;
void operator << (Reader &from);

public:
static const NumberValue zero;
static const NumberValue one;
static const NumberValue bTrue;
static const NumberValue bFalse;

private:
Number _value;
SemanticHints _semantic;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libs/core/src/data/block.cpp
Expand Up @@ -142,9 +142,9 @@ Block &Block::append(Byte b)
return *this;
}

Block &Block::append(const char *str, int len)
Block &Block::append(const void *data, int len)
{
appendData_Block(&_block, str, len);
appendData_Block(&_block, data, len);
return *this;
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/libs/core/src/data/json.cpp
Expand Up @@ -88,8 +88,8 @@ class JSONParser
{
String::BytePos offset = pos.pos();
throw Error("JSONParser",
stringf("Error at position %u (%s^%s): %s",
offset,
stringf("Error at position %zu (%s^%s): %s",
offset.index,
source.substr(offset - 4, 4).c_str(),
source.substr(offset, 4).c_str(),
message.c_str()));
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libs/core/src/data/numbervalue.cpp
Expand Up @@ -26,6 +26,11 @@

namespace de {

const NumberValue NumberValue::zero(0.0);
const NumberValue NumberValue::one(1.0);
const NumberValue NumberValue::bTrue(true);
const NumberValue NumberValue::bFalse(false);

NumberValue::NumberValue(Number initialValue, SemanticHints semantic)
: _value(initialValue), _semantic(semantic)
{}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/core/src/data/writer.cpp
Expand Up @@ -186,7 +186,7 @@ Writer &Writer::operator << (const ddouble &value)

Writer &Writer::operator << (const String &text)
{
Block bytes = text.toUtf8();
Block bytes = text;

// First write the length of the text.
duint32 size = bytes.size();
Expand Down

0 comments on commit 1b7e3cc

Please sign in to comment.