Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: xfa/fxjse/class.cpp

Issue 1899103002: XFA unused function cleanup (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxjse/class.h" 7 #include "xfa/fxjse/class.h"
8 8
9 #include "xfa/fxjse/cfxjse_arguments.h" 9 #include "xfa/fxjse/cfxjse_arguments.h"
10 #include "xfa/fxjse/context.h" 10 #include "xfa/fxjse/context.h"
11 #include "xfa/fxjse/scope_inline.h" 11 #include "xfa/fxjse/scope_inline.h"
12 #include "xfa/fxjse/util_inline.h" 12 #include "xfa/fxjse/util_inline.h"
13 #include "xfa/fxjse/value.h" 13 #include "xfa/fxjse/value.h"
14 14
15 static void FXJSE_V8ConstructorCallback_Wrapper( 15 static void FXJSE_V8ConstructorCallback_Wrapper(
16 const v8::FunctionCallbackInfo<v8::Value>& info); 16 const v8::FunctionCallbackInfo<v8::Value>& info);
17 static void FXJSE_V8FunctionCallback_Wrapper( 17 static void FXJSE_V8FunctionCallback_Wrapper(
18 const v8::FunctionCallbackInfo<v8::Value>& info); 18 const v8::FunctionCallbackInfo<v8::Value>& info);
19 static void FXJSE_V8GetterCallback_Wrapper( 19 static void FXJSE_V8GetterCallback_Wrapper(
20 v8::Local<v8::String> property, 20 v8::Local<v8::String> property,
21 const v8::PropertyCallbackInfo<v8::Value>& info); 21 const v8::PropertyCallbackInfo<v8::Value>& info);
22 static void FXJSE_V8SetterCallback_Wrapper( 22 static void FXJSE_V8SetterCallback_Wrapper(
23 v8::Local<v8::String> property, 23 v8::Local<v8::String> property,
24 v8::Local<v8::Value> value, 24 v8::Local<v8::Value> value,
25 const v8::PropertyCallbackInfo<void>& info); 25 const v8::PropertyCallbackInfo<void>& info);
26 26
27 void FXJSE_DefineFunctions(FXJSE_HCONTEXT hContext,
28 const FXJSE_FUNCTION* lpFunctions,
29 int nNum) {
30 CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext);
31 ASSERT(lpContext);
32 CFXJSE_ScopeUtil_IsolateHandleContext scope(lpContext);
33 v8::Isolate* pIsolate = lpContext->GetRuntime();
34 v8::Local<v8::Object> hGlobalObject =
35 FXJSE_GetGlobalObjectFromContext(scope.GetLocalContext());
36 for (int32_t i = 0; i < nNum; i++) {
37 v8::Maybe<bool> maybe_success = hGlobalObject->DefineOwnProperty(
38 scope.GetLocalContext(),
39 v8::String::NewFromUtf8(pIsolate, lpFunctions[i].name),
40 v8::Function::New(
41 pIsolate, FXJSE_V8FunctionCallback_Wrapper,
42 v8::External::New(pIsolate,
43 const_cast<FXJSE_FUNCTION*>(lpFunctions + i))),
44 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
45 if (!maybe_success.FromMaybe(false))
46 return;
47 }
48 }
49
50 FXJSE_HCLASS FXJSE_DefineClass(FXJSE_HCONTEXT hContext, 27 FXJSE_HCLASS FXJSE_DefineClass(FXJSE_HCONTEXT hContext,
51 const FXJSE_CLASS* lpClass) { 28 const FXJSE_CLASS* lpClass) {
52 CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext); 29 CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext);
53 ASSERT(lpContext); 30 ASSERT(lpContext);
54 return reinterpret_cast<FXJSE_HCLASS>( 31 return reinterpret_cast<FXJSE_HCLASS>(
55 CFXJSE_Class::Create(lpContext, lpClass, FALSE)); 32 CFXJSE_Class::Create(lpContext, lpClass, FALSE));
56 } 33 }
57 34
58 FXJSE_HCLASS FXJSE_GetClass(FXJSE_HCONTEXT hContext,
59 const CFX_ByteStringC& szName) {
60 return reinterpret_cast<FXJSE_HCLASS>(CFXJSE_Class::GetClassFromContext(
61 reinterpret_cast<CFXJSE_Context*>(hContext), szName));
62 }
63
64 static void FXJSE_V8FunctionCallback_Wrapper( 35 static void FXJSE_V8FunctionCallback_Wrapper(
65 const v8::FunctionCallbackInfo<v8::Value>& info) { 36 const v8::FunctionCallbackInfo<v8::Value>& info) {
66 const FXJSE_FUNCTION* lpFunctionInfo = 37 const FXJSE_FUNCTION* lpFunctionInfo =
67 static_cast<FXJSE_FUNCTION*>(info.Data().As<v8::External>()->Value()); 38 static_cast<FXJSE_FUNCTION*>(info.Data().As<v8::External>()->Value());
68 if (!lpFunctionInfo) { 39 if (!lpFunctionInfo) {
69 return; 40 return;
70 } 41 }
71 CFX_ByteStringC szFunctionName(lpFunctionInfo->name); 42 CFX_ByteStringC szFunctionName(lpFunctionInfo->name);
72 CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); 43 CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
73 lpThisValue->ForceSetValue(info.This()); 44 lpThisValue->ForceSetValue(info.This());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext, 311 CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext,
341 const CFX_ByteStringC& szName) { 312 const CFX_ByteStringC& szName) {
342 for (int count = pContext->m_rgClasses.GetSize(), i = 0; i < count; i++) { 313 for (int count = pContext->m_rgClasses.GetSize(), i = 0; i < count; i++) {
343 CFXJSE_Class* pClass = pContext->m_rgClasses[i]; 314 CFXJSE_Class* pClass = pContext->m_rgClasses[i];
344 if (pClass->m_szClassName == szName) { 315 if (pClass->m_szClassName == szName) {
345 return pClass; 316 return pClass;
346 } 317 }
347 } 318 }
348 return NULL; 319 return NULL;
349 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698