summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
AgeCommit message (Collapse)Author
2018-02-21[formcalc] Use default destructorsDan Sinclair
This CL switches the empty destructors in the FormCalc expressions to use default. Change-Id: I0a2ea520c89a96d29a2e2564572a7cf345f9f31a Reviewed-on: https://pdfium-review.googlesource.com/27510 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-02-20[formcalc] Remove unused line parameterDan Sinclair
The recorded line number from the formcalc parse is never used. This Cl removes the parameter and removes the need to pass it through all of the constructors. Change-Id: Ice716cc4880dd17dc05bffcdce1dc1e4745108ea Reviewed-on: https://pdfium-review.googlesource.com/27412 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-19Cleanup FormCalc inheritancedan sinclair
This CL cleans up the FormCalc inheritance. The binary and unary items all share ToJavaScript methods now. Change-Id: I7bf0978449395fa2eb90b954cf2118d7aa3f71c6 Reviewed-on: https://pdfium-review.googlesource.com/27290 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-19Remove base class ToJavaScript methods in FormCalcdan sinclair
This CL removes the Loop base class as it adds no functionality. Other base classes have had their ToJavaScript methods set as pure virtual and their constructors made protected. Change-Id: I5c77b8734d23c576dd52db7f72396ecdf2f7bd22 Reviewed-on: https://pdfium-review.googlesource.com/27270 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-19Cleanup JS generation in formcalc.dan sinclair
This CL cleans up some of the JS generation code to make it easier to see what JavaScript is begin created. Change-Id: I4265226cca0e4de400d05cc0fea3f8c76608115e Reviewed-on: https://pdfium-review.googlesource.com/27250 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-19Inline FormCalc method namesdan sinclair
This CL inlines the FormCalc method names instead of using a lookup array. Many of the names were only referenced once and this makes the code a lot simpler to read. Change-Id: Ib80f5bfa0097e4f1bad232e7de452f067db2a758 Reviewed-on: https://pdfium-review.googlesource.com/27211 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-19Inline some formcalc identifiersdan sinclair
This CL inlines the RUNTIMEFUNCTIONRETURNVALUE and EXCLAMATION_IN_IDENTIFIER defines to make the output code easier to read. Change-Id: I4a86da2aefc75ff137d9a7cff0351515b275f1b1 Reviewed-on: https://pdfium-review.googlesource.com/27230 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-19Merge FormCalc to JavaScript methodsdan sinclair
This CL merges the ToJavaScript and the ToImpliedJS methods in the FormCalc expressions. The type of return is passed as a paramter to ToJavaScript. Change-Id: Idff83677bc70b964d95aa6ff6b0e2c1bf8c603ea Reviewed-on: https://pdfium-review.googlesource.com/27210 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-26Consistently apply JS size checkRyan Harrison
This CL makes the use of CXFA_IsTooBig consistent and universal across all of the ToJavascript and related methods. Previously this method was only applied in some calls. It is now being tested as a precondition and postcondition on every call and as a post condition for the entire translation process. There are some size checks within methods that potentially generate large amounts of JS that have been left in. BUG=chromium:752920 Change-Id: I1a8bfe21e0a17c2e47592fc6017060243674f1bc Reviewed-on: https://pdfium-review.googlesource.com/16812 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-25Fixing the prefix on IsTooBigRyan Harrison
Change-Id: I3be788e06790d8102fc3793a50a58c19f05f855d Reviewed-on: https://pdfium-review.googlesource.com/16790 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-10-25Add in depth check for ToJavascript and related methodsRyan Harrison
There exists a similar check for the parser, but it doesn't catch all cases of excessive memory usage, since a single parse step can generate multiple expressions that need to be converted or other cases where the parse depth doesn't match the emission depth later. Due to the expressions appearing in two different inheritence hierachies the depth information needs to be stored outside of the classes, thus the new depth class. Another way to handle this would be to change the method calls to take in a visitor object that tracks depth. This would require significant reworking of some of the code, so I am going to file a bug about doing that conversion as a cleanup. BUG=chromium:752495 Change-Id: Ica7c9b60ecf1e17530ea88b7bfb01582c63043be Reviewed-on: https://pdfium-review.googlesource.com/16752 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-09-27Remove FX_STRSIZE and replace with size_tRyan Harrison
BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-18Convert string class namesRyan Harrison
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-08-30Move CFX_WideTextBuf out of fx_basicDan Sinclair
This CL moves CFX_WideTextBuf to its own files and updates includes as needed. Change-Id: Ibe66ecf3e66f8f01dd8e9eaf6b467588be86ad4f Reviewed-on: https://pdfium-review.googlesource.com/12413 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-08-30Convert int* references to FX_STRSIZERyan Harrison
Through out the code base there are numerous places where variables are declared using a signed integer type when interacting with the string classes, since they assume that FX_STRSIZE is 'int'. As part of changing the underling type of FX_STRSIZE to be unsigned, these locations are being changed to use FX_STRSIZE. This is necessary as part of converting the type, but has been broken off into a separate CL, since it should be low risk. Some related cleanups that are low risk are included as part of this CL. BUG=pdfium:828 Change-Id: Ifaae54ad195ccde0fe8672f71271d29a6ebd65fd Reviewed-on: https://pdfium-review.googlesource.com/12210 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-07-28Convert calls to Mid() to Left() or Right() if possibleRyan Harrison
The various string/byte classes support Mid(), Left(), and Right() for extracting substrings. Mid() can handle all possible cases, but Left() and Right() are useful for common cases and more explicit about what is going on. Calls like Mid(offset, length - offset) can be converted to Right(length - offset). Calls like Mid(0, length) can be converted to Left(length). If the substring being extracted does not extend all the way to one of the edges of the string, then Mid() still needs to be used. BUG=pdfium:828 Change-Id: I2ec46ad3d71aac0f7b513e103c69cbe8c854cf62 Reviewed-on: https://pdfium-review.googlesource.com/9510 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-07-27Remove single param Mid() method from string classesRyan Harrison
This support is being removed from CFX_ByteString, CFX_ByteStringC, CFX_WideString, and CFX_WideStringC. This standardizes all of these classes to only have one Mid method that takes in 2 params, offset and count. Count now must be positive. The old behaviour of calculating the length for the user if -1 is passed in for the count has been removed. This work is in preperation for converting these classes to not accept negative lengths anywhere and thus make the underlying size type unsigned. BUG=pdfium:828 Change-Id: I5f15e7b7b00b264231817f143e2da88ee6f69e7b Reviewed-on: https://pdfium-review.googlesource.com/9430 Reviewed-by: (OOO Jul 28 - Aug 8) dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-07-05Extract comparison functions from std::lower_bound argsRyan Harrison
Cleanup of code I changed earlier last week, to match the style recommended in later reviews and make it more readable. BUG=pdfium:786 Change-Id: I2ff8b980a229718e389ad1a8063bd5059aedb66c Reviewed-on: https://pdfium-review.googlesource.com/7212 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-06-29Cleaning up SomMethod handling in fm2jsRyan Harrison
Removing hand rolled hash table and binrary search. BUG=pdfium:786 Change-Id: Iac18f02c9f560f484b974762474dbb51597d2353 Reviewed-on: https://pdfium-review.googlesource.com/7092 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-06-29Cleanup call expression handling in fm2jsRyan Harrison
Remove handling of arbitrary function calls, and only allow supported function calls. Issues with the lexer being overly permissive led to large blobs of javascript being dropped into the output. Specifically driver code was assuming that anything marked as a function would just be an identifier that could be inserted into the javascript, but the lexer marks things like ()()() as a function, which would lead to the following JS being inserted as an identifier. This change is intended to be a patch for the specific issue that was being seen from the fuzzer test, and further work will be needed to make the lexer more strict. BUG=724913 TEST=Ran fuzzer test case. Ran unittests,embeddertests,corpustests. Change-Id: Ib7d9239bf6fece853bea0f4915ee4ad72d3cd290 Reviewed-on: https://pdfium-review.googlesource.com/7032 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-23Use NOTREACHED() in more places.Lei Zhang
Change-Id: I88466943171f19259f84add69679741d44c8e123 Reviewed-on: https://pdfium-review.googlesource.com/5551 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-17Shorten internal JS prefixes.Dan Sinclair
This Cl shortens the prefix applied in JavaScript to reduce the size of the generated JavaScript string. Change-Id: Ica5d02cc89b17140ba42deae72484cd159f8e3e5 Reviewed-on: https://pdfium-review.googlesource.com/5590 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-17Rename formcalc files to better match contentsDan Sinclair
Most files match the contents. The expression files are named to match their base type even though they contain all the expression subclasses. Change-Id: I3b7705c7b206a9fa1afae8b677f765e8b788e84d Reviewed-on: https://pdfium-review.googlesource.com/5492 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>