mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
To use members of protocol extensions on existential types, we introduce an OpenExistentialExpr expression to open up the existential type (into a local archetype) and perform the operations on that local archetype. Unlike with uses of initializers or dynamic-Self-producing methods of protocols, which produce similar ASTs, we have the type checker perform the "open" operation and then track it through constraint application. This scheme is better (because it's more direct), but it's still using a simplistic approach to deciding where the actual OpenExistentialExpr goes that needs improvement. Swift SVN r26964
60 lines
1.6 KiB
C++
60 lines
1.6 KiB
C++
//===--- UUID.h - UUID generation -----------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This is an interface over the standard OSF uuid library that gives UUIDs
|
|
// sane value semantics and operators.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include <uuid/uuid.h>
|
|
#include "swift/Basic/UUID.h"
|
|
|
|
using namespace swift;
|
|
|
|
UUID::UUID(FromRandom_t) {
|
|
uuid_generate_random(Value);
|
|
}
|
|
|
|
UUID::UUID(FromTime_t) {
|
|
uuid_generate_time(Value);
|
|
}
|
|
|
|
UUID::UUID() {
|
|
uuid_clear(Value);
|
|
}
|
|
|
|
Optional<UUID> UUID::fromString(const char *s) {
|
|
UUID result;
|
|
if (uuid_parse(s, result.Value))
|
|
return None;
|
|
return result;
|
|
}
|
|
|
|
void UUID::toString(llvm::SmallVectorImpl<char> &out) const {
|
|
out.resize(UUID::StringBufferSize);
|
|
uuid_unparse(Value, out.data());
|
|
// Pop off the null terminator.
|
|
assert(out.back() == '\0' && "did not null-terminate?!");
|
|
out.pop_back();
|
|
}
|
|
|
|
int UUID::compare(UUID y) const {
|
|
return uuid_compare(Value, y.Value);
|
|
}
|
|
|
|
llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &os, UUID uuid) {
|
|
llvm::SmallString<UUID::StringBufferSize> buf;
|
|
uuid.toString(buf);
|
|
os << buf;
|
|
return os;
|
|
}
|