diff options
author | dan sinclair <dsinclair@chromium.org> | 2017-10-19 14:29:33 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-19 19:50:07 +0000 |
commit | cbe23dbdff3f6e41843fd99cbf615000b52727ed (patch) | |
tree | f2f9e6e5f4dc8818ef15a8f72fdfdab71a848097 /fpdfsdk/javascript/JS_Value.h | |
parent | c136b3146257d0f12d1347a9f1a4784372e19a56 (diff) | |
download | pdfium-cbe23dbdff3f6e41843fd99cbf615000b52727ed.tar.xz |
Refactoring JS Callbacks.
This CL updates the fpdfsdk/javascript callbacks to have explicit
get/set methods instead of one method which worked differently
depending on the mode.
This allows better ownership of the passed in params, (get takes a *
and set takes a const&). The Value object was changed to have To*
and Set methods to make the code clearer compared to the operator<<
and operator>> overloading.
Bug:
Change-Id: Id6ff20a4e3252adfd0a78b643e50b9f095085018
Reviewed-on: https://pdfium-review.googlesource.com/16330
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/JS_Value.h')
-rw-r--r-- | fpdfsdk/javascript/JS_Value.h | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h index 8c94ca742a..47e8cce98a 100644 --- a/fpdfsdk/javascript/JS_Value.h +++ b/fpdfsdk/javascript/JS_Value.h @@ -90,29 +90,39 @@ class CJS_PropValue { bool IsGetting() const { return !m_bIsSetting; } CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime.Get(); } CJS_Value* GetJSValue() { return &m_Value; } + const CJS_Value* GetJSValue() const { return &m_Value; } // These calls may re-enter JS (and hence invalidate objects). - void operator<<(int val); - void operator>>(int&) const; - void operator<<(bool val); - void operator>>(bool&) const; - void operator<<(double val); - void operator>>(double&) const; - void operator<<(CJS_Object* pObj); - void operator>>(CJS_Object*& ppObj) const; - void operator<<(CJS_Document* pJsDoc); - void operator>>(CJS_Document*& ppJsDoc) const; - void operator<<(ByteString); - void operator>>(ByteString&) const; - void operator<<(WideString); - void operator>>(WideString&) const; - void operator<<(const wchar_t* c_string); - void operator<<(v8::Local<v8::Object>); - void operator>>(v8::Local<v8::Object>&) const; - void operator>>(CJS_Array& array) const; - void operator<<(CJS_Array& array); - void operator<<(CJS_Date& date); - void operator>>(CJS_Date& date) const; + void Set(int val); + int ToInt() const; + + void Set(bool val); + bool ToBool() const; + + void Set(double val); + double ToDouble() const; + + void Set(CJS_Object* pObj); + CJS_Object* ToObject() const; + + void Set(CJS_Document* pJsDoc); + CJS_Document* ToDocument() const; + + void Set(const ByteString&); + ByteString ToByteString() const; + + void Set(const WideString&); + void Set(const wchar_t* c_string); + WideString ToWideString() const; + + void Set(v8::Local<v8::Object>); + v8::Local<v8::Object> ToV8Object() const; + + void Set(const CJS_Array& array); + CJS_Array ToArray() const; + + void Set(const CJS_Date& date); + CJS_Date ToDate() const; private: bool m_bIsSetting; @@ -154,6 +164,7 @@ class CJS_Date { int hour, int min, int sec); + CJS_Date(const CJS_Date&); virtual ~CJS_Date(); void Attach(v8::Local<v8::Date> pDate); |