From 4d5b8c5f990b8f06a55961c1f839c5b096658925 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 21 Feb 2017 15:17:07 -0800 Subject: Convert JS property tables to single-byte. Change-Id: I4daec9e05a63c55caa01402a594c3553073c439e Reviewed-on: https://pdfium-review.googlesource.com/2818 Commit-Queue: dsinclair Reviewed-by: dsinclair --- fpdfsdk/javascript/Annot.cpp | 6 +-- fpdfsdk/javascript/Document.cpp | 64 ++++++++++++------------ fpdfsdk/javascript/Field.cpp | 107 +++++++++++++++++++--------------------- fpdfsdk/javascript/Icon.cpp | 2 +- fpdfsdk/javascript/JS_Define.h | 2 +- fpdfsdk/javascript/app.cpp | 25 +++++----- fpdfsdk/javascript/color.cpp | 24 ++++----- fpdfsdk/javascript/event.cpp | 40 +++++++-------- fxjs/fxjs_v8.cpp | 6 +-- fxjs/fxjs_v8.h | 2 +- 10 files changed, 136 insertions(+), 142 deletions(-) diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp index 74af4b41a3..41c71ec411 100644 --- a/fpdfsdk/javascript/Annot.cpp +++ b/fpdfsdk/javascript/Annot.cpp @@ -22,9 +22,9 @@ CPDFSDK_BAAnnot* ToBAAnnot(CPDFSDK_Annot* annot) { JSConstSpec CJS_Annot::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; JSPropertySpec CJS_Annot::PropertySpecs[] = { - {L"hidden", get_hidden_static, set_hidden_static}, - {L"name", get_name_static, set_name_static}, - {L"type", get_type_static, set_type_static}, + {"hidden", get_hidden_static, set_hidden_static}, + {"name", get_name_static, set_name_static}, + {"type", get_type_static, set_type_static}, {0, 0, 0}}; JSMethodSpec CJS_Annot::MethodSpecs[] = {{0, 0}}; diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index d4dc9c35bd..3fdb906108 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -62,39 +62,39 @@ PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) JSConstSpec CJS_Document::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; JSPropertySpec CJS_Document::PropertySpecs[] = { - {L"ADBE", get_ADBE_static, set_ADBE_static}, - {L"author", get_author_static, set_author_static}, - {L"baseURL", get_baseURL_static, set_baseURL_static}, - {L"bookmarkRoot", get_bookmarkRoot_static, set_bookmarkRoot_static}, - {L"calculate", get_calculate_static, set_calculate_static}, - {L"Collab", get_Collab_static, set_Collab_static}, - {L"creationDate", get_creationDate_static, set_creationDate_static}, - {L"creator", get_creator_static, set_creator_static}, - {L"delay", get_delay_static, set_delay_static}, - {L"dirty", get_dirty_static, set_dirty_static}, - {L"documentFileName", get_documentFileName_static, + {"ADBE", get_ADBE_static, set_ADBE_static}, + {"author", get_author_static, set_author_static}, + {"baseURL", get_baseURL_static, set_baseURL_static}, + {"bookmarkRoot", get_bookmarkRoot_static, set_bookmarkRoot_static}, + {"calculate", get_calculate_static, set_calculate_static}, + {"Collab", get_Collab_static, set_Collab_static}, + {"creationDate", get_creationDate_static, set_creationDate_static}, + {"creator", get_creator_static, set_creator_static}, + {"delay", get_delay_static, set_delay_static}, + {"dirty", get_dirty_static, set_dirty_static}, + {"documentFileName", get_documentFileName_static, set_documentFileName_static}, - {L"external", get_external_static, set_external_static}, - {L"filesize", get_filesize_static, set_filesize_static}, - {L"icons", get_icons_static, set_icons_static}, - {L"info", get_info_static, set_info_static}, - {L"keywords", get_keywords_static, set_keywords_static}, - {L"layout", get_layout_static, set_layout_static}, - {L"media", get_media_static, set_media_static}, - {L"modDate", get_modDate_static, set_modDate_static}, - {L"mouseX", get_mouseX_static, set_mouseX_static}, - {L"mouseY", get_mouseY_static, set_mouseY_static}, - {L"numFields", get_numFields_static, set_numFields_static}, - {L"numPages", get_numPages_static, set_numPages_static}, - {L"pageNum", get_pageNum_static, set_pageNum_static}, - {L"pageWindowRect", get_pageWindowRect_static, set_pageWindowRect_static}, - {L"path", get_path_static, set_path_static}, - {L"producer", get_producer_static, set_producer_static}, - {L"subject", get_subject_static, set_subject_static}, - {L"title", get_title_static, set_title_static}, - {L"URL", get_URL_static, set_URL_static}, - {L"zoom", get_zoom_static, set_zoom_static}, - {L"zoomType", get_zoomType_static, set_zoomType_static}, + {"external", get_external_static, set_external_static}, + {"filesize", get_filesize_static, set_filesize_static}, + {"icons", get_icons_static, set_icons_static}, + {"info", get_info_static, set_info_static}, + {"keywords", get_keywords_static, set_keywords_static}, + {"layout", get_layout_static, set_layout_static}, + {"media", get_media_static, set_media_static}, + {"modDate", get_modDate_static, set_modDate_static}, + {"mouseX", get_mouseX_static, set_mouseX_static}, + {"mouseY", get_mouseY_static, set_mouseY_static}, + {"numFields", get_numFields_static, set_numFields_static}, + {"numPages", get_numPages_static, set_numPages_static}, + {"pageNum", get_pageNum_static, set_pageNum_static}, + {"pageWindowRect", get_pageWindowRect_static, set_pageWindowRect_static}, + {"path", get_path_static, set_path_static}, + {"producer", get_producer_static, set_producer_static}, + {"subject", get_subject_static, set_subject_static}, + {"title", get_title_static, set_title_static}, + {"URL", get_URL_static, set_URL_static}, + {"zoom", get_zoom_static, set_zoom_static}, + {"zoomType", get_zoomType_static, set_zoomType_static}, {0, 0, 0}}; JSMethodSpec CJS_Document::MethodSpecs[] = { diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index 99e75441d4..477b472e3c 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -75,64 +75,61 @@ bool SetWidgetDisplayStatus(CPDFSDK_Widget* pWidget, int value) { JSConstSpec CJS_Field::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; JSPropertySpec CJS_Field::PropertySpecs[] = { - {L"alignment", get_alignment_static, set_alignment_static}, - {L"borderStyle", get_borderStyle_static, set_borderStyle_static}, - {L"buttonAlignX", get_buttonAlignX_static, set_buttonAlignX_static}, - {L"buttonAlignY", get_buttonAlignY_static, set_buttonAlignY_static}, - {L"buttonFitBounds", get_buttonFitBounds_static, - set_buttonFitBounds_static}, - {L"buttonPosition", get_buttonPosition_static, set_buttonPosition_static}, - {L"buttonScaleHow", get_buttonScaleHow_static, set_buttonScaleHow_static}, - {L"buttonScaleWhen", get_buttonScaleWhen_static, - set_buttonScaleWhen_static}, - {L"calcOrderIndex", get_calcOrderIndex_static, set_calcOrderIndex_static}, - {L"charLimit", get_charLimit_static, set_charLimit_static}, - {L"comb", get_comb_static, set_comb_static}, - {L"commitOnSelChange", get_commitOnSelChange_static, + {"alignment", get_alignment_static, set_alignment_static}, + {"borderStyle", get_borderStyle_static, set_borderStyle_static}, + {"buttonAlignX", get_buttonAlignX_static, set_buttonAlignX_static}, + {"buttonAlignY", get_buttonAlignY_static, set_buttonAlignY_static}, + {"buttonFitBounds", get_buttonFitBounds_static, set_buttonFitBounds_static}, + {"buttonPosition", get_buttonPosition_static, set_buttonPosition_static}, + {"buttonScaleHow", get_buttonScaleHow_static, set_buttonScaleHow_static}, + {"buttonScaleWhen", get_buttonScaleWhen_static, set_buttonScaleWhen_static}, + {"calcOrderIndex", get_calcOrderIndex_static, set_calcOrderIndex_static}, + {"charLimit", get_charLimit_static, set_charLimit_static}, + {"comb", get_comb_static, set_comb_static}, + {"commitOnSelChange", get_commitOnSelChange_static, set_commitOnSelChange_static}, - {L"currentValueIndices", get_currentValueIndices_static, + {"currentValueIndices", get_currentValueIndices_static, set_currentValueIndices_static}, - {L"defaultStyle", get_defaultStyle_static, set_defaultStyle_static}, - {L"defaultValue", get_defaultValue_static, set_defaultValue_static}, - {L"doNotScroll", get_doNotScroll_static, set_doNotScroll_static}, - {L"doNotSpellCheck", get_doNotSpellCheck_static, - set_doNotSpellCheck_static}, - {L"delay", get_delay_static, set_delay_static}, - {L"display", get_display_static, set_display_static}, - {L"doc", get_doc_static, set_doc_static}, - {L"editable", get_editable_static, set_editable_static}, - {L"exportValues", get_exportValues_static, set_exportValues_static}, - {L"hidden", get_hidden_static, set_hidden_static}, - {L"fileSelect", get_fileSelect_static, set_fileSelect_static}, - {L"fillColor", get_fillColor_static, set_fillColor_static}, - {L"lineWidth", get_lineWidth_static, set_lineWidth_static}, - {L"highlight", get_highlight_static, set_highlight_static}, - {L"multiline", get_multiline_static, set_multiline_static}, - {L"multipleSelection", get_multipleSelection_static, + {"defaultStyle", get_defaultStyle_static, set_defaultStyle_static}, + {"defaultValue", get_defaultValue_static, set_defaultValue_static}, + {"doNotScroll", get_doNotScroll_static, set_doNotScroll_static}, + {"doNotSpellCheck", get_doNotSpellCheck_static, set_doNotSpellCheck_static}, + {"delay", get_delay_static, set_delay_static}, + {"display", get_display_static, set_display_static}, + {"doc", get_doc_static, set_doc_static}, + {"editable", get_editable_static, set_editable_static}, + {"exportValues", get_exportValues_static, set_exportValues_static}, + {"hidden", get_hidden_static, set_hidden_static}, + {"fileSelect", get_fileSelect_static, set_fileSelect_static}, + {"fillColor", get_fillColor_static, set_fillColor_static}, + {"lineWidth", get_lineWidth_static, set_lineWidth_static}, + {"highlight", get_highlight_static, set_highlight_static}, + {"multiline", get_multiline_static, set_multiline_static}, + {"multipleSelection", get_multipleSelection_static, set_multipleSelection_static}, - {L"name", get_name_static, set_name_static}, - {L"numItems", get_numItems_static, set_numItems_static}, - {L"page", get_page_static, set_page_static}, - {L"password", get_password_static, set_password_static}, - {L"print", get_print_static, set_print_static}, - {L"radiosInUnison", get_radiosInUnison_static, set_radiosInUnison_static}, - {L"readonly", get_readonly_static, set_readonly_static}, - {L"rect", get_rect_static, set_rect_static}, - {L"required", get_required_static, set_required_static}, - {L"richText", get_richText_static, set_richText_static}, - {L"richValue", get_richValue_static, set_richValue_static}, - {L"rotation", get_rotation_static, set_rotation_static}, - {L"strokeColor", get_strokeColor_static, set_strokeColor_static}, - {L"style", get_style_static, set_style_static}, - {L"submitName", get_submitName_static, set_submitName_static}, - {L"textColor", get_textColor_static, set_textColor_static}, - {L"textFont", get_textFont_static, set_textFont_static}, - {L"textSize", get_textSize_static, set_textSize_static}, - {L"type", get_type_static, set_type_static}, - {L"userName", get_userName_static, set_userName_static}, - {L"value", get_value_static, set_value_static}, - {L"valueAsString", get_valueAsString_static, set_valueAsString_static}, - {L"source", get_source_static, set_source_static}, + {"name", get_name_static, set_name_static}, + {"numItems", get_numItems_static, set_numItems_static}, + {"page", get_page_static, set_page_static}, + {"password", get_password_static, set_password_static}, + {"print", get_print_static, set_print_static}, + {"radiosInUnison", get_radiosInUnison_static, set_radiosInUnison_static}, + {"readonly", get_readonly_static, set_readonly_static}, + {"rect", get_rect_static, set_rect_static}, + {"required", get_required_static, set_required_static}, + {"richText", get_richText_static, set_richText_static}, + {"richValue", get_richValue_static, set_richValue_static}, + {"rotation", get_rotation_static, set_rotation_static}, + {"strokeColor", get_strokeColor_static, set_strokeColor_static}, + {"style", get_style_static, set_style_static}, + {"submitName", get_submitName_static, set_submitName_static}, + {"textColor", get_textColor_static, set_textColor_static}, + {"textFont", get_textFont_static, set_textFont_static}, + {"textSize", get_textSize_static, set_textSize_static}, + {"type", get_type_static, set_type_static}, + {"userName", get_userName_static, set_userName_static}, + {"value", get_value_static, set_value_static}, + {"valueAsString", get_valueAsString_static, set_valueAsString_static}, + {"source", get_source_static, set_source_static}, {0, 0, 0}}; JSMethodSpec CJS_Field::MethodSpecs[] = { diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp index 05be2599aa..72d91faa76 100644 --- a/fpdfsdk/javascript/Icon.cpp +++ b/fpdfsdk/javascript/Icon.cpp @@ -13,7 +13,7 @@ JSConstSpec CJS_Icon::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; JSPropertySpec CJS_Icon::PropertySpecs[] = { - {L"name", get_name_static, set_name_static}, + {"name", get_name_static, set_name_static}, {0, 0, 0}}; JSMethodSpec CJS_Icon::MethodSpecs[] = {{0, 0}}; diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h index 7549dc85e3..0875cc9fc6 100644 --- a/fpdfsdk/javascript/JS_Define.h +++ b/fpdfsdk/javascript/JS_Define.h @@ -24,7 +24,7 @@ struct JSConstSpec { }; struct JSPropertySpec { - const wchar_t* pName; + const char* pName; v8::AccessorGetterCallback pPropGet; v8::AccessorSetterCallback pPropPut; }; diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp index f1a39460a2..668156f0aa 100644 --- a/fpdfsdk/javascript/app.cpp +++ b/fpdfsdk/javascript/app.cpp @@ -161,20 +161,19 @@ void TimerObj::SetTimer(GlobalTimer* pTimer) { JSConstSpec CJS_App::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; JSPropertySpec CJS_App::PropertySpecs[] = { - {L"activeDocs", get_activeDocs_static, set_activeDocs_static}, - {L"calculate", get_calculate_static, set_calculate_static}, - {L"formsVersion", get_formsVersion_static, set_formsVersion_static}, - {L"fs", get_fs_static, set_fs_static}, - {L"fullscreen", get_fullscreen_static, set_fullscreen_static}, - {L"language", get_language_static, set_language_static}, - {L"media", get_media_static, set_media_static}, - {L"platform", get_platform_static, set_platform_static}, - {L"runtimeHighlight", get_runtimeHighlight_static, + {"activeDocs", get_activeDocs_static, set_activeDocs_static}, + {"calculate", get_calculate_static, set_calculate_static}, + {"formsVersion", get_formsVersion_static, set_formsVersion_static}, + {"fs", get_fs_static, set_fs_static}, + {"fullscreen", get_fullscreen_static, set_fullscreen_static}, + {"language", get_language_static, set_language_static}, + {"media", get_media_static, set_media_static}, + {"platform", get_platform_static, set_platform_static}, + {"runtimeHighlight", get_runtimeHighlight_static, set_runtimeHighlight_static}, - {L"viewerType", get_viewerType_static, set_viewerType_static}, - {L"viewerVariation", get_viewerVariation_static, - set_viewerVariation_static}, - {L"viewerVersion", get_viewerVersion_static, set_viewerVersion_static}, + {"viewerType", get_viewerType_static, set_viewerType_static}, + {"viewerVariation", get_viewerVariation_static, set_viewerVariation_static}, + {"viewerVersion", get_viewerVersion_static, set_viewerVersion_static}, {0, 0, 0}}; JSMethodSpec CJS_App::MethodSpecs[] = {{"alert", alert_static}, diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp index abf4049b6c..4fbec5b7c4 100644 --- a/fpdfsdk/javascript/color.cpp +++ b/fpdfsdk/javascript/color.cpp @@ -18,18 +18,18 @@ JSConstSpec CJS_Color::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; JSPropertySpec CJS_Color::PropertySpecs[] = { - {L"black", get_black_static, set_black_static}, - {L"blue", get_blue_static, set_blue_static}, - {L"cyan", get_cyan_static, set_cyan_static}, - {L"dkGray", get_dkGray_static, set_dkGray_static}, - {L"gray", get_gray_static, set_gray_static}, - {L"green", get_green_static, set_green_static}, - {L"ltGray", get_ltGray_static, set_ltGray_static}, - {L"magenta", get_magenta_static, set_magenta_static}, - {L"red", get_red_static, set_red_static}, - {L"transparent", get_transparent_static, set_transparent_static}, - {L"white", get_white_static, set_white_static}, - {L"yellow", get_yellow_static, set_yellow_static}, + {"black", get_black_static, set_black_static}, + {"blue", get_blue_static, set_blue_static}, + {"cyan", get_cyan_static, set_cyan_static}, + {"dkGray", get_dkGray_static, set_dkGray_static}, + {"gray", get_gray_static, set_gray_static}, + {"green", get_green_static, set_green_static}, + {"ltGray", get_ltGray_static, set_ltGray_static}, + {"magenta", get_magenta_static, set_magenta_static}, + {"red", get_red_static, set_red_static}, + {"transparent", get_transparent_static, set_transparent_static}, + {"white", get_white_static, set_white_static}, + {"yellow", get_yellow_static, set_yellow_static}, {0, 0, 0}}; JSMethodSpec CJS_Color::MethodSpecs[] = {{"convert", convert_static}, diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp index 323e2dd037..2b00cbc10e 100644 --- a/fpdfsdk/javascript/event.cpp +++ b/fpdfsdk/javascript/event.cpp @@ -16,26 +16,26 @@ JSConstSpec CJS_Event::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; JSPropertySpec CJS_Event::PropertySpecs[] = { - {L"change", get_change_static, set_change_static}, - {L"changeEx", get_changeEx_static, set_changeEx_static}, - {L"commitKey", get_commitKey_static, set_commitKey_static}, - {L"fieldFull", get_fieldFull_static, set_fieldFull_static}, - {L"keyDown", get_keyDown_static, set_keyDown_static}, - {L"modifier", get_modifier_static, set_modifier_static}, - {L"name", get_name_static, set_name_static}, - {L"rc", get_rc_static, set_rc_static}, - {L"richChange", get_richChange_static, set_richChange_static}, - {L"richChangeEx", get_richChangeEx_static, set_richChangeEx_static}, - {L"richValue", get_richValue_static, set_richValue_static}, - {L"selEnd", get_selEnd_static, set_selEnd_static}, - {L"selStart", get_selStart_static, set_selStart_static}, - {L"shift", get_shift_static, set_shift_static}, - {L"source", get_source_static, set_source_static}, - {L"target", get_target_static, set_target_static}, - {L"targetName", get_targetName_static, set_targetName_static}, - {L"type", get_type_static, set_type_static}, - {L"value", get_value_static, set_value_static}, - {L"willCommit", get_willCommit_static, set_willCommit_static}, + {"change", get_change_static, set_change_static}, + {"changeEx", get_changeEx_static, set_changeEx_static}, + {"commitKey", get_commitKey_static, set_commitKey_static}, + {"fieldFull", get_fieldFull_static, set_fieldFull_static}, + {"keyDown", get_keyDown_static, set_keyDown_static}, + {"modifier", get_modifier_static, set_modifier_static}, + {"name", get_name_static, set_name_static}, + {"rc", get_rc_static, set_rc_static}, + {"richChange", get_richChange_static, set_richChange_static}, + {"richChangeEx", get_richChangeEx_static, set_richChangeEx_static}, + {"richValue", get_richValue_static, set_richValue_static}, + {"selEnd", get_selEnd_static, set_selEnd_static}, + {"selStart", get_selStart_static, set_selStart_static}, + {"shift", get_shift_static, set_shift_static}, + {"source", get_source_static, set_source_static}, + {"target", get_target_static, set_target_static}, + {"targetName", get_targetName_static, set_targetName_static}, + {"type", get_type_static, set_type_static}, + {"value", get_value_static, set_value_static}, + {"willCommit", get_willCommit_static, set_willCommit_static}, {0, 0, 0}}; JSMethodSpec CJS_Event::MethodSpecs[] = {{0, 0}}; diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp index dc2071a88f..f876f8c53f 100644 --- a/fxjs/fxjs_v8.cpp +++ b/fxjs/fxjs_v8.cpp @@ -287,17 +287,15 @@ void CFXJS_Engine::DefineObjMethod(int nObjDefnID, } void CFXJS_Engine::DefineObjProperty(int nObjDefnID, - const wchar_t* sPropName, + const char* sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut) { v8::Isolate::Scope isolate_scope(m_isolate); v8::HandleScope handle_scope(m_isolate); - CFX_ByteString bsPropertyName = FX_UTF8Encode(CFX_WideStringC(sPropName)); CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(m_isolate, nObjDefnID); pObjDef->GetInstanceTemplate()->SetAccessor( - v8::String::NewFromUtf8(m_isolate, bsPropertyName.c_str(), - v8::NewStringType::kNormal) + v8::String::NewFromUtf8(m_isolate, sPropName, v8::NewStringType::kNormal) .ToLocalChecked(), pPropGet, pPropPut); } diff --git a/fxjs/fxjs_v8.h b/fxjs/fxjs_v8.h index 6b988e71a2..34e299b4e2 100644 --- a/fxjs/fxjs_v8.h +++ b/fxjs/fxjs_v8.h @@ -151,7 +151,7 @@ class CFXJS_Engine { const char* sMethodName, v8::FunctionCallback pMethodCall); void DefineObjProperty(int nObjDefnID, - const wchar_t* sPropName, + const char* sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut); void DefineObjAllProperties(int nObjDefnID, -- cgit v1.2.3