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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/JS_Define.h" | 8 #include "../../include/javascript/JS_Define.h" |
9 #include "../../include/javascript/JS_Object.h" | 9 #include "../../include/javascript/JS_Object.h" |
10 #include "../../include/javascript/JS_Value.h" | 10 #include "../../include/javascript/JS_Value.h" |
11 #include "../../include/javascript/Document.h" | 11 #include "../../include/javascript/Document.h" |
12 | 12 |
13 /* ---------------------------- CJS_Value ---------------------------- */ | 13 /* ---------------------------- CJS_Value ---------------------------- */ |
14 | 14 |
15 CJS_Value::CJS_Value(v8::Isolate* isolate) : m_eType(VT_unknown),m_isolate(isola
te) | 15 CJS_Value::CJS_Value(v8::Isolate* isolate) : m_eType(VT_unknown),m_isolate(isola
te) |
16 { | 16 { |
17 } | 17 } |
18 CJS_Value::CJS_Value(v8::Isolate* isolate, v8::Handle<v8::Value> pValue,FXJSVALU
ETYPE t) : | 18 CJS_Value::CJS_Value(v8::Isolate* isolate, v8::Local<v8::Value> pValue,FXJSVALUE
TYPE t) : |
19 m_pValue(pValue), m_eType(t), m_isolate(isolate) | 19 m_pValue(pValue), m_eType(t), m_isolate(isolate) |
20 { | 20 { |
21 } | 21 } |
22 | 22 |
23 CJS_Value::CJS_Value(v8::Isolate* isolate, const int &iValue):m_isolate(isolate) | 23 CJS_Value::CJS_Value(v8::Isolate* isolate, const int &iValue):m_isolate(isolate) |
24 { | 24 { |
25 operator =(iValue); | 25 operator =(iValue); |
26 } | 26 } |
27 | 27 |
28 CJS_Value::CJS_Value(v8::Isolate* isolate, const bool &bValue):m_isolate(isolate
) | 28 CJS_Value::CJS_Value(v8::Isolate* isolate, const bool &bValue):m_isolate(isolate
) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 CJS_Value::CJS_Value(v8::Isolate* isolate, CJS_Array& array):m_isolate(isolate) | 70 CJS_Value::CJS_Value(v8::Isolate* isolate, CJS_Array& array):m_isolate(isolate) |
71 { | 71 { |
72 operator = (array); | 72 operator = (array); |
73 } | 73 } |
74 | 74 |
75 CJS_Value::~CJS_Value() | 75 CJS_Value::~CJS_Value() |
76 { | 76 { |
77 } | 77 } |
78 | 78 |
79 void CJS_Value::Attach(v8::Handle<v8::Value> pValue,FXJSVALUETYPE t) | 79 void CJS_Value::Attach(v8::Local<v8::Value> pValue,FXJSVALUETYPE t) |
80 { | 80 { |
81 m_pValue = pValue; | 81 m_pValue = pValue; |
82 m_eType = t; | 82 m_eType = t; |
83 } | 83 } |
84 | 84 |
85 void CJS_Value::Attach(CJS_Value *pValue) | 85 void CJS_Value::Attach(CJS_Value *pValue) |
86 { | 86 { |
87 if (pValue) | 87 if (pValue) |
88 Attach(pValue->ToV8Value(), pValue->GetType()); | 88 Attach(pValue->ToV8Value(), pValue->GetType()); |
89 } | 89 } |
90 | 90 |
91 void CJS_Value::Detach() | 91 void CJS_Value::Detach() |
92 { | 92 { |
93 » m_pValue = v8::Handle<v8::Value>(); | 93 » m_pValue = v8::Local<v8::Value>(); |
94 m_eType = VT_unknown; | 94 m_eType = VT_unknown; |
95 } | 95 } |
96 | 96 |
97 /* -----------------------------------------------------------------------------
----------- */ | 97 /* -----------------------------------------------------------------------------
----------- */ |
98 | 98 |
99 int CJS_Value::ToInt() const | 99 int CJS_Value::ToInt() const |
100 { | 100 { |
101 » return JS_ToInt32(m_pValue); | 101 » return JS_ToInt32(m_isolate, m_pValue); |
102 } | 102 } |
103 | 103 |
104 bool CJS_Value::ToBool() const | 104 bool CJS_Value::ToBool() const |
105 { | 105 { |
106 » return JS_ToBoolean(m_pValue); | 106 » return JS_ToBoolean(m_isolate, m_pValue); |
107 } | 107 } |
108 | 108 |
109 double CJS_Value::ToDouble() const | 109 double CJS_Value::ToDouble() const |
110 { | 110 { |
111 » return JS_ToNumber(m_pValue); | 111 » return JS_ToNumber(m_isolate, m_pValue); |
112 } | 112 } |
113 | 113 |
114 float CJS_Value::ToFloat() const | 114 float CJS_Value::ToFloat() const |
115 { | 115 { |
116 return (float)ToDouble(); | 116 return (float)ToDouble(); |
117 } | 117 } |
118 | 118 |
119 CJS_Object* CJS_Value::ToCJSObject() const | 119 CJS_Object* CJS_Value::ToCJSObject() const |
120 { | 120 { |
121 » v8::Handle<v8::Object>» pObj = JS_ToObject(m_pValue); | 121 » v8::Local<v8::Object>» pObj = JS_ToObject(m_isolate, m_pValue); |
122 return (CJS_Object*)JS_GetPrivate(m_isolate, pObj); | 122 return (CJS_Object*)JS_GetPrivate(m_isolate, pObj); |
123 } | 123 } |
124 | 124 |
125 v8::Handle<v8::Object> CJS_Value::ToV8Object() const | 125 v8::Local<v8::Object> CJS_Value::ToV8Object() const |
126 { | 126 { |
127 » return JS_ToObject(m_pValue); | 127 » return JS_ToObject(m_isolate, m_pValue); |
128 } | 128 } |
129 | 129 |
130 CFX_WideString CJS_Value::ToCFXWideString() const | 130 CFX_WideString CJS_Value::ToCFXWideString() const |
131 { | 131 { |
132 » return JS_ToString(m_pValue); | 132 » return JS_ToString(m_isolate, m_pValue); |
133 } | 133 } |
134 | 134 |
135 CFX_ByteString CJS_Value::ToCFXByteString() const | 135 CFX_ByteString CJS_Value::ToCFXByteString() const |
136 { | 136 { |
137 return CFX_ByteString::FromUnicode(ToCFXWideString()); | 137 return CFX_ByteString::FromUnicode(ToCFXWideString()); |
138 } | 138 } |
139 | 139 |
140 v8::Handle<v8::Value> CJS_Value::ToV8Value() const | 140 v8::Local<v8::Value> CJS_Value::ToV8Value() const |
141 { | 141 { |
142 return m_pValue; | 142 return m_pValue; |
143 } | 143 } |
144 | 144 |
145 v8::Handle<v8::Array>CJS_Value::ToV8Array() const | 145 v8::Local<v8::Array>CJS_Value::ToV8Array() const |
146 { | 146 { |
147 if (IsArrayObject()) | 147 if (IsArrayObject()) |
148 » » return v8::Handle<v8::Array>::Cast(JS_ToObject(m_pValue)); | 148 » » return v8::Local<v8::Array>::Cast(JS_ToObject(m_isolate, m_pValu
e)); |
149 » return v8::Handle<v8::Array>(); | 149 » return v8::Local<v8::Array>(); |
150 } | 150 } |
151 | 151 |
152 /* -----------------------------------------------------------------------------
----------- */ | 152 /* -----------------------------------------------------------------------------
----------- */ |
153 | 153 |
154 void CJS_Value::operator =(int iValue) | 154 void CJS_Value::operator =(int iValue) |
155 { | 155 { |
156 m_pValue = JS_NewNumber(m_isolate, iValue); | 156 m_pValue = JS_NewNumber(m_isolate, iValue); |
157 | 157 |
158 m_eType = VT_number; | 158 m_eType = VT_number; |
159 } | 159 } |
(...skipping 11 matching lines...) Expand all Loading... |
171 | 171 |
172 m_eType = VT_number; | 172 m_eType = VT_number; |
173 } | 173 } |
174 | 174 |
175 void CJS_Value::operator = (float fValue) | 175 void CJS_Value::operator = (float fValue) |
176 { | 176 { |
177 m_pValue = JS_NewNumber(m_isolate,fValue); | 177 m_pValue = JS_NewNumber(m_isolate,fValue); |
178 m_eType = VT_number; | 178 m_eType = VT_number; |
179 } | 179 } |
180 | 180 |
181 void CJS_Value::operator =(v8::Handle<v8::Object> pObj) | 181 void CJS_Value::operator =(v8::Local<v8::Object> pObj) |
182 { | 182 { |
183 | 183 |
184 m_pValue = JS_NewObject(m_isolate,pObj); | 184 m_pValue = JS_NewObject(m_isolate,pObj); |
185 | 185 |
186 m_eType = VT_fxobject; | 186 m_eType = VT_fxobject; |
187 } | 187 } |
188 | 188 |
189 void CJS_Value::operator =(CJS_Object * pObj) | 189 void CJS_Value::operator =(CJS_Object * pObj) |
190 { | 190 { |
191 if (pObj) | 191 if (pObj) |
(...skipping 22 matching lines...) Expand all Loading... |
214 m_eType = VT_null; | 214 m_eType = VT_null; |
215 } | 215 } |
216 | 216 |
217 void CJS_Value::operator = (FX_LPCSTR pStr) | 217 void CJS_Value::operator = (FX_LPCSTR pStr) |
218 { | 218 { |
219 operator = (CFX_WideString::FromLocal(pStr).c_str()); | 219 operator = (CFX_WideString::FromLocal(pStr).c_str()); |
220 } | 220 } |
221 | 221 |
222 void CJS_Value::operator = (CJS_Array & array) | 222 void CJS_Value::operator = (CJS_Array & array) |
223 { | 223 { |
224 » m_pValue = JS_NewObject2(m_isolate,(v8::Handle<v8::Array>)array); | 224 » m_pValue = JS_NewObject2(m_isolate,(v8::Local<v8::Array>)array); |
225 | 225 |
226 m_eType = VT_object; | 226 m_eType = VT_object; |
227 } | 227 } |
228 | 228 |
229 void CJS_Value::operator = (CJS_Date & date) | 229 void CJS_Value::operator = (CJS_Date & date) |
230 { | 230 { |
231 m_pValue = JS_NewDate(m_isolate, (double)date); | 231 m_pValue = JS_NewDate(m_isolate, (double)date); |
232 | 232 |
233 m_eType = VT_date; | 233 m_eType = VT_date; |
234 } | 234 } |
235 | 235 |
236 void CJS_Value::operator = (CJS_Value value) | 236 void CJS_Value::operator = (CJS_Value value) |
237 { | 237 { |
238 m_pValue = value.ToV8Value(); | 238 m_pValue = value.ToV8Value(); |
239 | 239 |
240 m_eType = value.m_eType; | 240 m_eType = value.m_eType; |
| 241 m_isolate = value.m_isolate; |
241 } | 242 } |
242 | 243 |
243 /* -----------------------------------------------------------------------------
----------- */ | 244 /* -----------------------------------------------------------------------------
----------- */ |
244 | 245 |
245 FXJSVALUETYPE CJS_Value::GetType() const | 246 FXJSVALUETYPE CJS_Value::GetType() const |
246 { | 247 { |
247 if(m_pValue.IsEmpty()) return VT_unknown; | 248 if(m_pValue.IsEmpty()) return VT_unknown; |
248 if(m_pValue->IsString()) return VT_string; | 249 if(m_pValue->IsString()) return VT_string; |
249 if(m_pValue->IsNumber()) return VT_number; | 250 if(m_pValue->IsNumber()) return VT_number; |
250 if(m_pValue->IsBoolean()) return VT_boolean; | 251 if(m_pValue->IsBoolean()) return VT_boolean; |
(...skipping 14 matching lines...) Expand all Loading... |
265 { | 266 { |
266 if(m_pValue.IsEmpty()) return FALSE; | 267 if(m_pValue.IsEmpty()) return FALSE; |
267 return m_pValue->IsDate(); | 268 return m_pValue->IsDate(); |
268 } | 269 } |
269 | 270 |
270 //CJS_Value::operator CJS_Array() | 271 //CJS_Value::operator CJS_Array() |
271 FX_BOOL CJS_Value::ConvertToArray(CJS_Array &array) const | 272 FX_BOOL CJS_Value::ConvertToArray(CJS_Array &array) const |
272 { | 273 { |
273 if (IsArrayObject()) | 274 if (IsArrayObject()) |
274 { | 275 { |
275 » » array.Attach(JS_ToArray(m_pValue)); | 276 » » array.Attach(JS_ToArray(m_isolate, m_pValue)); |
276 return TRUE; | 277 return TRUE; |
277 } | 278 } |
278 | 279 |
279 return FALSE; | 280 return FALSE; |
280 } | 281 } |
281 | 282 |
282 FX_BOOL CJS_Value::ConvertToDate(CJS_Date &date) const | 283 FX_BOOL CJS_Value::ConvertToDate(CJS_Date &date) const |
283 { | 284 { |
284 // if (GetType() == VT_date) | 285 // if (GetType() == VT_date) |
285 // { | 286 // { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 ASSERT(m_bIsSetting); | 454 ASSERT(m_bIsSetting); |
454 ConvertToDate(date); | 455 ConvertToDate(date); |
455 } | 456 } |
456 | 457 |
457 void CJS_PropValue::operator<<(CJS_Date &date) | 458 void CJS_PropValue::operator<<(CJS_Date &date) |
458 { | 459 { |
459 ASSERT(!m_bIsSetting); | 460 ASSERT(!m_bIsSetting); |
460 CJS_Value::operator=(date); | 461 CJS_Value::operator=(date); |
461 } | 462 } |
462 | 463 |
463 CJS_PropValue::operator v8::Handle<v8::Value>() const | 464 CJS_PropValue::operator v8::Local<v8::Value>() const |
464 { | 465 { |
465 return m_pValue; | 466 return m_pValue; |
466 } | 467 } |
467 | 468 |
468 /* ======================================== CJS_Array ==========================
=============== */ | 469 /* ======================================== CJS_Array ==========================
=============== */ |
469 CJS_Array::CJS_Array(v8::Isolate* isolate):m_isolate(isolate) | 470 CJS_Array::CJS_Array(v8::Isolate* isolate):m_isolate(isolate) |
470 { | 471 { |
471 } | 472 } |
472 | 473 |
473 CJS_Array::~CJS_Array() | 474 CJS_Array::~CJS_Array() |
474 { | 475 { |
475 } | 476 } |
476 | 477 |
477 void CJS_Array::Attach(v8::Handle<v8::Array> pArray) | 478 void CJS_Array::Attach(v8::Local<v8::Array> pArray) |
478 { | 479 { |
479 m_pArray = pArray; | 480 m_pArray = pArray; |
480 } | 481 } |
481 | 482 |
482 FX_BOOL CJS_Array::IsAttached() | 483 FX_BOOL CJS_Array::IsAttached() |
483 { | 484 { |
484 return FALSE; | 485 return FALSE; |
485 } | 486 } |
486 | 487 |
487 void CJS_Array::GetElement(unsigned index,CJS_Value &value) | 488 void CJS_Array::GetElement(unsigned index,CJS_Value &value) |
488 { | 489 { |
489 if (m_pArray.IsEmpty()) | 490 if (m_pArray.IsEmpty()) |
490 return; | 491 return; |
491 » v8::Handle<v8::Value> p = JS_GetArrayElemnet(m_pArray,index); | 492 » v8::Local<v8::Value> p = JS_GetArrayElement(m_isolate, m_pArray,index); |
492 value.Attach(p,VT_object); | 493 value.Attach(p,VT_object); |
493 } | 494 } |
494 | 495 |
495 void CJS_Array::SetElement(unsigned index,CJS_Value value) | 496 void CJS_Array::SetElement(unsigned index,CJS_Value value) |
496 { | 497 { |
497 if (m_pArray.IsEmpty()) | 498 if (m_pArray.IsEmpty()) |
498 m_pArray = JS_NewArray(m_isolate); | 499 m_pArray = JS_NewArray(m_isolate); |
499 | 500 |
500 » JS_PutArrayElement(m_pArray, index, value.ToV8Value(), value.GetType()); | 501 » JS_PutArrayElement(m_isolate, m_pArray, index, value.ToV8Value(), value.
GetType()); |
501 } | 502 } |
502 | 503 |
503 int CJS_Array::GetLength() | 504 int CJS_Array::GetLength() |
504 { | 505 { |
505 if (m_pArray.IsEmpty()) | 506 if (m_pArray.IsEmpty()) |
506 return 0; | 507 return 0; |
507 return JS_GetArrayLength(m_pArray); | 508 return JS_GetArrayLength(m_pArray); |
508 } | 509 } |
509 | 510 |
510 CJS_Array:: operator v8::Handle<v8::Array>() | 511 CJS_Array:: operator v8::Local<v8::Array>() |
511 { | 512 { |
512 if (m_pArray.IsEmpty()) | 513 if (m_pArray.IsEmpty()) |
513 m_pArray = JS_NewArray(m_isolate); | 514 m_pArray = JS_NewArray(m_isolate); |
514 | 515 |
515 return m_pArray; | 516 return m_pArray; |
516 } | 517 } |
517 | 518 |
518 /* ======================================== CJS_Date ===========================
============== */ | 519 /* ======================================== CJS_Date ===========================
============== */ |
519 | 520 |
520 CJS_Date::CJS_Date(v8::Isolate* isolate) :m_isolate(isolate) | 521 CJS_Date::CJS_Date(v8::Isolate* isolate) :m_isolate(isolate) |
(...skipping 17 matching lines...) Expand all Loading... |
538 return JS_MakeDate(JS_MakeDay(year,mon,day), JS_MakeTime(hour,min,sec,ms
)); | 539 return JS_MakeDate(JS_MakeDay(year,mon,day), JS_MakeTime(hour,min,sec,ms
)); |
539 } | 540 } |
540 | 541 |
541 CJS_Date::~CJS_Date() | 542 CJS_Date::~CJS_Date() |
542 { | 543 { |
543 } | 544 } |
544 | 545 |
545 FX_BOOL CJS_Date::IsValidDate() | 546 FX_BOOL CJS_Date::IsValidDate() |
546 { | 547 { |
547 if(m_pDate.IsEmpty()) return FALSE; | 548 if(m_pDate.IsEmpty()) return FALSE; |
548 » return !JS_PortIsNan(JS_ToNumber(m_pDate)); | 549 » return !JS_PortIsNan(JS_ToNumber(m_isolate, m_pDate)); |
549 } | 550 } |
550 | 551 |
551 void CJS_Date::Attach(v8::Handle<v8::Value> pDate) | 552 void CJS_Date::Attach(v8::Local<v8::Value> pDate) |
552 { | 553 { |
553 m_pDate = pDate; | 554 m_pDate = pDate; |
554 } | 555 } |
555 | 556 |
556 int CJS_Date::GetYear() | 557 int CJS_Date::GetYear() |
557 { | 558 { |
558 if (IsValidDate()) | 559 if (IsValidDate()) |
559 » » return JS_GetYearFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); | 560 » » return JS_GetYearFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_
pDate))); |
560 | 561 |
561 return 0; | 562 return 0; |
562 } | 563 } |
563 | 564 |
564 void CJS_Date::SetYear(int iYear) | 565 void CJS_Date::SetYear(int iYear) |
565 { | 566 { |
566 double date = MakeDate(iYear,GetMonth(),GetDay(),GetHours(),GetMinutes()
,GetSeconds(),0); | 567 double date = MakeDate(iYear,GetMonth(),GetDay(),GetHours(),GetMinutes()
,GetSeconds(),0); |
567 JS_ValueCopy(m_pDate, JS_NewDate(m_isolate,date)); | 568 JS_ValueCopy(m_pDate, JS_NewDate(m_isolate,date)); |
568 } | 569 } |
569 | 570 |
570 int CJS_Date::GetMonth() | 571 int CJS_Date::GetMonth() |
571 { | 572 { |
572 if (IsValidDate()) | 573 if (IsValidDate()) |
573 » » return JS_GetMonthFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); | 574 » » return JS_GetMonthFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m
_pDate))); |
574 | 575 |
575 return 0; | 576 return 0; |
576 } | 577 } |
577 | 578 |
578 void CJS_Date::SetMonth(int iMonth) | 579 void CJS_Date::SetMonth(int iMonth) |
579 { | 580 { |
580 | 581 |
581 double date = MakeDate(GetYear(),iMonth,GetDay(),GetHours(),GetMinutes()
,GetSeconds(),0); | 582 double date = MakeDate(GetYear(),iMonth,GetDay(),GetHours(),GetMinutes()
,GetSeconds(),0); |
582 JS_ValueCopy(m_pDate, JS_NewDate(m_isolate,date)); | 583 JS_ValueCopy(m_pDate, JS_NewDate(m_isolate,date)); |
583 | 584 |
584 } | 585 } |
585 | 586 |
586 int CJS_Date::GetDay() | 587 int CJS_Date::GetDay() |
587 { | 588 { |
588 if (IsValidDate()) | 589 if (IsValidDate()) |
589 » » return JS_GetDayFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); | 590 » » return JS_GetDayFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_p
Date))); |
590 | 591 |
591 return 0; | 592 return 0; |
592 } | 593 } |
593 | 594 |
594 void CJS_Date::SetDay(int iDay) | 595 void CJS_Date::SetDay(int iDay) |
595 { | 596 { |
596 | 597 |
597 double date = MakeDate(GetYear(),GetMonth(),iDay,GetHours(),GetMinutes()
,GetSeconds(),0); | 598 double date = MakeDate(GetYear(),GetMonth(),iDay,GetHours(),GetMinutes()
,GetSeconds(),0); |
598 JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); | 599 JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); |
599 | 600 |
600 } | 601 } |
601 | 602 |
602 int CJS_Date::GetHours() | 603 int CJS_Date::GetHours() |
603 { | 604 { |
604 if (IsValidDate()) | 605 if (IsValidDate()) |
605 » » return JS_GetHourFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); | 606 » » return JS_GetHourFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_
pDate))); |
606 | 607 |
607 return 0; | 608 return 0; |
608 } | 609 } |
609 | 610 |
610 void CJS_Date::SetHours(int iHours) | 611 void CJS_Date::SetHours(int iHours) |
611 { | 612 { |
612 double date = MakeDate(GetYear(),GetMonth(),GetDay(),iHours,GetMinutes()
,GetSeconds(),0); | 613 double date = MakeDate(GetYear(),GetMonth(),GetDay(),iHours,GetMinutes()
,GetSeconds(),0); |
613 JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); | 614 JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); |
614 } | 615 } |
615 | 616 |
616 int CJS_Date::GetMinutes() | 617 int CJS_Date::GetMinutes() |
617 { | 618 { |
618 if (IsValidDate()) | 619 if (IsValidDate()) |
619 » » return JS_GetMinFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); | 620 » » return JS_GetMinFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_p
Date))); |
620 | 621 |
621 return 0; | 622 return 0; |
622 } | 623 } |
623 | 624 |
624 void CJS_Date::SetMinutes(int minutes) | 625 void CJS_Date::SetMinutes(int minutes) |
625 { | 626 { |
626 double date = MakeDate(GetYear(),GetMonth(),GetDay(),GetHours(),minutes,
GetSeconds(),0); | 627 double date = MakeDate(GetYear(),GetMonth(),GetDay(),GetHours(),minutes,
GetSeconds(),0); |
627 JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); | 628 JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); |
628 } | 629 } |
629 | 630 |
630 int CJS_Date::GetSeconds() | 631 int CJS_Date::GetSeconds() |
631 { | 632 { |
632 if (IsValidDate()) | 633 if (IsValidDate()) |
633 » » return JS_GetSecFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); | 634 » » return JS_GetSecFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_p
Date))); |
634 | 635 |
635 return 0; | 636 return 0; |
636 } | 637 } |
637 | 638 |
638 void CJS_Date::SetSeconds(int seconds) | 639 void CJS_Date::SetSeconds(int seconds) |
639 { | 640 { |
640 double date = MakeDate(GetYear(),GetMonth(),GetDay(),GetHours(),GetMinut
es(),seconds,0); | 641 double date = MakeDate(GetYear(),GetMonth(),GetDay(),GetHours(),GetMinut
es(),seconds,0); |
641 JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); | 642 JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); |
642 } | 643 } |
643 | 644 |
644 CJS_Date::operator v8::Handle<v8::Value>() | 645 CJS_Date::operator v8::Local<v8::Value>() |
645 { | 646 { |
646 return m_pDate; | 647 return m_pDate; |
647 } | 648 } |
648 | 649 |
649 CJS_Date::operator double() const | 650 CJS_Date::operator double() const |
650 { | 651 { |
651 if(m_pDate.IsEmpty()) | 652 if(m_pDate.IsEmpty()) |
652 return 0.0; | 653 return 0.0; |
653 » return JS_ToNumber(m_pDate); | 654 » return JS_ToNumber(m_isolate, m_pDate); |
654 } | 655 } |
655 | 656 |
656 CFX_WideString CJS_Date::ToString() const | 657 CFX_WideString CJS_Date::ToString() const |
657 { | 658 { |
658 if(m_pDate.IsEmpty()) | 659 if(m_pDate.IsEmpty()) |
659 return L""; | 660 return L""; |
660 » return JS_ToString(m_pDate); | 661 » return JS_ToString(m_isolate, m_pDate); |
661 } | 662 } |
OLD | NEW |