I'm writing a "wrapper" [1] for nsIDOMEvent, which has
a method GetType(nsAString & aType). I need to pass the
returned value back. I know this can be called like
#include "nsEmbedString.h"
nsEmbedString u16container;
const PRUnichar *u16str;
event->GetType(u16container);
u16str = u16container.get();
However, I think I need a UTF-8 encoded string. [2]
So I thought I could do this:
#include "nsReadableUtils.h" /* for CopyUTF16toUTF8 */
#include "nsEmbedString.h"
nsEmbedString u16container;
nsEmbedCString u8container;
const PRUnichar *u16str;
const char *u8str;
event->GetType(u16container);
u16str = u16container.get();
CopyUTF16toUTF8(u16str, u8container);
u8str = u8container.get();
But it won't compile because of the included headers:
==== make error output ====
In file included from /usr/include/mozilla/nsEmbedString.h:43,
from mozilladom2perl.h:25,
from DOM.xs:31:
/usr/include/mozilla/nsStringAPI.h:640: error: redefinition of `class nsAString
'
/usr/include/mozilla/string/nsTAString.h:104: error: previous definition of `
class nsAString'
/usr/include/mozilla/nsStringAPI.h:722: error: redefinition of `class
nsACString'
/usr/include/mozilla/string/nsTAString.h:104: error: previous definition of `
class nsACString'
/usr/include/mozilla/nsStringAPI.h:670: warning: inline function `void
nsAString::Assign(const nsAString&)' used but never defined
/usr/include/mozilla/nsStringAPI.h:674: warning: inline function `void
nsAString::Assign(const PRUnichar*, unsigned int)' used but never defined
/usr/include/mozilla/nsStringAPI.h:678: warning: inline function `void
nsAString::Assign(short unsigned int)' used but never defined
/usr/include/mozilla/nsStringAPI.h:752: warning: inline function `void
nsACString::Assign(const nsACString&)' used but never defined
/usr/include/mozilla/nsStringAPI.h:756: warning: inline function `void
nsACString::Assign(const char*, unsigned int)' used but never defined
/usr/include/mozilla/nsStringAPI.h:760: warning: inline function `void
nsACString::Assign(char)' used but never defined
make: *** [xs/DOM.o] Error 1
=============
It seems for one thing that string/nsTAString.h is included from
both nsReadableUtils.h and nsEmbedString.h, and its code is not
protected by a #ifndef ... #define. So am I not supposed to use
string/nsReadableUtils.h, or what am I doing wrong? What am I
supposed to do?
____
[1] There's a Perl module, Gtk2::MozEmbed which wraps GtkMozEmbed.
There are dom_key_* and dom_mouse_* events which ultimately
inherit from nsIDOMEvent. I'm writing code to go from Perl to C++
and back for the methods on the event objects.
[2] Perl handles strings as UTF-8. I don't think it does UTF-16.
_______________________________________________
mozilla-embedding mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-embedding