| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2007-2009 Google, Inc. All rights reserved. | 3 * Copyright (C) 2007-2009 Google, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 return npobj->_class->enumerate(npobj, identifier, count); | 475 return npobj->_class->enumerate(npobj, identifier, count); |
| 476 | 476 |
| 477 return false; | 477 return false; |
| 478 } | 478 } |
| 479 | 479 |
| 480 bool NPN_Construct(NPP npp, NPObject* npobj, const NPVariant* args, uint32_t arg
Count, NPVariant* result) | 480 bool NPN_Construct(NPP npp, NPObject* npobj, const NPVariant* args, uint32_t arg
Count, NPVariant* result) |
| 481 { | 481 { |
| 482 if (!npobj) | 482 if (!npobj) |
| 483 return false; | 483 return false; |
| 484 | 484 |
| 485 // FIXME(estade): implement this case. | |
| 486 if (npobj->_class == npScriptObjectClass) { | 485 if (npobj->_class == npScriptObjectClass) { |
| 487 VOID_TO_NPVARIANT(*result); | 486 V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); |
| 488 return false; | 487 |
| 488 v8::HandleScope handleScope; |
| 489 v8::Handle<v8::Context> context = getV8Context(npp, npobj); |
| 490 if (context.IsEmpty()) |
| 491 return false; |
| 492 v8::Context::Scope scope(context); |
| 493 |
| 494 // Lookup the constructor function. |
| 495 v8::Handle<v8::Object> ctorObj(object->v8Object); |
| 496 if (!ctorObj->IsFunction()) |
| 497 return false; |
| 498 |
| 499 // Call the constructor. |
| 500 v8::Local<v8::Value> resultObj; |
| 501 v8::Handle<v8::Function> ctor(v8::Function::Cast(*ctorObj)); |
| 502 if (!ctor->IsNull()) { |
| 503 WebCore::V8Proxy* proxy = GetV8Proxy(npobj); |
| 504 ASSERT(proxy); |
| 505 |
| 506 // Create list of args to pass to v8. |
| 507 v8::Handle<v8::Value>* argv = listFromVariantArgs(args, argCount, np
obj); |
| 508 resultObj = proxy->NewInstance(ctor, argCount, argv); |
| 509 delete[] argv; |
| 510 } |
| 511 |
| 512 // If we had an error return false. |
| 513 if (resultObj.IsEmpty()) |
| 514 return false; |
| 515 |
| 516 // Convert the result back to an NPVariant. |
| 517 convertV8ObjectToNPVariant(resultObj, npobj, result); |
| 518 return true; |
| 489 } | 519 } |
| 490 | 520 |
| 491 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npobj->_class) && npobj->_class->constr
uct) | 521 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npobj->_class) && npobj->_class->constr
uct) |
| 492 return npobj->_class->construct(npobj, args, argCount, result); | 522 return npobj->_class->construct(npobj, args, argCount, result); |
| 493 | 523 |
| 494 return false; | 524 return false; |
| 495 } | 525 } |
| OLD | NEW |