FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
void IDispatchAPI::getMemberNames ( std::vector< std::string > &  nameVector) const
virtual

Called by the browser to enumerate the members of this JSAPI object.

This must be implemented by anything extending JSAPI directly. JSAPIAuto implements this for you.

Parameters
[out]nameVectorThe name vector.

Implements FB::JSAPI.

Definition at line 53 of file IDispatchAPI.cpp.

References FB::wstring_to_utf8().

54 {
55  if (m_browser.expired() || m_obj.expired())
56  return;
57 
58  ActiveXBrowserHostPtr browser(getHost());
59  if (!browser->isMainThread()) {
60  typedef void (FB::JSAPI::*getMemberNamesType)(std::vector<std::string> *nameVector) const;
61  browser->CallOnMainThread(boost::bind((getMemberNamesType)&FB::JSAPI::getMemberNames, this, &nameVector));
62  return;
63  }
64  if (is_JSAPI) {
65  FB::JSAPIPtr tmp = inner.lock();
66  if (tmp)
67  tmp->getMemberNames(nameVector);
68  return;
69  }
70 
71  try {
72  CComQIPtr<IDispatchEx> dispatchEx(getIDispatch());
73  if (!dispatchEx) {
74  throw FB::script_error("Cannot enumerate members; IDispatchEx not supported");
75  }
76 
77  DISPID dispid = DISPID_STARTENUM;
78  while (dispatchEx->GetNextDispID(fdexEnumAll, dispid, &dispid) != S_FALSE) {
79  if (dispid < 0) {
80  continue;
81  }
82  CComBSTR memberName;
83  if (SUCCEEDED(dispatchEx->GetMemberName(dispid, &memberName))) {
84  std::wstring name(memberName);
85  nameVector.push_back(FB::wstring_to_utf8(name));
86  }
87  }
88  } catch(...) {}
89 }
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
std::string wstring_to_utf8(const std::wstring &src)
Accepts a std::wstring and returns a UTF8-encoded std::string.
Definition: utf8_tools.cpp:37
JavaScript API class – provides a javascript interface that can be exposed to the browser...
Definition: JSAPI.h:56

Here is the call graph for this function: