summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/Document.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-24 11:23:25 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-24 17:17:44 +0000
commit1d8d9ac983fa9c7b6dfc3df736cfd3eae6908a60 (patch)
tree4508fee34d447c5753bdcc0568ad888873e838c2 /fpdfsdk/javascript/Document.cpp
parente49749265c4e503c37a316e4ca6eeff430d13b87 (diff)
downloadpdfium-1d8d9ac983fa9c7b6dfc3df736cfd3eae6908a60.tar.xz
Remove CJS_Value constructors
This CL removes most of the CJS_Value constructors and leaves the v8::Local<v8::Value> constructor as the only non-default construtor. Change-Id: Ie98260d10eff645d0ca688b353e7d40ba1aac157 Reviewed-on: https://pdfium-review.googlesource.com/16611 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/Document.cpp')
-rw-r--r--fpdfsdk/javascript/Document.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index a47deea790..c406425a92 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -325,7 +325,9 @@ bool Document::getField(CJS_Runtime* pRuntime,
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
pField->AttachField(this, wideName);
- vRet = CJS_Value(pJSField);
+
+ if (pJSField)
+ vRet = CJS_Value(pJSField->ToV8Object());
return true;
}
@@ -353,7 +355,7 @@ bool Document::getNthFieldName(CJS_Runtime* pRuntime,
if (!pField)
return false;
- vRet = CJS_Value(pRuntime, pField->GetFullName().c_str());
+ vRet = CJS_Value(pRuntime->NewString(pField->GetFullName().c_str()));
return true;
}
@@ -1279,7 +1281,9 @@ bool Document::getAnnot(CJS_Runtime* pRuntime,
static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
pAnnot->SetSDKAnnot(pSDKBAAnnot);
- vRet = CJS_Value(pJS_Annot);
+ if (pJS_Annot)
+ vRet = CJS_Value(pJS_Annot->ToV8Object());
+
return true;
}
@@ -1317,10 +1321,12 @@ bool Document::getAnnots(CJS_Runtime* pRuntime,
static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
pAnnot->SetSDKAnnot(static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur.Get()));
- annots.SetElement(pRuntime, i, CJS_Value(pJS_Annot));
+ annots.SetElement(
+ pRuntime, i,
+ pJS_Annot ? CJS_Value(pJS_Annot->ToV8Object()) : CJS_Value());
}
}
- vRet = CJS_Value(pRuntime, annots);
+ vRet = CJS_Value(annots.ToV8Array(pRuntime));
return true;
}
@@ -1408,7 +1414,9 @@ bool Document::get_icons(CJS_Runtime* pRuntime,
static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
pIcon->SetIconName(name);
- Icons.SetElement(pRuntime, i++, CJS_Value(pJS_Icon));
+ Icons.SetElement(
+ pRuntime, i++,
+ pJS_Icon ? CJS_Value(pJS_Icon->ToV8Object()) : CJS_Value());
}
vp->Set(Icons.ToV8Array(pRuntime));
@@ -1444,7 +1452,9 @@ bool Document::getIcon(CJS_Runtime* pRuntime,
CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
pIcon->SetIconName(*it);
- vRet = CJS_Value(pJS_Icon);
+ if (pJS_Icon)
+ vRet = CJS_Value(pJS_Icon->ToV8Object());
+
return true;
}
@@ -1560,7 +1570,7 @@ bool Document::getPageNthWord(CJS_Runtime* pRuntime,
swRet.TrimRight();
}
- vRet = CJS_Value(pRuntime, swRet.c_str());
+ vRet = CJS_Value(pRuntime->NewString(swRet.c_str()));
return true;
}
@@ -1611,7 +1621,7 @@ bool Document::getPageNumWords(CJS_Runtime* pRuntime,
nWords += CountWords(pPageObj->AsText());
}
- vRet = CJS_Value(pRuntime, nWords);
+ vRet = CJS_Value(pRuntime->NewNumber(nWords));
return true;
}