Add some missing const to CJX_Object getters [pdfium : master]

0 views
Skip to first unread message

Tom Sepez (Gerrit)

unread,
May 14, 2021, 6:17:31 PM5/14/21
to Lei Zhang, pdfium-...@googlegroups.com

Attention is currently required from: Lei Zhang.

Patch set 1:Commit-Queue +1

View Change

    To view, visit change 80410. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: pdfium
    Gerrit-Branch: master
    Gerrit-Change-Id: I1536afc52b9b252af815a2821a086457e610332d
    Gerrit-Change-Number: 80410
    Gerrit-PatchSet: 1
    Gerrit-Owner: Tom Sepez <tse...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Lei Zhang <the...@chromium.org>
    Gerrit-Comment-Date: Fri, 14 May 2021 22:17:27 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Lei Zhang (Gerrit)

    unread,
    May 14, 2021, 6:51:31 PM5/14/21
    to Tom Sepez, Lei Zhang, Chromium commit bot, pdfium-...@googlegroups.com

    Attention is currently required from: Tom Sepez.

    Patch set 1:Code-Review +1

    View Change

      To view, visit change 80410. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: pdfium
      Gerrit-Branch: master
      Gerrit-Change-Id: I1536afc52b9b252af815a2821a086457e610332d
      Gerrit-Change-Number: 80410
      Gerrit-PatchSet: 1
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-CC: Chromium commit bot <commi...@chromium.org>
      Gerrit-Attention: Tom Sepez <tse...@chromium.org>
      Gerrit-Comment-Date: Fri, 14 May 2021 22:51:28 +0000

      Tom Sepez (Gerrit)

      unread,
      May 14, 2021, 6:56:01 PM5/14/21
      to Lei Zhang, Chromium commit bot, pdfium-...@googlegroups.com

      Attention is currently required from: Tom Sepez.

      Patch set 1:Commit-Queue +2

      View Change

        To view, visit change 80410. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: pdfium
        Gerrit-Branch: master
        Gerrit-Change-Id: I1536afc52b9b252af815a2821a086457e610332d
        Gerrit-Change-Number: 80410
        Gerrit-PatchSet: 1
        Gerrit-Owner: Tom Sepez <tse...@chromium.org>
        Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
        Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
        Gerrit-CC: Chromium commit bot <commi...@chromium.org>
        Gerrit-Attention: Tom Sepez <tse...@chromium.org>
        Gerrit-Comment-Date: Fri, 14 May 2021 22:55:57 +0000

        Chromium commit bot (Gerrit)

        unread,
        May 14, 2021, 7:15:25 PM5/14/21
        to Tom Sepez, Lei Zhang, pdfium-...@googlegroups.com

        Chromium commit bot submitted this change.

        View Change

        Approvals: Lei Zhang: Looks good to me Tom Sepez: Commit
        Add some missing const to CJX_Object getters

        -- Organize each section in header with const methods first.

        Change-Id: I1536afc52b9b252af815a2821a086457e610332d
        Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/80410
        Reviewed-by: Lei Zhang <the...@chromium.org>
        Commit-Queue: Tom Sepez <tse...@chromium.org>
        ---
        M fxjs/xfa/cjx_object.cpp
        M fxjs/xfa/cjx_object.h
        2 files changed, 28 insertions(+), 25 deletions(-)

        diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
        index c82bddb..ccb70a2 100644
        --- a/fxjs/xfa/cjx_object.cpp
        +++ b/fxjs/xfa/cjx_object.cpp
        @@ -197,7 +197,7 @@
        FXJSE_ThrowMessage(str.ToUTF8().AsStringView());
        }

        -bool CJX_Object::HasAttribute(XFA_Attribute eAttr) {
        +bool CJX_Object::HasAttribute(XFA_Attribute eAttr) const {
        uint32_t key = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
        return HasMapModuleKey(key);
        }
        @@ -244,7 +244,7 @@
        SetMapModuleString(key, wsValue);
        }

        -WideString CJX_Object::GetAttributeByString(WideStringView attr) {
        +WideString CJX_Object::GetAttributeByString(WideStringView attr) const {
        Optional<WideString> result;
        Optional<XFA_ATTRIBUTEINFO> enum_attr = XFA_GetAttributeByName(attr);
        if (enum_attr.has_value())
        @@ -254,12 +254,12 @@
        return result.value_or(WideString());
        }

        -WideString CJX_Object::GetAttributeByEnum(XFA_Attribute attr) {
        +WideString CJX_Object::GetAttributeByEnum(XFA_Attribute attr) const {
        return TryAttribute(attr, true).value_or(WideString());
        }

        Optional<WideString> CJX_Object::TryAttribute(XFA_Attribute eAttr,
        - bool bUseDefault) {
        + bool bUseDefault) const {
        switch (GetXFANode()->GetAttributeType(eAttr)) {
        case XFA_AttributeType::Enum: {
        Optional<XFA_AttributeValue> value = TryEnum(eAttr, bUseDefault);
        @@ -299,7 +299,8 @@
        RemoveMapModuleKey(GetMapKey_Custom(wsAttr));
        }

        -Optional<bool> CJX_Object::TryBoolean(XFA_Attribute eAttr, bool bUseDefault) {
        +Optional<bool> CJX_Object::TryBoolean(XFA_Attribute eAttr,
        + bool bUseDefault) const {
        uint32_t key = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
        Optional<int32_t> value = GetMapModuleValueFollowingChain(key);
        if (value.has_value())
        @@ -317,7 +318,7 @@
        }
        }

        -bool CJX_Object::GetBoolean(XFA_Attribute eAttr) {
        +bool CJX_Object::GetBoolean(XFA_Attribute eAttr) const {
        return TryBoolean(eAttr, true).value_or(false);
        }

        @@ -673,11 +674,12 @@
        }
        }

        -WideString CJX_Object::GetContent(bool bScriptModify) {
        +WideString CJX_Object::GetContent(bool bScriptModify) const {
        return TryContent(bScriptModify, true).value_or(WideString());
        }

        -Optional<WideString> CJX_Object::TryContent(bool bScriptModify, bool bProto) {
        +Optional<WideString> CJX_Object::TryContent(bool bScriptModify,
        + bool bProto) const {
        CXFA_Node* pNode = nullptr;
        switch (GetXFANode()->GetObjectType()) {
        case XFA_ObjectType::ContainerNode:
        @@ -738,7 +740,7 @@
        return {};
        }

        -Optional<WideString> CJX_Object::TryNamespace() {
        +Optional<WideString> CJX_Object::TryNamespace() const {
        if (GetXFANode()->IsModelNode() ||
        GetXFANode()->GetElementType() == XFA_Element::Packet) {
        CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
        @@ -880,7 +882,7 @@
        return pdfium::nullopt;
        }

        -bool CJX_Object::HasMapModuleKey(uint32_t key) {
        +bool CJX_Object::HasMapModuleKey(uint32_t key) const {
        CFXJSE_MapModule* pModule = GetMapModule();
        return pModule && pModule->HasKey(key);
        }
        diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
        index b2a7ca9..7dacd99 100644
        --- a/fxjs/xfa/cjx_object.h
        +++ b/fxjs/xfa/cjx_object.h
        @@ -129,23 +129,24 @@
        CJS_Result RunMethod(const WideString& func,
        const std::vector<v8::Local<v8::Value>>& params);

        - bool HasAttribute(XFA_Attribute eAttr);
        + bool HasAttribute(XFA_Attribute eAttr) const;
        + WideString GetAttributeByString(WideStringView attr) const;
        + WideString GetAttributeByEnum(XFA_Attribute attr) const;
        + Optional<WideString> TryAttribute(XFA_Attribute eAttr,
        + bool bUseDefault) const;
        void SetAttributeByEnum(XFA_Attribute eAttr,
        const WideString& wsValue,
        bool bNotify);
        void SetAttributeByString(WideStringView wsAttr, const WideString& wsValue);
        void RemoveAttribute(WideStringView wsAttr);
        - WideString GetAttributeByString(WideStringView attr);
        - WideString GetAttributeByEnum(XFA_Attribute attr);
        - Optional<WideString> TryAttribute(XFA_Attribute eAttr, bool bUseDefault);

        - Optional<WideString> TryContent(bool bScriptModify, bool bProto);
        + WideString GetContent(bool bScriptModify) const;
        + Optional<WideString> TryContent(bool bScriptModify, bool bProto) const;
        void SetContent(const WideString& wsContent,
        const WideString& wsXMLValue,
        bool bNotify,
        bool bScriptModify,
        bool bSyncData);
        - WideString GetContent(bool bScriptModify);

        template <typename T>
        T* GetProperty(int32_t index, XFA_Element eType) const {
        @@ -185,33 +186,33 @@
        bool bSetting,
        XFA_SOM_MESSAGETYPE iMessageType);

        - Optional<WideString> TryNamespace();
        + Optional<WideString> TryNamespace() const;

        + int32_t GetInteger(XFA_Attribute eAttr) const;
        Optional<int32_t> TryInteger(XFA_Attribute eAttr, bool bUseDefault) const;
        void SetInteger(XFA_Attribute eAttr, int32_t iValue, bool bNotify);
        - int32_t GetInteger(XFA_Attribute eAttr) const;

        + WideString GetCData(XFA_Attribute eAttr) const;
        Optional<WideString> TryCData(XFA_Attribute eAttr, bool bUseDefault) const;
        void SetCData(XFA_Attribute eAttr, const WideString& wsValue);
        - WideString GetCData(XFA_Attribute eAttr) const;

        + XFA_AttributeValue GetEnum(XFA_Attribute eAttr) const;
        Optional<XFA_AttributeValue> TryEnum(XFA_Attribute eAttr,
        bool bUseDefault) const;
        void SetEnum(XFA_Attribute eAttr, XFA_AttributeValue eValue, bool bNotify);
        - XFA_AttributeValue GetEnum(XFA_Attribute eAttr) const;

        - Optional<bool> TryBoolean(XFA_Attribute eAttr, bool bUseDefault);
        + bool GetBoolean(XFA_Attribute eAttr) const;
        + Optional<bool> TryBoolean(XFA_Attribute eAttr, bool bUseDefault) const;
        void SetBoolean(XFA_Attribute eAttr, bool bValue, bool bNotify);
        - bool GetBoolean(XFA_Attribute eAttr);

        + CXFA_Measurement GetMeasure(XFA_Attribute eAttr) const;
        + float GetMeasureInUnit(XFA_Attribute eAttr, XFA_Unit unit) const;
        Optional<CXFA_Measurement> TryMeasure(XFA_Attribute eAttr,
        bool bUseDefault) const;
        Optional<float> TryMeasureAsFloat(XFA_Attribute attr) const;
        void SetMeasure(XFA_Attribute eAttr,
        const CXFA_Measurement& mValue,
        bool bNotify);
        - CXFA_Measurement GetMeasure(XFA_Attribute eAttr) const;
        - float GetMeasureInUnit(XFA_Attribute eAttr, XFA_Unit unit) const;

        void MergeAllData(CXFA_Object* pDstObj);

        @@ -268,7 +269,7 @@
        Optional<WideString> GetMapModuleStringFollowingChain(uint32_t key) const;
        Optional<CXFA_Measurement> GetMapModuleMeasurementFollowingChain(
        uint32_t key) const;
        - bool HasMapModuleKey(uint32_t key);
        + bool HasMapModuleKey(uint32_t key) const;
        void RemoveMapModuleKey(uint32_t key);
        void MoveBufferMapData(CXFA_Object* pDstObj);


        To view, visit change 80410. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: pdfium
        Gerrit-Branch: master
        Gerrit-Change-Id: I1536afc52b9b252af815a2821a086457e610332d
        Gerrit-Change-Number: 80410
        Gerrit-PatchSet: 2
        Gerrit-Owner: Tom Sepez <tse...@chromium.org>
        Gerrit-Reviewer: Chromium commit bot <commi...@chromium.org>
        Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
        Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
        Gerrit-MessageType: merged
        Reply all
        Reply to author
        Forward
        0 new messages