Avoid using constexpr char in headers. https://groups.google.com/a/chromium.org/g/chromium-dev/c/SyIIaptlkrA says not to do this, so be consistent with Chromium's guidance. Change-Id: Ib21c9d772ae4c4525bcde1665d6da07fbd983655 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/81631 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/constants/BUILD.gn b/constants/BUILD.gn index 4489b66..3b3ae2d 100644 --- a/constants/BUILD.gn +++ b/constants/BUILD.gn
@@ -7,12 +7,17 @@ source_set("constants") { sources = [ "access_permissions.h", + "annotation_common.cpp", "annotation_common.h", "annotation_flags.h", + "form_fields.cpp", "form_fields.h", "form_flags.h", + "page_object.cpp", "page_object.h", + "stream_dict_common.cpp", "stream_dict_common.h", + "transparency.cpp", "transparency.h", ] }
diff --git a/constants/annotation_common.cpp b/constants/annotation_common.cpp new file mode 100644 index 0000000..40050e2 --- /dev/null +++ b/constants/annotation_common.cpp
@@ -0,0 +1,37 @@ +// Copyright 2021 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "constants/annotation_common.h" + +namespace pdfium { +namespace annotation { + +// PDF 1.7 spec, table 8.15. +// Entries common to all annotation dictionaries. +const char kType[] = "Type"; +const char kSubtype[] = "Subtype"; +const char kRect[] = "Rect"; +const char kContents[] = "Contents"; +const char kP[] = "P"; +const char kNM[] = "NM"; +const char kM[] = "M"; +const char kF[] = "F"; +const char kAP[] = "AP"; +const char kAS[] = "AS"; +const char kBorder[] = "Border"; +const char kC[] = "C"; +const char kStructParent[] = "StructParent"; +const char kOC[] = "OC"; + +// Entries for polygon and polyline annotations. +const char kVertices[] = "Vertices"; + +// Entries for ink annotations +const char kInkList[] = "InkList"; + +// Entries for line annotations +const char kL[] = "L"; + +} // namespace annotation +} // namespace pdfium
diff --git a/constants/annotation_common.h b/constants/annotation_common.h index 656842b..0dfe206 100644 --- a/constants/annotation_common.h +++ b/constants/annotation_common.h
@@ -8,32 +8,26 @@ namespace pdfium { namespace annotation { -// PDF 1.7 spec, table 8.15. -// Entries common to all annotation dictionaries. +extern const char kType[]; +extern const char kSubtype[]; +extern const char kRect[]; +extern const char kContents[]; +extern const char kP[]; +extern const char kNM[]; +extern const char kM[]; +extern const char kF[]; +extern const char kAP[]; +extern const char kAS[]; +extern const char kBorder[]; +extern const char kC[]; +extern const char kStructParent[]; +extern const char kOC[]; -constexpr char kType[] = "Type"; -constexpr char kSubtype[] = "Subtype"; -constexpr char kRect[] = "Rect"; -constexpr char kContents[] = "Contents"; -constexpr char kP[] = "P"; -constexpr char kNM[] = "NM"; -constexpr char kM[] = "M"; -constexpr char kF[] = "F"; -constexpr char kAP[] = "AP"; -constexpr char kAS[] = "AS"; -constexpr char kBorder[] = "Border"; -constexpr char kC[] = "C"; -constexpr char kStructParent[] = "StructParent"; -constexpr char kOC[] = "OC"; +extern const char kVertices[]; -// Entries for polygon and polyline annotations. -constexpr char kVertices[] = "Vertices"; +extern const char kInkList[]; -// Entries for ink annotations -constexpr char kInkList[] = "InkList"; - -// Entries for line annotations -constexpr char kL[] = "L"; +extern const char kL[]; } // namespace annotation } // namespace pdfium
diff --git a/constants/form_fields.cpp b/constants/form_fields.cpp new file mode 100644 index 0000000..7409e8d --- /dev/null +++ b/constants/form_fields.cpp
@@ -0,0 +1,30 @@ +// Copyright 2021 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "constants/form_fields.h" + +namespace pdfium { +namespace form_fields { + +// PDF 1.7 spec, table 8.69. +// Entries common to all field dictionaries. +const char kFT[] = "FT"; +const char kParent[] = "Parent"; +const char kKids[] = "Kids"; +const char kT[] = "T"; +const char kTU[] = "TU"; +const char kTM[] = "TM"; +const char kFf[] = "Ff"; +const char kV[] = "V"; +const char kDV[] = "DV"; +const char kAA[] = "AA"; + +// FT values from PDF 1.7 spec, table 8.69. +const char kBtn[] = "Btn"; +const char kTx[] = "Tx"; +const char kCh[] = "Ch"; +const char kSig[] = "Sig"; + +} // namespace form_fields +} // namespace pdfium
diff --git a/constants/form_fields.h b/constants/form_fields.h index 5b7c169..cd2b0fa 100644 --- a/constants/form_fields.h +++ b/constants/form_fields.h
@@ -8,24 +8,21 @@ namespace pdfium { namespace form_fields { -// PDF 1.7 spec, table 8.69. -// Entries common to all field dictionaries. -constexpr char kFT[] = "FT"; -constexpr char kParent[] = "Parent"; -constexpr char kKids[] = "Kids"; -constexpr char kT[] = "T"; -constexpr char kTU[] = "TU"; -constexpr char kTM[] = "TM"; -constexpr char kFf[] = "Ff"; -constexpr char kV[] = "V"; -constexpr char kDV[] = "DV"; -constexpr char kAA[] = "AA"; +extern const char kFT[]; +extern const char kParent[]; +extern const char kKids[]; +extern const char kT[]; +extern const char kTU[]; +extern const char kTM[]; +extern const char kFf[]; +extern const char kV[]; +extern const char kDV[]; +extern const char kAA[]; -// FT values from PDF 1.7 spec, table 8.69. -constexpr char kBtn[] = "Btn"; -constexpr char kTx[] = "Tx"; -constexpr char kCh[] = "Ch"; -constexpr char kSig[] = "Sig"; +extern const char kBtn[]; +extern const char kTx[]; +extern const char kCh[]; +extern const char kSig[]; } // namespace form_fields } // namespace pdfium
diff --git a/constants/page_object.cpp b/constants/page_object.cpp new file mode 100644 index 0000000..42f76b9 --- /dev/null +++ b/constants/page_object.cpp
@@ -0,0 +1,24 @@ +// Copyright 2021 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "constants/page_object.h" + +namespace pdfium { +namespace page_object { + +// PDF 1.7 spec, table 3.27. +// Entries in a page object. +const char kType[] = "Type"; +const char kParent[] = "Parent"; +const char kResources[] = "Resources"; +const char kMediaBox[] = "MediaBox"; +const char kCropBox[] = "CropBox"; +const char kBleedBox[] = "BleedBox"; +const char kTrimBox[] = "TrimBox"; +const char kArtBox[] = "ArtBox"; +const char kContents[] = "Contents"; +const char kRotate[] = "Rotate"; + +} // namespace page_object +} // namespace pdfium
diff --git a/constants/page_object.h b/constants/page_object.h index 8a41b8c..75f9b76 100644 --- a/constants/page_object.h +++ b/constants/page_object.h
@@ -8,19 +8,16 @@ namespace pdfium { namespace page_object { -// PDF 1.7 spec, table 3.27. -// Entries in a page object. - -constexpr char kType[] = "Type"; -constexpr char kParent[] = "Parent"; -constexpr char kResources[] = "Resources"; -constexpr char kMediaBox[] = "MediaBox"; -constexpr char kCropBox[] = "CropBox"; -constexpr char kBleedBox[] = "BleedBox"; -constexpr char kTrimBox[] = "TrimBox"; -constexpr char kArtBox[] = "ArtBox"; -constexpr char kContents[] = "Contents"; -constexpr char kRotate[] = "Rotate"; +extern const char kType[]; +extern const char kParent[]; +extern const char kResources[]; +extern const char kMediaBox[]; +extern const char kCropBox[]; +extern const char kBleedBox[]; +extern const char kTrimBox[]; +extern const char kArtBox[]; +extern const char kContents[]; +extern const char kRotate[]; } // namespace page_object } // namespace pdfium
diff --git a/constants/stream_dict_common.cpp b/constants/stream_dict_common.cpp new file mode 100644 index 0000000..0f9ca30 --- /dev/null +++ b/constants/stream_dict_common.cpp
@@ -0,0 +1,22 @@ +// Copyright 2021 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "constants/stream_dict_common.h" + +namespace pdfium { +namespace stream { + +// PDF 1.7 spec, table 3.4. +// Entries common to all stream dictionaries. +// +// TODO(https://crbug.com/pdfium/1049): Examine all usages of "Length", +// "Filter", and "F". +const char kLength[] = "Length"; +const char kFilter[] = "Filter"; +const char kDecodeParms[] = "DecodeParms"; +const char kF[] = "F"; +const char kDL[] = "DL"; + +} // namespace stream +} // namespace pdfium
diff --git a/constants/stream_dict_common.h b/constants/stream_dict_common.h index fc12622..d9f6bd9 100644 --- a/constants/stream_dict_common.h +++ b/constants/stream_dict_common.h
@@ -8,18 +8,11 @@ namespace pdfium { namespace stream { -// PDF 1.7 spec, table 3.4. -// Entries common to all stream dictionaries. - -// TODO(https://crbug.com/pdfium/1049): Examine all usages of "Length", -// "Filter", and "F". -constexpr char kLength[] = "Length"; -constexpr char kFilter[] = "Filter"; -constexpr char kDecodeParms[] = "DecodeParms"; -constexpr char kF[] = "F"; -// constexpr char kFFilter[] = "FFilter"; -// constexpr char kFDecodeParms[] = "FDecodeParms"; -constexpr char kDL[] = "DL"; +extern const char kLength[]; +extern const char kFilter[]; +extern const char kDecodeParms[]; +extern const char kF[]; +extern const char kDL[]; } // namespace stream } // namespace pdfium
diff --git a/constants/transparency.cpp b/constants/transparency.cpp new file mode 100644 index 0000000..dc2405a --- /dev/null +++ b/constants/transparency.cpp
@@ -0,0 +1,48 @@ +// Copyright 2021 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "constants/transparency.h" + +namespace pdfium { +namespace transparency { + +// PDF 1.7 spec, table 7.2. +// Standard separable blend modes. +const char kNormal[] = "Normal"; +const char kMultiply[] = "Multiply"; +const char kScreen[] = "Screen"; +const char kOverlay[] = "Overlay"; +const char kDarken[] = "Darken"; +const char kLighten[] = "Lighten"; +const char kColorDodge[] = "ColorDodge"; +const char kColorBurn[] = "ColorBurn"; +const char kHardLight[] = "HardLight"; +const char kSoftLight[] = "SoftLight"; +const char kDifference[] = "Difference"; +const char kExclusion[] = "Exclusion"; + +// PDF 1.7 spec, table 7.3. +// Standard nonseparable blend modes. +const char kHue[] = "Hue"; +const char kSaturation[] = "Saturation"; +const char kColor[] = "Color"; +const char kLuminosity[] = "Luminosity"; + +// PDF 1.7 spec, table 7.10. +// Entries in a soft-mask dictionary. +const char kSoftMaskSubType[] = "S"; +const char kAlpha[] = "Alpha"; +const char kG[] = "G"; +const char kBC[] = "BC"; +const char kTR[] = "TR"; + +// PDF 1.7 spec, table 7.13. +// Additional entries specific to a transparency group attributes dictionary. +const char kGroupSubType[] = "S"; +const char kTransparency[] = "Transparency"; +const char kCS[] = "CS"; +const char kI[] = "I"; + +} // namespace transparency +} // namespace pdfium
diff --git a/constants/transparency.h b/constants/transparency.h index 6532868..87a2408 100644 --- a/constants/transparency.h +++ b/constants/transparency.h
@@ -8,46 +8,34 @@ namespace pdfium { namespace transparency { -// PDF 1.7 spec, table 7.2. -// Standard separable blend modes. +extern const char kNormal[]; +extern const char kMultiply[]; +extern const char kScreen[]; +extern const char kOverlay[]; +extern const char kDarken[]; +extern const char kLighten[]; +extern const char kColorDodge[]; +extern const char kColorBurn[]; +extern const char kHardLight[]; +extern const char kSoftLight[]; +extern const char kDifference[]; +extern const char kExclusion[]; -constexpr char kNormal[] = "Normal"; -constexpr char kMultiply[] = "Multiply"; -constexpr char kScreen[] = "Screen"; -constexpr char kOverlay[] = "Overlay"; -constexpr char kDarken[] = "Darken"; -constexpr char kLighten[] = "Lighten"; -constexpr char kColorDodge[] = "ColorDodge"; -constexpr char kColorBurn[] = "ColorBurn"; -constexpr char kHardLight[] = "HardLight"; -constexpr char kSoftLight[] = "SoftLight"; -constexpr char kDifference[] = "Difference"; -constexpr char kExclusion[] = "Exclusion"; +extern const char kHue[]; +extern const char kSaturation[]; +extern const char kColor[]; +extern const char kLuminosity[]; -// PDF 1.7 spec, table 7.3. -// Standard nonseparable blend modes. +extern const char kSoftMaskSubType[]; +extern const char kAlpha[]; +extern const char kG[]; +extern const char kBC[]; +extern const char kTR[]; -constexpr char kHue[] = "Hue"; -constexpr char kSaturation[] = "Saturation"; -constexpr char kColor[] = "Color"; -constexpr char kLuminosity[] = "Luminosity"; - -// PDF 1.7 spec, table 7.10. -// Entries in a soft-mask dictionary. - -constexpr char kSoftMaskSubType[] = "S"; -constexpr char kAlpha[] = "Alpha"; -constexpr char kG[] = "G"; -constexpr char kBC[] = "BC"; -constexpr char kTR[] = "TR"; - -// PDF 1.7 spec, table 7.13. -// Additional entries specific to a transparency group attributes dictionary. - -constexpr char kGroupSubType[] = "S"; -constexpr char kTransparency[] = "Transparency"; -constexpr char kCS[] = "CS"; -constexpr char kI[] = "I"; +extern const char kGroupSubType[]; +extern const char kTransparency[]; +extern const char kCS[]; +extern const char kI[]; } // namespace transparency } // namespace pdfium