summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-08-17 11:58:34 -0700
committerTom Sepez <tsepez@chromium.org>2015-08-17 11:58:34 -0700
commited7599b9042169f11b00f1126bfd3aff0f56b35f (patch)
tree0e5bafee56227bec79f759314bca5c045577143c /fpdfsdk/src/javascript
parentfdc8f439e854a2636e7d22d7104bf08cf5620b0b (diff)
downloadpdfium-ed7599b9042169f11b00f1126bfd3aff0f56b35f.tar.xz
js_global_data and global_alternate violate naming rules.
They look too much like locals; use JSGlobalData and JSGlobalAlternate instead. Kill some commented out code. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1289903004 .
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r--fpdfsdk/src/javascript/JS_GlobalData.cpp17
-rw-r--r--fpdfsdk/src/javascript/global.cpp89
2 files changed, 45 insertions, 61 deletions
diff --git a/fpdfsdk/src/javascript/JS_GlobalData.cpp b/fpdfsdk/src/javascript/JS_GlobalData.cpp
index 9f954acee5..0a21a9253c 100644
--- a/fpdfsdk/src/javascript/JS_GlobalData.cpp
+++ b/fpdfsdk/src/javascript/JS_GlobalData.cpp
@@ -398,23 +398,6 @@ void CJS_GlobalData::LoadGlobalPersistentVariables() {
}
}
-/*
-struct js_global_datafile_header
-{
- FX_WORD type; //FX ('X' << 8) | 'F'
- FX_WORD version; //1.0
- FX_DWORD datacount;
-};
-struct js_global_datafile_data
-{
- FX_WORD type;
- FX_DWORD nData;
- FX_WORD bData;
- FX_DWORD nStrLen;
- char* pStr;
-};
-*/
-
void CJS_GlobalData::SaveGlobalPersisitentVariables() {
FX_DWORD nCount = 0;
CFX_BinaryBuf sData;
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index 17aa00e31d..aa3bfa026a 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -89,13 +89,13 @@ BEGIN_JS_STATIC_METHOD(CJS_Global)
JS_STATIC_METHOD_ENTRY(setPersistent)
END_JS_STATIC_METHOD()
-IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, global_alternate, global);
+IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, JSGlobalAlternate, global);
FX_BOOL CJS_Global::InitInstance(IFXJS_Context* cc) {
CJS_Context* pContext = (CJS_Context*)cc;
ASSERT(pContext != NULL);
- global_alternate* pGlobal = (global_alternate*)GetEmbedObject();
+ JSGlobalAlternate* pGlobal = (JSGlobalAlternate*)GetEmbedObject();
ASSERT(pGlobal != NULL);
pGlobal->Initial(pContext->GetReaderApp());
@@ -103,28 +103,29 @@ FX_BOOL CJS_Global::InitInstance(IFXJS_Context* cc) {
return TRUE;
};
-global_alternate::global_alternate(CJS_Object* pJSObject)
- : CJS_EmbedObj(pJSObject), m_pApp(NULL) {}
+JSGlobalAlternate::JSGlobalAlternate(CJS_Object* pJSObject)
+ : CJS_EmbedObj(pJSObject), m_pApp(NULL) {
+}
-global_alternate::~global_alternate() {
+JSGlobalAlternate::~JSGlobalAlternate() {
DestroyGlobalPersisitentVariables();
m_pApp->GetRuntimeFactory()->ReleaseGlobalData();
}
-void global_alternate::Initial(CPDFDoc_Environment* pApp) {
+void JSGlobalAlternate::Initial(CPDFDoc_Environment* pApp) {
m_pApp = pApp;
m_pGlobalData = pApp->GetRuntimeFactory()->NewGlobalData(pApp);
UpdateGlobalPersistentVariables();
}
-FX_BOOL global_alternate::QueryProperty(const FX_WCHAR* propname) {
+FX_BOOL JSGlobalAlternate::QueryProperty(const FX_WCHAR* propname) {
return CFX_WideString(propname) != L"setPersistent";
}
-FX_BOOL global_alternate::DelProperty(IFXJS_Context* cc,
- const FX_WCHAR* propname,
- CFX_WideString& sError) {
- js_global_data* pData = NULL;
+FX_BOOL JSGlobalAlternate::DelProperty(IFXJS_Context* cc,
+ const FX_WCHAR* propname,
+ CFX_WideString& sError) {
+ JSGlobalData* pData = NULL;
CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
if (m_mapGlobal.Lookup(sPropName, (void*&)pData)) {
@@ -135,10 +136,10 @@ FX_BOOL global_alternate::DelProperty(IFXJS_Context* cc,
return FALSE;
}
-FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc,
- const FX_WCHAR* propname,
- CJS_PropValue& vp,
- CFX_WideString& sError) {
+FX_BOOL JSGlobalAlternate::DoProperty(IFXJS_Context* cc,
+ const FX_WCHAR* propname,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
if (vp.IsSetting()) {
CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
switch (vp.GetType()) {
@@ -187,7 +188,7 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc,
vp.SetNull();
return TRUE;
}
- js_global_data* pData = (js_global_data*)pVoid;
+ JSGlobalData* pData = (JSGlobalData*)pVoid;
if (pData->bDeleted)
return TRUE;
@@ -217,10 +218,10 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc,
return FALSE;
}
-FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc,
- const CJS_Parameters& params,
- CJS_Value& vRet,
- CFX_WideString& sError) {
+FX_BOOL JSGlobalAlternate::setPersistent(IFXJS_Context* cc,
+ const CJS_Parameters& params,
+ CJS_Value& vRet,
+ CFX_WideString& sError) {
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
if (params.size() != 2) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
@@ -229,7 +230,7 @@ FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc,
CFX_ByteString sName = params[0].ToCFXByteString();
- js_global_data* pData = NULL;
+ JSGlobalData* pData = NULL;
if (m_mapGlobal.Lookup(sName, (void*&)pData)) {
if (pData && !pData->bDeleted) {
pData->bPersistent = params[1].ToBool();
@@ -241,7 +242,7 @@ FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc,
return FALSE;
}
-void global_alternate::UpdateGlobalPersistentVariables() {
+void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
ASSERT(m_pGlobalData != NULL);
for (int i = 0, sz = m_pGlobalData->GetSize(); i < sz; i++) {
@@ -296,13 +297,13 @@ void global_alternate::UpdateGlobalPersistentVariables() {
}
}
-void global_alternate::CommitGlobalPersisitentVariables() {
+void JSGlobalAlternate::CommitGlobalPersisitentVariables() {
ASSERT(m_pGlobalData != NULL);
FX_POSITION pos = m_mapGlobal.GetStartPosition();
while (pos) {
CFX_ByteString name;
- js_global_data* pData = NULL;
+ JSGlobalData* pData = NULL;
m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData);
if (pData) {
@@ -348,8 +349,8 @@ void global_alternate::CommitGlobalPersisitentVariables() {
}
}
-void global_alternate::ObjectToArray(v8::Local<v8::Object> pObj,
- CJS_GlobalVariableArray& array) {
+void JSGlobalAlternate::ObjectToArray(v8::Local<v8::Object> pObj,
+ CJS_GlobalVariableArray& array) {
v8::Local<v8::Context> context = pObj->CreationContext();
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Array> pKeyList = JS_GetObjectElementNames(isolate, pObj);
@@ -405,8 +406,8 @@ void global_alternate::ObjectToArray(v8::Local<v8::Object> pObj,
}
}
-void global_alternate::PutObjectProperty(v8::Local<v8::Object> pObj,
- CJS_KeyValue* pData) {
+void JSGlobalAlternate::PutObjectProperty(v8::Local<v8::Object> pObj,
+ CJS_KeyValue* pData) {
ASSERT(pData != NULL);
for (int i = 0, sz = pData->objData.Count(); i < sz; i++) {
@@ -445,11 +446,11 @@ void global_alternate::PutObjectProperty(v8::Local<v8::Object> pObj,
}
}
-void global_alternate::DestroyGlobalPersisitentVariables() {
+void JSGlobalAlternate::DestroyGlobalPersisitentVariables() {
FX_POSITION pos = m_mapGlobal.GetStartPosition();
while (pos) {
CFX_ByteString name;
- js_global_data* pData = NULL;
+ JSGlobalData* pData = NULL;
m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData);
delete pData;
}
@@ -457,17 +458,17 @@ void global_alternate::DestroyGlobalPersisitentVariables() {
m_mapGlobal.RemoveAll();
}
-FX_BOOL global_alternate::SetGlobalVariables(const FX_CHAR* propname,
- int nType,
- double dData,
- bool bData,
- const CFX_ByteString& sData,
- JSObject pData,
- bool bDefaultPersistent) {
+FX_BOOL JSGlobalAlternate::SetGlobalVariables(const FX_CHAR* propname,
+ int nType,
+ double dData,
+ bool bData,
+ const CFX_ByteString& sData,
+ JSObject pData,
+ bool bDefaultPersistent) {
if (propname == NULL)
return FALSE;
- js_global_data* pTemp = NULL;
+ JSGlobalData* pTemp = NULL;
m_mapGlobal.Lookup(propname, (void*&)pTemp);
if (pTemp) {
@@ -502,35 +503,35 @@ FX_BOOL global_alternate::SetGlobalVariables(const FX_CHAR* propname,
return TRUE;
}
- js_global_data* pNewData = NULL;
+ JSGlobalData* pNewData = NULL;
switch (nType) {
case JS_GLOBALDATA_TYPE_NUMBER: {
- pNewData = new js_global_data;
+ pNewData = new JSGlobalData;
pNewData->nType = JS_GLOBALDATA_TYPE_NUMBER;
pNewData->dData = dData;
pNewData->bPersistent = bDefaultPersistent;
} break;
case JS_GLOBALDATA_TYPE_BOOLEAN: {
- pNewData = new js_global_data;
+ pNewData = new JSGlobalData;
pNewData->nType = JS_GLOBALDATA_TYPE_BOOLEAN;
pNewData->bData = bData;
pNewData->bPersistent = bDefaultPersistent;
} break;
case JS_GLOBALDATA_TYPE_STRING: {
- pNewData = new js_global_data;
+ pNewData = new JSGlobalData;
pNewData->nType = JS_GLOBALDATA_TYPE_STRING;
pNewData->sData = sData;
pNewData->bPersistent = bDefaultPersistent;
} break;
case JS_GLOBALDATA_TYPE_OBJECT: {
- pNewData = new js_global_data;
+ pNewData = new JSGlobalData;
pNewData->nType = JS_GLOBALDATA_TYPE_OBJECT;
pNewData->pData.Reset(JS_GetRuntime(pData), pData);
pNewData->bPersistent = bDefaultPersistent;
} break;
case JS_GLOBALDATA_TYPE_NULL: {
- pNewData = new js_global_data;
+ pNewData = new JSGlobalData;
pNewData->nType = JS_GLOBALDATA_TYPE_NULL;
pNewData->bPersistent = bDefaultPersistent;
} break;