Skip to content

Commit

Permalink
libcore: Fixed all compile errors in libcore; linking still fails
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent e685465 commit 5b3fca7
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 55 deletions.
6 changes: 3 additions & 3 deletions doomsday/libs/core/include/de/data/path.h
Expand Up @@ -76,15 +76,15 @@ class DE_PUBLIC Path : public ISerializable, public LogEntry::Arg::Base
/**
* Segments are implicitly converted to text strings.
*/
operator CString() const;
inline operator CString() const { return range; }

/**
* Converts the segment to a string.
*/
// String toString() const;

Rangecc toRange() const { return range; }
String toString() const { return String(range); }
inline Rangecc toRange() const { return range; }
inline String toString() const { return String(range); }

/**
* Determines the length of the segment in characters.
Expand Down
2 changes: 2 additions & 0 deletions doomsday/libs/core/src/data/path.cpp
Expand Up @@ -231,6 +231,8 @@ DE_PIMPL_NOREF(Path)
}
};

const String Path::Impl::emptyPath;

Path::Path() : d(new Impl)
{}

Expand Down
5 changes: 5 additions & 0 deletions doomsday/libs/core/src/data/string.cpp
Expand Up @@ -164,6 +164,11 @@ CString String::toCString() const
return {begin(), end()};
}

void String::clear()
{
clear_String(&_str);
}

bool String::contains(char c) const
{
for (const char *i = constBegin_String(&_str), *end = constEnd_String(&_str); i != end; ++i)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libs/core/src/net/address.cpp
Expand Up @@ -79,7 +79,7 @@ Address Address::take(iAddress *addr)
// d->port = port;
//}

Address::Address(Address const &other) : LogEntry::Arg::Base(), d(new Impl)
Address::Address(const Address &other) : LogEntry::Arg::Base(), d(new Impl)
{
d->addr.reset(copy_Address(other.d->addr));
d->port = other.d->port;
Expand Down
12 changes: 10 additions & 2 deletions doomsday/libs/core/src/net/beacon.cpp
Expand Up @@ -42,12 +42,13 @@ DE_PIMPL_NOREF(Beacon)
{
duint16 port;
duint16 servicePort;
QUdpSocket *socket;
// QUdpSocket *socket;
Block message;
QTimer *timer;
// QTimer *timer;
Time discoveryEndsAt;
Map<Address, Block> found;

#if 0
Impl() : socket(0), timer(0)
{}

Expand All @@ -56,6 +57,7 @@ DE_PIMPL_NOREF(Beacon)
delete socket;
delete timer;
}
#endif
};

Beacon::Beacon(duint16 port) : d(new Impl)
Expand All @@ -70,6 +72,7 @@ duint16 Beacon::port() const

void Beacon::start(duint16 serviceListenPort)
{
#if 0
DE_ASSERT(!d->socket);

d->servicePort = serviceListenPort;
Expand All @@ -88,6 +91,7 @@ void Beacon::start(duint16 serviceListenPort)

/// @throws PortError Could not open the UDP port.
throw PortError("Beacon::start", "Could not bind to UDP port " + String::asText(d->port));
#endif
}

void Beacon::setMessage(IByteArray const &advertisedMessage)
Expand All @@ -104,12 +108,15 @@ void Beacon::setMessage(IByteArray const &advertisedMessage)

void Beacon::stop()
{
#if 0
delete d->socket;
d->socket = 0;
#endif
}

void Beacon::discover(TimeSpan timeOut, TimeSpan interval)
{
#if 0
if (d->timer) return; // Already discovering.

DE_ASSERT(!d->socket);
Expand Down Expand Up @@ -149,6 +156,7 @@ void Beacon::discover(TimeSpan timeOut, TimeSpan interval)
d->timer->start(interval.asMilliSeconds());

continueDiscovery();
#endif
}

List<Address> Beacon::foundHosts() const
Expand Down
4 changes: 4 additions & 0 deletions doomsday/libs/core/src/net/listensocket.cpp
Expand Up @@ -51,8 +51,12 @@ DE_PIMPL(ListenSocket)
i->incomingConnection(d->self());
}
}

DE_PIMPL_AUDIENCE(Incoming)
};

DE_AUDIENCE_METHOD(ListenSocket, Incoming)

ListenSocket::ListenSocket(duint16 port) : d(new Impl(this))
{
LOG_AS("ListenSocket");
Expand Down
10 changes: 10 additions & 0 deletions doomsday/libs/core/src/net/socket.cpp
Expand Up @@ -515,8 +515,18 @@ DE_PIMPL_NOREF(Socket)
i->allSent(self);
}
}

DE_PIMPL_AUDIENCE(StateChange)
DE_PIMPL_AUDIENCE(Message)
DE_PIMPL_AUDIENCE(AllSent)
DE_PIMPL_AUDIENCE(Error)
};

DE_AUDIENCE_METHOD(Socket, StateChange)
DE_AUDIENCE_METHOD(Socket, Message)
DE_AUDIENCE_METHOD(Socket, AllSent)
DE_AUDIENCE_METHOD(Socket, Error)

Socket::Socket() : d(new Impl)
{
// initialize();
Expand Down
43 changes: 21 additions & 22 deletions doomsday/libs/core/src/scriptsys/scriptedinfo.cpp
Expand Up @@ -42,7 +42,7 @@ static const char *BLOCK_SCRIPT = ScriptedInfo::SCRIPT;
static const char *KEY_SCRIPT = ScriptedInfo::SCRIPT;
static const char *KEY_INHERITS = "inherits";
static const char *KEY_CONDITION = "condition";
static const char *VAR_SCRIPT = "__script%1__";
static const char *VAR_SCRIPT = "__script%02d__";

DE_PIMPL(ScriptedInfo)
{
Expand All @@ -58,11 +58,10 @@ DE_PIMPL(ScriptedInfo)
, process(globalNamespace)
{
// No limitation on duplicates for the special block types.
info.setAllowDuplicateBlocksOfType(
QStringList() << BLOCK_GROUP << BLOCK_NAMESPACE);
info.setAllowDuplicateBlocksOfType({BLOCK_GROUP, BLOCK_NAMESPACE});

// Blocks whose contents are parsed as scripts.
info.setScriptBlocks(QStringList() << BLOCK_SCRIPT);
info.setScriptBlocks({BLOCK_SCRIPT});

// Single-token blocks are implicitly treated as "group" blocks.
info.setImplicitBlockType(BLOCK_GROUP);
Expand Down Expand Up @@ -152,7 +151,7 @@ DE_PIMPL(ScriptedInfo)
if (!ns.has(targetName))
{
// Assume it's an identifier rather than a regular variable.
targetName = checkNamespaceForVariable(target.text.toLower());
targetName = checkNamespaceForVariable(target.text.lower());
}
if (!ns.has(targetName))
{
Expand Down Expand Up @@ -247,7 +246,7 @@ DE_PIMPL(ScriptedInfo)
int counter = 0;
for (;;)
{
String name = VAR_SCRIPT.arg(counter, 2 /*width*/, 10 /*base*/, QLatin1Char('0'));
String name = String::format(VAR_SCRIPT, counter);
if (!where.has(name)) return name;
counter++;
}
Expand All @@ -260,8 +259,8 @@ DE_PIMPL(ScriptedInfo)
if (Info::Element *condition = block.find(KEY_CONDITION))
{
// Any block will be ignored if its condition is false.
std::unique_ptr<Value> result(evaluate(condition->values().first(), 0));
if (result.isNull() || result->isFalse())
std::unique_ptr<Value> result(evaluate(condition->values().first(), nullptr));
if (!result || result->isFalse())
{
return;
}
Expand Down Expand Up @@ -357,8 +356,9 @@ DE_PIMPL(ScriptedInfo)
// These are not processed as regular subelements because the
// path of the script record is not directly determined by the parent
// blocks (see above; chooseScriptName()).
for (auto const *elem : block.contents().values())
for (const auto &i : block.contents())
{
auto *elem = i.second;
if (elem->isKey())
{
auto const &key = elem->as<Info::KeyElement>();
Expand All @@ -375,7 +375,7 @@ DE_PIMPL(ScriptedInfo)
// script block).
if (!isScriptBlock)
{
foreach (Info::Element const *sub, block.contentsInOrder())
for (const auto *sub : block.contentsInOrder())
{
// Handle special elements.
if (sub->name() == KEY_CONDITION || sub->name() == KEY_INHERITS)
Expand Down Expand Up @@ -403,7 +403,7 @@ DE_PIMPL(ScriptedInfo)
String variableName(Info::Element const &element)
{
String varName = element.name();
for (Info::BlockElement *b = element.parent(); b != 0; b = b->parent())
for (Info::BlockElement *b = element.parent(); b != nullptr; b = b->parent())
{
if (b->blockType() == BLOCK_NAMESPACE) continue;

Expand Down Expand Up @@ -489,32 +489,30 @@ DE_PIMPL(ScriptedInfo)
void processKey(Info::KeyElement const &key)
{
std::unique_ptr<Value> v(makeValue(key.value(), key.parent()));
process.globals().add(variableName(key)) = v.take();
process.globals().add(variableName(key)) = v.release();
}

void processList(Info::ListElement const &list)
{
ArrayValue* av = new ArrayValue;
foreach (InfoValue const &v, list.values())
for (const InfoValue &v : list.values())
{
*av << makeValue(v, list.parent());
}
process.globals().addArray(variableName(list), av);
}

static void findBlocks(String const &blockType, Paths &paths, Record const &rec, String prefix = "")
static void findBlocks(String const &blockType, Paths &paths, Record const &rec, const String& prefix = {})
{
if (rec.hasMember(VAR_BLOCK_TYPE) &&
!rec[VAR_BLOCK_TYPE].value().asText().compareWithoutCase(blockType))
{
// Block type matches.
paths.insert(prefix);
}

Record::Subrecords const subs = rec.subrecords();
DE_FOR_EACH_CONST(Record::Subrecords, i, subs)
for (const auto &i : rec.subrecords())
{
findBlocks(blockType, paths, *i.value(), prefix.concatenateMember(i.key()));
findBlocks(blockType, paths, *i.second, prefix.concatenateMember(i.first));
}
}

Expand Down Expand Up @@ -548,7 +546,7 @@ void ScriptedInfo::parse(File const &file)

Value *ScriptedInfo::evaluate(String const &source)
{
return d->evaluate(source, 0);
return d->evaluate(source, nullptr);
}

Record &ScriptedInfo::objectNamespace()
Expand Down Expand Up @@ -581,7 +579,7 @@ String ScriptedInfo::absolutePathInContext(Record const &context, String const &
{
// Look in reverse so the latest inherited locations are checked first.
auto const &elems = context.geta(VAR_INHERITED_SOURCES);
for (int i = elems.size() - 1; i >= 0; --i)
for (long i = elems.size() - 1; i >= 0; --i)
{
String inheritedPath = elems.at(i).asText().fileNamePath() / relativePath;
if (App::rootFolder().has(inheritedPath))
Expand Down Expand Up @@ -626,7 +624,7 @@ bool ScriptedInfo::isTrue(RecordAccessor const &rec, String const &name, bool de

String ScriptedInfo::blockType(Record const &block)
{
return block.gets(VAR_BLOCK_TYPE, BLOCK_GROUP).toLower();
return block.gets(VAR_BLOCK_TYPE, BLOCK_GROUP).lower();
}

bool ScriptedInfo::isFalse(RecordAccessor const &rec, String const &name, bool defaultValue)
Expand Down Expand Up @@ -675,7 +673,8 @@ Record::Subrecords ScriptedInfo::subrecordsOfType(String const &blockType, Recor

StringList ScriptedInfo::sortRecordsBySource(Record::Subrecords const &subrecs)
{
StringList keys = subrecs.keys();
StringList keys =
map<StringList>(subrecs, [](const std::pair<String, Record *> &v) { return v.first; });

std::sort(keys.begin(), keys.end(), [&subrecs] (String const &a, String const &b) -> bool
{
Expand Down

0 comments on commit 5b3fca7

Please sign in to comment.