FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
void IDispatchAPI::RemoveProperty ( const std::string &  propertyName)
virtual

Removes a property.

Parameters
propertyNameName of the property.
Since
1.5

Implements FB::JSAPI.

Definition at line 361 of file IDispatchAPI.cpp.

References FB::utf8_to_wstring().

362 {
363  if (m_browser.expired())
364  return;
365 
366  ActiveXBrowserHostPtr browser(getHost());
367  if (!browser->isMainThread()) {
368  browser->CallOnMainThread(boost::bind((FB::RemovePropertyType)&IDispatchAPI::RemoveProperty, this, propertyName));
369  return;
370  }
371 
372  if (is_JSAPI) {
373  FB::JSAPIPtr tmp = inner.lock();
374  if (tmp)
375  RemoveProperty(propertyName);
376  return;
377  }
378 
379  DISPID dispId = getIDForName(FB::utf8_to_wstring(propertyName));
380  if (dispId == DISPID_UNKNOWN) {
381  return;
382  }
383 
384  HRESULT hr;
385  CComQIPtr<IDispatchEx> dispatchEx(getIDispatch());
386  if (dispatchEx) {
387  hr = dispatchEx->DeleteMemberByDispID(dispId);
388  } else {
389  // todo: IDispatch does not support removing properties. Do SetProperty(propertyName, undefined); instead?
390  throw FB::script_error("Could not remove property");
391  }
392 
393  if (FAILED(hr)) {
394  return;
395  } else {
396  // todo: we should probably remove the name from the afxmap, but this is a bit hairy as described at
397  // http://msdn.microsoft.com/en-us/library/sky96ah7(v=vs.94).aspx . So we'll ignore it for now.
398  }
399 }
boost::shared_ptr< FB::JSAPI > JSAPIPtr
Defines an alias for a JSAPI shared_ptr (you should never use a JSAPI* directly)
Definition: APITypes.h:94
Exception type; when thrown in a JSAPI method, a javascript exception will be thrown.
Definition: JSExceptions.h:28
void(JSAPI::* RemovePropertyType)(const std::string &)
Defines an alias representing a function pointer to JSAPI::GetProperty.
Definition: APITypes.h:180
void RemoveProperty(const std::string &propertyName)
Removes a property.
std::wstring utf8_to_wstring(const std::string &src)
Accepts a UTF8-encoded std::string and returns a std::wstring.
Definition: utf8_tools.cpp:50

Here is the call graph for this function: