Page tree
Skip to end of metadata
Go to start of metadata

FB::JSAPIPtr FB::JSAPIAuto::GetMethodObject ( const std::string &  methodObjName)

Gets a method object (JSAPI object that has a default method)

Often it is preferable with the plugins to have the API return a JSAPI object as a property and then call the default method on that object. This looks the same in javascript, except that you can save the function object if you want to. See FB::JSFunction for an example of how to make a function object

methodObjNameName of the methodObj.
The methodObj value
See Also

Reimplemented from FB::JSAPI.

Definition at line 363 of file JSAPIAuto.cpp.

364 {
365  boost::recursive_mutex::scoped_lock lock(m_zoneMutex);
366  if(!m_valid)
367  throw object_invalidated();
369  if (memberAccessible(m_zoneMap.find(methodObjName)) && HasMethod(methodObjName)) {
370  MethodObjectMap::const_iterator fnd = m_methodObjectMap.find(boost::make_tuple(methodObjName, getZone()));
371  if (fnd != m_methodObjectMap.end()) {
372  return fnd->second;
373  } else {
374  FB::JSFunctionPtr ptr(boost::make_shared<FB::JSFunction>(shared_from_this(), methodObjName, getZone()));
375  m_methodObjectMap[boost::make_tuple(methodObjName, getZone())] = ptr;
376  return ptr;
377  }
378  } else {
379  throw invalid_member(methodObjName);
380  }
381 }
virtual bool HasMethod(const std::string &methodName) const
Query if the JSAPI object has the 'methodName' method.
Definition: JSAPIAuto.cpp:146
virtual SecurityZone getZone() const
Gets the currently active zone.
Definition: JSAPIImpl.h:238
  • No labels