void CXFA_FMBlockExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"{\n"); if (m_pExpressionList) { for (int i = 0; i < m_pExpressionList->GetSize(); ++i) { CXFA_FMExpression* e = reinterpret_cast<CXFA_FMExpression*>(m_pExpressionList->GetAt(i)); if (i + 1 == m_pExpressionList->GetSize()) { e->ToImpliedReturnJS(javascript); } else { e->ToJavaScript(javascript); } } } javascript << FX_WSTRC(L"}\n"); }
void CXFA_FMBlockExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"{\n"); if (m_pExpressionList) { int32_t expc = m_pExpressionList->GetSize(); int32_t index = 0; CXFA_FMExpression* e = 0; while (index < expc) { e = (CXFA_FMExpression*)m_pExpressionList->GetAt(index); if (index + 1 == expc) { e->ToImpliedReturnJS(javascript); } else { e->ToJavaScript(javascript); } index++; } } javascript << FX_WSTRC(L"}\n"); }
void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { if (m_isGlobal && (!m_pExpressions || m_pExpressions->GetSize() == 0)) { javascript << FX_WSTRC(L"// comments only"); return; } if (m_isGlobal) { javascript << FX_WSTRC(L"(\n"); } javascript << FX_WSTRC(L"function "); if (m_wsName.GetAt(0) == L'!') { CFX_WideString tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1); javascript << tempName; } else { javascript << m_wsName; } javascript << FX_WSTRC(L"("); if (m_pArguments != 0) { int32_t argc = m_pArguments->GetSize(); int32_t index = 0; CFX_WideStringC identifier = 0; while (index < argc) { identifier = m_pArguments->GetAt(index); if (identifier.GetAt(0) == L'!') { CFX_WideString tempIdentifier = EXCLAMATION_IN_IDENTIFIER + identifier.Mid(1); javascript << tempIdentifier; } else { javascript << identifier; } if (index + 1 < argc) { javascript << FX_WSTRC(L", "); } index++; } } javascript << FX_WSTRC(L")\n{\n"); javascript << FX_WSTRC(L"var "); javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = null;\n"); if (m_pExpressions) { int32_t expc = m_pExpressions->GetSize(); int32_t index = 0; CXFA_FMExpression* e = 0; while (index < expc) { e = (CXFA_FMExpression*)m_pExpressions->GetAt(index); if (index + 1 < expc) { e->ToJavaScript(javascript); } else { e->ToImpliedReturnJS(javascript); } index++; } } javascript << FX_WSTRC(L"return "); if (m_isGlobal) { javascript << XFA_FM_EXPTypeToString(GETFMVALUE); javascript << FX_WSTRC(L"("); javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L")"); } else { javascript << RUNTIMEFUNCTIONRETURNVALUE; } javascript << FX_WSTRC(L";\n}\n"); if (m_isGlobal) { javascript << FX_WSTRC(L").call(this);\n"); } }