aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFTypes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pdf/SkPDFTypes.cpp')
-rw-r--r--src/pdf/SkPDFTypes.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp
index c1505ea413..3a8120995c 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -15,18 +15,13 @@
////////////////////////////////////////////////////////////////////////////////
-SkString* pun(char* x) { return reinterpret_cast<SkString*>(x); }
-const SkString* pun(const char* x) {
- return reinterpret_cast<const SkString*>(x);
-}
-
SkPDFUnion::SkPDFUnion(Type t) : fType(t) {}
SkPDFUnion::~SkPDFUnion() {
switch (fType) {
case Type::kNameSkS:
case Type::kStringSkS:
- pun(fSkString)->~SkString();
+ fSkString.destroy();
return;
case Type::kObjRef:
case Type::kObject:
@@ -59,7 +54,7 @@ SkPDFUnion SkPDFUnion::copy() const {
switch (fType) {
case Type::kNameSkS:
case Type::kStringSkS:
- new (pun(u.fSkString)) SkString(*pun(fSkString));
+ u.fSkString.init(fSkString.get());
return u;
case Type::kObjRef:
case Type::kObject:
@@ -140,11 +135,10 @@ void SkPDFUnion::emitObject(SkWStream* stream,
return;
case Type::kNameSkS:
stream->writeText("/");
- write_name_escaped(stream, pun(fSkString)->c_str());
+ write_name_escaped(stream, fSkString.get().c_str());
return;
case Type::kStringSkS:
- SkPDFUtils::WriteString(stream, pun(fSkString)->c_str(),
- pun(fSkString)->size());
+ SkPDFUtils::WriteString(stream, fSkString.get().c_str(), fSkString.get().size());
return;
case Type::kObjRef:
stream->writeDecAsText(objNumMap.getObjectNumber(fObject));
@@ -221,13 +215,13 @@ SkPDFUnion SkPDFUnion::String(const char* value) {
SkPDFUnion SkPDFUnion::Name(const SkString& s) {
SkPDFUnion u(Type::kNameSkS);
- new (pun(u.fSkString)) SkString(s);
+ u.fSkString.init(s);
return u;
}
SkPDFUnion SkPDFUnion::String(const SkString& s) {
SkPDFUnion u(Type::kStringSkS);
- new (pun(u.fSkString)) SkString(s);
+ u.fSkString.init(s);
return u;
}