summaryrefslogtreecommitdiff
path: root/fpdfsdk/include/javascript/JS_Define.h
AgeCommit message (Collapse)Author
2015-04-23Remove unused nParamNum values from JS method tables.Tom Sepez
The code to validate the number of parameters happens inside each particular method, rather than prior to method dispatch. As such, there's no point in having this number take up space in the table. Add some test to cover at least some of the per-method validations, and update error messages to be more useful. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1084183008
2015-04-23Kill overloaded cast operators in CJS_Value.Tom Sepez
The red-flag here is the explicit invocation of things like params[1].operator CFX_WideString() rather than static_cast<CFX_WideString>(params[1]) to invoke the conversion. Turns out the above won't compile due to ambiguity given the number of implicit constructors for widestrings. CJS_Value has both constructors and assignment operators for the primitive types, which means that conversions can take place unexpectedly in both directions, a second red flag. We don't want the compiler invoking these at will since it may hide bugs. In fact, when they are removed, three such places were discovered. Also rename ToJSValue to ToV8Value to match the other ToV8xxxxx functions added. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1096813008
2015-04-17Replace FX_NEW with new, remove tests from fpdfsdkTom Sepez
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1089823004
2015-04-07Fix (nearly all) IWYU in fpdfskd/include/javascript/ headers.Tom Sepez
Move some typedefs for v8 types into fxjs_v8.h wrapper to avoid circular inclusions. Also delete JS_Module.h, as no other file includes it. BUG=https://code.google.com/p/pdfium/issues/detail?id=66 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1060133002
2015-03-02Kill off JS_ErrorString type.Tom Sepez
This provides no benefit, and reduces transparency. Along the way: Kill off some unused/commented-out code. Return void where a bool return doesn't make sense. Remove a pointless template type. Remove now unused constants and types. R=thestig@chromium.org Review URL: https://codereview.chromium.org/971033002
2015-03-02Return error information from pdfium to JS.Tom Sepez
This implements the previously unimplemented JS_Error() function. Along the way: - fix some IWYU when the include order in global.cpp was perturbed. - remove some uses of JS_ErrorString, to increase transparency. - use vp.IsSetting() in place of !vp.IsGetting() for clarity. - specify an error string on several error return paths. - add an error string for writing readonly properties. - rename an error string constant to reflect the actual message. - replace calls to variadic Format() with a function doing string appends. - remove unused JS_GetClassName() R=thestig@chromium.org Review URL: https://codereview.chromium.org/963193003
2015-02-25Kill off unused IFXJS interface methods.Tom Sepez
Re-work of original CL at: https://codereview.chromium.org/933043002/ Much of the IFXJS interface appears completely unused, so Kill off unused IFXJS interface methods. The code itself appears incomplete against all of the objects present in the paths that actually do register objects with JS. R=thestig@chromium.org Review URL: https://codereview.chromium.org/954923004
2015-02-23Replace second set of #defines with templates in JS_Define.hchromium/2342chromium/2341chromium/2340chromium/2339chromium/2338chromium/2337chromium/2336chromium/2335chromium/2334chromium/2333chromium/2332chromium/2331chromium/2330chromium/2329chromium/2328chromium/2327chromium/2326chromium/2325chromium/2324chromium/2323chromium/2322chromium/2321chromium/2320chromium/2319chromium/2318chromium/2317chromium/2316chromium/2315chromium/2314Tom Sepez
Continuation of effort now that a test case is present on origin/master. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/945623002
2015-02-18Replace ugly JS_Define macros with templates.Tom Sepez
This allows us to step through the JS bindings code with the debugger, which I could not do (but wanted to) the other day. In the process, get rid of some else after returns, and one unreachable code path. I also get rid of some tracing macros that we would never use for the sake of clarity, and some plain unused definitions. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/908033002
2015-02-17Tidy up JS_Defines.hTom Sepez
This is a purely mechanical change, no new functionality. - Expand some macros which were merely a short-cut to save typing but reduced transparency. - Put GET_VALUE_TYPE() implementation into a .cpp file. This is a portion of the patch from issue 908033002 at patchset 40001 (http://crrev.com/908033002#ps40001) R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/927263003
2014-12-12Avoid duplicate definitions of JSCONST_n*Hash and QeTable variables.Bruce Dawson
QeTable is a 752 byte array that was defined in a header file. This caused it to be instantiated by the VC++ compiler 12 times, wasting 8,272 bytes of space in the data segment. Because 'const' implies 'static' this did not cause any duplicate symbol errors. JSCONST_n*HASH are a set of eight variables that are defined in a header file. This causes them to be replicated 15 times. The variables themselves are tiny but they are dynamically initialized and this dynamic initialization code is replicated 15 times. When tested on pdfium_test.exe the effect of this change is to: Reduce the .text (code) segment by 3,616 bytes. Reduce the .rdata section by 8,656 bytes. Reduce the total binary file size by 13312 bytes. These are the worst offenders for pdf.dll as shown in: https://drive.google.com/open?id=1BvubxoA2SU_2e4T5cq7jHTjc1TlT0qOndpIfX3DMeA8&authuser=0 This will also drastically simplify the list of work to be done for bug 441899 (getting rid of initializers). BUG=441988 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/802013002
2014-12-08Replace manual/error-prone/hard-to-verify arraysize calculations with safe ↵Bruce Dawson
FX_ArraySize macro. pdfium has numerous places where the number of elements in an array is calculated with expressions like: sizeof(cFormats)/sizeof(FX_LPCWSTR) This is suboptimal because it is verbose, it is easy to get wrong, and it cannot be determined through casual inspection whether the code is correct. It will give incorrect results if cFormats is a pointer instead of an array and it will give incorrect results if FX_LPCWSTR is not the type of the array elements. The FX_WSTRC macro in fx_string.h which I fixed was particularly scary because it would silently misbehave if passed a pointer. The FX_ArraySize macro which I have added and started using (taken from arraysize in v8's macros.h) is easier to use and will always give correct results. If passed a pointer it will fail to compile. For this change I only fixed instances of sizeof(FX_LPCWSTR). There appear to be about 150 other places in the pdfium code that could benefit from using FX_ArraySize. R=bo_xu@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/729293003
2014-12-08Getting rid of more (FX_LPCWSTR) casts and fixing two bugs revealed by this.Bruce Dawson
Since casts to FX_LPCWSTR have been shown to hide bugs I tried removing more of them, targeting those places where a cast was used to force a conversion from CFX_WideString to FX_LPCWSTR, replacing these casts with calls to the newly added .c_str() function. This revealed two places where the cast was hiding a bug -- where ->c_str() was required instead! This removes ~33 FX_LPCWSTR casts and there are ~31 left, many of which will go away in some future change. Also includes this change: Removing unnecessary casts from wchar_t* to wchar_t*, by various names. Original patch from Bruce Dawson(brucedawson@chromium.org) R=bo_xu@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/733693003
2014-11-17Removing unnecessary casts from wchar_t* to wchar_t*, by various names.Bruce Dawson
Remove casts that merely cast from wchar_t* to wchar_t*. Sometimes the types or casts are FX_LPCWSTR but the idea is the same. Excess casts can (and have) hidden bugs so removing these may prevent future problems. Original patch from Bruce Dawson(brucedawson@chromium.org) R=bo_xu@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/730993002
2014-08-13Remove try/catch blockBo Xu
BUG=pdfium:28 R=thakis@chromium.org Review URL: https://codereview.chromium.org/472563002
2014-06-19Fix JS_WIDESTRING to work with clang-clJohn Abd-El-Malek
MSVC lexes L#macro_arg as a single wide string literal token, but Clang and other C/C++ compliant lexers do not. There was already a workaround to use implicit string concatenation for GCC, but there's a simpler solution of token pasting the L onto the stringized macro argument with 'L###macro_arg'. This works with Clang, GCC, and MSVC. R=jun_fang@foxitsoftware.com, jam@chromium.org BUG=82385 Original patch by Reid Kleckner <rnk@chromium.org> Review URL: https://codereview.chromium.org/345643002
2014-05-23Convert all line endings to LF.John Abd-El-Malek
2014-05-20Remove "using namespace v8" in header. This allows us to turn all warnings ↵John Abd-El-Malek
into errors. It also makes it clearer to find usage of v8 in the library.
2014-05-17Initial commit.John Abd-El-Malek