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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // FIXME(mbelshe): comments on why use malloc and free. | 54 // FIXME(mbelshe): comments on why use malloc and free. |
55 static NPObject* AllocV8NPObject(NPP, NPClass*) | 55 static NPObject* AllocV8NPObject(NPP, NPClass*) |
56 { | 56 { |
57 return static_cast<NPObject*>(malloc(sizeof(V8NPObject))); | 57 return static_cast<NPObject*>(malloc(sizeof(V8NPObject))); |
58 } | 58 } |
59 | 59 |
60 static void FreeV8NPObject(NPObject* npobj) | 60 static void FreeV8NPObject(NPObject* npobj) |
61 { | 61 { |
62 V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); | 62 V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); |
63 #ifndef NDEBUG | 63 #ifndef NDEBUG |
64 V8GCController::unregisterGlobalHandle(object, object->v8Object); | 64 WebCore::V8GCController::unregisterGlobalHandle(object, object->v8Object); |
65 #endif | 65 #endif |
66 object->v8Object.Dispose(); | 66 object->v8Object.Dispose(); |
67 free(object); | 67 free(object); |
68 } | 68 } |
69 | 69 |
70 static v8::Handle<v8::Value>* listFromVariantArgs(const NPVariant* args, | 70 static v8::Handle<v8::Value>* listFromVariantArgs(const NPVariant* args, |
71 uint32_t argCount, | 71 uint32_t argCount, |
72 NPObject *owner) | 72 NPObject *owner) |
73 { | 73 { |
74 v8::Handle<v8::Value>* argv = new v8::Handle<v8::Value>[argCount]; | 74 v8::Handle<v8::Value>* argv = new v8::Handle<v8::Value>[argCount]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 object->GetInternalField(V8Custom::kDOMWrapperTypeIndex)->Uint32Value()
== V8ClassIndex::NPOBJECT) { | 107 object->GetInternalField(V8Custom::kDOMWrapperTypeIndex)->Uint32Value()
== V8ClassIndex::NPOBJECT) { |
108 | 108 |
109 NPObject* rv = V8Proxy::convertToNativeObject<NPObject>(V8ClassIndex::NP
OBJECT, object); | 109 NPObject* rv = V8Proxy::convertToNativeObject<NPObject>(V8ClassIndex::NP
OBJECT, object); |
110 NPN_RetainObject(rv); | 110 NPN_RetainObject(rv); |
111 return rv; | 111 return rv; |
112 } | 112 } |
113 | 113 |
114 V8NPObject* obj = reinterpret_cast<V8NPObject*>(NPN_CreateObject(npp, &V8NPO
bjectClass)); | 114 V8NPObject* obj = reinterpret_cast<V8NPObject*>(NPN_CreateObject(npp, &V8NPO
bjectClass)); |
115 obj->v8Object = v8::Persistent<v8::Object>::New(object); | 115 obj->v8Object = v8::Persistent<v8::Object>::New(object); |
116 #ifndef NDEBUG | 116 #ifndef NDEBUG |
117 V8GCController::registerGlobalHandle(WebCore::NPOBJECT, obj, obj->v8Object); | 117 WebCore::V8GCController::registerGlobalHandle(WebCore::NPOBJECT, obj, obj->v
8Object); |
118 #endif | 118 #endif |
119 obj->rootObject = root; | 119 obj->rootObject = root; |
120 return reinterpret_cast<NPObject*>(obj); | 120 return reinterpret_cast<NPObject*>(obj); |
121 } | 121 } |
122 | 122 |
123 bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, | 123 bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, |
124 const NPVariant *args, uint32_t argCount, NPVariant *result) | 124 const NPVariant *args, uint32_t argCount, NPVariant *result) |
125 { | 125 { |
126 if (!npobj) | 126 if (!npobj) |
127 return false; | 127 return false; |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 // Convert the result back to an NPVariant. | 519 // Convert the result back to an NPVariant. |
520 convertV8ObjectToNPVariant(resultObj, npobj, result); | 520 convertV8ObjectToNPVariant(resultObj, npobj, result); |
521 return true; | 521 return true; |
522 } | 522 } |
523 | 523 |
524 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npobj->_class) && npobj->_class->constr
uct) | 524 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npobj->_class) && npobj->_class->constr
uct) |
525 return npobj->_class->construct(npobj, args, argCount, result); | 525 return npobj->_class->construct(npobj, args, argCount, result); |
526 | 526 |
527 return false; | 527 return false; |
528 } | 528 } |
OLD | NEW |