diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-05-03 17:19:53 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-03 17:19:53 +0000 |
commit | 525147a1f6d6cd736a407d1e189ac25d2f4726e8 (patch) | |
tree | bdc818c52d902a5a4e8ce8a4f0ba29bd11007b05 /fpdfsdk/fpdf_attachment.cpp | |
parent | ccd9421589922b8f35ee5330d7fdac7edea081db (diff) | |
download | pdfium-525147a1f6d6cd736a407d1e189ac25d2f4726e8.tar.xz |
Use strict types in FPDF API, try #3
Rather than messing with actual inheritence, add type-checking wrappers
and just blatantly cast to incomplete types. Along the way, this points
out places where we would downcast without checking, which I fix.
Change-Id: Ieb303eb46ad8522dfe082454f1f10f247ffd52d5
Reviewed-on: https://pdfium-review.googlesource.com/32030
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_attachment.cpp')
-rw-r--r-- | fpdfsdk/fpdf_attachment.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fpdfsdk/fpdf_attachment.cpp b/fpdfsdk/fpdf_attachment.cpp index 25957174bc..f2ed684e40 100644 --- a/fpdfsdk/fpdf_attachment.cpp +++ b/fpdfsdk/fpdf_attachment.cpp @@ -26,10 +26,6 @@ namespace { constexpr char kChecksumKey[] = "CheckSum"; -CPDF_Object* CPDFObjectFromFPDFAttachment(FPDF_ATTACHMENT attachment) { - return static_cast<CPDF_Object*>(attachment); -} - ByteString CFXByteStringHexDecode(const ByteString& bsHex) { uint8_t* result = nullptr; uint32_t size = 0; @@ -101,7 +97,7 @@ FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name) { return nullptr; } - return pFile; + return FPDFAttachmentFromCPDFObject(pFile); } FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV @@ -115,7 +111,8 @@ FPDFDoc_GetAttachment(FPDF_DOCUMENT document, int index) { return nullptr; WideString csName; - return nameTree.LookupValueAndName(index, &csName); + return FPDFAttachmentFromCPDFObject( + nameTree.LookupValueAndName(index, &csName)); } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |