OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (!npObject || !_NPN_IsAlive(npObject)) { | 102 if (!npObject || !_NPN_IsAlive(npObject)) { |
103 V8ThrowException::throwReferenceError("NPObject deleted", isolate); | 103 V8ThrowException::throwReferenceError("NPObject deleted", isolate); |
104 return; | 104 return; |
105 } | 105 } |
106 | 106 |
107 // Wrap up parameters. | 107 // Wrap up parameters. |
108 int numArgs = info.Length(); | 108 int numArgs = info.Length(); |
109 OwnPtr<NPVariant[]> npArgs = adoptArrayPtr(new NPVariant[numArgs]); | 109 OwnPtr<NPVariant[]> npArgs = adoptArrayPtr(new NPVariant[numArgs]); |
110 | 110 |
111 for (int i = 0; i < numArgs; i++) | 111 for (int i = 0; i < numArgs; i++) |
112 convertV8ObjectToNPVariant(info[i], npObject, &npArgs[i], isolate); | 112 convertV8ObjectToNPVariant(isolate, info[i], npObject, &npArgs[i]); |
113 | 113 |
114 NPVariant result; | 114 NPVariant result; |
115 VOID_TO_NPVARIANT(result); | 115 VOID_TO_NPVARIANT(result); |
116 | 116 |
117 bool retval = true; | 117 bool retval = true; |
118 switch (functionId) { | 118 switch (functionId) { |
119 case InvokeMethod: | 119 case InvokeMethod: |
120 if (npObject->_class->invoke) { | 120 if (npObject->_class->invoke) { |
121 v8::Handle<v8::String> functionName = v8::Handle<v8::String>::Cast(i
nfo.Data()); | 121 v8::Handle<v8::String> functionName = v8::Handle<v8::String>::Cast(i
nfo.Data()); |
122 NPIdentifier identifier = getStringIdentifier(functionName); | 122 NPIdentifier identifier = getStringIdentifier(functionName); |
(...skipping 14 matching lines...) Expand all Loading... |
137 | 137 |
138 if (!retval) | 138 if (!retval) |
139 V8ThrowException::throwGeneralError("Error calling method on NPObject.",
isolate); | 139 V8ThrowException::throwGeneralError("Error calling method on NPObject.",
isolate); |
140 | 140 |
141 for (int i = 0; i < numArgs; i++) | 141 for (int i = 0; i < numArgs; i++) |
142 _NPN_ReleaseVariantValue(&npArgs[i]); | 142 _NPN_ReleaseVariantValue(&npArgs[i]); |
143 | 143 |
144 // Unwrap return values. | 144 // Unwrap return values. |
145 v8::Handle<v8::Value> returnValue; | 145 v8::Handle<v8::Value> returnValue; |
146 if (_NPN_IsAlive(npObject)) | 146 if (_NPN_IsAlive(npObject)) |
147 returnValue = convertNPVariantToV8Object(&result, npObject, isolate); | 147 returnValue = convertNPVariantToV8Object(isolate, &result, npObject); |
148 _NPN_ReleaseVariantValue(&result); | 148 _NPN_ReleaseVariantValue(&result); |
149 | 149 |
150 v8SetReturnValue(info, returnValue); | 150 v8SetReturnValue(info, returnValue); |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 void npObjectMethodHandler(const v8::FunctionCallbackInfo<v8::Value>& info) | 154 void npObjectMethodHandler(const v8::FunctionCallbackInfo<v8::Value>& info) |
155 { | 155 { |
156 return npObjectInvokeImpl(info, InvokeMethod); | 156 return npObjectInvokeImpl(info, InvokeMethod); |
157 } | 157 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 if (!_NPN_IsAlive(npObject)) | 247 if (!_NPN_IsAlive(npObject)) |
248 return V8ThrowException::throwReferenceError("NPObject deleted", iso
late); | 248 return V8ThrowException::throwReferenceError("NPObject deleted", iso
late); |
249 | 249 |
250 NPVariant result; | 250 NPVariant result; |
251 VOID_TO_NPVARIANT(result); | 251 VOID_TO_NPVARIANT(result); |
252 if (!npObject->_class->getProperty(npObject, identifier, &result)) | 252 if (!npObject->_class->getProperty(npObject, identifier, &result)) |
253 return v8Undefined(); | 253 return v8Undefined(); |
254 | 254 |
255 v8::Handle<v8::Value> returnValue; | 255 v8::Handle<v8::Value> returnValue; |
256 if (_NPN_IsAlive(npObject)) | 256 if (_NPN_IsAlive(npObject)) |
257 returnValue = convertNPVariantToV8Object(&result, npObject, isolate)
; | 257 returnValue = convertNPVariantToV8Object(isolate, &result, npObject)
; |
258 _NPN_ReleaseVariantValue(&result); | 258 _NPN_ReleaseVariantValue(&result); |
259 return returnValue; | 259 return returnValue; |
260 | 260 |
261 } | 261 } |
262 | 262 |
263 if (!_NPN_IsAlive(npObject)) | 263 if (!_NPN_IsAlive(npObject)) |
264 return V8ThrowException::throwReferenceError("NPObject deleted", isolate
); | 264 return V8ThrowException::throwReferenceError("NPObject deleted", isolate
); |
265 | 265 |
266 if (key->IsString() && npObject->_class->hasMethod && npObject->_class->hasM
ethod(npObject, identifier)) { | 266 if (key->IsString() && npObject->_class->hasMethod && npObject->_class->hasM
ethod(npObject, identifier)) { |
267 if (!_NPN_IsAlive(npObject)) | 267 if (!_NPN_IsAlive(npObject)) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 V8ThrowException::throwReferenceError("NPObject deleted", isolate); | 325 V8ThrowException::throwReferenceError("NPObject deleted", isolate); |
326 return value; // Intercepted, but an exception was thrown. | 326 return value; // Intercepted, but an exception was thrown. |
327 } | 327 } |
328 | 328 |
329 if (npObject->_class->hasProperty && npObject->_class->setProperty && npObje
ct->_class->hasProperty(npObject, identifier)) { | 329 if (npObject->_class->hasProperty && npObject->_class->setProperty && npObje
ct->_class->hasProperty(npObject, identifier)) { |
330 if (!_NPN_IsAlive(npObject)) | 330 if (!_NPN_IsAlive(npObject)) |
331 return V8ThrowException::throwReferenceError("NPObject deleted", iso
late); | 331 return V8ThrowException::throwReferenceError("NPObject deleted", iso
late); |
332 | 332 |
333 NPVariant npValue; | 333 NPVariant npValue; |
334 VOID_TO_NPVARIANT(npValue); | 334 VOID_TO_NPVARIANT(npValue); |
335 convertV8ObjectToNPVariant(value, npObject, &npValue, isolate); | 335 convertV8ObjectToNPVariant(isolate, value, npObject, &npValue); |
336 bool success = npObject->_class->setProperty(npObject, identifier, &npVa
lue); | 336 bool success = npObject->_class->setProperty(npObject, identifier, &npVa
lue); |
337 _NPN_ReleaseVariantValue(&npValue); | 337 _NPN_ReleaseVariantValue(&npValue); |
338 if (success) | 338 if (success) |
339 return value; // Intercept the call. | 339 return value; // Intercept the call. |
340 } | 340 } |
341 return v8Undefined(); | 341 return v8Undefined(); |
342 } | 342 } |
343 | 343 |
344 | 344 |
345 void npObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value
> value, const v8::PropertyCallbackInfo<v8::Value>& info) | 345 void npObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value
> value, const v8::PropertyCallbackInfo<v8::Value>& info) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 v8::HandleScope scope(isolate); | 487 v8::HandleScope scope(isolate); |
488 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat
e); | 488 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat
e); |
489 if (!wrapper.IsEmpty()) { | 489 if (!wrapper.IsEmpty()) { |
490 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); | 490 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); |
491 staticNPObjectMap().removeAndDispose(object); | 491 staticNPObjectMap().removeAndDispose(object); |
492 _NPN_ReleaseObject(object); | 492 _NPN_ReleaseObject(object); |
493 } | 493 } |
494 } | 494 } |
495 | 495 |
496 } // namespace blink | 496 } // namespace blink |
OLD | NEW |