Hello all,
For the first time, I need to return a string from my (Windows, MS) C++
XPCOM object to JavaScript; I've looked at the XPCOM string guide, but
what seems to be the preferred helper class, nsAString, is declared but
not defined in my XPCOM hierarchy. (I'm pretty sure it's from a Gecko
archive somewhere, but I forget exactly where I got it. In any case,
it's been working for my extension so far, and I'd really prefer not to
have to get e.g. the whole Mozilla hierarchy in order to get this
working.)
An example function in the idl is:
wstring GetFoo();
The .h file generated from that is:
NS_IMETHOD GetFoo(PRUnichar **_retval) = 0;
The ToNewUnicode() overloads are not defined in my XPCOM files, so I
tried allocating the strings myself:
PRUnichar *ToNewUnicode(const TCHAR *sz)
{
PRUnichar *szRet = (PRUnichar*)NS_Alloc(lstrlen(sz)+2);
lstrcpy(szRet, sz);
return szRet;
}
But that crashes FF.
Suggestions? Thanks in advance.
-Paul
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom