FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
size_t IDispatchAPI::getMemberCount ( ) const
virtual

Gets the member count.

Returns
The member count.

Implements FB::JSAPI.

Definition at line 91 of file IDispatchAPI.cpp.

92 {
93  if (m_browser.expired() || m_obj.expired())
94  return 0;
95 
96  ActiveXBrowserHostPtr browser(getHost());
97  if (!browser->isMainThread()) {
98  return browser->CallOnMainThread(boost::bind(&IDispatchAPI::getMemberCount, this));
99  }
100 
101  if (is_JSAPI) {
102  FB::JSAPIPtr tmp = inner.lock();
103  if (!tmp) {
104  // TODO: check if this should be -1
105  return 0;
106  }
107  return tmp->getMemberCount();
108  }
109 
110  size_t count = 0;
111  try {
112  CComQIPtr<IDispatchEx> dispatchEx(getIDispatch());
113  if (!dispatchEx) {
114  return -1;
115  }
116 
117  DISPID dispid = DISPID_STARTENUM;
118  while (dispatchEx->GetNextDispID(fdexEnumAll, dispid, &dispid) != S_FALSE) {
119  if (dispid >= 0) {
120  ++count;
121  }
122  }
123  } catch (...) {}
124 
125  return count;
126 }
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
size_t getMemberCount() const
Gets the member count.