OLD | NEW |
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 "../../../core/include/fxcrt/fx_basic.h" | 7 #include "../../../core/include/fxcrt/fx_basic.h" |
8 #include "../../../core/include/fxcrt/fx_ext.h" | 8 #include "../../../core/include/fxcrt/fx_ext.h" |
9 #include "../../include/jsapi/fxjs_v8.h" | 9 #include "../../include/jsapi/fxjs_v8.h" |
10 #include "../../include/fsdk_define.h" | 10 #include "../../include/fsdk_define.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 public: | 34 public: |
35 CJS_PrivateData():ObjDefID(-1), pPrivate(NULL) {} | 35 CJS_PrivateData():ObjDefID(-1), pPrivate(NULL) {} |
36 int ObjDefID; | 36 int ObjDefID; |
37 void* pPrivate; | 37 void* pPrivate; |
38 }; | 38 }; |
39 | 39 |
40 | 40 |
41 class CJS_ObjDefintion | 41 class CJS_ObjDefintion |
42 { | 42 { |
43 public: | 43 public: |
44 » CJS_ObjDefintion(v8::Isolate* isolate, const wchar_t* sObjName, FXJSOBJT
YPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned b
ApplyNew): | 44 » CJS_ObjDefintion(v8::Isolate* isolate, const wchar_t* sObjName, FXJSOBJT
YPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor): |
45 » objName(sObjName), objType(eObjType), m_pConstructor(pConstructor), m_
pDestructor(pDestructor),m_bApplyNew(bApplyNew),m_bSetAsGlobalObject(FALSE) | 45 » objName(sObjName), objType(eObjType), m_pConstructor(pConstructor), m_
pDestructor(pDestructor),m_bSetAsGlobalObject(FALSE) |
46 { | 46 { |
47 v8::Isolate::Scope isolate_scope(isolate); | 47 v8::Isolate::Scope isolate_scope(isolate); |
48 v8::HandleScope handle_scope(isolate); | 48 v8::HandleScope handle_scope(isolate); |
49 | 49 |
50 v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate
::New(isolate); | 50 v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate
::New(isolate); |
51 objTemplate->SetInternalFieldCount(2); | 51 objTemplate->SetInternalFieldCount(2); |
52 m_objTemplate.Reset(isolate, objTemplate); | 52 m_objTemplate.Reset(isolate, objTemplate); |
53 | 53 |
54 //Document as the global object. | 54 //Document as the global object. |
55 if(FXSYS_wcscmp(sObjName, L"Document") == 0) | 55 if(FXSYS_wcscmp(sObjName, L"Document") == 0) |
56 { | 56 { |
57 m_bSetAsGlobalObject = TRUE; | 57 m_bSetAsGlobalObject = TRUE; |
58 } | 58 } |
59 | 59 |
60 } | 60 } |
61 ~CJS_ObjDefintion() | 61 ~CJS_ObjDefintion() |
62 { | 62 { |
63 m_objTemplate.Reset(); | 63 m_objTemplate.Reset(); |
64 m_StaticObj.Reset(); | 64 m_StaticObj.Reset(); |
65 } | 65 } |
66 public: | 66 public: |
67 const wchar_t* objName; | 67 const wchar_t* objName; |
68 FXJSOBJTYPE objType; | 68 FXJSOBJTYPE objType; |
69 LP_CONSTRUCTOR m_pConstructor; | 69 LP_CONSTRUCTOR m_pConstructor; |
70 LP_DESTRUCTOR m_pDestructor; | 70 LP_DESTRUCTOR m_pDestructor; |
71 unsigned m_bApplyNew; | |
72 FX_BOOL m_bSetAsGlobalObject; | 71 FX_BOOL m_bSetAsGlobalObject; |
73 | 72 |
74 v8::Global<v8::ObjectTemplate> m_objTemplate; | 73 v8::Global<v8::ObjectTemplate> m_objTemplate; |
75 v8::Global<v8::Object> m_StaticObj; | 74 v8::Global<v8::Object> m_StaticObj; |
76 }; | 75 }; |
77 | 76 |
78 int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE e
ObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApply
New) | 77 int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE e
ObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor) |
79 { | 78 { |
80 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 79 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; |
81 v8::Isolate::Scope isolate_scope(isolate); | 80 v8::Isolate::Scope isolate_scope(isolate); |
82 v8::HandleScope handle_scope(isolate); | 81 v8::HandleScope handle_scope(isolate); |
83 CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlo
t); | 82 CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlo
t); |
84 if(!pArray) | 83 if(!pArray) |
85 { | 84 { |
86 pArray = new CFX_PtrArray(); | 85 pArray = new CFX_PtrArray(); |
87 isolate->SetData(g_embedderDataSlot, pArray); | 86 isolate->SetData(g_embedderDataSlot, pArray); |
88 } | 87 } |
89 » CJS_ObjDefintion* pObjDef = new CJS_ObjDefintion(isolate, sObjName, eObj
Type, pConstructor, pDestructor, bApplyNew); | 88 » CJS_ObjDefintion* pObjDef = new CJS_ObjDefintion(isolate, sObjName, eObj
Type, pConstructor, pDestructor); |
90 pArray->Add(pObjDef); | 89 pArray->Add(pObjDef); |
91 return pArray->GetSize()-1; | 90 return pArray->GetSize()-1; |
92 } | 91 } |
93 | 92 |
94 int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* s
MethodName, v8::FunctionCallback pMethodCall) | 93 int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* s
MethodName, v8::FunctionCallback pMethodCall) |
95 { | 94 { |
96 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 95 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; |
97 v8::Isolate::Scope isolate_scope(isolate); | 96 v8::Isolate::Scope isolate_scope(isolate); |
98 v8::HandleScope handle_scope(isolate); | 97 v8::HandleScope handle_scope(isolate); |
99 | 98 |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 { | 1061 { |
1063 return d != d; | 1062 return d != d; |
1064 } | 1063 } |
1065 | 1064 |
1066 double JS_LocalTime(double d) | 1065 double JS_LocalTime(double d) |
1067 { | 1066 { |
1068 return JS_GetDateTime() + _getDaylightSavingTA(d); | 1067 return JS_GetDateTime() + _getDaylightSavingTA(d); |
1069 } | 1068 } |
1070 | 1069 |
1071 //JavaScript time implement End. | 1070 //JavaScript time implement End. |
OLD | NEW |