diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-10-25 13:30:31 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-25 18:40:45 +0000 |
commit | 8f524d6ff9c5c5e07388438e58aca7dc39f43a1f (patch) | |
tree | ec73d24ebdfb84e0c9a254a35912edc5ab54dae7 /fpdfsdk/javascript/Annot.cpp | |
parent | 2474a3b2d9fe987dac58813771f1fa66427e124f (diff) | |
download | pdfium-8f524d6ff9c5c5e07388438e58aca7dc39f43a1f.tar.xz |
Refactor JS method parameters and return values.
This CL removes the out parameters from the JS methods and changes the
return from a |bool| to a |CJS_Return| value. The return value holds the
returned v8 object, error string and a status code.
Change-Id: I82488ff0d916475d7e3c8e51ed868639806181c9
Reviewed-on: https://pdfium-review.googlesource.com/16751
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/Annot.cpp')
-rw-r--r-- | fpdfsdk/javascript/Annot.cpp | 68 |
1 files changed, 22 insertions, 46 deletions
diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp index a068e28008..4240bbc974 100644 --- a/fpdfsdk/javascript/Annot.cpp +++ b/fpdfsdk/javascript/Annot.cpp @@ -35,29 +35,20 @@ Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {} Annot::~Annot() {} -bool Annot::get_hidden(CJS_Runtime* pRuntime, - CJS_Value* vp, - WideString* sError) { - if (!m_pAnnot) { - *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); - return false; - } +CJS_Return Annot::get_hidden(CJS_Runtime* pRuntime) { + if (!m_pAnnot) + return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT)); CPDF_Annot* pPDFAnnot = ToBAAnnot(m_pAnnot.Get())->GetPDFAnnot(); - vp->Set(pRuntime->NewBoolean( + return CJS_Return(pRuntime->NewBoolean( CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict()))); - return true; } -bool Annot::set_hidden(CJS_Runtime* pRuntime, - v8::Local<v8::Value> vp, - WideString* sError) { +CJS_Return Annot::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { // May invalidate m_pAnnot. bool bHidden = pRuntime->ToBoolean(vp); - if (!m_pAnnot) { - *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); - return false; - } + if (!m_pAnnot) + return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT)); uint32_t flags = ToBAAnnot(m_pAnnot.Get())->GetFlags(); if (bHidden) { @@ -73,53 +64,38 @@ bool Annot::set_hidden(CJS_Runtime* pRuntime, } ToBAAnnot(m_pAnnot.Get())->SetFlags(flags); - return true; + return CJS_Return(true); } -bool Annot::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { - if (!m_pAnnot) { - *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); - return false; - } - - vp->Set( +CJS_Return Annot::get_name(CJS_Runtime* pRuntime) { + if (!m_pAnnot) + return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT)); + return CJS_Return( pRuntime->NewString(ToBAAnnot(m_pAnnot.Get())->GetAnnotName().c_str())); - return true; } -bool Annot::set_name(CJS_Runtime* pRuntime, - v8::Local<v8::Value> vp, - WideString* sError) { +CJS_Return Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { // May invalidate m_pAnnot. WideString annotName = pRuntime->ToWideString(vp); - if (!m_pAnnot) { - *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); - return false; - } + if (!m_pAnnot) + return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT)); ToBAAnnot(m_pAnnot.Get())->SetAnnotName(annotName); - return true; + return CJS_Return(true); } -bool Annot::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { - if (!m_pAnnot) { - *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); - return false; - } - - vp->Set(pRuntime->NewString( +CJS_Return Annot::get_type(CJS_Runtime* pRuntime) { + if (!m_pAnnot) + return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT)); + return CJS_Return(pRuntime->NewString( WideString::FromLocal(CPDF_Annot::AnnotSubtypeToString( ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype()) .c_str()) .c_str())); - return true; } -bool Annot::set_type(CJS_Runtime* pRuntime, - v8::Local<v8::Value> vp, - WideString* sError) { - *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); - return false; +CJS_Return Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY)); } void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* annot) { |