From 721f5fa5061f2dec8282b7bde48c9d4721208b7a Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 23 Jul 2018 18:03:44 +0000 Subject: Replace CFXJSE_HostObject::type_ with polymorphic conversion methods More foolproof technique, and saves one word in every instance at a cost of two pointers in every subclass vtable. Change-Id: Ied4f91d4d203b5e6d83abe751159eb7e55489bb5 Reviewed-on: https://pdfium-review.googlesource.com/38530 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- xfa/fxfa/parser/cxfa_object.cpp | 9 ++++++--- xfa/fxfa/parser/cxfa_object.h | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp index a716c651f5..920e33860e 100644 --- a/xfa/fxfa/parser/cxfa_object.cpp +++ b/xfa/fxfa/parser/cxfa_object.cpp @@ -22,15 +22,18 @@ CXFA_Object::CXFA_Object(CXFA_Document* pDocument, XFA_Element elementType, const WideStringView& elementName, std::unique_ptr jsObject) - : CFXJSE_HostObject(kXFA), - m_pDocument(pDocument), + : m_pDocument(pDocument), m_objectType(objectType), m_elementType(elementType), m_elementNameHash(FX_HashCode_GetW(elementName, false)), m_elementName(elementName), m_pJSObject(std::move(jsObject)) {} -CXFA_Object::~CXFA_Object() {} +CXFA_Object::~CXFA_Object() = default; + +CXFA_Object* CXFA_Object::AsCXFAObject() { + return this; +} WideString CXFA_Object::GetSOMExpression() { CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext(); diff --git a/xfa/fxfa/parser/cxfa_object.h b/xfa/fxfa/parser/cxfa_object.h index 20412dcbf7..023516a05e 100644 --- a/xfa/fxfa/parser/cxfa_object.h +++ b/xfa/fxfa/parser/cxfa_object.h @@ -36,6 +36,9 @@ class CXFA_Object : public CFXJSE_HostObject { public: ~CXFA_Object() override; + // CFXJSE_HostObject: + CXFA_Object* AsCXFAObject() override; + CXFA_Document* GetDocument() const { return m_pDocument.Get(); } XFA_ObjectType GetObjectType() const { return m_objectType; } -- cgit v1.2.3