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, 2008, 2009 Google, Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008, 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "wtf/OwnPtr.h" | 44 #include "wtf/OwnPtr.h" |
45 | 45 |
46 #include <stdio.h> | 46 #include <stdio.h> |
47 #include "wtf/StringExtras.h" | 47 #include "wtf/StringExtras.h" |
48 #include "wtf/text/WTFString.h" | 48 #include "wtf/text/WTFString.h" |
49 | 49 |
50 using namespace WebCore; | 50 using namespace WebCore; |
51 | 51 |
52 namespace WebCore { | 52 namespace WebCore { |
53 | 53 |
54 WrapperTypeInfo* npObjectTypeInfo() | 54 const WrapperTypeInfo* npObjectTypeInfo() |
55 { | 55 { |
56 static WrapperTypeInfo typeInfo = { 0, 0, 0, 0, 0, 0, 0, WrapperTypeObjectPr
ototype }; | 56 static const WrapperTypeInfo typeInfo = { 0, 0, 0, 0, 0, 0, 0, WrapperTypeOb
jectPrototype }; |
57 return &typeInfo; | 57 return &typeInfo; |
58 } | 58 } |
59 | 59 |
60 // FIXME: Comments on why use malloc and free. | 60 // FIXME: Comments on why use malloc and free. |
61 static NPObject* allocV8NPObject(NPP, NPClass*) | 61 static NPObject* allocV8NPObject(NPP, NPClass*) |
62 { | 62 { |
63 return static_cast<NPObject*>(malloc(sizeof(V8NPObject))); | 63 return static_cast<NPObject*>(malloc(sizeof(V8NPObject))); |
64 } | 64 } |
65 | 65 |
66 static void freeV8NPObject(NPObject* npObject) | 66 static void freeV8NPObject(NPObject* npObject) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 NPObject* v8ObjectToNPObject(v8::Handle<v8::Object> object) | 112 NPObject* v8ObjectToNPObject(v8::Handle<v8::Object> object) |
113 { | 113 { |
114 return reinterpret_cast<NPObject*>(object->GetAlignedPointerFromInternalFiel
d(v8DOMWrapperObjectIndex)); | 114 return reinterpret_cast<NPObject*>(object->GetAlignedPointerFromInternalFiel
d(v8DOMWrapperObjectIndex)); |
115 } | 115 } |
116 | 116 |
117 NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, DOMWind
ow* root, v8::Isolate* isolate) | 117 NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, DOMWind
ow* root, v8::Isolate* isolate) |
118 { | 118 { |
119 // Check to see if this object is already wrapped. | 119 // Check to see if this object is already wrapped. |
120 if (object->InternalFieldCount() == npObjectInternalFieldCount) { | 120 if (object->InternalFieldCount() == npObjectInternalFieldCount) { |
121 WrapperTypeInfo* typeInfo = static_cast<WrapperTypeInfo*>(object->GetAli
gnedPointerFromInternalField(v8DOMWrapperTypeIndex)); | 121 const WrapperTypeInfo* typeInfo = static_cast<const WrapperTypeInfo*>(ob
ject->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex)); |
122 if (typeInfo == npObjectTypeInfo()) { | 122 if (typeInfo == npObjectTypeInfo()) { |
123 NPObject* returnValue = v8ObjectToNPObject(object); | 123 NPObject* returnValue = v8ObjectToNPObject(object); |
124 _NPN_RetainObject(returnValue); | 124 _NPN_RetainObject(returnValue); |
125 return returnValue; | 125 return returnValue; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 V8NPObjectVector* objectVector = 0; | 129 V8NPObjectVector* objectVector = 0; |
130 if (V8PerContextData* perContextData = V8PerContextData::from(object->Creati
onContext())) { | 130 if (V8PerContextData* perContextData = V8PerContextData::from(object->Creati
onContext())) { |
131 int v8ObjectHash = object->GetIdentityHash(); | 131 int v8ObjectHash = object->GetIdentityHash(); |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 | 605 |
606 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); | 606 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); |
607 return true; | 607 return true; |
608 } | 608 } |
609 | 609 |
610 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) | 610 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) |
611 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); | 611 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); |
612 | 612 |
613 return false; | 613 return false; |
614 } | 614 } |
OLD | NEW |