diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-09-11 13:04:48 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-09-11 13:04:48 -0700 |
commit | f9e40aec10263f9445d69598657f42550294d653 (patch) | |
tree | eb20eaef0841334b14266b4a83efe34ade7b1b0e /fpdfsdk/src/javascript/JS_Runtime.cpp | |
parent | df4de98c06075b0e491ac645f2d118a6813cedc9 (diff) | |
download | pdfium-f9e40aec10263f9445d69598657f42550294d653.tar.xz |
Fix strings, remove stringify macros, void return types for Consts.h.
Replace multiple #defines of the same strings with externs.
Fix strings mangled by interaction of # and clang-format.
Remove macros as possible.
Make more JS_ functions void and simplify.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1342433002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Runtime.cpp')
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 80 |
1 files changed, 28 insertions, 52 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index 5f4a473c87..4b18d80f6c 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -137,7 +137,7 @@ CJS_Runtime::~CJS_Runtime() { m_isolate->Dispose(); } -FX_BOOL CJS_Runtime::DefineJSObjects() { +void CJS_Runtime::DefineJSObjects() { v8::Isolate::Scope isolate_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate()); v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); @@ -145,67 +145,43 @@ FX_BOOL CJS_Runtime::DefineJSObjects() { // The call order determines the "ObjDefID" assigned to each class. // ObjDefIDs 0 - 2 - if (CJS_Border::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_Display::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_Font::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; + CJS_Border::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_Display::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_Font::DefineJSObjects(GetIsolate(), JS_STATIC); // ObjDefIDs 3 - 5 - if (CJS_Highlight::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_Position::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_ScaleHow::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; + CJS_Highlight::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_Position::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_ScaleHow::DefineJSObjects(GetIsolate(), JS_STATIC); // ObjDefIDs 6 - 8 - if (CJS_ScaleWhen::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_Style::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_Zoomtype::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; + CJS_ScaleWhen::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_Style::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_Zoomtype::DefineJSObjects(GetIsolate(), JS_STATIC); // ObjDefIDs 9 - 11 - if (CJS_App::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_Color::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_Console::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; + CJS_App::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_Color::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_Console::DefineJSObjects(GetIsolate(), JS_STATIC); // ObjDefIDs 12 - 14 - if (CJS_Document::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) - return FALSE; - if (CJS_Event::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_Field::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) - return FALSE; + CJS_Document::DefineJSObjects(GetIsolate(), JS_DYNAMIC); + CJS_Event::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_Field::DefineJSObjects(GetIsolate(), JS_DYNAMIC); // ObjDefIDs 15 - 17 - if (CJS_Global::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - if (CJS_Icon::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) - return FALSE; - if (CJS_Util::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) - return FALSE; - - // ObjDefIDs 18 - 20 - if (CJS_PublicMethods::DefineJSObjects(GetIsolate()) < 0) - return FALSE; - if (CJS_GlobalConsts::DefineJSObjects(GetIsolate()) < 0) - return FALSE; - if (CJS_GlobalArrays::DefineJSObjects(GetIsolate()) < 0) - return FALSE; - - if (CJS_TimerObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) - return FALSE; - if (CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) - return FALSE; - - return TRUE; + CJS_Global::DefineJSObjects(GetIsolate(), JS_STATIC); + CJS_Icon::DefineJSObjects(GetIsolate(), JS_DYNAMIC); + CJS_Util::DefineJSObjects(GetIsolate(), JS_STATIC); + + // ObjDefIDs 18 - 20 (these can't fail, return void). + CJS_PublicMethods::DefineJSObjects(GetIsolate()); + CJS_GlobalConsts::DefineJSObjects(GetIsolate()); + CJS_GlobalArrays::DefineJSObjects(GetIsolate()); + + // ObjDefIDs 21 - 22. + CJS_TimerObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC); + CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC); } IFXJS_Context* CJS_Runtime::NewContext() { |