From 8e4c505ff6d82263183e9f812fcc7b45c1414f15 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 14 Apr 2016 13:42:44 -0700 Subject: Rename CFX_ByteTextBuf::GetByteString() to AsStringC(). Do the same for CFX_WideTextBuf as well. The name is confusing because these return CFX_ByteStringC, not CFX_ByteString. The AsStringC naming gives parallelism with the string types themselves, and may help to indicate that the result is only good for the lifetime of the object being operated upon. Review URL: https://codereview.chromium.org/1886263003 --- xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 31 +++++++++++------------------- xfa/fxfa/fm2js/xfa_simpleexpression.cpp | 10 +++++----- xfa/fxfa/parser/xfa_document_serialize.cpp | 10 +++++----- xfa/fxfa/parser/xfa_parser_imp.cpp | 6 +++--- 4 files changed, 24 insertions(+), 33 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index cc148c72ea..351aedd669 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -3248,7 +3248,7 @@ void CXFA_FM2JSContext::Eval(FXJSE_HOBJECT hThis, wsJavaScriptBuf, wsError); FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime); FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime); - javaScript = wsJavaScriptBuf.GetWideString(); + javaScript = wsJavaScriptBuf.AsStringC(); FXJSE_ExecuteScript( hContext, FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), @@ -3693,8 +3693,7 @@ void CXFA_FM2JSContext::Decode(FXJSE_HOBJECT hThis, HValueToUTF8String(argOne, toDecodeString); CFX_ByteTextBuf resultBuf; DecodeURL(toDecodeString.AsStringC(), resultBuf); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); } FXJSE_Value_Release(argOne); } else if (argc == 2) { @@ -3715,8 +3714,7 @@ void CXFA_FM2JSContext::Decode(FXJSE_HOBJECT hThis, } else { DecodeURL(toDecodeString.AsStringC(), resultBuf); } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); } FXJSE_Value_Release(argOne); FXJSE_Value_Release(argTwo); @@ -3966,8 +3964,7 @@ void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis, HValueToUTF8String(argOne, toEncodeString); CFX_ByteTextBuf resultBuf; EncodeURL(toEncodeString.AsStringC(), resultBuf); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); } FXJSE_Value_Release(argOne); } else if (argc == 2) { @@ -3988,8 +3985,7 @@ void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis, } else { EncodeURL(toEncodeString.AsStringC(), resultBuf); } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); } FXJSE_Value_Release(argOne); FXJSE_Value_Release(argTwo); @@ -4773,8 +4769,7 @@ void CXFA_FM2JSContext::Replace(FXJSE_HOBJECT hThis, } } resultString.AppendChar(0); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultString.GetByteString()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); FXJSE_Value_Release(argOne); FXJSE_Value_Release(argTwo); if (argc == 3) { @@ -4860,8 +4855,7 @@ void CXFA_FM2JSContext::Space(FXJSE_HOBJECT hThis, index++; } spaceString.AppendByte(0); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - spaceString.GetByteString()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); } FXJSE_Value_Release(argOne); } else { @@ -4977,8 +4971,7 @@ void CXFA_FM2JSContext::Str(FXJSE_HOBJECT hThis, resultBuf.AppendChar(0); } } - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); } else { FXJSE_Value_SetNull(args.GetReturnValue()); } @@ -5044,8 +5037,7 @@ void CXFA_FM2JSContext::Stuff(FXJSE_HOBJECT hThis, ++i; } resultString.AppendChar(0); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultString.GetByteString()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); FXJSE_Value_Release(sourceValue); FXJSE_Value_Release(startValue); FXJSE_Value_Release(deleteValue); @@ -5223,8 +5215,7 @@ void CXFA_FM2JSContext::WordNum(FXJSE_HOBJECT hThis, CFX_ByteString numberString; numberString.Format("%.2f", fNumber); WordUS(numberString.AsStringC(), iIdentifier, resultBuf); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - resultBuf.GetByteString()); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); } } else { FXJSE_Value_SetNull(args.GetReturnValue()); @@ -6388,7 +6379,7 @@ void CXFA_FM2JSContext::eval_translation(FXJSE_HOBJECT hThis, CFX_WideString wsError; XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError); if (wsError.IsEmpty()) { - CFX_WideString javaScript = wsJavaScriptBuf.GetWideString(); + CFX_WideString javaScript = wsJavaScriptBuf.AsStringC(); FXJSE_Value_SetUTF8String( args.GetReturnValue(), FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) diff --git a/xfa/fxfa/fm2js/xfa_simpleexpression.cpp b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp index b600b52ebd..f6c12ae64d 100644 --- a/xfa/fxfa/fm2js/xfa_simpleexpression.cpp +++ b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp @@ -237,7 +237,7 @@ void CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) { CFX_WideTextBuf tempExp1; m_pExp1->ToJavaScript(tempExp1); if (m_pExp1->GetOperatorToken() == TOKidentifier && - tempExp1.GetWideString() != FX_WSTRC(L"this")) { + tempExp1.AsStringC() != FX_WSTRC(L"this")) { javascript << FX_WSTRC(L"else\n{\n"); javascript << tempExp1; javascript << FX_WSTRC(L" = "); @@ -267,7 +267,7 @@ void CXFA_FMAssignExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { CFX_WideTextBuf tempExp1; m_pExp1->ToJavaScript(tempExp1); if (m_pExp1->GetOperatorToken() == TOKidentifier && - tempExp1.GetWideString() != FX_WSTRC(L"this")) { + tempExp1.AsStringC() != FX_WSTRC(L"this")) { javascript << FX_WSTRC(L"else\n{\n"); javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = "); @@ -530,7 +530,7 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << funcName; javascript << FX_WSTRC(L"("); if (m_pArguments) { - uint32_t methodPara = IsMethodWithObjParam(funcName.GetWideString()); + uint32_t methodPara = IsMethodWithObjParam(funcName.AsStringC()); if (methodPara > 0) { for (int i = 0; i < m_pArguments->GetSize(); ++i) { if ((methodPara & (0x01 << i)) > 0) { @@ -568,12 +568,12 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { bool isEvalFunc = false; bool isExistsFunc = false; if (IsBuildInFunc(&funcName)) { - if (funcName.GetWideString() == FX_WSTRC(L"Eval")) { + if (funcName.AsStringC() == FX_WSTRC(L"Eval")) { isEvalFunc = true; javascript << FX_WSTRC(L"eval.call(this, "); javascript << gs_lpStrExpFuncName[CALL]; javascript << FX_WSTRC(L"Translate"); - } else if (funcName.GetWideString() == FX_WSTRC(L"Exists")) { + } else if (funcName.AsStringC() == FX_WSTRC(L"Exists")) { isExistsFunc = true; javascript << gs_lpStrExpFuncName[CALL]; javascript << funcName; diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp index 87707d84e6..3c06afaf4a 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.cpp +++ b/xfa/fxfa/parser/xfa_document_serialize.cpp @@ -94,7 +94,7 @@ CFX_WideString XFA_ExportEncodeAttribute(const CFX_WideString& str) { textBuf.AppendChar(str[i]); } } - return textBuf.GetWideString(); + return textBuf.AsStringC(); } CFX_WideString XFA_ExportEncodeContent(const CFX_WideStringC& str) { CFX_WideTextBuf textBuf; @@ -124,7 +124,7 @@ CFX_WideString XFA_ExportEncodeContent(const CFX_WideStringC& str) { textBuf.AppendChar(str.GetAt(i)); } } - return textBuf.GetWideString(); + return textBuf.AsStringC(); } static void XFA_SaveAttribute(CXFA_Node* pNode, XFA_ATTRIBUTE eName, @@ -303,7 +303,7 @@ static void XFA_DataExporter_RegenerateFormFile_Changed( buf << FX_WSTRC(L""); - wsChildren += buf.GetWideString(); + wsChildren += buf.AsStringC(); buf.Clear(); } else { CFX_WideStringC wsValue = pRawValueNode->GetCData(XFA_ATTRIBUTE_Value); @@ -330,7 +330,7 @@ static void XFA_DataExporter_RegenerateFormFile_Changed( while (pChildNode) { XFA_DataExporter_RegenerateFormFile_Changed(pChildNode, newBuf, bSaveXML); - wsChildren += newBuf.GetWideString(); + wsChildren += newBuf.AsStringC(); newBuf.Clear(); pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); } @@ -342,7 +342,7 @@ static void XFA_DataExporter_RegenerateFormFile_Changed( while (pChildNode) { XFA_DataExporter_RegenerateFormFile_Changed(pChildNode, newBuf, bSaveXML); - wsChildren += newBuf.GetWideString(); + wsChildren += newBuf.AsStringC(); newBuf.Clear(); pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); } diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp index 002197c55d..75ccb1122a 100644 --- a/xfa/fxfa/parser/xfa_parser_imp.cpp +++ b/xfa/fxfa/parser/xfa_parser_imp.cpp @@ -1248,7 +1248,7 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, } else { bMarkAsCompound = TRUE; if (pXMLCurValueNode) { - CFX_WideStringC wsCurValue = wsCurValueTextBuf.GetWideString(); + CFX_WideStringC wsCurValue = wsCurValueTextBuf.AsStringC(); if (!wsCurValue.IsEmpty()) { CXFA_Node* pXFAChild = m_pFactory->CreateNode(ePacketID, XFA_ELEMENT_DataValue); @@ -1282,7 +1282,7 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, } } if (pXMLCurValueNode) { - CFX_WideStringC wsCurValue = wsCurValueTextBuf.GetWideString(); + CFX_WideStringC wsCurValue = wsCurValueTextBuf.AsStringC(); if (!wsCurValue.IsEmpty()) { if (bMarkAsCompound) { CXFA_Node* pXFAChild = @@ -1301,7 +1301,7 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, } pXMLCurValueNode = nullptr; } - CFX_WideStringC wsNodeValue = wsValueTextBuf.GetWideString(); + CFX_WideStringC wsNodeValue = wsValueTextBuf.AsStringC(); pXFANode->SetCData(XFA_ATTRIBUTE_Value, wsNodeValue); } -- cgit v1.2.3