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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 v8Context->SetEmbedderData(1, ptr); | 244 v8Context->SetEmbedderData(1, ptr); |
245 | 245 |
246 CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); | 246 CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
247 if(!pArray) return; | 247 if(!pArray) return; |
248 | 248 |
249 for(int i=0; i<pArray->GetSize(); i++) | 249 for(int i=0; i<pArray->GetSize(); i++) |
250 { | 250 { |
251 CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i); | 251 CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i); |
252 CFX_WideString ws = CFX_WideString(pObjDef->objName); | 252 CFX_WideString ws = CFX_WideString(pObjDef->objName); |
253 CFX_ByteString bs = ws.UTF8Encode(); | 253 CFX_ByteString bs = ws.UTF8Encode(); |
254 » » v8::Handle<v8::String> objName = v8::String::NewFromUtf8(isolate ,(FX_LPCSTR)bs, v8::String::kNormalString, bs.GetLength()); | 254 v8::Handle<v8::String> objName = v8::String::NewFromUtf8(isolate, bs.c_s tr(), v8::String::kNormalString, bs.GetLength()); |
brucedawson
2014/12/30 23:13:02
Indent, times four in this file.
| |
255 | 255 |
256 | 256 |
257 if(pObjDef->objType == JS_DYNAMIC) | 257 if(pObjDef->objType == JS_DYNAMIC) |
258 { | 258 { |
259 //Document is set as global object, need to construct it first. | 259 //Document is set as global object, need to construct it first. |
260 if(ws.Equal(L"Document")) | 260 if(ws.Equal(L"Document")) |
261 { | 261 { |
262 | 262 |
263 CJS_PrivateData* pPrivateData = FX_NEW CJS_Priva teData; | 263 CJS_PrivateData* pPrivateData = FX_NEW CJS_Priva teData; |
264 pPrivateData->ObjDefID = i; | 264 pPrivateData->ObjDefID = i; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 int JS_Parse(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror) | 317 int JS_Parse(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror) |
318 { | 318 { |
319 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 319 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; |
320 v8::Isolate::Scope isolate_scope(isolate); | 320 v8::Isolate::Scope isolate_scope(isolate); |
321 v8::TryCatch try_catch; | 321 v8::TryCatch try_catch; |
322 | 322 |
323 CFX_WideString wsScript(script); | 323 CFX_WideString wsScript(script); |
324 CFX_ByteString bsScript = wsScript.UTF8Encode(); | 324 CFX_ByteString bsScript = wsScript.UTF8Encode(); |
325 | 325 |
326 | 326 |
327 » v8::Handle<v8::Script> compiled_script = v8::Script::Compile(v8::String: :NewFromUtf8(isolate,(FX_LPCSTR)bsScript,v8::String::kNormalString, bsScript.Get Length())); | 327 v8::Handle<v8::Script> compiled_script = v8::Script::Compile(v8::String::New FromUtf8(isolate, bsScript.c_str(), v8::String::kNormalString, bsScript.GetLengt h())); |
328 if (compiled_script.IsEmpty()) { | 328 if (compiled_script.IsEmpty()) { |
329 v8::String::Utf8Value error(try_catch.Exception()); | 329 v8::String::Utf8Value error(try_catch.Exception()); |
330 return -1; | 330 return -1; |
331 } | 331 } |
332 return 0; | 332 return 0; |
333 } | 333 } |
334 | 334 |
335 int JS_Execute(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t * script, long length, FXJSErr* perror) | 335 int JS_Execute(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t * script, long length, FXJSErr* perror) |
336 { | 336 { |
337 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 337 v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; |
338 v8::Isolate::Scope isolate_scope(isolate); | 338 v8::Isolate::Scope isolate_scope(isolate); |
339 v8::TryCatch try_catch; | 339 v8::TryCatch try_catch; |
340 | 340 |
341 CFX_WideString wsScript(script); | 341 CFX_WideString wsScript(script); |
342 CFX_ByteString bsScript = wsScript.UTF8Encode(); | 342 CFX_ByteString bsScript = wsScript.UTF8Encode(); |
343 | 343 |
344 » v8::Handle<v8::Script> compiled_script = v8::Script::Compile(v8::String: :NewFromUtf8(isolate,(FX_LPCSTR)bsScript,v8::String::kNormalString, bsScript.Get Length())); | 344 v8::Handle<v8::Script> compiled_script = v8::Script::Compile(v8::String::New FromUtf8(isolate, bsScript.c_str(), v8::String::kNormalString, bsScript.GetLengt h())); |
345 if (compiled_script.IsEmpty()) { | 345 if (compiled_script.IsEmpty()) { |
346 v8::String::Utf8Value error(try_catch.Exception()); | 346 v8::String::Utf8Value error(try_catch.Exception()); |
347 return -1; | 347 return -1; |
348 } | 348 } |
349 | 349 |
350 v8::Handle<v8::Value> result = compiled_script->Run(); | 350 v8::Handle<v8::Value> result = compiled_script->Run(); |
351 if (result.IsEmpty()) { | 351 if (result.IsEmpty()) { |
352 v8::String::Utf8Value error(try_catch.Exception()); | 352 v8::String::Utf8Value error(try_catch.Exception()); |
353 return -1; | 353 return -1; |
354 } | 354 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 v8::Handle<v8::Value> JS_GetObjectValue(v8::Handle<v8::Object> pObj) | 546 v8::Handle<v8::Value> JS_GetObjectValue(v8::Handle<v8::Object> pObj) |
547 { | 547 { |
548 return pObj; | 548 return pObj; |
549 } | 549 } |
550 | 550 |
551 v8::Handle<v8::String> WSToJSString(IJS_Runtime* pJSRuntime, const wchar_t* Prop ertyName, int Len = -1) | 551 v8::Handle<v8::String> WSToJSString(IJS_Runtime* pJSRuntime, const wchar_t* Prop ertyName, int Len = -1) |
552 { | 552 { |
553 CFX_WideString ws = CFX_WideString(PropertyName,Len); | 553 CFX_WideString ws = CFX_WideString(PropertyName,Len); |
554 CFX_ByteString bs = ws.UTF8Encode(); | 554 CFX_ByteString bs = ws.UTF8Encode(); |
555 if(!pJSRuntime) pJSRuntime = v8::Isolate::GetCurrent(); | 555 if(!pJSRuntime) pJSRuntime = v8::Isolate::GetCurrent(); |
556 » return v8::String::NewFromUtf8(pJSRuntime, (FX_LPCSTR)bs); | 556 return v8::String::NewFromUtf8(pJSRuntime, bs.c_str()); |
557 } | 557 } |
558 | 558 |
559 v8::Handle<v8::Value> JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Handle<v8 ::Object> pObj,const wchar_t* PropertyName) | 559 v8::Handle<v8::Value> JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Handle<v8 ::Object> pObj,const wchar_t* PropertyName) |
560 { | 560 { |
561 if(pObj.IsEmpty()) return v8::Handle<v8::Value>(); | 561 if(pObj.IsEmpty()) return v8::Handle<v8::Value>(); |
562 return pObj->Get(WSToJSString(pJSRuntime,PropertyName)); | 562 return pObj->Get(WSToJSString(pJSRuntime,PropertyName)); |
563 } | 563 } |
564 | 564 |
565 v8::Handle<v8::Array> JS_GetObjectElementNames(v8::Handle<v8::Object> pObj) | 565 v8::Handle<v8::Array> JS_GetObjectElementNames(v8::Handle<v8::Object> pObj) |
566 { | 566 { |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 { | 1031 { |
1032 return d != d; | 1032 return d != d; |
1033 } | 1033 } |
1034 | 1034 |
1035 double JS_LocalTime(double d) | 1035 double JS_LocalTime(double d) |
1036 { | 1036 { |
1037 return JS_GetDateTime() + _getDaylightSavingTA(d); | 1037 return JS_GetDateTime() + _getDaylightSavingTA(d); |
1038 } | 1038 } |
1039 | 1039 |
1040 //JavaScript time implement End. | 1040 //JavaScript time implement End. |
OLD | NEW |