| 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 22 matching lines...) Expand all Loading... |
| 33 public: | 33 public: |
| 34 CJS_PrivateData():ObjDefID(-1), pPrivate(NULL) {} | 34 CJS_PrivateData():ObjDefID(-1), pPrivate(NULL) {} |
| 35 int ObjDefID; | 35 int ObjDefID; |
| 36 void* pPrivate; | 36 void* pPrivate; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 | 39 |
| 40 class CJS_ObjDefintion | 40 class CJS_ObjDefintion |
| 41 { | 41 { |
| 42 public: | 42 public: |
| 43 » CJS_ObjDefintion(v8::Isolate* isolate, const wchar_t* sObjName, FXJSOBJT
YPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned b
ApplyNew): | 43 » CJS_ObjDefintion(v8::Isolate* isolate, const wchar_t* sObjName, FXJSOBJT
YPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor): |
| 44 » objName(sObjName), objType(eObjType), m_pConstructor(pConstructor), m_
pDestructor(pDestructor),m_bApplyNew(bApplyNew),m_bSetAsGlobalObject(FALSE) | 44 » objName(sObjName), objType(eObjType), m_pConstructor(pConstructor), m_
pDestructor(pDestructor),m_bSetAsGlobalObject(FALSE) |
| 45 { | 45 { |
| 46 v8::Isolate::Scope isolate_scope(isolate); | 46 v8::Isolate::Scope isolate_scope(isolate); |
| 47 v8::HandleScope handle_scope(isolate); | 47 v8::HandleScope handle_scope(isolate); |
| 48 | 48 |
| 49 v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate
::New(isolate); | 49 v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate
::New(isolate); |
| 50 objTemplate->SetInternalFieldCount(2); | 50 objTemplate->SetInternalFieldCount(2); |
| 51 m_objTemplate.Reset(isolate, objTemplate); | 51 m_objTemplate.Reset(isolate, objTemplate); |
| 52 | 52 |
| 53 //Document as the global object. | 53 //Document as the global object. |
| 54 if(FXSYS_wcscmp(sObjName, L"Document") == 0) | 54 if(FXSYS_wcscmp(sObjName, L"Document") == 0) |
| 55 { | 55 { |
| 56 m_bSetAsGlobalObject = TRUE; | 56 m_bSetAsGlobalObject = TRUE; |
| 57 } | 57 } |
| 58 | 58 |
| 59 } | 59 } |
| 60 ~CJS_ObjDefintion() | 60 ~CJS_ObjDefintion() |
| 61 { | 61 { |
| 62 m_objTemplate.Reset(); | 62 m_objTemplate.Reset(); |
| 63 m_StaticObj.Reset(); | 63 m_StaticObj.Reset(); |
| 64 } | 64 } |
| 65 public: | 65 public: |
| 66 const wchar_t* objName; | 66 const wchar_t* objName; |
| 67 FXJSOBJTYPE objType; | 67 FXJSOBJTYPE objType; |
| 68 LP_CONSTRUCTOR m_pConstructor; | 68 LP_CONSTRUCTOR m_pConstructor; |
| 69 LP_DESTRUCTOR m_pDestructor; | 69 LP_DESTRUCTOR m_pDestructor; |
| 70 unsigned m_bApplyNew; | |
| 71 FX_BOOL m_bSetAsGlobalObject; | 70 FX_BOOL m_bSetAsGlobalObject; |
| 72 | 71 |
| 73 v8::Global<v8::ObjectTemplate> m_objTemplate; | 72 v8::Global<v8::ObjectTemplate> m_objTemplate; |
| 74 v8::Global<v8::Object> m_StaticObj; | 73 v8::Global<v8::Object> m_StaticObj; |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE e
ObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApply
New) | 76 int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE e
ObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor) |
| 78 { | 77 { |
| 79 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 78 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; |
| 80 v8::Isolate::Scope isolate_scope(isolate); | 79 v8::Isolate::Scope isolate_scope(isolate); |
| 81 v8::HandleScope handle_scope(isolate); | 80 v8::HandleScope handle_scope(isolate); |
| 82 CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1); | 81 CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(1); |
| 83 if(!pArray) | 82 if(!pArray) |
| 84 { | 83 { |
| 85 pArray = FX_NEW CFX_PtrArray(); | 84 pArray = FX_NEW CFX_PtrArray(); |
| 86 isolate->SetData(1, pArray); | 85 isolate->SetData(1, pArray); |
| 87 } | 86 } |
| 88 » CJS_ObjDefintion* pObjDef = FX_NEW CJS_ObjDefintion(isolate, sObjName, e
ObjType, pConstructor, pDestructor, bApplyNew); | 87 » CJS_ObjDefintion* pObjDef = FX_NEW CJS_ObjDefintion(isolate, sObjName, e
ObjType, pConstructor, pDestructor); |
| 89 pArray->Add(pObjDef); | 88 pArray->Add(pObjDef); |
| 90 return pArray->GetSize()-1; | 89 return pArray->GetSize()-1; |
| 91 } | 90 } |
| 92 | 91 |
| 93 int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* s
MethodName, v8::FunctionCallback pMethodCall) | 92 int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* s
MethodName, v8::FunctionCallback pMethodCall) |
| 94 { | 93 { |
| 95 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 94 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; |
| 96 v8::Isolate::Scope isolate_scope(isolate); | 95 v8::Isolate::Scope isolate_scope(isolate); |
| 97 v8::HandleScope handle_scope(isolate); | 96 v8::HandleScope handle_scope(isolate); |
| 98 | 97 |
| (...skipping 963 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 |