Petar Popara wrote:
I'm writing scriptable plugin for Mozilla browsers. I have no problems with using my main class, but I need some other helper classes. I have declared my helper class/interface I would like to use in JavaScript:
[snip]
The problem is that I don't know how to create my helper class? :( I need it here:

NS_IMETHODIMP nsScriptablePeer::CreateMyObject(nsIMyObject * *_retVal)
{
  *a_retVal = *** create it here... ***
  return NS_OK;
}

Since you are implementing the C++ object yourself, just create it using the "new" operator. Make sure you addref the object before you return it:


NS_IMETHODIMP nsScriptablePeer::CreateNewObject(nsIMyObject **_retval)
{
  *_retval = new myHelperObject();
  if (!*_retval)
    return NS_ERROR_OUT_OF_MEMORY;

  NS_ADDREF(*_retval);
  return NS_OK;
}

--BDS
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to