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 "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" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 const v8::FunctionCallbackInfo<v8::Value>& info) { | 234 const v8::FunctionCallbackInfo<v8::Value>& info) { |
235 const FXJSE_CLASS* lpClass = | 235 const FXJSE_CLASS* lpClass = |
236 static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); | 236 static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value()); |
237 if (!lpClass) { | 237 if (!lpClass) { |
238 return; | 238 return; |
239 } | 239 } |
240 if (info.This() == info.Holder() && lpClass->name) { | 240 if (info.This() == info.Holder() && lpClass->name) { |
241 CFX_ByteString szStringVal; | 241 CFX_ByteString szStringVal; |
242 szStringVal.Format("[object %s]", lpClass->name); | 242 szStringVal.Format("[object %s]", lpClass->name); |
243 info.GetReturnValue().Set(v8::String::NewFromUtf8( | 243 info.GetReturnValue().Set(v8::String::NewFromUtf8( |
244 info.GetIsolate(), (const FX_CHAR*)szStringVal, | 244 info.GetIsolate(), szStringVal.c_str(), v8::String::kNormalString, |
245 v8::String::kNormalString, szStringVal.GetLength())); | 245 szStringVal.GetLength())); |
246 } else { | 246 } else { |
247 v8::Local<v8::String> local_str = | 247 v8::Local<v8::String> local_str = |
248 info.This() | 248 info.This() |
249 ->ObjectProtoToString(info.GetIsolate()->GetCurrentContext()) | 249 ->ObjectProtoToString(info.GetIsolate()->GetCurrentContext()) |
250 .FromMaybe(v8::Local<v8::String>()); | 250 .FromMaybe(v8::Local<v8::String>()); |
251 info.GetReturnValue().Set(local_str); | 251 info.GetReturnValue().Set(local_str); |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, | 255 CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext, | 340 CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext, |
341 const CFX_ByteStringC& szName) { | 341 const CFX_ByteStringC& szName) { |
342 for (int count = pContext->m_rgClasses.GetSize(), i = 0; i < count; i++) { | 342 for (int count = pContext->m_rgClasses.GetSize(), i = 0; i < count; i++) { |
343 CFXJSE_Class* pClass = pContext->m_rgClasses[i]; | 343 CFXJSE_Class* pClass = pContext->m_rgClasses[i]; |
344 if (pClass->m_szClassName == szName) { | 344 if (pClass->m_szClassName == szName) { |
345 return pClass; | 345 return pClass; |
346 } | 346 } |
347 } | 347 } |
348 return NULL; | 348 return NULL; |
349 } | 349 } |
OLD | NEW |