From 1d8d9ac983fa9c7b6dfc3df736cfd3eae6908a60 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 24 Oct 2017 11:23:25 -0400 Subject: Remove CJS_Value constructors This CL removes most of the CJS_Value constructors and leaves the v8::Local constructor as the only non-default construtor. Change-Id: Ie98260d10eff645d0ca688b353e7d40ba1aac157 Reviewed-on: https://pdfium-review.googlesource.com/16611 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/javascript/color.cpp | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'fpdfsdk/javascript/color.cpp') diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp index 37ab1cc4fe..e730c31588 100644 --- a/fpdfsdk/javascript/color.cpp +++ b/fpdfsdk/javascript/color.cpp @@ -44,24 +44,32 @@ CJS_Array color::ConvertPWLColorToArray(CJS_Runtime* pRuntime, CJS_Array array; switch (color.nColorType) { case CFX_Color::kTransparent: - array.SetElement(pRuntime, 0, CJS_Value(pRuntime, "T")); + array.SetElement(pRuntime, 0, CJS_Value(pRuntime->NewString(L"T"))); break; case CFX_Color::kGray: - array.SetElement(pRuntime, 0, CJS_Value(pRuntime, "G")); - array.SetElement(pRuntime, 1, CJS_Value(pRuntime, color.fColor1)); + array.SetElement(pRuntime, 0, CJS_Value(pRuntime->NewString(L"G"))); + array.SetElement(pRuntime, 1, + CJS_Value(pRuntime->NewNumber(color.fColor1))); break; case CFX_Color::kRGB: - array.SetElement(pRuntime, 0, CJS_Value(pRuntime, "RGB")); - array.SetElement(pRuntime, 1, CJS_Value(pRuntime, color.fColor1)); - array.SetElement(pRuntime, 2, CJS_Value(pRuntime, color.fColor2)); - array.SetElement(pRuntime, 3, CJS_Value(pRuntime, color.fColor3)); + array.SetElement(pRuntime, 0, CJS_Value(pRuntime->NewString(L"RGB"))); + array.SetElement(pRuntime, 1, + CJS_Value(pRuntime->NewNumber(color.fColor1))); + array.SetElement(pRuntime, 2, + CJS_Value(pRuntime->NewNumber(color.fColor2))); + array.SetElement(pRuntime, 3, + CJS_Value(pRuntime->NewNumber(color.fColor3))); break; case CFX_Color::kCMYK: - array.SetElement(pRuntime, 0, CJS_Value(pRuntime, "CMYK")); - array.SetElement(pRuntime, 1, CJS_Value(pRuntime, color.fColor1)); - array.SetElement(pRuntime, 2, CJS_Value(pRuntime, color.fColor2)); - array.SetElement(pRuntime, 3, CJS_Value(pRuntime, color.fColor3)); - array.SetElement(pRuntime, 4, CJS_Value(pRuntime, color.fColor4)); + array.SetElement(pRuntime, 0, CJS_Value(pRuntime->NewString(L"CMYK"))); + array.SetElement(pRuntime, 1, + CJS_Value(pRuntime->NewNumber(color.fColor1))); + array.SetElement(pRuntime, 2, + CJS_Value(pRuntime->NewNumber(color.fColor2))); + array.SetElement(pRuntime, 3, + CJS_Value(pRuntime->NewNumber(color.fColor3))); + array.SetElement(pRuntime, 4, + CJS_Value(pRuntime->NewNumber(color.fColor4))); break; } return array; @@ -300,8 +308,9 @@ bool color::convert(CJS_Runtime* pRuntime, CFX_Color color = ConvertArrayToPWLColor(pRuntime, params[0].ToArray(pRuntime)); - vRet = CJS_Value(pRuntime, ConvertPWLColorToArray( - pRuntime, color.ConvertColorType(nColorType))); + vRet = CJS_Value( + ConvertPWLColorToArray(pRuntime, color.ConvertColorType(nColorType)) + .ToV8Array(pRuntime)); return true; } @@ -321,6 +330,6 @@ bool color::equal(CJS_Runtime* pRuntime, ConvertArrayToPWLColor(pRuntime, params[1].ToArray(pRuntime)); color1 = color1.ConvertColorType(color2.nColorType); - vRet = CJS_Value(pRuntime, color1 == color2); + vRet = CJS_Value(pRuntime->NewBoolean(color1 == color2)); return true; } -- cgit v1.2.3