Merge m-i to m-c.
authorKyle Huey <khuey@kylehuey.com>
Tue, 27 Sep 2011 08:33:03 -0400
changeset 79012 9a4ee730c0d9d513d141fb72a92cbc1d94588a3d
parent 78989 5373b67aec43f179d0f6173aec843a546af11abf (current diff)
parent 79011 9733c9885c0202a93cee7b7d2e9901593a4213cb (diff)
child 79013 ade33e515f463c035348616d8637078cb67b7fc7
child 79358 37843077ff3d446caad0c795c46d865902b1d18d
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge m-i to m-c.
browser/base/content/tabbrowser.xml
build/autoconf/libIDL.m4
xpcom/typelib/xpidl/README
xpcom/typelib/xpidl/xpidl.c
xpcom/typelib/xpidl/xpidl.h
xpcom/typelib/xpidl/xpidl_doc.c
xpcom/typelib/xpidl/xpidl_header.c
xpcom/typelib/xpidl/xpidl_idl.c
xpcom/typelib/xpidl/xpidl_java.c
xpcom/typelib/xpidl/xpidl_typelib.c
xpcom/typelib/xpidl/xpidl_util.c
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,15 +1,14 @@
 dnl
 dnl Local autoconf macros used with mozilla
 dnl The contents of this file are under the Public Domain.
 dnl 
 
 builtin(include, build/autoconf/glib.m4)dnl
-builtin(include, build/autoconf/libIDL.m4)dnl
 builtin(include, build/autoconf/nspr.m4)dnl
 builtin(include, build/autoconf/nss.m4)dnl
 builtin(include, build/autoconf/pkg.m4)dnl
 builtin(include, build/autoconf/freetype2.m4)dnl
 builtin(include, build/autoconf/codeset.m4)dnl
 builtin(include, build/autoconf/altoptions.m4)dnl
 builtin(include, build/autoconf/mozprog.m4)dnl
 builtin(include, build/autoconf/mozheader.m4)dnl
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -4172,16 +4172,21 @@
           if (aTab.hasAttribute("busy")) {
             aMenuitem.setAttribute("busy", aTab.getAttribute("busy"));
             aMenuitem.removeAttribute("image");
           } else {
             aMenuitem.setAttribute("image", aTab.getAttribute("image"));
             aMenuitem.removeAttribute("busy");
           }
 
+          if (aTab.hasAttribute("pending"))
+            aMenuitem.setAttribute("pending", aTab.getAttribute("pending"));
+          else
+            aMenuitem.removeAttribute("pending");
+
           if (aTab.selected)
             aMenuitem.setAttribute("selected", "true");
           else
             aMenuitem.removeAttribute("selected");
         ]]></body>
       </method>
     </implementation>
 
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -2820,16 +2820,17 @@ SessionStoreService.prototype = {
         this.xulAttributes[name] = true;
 
       tabData._tabStillLoading = true;
 
       // keep the data around to prevent dataloss in case
       // a tab gets closed before it's been properly restored
       browser.__SS_data = tabData;
       browser.__SS_restoreState = TAB_STATE_NEEDS_RESTORE;
+      tab.setAttribute("pending", "true");
 
       // Make sure that set/getTabValue will set/read the correct data by
       // wiping out any current value in tab.__SS_extdata.
       delete tab.__SS_extdata;
 
       if (!tabData.entries || tabData.entries.length == 0) {
         // make sure to blank out this tab's content
         // (just purging the tab's history won't be enough)
@@ -3002,16 +3003,17 @@ SessionStoreService.prototype = {
     // Make sure that this tab is removed from _tabsToRestore
     this._removeTabFromTabsToRestore(aTab);
 
     // Increase our internal count.
     this._tabsRestoringCount++;
 
     // Set this tab's state to restoring
     browser.__SS_restoreState = TAB_STATE_RESTORING;
+    aTab.removeAttribute("pending");
 
     // Remove the history listener, since we no longer need it once we start restoring
     this._removeSHistoryListener(aTab);
 
     let activeIndex = (tabData.index || tabData.entries.length) - 1;
     if (activeIndex >= tabData.entries.length)
       activeIndex = tabData.entries.length - 1;
     // Reset currentURI.  This creates a new session history entry with a new
--- a/browser/components/sessionstore/test/browser/Makefile.in
+++ b/browser/components/sessionstore/test/browser/Makefile.in
@@ -147,16 +147,17 @@ include $(topsrcdir)/config/rules.mk
 	browser_624727.js \
 	browser_625257.js \
 	browser_628270.js \
 	browser_635418.js \
 	browser_636279.js \
 	browser_645428.js \
 	browser_659591.js \
 	browser_662812.js \
+	browser_682507.js \
 	$(NULL)
 
 ifneq ($(OS_ARCH),Darwin)
 _BROWSER_TEST_FILES += \
 	browser_597071.js \
 	browser_625016.js \
 	$(NULL)
 endif
new file mode 100644
--- /dev/null
+++ b/browser/components/sessionstore/test/browser/browser_682507.js
@@ -0,0 +1,16 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
+  gBrowser.addTab("about:mozilla");
+
+  ss.setTabState(gBrowser.tabs[1], ss.getTabState(gBrowser.tabs[1]));
+  ok(gBrowser.tabs[1].hasAttribute("pending"), "second tab should have 'pending' attribute");
+
+  gBrowser.selectedTab = gBrowser.tabs[1];
+  ok(!gBrowser.tabs[1].hasAttribute("pending"), "second tab should have not 'pending' attribute");
+
+  gBrowser.removeTab(gBrowser.tabs[1]);
+  Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
+}
deleted file mode 100644
--- a/build/autoconf/libIDL.m4
+++ /dev/null
@@ -1,194 +0,0 @@
-# Configure paths for LIBIDL
-
-dnl AM_PATH_LIBIDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
-dnl Test for LIBIDL, and define LIBIDL_CFLAGS and LIBIDL_LIBS
-dnl
-AC_DEFUN([AM_PATH_LIBIDL],
-[dnl 
-dnl Get the cflags and libraries from the libIDL-config script
-dnl
-AC_ARG_WITH(libIDL-prefix,[  --with-libIDL-prefix=PFX
-                          Prefix where libIDL is installed (optional)],
-            libIDL_config_prefix="$withval", libIDL_config_prefix="")
-AC_ARG_WITH(libIDL-exec-prefix,[  --with-libIDL-exec-prefix=PFX
-                          Exec prefix where libIDL is installed (optional)],
-            libIDL_config_exec_prefix="$withval", libIDL_config_exec_prefix="")
-AC_ARG_ENABLE(libIDLtest, [  --disable-libIDLtest    Do not try to compile and run a test libIDL program],
-		    , enable_libIDLtest=yes)
-
-  if test x$libIDL_config_exec_prefix != x ; then
-     libIDL_config_args="$libIDL_config_args --exec-prefix=$libIDL_config_exec_prefix"
-     if test x${HOST_LIBIDL_CONFIG+set} != xset ; then
-        HOST_LIBIDL_CONFIG=$libIDL_config_exec_prefix/bin/libIDL-config
-     fi
-  fi
-  if test x$libIDL_config_prefix != x ; then
-     libIDL_config_args="$libIDL_config_args --prefix=$libIDL_config_prefix"
-     if test x${HOST_LIBIDL_CONFIG+set} != xset ; then
-        HOST_LIBIDL_CONFIG=$libIDL_config_prefix/bin/libIDL-config
-     fi
-  fi
-
-  AM_PATH_GLIB(1.2.0)
-
-  dnl Force a version check to keep upgraded versions from being overridden by the cached value.
-  unset ac_cv_path_LIBIDL_CONFIG
-
-  AC_PATH_PROG(HOST_LIBIDL_CONFIG, libIDL-config, no)
-  min_libIDL_version=ifelse([$1], ,0.6.0,$1)
-  AC_MSG_CHECKING(for libIDL - version >= $min_libIDL_version)
-  no_libIDL=""
-  if test "$HOST_LIBIDL_CONFIG" = "no" ; then
-    no_libIDL=yes
-  else
-    HOST_LIBIDL_CFLAGS=`$HOST_LIBIDL_CONFIG $libIDL_config_args --cflags`
-    HOST_LIBIDL_LIBS=`$HOST_LIBIDL_CONFIG $libIDL_config_args --libs`
-    libIDL_config_major_version=`$HOST_LIBIDL_CONFIG $libIDL_config_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
-    libIDL_config_minor_version=`$HOST_LIBIDL_CONFIG $libIDL_config_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
-    libIDL_config_micro_version=`$HOST_LIBIDL_CONFIG $libIDL_config_args --version | \
-           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
-    if test "x$enable_libIDLtest" = "xyes" ; then
-      ac_save_CFLAGS="$CFLAGS"
-      ac_save_LIBS="$LIBS"
-      CFLAGS="$CFLAGS $HOST_LIBIDL_CFLAGS"
-      LIBS="$HOST_LIBIDL_LIBS $LIBS"
-dnl
-dnl Now check if the installed LIBIDL is sufficiently new.
-dnl
-      rm -f conf.libIDLtest
-      AC_TRY_RUN([
-#include <stdio.h>
-#include <stdlib.h>
-#include <libIDL/IDL.h>
-
-int 
-main ()
-{
-  int major, minor, micro;
-  int libIDL_major_version;
-  int libIDL_minor_version;
-  int libIDL_micro_version;
-  char *tmp_version;
-
-  system ("touch conf.libIDLtest");
-
-  /* HP/UX 9 (%@#!) writes to sscanf strings */
-  tmp_version = g_strdup ("$min_libIDL_version");
-  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
-     printf("%s, bad version string\n", "$min_libIDL_version");
-     exit(1);
-  }
-  tmp_version = g_strdup (IDL_get_libver_string ());
-  if (sscanf(tmp_version, "%d.%d.%d",
-	     &libIDL_major_version,
-	     &libIDL_minor_version,
-	     &libIDL_micro_version) != 3) {
-     printf("%s, bad version string\n", tmp_version);
-     exit(1);
-  }
-
-  if ((libIDL_major_version != $libIDL_config_major_version) ||
-      (libIDL_minor_version != $libIDL_config_minor_version) ||
-      (libIDL_micro_version != $libIDL_config_micro_version))
-    {
-      printf("\n*** 'libIDL-config --version' returned %d.%d.%d, but libIDL (%d.%d.%d)\n", 
-             $libIDL_config_major_version, $libIDL_config_minor_version, $libIDL_config_micro_version,
-             libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
-      printf ("*** was found! If libIDL-config was correct, then it is best\n");
-      printf ("*** to remove the old version of LIBIDL. You may also be able to fix the error\n");
-      printf("*** by modifying your LD_LIBRARY_PATH environment variable, or by editing\n");
-      printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
-      printf("*** required on your system.\n");
-      printf("*** If libIDL-config was wrong, set the environment variable LIBIDL_CONFIG\n");
-      printf("*** to point to the correct copy of libIDL-config, and remove the file config.cache\n");
-      printf("*** before re-running configure\n");
-    } 
-  else if ((libIDL_major_version != LIBIDL_MAJOR_VERSION) ||
-	   (libIDL_minor_version != LIBIDL_MINOR_VERSION) ||
-           (libIDL_micro_version != LIBIDL_MICRO_VERSION))
-    {
-      printf("\n*** libIDL header files (version %d.%d.%d) do not match\n",
-	     LIBIDL_MAJOR_VERSION, LIBIDL_MINOR_VERSION, LIBIDL_MICRO_VERSION);
-      printf("*** library (version %d.%d.%d)\n",
-	     libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
-    }
-  else
-    {
-      if ((libIDL_major_version > major) ||
-        ((libIDL_major_version == major) && (libIDL_minor_version > minor)) ||
-        ((libIDL_major_version == major) && (libIDL_minor_version == minor) && (libIDL_micro_version >= micro)))
-      {
-        return 0;
-       }
-     else
-      {
-        printf("\n*** An old version of libIDL (%d.%d.%d) was found.\n",
-               libIDL_major_version, libIDL_minor_version, libIDL_micro_version);
-        printf("*** You need at least libIDL version %d.%d.%d.\n",
-               major, minor, micro);
-        printf("***\n");
-        printf("*** If you have already installed a sufficiently new version, this error\n");
-        printf("*** probably means that the wrong copy of the libIDL-config shell script is\n");
-        printf("*** being found. The easiest way to fix this is to remove the old version\n");
-        printf("*** of libIDL, but you can also set the LIBIDL_CONFIG environment to point to the\n");
-        printf("*** correct copy of libIDL-config. (In this case, you will have to\n");
-        printf("*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf\n");
-        printf("*** so that the correct libraries are found at run-time))\n");
-      }
-    }
-  return 1;
-}
-],, no_libIDL=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
-       CFLAGS="$ac_save_CFLAGS"
-       LIBS="$ac_save_LIBS"
-     fi
-  fi
-  if test "x$no_libIDL" = x ; then
-     AC_MSG_RESULT(yes)
-     ifelse([$2], , :, [$2])     
-  else
-     AC_MSG_RESULT(no)
-     if test "$HOST_LIBIDL_CONFIG" = "no" ; then
-       echo "*** The libIDL-config script installed by libIDL could not be found"
-       echo "*** If libIDL was installed in PREFIX, make sure PREFIX/bin is in"
-       echo "*** your path, or set the LIBIDL_CONFIG environment variable to the"
-       echo "*** full path to libIDL-config."
-     else
-       if test -f conf.libIDLtest ; then
-        :
-       else
-          echo "*** Could not run libIDL test program, checking why..."
-          CFLAGS="$CFLAGS $HOST_LIBIDL_CFLAGS"
-          LIBS="$LIBS $HOST_LIBIDL_LIBS"
-          AC_TRY_LINK([
-#include <stdio.h>
-#include <stdlib.h>
-#include <libIDL/IDL.h>
-],      [ return IDL_get_libver_string ? 1 : 0; ],
-        [ echo "*** The test program compiled, but did not run. This usually means"
-          echo "*** that the run-time linker is not finding libIDL or finding the wrong"
-          echo "*** version of LIBIDL. If it is not finding libIDL, you'll need to set your"
-          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
-          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
-          echo "*** is required on your system"
-	  echo "***"
-          echo "*** If you have an old version installed, it is best to remove it, although"
-          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
-        [ echo "*** The test program failed to compile or link. See the file config.log for the"
-          echo "*** exact error that occurred. This usually means libIDL was incorrectly installed"
-          echo "*** or that you have moved libIDL since it was installed. In the latter case, you"
-          echo "*** may want to edit the libIDL-config script: $LIBIDL_CONFIG" ])
-          CFLAGS="$ac_save_CFLAGS"
-          LIBS="$ac_save_LIBS"
-       fi
-     fi
-     HOST_LIBIDL_CFLAGS=""
-     HOST_LIBIDL_LIBS=""
-     ifelse([$3], , :, [$3])
-  fi
-  AC_SUBST(HOST_LIBIDL_CFLAGS)
-  AC_SUBST(HOST_LIBIDL_LIBS)
-  rm -f conf.libIDLtest
-])
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -395,20 +395,16 @@ HOST_LDFLAGS	= @HOST_LDFLAGS@
 HOST_OPTIMIZE_FLAGS = @HOST_OPTIMIZE_FLAGS@
 HOST_NSPR_MDCPUCFG = @HOST_NSPR_MDCPUCFG@
 HOST_AR		= @HOST_AR@
 HOST_AR_FLAGS	= @HOST_AR_FLAGS@
 HOST_LD		= @HOST_LD@
 HOST_RANLIB	= @HOST_RANLIB@
 HOST_BIN_SUFFIX	= @HOST_BIN_SUFFIX@
 
-HOST_LIBIDL_CONFIG = @HOST_LIBIDL_CONFIG@
-HOST_LIBIDL_CFLAGS = @HOST_LIBIDL_CFLAGS@
-HOST_LIBIDL_LIBS   = @HOST_LIBIDL_LIBS@
-
 HOST_OS_ARCH	= @HOST_OS_ARCH@
 host_cpu	= @host_cpu@
 host_vendor	= @host_vendor@
 host_os		= @host_os@
 
 TARGET_NSPR_MDCPUCFG = @TARGET_NSPR_MDCPUCFG@
 TARGET_CPU	= @TARGET_CPU@
 TARGET_VENDOR	= @TARGET_VENDOR@
@@ -573,19 +569,16 @@ MOZ_LIBNOTIFY_CFLAGS	= @MOZ_LIBNOTIFY_CF
 MOZ_LIBNOTIFY_LIBS	= @MOZ_LIBNOTIFY_LIBS@
 MOZ_ENABLE_LIBNOTIFY	= @MOZ_ENABLE_LIBNOTIFY@
 
 MOZ_ALSA_LIBS           = @MOZ_ALSA_LIBS@
 
 GLIB_CFLAGS	= @GLIB_CFLAGS@
 GLIB_LIBS	= @GLIB_LIBS@
 GLIB_GMODULE_LIBS	= @GLIB_GMODULE_LIBS@
-LIBIDL_CFLAGS = @LIBIDL_CFLAGS@
-LIBIDL_LIBS = @LIBIDL_LIBS@
-STATIC_LIBIDL = @STATIC_LIBIDL@
 
 MOZ_NATIVE_MAKEDEPEND	= @SYSTEM_MAKEDEPEND@
 
 export CL_INCLUDES_PREFIX = @CL_INCLUDES_PREFIX@
 
 MOZ_AUTO_DEPS	= @MOZ_AUTO_DEPS@
 COMPILER_DEPEND = @COMPILER_DEPEND@
 MDDEPDIR        := @MDDEPDIR@
--- a/config/system-headers
+++ b/config/system-headers
@@ -303,17 +303,16 @@ gtk/gtk.h
 gtk/gtkprinter.h
 gtk/gtkprintjob.h
 gtk/gtkprintunixdialog.h
 HIToolbox/HIToolbox.h
 hlink.h
 ia64/sys/inline.h
 Icons.h
 iconv.h
-IDL.h
 ieeefp.h
 ifaddrs.h
 image.h
 imagehlp.h
 imm.h
 initguid.h
 InterfaceDefs.h
 InternetConfig.h
@@ -399,17 +398,16 @@ libgnomeui/gnome-ui-init.h
 libgnomevfs/gnome-vfs-file-info.h
 libgnomevfs/gnome-vfs.h
 libgnomevfs/gnome-vfs-init.h
 libgnomevfs/gnome-vfs-mime.h
 libgnomevfs/gnome-vfs-mime-handlers.h
 libgnomevfs/gnome-vfs-mime-utils.h
 libgnomevfs/gnome-vfs-ops.h
 libgnomevfs/gnome-vfs-standard-callbacks.h
-libIDL/IDL.h
 lib$routines.h
 libnotify/notify.h
 limits
 limits.h
 link.h
 linux/kernel.h
 linux/limits.h
 linux/rtc.h
--- a/configure.in
+++ b/configure.in
@@ -111,17 +111,16 @@ MOZJPEG=62
 MOZPNG=10401
 MOZZLIB=0x1230
 NSPR_VERSION=4
 NSS_VERSION=3
 
 dnl Set the minimum version of toolkit libs used by mozilla
 dnl ========================================================
 GLIB_VERSION=1.2.0
-LIBIDL_VERSION=0.6.3
 PERL_VERSION=5.006
 PYTHON_VERSION=2.5
 CAIRO_VERSION=1.10
 PANGO_VERSION=1.14.0
 GTK2_VERSION=2.10.0
 WINDRES_VERSION=2.14.90
 W32API_VERSION=3.14
 GNOMEVFS_VERSION=2.0
@@ -7826,217 +7825,18 @@ XPCOM_LIBS="$LIBXUL_LIBS"
 
 dnl ========================================================
 dnl =
 dnl = Standalone module options
 dnl =
 dnl ========================================================
 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
 
-dnl Check for GLib and libIDL.
-dnl ========================================================
-SKIP_IDL_CHECK="no"
-
-if test -z "$COMPILE_ENVIRONMENT"; then
-    SKIP_IDL_CHECK="yes"
-fi
-
-dnl = Allow users to disable libIDL checking for standalone modules
-MOZ_ARG_WITHOUT_BOOL(libIDL,
-[  --without-libIDL        Skip check for libIDL (standalone modules only)],
-	SKIP_IDL_CHECK="yes")
-
-if test -z "$CROSS_COMPILE"; then
-    if test -z "$HOST_LIBIDL_CONFIG"; then
-        HOST_LIBIDL_CONFIG="$LIBIDL_CONFIG"
-    fi
-    if test -z "$HOST_LIBIDL_PREFIX"; then
-        HOST_LIBIDL_PREFIX="$LIBIDL_PREFIX"
-    fi
-fi
-
-if test "$SKIP_IDL_CHECK" = "no"
-then
-    _LIBIDL_FOUND=
-    case "$host" in
-    *-mingw*)
-        if test -n "$GLIB_PREFIX"; then
-            _GLIB_PREFIX_DIR=`cd $GLIB_PREFIX && pwd -W`
-            if test "$?" = "0"; then
-                if test `echo ${PATH}: | grep -ic "$_GLIB_PREFIX_DIR/bin:"` = 0; then
-                    AC_MSG_ERROR([GLIB_PREFIX must be in your \$PATH.])
-                fi
-            else
-                 AC_MSG_ERROR([GLIB_PREFIX is set but "${GLIB_PREFIX}" is not a directory.])
-            fi
-        else
-            _GLIB_PREFIX_DIR=$MOZ_TOOLS_DIR
-        fi
-        if test ! -f "${_GLIB_PREFIX_DIR}/include/glib.h"; then
-            AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/include/glib.h .])
-        fi
-        GLIB_CFLAGS="-I${_GLIB_PREFIX_DIR}/include"
-        if test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"; then
-            GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"
-        elif test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"; then
-            GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"
-        else
-            AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/lib/glib-1.2.lib or $_GLIB_PREFIX_DIR/lib/glib-1.2_s.lib])
-        fi
-
-        if test -n "$HOST_LIBIDL_PREFIX"; then
-            _LIBIDL_PREFIX_DIR=`cd $HOST_LIBIDL_PREFIX && pwd -W`
-            if test "$?" = "0"; then
-                if test `echo ${PATH}: | grep -ic "$_LIBIDL_PREFIX_DIR/bin:"` = 0; then
-                    AC_MSG_ERROR([LIBIDL_PREFIX must be in your \$PATH.])
-                fi
-            else
-                AC_MSG_ERROR([LIBIDL_PREFIX is set but "${LIBIDL_PREFIX}" is not a directory.])
-            fi
-        else
-            _LIBIDL_PREFIX_DIR=$MOZ_TOOLS_DIR
-        fi
-        if test ! -f "${_LIBIDL_PREFIX_DIR}/include/libIDL/IDL.h"; then
-            AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/include/libIDL/IDL.h .])
-        fi
-        HOST_LIBIDL_CFLAGS="-I${_LIBIDL_PREFIX_DIR}/include ${GLIB_CFLAGS}"
-        if test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"; then
-            HOST_LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"
-            STATIC_LIBIDL=1
-        elif test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"; then
-            HOST_LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"
-        else
-            AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/lib/libidl-0.6.lib or $_LIBIDL_PREFIX_DIR/lib/libidl-0.6_s.lib])
-        fi
-        HOST_LIBIDL_LIBS="${HOST_LIBIDL_LIBS} ${GLIB_LIBS}"
-        _LIBIDL_FOUND=1
-        ;;
-    esac
-
-    if test -z "$_LIBIDL_FOUND"; then
-        if test "$MACOS_SDK_DIR"; then
-            dnl xpidl, and therefore libIDL, is only needed on the build host.
-            dnl Don't build it against the SDK, as that causes problems.
-            _MACSAVE_CFLAGS="$CFLAGS"
-            _MACSAVE_LIBS="$LIBS"
-            _MACSAVE_LDFLAGS="$LDFLAGS"
-            _MACSAVE_NEXT_ROOT="$NEXT_ROOT"
-          changequote(,)
-          CFLAGS=`echo $CFLAGS|sed -E -e "s%((-I|-isystem )${MACOS_SDK_DIR}/usr/(include|lib/gcc)[^ ]*)|-F${MACOS_SDK_DIR}(/System)?/Library/Frameworks[^ ]*|-nostdinc[^ ]*|-isysroot ${MACOS_SDK_DIR}%%g"`
-          LIBS=`echo $LIBS|sed -e "s?-L${MACOS_SDK_DIR}/usr/lib[^ ]*??g"`
-          LDFLAGS=`echo $LDFLAGS|sed -e "s?-Wl,-syslibroot,${MACOS_SDK_DIR}??g"`
-          changequote([,])
-          unset NEXT_ROOT
-        fi
-
-        PKG_CHECK_MODULES(HOST_LIBIDL, libIDL-2.0 >= 0.8.0 glib-2.0 gobject-2.0, _LIBIDL_FOUND=1,_LIBIDL_FOUND=)
-    fi
-
-    dnl if no gtk/libIDL1 or gtk2/libIDL2 combination was found, fall back
-    dnl to either libIDL1 or libIDL2.
-    if test -z "$_LIBIDL_FOUND"; then
-        AM_PATH_LIBIDL($LIBIDL_VERSION,_LIBIDL_FOUND=1)
-        if test -z "$_LIBIDL_FOUND"; then
-            PKG_CHECK_MODULES(HOST_LIBIDL, libIDL-2.0 >= 0.8.0,_LIBIDL_FOUND=1)
-        fi
-    fi
-    dnl
-    dnl If we don't have a libIDL config program & not cross-compiling,
-    dnl     look for orbit-config instead.
-    dnl
-    if test -z "$_LIBIDL_FOUND" -a -z "$CROSS_COMPILE"; then
-        MOZ_PATH_PROGS(ORBIT_CONFIG, $ORBIT_CONFIG orbit-config)
-        if test -n "$ORBIT_CONFIG"; then
-            AC_MSG_CHECKING([for ORBit libIDL usability])
-        	_ORBIT_CFLAGS=`${ORBIT_CONFIG} client --cflags`
-    	    _ORBIT_LIBS=`${ORBIT_CONFIG} client --libs`
-            _ORBIT_INC_PATH=`${PERL} -e '{ for $f (@ARGV) { print "$f " if ($f =~ m/^-I/); } }' -- ${_ORBIT_CFLAGS}`
-            _ORBIT_LIB_PATH=`${PERL} -e '{ for $f (@ARGV) { print "$f " if ($f =~ m/^-L/); } }' -- ${_ORBIT_LIBS}`
-            HOST_LIBIDL_CFLAGS="$_ORBIT_INC_PATH"
-            HOST_LIBIDL_LIBS="$_ORBIT_LIB_PATH -lIDL -lglib"
-            HOST_LIBIDL_CONFIG=
-            _SAVE_CFLAGS="$CFLAGS"
-            _SAVE_LIBS="$LIBS"
-            CFLAGS="$HOST_LIBIDL_CFLAGS $CFLAGS"
-            LIBS="$HOST_LIBIDL_LIBS $LIBS"
-            AC_TRY_RUN([
-#include <stdlib.h>
-#include <libIDL/IDL.h>
-int main() {
-  char *s;
-  s=strdup(IDL_get_libver_string());
-  if(s==NULL) {
-    exit(1);
-  }
-  exit(0);
-}
-            ], [_LIBIDL_FOUND=1
-                result="yes"],
-               [HOST_LIBIDL_CFLAGS=
-                HOST_LIBIDL_LIBS=
-                result="no"],
-               [_LIBIDL_FOUND=1
-                result="maybe"] )
-            AC_MSG_RESULT($result)
-            CFLAGS="$_SAVE_CFLAGS"
-            LIBS="$_SAVE_LIBS"
-        fi
-    fi
-    if test -z "$_LIBIDL_FOUND"; then
-        AC_MSG_ERROR([libIDL not found.
-        libIDL $LIBIDL_VERSION or higher is required.])
-    fi
-    if test "$MACOS_SDK_DIR"; then
-      CFLAGS="$_MACSAVE_CFLAGS"
-      LIBS="$_MACSAVE_LIBS"
-      LDFLAGS="$_MACSAVE_LDFLAGS"
-      if test -n "$_MACSAVE_NEXT_ROOT" ; then
-        export NEXT_ROOT="$_MACSAVE_NEXT_ROOT"
-      fi
-    fi
-fi
-
-if test -n "$CROSS_COMPILE"; then
-    case "$target" in
-    *-mingw*)
-        if test -n "$GLIB_PREFIX"; then
-            GLIB_CFLAGS="-I${GLIB_PREFIX}/include"
-            if test -f "${GLIB_PREFIX}/lib/glib-1.2_s.lib"; then
-                GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2_s.lib"
-            elif test -f "${GLIB_PREFIX}/lib/glib-1.2.lib"; then
-                GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2.lib"
-            else
-                AC_MSG_ERROR([Cannot find $GLIB_PREFIX/lib/glib-1.2.lib or $GLIB_PREFIX/lib/glib-1.2_s.lib])
-            fi
-        fi
-
-        if test -n "$LIBIDL_PREFIX"; then
-            LIBIDL_CFLAGS="-I${LIBIDL_PREFIX}/include ${GLIB_CFLAGS}"
-            if test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"; then
-                LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"
-                STATIC_LIBIDL=1
-            elif test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"; then
-                LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"
-            else
-                AC_MSG_ERROR([Cannot find $LIBIDL_PREFIX/lib/libIDL-0.6.lib or $LIBIDL_PREFIX/lib/libIDL-0.6_s.lib])
-            fi
-        fi
-        LIBIDL_LIBS="${LIBIDL_LIBS} ${GLIB_LIBS}"
-        ;;
-    *)
-        if test -n "LIBIDL_CONFIG" -a "LIBIDL_CONFIG" != "no"; then
-            LIBIDL_CFLAGS=`${LIBIDL_CONFIG} --cflags`
-            LIBIDL_LIBS=`${LIBIDL_CONFIG} --libs`
-        fi
-        ;;
-    esac
-else
-    LIBIDL_CFLAGS="$HOST_LIBIDL_CFLAGS"
-    LIBIDL_LIBS="$HOST_LIBIDL_LIBS"
-fi
+dnl Check for GLib.
+dnl ========================================================
 
 if test -z "$SKIP_PATH_CHECKS"; then
 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
     if test "$MOZ_ENABLE_GTK2" -o "$USE_ELF_DYNSTR_GC" ; then
         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
     else
         AM_PATH_GLIB(${GLIB_VERSION})
     fi
@@ -8045,25 +7845,19 @@ fi
 
 if test -z "${GLIB_GMODULE_LIBS}" \
    -a -n "${GLIB_CONFIG}"\
     -a "${GLIB_CONFIG}" != no\
 ; then
     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
 fi
 
-AC_SUBST(LIBIDL_CFLAGS)
-AC_SUBST(LIBIDL_LIBS)
-AC_SUBST(STATIC_LIBIDL)
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 AC_SUBST(GLIB_GMODULE_LIBS)
-AC_SUBST(HOST_LIBIDL_CONFIG)
-AC_SUBST(HOST_LIBIDL_CFLAGS)
-AC_SUBST(HOST_LIBIDL_LIBS)
 
 dnl ========================================================
 dnl Check for cairo
 dnl ========================================================
 MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
 
 MOZ_TREE_CAIRO=1
 MOZ_ARG_ENABLE_BOOL(system-cairo,
--- a/content/base/public/nsDeprecatedOperationList.h
+++ b/content/base/public/nsDeprecatedOperationList.h
@@ -66,8 +66,16 @@ DEPRECATED_OPERATION(RemoveChild)
 DEPRECATED_OPERATION(AppendChild)
 DEPRECATED_OPERATION(CloneNode)
 DEPRECATED_OPERATION(OwnerDocument)
 DEPRECATED_OPERATION(Normalize)
 DEPRECATED_OPERATION(IsSupported)
 DEPRECATED_OPERATION(IsEqualNode)
 DEPRECATED_OPERATION(TextContent)
 DEPRECATED_OPERATION(EnablePrivilege)
+DEPRECATED_OPERATION(IsSameNode)
+DEPRECATED_OPERATION(ReplaceWholeText)
+DEPRECATED_OPERATION(GlobalStorage)
+DEPRECATED_OPERATION(XmlEncoding)
+DEPRECATED_OPERATION(XmlVersion)
+DEPRECATED_OPERATION(InputEncoding)
+DEPRECATED_OPERATION(XmlStandalone)
+DEPRECATED_OPERATION(IsElementContentWhitespace)
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -1574,17 +1574,17 @@ public:
   enum DeprecatedOperations {
 #include "nsDeprecatedOperationList.h"
     eDeprecatedOperationCount
   };
 #undef DEPRECATED_OPERATION
   void WarnOnceAbout(DeprecatedOperations aOperation);
 
 private:
-  PRUint32 mWarnedAbout;
+  PRUint64 mWarnedAbout;
 
 protected:
   ~nsIDocument()
   {
     // XXX The cleanup of mNodeInfoManager (calling DropDocumentReference and
     //     releasing it) happens in the nsDocument destructor. We'd prefer to
     //     do it here but nsNodeInfoManager is a concrete class that we don't
     //     want to expose to users of the nsIDocument API outside of Gecko.
--- a/content/base/src/nsContentIterator.cpp
+++ b/content/base/src/nsContentIterator.cpp
@@ -564,27 +564,27 @@ nsINode*
 nsContentIterator::GetDeepFirstChild(nsINode *aRoot,
                                      nsTArray<PRInt32> *aIndexes)
 {
   if (!aRoot) {
     return nsnull;
   }
 
   nsINode *n = aRoot;
-  nsINode *nChild = n->GetChildAt(0);
+  nsINode *nChild = n->GetFirstChild();
 
   while (nChild)
   {
     if (aIndexes)
     {
       // Add this node to the stack of indexes
       aIndexes->AppendElement(0);
     }
     n = nChild;
-    nChild = n->GetChildAt(0);
+    nChild = n->GetFirstChild();
   }
 
   return n;
 }
 
 nsINode*
 nsContentIterator::GetDeepLastChild(nsINode *aRoot, nsTArray<PRInt32> *aIndexes)
 {
@@ -742,17 +742,17 @@ nsContentIterator::NextNode(nsINode *aNo
   nsINode *n = aNode;
   nsINode *nextNode = nsnull;
 
   if (mPre)  // if we are a Pre-order iterator, use pre-order
   {
     // if it has children then next node is first child
     if (NodeHasChildren(n))
     {
-      nsINode *nFirstChild = n->GetChildAt(0);
+      nsINode *nFirstChild = n->GetFirstChild();
 
       // update cache
       if (aIndexes)
       {
         // push an entry on the index stack
         aIndexes->AppendElement(0);
       }
       else mCachedIndex = 0;
@@ -884,17 +884,18 @@ nsContentIterator::PrevNode(nsINode *aNo
   }
   else  // post-order
   {
     PRInt32 numChildren = n->GetChildCount();
   
     // if it has children then prev node is last child
     if (numChildren)
     {
-      nsINode *nLastChild = n->GetChildAt(--numChildren);
+      nsINode *nLastChild = n->GetLastChild();
+      numChildren--;
 
       // update cache
       if (aIndexes)
       {
         // push an entry on the index stack
         aIndexes->AppendElement(numChildren);
       }
       else mCachedIndex = numChildren;
@@ -1295,17 +1296,17 @@ nsresult nsContentSubtreeIterator::Init(
   if (NS_FAILED(aRange->GetEndContainer(getter_AddRefs(endParent))) || !endParent)
     return NS_ERROR_FAILURE;
   nEndP = do_QueryInterface(endParent);
   aRange->GetEndOffset(&endIndx);
 
   // short circuit when start node == end node
   if (startParent == endParent)
   {
-    nsINode* nChild = nStartP->GetChildAt(0);
+    nsINode* nChild = nStartP->GetFirstChild();
   
     if (!nChild) // no children, must be a text node or empty container
     {
       // all inside one text node - empty subtree iterator
       MakeEmpty();
       return NS_OK;
     }
     else
@@ -1485,17 +1486,17 @@ nsContentSubtreeIterator::Next()
   nextNode = GetDeepFirstChild(nextNode);
   return GetTopAncestorInRange(nextNode, address_of(mCurNode));
 */
   PRInt32 i = mEndNodes.IndexOf(nextNode);
   while (i != -1)
   {
     // as long as we are finding ancestors of the endpoint of the range,
     // dive down into their children
-    nextNode = nextNode->GetChildAt(0);
+    nextNode = nextNode->GetFirstChild();
     NS_ASSERTION(nextNode, "Iterator error, expected a child node!");
 
     // should be impossible to get a null pointer.  If we went all the way
     // down the child chain to the bottom without finding an interior node, 
     // then the previous node should have been the last, which was
     // was tested at top of routine.
     i = mEndNodes.IndexOf(nextNode);
   }
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -3777,19 +3777,19 @@ nsContentUtils::SetNodeTextContent(nsICo
 
   textContent->SetText(aValue, PR_TRUE);
 
   return aContent->AppendChildTo(textContent, PR_TRUE);
 }
 
 static void AppendNodeTextContentsRecurse(nsINode* aNode, nsAString& aResult)
 {
-  nsIContent* child;
-  PRUint32 i;
-  for (i = 0; (child = aNode->GetChildAt(i)); ++i) {
+  for (nsIContent* child = aNode->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     if (child->IsElement()) {
       AppendNodeTextContentsRecurse(child, aResult);
     }
     else if (child->IsNodeOfType(nsINode::eTEXT)) {
       child->AppendTextTo(aResult);
     }
   }
 }
@@ -3801,32 +3801,32 @@ nsContentUtils::AppendNodeTextContent(ns
 {
   if (aNode->IsNodeOfType(nsINode::eTEXT)) {
     static_cast<nsIContent*>(aNode)->AppendTextTo(aResult);
   }
   else if (aDeep) {
     AppendNodeTextContentsRecurse(aNode, aResult);
   }
   else {
-    nsIContent* child;
-    PRUint32 i;
-    for (i = 0; (child = aNode->GetChildAt(i)); ++i) {
+    for (nsIContent* child = aNode->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
       if (child->IsNodeOfType(nsINode::eTEXT)) {
         child->AppendTextTo(aResult);
       }
     }
   }
 }
 
 PRBool
 nsContentUtils::HasNonEmptyTextContent(nsINode* aNode)
 {
-  nsIContent* child;
-  PRUint32 i;
-  for (i = 0; (child = aNode->GetChildAt(i)); ++i) {
+  for (nsIContent* child = aNode->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     if (child->IsNodeOfType(nsINode::eTEXT) &&
         child->TextLength() > 0) {
       return PR_TRUE;
     }
   }
 
   return PR_FALSE;
 }
--- a/content/base/src/nsDOMAttribute.cpp
+++ b/content/base/src/nsDOMAttribute.cpp
@@ -655,16 +655,21 @@ nsDOMAttribute::SetTextContent(const nsA
     document->WarnOnceAbout(nsIDocument::eTextContent);
   }
   return SetNodeValue(aTextContent);
 }
 
 NS_IMETHODIMP
 nsDOMAttribute::IsSameNode(nsIDOMNode *other, PRBool *aResult)
 {
+  nsIDocument* document = GetOwnerDoc();
+  if (document) {
+    document->WarnOnceAbout(nsIDocument::eIsSameNode);
+  }
+
   *aResult = other == this;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMAttribute::Contains(nsIDOMNode* aOther, PRBool* aReturn)
 {
   return nsINode::Contains(aOther, aReturn);
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -4928,22 +4928,21 @@ GetElementByAttribute(nsIContent* aConte
                       nsIDOMElement** aResult)
 {
   if (aUniversalMatch ? aContent->HasAttr(kNameSpaceID_None, aAttrName) :
                         aContent->AttrValueIs(kNameSpaceID_None, aAttrName,
                                               aAttrValue, eCaseMatters)) {
     return CallQueryInterface(aContent, aResult);
   }
 
-  PRUint32 childCount = aContent->GetChildCount();
-
-  for (PRUint32 i = 0; i < childCount; ++i) {
-    nsIContent *current = aContent->GetChildAt(i);
-
-    GetElementByAttribute(current, aAttrName, aAttrValue, aUniversalMatch,
+  for (nsIContent* child = aContent->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
+
+    GetElementByAttribute(child, aAttrName, aAttrValue, aUniversalMatch,
                           aResult);
 
     if (*aResult)
       return NS_OK;
   }
 
   return NS_OK;
 }
@@ -5110,20 +5109,21 @@ Element*
 nsIDocument::GetHtmlChildElement(nsIAtom* aTag)
 {
   Element* html = GetHtmlElement();
   if (!html)
     return nsnull;
 
   // Look for the element with aTag inside html. This needs to run
   // forwards to find the first such element.
-  for (PRUint32 i = 0; i < html->GetChildCount(); ++i) {
-    nsIContent* result = html->GetChildAt(i);
-    if (result->Tag() == aTag && result->IsHTML())
-      return result->AsElement();
+  for (nsIContent* child = html->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
+    if (child->IsHTML(aTag))
+      return child->AsElement();
   }
   return nsnull;
 }
 
 nsIContent*
 nsDocument::GetTitleContent(PRUint32 aNamespace)
 {
   // mMayHaveTitleElement will have been set to true if any HTML or SVG
@@ -5821,16 +5821,17 @@ NS_IMETHODIMP
 nsDocument::SetTextContent(const nsAString & aTextContent)
 {
   return nsINode::SetTextContent(aTextContent);
 }
 
 NS_IMETHODIMP
 nsDocument::IsSameNode(nsIDOMNode *other, PRBool *aResult)
 {
+  WarnOnceAbout(eIsSameNode);
   *aResult = other == this;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::LookupPrefix(const nsAString & namespaceURI, nsAString & aResult)
 {
   SetDOMStringToNull(aResult);
@@ -5872,43 +5873,46 @@ NS_IMETHODIMP
 nsDocument::Contains(nsIDOMNode* aOther, PRBool* aReturn)
 {
   return nsINode::Contains(aOther, aReturn);
 }
 
 NS_IMETHODIMP
 nsDocument::GetInputEncoding(nsAString& aInputEncoding)
 {
+  WarnOnceAbout(eInputEncoding);
   if (mHaveInputEncoding) {
     return GetCharacterSet(aInputEncoding);
   }
 
   SetDOMStringToNull(aInputEncoding);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetXmlEncoding(nsAString& aXmlEncoding)
 {
+  WarnOnceAbout(eXmlEncoding);
   if (!IsHTML() &&
       mXMLDeclarationBits & XML_DECLARATION_BITS_DECLARATION_EXISTS &&
       mXMLDeclarationBits & XML_DECLARATION_BITS_ENCODING_EXISTS) {
     // XXX We don't store the encoding given in the xml declaration.
     // For now, just output the inputEncoding which we do store.
     GetInputEncoding(aXmlEncoding);
   } else {
     SetDOMStringToNull(aXmlEncoding);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetXmlStandalone(PRBool *aXmlStandalone)
 {
+  WarnOnceAbout(eXmlStandalone);
   *aXmlStandalone = 
     !IsHTML() &&
     mXMLDeclarationBits & XML_DECLARATION_BITS_DECLARATION_EXISTS &&
     mXMLDeclarationBits & XML_DECLARATION_BITS_STANDALONE_EXISTS &&
     mXMLDeclarationBits & XML_DECLARATION_BITS_STANDALONE_YES;
 
   return NS_OK;
 }
@@ -5924,16 +5928,17 @@ nsDocument::GetMozSyntheticDocument(PRBo
 {
   *aSyntheticDocument = mIsSyntheticDocument;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetXmlVersion(nsAString& aXmlVersion)
 {
+  WarnOnceAbout(eXmlVersion);
   if (IsHTML()) {
     SetDOMStringToNull(aXmlVersion);
     return NS_OK;
   }
 
   // If there is no declaration, the value is "1.0".
 
   // XXX We only support "1.0", so always output "1.0" until that changes.
@@ -6008,17 +6013,17 @@ BlastSubtreeToPieces(nsINode *aNode)
         // XXX Should we abort here?
         NS_ASSERTION(NS_SUCCEEDED(rv), "Uhoh, UnsetAttr shouldn't fail!");
       }
     }
   }
 
   count = aNode->GetChildCount();
   for (i = 0; i < count; ++i) {
-    BlastSubtreeToPieces(aNode->GetChildAt(0));
+    BlastSubtreeToPieces(aNode->GetFirstChild());
 #ifdef DEBUG
     nsresult rv =
 #endif
       aNode->RemoveChildAt(0, PR_FALSE);
 
     // XXX Should we abort here?
     NS_ASSERTION(NS_SUCCEEDED(rv), "Uhoh, RemoveChildAt shouldn't fail!");
   }
@@ -8151,17 +8156,17 @@ static const char* kWarnings[] = {
 #include "nsDeprecatedOperationList.h"
   nsnull
 };
 #undef DEPRECATED_OPERATION
 
 void
 nsIDocument::WarnOnceAbout(DeprecatedOperations aOperation)
 {
-  PR_STATIC_ASSERT(eDeprecatedOperationCount <= 32);
+  PR_STATIC_ASSERT(eDeprecatedOperationCount <= 64);
   if (mWarnedAbout & (1 << aOperation)) {
     return;
   }
   mWarnedAbout |= (1 << aOperation);
   nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
                                   kWarnings[aOperation],
                                   nsnull, 0,
                                   nsnull,
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -841,16 +841,18 @@ nsGenericDOMDataNode::GetWholeText(nsASt
 }
 
 nsresult
 nsGenericDOMDataNode::ReplaceWholeText(const nsAString& aContent,
                                        nsIDOMText **aResult)
 {
   *aResult = nsnull;
 
+  GetOwnerDoc()->WarnOnceAbout(nsIDocument::eReplaceWholeText);
+
   // Handle parent-less nodes
   nsCOMPtr<nsIContent> parent = GetParent();
   if (!parent) {
     if (aContent.IsEmpty()) {
       return NS_OK;
     }
 
     SetNodeValue(aContent);
--- a/content/base/src/nsGenericDOMDataNode.h
+++ b/content/base/src/nsGenericDOMDataNode.h
@@ -329,16 +329,17 @@ protected:
   nsresult SplitText(PRUint32 aOffset, nsIDOMText** aReturn);
 
   nsresult GetWholeText(nsAString& aWholeText);
 
   nsresult ReplaceWholeText(const nsAString& aContent, nsIDOMText **aReturn);
 
   nsresult GetIsElementContentWhitespace(PRBool *aReturn)
   {
+    GetOwnerDoc()->WarnOnceAbout(nsIDocument::eIsElementContentWhitespace);
     *aReturn = TextIsOnlyWhitespace();
     return NS_OK;
   }
 
   static PRInt32 FirstLogicallyAdjacentTextNode(nsIContent* aParent,
                                                 PRInt32 aIndex);
 
   static PRInt32 LastLogicallyAdjacentTextNode(nsIContent* aParent,
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -453,17 +453,17 @@ nsINode::GetChildNodes(nsIDOMNodeList** 
   NS_ADDREF(*aChildNodes);
 
   return NS_OK;
 }
 
 nsresult
 nsINode::GetFirstChild(nsIDOMNode** aNode)
 {
-  nsIContent* child = GetChildAt(0);
+  nsIContent* child = GetFirstChild();
   if (child) {
     return CallQueryInterface(child, aNode);
   }
 
   *aNode = nsnull;
 
   return NS_OK;
 }
@@ -2870,19 +2870,19 @@ BindNodesInInsertPoints(nsXBLBinding* aB
 #ifdef MOZ_XUL
     nsCOMPtr<nsIXULDocument> xulDoc = do_QueryInterface(aDocument);
 #endif
     PRUint32 i;
     for (i = 0; i < inserts->Length(); ++i) {
       nsCOMPtr<nsIContent> insertRoot =
         inserts->ElementAt(i)->GetDefaultContent();
       if (insertRoot) {
-        PRUint32 j;
-        for (j = 0; j < insertRoot->GetChildCount(); ++j) {
-          nsCOMPtr<nsIContent> child = insertRoot->GetChildAt(j);
+        for (nsCOMPtr<nsIContent> child = insertRoot->GetFirstChild();
+             child;
+             child = child->GetNextSibling()) {
           rv = child->BindToTree(aDocument, aInsertParent,
                                  aBinding->GetBoundElement(), allowScripts);
           NS_ENSURE_SUCCESS(rv, rv);
 
 #ifdef MOZ_XUL
           if (xulDoc) {
             xulDoc->AddSubtreeToDocument(child);
           }
@@ -3004,19 +3004,19 @@ nsGenericElement::BindToTree(nsIDocument
       nsBindingManager* bmgr = ownerDoc->BindingManager();
 
       // First check if we have a binding...
       nsXBLBinding* contBinding =
         GetFirstBindingWithContent(bmgr, this);
       if (contBinding) {
         nsCOMPtr<nsIContent> anonRoot = contBinding->GetAnonymousContent();
         PRBool allowScripts = contBinding->AllowScripts();
-        PRUint32 i;
-        for (i = 0; i < anonRoot->GetChildCount(); ++i) {
-          nsCOMPtr<nsIContent> child = anonRoot->GetChildAt(i);
+        for (nsCOMPtr<nsIContent> child = anonRoot->GetFirstChild();
+             child;
+             child = child->GetNextSibling()) {
           rv = child->BindToTree(aDocument, this, this, allowScripts);
           NS_ENSURE_SUCCESS(rv, rv);
         }
 
         // ...then check if we have content in insertion points that are
         // direct children of the <content>
         rv = BindNodesInInsertPoints(contBinding, this, aDocument);
         NS_ENSURE_SUCCESS(rv, rv);
@@ -3936,30 +3936,29 @@ PRBool IsAllowedAsChild(nsIContent* aNew
       // they're allowed inside elements.  If we ever change this to allow
       // doctype nodes in document fragments, we'll need to update this code
       if (!aParent->IsNodeOfType(nsINode::eDOCUMENT)) {
         // All good here
         return PR_TRUE;
       }
 
       PRBool sawElement = PR_FALSE;
-      PRUint32 count = aNewChild->GetChildCount();
-      for (PRUint32 index = 0; index < count; ++index) {
-        nsIContent* childContent = aNewChild->GetChildAt(index);
-        NS_ASSERTION(childContent, "Something went wrong");
-        if (childContent->IsElement()) {
+      for (nsIContent* child = aNewChild->GetFirstChild();
+           child;
+           child = child->GetNextSibling()) {
+        if (child->IsElement()) {
           if (sawElement) {
             // Can't put two elements into a document
             return PR_FALSE;
           }
           sawElement = PR_TRUE;
         }
         // If we can put this content at the the right place, we might be ok;
         // if not, we bail out.
-        if (!IsAllowedAsChild(childContent, aParent, aIsReplace, aRefChild)) {
+        if (!IsAllowedAsChild(child, aParent, aIsReplace, aRefChild)) {
           return PR_FALSE;
         }
       }
 
       // Everything in the fragment checked out ok, so we can stick it in here
       return PR_TRUE;
     }
   default:
@@ -4123,18 +4122,19 @@ nsINode::ReplaceOrInsertBefore(PRBool aR
     if (!count) {
       return NS_OK;
     }
 
     // Copy the children into a separate array to avoid having to deal with
     // mutations to the fragment while we're inserting.
     nsAutoTArray<nsCOMPtr<nsIContent>, 50> fragChildren;
     fragChildren.SetCapacity(count);
-    for (PRUint32 i = 0; i < count; i++) {
-      nsIContent* child = newContent->GetChildAt(i);
+    for (nsIContent* child = newContent->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
       NS_ASSERTION(child->GetCurrentDoc() == nsnull,
                    "How did we get a child with a current doc?");
       fragChildren.AppendElement(child);
     }
 
     // Remove the children from the fragment.
     for (PRUint32 i = count; i > 0;) {
       newContent->RemoveChildAt(--i, PR_TRUE);
@@ -4205,16 +4205,20 @@ nsINode::IsEqualNode(nsIDOMNode* aOther,
   nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
   *aReturn = IsEqualTo(other);
   return NS_OK;
 }
 
 nsresult
 nsINode::IsSameNode(nsIDOMNode* aOther, PRBool* aReturn)
 {
+  nsIDocument* owner = GetOwnerDoc();
+  if (owner) {
+    owner->WarnOnceAbout(nsIDocument::eIsSameNode);
+  }
   nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
   *aReturn = other == this;
   return NS_OK;
 }
 
 //----------------------------------------------------------------------
 
 // nsISupports implementation
@@ -4995,23 +4999,22 @@ nsGenericElement::List(FILE* out, PRInt3
 
   ListAttributes(out);
 
   fprintf(out, " state=[%llx]", State().GetInternalValue());
   fprintf(out, " flags=[%08x]", static_cast<unsigned int>(GetFlags()));
   fprintf(out, " primaryframe=%p", static_cast<void*>(GetPrimaryFrame()));
   fprintf(out, " refcount=%d<", mRefCnt.get());
 
-  PRUint32 i, length = GetChildCount();
-  if (length > 0) {
+  nsIContent* child = GetFirstChild();
+  if (child) {
     fputs("\n", out);
-
-    for (i = 0; i < length; ++i) {
-      nsIContent *kid = GetChildAt(i);
-      kid->List(out, aIndent + 1);
+    
+    for (; child; child = child->GetNextSibling()) {
+      child->List(out, aIndent + 1);
     }
 
     for (indent = aIndent; --indent >= 0; ) fputs("  ", out);
   }
 
   fputs(">\n", out);
   
   nsGenericElement* nonConstThis = const_cast<nsGenericElement*>(this);
@@ -5022,22 +5025,23 @@ nsGenericElement::List(FILE* out, PRInt3
     // Note: not listing nsIAnonymousContentCreator-created content...
 
     nsBindingManager* bindingManager = document->BindingManager();
     nsCOMPtr<nsIDOMNodeList> anonymousChildren;
     bindingManager->GetAnonymousNodesFor(nonConstThis,
                                          getter_AddRefs(anonymousChildren));
 
     if (anonymousChildren) {
+      PRUint32 length;
       anonymousChildren->GetLength(&length);
       if (length > 0) {
         for (indent = aIndent; --indent >= 0; ) fputs("  ", out);
         fputs("anonymous-children<\n", out);
 
-        for (i = 0; i < length; ++i) {
+        for (PRUint32 i = 0; i < length; ++i) {
           nsCOMPtr<nsIDOMNode> node;
           anonymousChildren->Item(i, getter_AddRefs(node));
           nsCOMPtr<nsIContent> child = do_QueryInterface(node);
           child->List(out, aIndent + 1);
         }
 
         for (indent = aIndent; --indent >= 0; ) fputs("  ", out);
         fputs(">\n", out);
@@ -5045,23 +5049,24 @@ nsGenericElement::List(FILE* out, PRInt3
     }
 
     if (bindingManager->HasContentListFor(nonConstThis)) {
       nsCOMPtr<nsIDOMNodeList> contentList;
       bindingManager->GetContentListFor(nonConstThis,
                                         getter_AddRefs(contentList));
 
       NS_ASSERTION(contentList != nsnull, "oops, binding manager lied");
-
+      
+      PRUint32 length;
       contentList->GetLength(&length);
       if (length > 0) {
         for (indent = aIndent; --indent >= 0; ) fputs("  ", out);
         fputs("content-list<\n", out);
 
-        for (i = 0; i < length; ++i) {
+        for (PRUint32 i = 0; i < length; ++i) {
           nsCOMPtr<nsIDOMNode> node;
           contentList->Item(i, getter_AddRefs(node));
           nsCOMPtr<nsIContent> child = do_QueryInterface(node);
           child->List(out, aIndent + 1);
         }
 
         for (indent = aIndent; --indent >= 0; ) fputs("  ", out);
         fputs(">\n", out);
@@ -5082,21 +5087,21 @@ nsGenericElement::DumpContent(FILE* out,
   fputs(NS_LossyConvertUTF16toASCII(buf).get(), out);
 
   if(aDumpAll) ListAttributes(out);
 
   fputs(">", out);
 
   if(aIndent) fputs("\n", out);
 
-  PRInt32 index, kids = GetChildCount();
-  for (index = 0; index < kids; index++) {
-    nsIContent *kid = GetChildAt(index);
+  for (nsIContent* child = GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     PRInt32 indent = aIndent ? aIndent + 1 : 0;
-    kid->DumpContent(out, indent, aDumpAll);
+    child->DumpContent(out, indent, aDumpAll);
   }
   for (indent = aIndent; --indent >= 0; ) fputs("  ", out);
   fputs("</", out);
   fputs(NS_LossyConvertUTF16toASCII(buf).get(), out);
   fputs(">", out);
 
   if(aIndent) fputs("\n", out);
 }
--- a/content/base/src/nsNodeUtils.cpp
+++ b/content/base/src/nsNodeUtils.cpp
@@ -654,20 +654,21 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNod
                     aNodesWithProperties.AppendObject(clonedAttrChildNode);
         NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
       }
     }
   }
   // XXX End of workaround for broken attribute nodes.
   else if (aDeep || aNode->IsNodeOfType(nsINode::eATTRIBUTE)) {
     // aNode's children.
-    PRUint32 i, length = aNode->GetChildCount();
-    for (i = 0; i < length; ++i) {
+    for (nsIContent* cloneChild = aNode->GetFirstChild();
+         cloneChild;
+       cloneChild = cloneChild->GetNextSibling()) {
       nsCOMPtr<nsINode> child;
-      rv = CloneAndAdopt(aNode->GetChildAt(i), aClone, PR_TRUE, nodeInfoManager,
+      rv = CloneAndAdopt(cloneChild, aClone, PR_TRUE, nodeInfoManager,
                          aCx, aNewScope, aNodesWithProperties, clone,
                          getter_AddRefs(child));
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   // XXX setting document on some nodes not in a document so XBL will bind
   // and chrome won't break. Make XBL bind to document-less nodes!
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -1921,23 +1921,20 @@ nsObjectLoadingContent::GetPluginSupport
   if (aContent->Tag() == nsGkAtoms::embed ||
       aContent->Tag() == nsGkAtoms::applet) {
     return GetPluginDisabledState(aContentType);
   }
 
   PRBool hasAlternateContent = PR_FALSE;
 
   // Search for a child <param> with a pluginurl name
-  PRUint32 count = aContent->GetChildCount();
-  for (PRUint32 i = 0; i < count; ++i) {
-    nsIContent* child = aContent->GetChildAt(i);
-    NS_ASSERTION(child, "GetChildCount lied!");
-
-    if (child->IsHTML() &&
-        child->Tag() == nsGkAtoms::param) {
+  for (nsIContent* child = aContent->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
+    if (child->IsHTML(nsGkAtoms::param)) {
       if (child->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
                              NS_LITERAL_STRING("pluginurl"), eIgnoreCase)) {
         return GetPluginDisabledState(aContentType);
       }
     } else if (!hasAlternateContent) {
       hasAlternateContent =
         nsStyleUtil::IsSignificantChild(child, PR_TRUE, PR_FALSE);
     }
--- a/content/base/src/nsXHTMLContentSerializer.cpp
+++ b/content/base/src/nsXHTMLContentSerializer.cpp
@@ -493,21 +493,20 @@ nsXHTMLContentSerializer::AfterElementSt
   if (aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
       mRewriteEncodingDeclaration &&
       name == nsGkAtoms::head) {
 
     // Check if there already are any content-type meta children.
     // If there are, they will be modified to use the correct charset.
     // If there aren't, we'll insert one here.
     PRBool hasMeta = PR_FALSE;
-    PRUint32 i, childCount = aContent->GetChildCount();
-    for (i = 0; i < childCount; ++i) {
-      nsIContent* child = aContent->GetChildAt(i);
-      if (child->IsHTML() &&
-          child->Tag() == nsGkAtoms::meta &&
+    for (nsIContent* child = aContent->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
+      if (child->IsHTML(nsGkAtoms::meta) &&
           child->HasAttr(kNameSpaceID_None, nsGkAtoms::content)) {
         nsAutoString header;
         child->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header);
 
         if (header.LowerCaseEqualsLiteral("content-type")) {
           hasMeta = PR_TRUE;
           break;
         }
@@ -1014,22 +1013,20 @@ nsXHTMLContentSerializer::IsFirstChildOf
   }
   else
     return PR_FALSE;
 }
 
 PRBool
 nsXHTMLContentSerializer::HasNoChildren(nsIContent * aContent) {
 
-  PRUint32 i, childCount = aContent->GetChildCount();
-
-  for (i = 0; i < childCount; ++i) {
-
-    nsIContent* child = aContent->GetChildAt(i);
-
+  for (nsIContent* child = aContent->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
+       
     if (!child->IsNodeOfType(nsINode::eTEXT))
       return PR_FALSE;
 
     if (child->TextLength())
       return PR_FALSE;
   }
 
   return PR_TRUE;
--- a/content/base/test/Makefile.in
+++ b/content/base/test/Makefile.in
@@ -214,16 +214,17 @@ include $(topsrcdir)/config/rules.mk
 		file_XHR_pass1.xml \
 		file_XHR_pass2.txt \
 		file_XHR_pass3.txt \
 		file_XHR_pass3.txt^headers^ \
 		file_XHR_fail1.txt \
 		file_XHR_fail1.txt^headers^ \
 		file_XHR_binary1.bin \
 		file_XHR_binary1.bin^headers^ \
+		file_XHR_binary2.bin \
 		test_bug428847.html \
 		file_bug428847-1.xhtml \
 		file_bug428847-2.xhtml \
 		test_bug431701.html \
 		test_bug431833.html \
 		test_bug435425.html \
 		bug435425.sjs \
 		bug435425_redirect.sjs \
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9f442b092d4eec5c07087f507aef024c031658c2
GIT binary patch
literal 65536
zc%1Fe0}>bp006Mswr$(C&DFMT+qSvYT5a35ZM%1UNAiON2pA}Ekf6bWhX@%ebeOQ=
z!bgZ0DRPvk(W1wQ87p?2xbfmANSG*blBCI!r%0J9b(*y4(r3t+DRY*r*|O)znJagm
zy!rAMC|Ia)k)p+lmnd1PbeXc{%2%jZsdAO7)vDL1`A@Cdb?Vlu-=JZm#!Z?wYu=(|
ztJZDWwrk&^W2eqtx_0Z{qi3()efsw6KVaaX!9#`)8$M#>sL^A_jvGH=;-tw_rcRqa
zW9F>cbLP&QzhL2_#Y>hhTmJ8VD^{*ry=LvY^&2*B`hWA5t=qQm*tu)>p1u3_A2@jE
z@R6g(j-NPr>hzhj=gwcac<J($tJkjIxOwaLoxAt$KX~})@sp>|p1*kc>h+tq@7{m-
z`04YPuiw7^`1$L10Dpgfe}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}
ze}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}
ze}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}
ze}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}
ze}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}e}8{}
Me}8{}fB(P#KfAhzasU7T
--- a/content/base/test/test_XHR.html
+++ b/content/base/test/test_XHR.html
@@ -173,17 +173,17 @@ is(xhr.status, 200, "wrong status");
 checkResponseTextAccessThrows(xhr);
 checkResponseXMLAccessThrows(xhr);
 checkResponseAccessThrows(xhr);
 checkResponseAccessThrows(xhr); // Check twice to ensure that we still throw
 
 // test response (responseType='blob')
 var onloadCount = 0;
 function checkOnloadCount() {
-  if (++onloadCount >= 2) SimpleTest.finish();
+  if (++onloadCount >= 3) SimpleTest.finish();
 };
 
 // with a simple text file
 xhr = new XMLHttpRequest();
 xhr.open("GET", 'file_XHR_pass2.txt', false); 
 xhr.responseType = 'blob';
 xhr.send(null);
 is(xhr.status, 200, "wrong status");
@@ -198,17 +198,18 @@ is(b.size, "hello pass\n".length, "wrong
 var fr = new FileReader();
 fr.onload = function() {
   ok(fr.result, "hello pass\n", "wrong values");
   checkOnloadCount();
 };
 fr.readAsBinaryString(b);
 
 // with a binary file
-xhr = new XMLHttpRequest();
+(function(){
+var xhr = new XMLHttpRequest();
 xhr.onreadystatechange = function() {
   switch (xhr.readyState) {
   case 2:
     is(xhr.status, 200, "wrong status");
     xhr.responseType = 'blob';
     break;
   case 4:
     b = xhr.response;
@@ -223,16 +224,47 @@ xhr.onreadystatechange = function() {
     xhr = null; // kill the XHR object
     SpecialPowers.gc();
     fr.readAsBinaryString(b);
     break;
   }
 };
 xhr.open("GET", 'file_XHR_binary1.bin', true);
 xhr.send(null);
+})();
+
+(function(){
+// with a larger binary file
+var xhr = new XMLHttpRequest();
+xhr.onreadystatechange = function() {
+  if (xhr.readyState == 4) {
+    b = xhr.response;
+    ok(b != null, "should have a non-null blob");
+    is(b.size, 65536, "wrong blob size");
+
+    var fr = new FileReader();
+    fr.onload = function() {
+      var u8 = new Uint8Array(fr.result);
+      for (var i = 0; i < 65536; i++) {
+        if (u8[i] !== (i & 255)) {
+          break;
+        }
+      }
+      is(i, 65536, "wrong value at offset " + i);
+      checkOnloadCount();
+    };
+    xhr = null; // kill the XHR object
+    SpecialPowers.gc();
+    fr.readAsArrayBuffer(b);
+  }
+};
+xhr.open("GET", 'file_XHR_binary2.bin', true);
+xhr.responseType = 'blob';
+xhr.send(null);
+})();
 
 var client = new XMLHttpRequest();
 client.onreadystatechange = function() {
     if(client.readyState == 4) {
       try {
         is(client.responseXML, null, "responseXML should be null.");
         is(client.responseText, "", "responseText should be empty string.");
         is(client.response, "", "response should be empty string.");
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -3656,24 +3656,20 @@ nsGenericHTMLElement::SyncEditorsOnSubtr
   if (element) {
     nsCOMPtr<nsIEditor> editor = element->GetAssociatedEditor();
     if (editor) {
       editor->SyncRealTimeSpell();
     }
   }
 
   /* Sync all children */
-  PRUint32 childCount = content->GetChildCount();
-  for (PRUint32 i = 0; i < childCount; ++i) {
-    nsIContent* childContent = content->GetChildAt(i);
-    NS_ASSERTION(childContent,
-                 "DOM mutated unexpectedly while syncing editors!");
-    if (childContent) {
-      SyncEditorsOnSubtree(childContent);
-    }
+  for (nsIContent* child = content->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
+    SyncEditorsOnSubtree(child);
   }
 }
 
 void
 nsGenericHTMLElement::RecompileScriptEventListeners()
 {
     PRInt32 i, count = mAttrsAndChildren.AttrCount();
     for (i = 0; i < count; ++i) {
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -598,23 +598,20 @@ NS_IMETHODIMP nsHTMLMediaElement::Load()
   AbortExistingLoads();
   QueueSelectResourceTask();
   mIsRunningLoadMethod = PR_FALSE;
   return NS_OK;
 }
 
 static PRBool HasSourceChildren(nsIContent *aElement)
 {
-  PRUint32 count = aElement->GetChildCount();
-  for (PRUint32 i = 0; i < count; ++i) {
-    nsIContent* child = aElement->GetChildAt(i);
-    NS_ASSERTION(child, "GetChildCount lied!");
-    if (child &&
-        child->Tag() == nsGkAtoms::source &&
-        child->IsHTML())
+  for (nsIContent* child = aElement->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
+    if (child->IsHTML(nsGkAtoms::source))
     {
       return PR_TRUE;
     }
   }
   return PR_FALSE;
 }
 
 void nsHTMLMediaElement::SelectResource()
@@ -2523,19 +2520,17 @@ nsIContent* nsHTMLMediaElement::GetNextS
 
     // Advance the range to the next child.
     rv = mSourcePointer->SetStart(thisDomNode, startOffset+1);
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     nsIContent* child = GetChildAt(startOffset);
 
     // If child is a <source> element, it is the next candidate.
-    if (child &&
-        child->Tag() == nsGkAtoms::source &&
-        child->IsHTML())
+    if (child && child->IsHTML(nsGkAtoms::source))
     {
       mSourceLoadCandidate = child;
       return child;
     }
   }
   NS_NOTREACHED("Execution should not reach here!");
   return nsnull;
 }
--- a/content/html/content/src/nsHTMLSelectElement.cpp
+++ b/content/html/content/src/nsHTMLSelectElement.cpp
@@ -386,19 +386,20 @@ nsHTMLSelectElement::InsertOptionsIntoLi
   if (aDepth == 0) {
     mNonOptionChildren++;
   }
 
   // Recurse down into optgroups
   if (aOptions->IsHTML(nsGkAtoms::optgroup)) {
     mOptGroupCount++;
 
-    PRUint32 numChildren = aOptions->GetChildCount();
-    for (PRUint32 i = 0; i < numChildren; ++i) {
-      nsresult rv = InsertOptionsIntoListRecurse(aOptions->GetChildAt(i),
+    for (nsIContent* child = aOptions->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
+      nsresult rv = InsertOptionsIntoListRecurse(child,
                                                  aInsertIndex, aDepth+1);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   return NS_OK;
 }
 
@@ -430,19 +431,21 @@ nsHTMLSelectElement::RemoveOptionsFromLi
   if (aDepth == 0) {
     mNonOptionChildren--;
   }
 
   // Recurse down deeper for options
   if (mOptGroupCount && aOptions->IsHTML(nsGkAtoms::optgroup)) {
     mOptGroupCount--;
 
-    PRUint32 numChildren = aOptions->GetChildCount();
-    for (PRUint32 i = 0; i < numChildren; ++i) {
-      nsresult rv = RemoveOptionsFromListRecurse(aOptions->GetChildAt(i),
+    for (nsIContent* child = aOptions->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
+
+      nsresult rv = RemoveOptionsFromListRecurse(child,
                                                  aRemoveIndex,
                                                  aNumRemoved,
                                                  aDepth + 1);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   return NS_OK;
--- a/content/html/content/src/nsHTMLTableElement.cpp
+++ b/content/html/content/src/nsHTMLTableElement.cpp
@@ -405,22 +405,21 @@ nsHTMLTableElement::SetCaption(nsIDOMHTM
   }
 
   return rv;
 }
 
 already_AddRefed<nsIDOMHTMLTableSectionElement>
 nsHTMLTableElement::GetSection(nsIAtom *aTag)
 {
-  PRUint32 childCount = GetChildCount();
-
   nsCOMPtr<nsIDOMHTMLTableSectionElement> section;
 
-  for (PRUint32 i = 0; i < childCount; ++i) {
-    nsIContent *child = GetChildAt(i);
+  for (nsIContent* child = nsINode::GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
 
     section = do_QueryInterface(child);
 
     if (section && child->NodeInfo()->Equals(aTag)) {
       nsIDOMHTMLTableSectionElement *result = section;
       NS_ADDREF(result);
 
       return result;
@@ -762,19 +761,19 @@ nsHTMLTableElement::InsertRow(PRInt32 aI
     }
   }
   else
   { // the row count was 0, so 
     // find the first row group and insert there as first child
     nsCOMPtr<nsIDOMNode> rowGroup;
 
     PRInt32 namespaceID = mNodeInfo->NamespaceID();
-    PRUint32 childCount = GetChildCount();
-    for (PRUint32 i = 0; i < childCount; ++i) {
-      nsIContent* child = GetChildAt(i);
+    for (nsIContent* child = nsINode::GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
       nsINodeInfo *childInfo = child->NodeInfo();
       nsIAtom *localName = childInfo->NameAtom();
       if (childInfo->NamespaceID() == namespaceID &&
           (localName == nsGkAtoms::thead ||
            localName == nsGkAtoms::tbody ||
            localName == nsGkAtoms::tfoot)) {
         rowGroup = do_QueryInterface(child);
         NS_ASSERTION(rowGroup, "HTML node did not QI to nsIDOMNode");
--- a/content/html/content/src/nsTextEditorState.cpp
+++ b/content/html/content/src/nsTextEditorState.cpp
@@ -526,17 +526,17 @@ nsTextInputSelectionImpl::CompleteMove(P
   {
     offset = parentDIV->GetChildCount();
 
     // Prevent the caret from being placed after the last
     // BR node in the content tree!
 
     if (offset > 0)
     {
-      nsIContent *child = parentDIV->GetChildAt(offset - 1);
+      nsIContent *child = parentDIV->GetLastChild();
 
       if (child->Tag() == nsGkAtoms::br)
       {
         --offset;
         hint = nsFrameSelection::HINTRIGHT; // for Bug 106855
       }
     }
   }
@@ -1748,17 +1748,17 @@ nsTextEditorState::SetValue(const nsAStr
     }
 #endif
 
     nsAutoString currentValue;
     if (!mEditorInitialized && IsSingleLineTextControl()) {
       // Grab the current value directly from the text node to make sure that we
       // deal with stale data correctly.
       NS_ASSERTION(mRootNode, "We should have a root node here");
-      nsIContent *textContent = mRootNode->GetChildAt(0);
+      nsIContent *textContent = mRootNode->GetFirstChild();
       nsCOMPtr<nsIDOMCharacterData> textNode = do_QueryInterface(textContent);
       if (textNode) {
         textNode->GetData(currentValue);
       }
     } else {
       mBoundFrame->GetText(currentValue);
     }
 
@@ -1973,18 +1973,18 @@ nsTextEditorState::UpdatePlaceholderText
   if (!mPlaceholderDiv)
     return;
 
   nsAutoString placeholderValue;
 
   nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
   content->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholderValue);
   nsContentUtils::RemoveNewlines(placeholderValue);
-  NS_ASSERTION(mPlaceholderDiv->GetChildAt(0), "placeholder div has no child");
-  mPlaceholderDiv->GetChildAt(0)->SetText(placeholderValue, aNotify);
+  NS_ASSERTION(mPlaceholderDiv->GetFirstChild(), "placeholder div has no child");
+  mPlaceholderDiv->GetFirstChild()->SetText(placeholderValue, aNotify);
   ValueWasChanged(aNotify);
 }
 
 void
 nsTextEditorState::SetPlaceholderClass(PRBool aVisible,
                                        PRBool aNotify)
 {
   NS_ASSERTION(mPlaceholderDiv, "This function should not be called if "
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -2695,19 +2695,19 @@ nsHTMLDocument::GetDocumentAllResult(con
 
   return cont;
 }
 
 static void
 NotifyEditableStateChange(nsINode *aNode, nsIDocument *aDocument,
                           PRBool aEditable)
 {
-  PRUint32 i, n = aNode->GetChildCount();
-  for (i = 0; i < n; ++i) {
-    nsIContent *child = aNode->GetChildAt(i);
+  for (nsIContent* child = aNode->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     if (child->HasFlag(NODE_IS_EDITABLE) != aEditable &&
         child->IsElement()) {
       child->AsElement()->UpdateState(true);
     }
     NotifyEditableStateChange(child, aDocument, aEditable);
   }
 }
 
--- a/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp
+++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp
@@ -152,19 +152,19 @@ SVGMotionSMILAnimationFunction::GetCalcM
 
 /*
  * Returns the first <mpath> child of the given element
  */
 
 static nsSVGMpathElement*
 GetFirstMpathChild(nsIContent* aElem)
 {
-  PRUint32 childCount = aElem->GetChildCount();
-  for (PRUint32 i = 0; i < childCount; ++i) {
-    nsIContent* child = aElem->GetChildAt(i);
+  for (nsIContent* child = aElem->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     if (child->Tag() == nsGkAtoms::mpath &&
         child->GetNameSpaceID() == kNameSpaceID_SVG) {
       return static_cast<nsSVGMpathElement*>(child);
     }
   }
 
   return nsnull;
 }
--- a/content/svg/content/src/nsSVGFilters.cpp
+++ b/content/svg/content/src/nsSVGFilters.cpp
@@ -1821,20 +1821,22 @@ nsSVGFEComponentTransferElement::Filter(
   PRUint8* sourceData = aSources[0]->mImage->Data();
   PRUint8* targetData = aTarget->mImage->Data();
   PRUint32 stride = aTarget->mImage->Stride();
 
   PRUint8 tableR[256], tableG[256], tableB[256], tableA[256];
   for (int i=0; i<256; i++)
     tableR[i] = tableG[i] = tableB[i] = tableA[i] = i;
   PRUint8* tables[] = { tableR, tableG, tableB, tableA };
-  PRUint32 count = GetChildCount();
-  for (PRUint32 k = 0; k < count; k++) {
+  for (nsIContent* childContent = nsINode::GetFirstChild();
+       childContent;
+       childContent = childContent->GetNextSibling()) {
+
     nsRefPtr<nsSVGComponentTransferFunctionElement> child;
-    CallQueryInterface(GetChildAt(k),
+    CallQueryInterface(childContent,
             (nsSVGComponentTransferFunctionElement**)getter_AddRefs(child));
     if (child) {
       child->GenerateLookupTable(tables[child->GetChannel()]);
     }
   }
 
   for (PRInt32 y = rect.y; y < rect.YMost(); y++) {
     for (PRInt32 x = rect.x; x < rect.XMost(); x++) {
@@ -2372,19 +2374,19 @@ nsSVGFEMergeElement::Filter(nsSVGFilterI
     ctx.Paint();
   }
   return NS_OK;
 }
 
 void
 nsSVGFEMergeElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
 {
-  PRUint32 count = GetChildCount();
-  for (PRUint32 i = 0; i < count; i++) {
-    nsIContent* child = GetChildAt(i);
+  for (nsIContent* child = nsINode::GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     nsRefPtr<nsSVGFEMergeNodeElement> node;
     CallQueryInterface(child, (nsSVGFEMergeNodeElement**)getter_AddRefs(node));
     if (node) {
       aSources.AppendElement(nsSVGStringInfo(node->In1(), node));
     }
   }
 }
 
@@ -4863,20 +4865,20 @@ nsSVGFELightingElement::Filter(nsSVGFilt
   nsCOMPtr<nsIDOMSVGFESpotLightElement> spotLight;
 
   nsIFrame* frame = GetPrimaryFrame();
   if (!frame) return NS_ERROR_FAILURE;
   nsStyleContext* style = frame->GetStyleContext();
 
   nscolor lightColor = style->GetStyleSVGReset()->mLightingColor;
 
-  // find specified light
-  PRUint32 count = GetChildCount();
-  for (PRUint32 k = 0; k < count; k++) {
-    nsCOMPtr<nsIContent> child = GetChildAt(k);
+  // find specified light  
+  for (nsCOMPtr<nsIContent> child = nsINode::GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     distantLight = do_QueryInterface(child);
     pointLight = do_QueryInterface(child);
     spotLight = do_QueryInterface(child);
     if (distantLight || pointLight || spotLight)
       break;
   }
 
   if (!distantLight && !pointLight && !spotLight)
--- a/content/svg/content/src/nsSVGSwitchElement.cpp
+++ b/content/svg/content/src/nsSVGSwitchElement.cpp
@@ -162,23 +162,22 @@ nsSVGSwitchElement::FindActiveChild() co
 {
   PRBool allowReorder = AttrValueIs(kNameSpaceID_None,
                                     nsGkAtoms::allowReorder,
                                     nsGkAtoms::yes, eCaseMatters);
 
   const nsAdoptingString& acceptLangs =
     Preferences::GetLocalizedString("intl.accept_languages");
 
-  PRUint32 count = GetChildCount();
-
   if (allowReorder && !acceptLangs.IsEmpty()) {
     PRInt32 bestLanguagePreferenceRank = -1;
     nsIContent *bestChild = nsnull;
-    for (PRUint32 i = 0; i < count; i++) {
-      nsIContent *child = GetChildAt(i);
+    for (nsIContent* child = nsINode::GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
       if (nsSVGFeatures::PassesConditionalProcessingTests(
             child, nsSVGFeatures::kIgnoreSystemLanguage)) {
         nsAutoString value;
         if (child->GetAttr(kNameSpaceID_None, nsGkAtoms::systemLanguage,
                            value)) {
           PRInt32 languagePreferenceRank =
             nsSVGFeatures::GetBestLanguagePreferenceRank(value, acceptLangs);
           switch (languagePreferenceRank) {
@@ -199,16 +198,17 @@ nsSVGSwitchElement::FindActiveChild() co
         } else if (!bestChild) {
           bestChild = child;
         }
       }
     }
     return bestChild;
   }
 
-  for (PRUint32 i = 0; i < count; i++) {
-    nsIContent *child = GetChildAt(i);
+  for (nsIContent* child = nsINode::GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     if (nsSVGFeatures::PassesConditionalProcessingTests(child, &acceptLangs)) {
       return child;
     }
   }
   return nsnull;
 }
--- a/content/svg/content/src/nsSVGUseElement.cpp
+++ b/content/svg/content/src/nsSVGUseElement.cpp
@@ -361,17 +361,17 @@ nsSVGUseElement::CreateAnonymousContent(
 
       newcontent->GetAttr(nsID, lname, value);
       svgNode->SetAttr(nsID, lname, name->GetPrefix(), value, PR_FALSE);
     }
 
     // move the children over
     PRUint32 num = newcontent->GetChildCount();
     for (i = 0; i < num; i++) {
-      nsCOMPtr<nsIContent> child = newcontent->GetChildAt(0);
+      nsCOMPtr<nsIContent> child = newcontent->GetFirstChild();
       newcontent->RemoveChildAt(0, PR_FALSE);
       svgNode->InsertChildAt(child, i, PR_TRUE);
     }
 
     newcontent = svgNode;
   }
 
   if (symbol || svg) {
--- a/content/xbl/src/nsXBLBinding.cpp
+++ b/content/xbl/src/nsXBLBinding.cpp
@@ -344,20 +344,19 @@ nsXBLBinding::InstallAnonymousContent(ns
   // to all its kids, which are anonymous content from the point of view of
   // aElement.
   // (2) The children's parent back pointer should not be to this synthetic root
   // but should instead point to the enclosing parent element.
   nsIDocument* doc = aElement->GetCurrentDoc();
   PRBool allowScripts = AllowScripts();
 
   nsAutoScriptBlocker scriptBlocker;
-
-  PRUint32 childCount = aAnonParent->GetChildCount();
-  for (PRUint32 i = 0; i < childCount; i++) {
-    nsIContent *child = aAnonParent->GetChildAt(i);
+  for (nsIContent* child = aAnonParent->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     child->UnbindFromTree();
     nsresult rv =
       child->BindToTree(doc, aElement, mBoundElement, allowScripts);
     if (NS_FAILED(rv)) {
       // Oh, well... Just give up.
       // XXXbz This really shouldn't be a void method!
       child->UnbindFromTree();
       return;
@@ -382,19 +381,19 @@ nsXBLBinding::UninstallAnonymousContent(
 {
   nsAutoScriptBlocker scriptBlocker;
   // Hold a strong ref while doing this, just in case.
   nsCOMPtr<nsIContent> anonParent = aAnonParent;
 #ifdef MOZ_XUL
   nsCOMPtr<nsIXULDocument> xuldoc =
     do_QueryInterface(aDocument);
 #endif
-  PRUint32 childCount = aAnonParent->GetChildCount();
-  for (PRUint32 i = 0; i < childCount; ++i) {
-    nsIContent* child = aAnonParent->GetChildAt(i);
+  for (nsIContent* child = aAnonParent->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     child->UnbindFromTree();
 #ifdef MOZ_XUL
     if (xuldoc) {
       xuldoc->RemoveSubtreeFromDocument(child);
     }
 #endif
   }
 }
@@ -571,21 +570,21 @@ RealizeDefaultContent(nsISupports* aKey,
         binding->InstallAnonymousContent(clonedContent, insParent);
 
         // Cache the clone so that it can be properly destroyed if/when our
         // other anonymous content is destroyed.
         currPoint->SetDefaultContent(clonedContent);
 
         // Now make sure the kids of the clone are added to the insertion point as
         // children.
-        PRUint32 cloneKidCount = clonedContent->GetChildCount();
-        for (PRUint32 k = 0; k < cloneKidCount; k++) {
-          nsIContent *cloneChild = clonedContent->GetChildAt(k);
-          bm->SetInsertionParent(cloneChild, insParent);
-          currPoint->AddChild(cloneChild);
+        for (nsIContent* child = clonedContent->GetFirstChild();
+             child;
+             child = child->GetNextSibling()) {
+          bm->SetInsertionParent(child, insParent);
+          currPoint->AddChild(child);
         }
       }
     }
   }
 
   return PL_DHASH_NEXT;
 }
 
@@ -1173,21 +1172,20 @@ nsXBLBinding::ChangeDocument(nsIDocument
                                           nsnull);
 
         nsXBLBinding::UninstallAnonymousContent(aOldDocument, anonymous);
       }
 
       // Make sure that henceforth we don't claim that mBoundElement's children
       // have insertion parents in the old document.
       nsBindingManager* bindingManager = aOldDocument->BindingManager();
-      for (PRUint32 i = mBoundElement->GetChildCount(); i > 0; --i) {
-        NS_ASSERTION(mBoundElement->GetChildAt(i-1),
-                     "Must have child at i for 0 <= i < GetChildCount()!");
-        bindingManager->SetInsertionParent(mBoundElement->GetChildAt(i-1),
-                                           nsnull);
+      for (nsIContent* child = mBoundElement->GetLastChild();
+           child;
+           child = child->GetPreviousSibling()) {
+        bindingManager->SetInsertionParent(child, nsnull);
       }
     }
   }
 }
 
 PRBool
 nsXBLBinding::InheritsStyle() const
 {
--- a/content/xbl/src/nsXBLPrototypeBinding.cpp
+++ b/content/xbl/src/nsXBLPrototypeBinding.cpp
@@ -809,20 +809,19 @@ nsXBLPrototypeBinding::ImplementsInterfa
   return PR_FALSE;
 }
 
 // Internal helpers ///////////////////////////////////////////////////////////////////////
 
 nsIContent*
 nsXBLPrototypeBinding::GetImmediateChild(nsIAtom* aTag)
 {
-  PRUint32 childCount = mBinding->GetChildCount();
-
-  for (PRUint32 i = 0; i < childCount; i++) {
-    nsIContent* child = mBinding->GetChildAt(i);
+  for (nsIContent* child = mBinding->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     if (child->NodeInfo()->Equals(aTag, kNameSpaceID_XBL)) {
       return child;
     }
   }
 
   return nsnull;
 }
  
@@ -1175,19 +1174,20 @@ nsXBLPrototypeBinding::ConstructAttribut
         token = nsCRT::strtok( newStr, ", ", &newStr );
       }
 
       nsMemory::Free(str);
     }
   }
 
   // Recur into our children.
-  PRUint32 childCount = aElement->GetChildCount();
-  for (PRUint32 i = 0; i < childCount; i++) {
-    ConstructAttributeTable(aElement->GetChildAt(i));
+  for (nsIContent* child = aElement->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
+    ConstructAttributeTable(child);
   }
 }
 
 static PRBool
 DeleteInsertionPointEntry(nsHashKey* aKey, void* aData, void* aClosure)
 {
   static_cast<nsXBLInsertionPointEntry*>(aData)->Release();
   return PR_TRUE;
@@ -1357,20 +1357,19 @@ nsXBLPrototypeBinding::ConstructInterfac
   return NS_OK;
 }
 
 void
 nsXBLPrototypeBinding::GetNestedChildren(nsIAtom* aTag, PRInt32 aNamespace,
                                          nsIContent* aContent,
                                          nsCOMArray<nsIContent> & aList)
 {
-  PRUint32 childCount = aContent->GetChildCount();
-
-  for (PRUint32 i = 0; i < childCount; i++) {
-    nsIContent *child = aContent->GetChildAt(i);
+  for (nsIContent* child = aContent->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
 
     if (child->NodeInfo()->Equals(aTag, aNamespace)) {
       aList.AppendObject(child);
     }
     else
       GetNestedChildren(aTag, aNamespace, child, aList);
   }
 }
--- a/content/xbl/src/nsXBLWindowKeyHandler.cpp
+++ b/content/xbl/src/nsXBLWindowKeyHandler.cpp
@@ -206,18 +206,19 @@ NS_IMPL_ISUPPORTS1(nsXBLWindowKeyHandler
 static void
 BuildHandlerChain(nsIContent* aContent, nsXBLPrototypeHandler** aResult)
 {
   *aResult = nsnull;
 
   // Since we chain each handler onto the next handler,
   // we'll enumerate them here in reverse so that when we
   // walk the chain they'll come out in the original order
-  for (PRUint32 j = aContent->GetChildCount(); j--; ) {
-    nsIContent *key = aContent->GetChildAt(j);
+  for (nsIContent* key = aContent->GetLastChild();
+       key;
+       key = key->GetPreviousSibling()) {
 
     if (key->NodeInfo()->Equals(nsGkAtoms::key, kNameSpaceID_XUL)) {
       // Check whether the key element has empty value at key/char attribute.
       // Such element is used by localizers for alternative shortcut key
       // definition on the locale. See bug 426501.
       nsAutoString valKey, valCharCode, valKeyCode;
       PRBool attrExists =
         key->GetAttr(kNameSpaceID_None, nsGkAtoms::key, valKey) ||
--- a/content/xml/document/src/nsXMLContentSink.cpp
+++ b/content/xml/document/src/nsXMLContentSink.cpp
@@ -301,19 +301,19 @@ nsXMLContentSink::DidBuildModel(PRBool a
   DidBuildModelImpl(aTerminated);
 
   if (mXSLTProcessor) {
     // stop observing in order to avoid crashing when replacing content
     mDocument->RemoveObserver(this);
     mIsDocumentObserver = PR_FALSE;
 
     // Check for xslt-param and xslt-param-namespace PIs
-    PRUint32 i;
-    nsIContent* child;
-    for (i = 0; (child = mDocument->GetChildAt(i)); ++i) {
+    for (nsIContent* child = mDocument->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
       if (child->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
         nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(child);
         CheckXSLTParamPI(pi, mXSLTProcessor, mDocument);
       }
       else if (child->IsElement()) {
         // Only honor PIs in the prolog
         break;
       }
--- a/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp
+++ b/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp
@@ -204,17 +204,17 @@ txXPathTreeWalker::moveToFirstChild()
     }
 
     NS_ASSERTION(!mPosition.isDocument() ||
                  (mCurrentIndex == kUnknownIndex && mDescendants.IsEmpty()),
                  "we shouldn't have any position info at the document");
     NS_ASSERTION(mCurrentIndex != kUnknownIndex || mDescendants.IsEmpty(),
                  "Index should be known if parents index are");
 
-    nsIContent* child = mPosition.mNode->GetChildAt(0);
+    nsIContent* child = mPosition.mNode->GetFirstChild();
     if (!child) {
         return PR_FALSE;
     }
     mPosition.mIndex = txXPathNode::eContent;
     mPosition.mNode = child;
 
     if (mCurrentIndex != kUnknownIndex &&
         !mDescendants.AppendValue(mCurrentIndex)) {
@@ -237,17 +237,17 @@ txXPathTreeWalker::moveToLastChild()
                  "we shouldn't have any position info at the document");
     NS_ASSERTION(mCurrentIndex != kUnknownIndex || mDescendants.IsEmpty(),
                  "Index should be known if parents index are");
 
     PRUint32 total = mPosition.mNode->GetChildCount();
     if (!total) {
         return PR_FALSE;
     }
-    mPosition.mNode = mPosition.mNode->GetChildAt(total - 1);
+    mPosition.mNode = mPosition.mNode->GetLastChild();
 
     if (mCurrentIndex != kUnknownIndex &&
         !mDescendants.AppendValue(mCurrentIndex)) {
         mDescendants.Clear();
     }
     mCurrentIndex = total - 1;
 
     return PR_TRUE;
--- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
+++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
@@ -599,41 +599,38 @@ handleNode(nsINode* aNode, txStylesheetC
                                      ni->NameAtom(),
                                      ni->GetPrefixAtom(), atts,
                                      attsCount);
         NS_ENSURE_SUCCESS(rv, rv);
 
         // explicitly destroy the attrs here since we no longer need it
         atts = nsnull;
 
-        PRUint32 childCount = element->GetChildCount();
-        if (childCount > 0) {
-            PRUint32 counter = 0;
-            nsIContent *child;
-            while ((child = element->GetChildAt(counter++))) {
-                rv = handleNode(child, aCompiler);
-                NS_ENSURE_SUCCESS(rv, rv);
-            }
+        for (nsIContent* child = element->GetFirstChild();
+             child;
+             child = child->GetNextSibling()) {
+             
+            rv = handleNode(child, aCompiler);
+            NS_ENSURE_SUCCESS(rv, rv);
         }
 
         rv = aCompiler->endElement();
         NS_ENSURE_SUCCESS(rv, rv);
     }
     else if (aNode->IsNodeOfType(nsINode::eTEXT)) {
         nsAutoString chars;
         static_cast<nsIContent*>(aNode)->AppendTextTo(chars);
         rv = aCompiler->characters(chars);
         NS_ENSURE_SUCCESS(rv, rv);
     }
     else if (aNode->IsNodeOfType(nsINode::eDOCUMENT)) {
-        nsIDocument* document = static_cast<nsIDocument*>(aNode);
-
-        PRUint32 counter = 0;
-        nsIContent *child;
-        while ((child = document->GetChildAt(counter++))) {
+        for (nsIContent* child = aNode->GetFirstChild();
+             child;
+             child = child->GetNextSibling()) {
+             
             rv = handleNode(child, aCompiler);
             NS_ENSURE_SUCCESS(rv, rv);
         }
     }
 
     return NS_OK;
 }
 
--- a/content/xul/content/src/nsXULPopupListener.cpp
+++ b/content/xul/content/src/nsXULPopupListener.cpp
@@ -311,31 +311,29 @@ nsXULPopupListener::ClosePopup()
     // fire events during destruction.  
     nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
     if (pm)
       pm->HidePopup(mPopupContent, PR_FALSE, PR_TRUE, PR_TRUE);
     mPopupContent = nsnull;  // release the popup
   }
 } // ClosePopup
 
-static void
-GetImmediateChild(nsIContent* aContent, nsIAtom *aTag, nsIContent** aResult) 
+static already_AddRefed<nsIContent>
+GetImmediateChild(nsIContent* aContent, nsIAtom *aTag) 
 {
-  *aResult = nsnull;
-  PRInt32 childCount = aContent->GetChildCount();
-  for (PRInt32 i = 0; i < childCount; i++) {
-    nsIContent *child = aContent->GetChildAt(i);
+  for (nsIContent* child = aContent->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     if (child->Tag() == aTag) {
-      *aResult = child;
-      NS_ADDREF(*aResult);
-      return;
+      NS_ADDREF(child);
+      return child;
     }
   }
 
-  return;
+  return nsnull;
 }
 
 //
 // LaunchPopup
 //
 // Given the element on which the event was triggered and the mouse locations in
 // Client and widget coordinates, popup a new window showing the appropriate 
 // content.
@@ -379,19 +377,17 @@ nsXULPopupListener::LaunchPopup(nsIDOMEv
     NS_ERROR("Popup attached to an element that isn't in XUL!");
     return NS_ERROR_FAILURE;
   }
 
   // Handle the _child case for popups and context menus
   nsCOMPtr<nsIDOMElement> popupElement;
 
   if (identifier.EqualsLiteral("_child")) {
-    nsCOMPtr<nsIContent> popup;
-
-    GetImmediateChild(content, nsGkAtoms::menupopup, getter_AddRefs(popup));
+    nsCOMPtr<nsIContent> popup = GetImmediateChild(content, nsGkAtoms::menupopup);
     if (popup)
       popupElement = do_QueryInterface(popup);
     else {
       nsCOMPtr<nsIDOMDocumentXBL> nsDoc(do_QueryInterface(domDocument));
       nsCOMPtr<nsIDOMNodeList> list;
       nsDoc->GetAnonymousNodes(mElement, getter_AddRefs(list));
       if (list) {
         PRUint32 ctr,listLength;
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -925,24 +925,24 @@ nsXULDocument::ExecuteOnBroadcastHandler
                                             nsIDOMElement* aListener,
                                             nsIAtom* aAttr)
 {
     // Now we execute the onchange handler in the context of the
     // observer. We need to find the observer in order to
     // execute the handler.
 
     nsCOMPtr<nsIContent> listener = do_QueryInterface(aListener);
-    PRUint32 count = listener->GetChildCount();
-    for (PRUint32 i = 0; i < count; ++i) {
+    for (nsIContent* child = listener->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
+
         // Look for an <observes> element beneath the listener. This
         // ought to have an |element| attribute that refers to
         // aBroadcaster, and an |attribute| element that tells us what
         // attriubtes we're listening for.
-        nsIContent *child = listener->GetChildAt(i);
-
         if (!child->NodeInfo()->Equals(nsGkAtoms::observes, kNameSpaceID_XUL))
             continue;
 
         // Is this the element that was listening to us?
         nsAutoString listeningToID;
         child->GetAttr(kNameSpaceID_None, nsGkAtoms::element, listeningToID);
 
         nsAutoString broadcasterID;
@@ -1759,20 +1759,21 @@ nsXULDocument::AddSubtreeToDocument(nsIC
 
     Element* aElement = aContent->AsElement();
 
     // Do pre-order addition magic
     nsresult rv = AddElementToDocumentPre(aElement);
     if (NS_FAILED(rv)) return rv;
 
     // Recurse to children
-    PRUint32 count = aElement->GetChildCount();
-
-    while (count-- > 0) {
-        rv = AddSubtreeToDocument(aElement->GetChildAt(count));
+    for (nsIContent* child = aElement->GetLastChild();
+         child;
+         child = child->GetPreviousSibling()) {
+
+        rv = AddSubtreeToDocument(child);
         if (NS_FAILED(rv))
             return rv;
     }
 
     // Do post-order addition magic
     return AddElementToDocumentPost(aElement);
 }
 
@@ -1793,20 +1794,21 @@ nsXULDocument::RemoveSubtreeFromDocument
     if (aElement->NodeInfo()->Equals(nsGkAtoms::keyset, kNameSpaceID_XUL)) {
         nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
         if (xblService) {
             xblService->DetachGlobalKeyHandler(aElement);
         }
     }
 
     // 1. Remove any children from the document.
-    PRUint32 count = aElement->GetChildCount();
-
-    while (count-- > 0) {
-        rv = RemoveSubtreeFromDocument(aElement->GetChildAt(count));
+    for (nsIContent* child = aElement->GetLastChild();
+         child;
+         child = child->GetPreviousSibling()) {
+
+        rv = RemoveSubtreeFromDocument(child);
         if (NS_FAILED(rv))
             return rv;
     }
 
     // 2. Remove the element from the resource-to-element map.
     // Also remove it from the id map, since we added it in
     // AddElementToDocumentPre().
     RemoveElementFromRefMap(aElement);
@@ -4072,17 +4074,17 @@ nsXULDocument::OverlayForwardReference::
 
     PRUint32 childCount = aOverlayNode->GetChildCount();
 
     // This must be a strong reference since it will be the only
     // reference to a content object during part of this loop.
     nsCOMPtr<nsIContent> currContent;
 
     for (i = 0; i < childCount; ++i) {
-        currContent = aOverlayNode->GetChildAt(0);
+        currContent = aOverlayNode->GetFirstChild();
 
         nsIAtom *idAtom = currContent->GetID();
 
         nsIContent *elementInDocument = nsnull;
         if (idAtom) {
             nsDependentAtomString id(idAtom);
 
             if (!id.IsEmpty()) {
--- a/content/xul/templates/src/nsContentSupportMap.cpp
+++ b/content/xul/templates/src/nsContentSupportMap.cpp
@@ -54,20 +54,19 @@ nsContentSupportMap::Finish()
         PL_DHashTableFinish(&mMap);
 }
 
 nsresult
 nsContentSupportMap::Remove(nsIContent* aElement)
 {
     if (!mMap.ops)
         return NS_ERROR_NOT_INITIALIZED;
-
-    PL_DHashTableOperate(&mMap, aElement, PL_DHASH_REMOVE);
-
-    PRUint32 count = aElement->GetChildCount();
-    for (PRUint32 i = 0; i < count; ++i) {
-        Remove(aElement->GetChildAt(i));
-    }
+    
+    nsIContent* child = aElement;    
+    do {
+        PL_DHashTableOperate(&mMap, child, PL_DHASH_REMOVE);
+        child = child->GetNextNode(aElement);
+    } while(child);
 
     return NS_OK;
 }
 
 
--- a/content/xul/templates/src/nsTemplateMap.h
+++ b/content/xul/templates/src/nsTemplateMap.h
@@ -76,19 +76,20 @@ public:
             entry->mTemplate = aTemplate;
         }
     }
 
     void
     Remove(nsIContent* aContent) {
         PL_DHashTableOperate(&mTable, aContent, PL_DHASH_REMOVE);
 
-        PRUint32 count = aContent->GetChildCount();
-        for (PRUint32 i = 0; i < count; ++i) {
-            Remove(aContent->GetChildAt(i));
+        for (nsIContent* child = aContent->GetFirstChild();
+             child;
+             child = child->GetNextSibling()) {
+            Remove(child);
         }
     }
 
 
     void
     GetTemplateFor(nsIContent* aContent, nsIContent** aResult) {
         Entry* entry =
             reinterpret_cast<Entry*>(PL_DHashTableOperate(&mTable, aContent, PL_DHASH_LOOKUP));
--- a/content/xul/templates/src/nsXULContentBuilder.cpp
+++ b/content/xul/templates/src/nsXULContentBuilder.cpp
@@ -493,20 +493,19 @@ nsXULContentBuilder::BuildContentFromTem
                 nsAtomCString(aTemplateNode->Tag()).get(), 
                 nsAtomCString(aResourceNode->Tag()).get(),
                 nsAtomCString(aRealNode->Tag()).get(), NS_ConvertUTF16toUTF8(id).get()));
     }
 #endif
 
     // Iterate through all of the template children, constructing
     // "real" content model nodes for each "template" child.
-    PRUint32 count = aTemplateNode->GetChildCount();
-
-    for (PRUint32 kid = 0; kid < count; kid++) {
-        nsIContent *tmplKid = aTemplateNode->GetChildAt(kid);
+    for (nsIContent* tmplKid = aTemplateNode->GetFirstChild();
+         tmplKid;
+         tmplKid = tmplKid->GetNextSibling()) {
 
         PRInt32 nameSpaceID = tmplKid->GetNameSpaceID();
 
         // Check whether this element is the generation element. The generation
         // element is the element that is cookie-cutter copied once for each
         // different result specified by |aChild|.
         //
         // Nodes that appear -above- the generation element
@@ -1930,18 +1929,20 @@ nsXULContentBuilder::InsertSortedNode(ns
         {
             // found "static" XUL element count hint
             PRInt32 strErr = 0;
             staticCount = staticValue.ToInteger(&strErr);
             if (strErr)
                 staticCount = 0;
         } else {
             // compute the "static" XUL element count
-            for (PRUint32 childLoop = 0; childLoop < numChildren; ++childLoop) {
-                child = aContainer->GetChildAt(childLoop);
+            for (nsIContent* child = aContainer->GetFirstChild();
+                 child;
+                 child = child->GetNextSibling()) {
+                 
                 if (nsContentUtils::HasNonEmptyAttr(child, kNameSpaceID_None,
                                                     nsGkAtoms::_template))
                     break;
                 else
                     ++staticCount;
             }
 
             if (mSortState.sortStaticsLast) {
--- a/content/xul/templates/src/nsXULContentUtils.cpp
+++ b/content/xul/templates/src/nsXULContentUtils.cpp
@@ -196,23 +196,22 @@ nsXULContentUtils::GetCollation()
 //------------------------------------------------------------------------
 
 nsresult
 nsXULContentUtils::FindChildByTag(nsIContent* aElement,
                                   PRInt32 aNameSpaceID,
                                   nsIAtom* aTag,
                                   nsIContent** aResult)
 {
-    PRUint32 count = aElement->GetChildCount();
+    for (nsIContent* child = aElement->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
 
-    for (PRUint32 i = 0; i < count; ++i) {
-        nsIContent *kid = aElement->GetChildAt(i);
-
-        if (kid->NodeInfo()->Equals(aTag, aNameSpaceID)) {
-            NS_ADDREF(*aResult = kid);
+        if (child->NodeInfo()->Equals(aTag, aNameSpaceID)) {
+            NS_ADDREF(*aResult = child);
 
             return NS_OK;
         }
     }
 
     *aResult = nsnull;
     return NS_RDF_NO_VALUE; // not found
 }
--- a/content/xul/templates/src/nsXULSortService.cpp
+++ b/content/xul/templates/src/nsXULSortService.cpp
@@ -104,21 +104,19 @@ XULSortServiceImpl::SetSortHints(nsICont
 
 void
 XULSortServiceImpl::SetSortColumnHints(nsIContent *content,
                                        const nsAString &sortResource,
                                        const nsAString &sortDirection)
 {
   // set sort info on current column. This ensures that the
   // column header sort indicator is updated properly.
-  PRUint32 numChildren = content->GetChildCount();
-
-  for (PRUint32 childIndex = 0; childIndex < numChildren; ++childIndex) {
-    nsIContent *child = content->GetChildAt(childIndex);
-
+  for (nsIContent* child = content->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     if (child->IsXUL()) {
       nsIAtom *tag = child->Tag();
 
       if (tag == nsGkAtoms::treecols) {
         SetSortColumnHints(child, sortResource, sortDirection);
       } else if (tag == nsGkAtoms::treecol) {
         nsAutoString value;
         child->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, value);
@@ -172,21 +170,20 @@ XULSortServiceImpl::GetItemsToSort(nsICo
                                       kNameSpaceID_XUL,
                                       nsGkAtoms::treechildren,
                                       getter_AddRefs(treechildren));
     if (!treechildren)
       return NS_OK;
   
     aContainer = treechildren;
   }
-
-  PRUint32 count = aContainer->GetChildCount();
-  for (PRUint32 c = 0; c < count; c++) {
-    nsIContent *child = aContainer->GetChildAt(c);
-
+  
+  for (nsIContent* child = aContainer->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
     contentSortInfo* cinfo = aSortItems.AppendElement();
     if (!cinfo)
       return NS_ERROR_OUT_OF_MEMORY;
 
     cinfo->content = child;
   }
 
   return NS_OK;
@@ -194,19 +191,19 @@ XULSortServiceImpl::GetItemsToSort(nsICo
 
 
 nsresult
 XULSortServiceImpl::GetTemplateItemsToSort(nsIContent* aContainer,
                                            nsIXULTemplateBuilder* aBuilder,
                                            nsSortState* aSortState,
                                            nsTArray<contentSortInfo>& aSortItems)
 {
-  PRUint32 numChildren = aContainer->GetChildCount();
-  for (PRUint32 childIndex = 0; childIndex < numChildren; childIndex++) {
-    nsIContent *child = aContainer->GetChildAt(childIndex);
+  for (nsIContent* child = aContainer->GetFirstChild();
+       child;
+       child = child->GetNextSibling()) {
   
     nsCOMPtr<nsIDOMElement> childnode = do_QueryInterface(child);
 
     nsCOMPtr<nsIXULTemplateResult> result;
     nsresult rv = aBuilder->GetResultForContent(childnode, getter_AddRefs(result));
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (result) {
@@ -342,19 +339,19 @@ XULSortServiceImpl::SortContainer(nsICon
       parent->AppendChildTo(child, PR_TRUE);
 
       // if it's a container in a tree or menu, find its children,
       // and sort those also
       if (!child->AttrValueIs(kNameSpaceID_None, nsGkAtoms::container,
                               nsGkAtoms::_true, eCaseMatters))
         continue;
         
-      PRUint32 numChildren = child->GetChildCount();
-      for (PRUint32 gcindex = 0; gcindex < numChildren; gcindex++) {
-        nsIContent *grandchild = child->GetChildAt(gcindex);
+      for (nsIContent* grandchild = child->GetFirstChild();
+           grandchild;
+           grandchild = grandchild->GetNextSibling()) {
         nsINodeInfo *ni = grandchild->NodeInfo();
         nsIAtom *localName = ni->NameAtom();
         if (ni->NamespaceID() == kNameSpaceID_XUL &&
             (localName == nsGkAtoms::treechildren ||
              localName == nsGkAtoms::menupopup)) {
           SortContainer(grandchild, aSortState);
         }
       }
--- a/content/xul/templates/src/nsXULTemplateBuilder.cpp
+++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp
@@ -1694,20 +1694,19 @@ nsXULTemplateBuilder::GetTemplateRoot(ns
             return NS_OK;
         }
     }
 
 #if 1 // XXX hack to workaround bug with XBL insertion/removal?
     {
         // If root node has no template attribute, then look for a child
         // node which is a template tag
-        PRUint32 count = mRoot->GetChildCount();
-
-        for (PRUint32 i = 0; i < count; ++i) {
-            nsIContent *child = mRoot->GetChildAt(i);
+        for (nsIContent* child = mRoot->GetFirstChild();
+             child;
+             child = child->GetNextSibling()) {
 
             if (IsTemplateElement(child)) {
                 NS_ADDREF(*aResult = child);
                 return NS_OK;
             }
         }
     }
 #endif
@@ -1851,20 +1850,20 @@ nsXULTemplateBuilder::CompileTemplate(ns
 {
     NS_ASSERTION(aQuerySet, "No queryset supplied");
 
     nsresult rv = NS_OK;
 
     PRBool isQuerySetMode = PR_FALSE;
     PRBool hasQuerySet = PR_FALSE, hasRule = PR_FALSE, hasQuery = PR_FALSE;
 
-    PRUint32 count = aTemplate->GetChildCount();
-
-    for (PRUint32 i = 0; i < count; i++) {
-        nsIContent *rulenode = aTemplate->GetChildAt(i);
+    for (nsIContent* rulenode = aTemplate->GetFirstChild();
+         rulenode;
+         rulenode = rulenode->GetNextSibling()) {
+
         nsINodeInfo *ni = rulenode->NodeInfo();
 
         // don't allow more queries than can be supported
         if (*aPriority == PR_INT16_MAX)
             return NS_ERROR_FAILURE;
 
         // XXXndeakin queryset isn't a good name for this tag since it only
         //            ever contains one query
@@ -2238,22 +2237,21 @@ nsXULTemplateBuilder::CompileConditions(
     nsAutoString tag;
     aCondition->GetAttr(kNameSpaceID_None, nsGkAtoms::parent, tag);
 
     if (!tag.IsEmpty()) {
         nsCOMPtr<nsIAtom> tagatom = do_GetAtom(tag);
         aRule->SetTag(tagatom);
     }
 
-    PRUint32 count = aCondition->GetChildCount();
-
     nsTemplateCondition* currentCondition = nsnull;
 
-    for (PRUint32 i = 0; i < count; i++) {
-        nsIContent *node = aCondition->GetChildAt(i);
+    for (nsIContent* node = aCondition->GetFirstChild();
+         node;
+         node = node->GetNextSibling()) {
 
         if (node->NodeInfo()->Equals(nsGkAtoms::where, kNameSpaceID_XUL)) {
             nsresult rv = CompileWhereCondition(aRule, node, &currentCondition);
             if (NS_FAILED(rv))
                 return rv;
         }
     }
 
@@ -2361,20 +2359,19 @@ nsXULTemplateBuilder::CompileWhereCondit
 }
 
 nsresult
 nsXULTemplateBuilder::CompileBindings(nsTemplateRule* aRule, nsIContent* aBindings)
 {
     // Add an extended rule's bindings.
     nsresult rv;
 
-    PRUint32 count = aBindings->GetChildCount();
-
-    for (PRUint32 i = 0; i < count; ++i) {
-        nsIContent *binding = aBindings->GetChildAt(i);
+    for (nsIContent* binding = aBindings->GetFirstChild();
+         binding;
+         binding = binding->GetNextSibling()) {
 
         if (binding->NodeInfo()->Equals(nsGkAtoms::binding,
                                         kNameSpaceID_XUL)) {
             rv = CompileBinding(aRule, binding);
             if (NS_FAILED(rv))
                 return rv;
         }
     }
@@ -2476,20 +2473,21 @@ nsXULTemplateBuilder::AddSimpleRuleBindi
 
                 // Scan the attribute for variables, adding a binding for
                 // each one.
                 ParseAttribute(value, AddBindingsFor, nsnull, aRule);
             }
         }
 
         // Push kids onto the stack, and search them next.
-        count = element->GetChildCount();
-
-        while (count-- > 0) {
-            if (elements.AppendElement(element->GetChildAt(count)) == nsnull)
+        for (nsIContent* child = element->GetLastChild();
+             child;
+             child = child->GetPreviousSibling()) {
+
+            if (!elements.AppendElement(child))
                 return NS_ERROR_OUT_OF_MEMORY;
         }
     }
 
     aRule->AddBindingsToQueryProcessor(mQueryProcessor);
 
     return NS_OK;
 }
--- a/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp
+++ b/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp
@@ -1268,24 +1268,23 @@ nsXULTemplateQueryProcessorRDF::CompileE
     nsresult rv = mAllTests.Add(idnode);
     if (NS_FAILED(rv)) {
         delete idnode;
         return rv;
     }
 
     TestNode* prevnode = idnode;
 
-    PRUint32 count = aConditions->GetChildCount();
-
-    for (PRUint32 i = 0; i < count; ++i) {
-        nsIContent *condition = aConditions->GetChildAt(i);
+    for (nsIContent* condition = aConditions->GetFirstChild();
+         condition;
+         condition = condition->GetNextSibling()) {
 
         // the <content> condition should always be the first child
         if (condition->Tag() == nsGkAtoms::content) {
-            if (i) {
+            if (condition != aConditions->GetFirstChild()) {
                 nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_CONTENT_NOT_FIRST);
                 continue;
             }
 
             // check for <content tag='tag'/> which indicates that matches
             // should only be generated for items inside content with that tag
             nsAutoString tagstr;
             condition->GetAttr(kNameSpaceID_None, nsGkAtoms::tag, tagstr);
--- a/content/xul/templates/src/nsXULTemplateQueryProcessorStorage.cpp
+++ b/content/xul/templates/src/nsXULTemplateQueryProcessorStorage.cpp
@@ -323,20 +323,19 @@ nsXULTemplateQueryProcessorStorage::Comp
     nsresult rv = mStorageConnection->CreateStatement(NS_ConvertUTF16toUTF8(sqlQuery),
                                                               getter_AddRefs(statement));
     if (NS_FAILED(rv)) {
         nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_STORAGE_BAD_QUERY);
         return rv;
     }
 
     PRUint32 parameterCount = 0;
-    PRUint32 count = queryContent->GetChildCount();
-
-    for (PRUint32 i = 0; i < count; ++i) {
-        nsIContent *child = queryContent->GetChildAt(i);
+    for (nsIContent* child = queryContent->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
 
         if (child->NodeInfo()->Equals(nsGkAtoms::param, kNameSpaceID_XUL)) {
             nsAutoString value;
             nsContentUtils::GetNodeTextContent(child, PR_FALSE, value);
 
             PRUint32 index = parameterCount;
             nsAutoString name, indexValue;
 
--- a/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
+++ b/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
@@ -300,19 +300,20 @@ nsXULTemplateQueryProcessorXML::CompileQ
         nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_BAD_XPATH);
         return rv;
     }
 
     nsRefPtr<nsXMLQuery> query =
         new nsXMLQuery(this, aMemberVariable, compiledexpr);
     NS_ENSURE_TRUE(query, NS_ERROR_OUT_OF_MEMORY);
 
-    PRUint32 count = content->GetChildCount();
-    for (PRUint32 i = 0; i < count; ++i) {
-        nsIContent *condition = content->GetChildAt(i);
+    for (nsIContent* condition = content->GetFirstChild();
+         condition;
+         condition = condition->GetNextSibling()) {
+
         if (condition->NodeInfo()->Equals(nsGkAtoms::assign,
                                           kNameSpaceID_XUL)) {
             nsAutoString var;
             condition->GetAttr(kNameSpaceID_None, nsGkAtoms::var, var);
 
             nsAutoString expr;
             condition->GetAttr(kNameSpaceID_None, nsGkAtoms::expr, expr);
 
--- a/content/xul/templates/src/nsXULTemplateResultXML.cpp
+++ b/content/xul/templates/src/nsXULTemplateResultXML.cpp
@@ -91,19 +91,20 @@ nsXULTemplateResultXML::GetIsContainer(P
 }
 
 NS_IMETHODIMP
 nsXULTemplateResultXML::GetIsEmpty(PRBool* aIsEmpty)
 {
     // a node is considered empty if it has no elements as children
     nsCOMPtr<nsIContent> content = do_QueryInterface(mNode);
     if (content) {
-        PRUint32 count = content->GetChildCount();
-        for (PRUint32 c = 0; c < count; c++) {
-            if (content->GetChildAt(c)->IsElement()) {
+        for (nsIContent* child = content->GetFirstChild();
+             child;
+             child = child->GetNextSibling()) {
+            if (child->IsElement()) {
                 *aIsEmpty = PR_FALSE;
                 return NS_OK;
             }
         }
     }
 
     *aIsEmpty = PR_TRUE;
     return NS_OK;
--- a/content/xul/templates/src/nsXULTreeBuilder.cpp
+++ b/content/xul/templates/src/nsXULTreeBuilder.cpp
@@ -1357,20 +1357,20 @@ nsXULTreeBuilder::EnsureSortVariables()
     nsCOMPtr<nsIContent> treecols;
  
     nsXULContentUtils::FindChildByTag(mRoot, kNameSpaceID_XUL,
                                       nsGkAtoms::treecols,
                                       getter_AddRefs(treecols));
 
     if (!treecols)
         return NS_OK;
-
-    PRUint32 count = treecols->GetChildCount();
-    for (PRUint32 i = 0; i < count; ++i) {
-        nsIContent *child = treecols->GetChildAt(i);
+        
+    for (nsIContent* child = treecols->GetFirstChild();
+         child;
+         child = child->GetNextSibling()) {
 
         if (child->NodeInfo()->Equals(nsGkAtoms::treecol,
                                       kNameSpaceID_XUL)) {
             if (child->AttrValueIs(kNameSpaceID_None, nsGkAtoms::sortActive,
                                    nsGkAtoms::_true, eCaseMatters)) {
                 nsAutoString sort;
                 child->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, sort);
                 if (! sort.IsEmpty()) {
@@ -1496,21 +1496,21 @@ nsXULTreeBuilder::GetTemplateActionCellF
     nsCOMPtr<nsIContent> row;
     GetTemplateActionRowFor(aRow, getter_AddRefs(row));
     if (row) {
         nsCOMPtr<nsIAtom> colAtom;
         PRInt32 colIndex;
         aCol->GetAtom(getter_AddRefs(colAtom));
         aCol->GetIndex(&colIndex);
 
-        PRUint32 count = row->GetChildCount();
         PRUint32 j = 0;
-        for (PRUint32 i = 0; i < count; ++i) {
-            nsIContent *child = row->GetChildAt(i);
-
+        for (nsIContent* child = row->GetFirstChild();
+             child;
+             child = child->GetNextSibling()) {
+            
             if (child->NodeInfo()->Equals(nsGkAtoms::treecell,
                                           kNameSpaceID_XUL)) {
                 if (colAtom &&
                     child->AttrValueIs(kNameSpaceID_None, nsGkAtoms::ref,
                                        colAtom, eCaseMatters)) {
                     *aResult = child;
                     break;
                 }
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -8154,16 +8154,21 @@ nsGlobalWindow::GetSessionStorage(nsIDOM
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetGlobalStorage(nsIDOMStorageList ** aGlobalStorage)
 {
   NS_ENSURE_ARG_POINTER(aGlobalStorage);
 
+  nsCOMPtr<nsIDocument> document = do_QueryInterface(GetExtantDocument());
+  if (document) {
+    document->WarnOnceAbout(nsIDocument::eGlobalStorage);
+  }
+
   if (!Preferences::GetBool(kStorageEnabled)) {
     *aGlobalStorage = nsnull;
     return NS_OK;
   }
 
   if (!sGlobalStorageList) {
     nsresult rv = NS_NewDOMStorageList(&sGlobalStorageList);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -106,8 +106,16 @@ OwnerDocumentWarning=Use of attributes' 
 NormalizeWarning=Use of attributes' normalize() is deprecated.
 IsSupportedWarning=Use of attributes' isSupported() is deprecated.
 IsEqualNodeWarning=Use of attributes' isEqualNode() is deprecated.
 TextContentWarning=Use of attributes' textContent attribute is deprecated. Use value instead.
 EnablePrivilegeWarning=Use of enablePrivilege is deprecated.  Please use code that runs with the system principal (e.g. an extension) instead.
 nsIJSONDecodeDeprecatedWarning=nsIJSON.decode is deprecated.  Please use JSON.parse instead.
 nsIJSONEncodeDeprecatedWarning=nsIJSON.encode is deprecated.  Please use JSON.stringify instead.
 nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead.
+IsSameNodeWarning=Use of isSameNode is deprecated.  Please use A == B to test for equality instead.
+ReplaceWholeTextWarning=Use of replaceWholeText is deprecated. Please call normalize() on the parent and set the data attribute, or use textContent instead.
+XmlEncodingWarning=Use of xmlEncoding is deprecated.
+XmlVersionWarning=Use of xmlVersion is deprecated.
+InputEncodingWarning=Use of inputEncoding is deprecated.
+XmlStandaloneWarning=Use of xmlStandalone is deprecated.
+IsElementContentWhitespaceWarning=Use of isElementContentWhitespaceWarning is deprecated.
+GlobalStorageWarning=Use of globalStorage is deprecated. Please use localStorage instead.
--- a/gfx/thebes/gfxPointH3D.h
+++ b/gfx/thebes/gfxPointH3D.h
@@ -43,9 +43,9 @@
 
 struct THEBES_API gfxPointH3D : public mozilla::gfx::BasePoint4D<float, gfxPointH3D> {
     typedef mozilla::gfx::BasePoint4D<float, gfxPointH3D> Super;
 
     gfxPointH3D() : Super() {}
     gfxPointH3D(float aX, float aY, float aZ, float aW) : Super(aX, aY, aZ, aW) {}
 };
 
-#endif /* GFX_POINTH3D_H */ 
\ No newline at end of file
+#endif /* GFX_POINTH3D_H */
--- a/js/src/config/system-headers
+++ b/js/src/config/system-headers
@@ -303,17 +303,16 @@ gtk/gtk.h
 gtk/gtkprinter.h
 gtk/gtkprintjob.h
 gtk/gtkprintunixdialog.h
 HIToolbox/HIToolbox.h
 hlink.h
 ia64/sys/inline.h
 Icons.h
 iconv.h
-IDL.h
 ieeefp.h
 ifaddrs.h
 image.h
 imagehlp.h
 imm.h
 initguid.h
 InterfaceDefs.h
 InternetConfig.h
@@ -399,17 +398,16 @@ libgnomeui/gnome-ui-init.h
 libgnomevfs/gnome-vfs-file-info.h
 libgnomevfs/gnome-vfs.h
 libgnomevfs/gnome-vfs-init.h
 libgnomevfs/gnome-vfs-mime.h
 libgnomevfs/gnome-vfs-mime-handlers.h
 libgnomevfs/gnome-vfs-mime-utils.h
 libgnomevfs/gnome-vfs-ops.h
 libgnomevfs/gnome-vfs-standard-callbacks.h
-libIDL/IDL.h
 lib$routines.h
 libnotify/notify.h
 limits
 limits.h
 link.h
 linux/kernel.h
 linux/limits.h
 linux/rtc.h
--- a/js/src/methodjit/MachineRegs.h
+++ b/js/src/methodjit/MachineRegs.h
@@ -411,17 +411,17 @@ struct Registers {
     static const uint32 AvailAnyRegs = AvailRegs | AvailFPRegs;
 
     static inline uint32 maskReg(AnyRegisterID reg) {
         return (1 << reg.reg_);
     }
 
     /* Get a register which is not live before a FASTCALL. */
     static inline RegisterID tempCallReg() {
-        Registers regs(AvailRegs);
+        Registers regs(TempRegs);
         regs.takeReg(Registers::ArgReg0);
         regs.takeReg(Registers::ArgReg1);
         return regs.takeAnyReg().reg();
     }
 
     /* Get a register which is not live before a normal ABI call with at most four args. */
     static inline Registers tempCallRegMask() {
         Registers regs(AvailRegs);
--- a/js/src/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/src/xpconnect/src/dom_quickstubs.qsconf
@@ -812,22 +812,16 @@ customMethodCalls = {
         'code': '    PRUint16 result;\n'
                 '    rv = self->CompareDocPosition(arg0, &result);',
         'canFail': True
         },
     'nsIDOMNode_GetTextContent': {
         'thisType': 'nsINode',
         'canFail': False
         },
-    'nsIDOMNode_IsSameNode': {
-        'thisType': 'nsINode',
-        'arg0Type': 'nsINode',
-        'code': '    PRBool result = self == arg0;',
-        'canFail': False
-        },
     'nsIDOMNode_LookupPrefix': {
         'thisType': 'nsINode',
         'canFail': False
         },
     'nsIDOMNode_IsDefaultNamespace': {
         'thisType': 'nsINode',
         'canFail': False
         },
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -251,40 +251,58 @@ function OnRefTestLoad()
                              .frameLoader.messageManager;
     // The content script waits for the initial onload, then notifies
     // us.
     RegisterMessageListenersAndLoadContentScript();
 }
 
 function InitAndStartRefTests()
 {
-    /* set the gLoadTimeout */
+    /* These prefs are optional, so we don't need to spit an error to the log */
     try {
       var prefs = Components.classes["@mozilla.org/preferences-service;1"].
                   getService(Components.interfaces.nsIPrefBranch2);
+    } catch(e) {
+      gDumpLog("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + e + "\n");
+    }
+    
+    /* set the gLoadTimeout */
+    try {
       gLoadTimeout = prefs.getIntPref("reftest.timeout");
+    } catch(e) { 
+      gLoadTimeout = 5 * 60 * 1000; //5 minutes as per bug 479518
+    }
+    
+    /* Get the logfile for android tests */
+    try {
       logFile = prefs.getCharPref("reftest.logFile");
       if (logFile) {
         try {
           var mfl = new MozillaFileLogger(logFile);
           // Set to mirror to stdout as well as the file
           gDumpLog = function (msg) {dump(msg); mfl.log(msg);};
         }
         catch(e) {
           // If there is a problem, just use stdout
           gDumpLog = dump;
         }
       }
+    } catch(e) {}
+    
+    try {
       gRemote = prefs.getBoolPref("reftest.remote");
-      gIgnoreWindowSize = prefs.getBoolPref("reftest.ignoreWindowSize");
-    }
-    catch(e) {
-      gLoadTimeout = 5 * 60 * 1000; //5 minutes as per bug 479518
+    } catch(e) { 
+      gRemote = false;
     }
 
+    try {
+      gIgnoreWindowSize = prefs.getBoolPref("reftest.ignoreWindowSize");
+    } catch(e) {
+      gIgnoreWindowSize = false;
+    }
 
     /* Support for running a chunk (subset) of tests.  In separate try as this is optional */
     try {
       gTotalChunks = prefs.getIntPref("reftest.totalChunks");
       gThisChunk = prefs.getIntPref("reftest.thisChunk");
     }
     catch(e) {
       gTotalChunks = 0;
--- a/toolkit/mozapps/extensions/content/setting.xml
+++ b/toolkit/mozapps/extensions/content/setting.xml
@@ -307,17 +307,17 @@
     <content>
       <xul:vbox class="setting-label">
         <xul:label class="preferences-title" xbl:inherits="value=title" crop="end" flex="1"/>
         <xul:label class="preferences-description" xbl:inherits="value=desc" crop="end" flex="1">
           <children/>
         </xul:label>
       </xul:vbox>
       <xul:hbox anonid="input-container" class="setting-input">
-        <children includes="button"/>
+        <children includes="button|menulist"/>
       </xul:hbox>
     </content>
   </binding>
 
   <binding id="setting-string" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
     <content>
       <xul:vbox class="setting-label">
         <xul:label class="preferences-title" xbl:inherits="value=title" crop="end" flex="1"/>
--- a/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/options.xul
+++ b/toolkit/mozapps/extensions/test/browser/addons/browser_inlinesettings1/options.xul
@@ -1,10 +1,19 @@
 <?xml version="1.0" ?>
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <setting pref="extensions.inlinesettings1.bool" type="bool" title="Bool"/>
   <setting pref="extensions.inlinesettings1.boolint" type="boolint" on="1" off="2" title="BoolInt"/>
   <setting pref="extensions.inlinesettings1.integer" type="integer" title="Integer"/>
   <setting pref="extensions.inlinesettings1.string" type="string" title="String"/>
+  <setting type="control" title="Menulist">
+    <menulist sizetopopup="always" oncommand="window._testValue = this.value;">
+      <menupopup>
+        <menuitem label="Alpha" value="1" />
+        <menuitem label="Bravo" value="2" />
+        <menuitem label="Charlie" value="3" />
+      </menupopup>
+    </menulist>
+  </setting>
   <setting pref="extensions.inlinesettings1.color" type="color" title="Color"/>
   <setting pref="extensions.inlinesettings1.file" type="file" title="File"/>
   <setting pref="extensions.inlinesettings1.directory" type="directory" title="Directory"/>
 </vbox>
--- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js
@@ -3,17 +3,17 @@
  */
 
 // Tests various aspects of the details view
 
 var gManagerWindow;
 var gCategoryUtilities;
 var gProvider;
 
-const SETTINGS_ROWS = 7;
+const SETTINGS_ROWS = 8;
 
 var observer = {
   lastData: null,
   observe: function(aSubject, aTopic, aData) {
     if (aTopic == "addon-options-displayed")
       this.lastData = aData;
   }
 };
@@ -186,33 +186,42 @@ add_test(function() {
     input.select();
     EventUtils.synthesizeKey("b", {}, gManagerWindow);
     EventUtils.synthesizeKey("a", {}, gManagerWindow);
     EventUtils.synthesizeKey("r", {}, gManagerWindow);
     is(input.value, "bar", "Text box should have updated value");
     is(Services.prefs.getCharPref("extensions.inlinesettings1.string"), "bar", "String pref should have been updated");
 
     ok(!settings[4].hasAttribute("first-row"), "Not the first row");
+    var input = settings[4].firstElementChild;
+    is(input.value, "1", "Menulist should have initial value");
+    input.focus();
+    EventUtils.synthesizeKey("b", {}, gManagerWindow);
+    is(input.value, "2", "Menulist should have updated value");
+    is(gManagerWindow._testValue, "2", "Menulist oncommand handler should've updated the test value");
+    delete gManagerWindow._testValue;
+
+    ok(!settings[5].hasAttribute("first-row"), "Not the first row");
     Services.prefs.setCharPref("extensions.inlinesettings1.color", "#FF0000");
-    input = gManagerWindow.document.getAnonymousElementByAttribute(settings[4], "anonid", "input");
+    input = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "input");
     is(input.color, "#FF0000", "Color picker should have initial value");
     input.focus();
     EventUtils.synthesizeKey("VK_RIGHT", {}, gManagerWindow);
     EventUtils.synthesizeKey("VK_RIGHT", {}, gManagerWindow);
     EventUtils.synthesizeKey("VK_RETURN", {}, gManagerWindow);
     input.hidePopup();
     is(input.color, "#FF9900", "Color picker should have updated value");
     is(Services.prefs.getCharPref("extensions.inlinesettings1.color"), "#FF9900", "Color pref should have been updated");
 
     try {
       mockFilePickerFactory.register();
 
-      ok(!settings[5].hasAttribute("first-row"), "Not the first row");
-      var button = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "button");
-      input = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "input");
+      ok(!settings[6].hasAttribute("first-row"), "Not the first row");
+      var button = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "button");
+      input = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "input");
       is(input.value, "", "Label value should be empty");
 
       var profD = Services.dirsvc.get("ProfD", Ci.nsIFile);
       var curProcD = Services.dirsvc.get("CurProcD", Ci.nsIFile);
 
       _returnFile = profD;
       _returnValue = Ci.nsIFilePicker.returnOK;
       EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
@@ -222,19 +231,19 @@ add_test(function() {
 
       _returnFile = curProcD;
       _returnValue = Ci.nsIFilePicker.returnCancel;
       EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
       is(_mode, Ci.nsIFilePicker.modeOpen, "File picker mode should be open file");
       is(input.value, profD.path, "Label value should not have changed");
       is(Services.prefs.getCharPref("extensions.inlinesettings1.file"), profD.path, "File pref should not have changed");
 
-      ok(!settings[6].hasAttribute("first-row"), "Not the first row");
-      button = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "button");
-      input = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "input");
+      ok(!settings[7].hasAttribute("first-row"), "Not the first row");
+      button = gManagerWindow.document.getAnonymousElementByAttribute(settings[7], "anonid", "button");
+      input = gManagerWindow.document.getAnonymousElementByAttribute(settings[7], "anonid", "input");
       is(input.value, "", "Label value should be empty");
 
       _returnFile = profD;
       _returnValue = Ci.nsIFilePicker.returnOK;
       EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
       is(_mode, Ci.nsIFilePicker.modeGetFolder, "File picker mode should be directory");
       is(input.value, profD.path, "Label value should match file chosen");
       is(Services.prefs.getCharPref("extensions.inlinesettings1.directory"), profD.path, "Directory pref should match file chosen");
deleted file mode 100644
--- a/xpcom/typelib/xpidl/README
+++ /dev/null
@@ -1,16 +0,0 @@
-Wed Dec  2 14:35:41 EST 1998
-
-xpidl depends on Andrew Veliath and Elliot Lee's libIDL, a part of the
-GNOME ORBit C ORB.  We currently require libIDL >= 0.6.3, which in turn
-requires glib >= 1.2.0.
-
-libIDL builds for Linux and Win32 can be found, along with source
-tarballs, at http://www.rpi.edu/~veliaa/libIDL/, and Win32 users will
-need glib 1.2 and glib 1.2-dev from
-http://user.sgic.fi/~tml/gimp/win32/.  Source and Linux RPMs are also
-available from ftp://ftp.mozilla.org/pub/mozilla/libraries, and Win32
-binaries are included in the wintools.zip file at
-ftp://ftp.mozilla.org/pub/mozilla/source/wintools.zip.  A Mac project
-is in progress, and should be appearing shortly.
-
-glib tarballs and RPMs for Linux can be found through http://www.gtk.org.
deleted file mode 100644
--- a/xpcom/typelib/xpidl/xpidl.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * Main xpidl program entry point.
- */
-
-#include "xpidl.h"
-
-static ModeData modes[] = {
-    {"header",  "Generate C++ header",         "h",    xpidl_header_dispatch},
-    {"typelib", "Generate XPConnect typelib",  "xpt",  xpidl_typelib_dispatch},
-    {"doc",     "Generate HTML documentation", "html", xpidl_doc_dispatch},
-    {"java",    "Generate Java interface",     "java", xpidl_java_dispatch},
-    {0,         0,                             0,      0}
-};
-
-static ModeData *
-FindMode(char *mode)
-{
-    int i;
-    for (i = 0; modes[i].mode; i++) {
-        if (!strcmp(modes[i].mode, mode))
-            return &modes[i];
-    }
-    return NULL;
-}
-
-gboolean enable_debug               = FALSE;
-gboolean enable_warnings            = FALSE;
-gboolean verbose_mode               = FALSE;
-gboolean emit_typelib_annotations   = FALSE;
-gboolean explicit_output_filename   = FALSE;
-FILE *deps = NULL;
-
-/* The following globals are explained in xpt_struct.h */
-PRUint8  major_version              = XPT_MAJOR_VERSION;
-PRUint8  minor_version              = XPT_MINOR_VERSION;
-
-static char xpidl_usage_str[] =
-"Usage: %s -m mode [-w] [-v] [-t version number] [-d filename.pp]\n"
-"          [-I path] [-o basename | -e filename.ext] filename.idl\n"
-"       -a emit annotations to typelib\n"
-"       -w turn on warnings (recommended)\n"
-"       -v verbose mode (NYI)\n"
-"       -t create a typelib of a specific version number\n"
-"       -I add entry to start of include path for ``#include \"nsIThing.idl\"''\n"
-"       -o use basename (e.g. ``/tmp/nsIThing'') for output\n"
-"       -e use explicit output filename\n"
-"       -d write dependencies (requires -e)\n"
-"       -m specify output mode:\n";
-
-static void
-xpidl_usage(int argc, char *argv[])
-{
-    int i;
-    fprintf(stderr, xpidl_usage_str, argv[0]);
-    for (i = 0; modes[i].mode; i++) {
-        fprintf(stderr, "          %-12s  %-30s (.%s)\n", modes[i].mode,
-                modes[i].modeInfo, modes[i].suffix);
-    }
-}
-
-int main(int argc, char *argv[])
-{
-    int i;
-    IncludePathEntry *inc, *inc_head, **inc_tail;
-    char *file_basename = NULL;
-    ModeData *mode = NULL;
-    gboolean create_old_typelib = FALSE;
-
-    /* turn this on for extra checking of our code */
-/*    IDL_check_cast_enable(TRUE); */
-
-    inc_head = xpidl_malloc(sizeof *inc);
-    inc_head->directory = ".";
-    inc_head->next = NULL;
-    inc_tail = &inc_head->next;
-
-    for (i = 1; i < argc; i++) {
-        if (argv[i][0] != '-')
-            break;
-        switch (argv[i][1]) {
-          case '-':
-            argc++;             /* pretend we didn't see this */
-            /* fall through */
-          case 0:               /* - is a legal input filename (stdin)  */
-            goto done_options;
-          case 'a':
-            emit_typelib_annotations = TRUE;
-            break;
-          case 'w':
-            enable_warnings = TRUE;
-            break;
-          case 'v':
-            verbose_mode = TRUE;
-            break;
-          case 't':
-          {
-            /* Parse for "-t version number" and store it into global boolean
-             * and string variables.
-             */
-            const gchar* typelib_version_string = NULL;
-
-            /* 
-             * If -t is the last argument on the command line, we have a problem
-             */
-
-            if (i + 1 == argc) {
-                fprintf(stderr, "ERROR: missing version number after -t\n");
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-
-            /* Do not allow more than one "-t" definition */
-            if (create_old_typelib) {
-                fprintf(stderr,
-                        "ERROR: -t argument used twice. "
-                        "Cannot specify more than one version\n");
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-
-            /*
-             * Assume that the argument after "-t" is the version number string
-             * and search for it in our internal list of acceptable version
-             * numbers.
-             */
-            switch (XPT_ParseVersionString(argv[++i], &major_version, 
-                                           &minor_version)) {
-              case XPT_VERSION_CURRENT:
-                break; 
-              case XPT_VERSION_OLD: 
-                create_old_typelib = TRUE;
-                break; 
-              case XPT_VERSION_UNSUPPORTED: 
-                fprintf(stderr, "ERROR: version \"%s\" not supported.\n", 
-                        argv[i]);
-                xpidl_usage(argc, argv);
-                return 1;          
-              case XPT_VERSION_UNKNOWN: 
-              default:
-                fprintf(stderr, "ERROR: version \"%s\" not recognised.\n", 
-                        argv[i]);
-                xpidl_usage(argc, argv);
-                return 1;          
-            }
-            break;
-          }
-          case 'I':
-            if (argv[i][2] == '\0' && i == argc) {
-                fputs("ERROR: missing path after -I\n", stderr);
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-            inc = xpidl_malloc(sizeof *inc);
-            if (argv[i][2] == '\0') {
-                /* is it the -I foo form? */
-                inc->directory = argv[++i];
-            } else {
-                /* must be the -Ifoo form.  Don't preincrement i. */
-                inc->directory = argv[i] + 2;
-            }
-#ifdef DEBUG_shaver_includes
-            fprintf(stderr, "adding %s to include path\n", inc->directory);
-#endif
-            inc->next = NULL;
-            *inc_tail = inc;
-            inc_tail = &inc->next;
-            break;
-          case 'o':
-            if (i == argc) {
-                fprintf(stderr, "ERROR: missing basename after -o\n");
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-            file_basename = argv[++i];
-            explicit_output_filename = FALSE;
-            break;
-          case 'e':
-            if (i == argc) {
-                fprintf(stderr, "ERROR: missing basename after -e\n");
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-            file_basename = argv[++i];
-            explicit_output_filename = TRUE;
-            break;
-          case 'd':
-            if (!explicit_output_filename) {
-                fprintf(stderr, "ERROR: -d requires -e\n");
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-            if (i == argc) {
-                fprintf(stderr, "ERROR: missing filename after -d\n");
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-            deps = fopen(argv[++i], "w");
-            if (deps)
-                fprintf(deps, "%s:", file_basename);
-            break;
-          case 'm':
-            if (i + 1 == argc) {
-                fprintf(stderr, "ERROR: missing modename after -m\n");
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-            if (mode) {
-                fprintf(stderr,
-                        "ERROR: must specify exactly one mode "
-                        "(first \"%s\", now \"%s\")\n", mode->mode,
-                        argv[i + 1]);
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-            mode = FindMode(argv[++i]);
-            if (!mode) {
-                fprintf(stderr, "ERROR: unknown mode \"%s\"\n", argv[i]);
-                xpidl_usage(argc, argv);
-                return 1;
-            }
-            break;                 
-          default:
-            fprintf(stderr, "unknown option %s\n", argv[i]);
-            xpidl_usage(argc, argv);
-            return 1;
-        }
-    }
- done_options:
-    if (!mode) {
-        fprintf(stderr, "ERROR: must specify output mode\n");
-        xpidl_usage(argc, argv);
-        return 1;
-    }
-
-    /*
-     * Don't try to process multiple files, given that we don't handle -o
-     * multiply.
-     */
-    if (i < argc) {
-        i = xpidl_process_idl(argv[i], inc_head, file_basename, mode);
-    } else {
-        if (argc > i + 1) {
-            fprintf(stderr, "ERROR: extra arguments after input file\n");
-        } else {
-            fprintf(stderr, "ERROR: no file to process\n");
-        }
-        return 1;
-    }
-
-    if (deps) {
-        fprintf(deps, "\n");
-        fclose(deps);
-    }
-
-    return !i;
-}
deleted file mode 100644
--- a/xpcom/typelib/xpidl/xpidl.h
+++ /dev/null
@@ -1,275 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * Intramodule declarations.
- */
-
-#ifndef __xpidl_h
-#define __xpidl_h
-
-#include <errno.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <string.h> /* After glib.h to avoid warnings about shadowing 'index'. */
-
-#include <libIDL/IDL.h>
-
-#include <xpt_struct.h>
-
-/*
- * IDL_tree_warning bombs on libIDL version 6.5, and I don't want to not write
- * warnings... so I define a versioned one here.  Thanks to Mike Shaver for the
- * this solution, which allows us to pass through varargs calls.
- */
-#if !(LIBIDL_MAJOR_VERSION == 0 && LIBIDL_MINOR_VERSION == 6 && \
-      LIBIDL_MICRO_VERSION == 5) && !defined(DEBUG_shaver)
-/*
- * This turns a varargs call to XPIDL_WARNING directly into a varargs
- * call to IDL_tree_warning or xpidl_tree_warning as appropriate.  The
- * only tricky bit is that you must call XPIDL_WARNING with extra
- * parens, e.g. XPIDL_WARNING((foo, bar, "sil"))
- *
- * Probably best removed when we leave 6.5.  */
-#define XPIDL_WARNING(x) IDL_tree_warning x
-#else
-extern void xpidl_tree_warning(IDL_tree p, int level, const char *fmt, ...);
-#define XPIDL_WARNING(x) xpidl_tree_warning x
-#endif
-
-/*
- * Internal operation flags.
- */
-extern gboolean enable_debug;
-extern gboolean enable_warnings;
-extern gboolean verbose_mode;
-extern gboolean emit_typelib_annotations;
-extern gboolean explicit_output_filename;
-extern FILE *deps;
-
-extern PRUint8  major_version;
-extern PRUint8  minor_version;
-
-typedef struct TreeState TreeState;
-
-/*
- * A function to handle an IDL_tree type.
- */
-typedef gboolean (*nodeHandler)(TreeState *);
-
-/*
- * Struct containing functions to define the behavior of a given output mode.
- */
-typedef struct backend {
-    nodeHandler *dispatch_table; /* nodeHandlers table, indexed by node type. */
-    nodeHandler emit_prolog;     /* called at beginning of output generation. */
-    nodeHandler emit_epilog;     /* called at end. */
-} backend;
-
-/* Function that produces a struct of output-generation functions */
-typedef backend *(*backendFactory)();
- 
-extern backend *xpidl_header_dispatch(void);
-extern backend *xpidl_typelib_dispatch(void);
-extern backend *xpidl_doc_dispatch(void);
-extern backend *xpidl_java_dispatch(void);
-
-typedef struct ModeData {
-    char               *mode;
-    char               *modeInfo;
-    char               *suffix;
-    backendFactory     factory;
-} ModeData;
-
-typedef struct IncludePathEntry {
-    char                    *directory;
-    struct IncludePathEntry *next;
-} IncludePathEntry;
-
-struct TreeState {
-    FILE             *file;
-    char             *filename;
-    /* Maybe supplied by -o. Not related to (g_)basename from string.h or glib */
-    char             *basename;
-    IDL_ns           ns;
-    IDL_tree         tree;
-    GSList           *base_includes;
-    nodeHandler      *dispatch;
-    void             *priv;     /* mode-private data */
-};
-
-struct java_priv_data {
-    GHashTable *typedefTable;
-    GHashTable *keywords;
-    char       *filename;
-    GHashTable *nonIDLIfaces;
-};
-
-/*
- * Process an IDL file, generating InterfaceInfo, documentation and headers as
- * appropriate.
- */
-int
-xpidl_process_idl(char *filename, IncludePathEntry *include_path,
-                  char *file_basename, ModeData *mode);
-
-/*
- * Iterate over an IDLN_LIST -- why is this not part of libIDL?
- */
-void
-xpidl_list_foreach(IDL_tree p, IDL_tree_func foreach, gpointer user_data);
-
-/*
- * Wrapper whines to stderr then exits after null return from malloc or strdup.
- */
-void *
-xpidl_malloc(size_t nbytes);
-
-char *
-xpidl_strdup(const char *s);
-
-/*
- * Return a pointer to the start of the base filename of path
- */
-const char *
-xpidl_basename(const char * path);
-
-/*
- * Process an XPIDL node and its kids, if any.
- */
-gboolean
-xpidl_process_node(TreeState *state);
-
-/*
- * Write a newline folllowed by an indented, one-line comment containing IDL
- * source decompiled from state->tree.
- */
-void
-xpidl_write_comment(TreeState *state, int indent);
-
-
-
-/*
- * Functions for parsing and printing UUIDs.
- */
-
-/*
- * How large should the buffer supplied to xpidl_sprint_IID be?
- */
-#define UUID_LENGTH 37
-
-/*
- * Print an iid to into a supplied buffer; the buffer should be at least
- * UUID_LENGTH bytes.
- */
-gboolean
-xpidl_sprint_iid(nsID *iid, char iidbuf[]);
-
-/*
- * Parse a uuid string into an nsID struct.  We cannot link against libxpcom,
- * so we re-implement nsID::Parse here.
- */
-gboolean
-xpidl_parse_iid(nsID *id, const char *str);
-
-
-/* Try to common a little node-handling stuff. */
-
-/* is this node from an aggregate type (interface)? */
-#define UP_IS_AGGREGATE(node)                                                 \
-    (IDL_NODE_UP(node) &&                                                     \
-     (IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_INTERFACE ||                   \
-      IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_FORWARD_DCL))
-
-#define UP_IS_NATIVE(node)                                                    \
-    (IDL_NODE_UP(node) &&                                                     \
-     IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_NATIVE)
-
-#define DIPPER_TYPE(node)                                                     \
-    (NULL != IDL_tree_property_get(node, "domstring")  ||                     \
-     NULL != IDL_tree_property_get(node, "utf8string") ||                     \
-     NULL != IDL_tree_property_get(node, "cstring")    ||                     \
-     NULL != IDL_tree_property_get(node, "astring"))
-
-/*
- * Find the underlying type of an identifier typedef.  Returns NULL
- * (and doesn't complain) on failure.
- */
-IDL_tree /* IDL_TYPE_DCL */
-find_underlying_type(IDL_tree typedef_ident);
-
-/*
- * Check that const declarations match their stated sign and are of the
- * appropriate types.
- */
-gboolean
-verify_const_declaration(IDL_tree const_tree);
-
-/*
- * Check that scriptable attributes in scriptable interfaces actually are.
- */
-gboolean
-verify_attribute_declaration(IDL_tree method_tree);
-
-/*
- * Perform various validation checks on methods.
- */
-gboolean
-verify_method_declaration(IDL_tree method_tree);
-
-/*
- * Verifies the interface declaration
- */ 
-gboolean
-verify_interface_declaration(IDL_tree method_tree);
-
-/*
- * Verify that a native declaration has an associated C++ expression, i.e. that
- * it's of the form native <idl-name>(<c++-name>)
- */
-gboolean
-check_native(TreeState *state);
-
-void
-printlist(FILE *outfile, GSList *slist);
-
-gboolean
-is_method_scriptable(IDL_tree method_tree, IDL_tree ident);
-
-#endif /* __xpidl_h */
deleted file mode 100644
--- a/xpcom/typelib/xpidl/xpidl_doc.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "xpidl.h"
-
-/*
- * Generates documentation from javadoc-style comments in XPIDL files.
- */
-
-static gboolean
-doc_prolog(TreeState *state)
-{
-    fprintf(state->file, "<html>\n");
-    fprintf(state->file, "<head>\n");
-
-    fprintf(state->file,
-            "<!-- this file is generated from %s.idl -->\n",
-            state->basename);
-    fprintf(state->file, "<title>documentation for %s.idl interfaces</title>\n",
-            state->basename);
-    fprintf(state->file, "</head>\n\n");
-    fprintf(state->file, "<body>\n");
-
-    return TRUE;
-}
-
-static gboolean
-doc_epilog(TreeState *state)
-{
-    fprintf(state->file, "</body>\n");
-    fprintf(state->file, "</html>\n");
-
-    return TRUE;
-}
-
-
-static gboolean
-doc_list(TreeState *state)
-{
-    IDL_tree iter;
-    for (iter = state->tree; iter; iter = IDL_LIST(iter).next) {
-        state->tree = IDL_LIST(iter).data;
-        if (!xpidl_process_node(state))
-            return FALSE;
-    }
-    return TRUE;
-}
-
-static gboolean
-print_list(FILE *outfile, IDL_tree list)
-{
-    if (list == NULL)
-        return TRUE;
-
-    fprintf(outfile, "<ul>\n");
-    while (list != NULL) {
-        fprintf(outfile, "    <li>%s\n",
-                IDL_IDENT(IDL_LIST(list).data).str);
-        list = IDL_LIST(list).next;
-    }
-    fprintf(outfile, "</ul>\n");
-    return TRUE;
-}
-
-static gboolean
-doc_interface(TreeState *state)
-{
-    IDL_tree iface = state->tree;
-    IDL_tree iter;
-    IDL_tree orig;
-    char *classname = IDL_IDENT(IDL_INTERFACE(iface).ident).str;
-    GSList *doc_comments = IDL_IDENT(IDL_INTERFACE(iface).ident).comments;
-
-    fprintf(state->file, "interface %s<br>\n", classname);
-
-    /* Much more could happen at this step. */
-    /*
-     * If parsing doc comments, you might need to take some care with line
-     * endings, as the xpidl frontend will return comments containing of /r,
-     * /n, /r/n depending on the platform.  It's best to leave out platform
-     * #defines and just treat them all as equivalent.
-     */
-    if (doc_comments != NULL) {
-        fprintf(state->file, "doc comments:<br>\n");
-        fprintf(state->file, "<pre>\n");
-        printlist(state->file, doc_comments);
-        fprintf(state->file, "</pre>\n");
-        fprintf(state->file, "<br>\n");
-    }
-    
-    /* inherits from */
-    /*
-     * Note that we accept multiple inheritance here (for e.g. gnome idl)
-     * even though the header backend (specific to mozilla idl) rejects it.
-     */
-    if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
-        fprintf(state->file, "%s inherits from:<br>\n", classname);
-        print_list(state->file, iter);
-        fprintf(state->file, "<br>\n");
-    }
-
-    /*
-     * Call xpidl_process_node to recur through list of declarations in
-     * interface body; another option would be to explicitly iterate through
-     * the list.  xpidl_process_node currently requires twiddling the state to
-     * get the right node; I'll fix that soon to just take the node.  Makes it
-     * easier to follow what's going on, I think...
-     */
-    orig = state->tree;
-    state->tree = IDL_INTERFACE(iface).body;
-    if (state->tree && !xpidl_process_node(state))
-        return FALSE;
-    state->tree = orig;
-
-    return TRUE;
-}
-
-/*
- * Copied from xpidl_header.c.  You'll probably want to change it; if you can
- * use it verbatim or abstract it, we could move it to xpidl_util.c and share
- * it from there.
- */
-static gboolean
-write_type(IDL_tree type_tree, FILE *outfile)
-{
-    if (!type_tree) {
-        fputs("void", outfile);
-        return TRUE;
-    }
-
-    switch (IDL_NODE_TYPE(type_tree)) {
-      case IDLN_TYPE_INTEGER: {
-        gboolean sign = IDL_TYPE_INTEGER(type_tree).f_signed;
-        switch (IDL_TYPE_INTEGER(type_tree).f_type) {
-          case IDL_INTEGER_TYPE_SHORT:
-            fputs(sign ? "PRInt16" : "PRUint16", outfile);
-            break;
-          case IDL_INTEGER_TYPE_LONG:
-            fputs(sign ? "PRInt32" : "PRUint32", outfile);
-            break;
-          case IDL_INTEGER_TYPE_LONGLONG:
-            fputs(sign ? "PRInt64" : "PRUint64", outfile);
-            break;
-          default:
-            g_error("Unknown integer type %d\n",
-                    IDL_TYPE_INTEGER(type_tree).f_type);
-            return FALSE;
-        }
-        break;
-      }
-      case IDLN_TYPE_CHAR:
-        fputs("char", outfile);
-        break;
-      case IDLN_TYPE_WIDE_CHAR:
-        fputs("PRUnichar", outfile); /* wchar_t? */
-        break;
-      case IDLN_TYPE_WIDE_STRING:
-        fputs("PRUnichar *", outfile);
-        break;
-      case IDLN_TYPE_STRING:
-        fputs("char *", outfile);
-        break;
-      case IDLN_TYPE_BOOLEAN:
-        fputs("PRBool", outfile);
-        break;
-      case IDLN_TYPE_OCTET:
-        fputs("PRUint8", outfile);
-        break;
-      case IDLN_TYPE_FLOAT:
-        switch (IDL_TYPE_FLOAT(type_tree).f_type) {
-          case IDL_FLOAT_TYPE_FLOAT:
-            fputs("float", outfile);
-            break;
-          case IDL_FLOAT_TYPE_DOUBLE:
-            fputs("double", outfile);
-            break;
-          /* XXX 'long double' just ignored, or what? */
-          default:
-            fprintf(outfile, "unknown_type_%d", IDL_NODE_TYPE(type_tree));
-            break;
-        }
-        break;
-      case IDLN_IDENT:
-        if (UP_IS_NATIVE(type_tree)) {
-            fputs(IDL_NATIVE(IDL_NODE_UP(type_tree)).user_type, outfile);
-            if (IDL_tree_property_get(type_tree, "ptr")) {
-                fputs(" *", outfile);
-            } else if (IDL_tree_property_get(type_tree, "ref")) {
-                fputs(" &", outfile);
-            }
-        } else {
-            fputs(IDL_IDENT(type_tree).str, outfile);
-        }
-        if (UP_IS_AGGREGATE(type_tree))
-            fputs(" *", outfile);
-        break;
-      default:
-        fprintf(outfile, "unknown_type_%d", IDL_NODE_TYPE(type_tree));
-        break;
-    }
-    return TRUE;
-}
-
-/* handle ATTR_DCL (attribute declaration) nodes */
-static gboolean
-doc_attribute_declaration(TreeState *state)
-{
-    IDL_tree attr = state->tree;
-
-    if (!verify_attribute_declaration(attr))
-        return FALSE;
-    /*
-     * Attribute idents can also take doc comments.  They're ignored here;
-     * should they be?
-     */
-
-    if (IDL_ATTR_DCL(attr).f_readonly)
-        fprintf(state->file, "readonly ");
-
-    fprintf(state->file, "attribute ");
-
-    if (!write_type(IDL_ATTR_DCL(attr).param_type_spec, state->file))
-        return FALSE;
-
-    fprintf(state->file, "\n");
-    print_list(state->file, IDL_ATTR_DCL(attr).simple_declarations);
-    fprintf(state->file, "<br>\n");
-
-    return TRUE;
-}
-
-/* handle OP_DCL (method declaration) nodes */
-static gboolean
-doc_method_declaration(TreeState *state)
-{
-    /*
-     * Doc comment for attributes also applies here.
-     */
-
-    /*
-     * Look at 'write_method_signature' in xpidl_header.c for an example of how
-     * to navigate parse trees for methods.  For here, I just print the method
-     * name.
-     */
-
-    fprintf(state->file,
-            "method %s<br>\n",
-            IDL_IDENT(IDL_OP_DCL(state->tree).ident).str);
-
-    return TRUE;
-}
-
-backend *
-xpidl_doc_dispatch(void)
-{
-    static backend result;
-    static nodeHandler table[IDLN_LAST];
-    static gboolean initialized = FALSE;
-
-    result.emit_prolog = doc_prolog;
-    result.emit_epilog = doc_epilog;
-
-    if (!initialized) {
-        /* Initialize non-NULL elements */
-
-        /* I just handle a few... many still to be filled in! */
-
-        table[IDLN_LIST] = doc_list;
-        table[IDLN_INTERFACE] = doc_interface;
-        table[IDLN_ATTR_DCL] = doc_attribute_declaration;
-        table[IDLN_OP_DCL] = doc_method_declaration;
-
-        initialized = TRUE;
-    }
-  
-    result.dispatch_table = table;
-    return &result;
-}
deleted file mode 100644
--- a/xpcom/typelib/xpidl/xpidl_header.c
+++ /dev/null
@@ -1,1298 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * Generate XPCOM headers from XPIDL.
- */
-
-#include "xpidl.h"
-#include <ctype.h>
-
-#define AS_DECL 0
-#define AS_CALL 1
-#define AS_IMPL 2
-
-static gboolean write_method_signature(IDL_tree method_tree, FILE *outfile,
-                                       int mode, const char *className);
-static gboolean write_attr_accessor(IDL_tree attr_tree, FILE * outfile,
-                                    gboolean getter, 
-                                    int mode, const char *className);
-
-static void
-write_indent(FILE *outfile) {
-    fputs("  ", outfile);
-}
-
-static gboolean
-header_prolog(TreeState *state)
-{
-    const char *define = xpidl_basename(state->basename);
-    fprintf(state->file, "/*\n * DO NOT EDIT.  THIS FILE IS GENERATED FROM"
-            " %s.idl\n */\n", state->basename);
-    fprintf(state->file,
-            "\n#ifndef __gen_%s_h__\n"
-            "#define __gen_%s_h__\n",
-            define, define);
-    if (state->base_includes != NULL) {
-        guint len = g_slist_length(state->base_includes);
-        guint i;
-
-        fputc('\n', state->file);
-        for (i = 0; i < len; i++) {
-            char *ident, *dot;
-            
-            ident = (char *)g_slist_nth_data(state->base_includes, i);
-            
-            /* suppress any trailing .extension */
-            
-            /* XXX use g_basename instead ? ? */
-            
-            dot = strrchr(ident, '.');
-            if (dot != NULL)
-                *dot = '\0';
-            
-
-            /* begin include guard */            
-            fprintf(state->file,
-                    "\n#ifndef __gen_%s_h__\n",
-                     ident);
-
-            fprintf(state->file, "#include \"%s.h\"\n",
-                    (char *)g_slist_nth_data(state->base_includes, i));
-
-            fprintf(state->file, "#endif\n");
-            
-        }
-        if (i > 0)
-            fputc('\n', state->file);
-    }
-    /*
-     * Support IDL files that don't include a root IDL file that defines
-     * NS_NO_VTABLE.
-     */
-    fprintf(state->file,
-            "/* For IDL files that don't want to include root IDL files. */\n"
-            "#ifndef NS_NO_VTABLE\n"
-            "#define NS_NO_VTABLE\n"
-            "#endif\n");
-    
-    return TRUE;
-}
-
-static gboolean
-header_epilog(TreeState *state)
-{
-    const char *define = xpidl_basename(state->basename);
-    fprintf(state->file, "\n#endif /* __gen_%s_h__ */\n", define);
-    return TRUE;
-}
-
-static void
-write_classname_iid_define(FILE *file, const char *className)
-{
-    const char *iidName;
-    if (className[0] == 'n' && className[1] == 's') {
-        /* backcompat naming styles */
-        fputs("NS_", file);
-        iidName = className + 2;
-    } else {
-        iidName = className;
-    }
-    while (*iidName)
-        fputc(toupper(*iidName++), file);
-    fputs("_IID", file);
-}
-
-static gboolean
-interface(TreeState *state)
-{
-    IDL_tree iface = state->tree, iter, orig;
-    char *className = IDL_IDENT(IDL_INTERFACE(iface).ident).str;
-    char *classNameUpper = NULL;
-    char *classNameImpl = NULL;
-    char *cp;
-    gboolean ok = TRUE;
-    gboolean keepvtable, scriptable, deprecated;
-    const char *iid;
-    const char *name_space;
-    struct nsID id;
-    char iid_parsed[UUID_LENGTH];
-    GSList *doc_comments = IDL_IDENT(IDL_INTERFACE(iface).ident).comments;
-
-    if (!verify_interface_declaration(iface))
-        return FALSE;
-
-#define FAIL    do {ok = FALSE; goto out;} while(0)
-
-    fprintf(state->file,   "\n/* starting interface:    %s */\n",
-            className);
-
-    name_space = IDL_tree_property_get(IDL_INTERFACE(iface).ident, "namespace");
-    if (name_space) {
-        fprintf(state->file, "/* namespace:             %s */\n",
-                name_space);
-        fprintf(state->file, "/* fully qualified name:  %s.%s */\n",
-                name_space,className);
-    }
-
-    iid = IDL_tree_property_get(IDL_INTERFACE(iface).ident, "uuid");
-    if (iid) {
-        /* Redundant, but a better error than 'cannot parse.' */
-        if (strlen(iid) != 36) {
-            IDL_tree_error(state->tree, "IID %s is the wrong length\n", iid);
-            FAIL;
-        }
-
-        /*
-         * Parse uuid and then output resulting nsID to string, to validate
-         * uuid and normalize resulting .h files.
-         */
-        if (!xpidl_parse_iid(&id, iid)) {
-            IDL_tree_error(state->tree, "cannot parse IID %s\n", iid);
-            FAIL;
-        }
-        if (!xpidl_sprint_iid(&id, iid_parsed)) {
-            IDL_tree_error(state->tree, "error formatting IID %s\n", iid);
-            FAIL;
-        }
-
-        /* #define NS_ISUPPORTS_IID_STR "00000000-0000-0000-c000-000000000046" */
-        fputs("#define ", state->file);
-        write_classname_iid_define(state->file, className);
-        fprintf(state->file, "_STR \"%s\"\n", iid_parsed);
-        fputc('\n', state->file);
-
-        /* #define NS_ISUPPORTS_IID { {0x00000000 .... 0x46 }} */
-        fprintf(state->file, "#define ");
-        write_classname_iid_define(state->file, className);
-        fprintf(state->file, " \\\n"
-                "  {0x%.8x, 0x%.4x, 0x%.4x, \\\n"
-                "    { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, "
-                "0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }}\n",
-                id.m0, id.m1, id.m2,
-                id.m3[0], id.m3[1], id.m3[2], id.m3[3],
-                id.m3[4], id.m3[5], id.m3[6], id.m3[7]);
-        fputc('\n', state->file);
-    } else {
-        IDL_tree_error(state->tree, "interface %s lacks a uuid attribute\n", 
-            className);
-        FAIL;
-    }
-
-    if (doc_comments != NULL)
-        printlist(state->file, doc_comments);
-
-    /*
-     * NS_NO_VTABLE is defined in nsISupportsUtils.h, and defined on windows
-     * to __declspec(novtable) on windows.  This optimization is safe
-     * whenever the constructor calls no virtual methods.  Writing in IDL
-     * almost guarantees this, except for the case when a %{C++ block occurs in
-     * the interface.  We detect that case, and emit a macro call that disables
-     * the optimization.
-     */
-    keepvtable = FALSE;
-    for (iter = IDL_INTERFACE(state->tree).body;
-         iter != NULL;
-         iter = IDL_LIST(iter).next)
-    {
-        IDL_tree data = IDL_LIST(iter).data;
-        if (IDL_NODE_TYPE(data) == IDLN_CODEFRAG)
-            keepvtable = TRUE;
-    }
-   
-    scriptable = deprecated = FALSE;
-    if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable"))
-        scriptable = TRUE;
-    if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "deprecated"))
-        deprecated = TRUE;
-
-    /* The interface declaration itself. */
-    fprintf(state->file,
-            "class %s%s%s%s",
-            (keepvtable ? "" : "NS_NO_VTABLE "),
-            (scriptable ? "NS_SCRIPTABLE " : ""),
-            (deprecated ? "MOZ_DEPRECATED " : ""),
-            className);
-    
-    if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
-        fputs(" : ", state->file);
-        if (IDL_LIST(iter).next != NULL) {
-            IDL_tree_error(iter,
-                           "multiple inheritance is not supported by xpidl");
-            FAIL;
-        }
-        fprintf(state->file, "public %s", IDL_IDENT(IDL_LIST(iter).data).str);
-    }
-    fputs(" {\n"
-          " public: \n\n", state->file);
-    if (iid) {
-        fputs("  NS_DECLARE_STATIC_IID_ACCESSOR(", state->file);
-        write_classname_iid_define(state->file, className);
-        fputs(")\n\n", state->file);
-    }
-
-    orig = state->tree; /* It would be nice to remove this state-twiddling. */
-
-    state->tree = IDL_INTERFACE(iface).body;
-
-    if (state->tree && !xpidl_process_node(state))
-        FAIL;
-
-    fputs("};\n", state->file);
-    fputc('\n', state->file);
-
-    if (iid) {
-        fprintf(state->file, "  NS_DEFINE_STATIC_IID_ACCESSOR(%s, ",
-                 className);
-        write_classname_iid_define(state->file, className);
-        fputs(")\n\n", state->file);
-    }
-
-    /*
-     * #define NS_DECL_NSIFOO - create method prototypes that can be used in
-     * class definitions that support this interface.
-     *
-     * Walk the tree explicitly to prototype a reworking of xpidl to get rid of
-     * the callback mechanism.
-     */
-    state->tree = orig;
-    fputs("/* Use this macro when declaring classes that implement this "
-          "interface. */\n", state->file);
-    fputs("#define NS_DECL_", state->file);
-    classNameUpper = xpidl_strdup(className);
-    for (cp = classNameUpper; *cp != '\0'; cp++)
-        *cp = toupper(*cp);
-    fprintf(state->file, "%s \\\n", classNameUpper);
-    if (IDL_INTERFACE(state->tree).body == NULL) {
-        write_indent(state->file);
-        fputs("/* no methods! */\n", state->file);
-    }
-
-    for (iter = IDL_INTERFACE(state->tree).body;
-         iter != NULL;
-         iter = IDL_LIST(iter).next)
-    {
-        IDL_tree data = IDL_LIST(iter).data;
-
-        switch(IDL_NODE_TYPE(data)) {
-          case IDLN_OP_DCL:
-            write_indent(state->file);
-            write_method_signature(data, state->file, AS_DECL, NULL);
-            break;
-
-          case IDLN_ATTR_DCL:
-            write_indent(state->file);
-            if (!write_attr_accessor(data, state->file, TRUE, AS_DECL, NULL))
-                FAIL;
-            if (!IDL_ATTR_DCL(data).f_readonly) {
-                fputs("; \\\n", state->file); /* Terminate the previous one. */
-                write_indent(state->file);
-                if (!write_attr_accessor(data, state->file,
-                                         FALSE, AS_DECL, NULL))
-                    FAIL;
-                /* '; \n' at end will clean up. */
-            }
-            break;
-
-          case IDLN_CONST_DCL:
-            /* ignore it here; it doesn't contribute to the macro. */
-            continue;
-
-          case IDLN_CODEFRAG:
-            XPIDL_WARNING((iter, IDL_WARNING1,
-                           "%%{ .. %%} code fragment within interface "
-                           "ignored when generating NS_DECL_%s macro; "
-                           "if the code fragment contains method "
-                           "declarations, the macro probably isn't "
-                           "complete.", classNameUpper));
-            continue;
-
-          default:
-            IDL_tree_error(iter,
-                           "unexpected node type %d! "
-                           "Please file a bug against the xpidl component.",
-                           IDL_NODE_TYPE(data));
-            FAIL;
-        }
-
-        if (IDL_LIST(iter).next != NULL) {
-            fprintf(state->file, "; \\\n");
-        } else {
-            fprintf(state->file, "; \n");
-        }
-    }
-    fputc('\n', state->file);
-
-    /* XXX abstract above and below into one function? */
-    /*
-     * #define NS_FORWARD_NSIFOO - create forwarding methods that can delegate
-     * behavior from in implementation to another object.  As generated by
-     * idlc.
-     */
-    fprintf(state->file,
-            "/* Use this macro to declare functions that forward the "
-            "behavior of this interface to another object. */\n"
-            "#define NS_FORWARD_%s(_to) \\\n",
-            classNameUpper);
-    if (IDL_INTERFACE(state->tree).body == NULL) {
-        write_indent(state->file);
-        fputs("/* no methods! */\n", state->file);
-    }
-
-    for (iter = IDL_INTERFACE(state->tree).body;
-         iter != NULL;
-         iter = IDL_LIST(iter).next)
-    {
-        IDL_tree data = IDL_LIST(iter).data;
-
-        switch(IDL_NODE_TYPE(data)) {
-          case IDLN_OP_DCL:
-            write_indent(state->file);
-            write_method_signature(data, state->file, AS_DECL, NULL);
-            fputs(" { return _to ", state->file);
-            write_method_signature(data, state->file, AS_CALL, NULL);
-            break;
-
-          case IDLN_ATTR_DCL:
-            write_indent(state->file);
-            if (!write_attr_accessor(data, state->file, TRUE, AS_DECL, NULL))
-                FAIL;
-            fputs(" { return _to ", state->file);
-            if (!write_attr_accessor(data, state->file, TRUE, AS_CALL, NULL))
-                FAIL;
-            if (!IDL_ATTR_DCL(data).f_readonly) {
-                fputs("; } \\\n", state->file); /* Terminate the previous one. */
-                write_indent(state->file);
-                if (!write_attr_accessor(data, state->file,
-                                         FALSE, AS_DECL, NULL))
-                    FAIL;
-                fputs(" { return _to ", state->file);
-                if (!write_attr_accessor(data, state->file,
-                                         FALSE, AS_CALL, NULL))
-                    FAIL;
-                /* '; } \n' at end will clean up. */
-            }
-            break;
-
-          case IDLN_CONST_DCL:
-          case IDLN_CODEFRAG:
-              continue;
-
-          default:
-            FAIL;
-        }
-
-        if (IDL_LIST(iter).next != NULL) {
-            fprintf(state->file, "; } \\\n");
-        } else {
-            fprintf(state->file, "; } \n");
-        }
-    }
-    fputc('\n', state->file);
-
-
-    /* XXX abstract above and below into one function? */
-    /*
-     * #define NS_FORWARD_SAFE_NSIFOO - create forwarding methods that can delegate
-     * behavior from in implementation to another object.  As generated by
-     * idlc.
-     */
-    fprintf(state->file,
-            "/* Use this macro to declare functions that forward the "
-            "behavior of this interface to another object in a safe way. */\n"
-            "#define NS_FORWARD_SAFE_%s(_to) \\\n",
-            classNameUpper);
-    if (IDL_INTERFACE(state->tree).body == NULL) {
-        write_indent(state->file);
-        fputs("/* no methods! */\n", state->file);
-    }
-
-    for (iter = IDL_INTERFACE(state->tree).body;
-         iter != NULL;
-         iter = IDL_LIST(iter).next)
-    {
-        IDL_tree data = IDL_LIST(iter).data;
-
-        switch(IDL_NODE_TYPE(data)) {
-          case IDLN_OP_DCL:
-            write_indent(state->file);
-            write_method_signature(data, state->file, AS_DECL, NULL);
-            fputs(" { return !_to ? NS_ERROR_NULL_POINTER : _to->", state->file);
-            write_method_signature(data, state->file, AS_CALL, NULL);
-            break;
-
-          case IDLN_ATTR_DCL:
-            write_indent(state->file);
-            if (!write_attr_accessor(data, state->file, TRUE, AS_DECL, NULL))
-                FAIL;
-            fputs(" { return !_to ? NS_ERROR_NULL_POINTER : _to->", state->file);
-            if (!write_attr_accessor(data, state->file, TRUE, AS_CALL, NULL))
-                FAIL;
-            if (!IDL_ATTR_DCL(data).f_readonly) {
-                fputs("; } \\\n", state->file); /* Terminate the previous one. */
-                write_indent(state->file);
-                if (!write_attr_accessor(data, state->file,
-                                         FALSE, AS_DECL, NULL))
-                    FAIL;
-                fputs(" { return !_to ? NS_ERROR_NULL_POINTER : _to->", state->file);
-                if (!write_attr_accessor(data, state->file,
-                                         FALSE, AS_CALL, NULL))
-                    FAIL;
-                /* '; } \n' at end will clean up. */
-            }
-            break;
-
-          case IDLN_CONST_DCL:
-          case IDLN_CODEFRAG:
-              continue;
-
-          default:
-            FAIL;
-        }
-
-        if (IDL_LIST(iter).next != NULL) {
-            fprintf(state->file, "; } \\\n");
-        } else {
-            fprintf(state->file, "; } \n");
-        }
-    }
-    fputc('\n', state->file);
-
-    /*
-     * Build a sample implementation template.
-     */
-    if (strlen(className) >= 3 && className[2] == 'I') {
-        classNameImpl = xpidl_strdup(className);
-        if (!classNameImpl)
-            FAIL;
-        memmove(&classNameImpl[2], &classNameImpl[3], strlen(classNameImpl) - 2);
-    } else {
-        classNameImpl = xpidl_strdup("_MYCLASS_");
-        if (!classNameImpl)
-            FAIL;
-    }
-
-    fputs("#if 0\n"
-          "/* Use the code below as a template for the "
-          "implementation class for this interface. */\n"
-          "\n"
-          "/* Header file */"
-          "\n",
-          state->file);
-    fprintf(state->file, "class %s : public %s\n", classNameImpl, className);
-    fputs("{\n"
-          "public:\n", state->file);
-    write_indent(state->file);
-    fputs("NS_DECL_ISUPPORTS\n", state->file);
-    write_indent(state->file);
-    fprintf(state->file, "NS_DECL_%s\n", classNameUpper);
-    fputs("\n", state->file);
-    write_indent(state->file);
-    fprintf(state->file, "%s();\n", classNameImpl);
-    fputs("\n"
-          "private:\n", state->file);
-    write_indent(state->file);
-    fprintf(state->file, "~%s();\n", classNameImpl);
-    fputs("\n"
-          "protected:\n", state->file);
-    write_indent(state->file);
-    fputs("/* additional members */\n", state->file);
-    fputs("};\n\n", state->file);
-
-    fputs("/* Implementation file */\n", state->file);
-
-    fprintf(state->file, 
-            "NS_IMPL_ISUPPORTS1(%s, %s)\n", classNameImpl, className);
-    fputs("\n", state->file);
-    
-    fprintf(state->file, "%s::%s()\n", classNameImpl, classNameImpl);
-    fputs("{\n", state->file);
-    write_indent(state->file);
-    fputs("/* member initializers and constructor code */\n", state->file);
-    fputs("}\n\n", state->file);
-    
-    fprintf(state->file, "%s::~%s()\n", classNameImpl, classNameImpl);
-    fputs("{\n", state->file);
-    write_indent(state->file);
-    fputs("/* destructor code */\n", state->file);
-    fputs("}\n\n", state->file);
-
-    for (iter = IDL_INTERFACE(state->tree).body;
-         iter != NULL;
-         iter = IDL_LIST(iter).next)
-    {
-        IDL_tree data = IDL_LIST(iter).data;
-
-        switch(IDL_NODE_TYPE(data)) {
-          case IDLN_OP_DCL:
-            /* It would be nice to remove this state-twiddling. */
-            orig = state->tree; 
-            state->tree = data;
-            xpidl_write_comment(state, 0);
-            state->tree = orig;
-
-            write_method_signature(data, state->file, AS_IMPL, classNameImpl);
-            fputs("\n{\n", state->file);
-            write_indent(state->file);
-            write_indent(state->file);
-            fputs("return NS_ERROR_NOT_IMPLEMENTED;\n"
-                  "}\n"
-                  "\n", state->file);
-            break;
-
-          case IDLN_ATTR_DCL:
-            /* It would be nice to remove this state-twiddling. */
-            orig = state->tree; 
-            state->tree = data;
-            xpidl_write_comment(state, 0);
-            state->tree = orig;
-            
-            if (!write_attr_accessor(data, state->file, TRUE, 
-                                     AS_IMPL, classNameImpl))
-                FAIL;
-            fputs("\n{\n", state->file);
-            write_indent(state->file);
-            write_indent(state->file);
-            fputs("return NS_ERROR_NOT_IMPLEMENTED;\n"
-                  "}\n", state->file);
-
-            if (!IDL_ATTR_DCL(data).f_readonly) {
-                if (!write_attr_accessor(data, state->file, FALSE, 
-                                         AS_IMPL, classNameImpl))
-                    FAIL;
-                fputs("\n{\n", state->file);
-                write_indent(state->file);
-                write_indent(state->file);
-                fputs("return NS_ERROR_NOT_IMPLEMENTED;\n"
-                      "}\n", state->file);
-            }
-            fputs("\n", state->file);
-            break;
-
-          case IDLN_CONST_DCL:
-          case IDLN_CODEFRAG:
-              continue;
-
-          default:
-            FAIL;
-        }
-    }
-
-    fputs("/* End of implementation class template. */\n"
-          "#endif\n"
-          "\n", state->file);
-
-#undef FAIL
-
-out:
-    if (classNameUpper)
-        free(classNameUpper);
-    if (classNameImpl)
-        free(classNameImpl);
-    return ok;
-}
-
-static gboolean
-list(TreeState *state)
-{
-    IDL_tree iter;
-    for (iter = state->tree; iter; iter = IDL_LIST(iter).next) {
-        state->tree = IDL_LIST(iter).data;
-        if (!xpidl_process_node(state))
-            return FALSE;
-    }
-    return TRUE;
-}
-
-typedef enum write_type_mode {
-    WT_PLAIN, /* for use with typedef; also with NS_IMETHOD_() or NS_IMETHODIMP_() */
-    WT_IN, /* [in] param or setter */
-    WT_OUT /* [out] param, [inout] param, or getter */
-} write_type_mode;
-
-static gboolean
-write_type(IDL_tree type_tree, write_type_mode mode, gboolean force_const, FILE *outfile)
-{
-    gboolean starred;
-
-    if (!type_tree) {
-        fputs("void", outfile);
-        return TRUE;
-    }
-
-    /* In parameters for string, reference, and dipper types get const. */
-    if (force_const ||
-        (mode == WT_IN &&
-         (IDL_NODE_TYPE(type_tree) == IDLN_TYPE_STRING ||
-          IDL_NODE_TYPE(type_tree) == IDLN_TYPE_WIDE_STRING ||
-          IDL_tree_property_get(type_tree, "nsid") ||
-          IDL_tree_property_get(type_tree, "jsval") ||
-          DIPPER_TYPE(type_tree))))
-    {
-        fputs("const ", outfile);
-    }
-
-    starred = FALSE;
-    switch (IDL_NODE_TYPE(type_tree)) {
-      case IDLN_TYPE_INTEGER: {
-        gboolean sign = IDL_TYPE_INTEGER(type_tree).f_signed;
-        switch (IDL_TYPE_INTEGER(type_tree).f_type) {
-          case IDL_INTEGER_TYPE_SHORT:
-            fputs(sign ? "PRInt16" : "PRUint16", outfile);
-            break;
-          case IDL_INTEGER_TYPE_LONG:
-            fputs(sign ? "PRInt32" : "PRUint32", outfile);
-            break;
-          case IDL_INTEGER_TYPE_LONGLONG:
-            fputs(sign ? "PRInt64" : "PRUint64", outfile);
-            break;
-          default:
-            g_error("Unknown integer type %d\n",
-                    IDL_TYPE_INTEGER(type_tree).f_type);
-            return FALSE;
-        }
-        break;
-      }
-      case IDLN_TYPE_CHAR:
-        fputs("char", outfile);
-        break;
-      case IDLN_TYPE_WIDE_CHAR:
-        fputs("PRUnichar", outfile); /* wchar_t? */
-        break;
-      case IDLN_TYPE_WIDE_STRING:
-        fputs("PRUnichar *", outfile);
-        starred = TRUE;
-        break;
-      case IDLN_TYPE_STRING:
-        fputs("char *", outfile);
-        starred = TRUE;
-        break;
-      case IDLN_TYPE_BOOLEAN:
-        fputs("PRBool", outfile);
-        break;
-      case IDLN_TYPE_OCTET:
-        fputs("PRUint8", outfile);
-        break;
-      case IDLN_TYPE_FLOAT:
-        switch (IDL_TYPE_FLOAT(type_tree).f_type) {
-          case IDL_FLOAT_TYPE_FLOAT:
-            fputs("float", outfile);
-            break;
-          case IDL_FLOAT_TYPE_DOUBLE:
-            fputs("double", outfile);
-            break;
-          /* XXX 'long double' just ignored, or what? */
-          default:
-            fprintf(outfile, "unknown_type_%d", IDL_NODE_TYPE(type_tree));
-            break;
-        }
-        break;
-      case IDLN_IDENT:
-        if (UP_IS_NATIVE(type_tree)) {
-            if (IDL_tree_property_get(type_tree, "domstring") ||
-                IDL_tree_property_get(type_tree, "astring")) {
-                fputs("nsAString", outfile);
-            } else if (IDL_tree_property_get(type_tree, "utf8string")) {
-                fputs("nsACString", outfile);
-            } else if (IDL_tree_property_get(type_tree, "cstring")) {
-                fputs("nsACString", outfile);
-            } else {
-                fputs(IDL_NATIVE(IDL_NODE_UP(type_tree)).user_type, outfile);
-            }
-            if (IDL_tree_property_get(type_tree, "ptr")) {
-                fputs(" *", outfile);
-                starred = TRUE;
-            } else if (IDL_tree_property_get(type_tree, "ref")) {
-                if (mode == WT_IN || DIPPER_TYPE(type_tree)) {
-                    fputs(" &", outfile);
-                }
-            }
-        } else {
-            fputs(IDL_IDENT(type_tree).str, outfile);
-        }
-        if (UP_IS_AGGREGATE(type_tree)) {
-            fputs(" *", outfile);
-            starred = TRUE;
-        }
-        break;
-      default:
-        fprintf(outfile, "unknown_type_%d", IDL_NODE_TYPE(type_tree));
-        break;
-    }
-
-    if (!starred)
-        fputc(' ', outfile);
-    if (mode == WT_OUT && !DIPPER_TYPE(type_tree))
-        fputc('*', outfile);
-    return TRUE;
-}
-
-/*
- * An attribute declaration looks like:
- *
- * [ IDL_ATTR_DCL]
- *   - param_type_spec [IDL_TYPE_* or NULL for void]
- *   - simple_declarations [IDL_LIST]
- *     - data [IDL_IDENT]
- *     - next [IDL_LIST or NULL if no more idents]
- *       - data [IDL_IDENT]
- */
-
-#define ATTR_IDENT(tree) (IDL_IDENT(IDL_LIST(IDL_ATTR_DCL(tree).simple_declarations).data))
-#define ATTR_TYPE_DECL(tree) (IDL_ATTR_DCL(tree).param_type_spec)
-#define ATTR_TYPE(tree) (IDL_NODE_TYPE(ATTR_TYPE_DECL(tree)))
-#define ATTR_DECLS(tree) (IDL_LIST(IDL_ATTR_DCL(tree).simple_declarations).data)
-
-/*
- *  AS_DECL writes 'NS_IMETHOD foo(string bar, long sil)'
- *  AS_IMPL writes 'NS_IMETHODIMP className::foo(string bar, long sil)'
- *  AS_CALL writes 'foo(bar, sil)'
- */
-static gboolean
-write_attr_accessor(IDL_tree attr_tree, FILE * outfile,
-                    gboolean getter, int mode, const char *className)
-{
-    char *attrname = ATTR_IDENT(attr_tree).str;
-    const char *binaryname;
-    IDL_tree ident = IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).data;
-    gboolean nostdcall =
-        (IDL_tree_property_get(ATTR_DECLS(attr_tree), "nostdcall") != NULL);
-
-    if (mode == AS_DECL) {
-        if (IDL_tree_property_get(ident, "deprecated"))
-            fputs("MOZ_DEPRECATED ", outfile);
-        if (is_method_scriptable(attr_tree, ident))
-            fputs("NS_SCRIPTABLE ", outfile);
-
-        if (nostdcall)
-            fputs("virtual nsresult ", outfile);
-        else
-            fputs("NS_IMETHOD ", outfile);
-    } else if (mode == AS_IMPL) {
-        if (nostdcall)
-            fprintf(outfile, "nsresult %s::", className);
-        else
-            fprintf(outfile, "NS_IMETHODIMP %s::", className);
-    }
-    fprintf(outfile, "%cet",
-            getter ? 'G' : 'S');
-    binaryname = IDL_tree_property_get(ATTR_DECLS(attr_tree), "binaryname");
-    if (binaryname) {
-        fprintf(outfile, "%s(",
-                binaryname);
-    } else {
-        fprintf(outfile, "%c%s(",
-                toupper(*attrname),
-                attrname + 1);
-    }
-    if (IDL_tree_property_get(ident, "implicit_jscontext")) {
-        if (mode == AS_DECL || mode == AS_IMPL)
-            fputs("JSContext *", outfile);
-        fputs("cx, ", outfile);
-    }
-    if (mode == AS_DECL || mode == AS_IMPL) {
-        if (!write_type(ATTR_TYPE_DECL(attr_tree),
-                        getter ? WT_OUT : WT_IN,
-                        FALSE,
-                        outfile)) {
-            return FALSE;
-        }
-    }
-    fprintf(outfile, "a%c%s)", toupper(attrname[0]), attrname + 1);
-    return TRUE;
-}
-
-static gboolean
-attr_dcl(TreeState *state)
-{
-    GSList *doc_comments;
-
-    if (!verify_attribute_declaration(state->tree))
-        return FALSE;
-
-    doc_comments =
-        IDL_IDENT(IDL_LIST(IDL_ATTR_DCL
-                           (state->tree).simple_declarations).data).comments;
-
-    if (doc_comments != NULL) {
-        write_indent(state->file);
-        printlist(state->file, doc_comments);
-    }
-
-    /*
-     * XXX lists of attributes with the same type, e.g.
-     * attribute string foo, bar sil;
-     * are legal IDL... but we don't do anything with 'em.
-     */
-    if (IDL_LIST(IDL_ATTR_DCL(state->tree).simple_declarations).next != NULL) {
-        XPIDL_WARNING((state->tree, IDL_WARNING1,
-                       "multiple attributes in a single declaration aren't "
-                       "currently supported by xpidl"));
-    }
-
-    xpidl_write_comment(state, 2);
-
-    write_indent(state->file);
-    if (!write_attr_accessor(state->tree, state->file, TRUE, AS_DECL, NULL))
-        return FALSE;
-    fputs(" = 0;\n", state->file);
-
-    if (!IDL_ATTR_DCL(state->tree).f_readonly) {
-        write_indent(state->file);
-        if (!write_attr_accessor(state->tree, state->file, FALSE, AS_DECL, NULL))
-            return FALSE;
-        fputs(" = 0;\n", state->file);
-    }
-    fputc('\n', state->file);
-
-    return TRUE;
-}
-
-static gboolean
-do_enum(TreeState *state)
-{
-    IDL_tree_error(state->tree, "enums not supported, "
-                   "see http://bugzilla.mozilla.org/show_bug.cgi?id=8781");
-    return FALSE;
-}
-
-static gboolean
-do_const_dcl(TreeState *state)
-{
-    struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree);
-    const char *name = IDL_IDENT(dcl->ident).str;
-    gboolean is_signed;
-    GSList *doc_comments = IDL_IDENT(dcl->ident).comments;
-    IDL_tree real_type;
-    const char *const_format;
-
-    if (!verify_const_declaration(state->tree))
-        return FALSE;
-
-    if (doc_comments != NULL) {
-        write_indent(state->file);
-        printlist(state->file, doc_comments);
-    }
-
-    /* Could be a typedef; try to map it to the real type. */
-    real_type = find_underlying_type(dcl->const_type);
-    real_type = real_type ? real_type : dcl->const_type;
-    is_signed = IDL_TYPE_INTEGER(real_type).f_signed;
-
-    const_format = is_signed ? "%" IDL_LL "d" : "%" IDL_LL "uU";
-    write_indent(state->file);
-    fprintf(state->file, "enum { %s = ", name);
-    fprintf(state->file, const_format, IDL_INTEGER(dcl->const_exp).value);
-    fprintf(state->file, " };\n\n");
-
-    return TRUE;
-}
-
-static gboolean
-do_typedef(TreeState *state)
-{
-    IDL_tree type = IDL_TYPE_DCL(state->tree).type_spec;
-    IDL_tree dcls = IDL_TYPE_DCL(state->tree).dcls;
-    IDL_tree complex;
-    GSList *doc_comments;
-
-    if (IDL_NODE_TYPE(type) == IDLN_TYPE_SEQUENCE) {
-        XPIDL_WARNING((state->tree, IDL_WARNING1,
-                       "sequences not supported, ignored"));
-    } else {
-        if (IDL_NODE_TYPE(complex = IDL_LIST(dcls).data) == IDLN_TYPE_ARRAY) {
-            IDL_tree dim = IDL_TYPE_ARRAY(complex).size_list;
-            doc_comments = IDL_IDENT(IDL_TYPE_ARRAY(complex).ident).comments;
-
-            if (doc_comments != NULL)
-                printlist(state->file, doc_comments);
-
-            fputs("typedef ", state->file);
-            if (!write_type(type, WT_PLAIN, FALSE, state->file))
-                return FALSE;
-            fputs(" ", state->file);
-
-            fprintf(state->file, "%s",
-                    IDL_IDENT(IDL_TYPE_ARRAY(complex).ident).str);
-            do {
-                fputc('[', state->file);
-                if (IDL_LIST(dim).data) {
-                    fprintf(state->file, "%ld",
-                            (long)IDL_INTEGER(IDL_LIST(dim).data).value);
-                }
-                fputc(']', state->file);
-            } while ((dim = IDL_LIST(dim).next) != NULL);
-        } else {
-            doc_comments = IDL_IDENT(IDL_LIST(dcls).data).comments;
-
-            if (doc_comments != NULL)
-                printlist(state->file, doc_comments);
-
-            fputs("typedef ", state->file);
-            if (!write_type(type, WT_PLAIN, FALSE, state->file))
-                return FALSE;
-            fputs(" ", state->file);
-            fputs(IDL_IDENT(IDL_LIST(dcls).data).str, state->file);
-        }
-        fputs(";\n\n", state->file);
-    }
-    return TRUE;
-}
-
-/*
- * param generation:
- * in string foo        -->     nsString *foo
- * out string foo       -->     nsString **foo;
- * inout string foo     -->     nsString **foo;
- */
-
-/* If notype is true, just write the param name. */
-static gboolean
-write_param(IDL_tree param_tree, FILE *outfile)
-{
-    IDL_tree param_type_spec = IDL_PARAM_DCL(param_tree).param_type_spec;
-    write_type_mode mode =
-        (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_IN) ? WT_IN : WT_OUT;
-    IDL_tree sd = IDL_PARAM_DCL(param_tree).simple_declarator;
-    gboolean force_const =
-        (mode == WT_IN && IDL_tree_property_get(sd, "const")) ||
-        (mode == WT_OUT && IDL_tree_property_get(sd, "shared"));
-
-    if (!write_type(param_type_spec, mode, force_const, outfile))
-        return FALSE;
-
-    /* arrays get a bonus * too */
-    /* XXX Should this be a leading '*' or a trailing "[]" ?*/
-    if (IDL_tree_property_get(IDL_PARAM_DCL(param_tree).simple_declarator,
-                              "array"))
-        fputc('*', outfile);
-
-    fputs(IDL_IDENT(IDL_PARAM_DCL(param_tree).simple_declarator).str, outfile);
-
-    if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_OUT) {
-        fputs(" NS_OUTPARAM", outfile);
-    } else if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_INOUT) {
-        fputs(" NS_INOUTPARAM", outfile);
-    }
-
-    return TRUE;
-}
-
-/*
- * A forward declaration, usually an interface.
- */
-static gboolean
-forward_dcl(TreeState *state)
-{
-    IDL_tree iface = state->tree;
-    const char *className = IDL_IDENT(IDL_FORWARD_DCL(iface).ident).str;
-
-    if (!className)
-        return FALSE;
-
-    fprintf(state->file, "class %s; /* forward declaration */\n\n", className);
-    return TRUE;
-}
-
-/*
- * Shared between the interface class declaration and the NS_DECL_IFOO macro
- * provided to aid declaration of implementation classes.  
- * mode...
- *  AS_DECL writes 'NS_IMETHOD foo(string bar, long sil)'
- *  AS_IMPL writes 'NS_IMETHODIMP className::foo(string bar, long sil)'
- *  AS_CALL writes 'foo(bar, sil)'
- */
-static gboolean
-write_method_signature(IDL_tree method_tree, FILE *outfile, int mode,
-                       const char *className)
-{
-    struct _IDL_OP_DCL *op = &IDL_OP_DCL(method_tree);
-    gboolean no_generated_args = TRUE;
-    gboolean op_notxpcom =
-        (IDL_tree_property_get(op->ident, "notxpcom") != NULL);
-    gboolean op_opt_argc =
-        (IDL_tree_property_get(op->ident, "optional_argc") != NULL);
-    gboolean op_context =
-        (IDL_tree_property_get(op->ident, "implicit_jscontext") != NULL);
-    gboolean op_nostdcall =
-        (IDL_tree_property_get(op->ident, "nostdcall") != NULL);
-    const char *name;
-    const char *binaryname;
-    IDL_tree iter;
-
-    if (mode == AS_DECL) {
-        if (IDL_tree_property_get(op->ident, "deprecated"))
-            fputs("MOZ_DEPRECATED ", outfile);
-        if (is_method_scriptable(method_tree, op->ident))
-            fputs("NS_SCRIPTABLE ", outfile);
-
-        if (op_nostdcall) {
-            fputs("virtual ", outfile);
-            if (op_notxpcom) {
-                if (!write_type(op->op_type_spec, WT_PLAIN, FALSE, outfile))
-                    return FALSE;
-            }
-            else {
-                fputs("nsresult", outfile);
-            }
-        }
-        else if (op_notxpcom) {
-            fputs("NS_IMETHOD_(", outfile);
-            if (!write_type(op->op_type_spec, WT_PLAIN, FALSE, outfile))
-                return FALSE;
-            fputc(')', outfile);
-        } else {
-            fputs("NS_IMETHOD", outfile);
-        }
-        fputc(' ', outfile);
-    }
-    else if (mode == AS_IMPL) {
-        if (op_nostdcall) {
-            if (op_notxpcom) {
-                if (!write_type(op->op_type_spec, WT_PLAIN, FALSE, outfile))
-                    return FALSE;
-            }
-            else {
-                fputs("nsresult", outfile);
-            }
-        }
-        else if (op_notxpcom) {
-            fputs("NS_IMETHODIMP_(", outfile);
-            if (!write_type(op->op_type_spec, WT_PLAIN, FALSE, outfile))
-                return FALSE;
-            fputc(')', outfile);
-        } else {
-            fputs("NS_IMETHODIMP", outfile);
-        }
-        fputc(' ', outfile);
-    }
-    name = IDL_IDENT(op->ident).str;
-    if (mode == AS_IMPL) {
-        fprintf(outfile, "%s::", className);
-    }
-    binaryname = IDL_tree_property_get(op->ident, "binaryname");
-    if (binaryname) {
-        fprintf(outfile, "%s(", binaryname);
-    } else {
-        fprintf(outfile, "%c%s(", toupper(*name), name + 1);
-    }
-    for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) {
-        if (mode == AS_DECL || mode == AS_IMPL) {
-            if (!write_param(IDL_LIST(iter).data, outfile))
-                return FALSE;
-        } else {
-            fputs(IDL_IDENT(IDL_PARAM_DCL(IDL_LIST(iter).data)
-                            .simple_declarator).str,
-                  outfile);
-        }
-        if ((IDL_LIST(iter).next ||
-             (!op_notxpcom && op->op_type_spec) || op->f_varargs))
-            fputs(", ", outfile);
-        no_generated_args = FALSE;
-    }
-
-    if (op_context) {
-        if ((op_notxpcom || !op->op_type_spec) && !op->f_varargs)
-            fputs(", ", outfile);
-
-        if (mode == AS_DECL || mode == AS_IMPL)
-            fputs("JSContext *", outfile);
-
-        fputs("cx", outfile);
-
-        if ((!op_notxpcom && op->op_type_spec) || op->f_varargs)
-            fputs(", ", outfile);
-    }
-
-    if (op_opt_argc) {
-        if ((op_notxpcom || !op->op_type_spec) && !op->f_varargs)
-            fputs(", ", outfile);
-
-        if (mode == AS_DECL || mode == AS_IMPL)
-            fputs("PRUint8 ", outfile);
-
-        fputs("_argc", outfile);
-
-        if ((!op_notxpcom && op->op_type_spec) || op->f_varargs)
-            fputs(", ", outfile);
-    }
-
-    /* make IDL return value into trailing out argument */
-    if (op->op_type_spec && !op_notxpcom) {
-        IDL_tree fake_param = IDL_param_dcl_new(IDL_PARAM_OUT,
-                                                op->op_type_spec,
-                                                IDL_ident_new("_retval"));
-        if (!fake_param)
-            return FALSE;
-        if (mode == AS_DECL || mode == AS_IMPL) {
-            if (!write_param(fake_param, outfile))
-                return FALSE;
-        } else {
-            fputs("_retval", outfile);
-        }
-        if (op->f_varargs)
-            fputs(", ", outfile);
-        no_generated_args = FALSE;
-    }
-
-    /* varargs go last */
-    if (op->f_varargs) {
-        if (mode == AS_DECL || mode == AS_IMPL) {
-            fputs("nsVarArgs *", outfile);
-        }
-        fputs("_varargs", outfile);
-        no_generated_args = FALSE;
-    }
-
-    /*
-     * If generated method has no arguments, output 'void' to avoid C legacy
-     * behavior of disabling type checking.
-     */
-    if (no_generated_args && mode == AS_DECL) {
-        fputs("void", outfile);
-    }
-
-    fputc(')', outfile);
-
-    return TRUE;
-}
-
-/*
- * A method is an `operation', therefore a method decl is an `op dcl'.
- * I blame Elliot.
- */
-static gboolean
-op_dcl(TreeState *state)
-{
-    GSList *doc_comments = IDL_IDENT(IDL_OP_DCL(state->tree).ident).comments;
-
-    /*
-     * Verify that e.g. non-scriptable methods in [scriptable] interfaces
-     * are declared so.  Do this in a separate verification pass?
-     */
-    if (!verify_method_declaration(state->tree))
-        return FALSE;
-
-    if (doc_comments != NULL) {
-        write_indent(state->file);
-        printlist(state->file, doc_comments);
-    }
-    xpidl_write_comment(state, 2);
-
-    write_indent(state->file);
-    if (!write_method_signature(state->tree, state->file, AS_DECL, NULL))
-        return FALSE;
-    fputs(" = 0;\n\n", state->file);
-
-    return TRUE;
-}
-
-static void
-write_codefrag_line(gpointer data, gpointer user_data)
-{
-    TreeState *state = (TreeState *)user_data;
-    const char *line = (const char *)data;
-    fputs(line, state->file);
-    fputc('\n', state->file);
-}
-
-static gboolean
-codefrag(TreeState *state)
-{
-    const char *desc = IDL_CODEFRAG(state->tree).desc;
-    GSList *lines = IDL_CODEFRAG(state->tree).lines;
-    guint fragment_length;
-    
-    if (strcmp(desc, "C++") && /* libIDL bug? */ strcmp(desc, "C++\r")) {
-        XPIDL_WARNING((state->tree, IDL_WARNING1,
-                       "ignoring '%%{%s' escape. "
-                       "(Use '%%{C++' to escape verbatim C++ code.)", desc));
-
-        return TRUE;
-    }
-
-    /*
-     * Emit #file directive to point debuggers back to the original .idl file
-     * for the duration of the code fragment.  We look at internal IDL node
-     * properties _file, _line to do this; hopefully they won't change.
-     *
-     * _line seems to refer to the line immediately after the closing %}, so
-     * we backtrack to get the proper line for the beginning of the block.
-     */
-    /*
-     * Looks like getting this right means maintaining an accurate line
-     * count of everything generated, so we can set the file back to the
-     * correct line in the generated file afterwards.  Skipping for now...
-     */
-
-    fragment_length = g_slist_length(lines);
-/*      fprintf(state->file, "#line %d \"%s\"\n", */
-/*              state->tree->_line - fragment_length - 1, */
-/*              state->tree->_file); */
-
-    g_slist_foreach(lines, write_codefrag_line, (gpointer)state);
-
-    return TRUE;
-}
-
-backend *
-xpidl_header_dispatch(void)
-{
-    static backend result;
-    static nodeHandler table[IDLN_LAST];
-    static gboolean initialized = FALSE;
-    
-    result.emit_prolog = header_prolog;
-    result.emit_epilog = header_epilog;
-
-    if (!initialized) {
-        table[IDLN_LIST] = list;
-        table[IDLN_ATTR_DCL] = attr_dcl;
-        table[IDLN_OP_DCL] = op_dcl;
-        table[IDLN_FORWARD_DCL] = forward_dcl;
-        table[IDLN_TYPE_ENUM] = do_enum;
-        table[IDLN_INTERFACE] = interface;
-        table[IDLN_CODEFRAG] = codefrag;
-        table[IDLN_TYPE_DCL] = do_typedef;
-        table[IDLN_CONST_DCL] = do_const_dcl;
-        table[IDLN_NATIVE] = check_native;
-        initialized = TRUE;
-    }
-
-    result.dispatch_table = table;
-    return &result;
-}
deleted file mode 100644
--- a/xpcom/typelib/xpidl/xpidl_idl.c
+++ /dev/null
@@ -1,801 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Michael Ang <mang@subcarrier.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * Common IDL-processing code.
- */
-
-#include "xpidl.h"
-#include <limits.h>
-
-static gboolean parsed_empty_file;
-
-/*
- * The bulk of the generation happens here.
- */
-gboolean
-xpidl_process_node(TreeState *state)
-{
-    gint type;
-    nodeHandler *dispatch, handler;
-
-    XPT_ASSERT(state->tree);
-    type = IDL_NODE_TYPE(state->tree);
-
-    if ((dispatch = state->dispatch) && (handler = dispatch[type]))
-        return handler(state);
-    return TRUE;
-}
-
-static int
-msg_callback(int level, int num, int line, const char *file,
-             const char *message)
-{
-    char *warning_message;
-
-    /*
-     * Egregious hack to permit empty files.
-     * XXX libIDL needs an API to detect this case robustly.
-     */
-    if (0 == strcmp(message, "File empty after optimization")) {
-        parsed_empty_file = TRUE;
-        return 1;
-    }
-
-    if (!file)
-        file = "<unknown file>";
-    warning_message = g_strdup_printf("%s:%d: %s\n", file, line, message);
-
-    fputs(warning_message, stderr);
-
-    g_free(warning_message);
-    return 1;
-}
-
-/*
- * To keep track of the state associated with a given input file.  The 'next'
- * field lets us maintain a stack of input files.
- */
-typedef struct input_data {
-    char *filename;             /* where did I come from? */
-    unsigned int lineno;        /* last lineno processed */
-    char *buf;                  /* contents of file */
-    char *point;                /* next char to feed to libIDL */
-    char *max;                  /* 1 past last char in buf */
-    struct input_data *next;    /* file from which we were included */
-} input_data;
-
-/*
- * Passed to us by libIDL.  Holds global information and the current stack of
- * include files.
- */
-typedef struct input_callback_state {
-    struct input_data *input_stack; /* linked list of input_data */   
-    GHashTable *already_included;   /* to prevent redundant includes */
-    IncludePathEntry *include_path; /* search path for included files */
-    GSList *base_includes;          /* to accumulate #includes from *first* file;
-                                     * for passing thru TreeState to
-                                     * xpidl_header backend. */
-} input_callback_state;
-
-static FILE *
-fopen_from_includes(char **filename, const char *mode,
-                    IncludePathEntry *include_path)
-{
-    IncludePathEntry *current_path = include_path;
-    char *pathname;
-    FILE *inputfile;
-    if (!strcmp(*filename, "-"))
-        return stdin;
-
-    if ((*filename)[0] != '/') {
-        while (current_path) {
-            pathname = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
-                                       current_path->directory, *filename);
-            if (!pathname)
-                return NULL;
-            inputfile = fopen(pathname, mode);
-            if (inputfile) {
-                free(*filename);
-                *filename = xpidl_strdup(pathname);
-                g_free(pathname);
-                return inputfile;
-            }
-            g_free(pathname);
-            current_path = current_path->next;
-        }
-    } else {
-        inputfile = fopen(*filename, mode);
-        if (inputfile)
-            return inputfile;
-    }
-    return NULL;
-}
-
-static input_data *
-new_input_data(char **filename, IncludePathEntry *include_path)
-{
-    input_data *new_data;
-    FILE *inputfile;
-    char *buffer = NULL;
-    size_t offset = 0;
-    size_t buffer_size;
-
-#if defined(XP_OS2) || defined(XP_WIN32)
-    /*
-     * if filename is fully qualified (starts with driver letter), then
-     * just call fopen();  else, go with fopen_from_includes()
-     */
-    if( (*filename)[1] == ':' )
-      inputfile = fopen(*filename, "r");
-    else
-      inputfile = fopen_from_includes(filename, "r", include_path);
-#else
-    inputfile = fopen_from_includes(filename, "r", include_path);
-#endif
-
-    if (!inputfile)
-        return NULL;
-    /*
-     * Rather than try to keep track of many different varieties of state
-     * around the boundaries of a circular buffer, we just read in the entire
-     * file.
-     *
-     * We iteratively grow the buffer here; an alternative would be to use
-     * stat to find the exact buffer size we need, as xpt_dump does.
-     */
-    for (buffer_size = 8191; ; buffer_size *= 2) {
-        size_t just_read;
-        buffer = realloc(buffer, buffer_size + 1); /* +1 for trailing nul */
-        just_read = fread(buffer + offset, 1, buffer_size - offset, inputfile);
-        if (ferror(inputfile))
-            return NULL;
-
-        if (just_read < buffer_size - offset || just_read == 0) {
-            /* Done reading. */
-            offset += just_read;
-            break;
-        }
-        offset += just_read;
-    }
-
-    fclose(inputfile);
-
-    new_data = xpidl_malloc(sizeof (struct input_data));
-    new_data->point = new_data->buf = buffer;
-    new_data->max = buffer + offset;
-    *new_data->max = '\0';
-    new_data->filename = *filename;
-    /* libIDL expects the line number to be that of the *next* line */
-    new_data->lineno = 2;
-    new_data->next = NULL;
-
-    if (deps)
-        fprintf(deps, " \\\n\t%s", *filename);
-
-    return new_data;
-}
-
-/* process pending raw section */
-static int
-NextIsRaw(input_data *data, char **startp, int *lenp)
-{
-    char *end, *start;
-
-    /*
-     * XXXmccabe still needed: an in_raw flag to handle the case where we're in
-     * a raw block, but haven't managed to copy it all to xpidl.  This will
-     * happen when we have a raw block larger than
-     * IDL_input_data->fill.max_size (currently 8192.)
-     */
-    if (!(data->point[0] == '%' && data->point[1] == '{'))
-        return 0;
-        
-    start = *startp = data->point;
-    
-    end = NULL;
-    while (start < data->max && (end = strstr(start, "%}"))) {
-        if (end[-1] == '\r' ||
-            end[-1] == '\n')
-            break;
-        start = end + 1;
-    }
-
-    if (end && start < data->max) {
-        *lenp = end - data->point + 2;
-        return 1;
-    } else {
-        const char *filename;
-        int lineno;
-
-        IDL_file_get(&filename, &lineno);
-        msg_callback(IDL_ERROR, 0, lineno, filename,
-                     "unterminated %{ block");
-        return -1;
-    }
-}
-
-/* process pending comment */
-static int
-NextIsComment(input_data *data, char **startp, int *lenp)
-{
-    char *end;
-
-    if (!(data->point[0] == '/' && data->point[1] == '*'))
-        return 0;
-
-    end = strstr(data->point, "*/");
-    *lenp = 0;
-    if (end) {
-        int skippedLines = 0;
-        char *tempPoint;
-        
-        /* get current lineno */
-        IDL_file_get(NULL,(int *)&data->lineno);
-
-        /* get line count */
-        for (tempPoint = data->point; tempPoint < end; tempPoint++) {
-            if (*tempPoint == '\n')
-                skippedLines++;
-        }
-
-        data->lineno += skippedLines;
-        IDL_file_set(data->filename, (int)data->lineno);
-        
-        *startp = end + 2;
-
-        /* If it's a ** comment, tell libIDL about it. */
-        if (data->point[2] == '*') {
-            /* hack termination.  +2 to get past '*' '/' */
-            char t = *(end + 2);
-            *(end + 2) = '\0';
-            IDL_queue_new_ident_comment(data->point);
-            *(end + 2) = t;
-        }
-
-        data->point = *startp; /* XXXmccabe move this out of function? */
-        return 1;
-    } else {
-        const char *filename;
-        int lineno;
-
-        IDL_file_get(&filename, &lineno);
-        msg_callback(IDL_ERROR, 0, lineno, filename,
-                     "unterminated comment");
-        return -1;
-    }
-}
-
-static int
-NextIsInclude(input_callback_state *callback_state, char **startp,
-              int *lenp)
-{
-    input_data *data = callback_state->input_stack;
-    input_data *new_data;
-    char *filename, *end;
-    const char *scratch;
-
-    /* process the #include that we're in now */
-    if (strncmp(data->point, "#include \"", 10)) {
-        return 0;
-    }
-    
-    filename = data->point + 10; /* skip #include " */
-    XPT_ASSERT(filename < data->max);
-    end = filename;
-    while (end < data->max) {
-        if (*end == '\"' || *end == '\n' || *end == '\r')
-            break;
-        end++;
-    }
-
-    if (*end != '\"') {
-        /*
-         * Didn't find end of include file.  Scan 'til next whitespace to find
-         * some reasonable approximation of the filename, and use it to report
-         * an error.
-         */
-
-        end = filename;
-        while (end < data->max) {
-            if (*end == ' ' || *end == '\n' || *end == '\r' || *end == '\t')
-                break;
-            end++;
-        }
-        *end = '\0';
-        
-        /* make sure we have accurate line info */
-        IDL_file_get(&scratch, (int *)&data->lineno);
-        fprintf(stderr,
-                "%s:%d: didn't find end of quoted include name \"%s\n",
-                scratch, data->lineno, filename);
-        return -1;
-    }
-
-    *end = '\0';
-    *startp = end + 1;
-
-    if (data->next == NULL) {
-        /*
-         * If we're in the initial file, add this filename to the list
-         * of filenames to be turned into #include "filename.h"
-         * directives in xpidl_header.c.  We do it here rather than in the
-         * block below so it still gets added to the list even if it's
-         * already been recursively included from some other file.
-         */
-        char *filename_cp = xpidl_strdup(filename);
-        
-        /* note that g_slist_append accepts and likes null as list-start. */
-        callback_state->base_includes =
-            g_slist_append(callback_state->base_includes, filename_cp);
-    }
-
-    /* store offset for when we pop, or if we skip this one */
-    data->point = *startp;
-
-    if (!g_hash_table_lookup(callback_state->already_included, filename)) {
-        filename = xpidl_strdup(filename);
-        g_hash_table_insert(callback_state->already_included,
-                            filename, (void *)TRUE);
-        filename = xpidl_strdup(filename);
-        new_data = new_input_data(&filename, callback_state->include_path);
-        if (!new_data) {
-            char *error_message;
-            IDL_file_get(&scratch, (int *)&data->lineno);
-            error_message =
-                g_strdup_printf("can't open included file %s for reading\n",
-                                filename);
-            msg_callback(IDL_ERROR, 0,
-                         data->lineno, scratch, error_message);
-            g_free(error_message);
-            free(filename);
-            return -1;
-        }
-
-        new_data->next = data;
-        /* tell libIDL to exclude this IDL from the toplevel tree */
-        IDL_inhibit_push();
-        IDL_file_get(&scratch, (int *)&data->lineno);
-        callback_state->input_stack = new_data;
-        IDL_file_set(new_data->filename, (int)new_data->lineno);
-    }
-
-    *lenp = 0;               /* this is magic, see the comment below */
-    return 1;
-}    
-
-static void
-FindSpecial(input_data *data, char **startp, int *lenp)
-{
-    char *point = data->point;
-
-    /* magic sequences are:
-     * "%{"               raw block
-     * "/\*"              comment
-     * "#include \""      include
-     * The first and last want a newline [\r\n] before, or the start of the
-     * file.
-     */
-
-#define LINE_START(data, point) (point == data->buf ||                       \
-                                 (point > data->point &&                     \
-                                  (point[-1] == '\r' || point[-1] == '\n')))
-                                                 
-    while (point < data->max) {
-        if (point[0] == '/' && point[1] == '*')
-            break;
-        if (LINE_START(data, point)) {
-            if (point[0] == '%' && point[1] == '{')
-                break;
-            if (point[0] == '#' && !strncmp(point + 1, "include \"", 9))
-                break;
-        }
-        point++;
-    }
-
-#undef LINE_START
-
-    *startp = data->point;
-    *lenp = point - data->point;
-}
-
-/* set this with a debugger to see exactly what libIDL sees */
-static FILE *tracefile;
-
-static int
-input_callback(IDL_input_reason reason, union IDL_input_data *cb_data,
-               gpointer user_data)
-{
-    input_callback_state *callback_state = user_data;
-    input_data *data = callback_state->input_stack;
-    input_data *new_data = NULL;
-    unsigned int len, copy;
-    int rv;
-    char *start, *filename;
-
-    switch(reason) {
-      case IDL_INPUT_REASON_INIT:
-        filename = xpidl_strdup(cb_data->init.filename);
-        if (data == NULL || data->next == NULL) {
-            /*
-             * This is the first file being processed.  As it's the target
-             * file, we only look for it in the first entry in the include
-             * path, which we assume to be the current directory.
-             */
-
-            /* XXXmccabe proper assumption?  Do we handle files in other
-               directories? */
-
-            IncludePathEntry first_entry;
-
-            first_entry.directory = callback_state->include_path->directory;
-            first_entry.next = NULL;
-
-            new_data = new_input_data(&filename, &first_entry);
-        } else {
-            new_data = new_input_data(&filename, callback_state->include_path);
-        }
-
-        if (!new_data) {
-            free(filename);
-            return -1;
-        }
-
-        IDL_file_set(new_data->filename, (int)new_data->lineno);
-        callback_state->input_stack = new_data;
-        return 0;
-
-      case IDL_INPUT_REASON_FILL:
-        start = NULL;
-        len = 0;
-
-        while (data->point >= data->max) {
-            if (!data->next)
-                return 0;
-
-            /* Current file is done; revert to including file */
-            callback_state->input_stack = data->next;
-            free(data->filename);
-            free(data->buf);
-            free(data);
-            data = callback_state->input_stack;
-
-            IDL_file_set(data->filename, (int)data->lineno);
-            IDL_inhibit_pop();
-        }
-        
-        /*
-         * Now we scan for sequences which require special attention:
-         *   \n#include                   begins an include statement
-         *   \n%{                         begins a raw-source block
-         *   /\*                          begins a comment
-         * 
-         * We used to be fancier here, so make sure that we sent the most
-         * data possible at any given time.  To that end, we skipped over
-         * \n%{ raw \n%} blocks and then _continued_ the search for special
-         * sequences like \n#include or /\* comments .
-         * 
-         * It was really ugly, though -- liberal use of goto!  lots of implicit
-         * state!  what fun! -- so now we just do this:
-         *
-         * if (special at start) {
-         *     process that special -
-         *         - raw: send it to libIDL, and don't look inside for specials
-         *         - comments: adjust point and start over
-         *         - includes: push new input_data struct for included file, and
-         *           start over
-         * } else {
-         *     scan for next special
-         *     send data up to that special to libIDL
-         * }
-         *
-         * If len is set to zero, it is a sentinel value indicating we a comment
-         * or include was found, and parsing should start over.
-         *
-         * XXX const string foo = "/\*" will just screw us horribly.
-         * Hm but.  We could treat strings as we treat raw blocks, eh?
-         */
-
-        /*
-         * Order is important, so that you can have /\* comments and
-         * #includes within raw sections, and so that you can comment out
-         * #includes.
-         */
-        rv = NextIsRaw(data, &start, (int *)&len);
-        if (rv == -1) return -1;
-        if (!rv) {
-            /*
-             * When NextIsComment succeeds, it returns a 0 len (requesting a
-             * restart) and adjusts data->point to pick up after the comment.
-             */
-            rv = NextIsComment(data, &start, (int *)&len);
-            if (rv == -1) return -1;
-            if (!rv) {
-                /*
-                 * NextIsInclude might push a new input_data struct; if so, it
-                 * will return a 0 len, letting the callback pick up the new
-                 * file the next time around.
-                 */
-                rv = NextIsInclude(callback_state, &start, (int *)&len);
-                if (rv == -1) return -1;
-                if (!rv)
-                    FindSpecial(data, &start, (int *)&len);
-            }
-        }
-
-        if (len == 0) {
-            /*
-             * len == 0 is a sentinel value that means we found a comment or
-             * include.  If we found a comment, point has been adjusted to
-             * point past the comment.  If we found an include, a new input_data
-             * has been pushed.  In both cases, calling the input_callback again
-             * will pick up the new state.
-             */
-            return input_callback(reason, cb_data, user_data);
-        }
-
-        copy = MIN(len, (unsigned int) cb_data->fill.max_size);
-        memcpy(cb_data->fill.buffer, start, copy);
-        data->point = start + copy;
-
-        if (tracefile)
-            fwrite(cb_data->fill.buffer, copy, 1, tracefile);
-
-        return copy;
-
-      case IDL_INPUT_REASON_ABORT:
-      case IDL_INPUT_REASON_FINISH:
-        while (data != NULL) {
-            input_data *next;
-
-            next = data->next;
-            free(data->filename);
-            free(data->buf);
-            free(data);
-            data = next;
-        }
-        return 0;
-
-      default:
-        g_error("unknown input reason %d!", reason);
-        return -1;
-    }
-}
-
-static void
-free_ghash_key(gpointer key, gpointer value, gpointer user_data)
-{
-    /* We're only storing TRUE in the value... */
-    free(key);
-}
-
-static void
-free_gslist_data(gpointer data, gpointer user_data)
-{
-    free(data);
-}
-
-/* Pick up unlink. */
-#ifdef XP_UNIX
-#include <unistd.h>
-#elif XP_WIN
-/* We get it from stdio.h. */
-#define unlink _unlink
-#endif
-
-int
-xpidl_process_idl(char *filename, IncludePathEntry *include_path,
-                  char *file_basename, ModeData *mode)
-{
-    char *tmp, *outname, *real_outname = NULL;
-    IDL_tree top;
-    TreeState state;
-    int rv;
-    input_callback_state callback_state;
-    gboolean ok = TRUE;
-    backend *emitter;
-
-    callback_state.input_stack = NULL;
-    callback_state.base_includes = NULL;
-    callback_state.include_path = include_path;
-    callback_state.already_included = g_hash_table_new(g_str_hash, g_str_equal);
-
-    if (!callback_state.already_included) {
-        fprintf(stderr, "failed to create hashtable.  out of memory?\n");
-        return 0;
-    }
-
-    state.basename = xpidl_strdup(filename);
-
-    /* if basename has an .extension, truncate it. */
-    tmp = strrchr(state.basename, '.');
-    if (tmp)
-        *tmp = '\0';
-
-    if (!file_basename)
-        outname = xpidl_strdup(state.basename);
-    else
-        outname = xpidl_strdup(file_basename);
-
-    /* so we don't include it again! */
-    g_hash_table_insert(callback_state.already_included,
-                        xpidl_strdup(filename), (void *)TRUE);
-
-    parsed_empty_file = FALSE;
-
-    rv = IDL_parse_filename_with_input(filename, input_callback, &callback_state,
-                                       msg_callback, &top,
-                                       &state.ns,
-                                       IDLF_IGNORE_FORWARDS |
-                                       IDLF_XPIDL,
-                                       enable_warnings ? IDL_WARNING1 :
-                                       IDL_ERROR);
-    if (parsed_empty_file) {
-        /*
-         * If we've detected (via hack in msg_callback) that libIDL returned
-         * failure because it found a file with no IDL, set the parse tree to
-         * null and proceed.  Allowing this is useful to permit .idl files that
-         * collect #includes.
-         */
-        top = NULL;
-        state.ns = NULL;
-    } else if (rv != IDL_SUCCESS) {
-        if (rv == -1) {
-            g_warning("Parse of %s failed: %s", filename, g_strerror(errno));
-        } else {
-            g_warning("Parse of %s failed", filename);
-        }
-        return 0;
-    }
-
-    state.basename = xpidl_strdup(filename);
-    tmp = strrchr(state.basename, '.');
-    if (tmp)
-        *tmp = '\0';
-
-    /* so xpidl_header.c can use it to generate a list of #include directives */
-    state.base_includes = callback_state.base_includes;
-
-    emitter = mode->factory();
-    state.dispatch = emitter->dispatch_table;
-
-    if (strcmp(outname, "-")) {
-        const char *fopen_mode;
-        const char *out_basename;
-
-        /* explicit_output_filename can't be true without a filename */
-        if (explicit_output_filename) {
-            real_outname = g_strdup(outname);
-        } else {
-#if defined(XP_UNIX) || defined(XP_WIN) || defined(XP_OS2)
-            if (!file_basename) {
-                out_basename = xpidl_basename(outname);
-            } else {
-                out_basename = outname;
-            }
-#else
-            out_basename = outname;
-#endif
-            real_outname = g_strdup_printf("%s.%s", out_basename, mode->suffix);
-        }
-
-        /* don't create/open file here for Java */
-        if (strcmp(mode->mode, "java") == 0) {
-            state.filename = real_outname;
-        } else {
-            /* Use binary write for typelib mode */
-            fopen_mode = (strcmp(mode->mode, "typelib")) ? "w" : "wb";
-            state.file = fopen(real_outname, fopen_mode);
-            if (!state.file) {
-                perror("error opening output file");
-                return 0;
-            }
-        }
-    } else {
-        state.file = stdout;
-    }
-    state.tree = top;
-
-    if (emitter->emit_prolog)
-        emitter->emit_prolog(&state);
-    if (state.tree) /* Only if we have a tree to process. */
-        ok = xpidl_process_node(&state);
-    if (emitter->emit_epilog)
-        emitter->emit_epilog(&state);
-
-    if (strcmp(mode->mode, "java") != 0) {
-        if (state.file != stdout)
-            fclose(state.file);
-    }
-
-    free(state.basename);
-    free(outname);
-    g_hash_table_foreach(callback_state.already_included, free_ghash_key, NULL);
-    g_hash_table_destroy(callback_state.already_included);
-    g_slist_foreach(callback_state.base_includes, free_gslist_data, NULL);
-
-    if (state.ns)
-        IDL_ns_free(state.ns);
-    if (top)
-        IDL_tree_free(top);
-
-    if (strcmp(mode->mode, "java") != 0) {
-        if (real_outname != NULL) {
-            /*
-             * Delete partial output file on failure.  (Mac does this in the
-             * plugin driver code, if the compiler returns failure.)
-             */
-#if defined(XP_UNIX) || defined(XP_WIN)
-            if (!ok)
-                unlink(real_outname);
-#endif
-            g_free(real_outname);
-        }
-    }
-
-    return ok;
-}
-
-/*
- * Our own version of IDL_tree_warning, which we use when IDL_tree_warning
- * would crash on us.
- */
-void
-xpidl_tree_warning(IDL_tree p, int level, const char *fmt, ...)
-{
-    va_list ap;
-    char *msg, *file;
-    int lineno;
-
-    /* XXX need to check against __IDL_max_msg_level, no accessor */
-    va_start(ap, fmt);
-    msg = g_strdup_vprintf(fmt, ap);
-
-    if (p) {
-        file = p->_file;
-        lineno = p->_line;
-    } else {
-        file = NULL;
-        lineno = 0;
-    }
-
-    /* call our message callback, like IDL_tree_warning would */
-    msg_callback(level, 0, lineno, file, msg);
-    g_free(msg);
-    va_end(ap);
-}
deleted file mode 100644
--- a/xpcom/typelib/xpidl/xpidl_java.c
+++ /dev/null
@@ -1,1188 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Michael Allen (michael.allen@sun.com)
- *   Frank Mitchell (frank.mitchell@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * Generate Java interfaces from XPIDL.
- */
-
-#include "xpidl.h"
-#include <ctype.h>
-#include <glib.h>
-
-#ifdef XP_WIN
-#include <windef.h>
-#define PATH_MAX  MAX_PATH
-#elif defined(XP_OS2) && !defined(PATH_MAX)
-#include <os2.h>
-#define PATH_MAX  CCHMAXPATH
-#endif
-
-/* XXX Bug 331178 - nsIScriptSecurityManager inherits from non-scriptable
- * interface nsIXPCSecurityManager. To work around that, we write out a
- * Java interface for nsIXPCSecurityManager, but don't give it any methods.
- */
-#define CREATE_NSIXPCSECURITYMANAGER
-
-/* XXX Bug 324035 - XPIDL cannot tell whether a forward declared interface is
- * itself defined in an IDL file (in which case XPIDL will have also written
- * out a Java interface file) or if it is just defined in a C header (in which
- * case there will be an error when trying to compile the Java interfaces).
- * This workaround lists the infringing interfaces and writes out "nsISupports"
- * when encountering those types.
- */
-#define HANDLE_NON_IDL_IFACES
-
-/* XXX Bug 340009 - SWT depends on several [noscript] methods in order to
- * embed Mozilla in an SWT view.  This hack makes those methods available
- * to Java embedders.
- */
-#define OUTPUT_SWT_NOSCRIPT_METHODS
-
-/* XXX If an interface method throws an exception, how do we handle it? */
-/*#define HANDLE_EXCEPTIONS*/
-
-
-static char* subscriptIdentifier(TreeState *state, char *str);
-
-static char* javaKeywords[] = {
-  "abstract", "default"  , "if"        , "private"     , "throw"       ,
-  "boolean" , "do"       , "implements", "protected"   , "throws"      ,
-  "break"   , "double"   , "import",     "public"      , "transient"   ,
-  "byte"    , "else"     , "instanceof", "return"      , "try"         ,
-  "case"    , "extends"  , "int"       , "short"       , "void"        ,
-  "catch"   , "final"    , "interface" , "static"      , "volatile"    ,
-  "char"    , "finally"  , "long"      , "super"       , "while"       ,
-  "class"   , "float"    , "native"    , "switch"      ,
-  "const"   , "for"      , "new"       , "synchronized",
-  "continue", "goto"     , "package"   , "this"        ,
-    /* added in Java 1.2 */
-  "strictfp",
-    /* added in Java 1.4 */
-  "assert"  ,
-    /* added in Java 5.0 */
-  "enum"    ,
-    /* Java constants */
-  "true"    , "false"    , "null"      ,
-    /* java.lang.Object methods                                           *
-     *    - don't worry about "toString", since it does the same thing    *
-     *      as Object's "toString"                                        */
-  "clone"   , "equals"   , "finalize"  , "getClass"    , "hashCode"    ,
-  "notify"  , "notifyAll", /*"toString"  ,*/ "wait"
-};
-
-#ifdef HANDLE_NON_IDL_IFACES
-static char* nonIDLIfaces[] = {
-    "nsIPresShell",
-    "nsIDocument",
-    "nsIObjectFrame",
-    "nsObjectFrame",
-    "nsIFrame",
-    "nsIContent",
-    "nsILayoutHistoryState",
-    "nsIMdbEnv",
-    "nsIMdbTable",
-    "nsIMdbRow",
-    "nsIChannelSecurityInfo",
-    "nsIUnicodeDecoder",
-    "nsIUnicodeEncoder",
-    "nsIServiceManagerObsolete",
-    "nsIWordBreaker",
-    "nsISecureEnv",
-    "nsIScrollbarMediator",
-    "nsIScriptContext",
-    "nsIScriptGlobalObject",
-    "nsIScriptElement",
-    "nsIFrameSelection",
-    "nsIWidget",
-    "nsIMenuItem"
-};
-#define NONIDLS(state)      (((struct java_priv_data *)state->priv)->nonIDLIfaces)
-#endif
-
-#define TYPEDEFS(state)     (((struct java_priv_data *)state->priv)->typedefTable)
-#define PRIVDATA(state)     (((struct java_priv_data *)state->priv))
-#define KEYWORDS(state)     (((struct java_priv_data *)state->priv)->keywords)
-
-static void
-write_indent(FILE *outfile) {
-    fputs("  ", outfile);
-}
-
-static GSList*
-add_deprecated(GSList *comments)
-{
-    GSList *last;
-    char *buffer;
-    char *replaced;
-    const char deprecated[] = "* @deprecated */";
-
-    /* Handle the easy case: no documentation. */
-    if (comments == NULL) {
-        buffer = malloc(sizeof(deprecated)+2);
-        buffer[0] = '/';
-        buffer[1] = '*';
-        strcpy(buffer+2, deprecated);
-
-        return g_slist_append(comments, buffer);
-    }
-
-    /* xpidl is so nice in that they give us the data as a single node.
-     * We are going to have to (very hackishly) strip out the the end of the
-     * documentation comment, add the tag, and then pop it back together.
-     */
-
-    /* Step 1: Move the comment into a larger buffer, so that we can have
-     * more space to work with.
-     */
-    last = g_slist_last(comments);
-    buffer = last->data;
-    replaced = (char *)malloc(strlen(buffer) + sizeof(deprecated));
-    strcpy(replaced, buffer);
-    last->data = replaced;
-    free(buffer);
-    
-    /* Now replaced has the comment, with a large enough buffer to put in the
-     * @deprecated tag. We search for the last / in hopes that the previous
-     * character is the * we're looking for...
-     */
-    buffer = strrchr(replaced, '/');
-    if (buffer == NULL || buffer == replaced || buffer[-1] == '*') {
-        /* We can't find a '/', so there's no comment, or this is not the end
-         * of a comment, so we'll ignore adding the deprecated tag.
-         */
-        return comments;
-    }
-    /* buffer now points to '*' '/'. Overwrite both. */
-    strcpy(buffer-1, deprecated);
-    return comments;
-}
-
-static gboolean
-write_classname_iid_define(FILE *file, const char *className)
-{
-    const char *iidName;
-    if (className[0] == 'n' && className[1] == 's') {
-        /* backcompat naming styles */
-        fputs("NS_", file);
-        iidName = className + 2;
-    } else {
-        iidName = className;
-    }
-
-    while (*iidName) {
-        fputc(toupper(*iidName++), file);
-    }
-
-    fputs("_IID", file);
-    return TRUE;
-}
-
-static gboolean
-java_prolog(TreeState *state)
-{
-    int len, i;
-    state->priv = calloc(1, sizeof(struct java_priv_data));
-    if (!state->priv)
-        return FALSE;
-
-    TYPEDEFS(state) = 0;
-    TYPEDEFS(state) = g_hash_table_new(g_str_hash, g_str_equal);
-    if (!TYPEDEFS(state)) {
-        /* XXX report error */
-        free(state->priv);
-        return FALSE;
-    }
-
-    KEYWORDS(state) = 0;
-    KEYWORDS(state) = g_hash_table_new(g_str_hash, g_str_equal);
-    if (!KEYWORDS(state)) {
-        g_hash_table_destroy(TYPEDEFS(state));
-        free(state->priv);
-        return FALSE;
-    }
-    len = sizeof(javaKeywords)/sizeof(*javaKeywords);
-    for (i = 0; i < len; i++) {
-        g_hash_table_insert(KEYWORDS(state),
-                            javaKeywords[i],
-                            javaKeywords[i]);
-    }
-
-#ifdef HANDLE_NON_IDL_IFACES
-    NONIDLS(state) = 0;
-    NONIDLS(state) = g_hash_table_new(g_str_hash, g_str_equal);
-    if (!NONIDLS(state)) {
-        g_hash_table_destroy(TYPEDEFS(state));
-        free(state->priv);
-        return FALSE;
-    }
-    len = sizeof(nonIDLIfaces)/sizeof(*nonIDLIfaces);
-    for (i = 0; i < len; i++) {
-        g_hash_table_insert(NONIDLS(state),
-                            nonIDLIfaces[i],
-                            nonIDLIfaces[i]);
-    }
-#endif
-
-    return TRUE;
-}
-
-static gboolean 
-java_epilog(TreeState *state)
-{
-    /* points to other elements of the tree, so just destroy the table */
-    g_hash_table_destroy(TYPEDEFS(state));
-    g_hash_table_destroy(KEYWORDS(state));
-#ifdef HANDLE_NON_IDL_IFACES
-    g_hash_table_destroy(NONIDLS(state));
-#endif
-
-    free(state->priv);
-    state->priv = NULL;
-    
-    return TRUE;
-}
-
-static gboolean
-forward_declaration(TreeState *state) 
-{
-    /*
-     * Java doesn't need forward declarations unless the declared 
-     * class resides in a different package.
-     */
-#if 0
-    IDL_tree iface = state->tree;
-    const char *className = IDL_IDENT(IDL_FORWARD_DCL(iface).ident).str;
-    const char *pkgName = "org.mozilla.xpcom";
-    if (!className)
-        return FALSE;
-    /* XXX: Get package name and compare */
-    fprintf(state->file, "import %s.%s;\n", pkgName, className);
-#endif
-
-    return TRUE;
-}
-
-
-static gboolean
-interface_declaration(TreeState *state) 
-{
-    char outname[PATH_MAX];
-    char* p;
-    IDL_tree interface = state->tree;
-    IDL_tree iterator = NULL;
-    char *interface_name = 
-      subscriptIdentifier(state, IDL_IDENT(IDL_INTERFACE(interface).ident).str);
-    const char *iid = NULL;
-    char iid_parsed[UUID_LENGTH];
-    GSList *doc_comments = IDL_IDENT(IDL_INTERFACE(interface).ident).comments;
-
-    if (!verify_interface_declaration(interface))
-        return FALSE;
-
-    /*
-     * We only want to output scriptable interfaces
-     */
-    if (!IDL_tree_property_get(IDL_INTERFACE(interface).ident, "scriptable")) {
-        /*
-         * XXX SWT uses non-scriptable interface 'nsIAppShell' (bug 270892), so
-         * include that one.
-         */
-        if (strcmp(interface_name, "nsIAppShell") != 0
-#ifdef CREATE_NSIXPCSECURITYMANAGER
-            && strcmp(interface_name, "nsIXPCSecurityManager") != 0
-#endif
-            )
-            return TRUE;
-    }
-
-    /*
-     * Each Java interface must be in its own file.
-     */
-    p = strrchr(state->filename, '/');
-    if (p) {
-        strncpy(outname, state->filename, p + 1 - state->filename);
-        outname[p + 1 - state->filename] = '\0';
-    }
-    else {
-        outname[0] = '\0';
-    }
-    strcat(outname, interface_name);
-    strcat(outname, ".java");
-
-    state->file = fopen(outname, "w");
-    if (!state->file) {
-        perror("error opening output file");
-        return FALSE;
-    }
-
-    fprintf(state->file, "/*\n * DO NOT EDIT.  THIS FILE IS GENERATED FROM\n"
-            " * %s.idl\n */\n", state->basename);
-
-    /* package name (namespace) */
-    fputs("\npackage org.mozilla.interfaces;\n\n", state->file);
-
-
-    iid = IDL_tree_property_get(IDL_INTERFACE(interface).ident, "uuid");
-    if (iid) {
-        /*
-         * Parse uuid and then output resulting nsID to string, to
-         * validate uuid.
-         */
-        struct nsID id;
-        if (!xpidl_parse_iid(&id, iid)) {
-            IDL_tree_error(state->tree, "cannot parse IID %s\n", iid);
-            return FALSE;
-        }
-        if (!xpidl_sprint_iid(&id, iid_parsed)) {
-            IDL_tree_error(state->tree, "error formatting IID %s\n", iid);
-            return FALSE;
-        }
-    } else {
-        IDL_tree_error(state->tree, "interface %s lacks a uuid attribute\n", 
-                       interface_name);
-        return FALSE;
-    }
-
-    /*
-     * Add deprecated tags if the interface is deprecated
-     */
-    if (IDL_tree_property_get(IDL_INTERFACE(interface).ident, "deprecated")) {
-        doc_comments = add_deprecated(doc_comments);
-    }
-
-    /*
-     * Write any interface comments
-     */
-    if (doc_comments != NULL)
-        printlist(state->file, doc_comments);
-
-    /*
-     * Write "public interface <foo>"
-     */
-    fprintf(state->file, "public interface %s", interface_name);
-
-    /*
-     * Check for inheritence, and iterator over the inherited names,
-     * if any.
-     */
-
-    if ((iterator = IDL_INTERFACE(interface).inheritance_spec)) {
-        fputs(" extends ", state->file);
-
-        do {
-            fprintf(state->file, "%s", 
-                    IDL_IDENT(IDL_LIST(iterator).data).str);
-        
-            if (IDL_LIST(iterator).next) {
-                fputs(", ", state->file);
-            }
-        } while ((iterator = IDL_LIST(iterator).next));
-    }
-
-    fputs(" {\n\n", state->file);
-
-    /*
-     * Write interface constants for IID
-     */
-    if (iid) {
-        /* String NS_ISUPPORTS_IID = "{00000000-0000-0000-c000-000000000046}";*/
-        write_indent(state->file);
-        fputs("String ", state->file);
-        write_classname_iid_define(state->file, interface_name);
-        fputs(" =\n", state->file);
-        write_indent(state->file);
-        write_indent(state->file);
-        fprintf(state->file, "\"{%s}\";\n\n", iid_parsed);
-    }
-
-    /*
-     * Advance the state of the tree, go on to process more
-     */
-    
-    state->tree = IDL_INTERFACE(interface).body;
-
-    if (state->tree && !xpidl_process_node(state)) {
-        return FALSE;
-    }
-
-
-    fputs("}", state->file);
-
-    fclose(state->file);
-
-    return TRUE;
-}
-
-static gboolean
-process_list(TreeState *state)
-{
-    IDL_tree iter;
-    for (iter = state->tree; iter; iter = IDL_LIST(iter).next) {
-        state->tree = IDL_LIST(iter).data;
-        if (!xpidl_process_node(state))
-            return FALSE;
-    }
-    return TRUE;
-}
-
-static gboolean 
-xpcom_to_java_type(TreeState *state, IDL_tree param) 
-{
-    IDL_tree real_type, type;
-    IDL_tree up;
-
-    if (!state->tree) {
-        fputs("Object", state->file);
-        return TRUE;
-    }
-
-    /* Could be a typedef; try to map it to the real type */
-    real_type = find_underlying_type(state->tree);
-    type = real_type ? real_type : state->tree;
-
-    switch(IDL_NODE_TYPE(type)) {
-
-    case IDLN_TYPE_INTEGER: {
-
-        switch(IDL_TYPE_INTEGER(type).f_type) {
-
-        case IDL_INTEGER_TYPE_SHORT:
-            if (IDL_TYPE_INTEGER(type).f_signed)
-                fputs("short", state->file);
-            else
-                fputs("int", state->file);
-            break;
-
-        case IDL_INTEGER_TYPE_LONG:
-            if (IDL_TYPE_INTEGER(type).f_signed)
-                fputs("int", state->file);
-            else
-                fputs("long", state->file);
-            break;
-
-        case IDL_INTEGER_TYPE_LONGLONG:
-            if (IDL_TYPE_INTEGER(type).f_signed)
-                fputs("long", state->file);
-            else
-                fputs("double", state->file);
-            break;
-        
-        default:
-            g_error("   Unknown integer type: %d\n",
-                    IDL_TYPE_INTEGER(type).f_type);
-            return FALSE;
-
-        }
-
-        break;
-    }
-
-    case IDLN_TYPE_CHAR:
-    case IDLN_TYPE_WIDE_CHAR:
-        fputs("char", state->file);
-        break;
-
-    case IDLN_TYPE_WIDE_STRING:
-    case IDLN_TYPE_STRING:
-        fputs("String", state->file);
-        break;
-
-    case IDLN_TYPE_BOOLEAN:
-        fputs("boolean", state->file);
-        break;
-
-    case IDLN_TYPE_OCTET:
-        if (param && IDL_tree_property_get(IDL_PARAM_DCL(param).simple_declarator, "array"))
-            fputs("byte", state->file);
-        else
-            fputs("short", state->file);
-        break;
-
-    case IDLN_TYPE_FLOAT:
-        switch(IDL_TYPE_FLOAT(type).f_type) {
-
-        case IDL_FLOAT_TYPE_FLOAT:
-            fputs("float", state->file);
-            break;
-
-        case IDL_FLOAT_TYPE_DOUBLE:
-            fputs("double", state->file);
-            break;
-        
-        default:
-            g_error("    Unknown floating point typ: %d\n",
-                    IDL_NODE_TYPE(type));
-            break;
-        }
-        break;
-
-
-    case IDLN_IDENT:
-      if (!(up = IDL_NODE_UP(type))) {
-          IDL_tree_error(state->tree,
-                         "ERROR: orphan ident %s in param list\n",
-                         IDL_IDENT(state->tree).str);
-          return FALSE;
-      }
-      switch (IDL_NODE_TYPE(up)) {
-        case IDLN_FORWARD_DCL:
-        case IDLN_INTERFACE: {
-          char *className;
-          const char *iid_is;
-handle_iid_is:
-          /* might get here via the goto, so re-check type */
-          if (IDL_NODE_TYPE(up) == IDLN_INTERFACE)
-              className = IDL_IDENT(IDL_INTERFACE(up).ident).str;
-          else if (IDL_NODE_TYPE(up) == IDLN_FORWARD_DCL)
-              className = IDL_IDENT(IDL_FORWARD_DCL(up).ident).str;
-          else
-              className = IDL_IDENT(IDL_NATIVE(up).ident).str;
-
-          iid_is = NULL;
-          if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) {
-              IDL_tree simple = IDL_PARAM_DCL(state->tree).simple_declarator;
-              iid_is = IDL_tree_property_get(simple, "iid_is");
-          }
-
-          if (iid_is) {
-              fputs("nsISupports", state->file);
-          } else {
-              /*
-               * In JavaXPCOM, we handle weak references internally; no need
-               * for the |nsIWeakReference| interface.  So just return
-               * |nsISupports|.
-               */
-              if (strcmp(className, "nsIWeakReference") == 0) {
-                  fputs("nsISupports", state->file);
-              } else {
-#ifdef HANDLE_NON_IDL_IFACES
-                  char *nonidl = g_hash_table_lookup(NONIDLS(state), className);
-                  if (nonidl) {
-                      fputs("nsISupports", state->file);
-                  } else
-#endif
-                  {
-                      fprintf(state->file, "%s", className);
-                  }
-              }
-          }
-          break;
-        }
-        case IDLN_NATIVE: {
-            char *ident;
-
-            /* jband - adding goto for iid_is when type is native */
-            if (param) {
-                if (IDL_NODE_TYPE(param) == IDLN_PARAM_DCL &&
-                    IDL_tree_property_get(IDL_PARAM_DCL(param).simple_declarator,
-                                          "iid_is"))
-                {
-                    state->tree = param;
-                    goto handle_iid_is;
-                }
-            }
-
-            ident = IDL_IDENT(type).str;
-            if (IDL_tree_property_get(type, "nsid")) {
-                fputs("String", state->file);
-            } else if (IDL_tree_property_get(type, "domstring")) {
-                fputs("String", state->file);
-            } else if (IDL_tree_property_get(type, "astring")) {
-                fputs("String", state->file);
-            } else if (IDL_tree_property_get(type, "utf8string")) {
-                fputs("String", state->file);
-            } else if (IDL_tree_property_get(type, "cstring")) {
-                fputs("String", state->file);
-            } else {
-                const char* user_type = IDL_NATIVE(IDL_NODE_UP(type)).user_type;
-                IDL_tree real_type = 
-                    g_hash_table_lookup(TYPEDEFS(state), user_type);
-
-                if (real_type) {
-                    gboolean rc;
-                    IDL_tree orig_tree = state->tree;
-
-                    state->tree = real_type;
-                    rc = xpcom_to_java_type(state, param);
-
-                    state->tree = orig_tree;
-                    return rc;
-                } else {
-                    if (strcmp(user_type, "PRInt8") == 0) {
-                        fputs("byte", state->file);
-                    } else if (strcmp(user_type, "PRInt16") == 0 ||
-                               strcmp(user_type, "PRUint8") == 0) {
-                        fputs("short", state->file);
-                    } else if (strcmp(user_type, "PRInt32") == 0 ||
-                               strcmp(user_type, "int") == 0 ||
-                               strcmp(user_type, "PRUint16") == 0) {
-                        fputs("int", state->file);
-                    } else if (strcmp(user_type, "PRInt64") == 0 ||
-                               strcmp(user_type, "PRUint32") == 0) {
-                        fputs("long", state->file);
-                    } else if (strcmp(user_type, "PRUint64") == 0) {
-                        fputs("double", state->file);
-                    } else if (strcmp(user_type, "PRBool") == 0) {
-                        fputs("boolean", state->file);
-                    } else if (strcmp(user_type, "char") == 0 ||
-                               strcmp(user_type, "const char") == 0 ||
-                               strcmp(user_type, "unsigned char") == 0) {
-                        if (IDL_tree_property_get(type, "ptr")) {
-                            fputs("byte[]", state->file);
-                        } else {
-                            fputs("char", state->file);
-                        }
-                    } else if (strcmp(user_type, "nsIID") == 0) {
-                        fputs("String", state->file);
-                    } else if (strcmp(user_type, "nsString") == 0 ||
-                               strcmp(user_type, "nsAString") == 0 ||
-                               strcmp(user_type, "nsACString") == 0) {
-                        fputs("String", state->file);
-                    } else {
-                        fputs("long", state->file);
-                    }
-                }
-            }
-            break;
-          }
-        default:
-          if (IDL_NODE_TYPE(IDL_NODE_UP(up)) == IDLN_TYPE_DCL) {
-              /* restart with the underlying type */
-              gboolean rc;
-              IDL_tree orig_tree = state->tree;
-              state->tree = IDL_TYPE_DCL(IDL_NODE_UP(up)).type_spec;
-              rc = xpcom_to_java_type(state, param);
-              state->tree = orig_tree;
-              return rc;
-          }
-          IDL_tree_error(state->tree,
-                         "can't handle %s ident in param list\n",
-                         "that type of"
-                         );
-          return FALSE;
-      }
-      break;
-
-    default:
-      IDL_tree_error(state->tree, "can't handle %s in param list\n",
-#ifdef DEBUG_shaver
-                     /* XXX is this safe to use on Win now? */
-                     IDL_NODE_TYPE_NAME(IDL_NODE_UP(type))
-#else
-                  "that type"
-#endif
-      );
-      return FALSE;
-    }
-
-    return TRUE;
-
-}
-
-static gboolean
-xpcom_to_java_param(TreeState *state)
-{
-    IDL_tree param = state->tree;
-    state->tree = IDL_PARAM_DCL(param).param_type_spec;
-
-    /*
-     * Put in type of parameter
-     */
-
-    if (!xpcom_to_java_type(state, param)) {
-        return FALSE;
-    }
-
-    /*
-     * If the parameter is out or inout, make it a Java array of the
-     * appropriate type
-     */
-
-    if (IDL_PARAM_DCL(param).attr != IDL_PARAM_IN) {
-        fputs("[]", state->file);
-    }
-
-    /*
-     * If the parameter is an array make it a Java array
-     */
-    if (IDL_tree_property_get(IDL_PARAM_DCL(param).simple_declarator, "array"))
-        fputs("[]", state->file);
-
-    /*
-     * Put in name of parameter 
-     */
-    fputc(' ', state->file);
-    fputs(subscriptIdentifier(state, 
-                        IDL_IDENT(IDL_PARAM_DCL(param).simple_declarator).str), 
-          state->file);
-
-    return TRUE;
-}
-
-
-static gboolean
-type_declaration(TreeState *state) 
-{
-    /*
-     * Unlike C, Java has no type declaration directive.
-     * Instead, we record the mapping, and look up the actual type
-     * when needed.
-     */
-    IDL_tree type = IDL_TYPE_DCL(state->tree).type_spec;
-    IDL_tree dcls = IDL_TYPE_DCL(state->tree).dcls;
-
-    /* XXX: check for illegal types */
-
-    g_hash_table_insert(TYPEDEFS(state),
-                        IDL_IDENT(IDL_LIST(dcls).data).str,
-                        type);
-
-    return TRUE;
-}
-
-#ifdef OUTPUT_SWT_NOSCRIPT_METHODS
-static gboolean
-print_noscript_method(TreeState *state)
-{
-    IDL_tree iface = IDL_NODE_UP(IDL_NODE_UP(state->tree));
-    char *className = IDL_IDENT(IDL_INTERFACE(iface).ident).str;
-    if (strcmp(className, "nsIBaseWindow") == 0 ||
-        strcmp(className, "nsIEmbeddingSiteWindow") == 0)
-        return TRUE;
-    return FALSE;
-}
-#endif
-
-static gboolean
-method_declaration(TreeState *state) 
-{
-    const char* array = NULL;
-    struct _IDL_OP_DCL *method = &IDL_OP_DCL(state->tree);
-    gboolean method_notxpcom = 
-        (IDL_tree_property_get(method->ident, "notxpcom") != NULL);
-    gboolean method_noscript = 
-        (IDL_tree_property_get(method->ident, "noscript") != NULL);
-    IDL_tree iterator = NULL;
-    IDL_tree retval_param = NULL;
-    char *method_name =
-                  g_strdup_printf("%c%s",
-                                  tolower(IDL_IDENT(method->ident).str[0]),
-                                  IDL_IDENT(method->ident).str + 1);
-    GSList *doc_comments = IDL_IDENT(method->ident).comments;
-
-    if (!verify_method_declaration(state->tree))
-        return FALSE;
-
-#ifdef OUTPUT_SWT_NOSCRIPT_METHODS
-    if (method_notxpcom)
-        return TRUE;
-    if (method_noscript && !print_noscript_method(state))
-        return TRUE;
-#else
-    /* do not write nonscriptable methods */
-    if (method_notxpcom || method_noscript) {
-        return TRUE;
-    }
-#endif
-
-#ifdef CREATE_NSIXPCSECURITYMANAGER
-    /* Since this interface is non-scriptable, we treat all of its methods
-     * as if they were [noscript] */
-    {
-        IDL_tree iface = IDL_NODE_UP(IDL_NODE_UP(state->tree));
-        char *className = IDL_IDENT(IDL_INTERFACE(iface).ident).str;
-        if (strcmp(className, "nsIXPCSecurityManager") == 0)
-            return TRUE;
-    }
-#endif
-
-    /*
-     * Add deprecated tags if the interface is deprecated
-     */
-    if (IDL_tree_property_get(method->ident, "deprecated")) {
-        doc_comments = add_deprecated(doc_comments);
-    }
-
-    if (doc_comments != NULL) {
-        write_indent(state->file);
-        printlist(state->file, doc_comments);
-    }
-
-    /*
-     * Write return type
-     * Unlike C++ headers, Java interfaces return the declared 
-     * return value; an exception indicates XPCOM method failure.
-     */
-    write_indent(state->file);
-    if (method->op_type_spec) {
-        state->tree = method->op_type_spec;
-        if (!xpcom_to_java_type(state, NULL)) {
-            return FALSE;
-        }
-    } else {
-        /* Check for retval attribute */
-        for (iterator = method->parameter_dcls; iterator != NULL; 
-             iterator = IDL_LIST(iterator).next) {
-
-            IDL_tree original_tree = state->tree;
-            IDL_tree simple_decl;
-
-            state->tree = IDL_LIST(iterator).data;
-            simple_decl = IDL_PARAM_DCL(state->tree).simple_declarator;
-
-            if (IDL_tree_property_get(simple_decl, "retval")) {
-                IDL_tree param;
-
-                retval_param = iterator;
-                array = IDL_tree_property_get(simple_decl, "array");
-
-                /*
-                 * Put in type of parameter
-                 */
-                param = state->tree;
-                state->tree = IDL_PARAM_DCL(state->tree).param_type_spec;
-                if (!xpcom_to_java_type(state, param)) {
-                    return FALSE;
-                }
-
-                if (array) {
-                    fputs("[]", state->file);
-                }
-            }
-
-            state->tree = original_tree;
-        }
-
-        if (retval_param == NULL) {
-            fputs("void", state->file);
-        }
-    }
- 
-    /*
-     * Write method name
-     */
-    fprintf(state->file, " %s(", subscriptIdentifier(state, method_name));
-
-    /*
-     * Write parameters
-     */
-    for (iterator = method->parameter_dcls; iterator != NULL; 
-         iterator = IDL_LIST(iterator).next) {
-
-        /* Skip "retval" */
-        if (iterator == retval_param) {
-            continue;
-        }
-
-        if (iterator != method->parameter_dcls) {
-            fputs(", ", state->file);
-        }
-        
-        state->tree = IDL_LIST(iterator).data;
-
-        if (!xpcom_to_java_param(state)) {
-            return FALSE;
-        }
-    }
-
-    fputs(")", state->file);
-
-#ifdef HANDLE_EXCEPTIONS
-    if (method->raises_expr) {
-        IDL_tree iter = method->raises_expr;
-        IDL_tree dataNode = IDL_LIST(iter).data;
-
-        fputs(" throws ", state->file);
-        fputs(IDL_IDENT(dataNode).str, state->file);
-        iter = IDL_LIST(iter).next;
-
-        while (iter) {
-            dataNode = IDL_LIST(iter).data;
-            fprintf(state->file, ", %s", IDL_IDENT(dataNode).str);
-            iter = IDL_LIST(iter).next;
-        }
-    }
-#endif
-
-    fputs(";\n\n", state->file);
-
-    return TRUE;
-}
-
-
-static gboolean
-constant_declaration(TreeState *state)
-{
-    struct _IDL_CONST_DCL *declaration = &IDL_CONST_DCL(state->tree);
-    const char *name = IDL_IDENT(declaration->ident).str;
-    GSList *doc_comments = IDL_IDENT(declaration->ident).comments;
-    IDL_tree real_type;
-
-    const char* format;
-    const char* type_str;
-    gboolean is_long;
-
-    gboolean success;
-
-    if (!verify_const_declaration(state->tree))
-        return FALSE;
-
-    /* Could be a typedef; try to map it to the real type. */
-    real_type = find_underlying_type(declaration->const_type);
-    real_type = real_type ? real_type : declaration->const_type;
-
-    /* Consts must be in an interface */
-    if (!IDL_NODE_UP(IDL_NODE_UP(state->tree)) ||
-        IDL_NODE_TYPE(IDL_NODE_UP(IDL_NODE_UP(state->tree))) != 
-        IDLN_INTERFACE) {
-
-        XPIDL_WARNING((state->tree, IDL_WARNING1,
-                       "A constant \"%s\" was declared outside an interface."
-                       "  It was ignored.", name));
-
-        return TRUE;
-    }
-
-    /*
-     * The C++ header XPIDL module only allows for shorts and longs (ints)
-     * to be constants, so we will follow the same convention
-     */
-
-    is_long = FALSE;
-
-    success = (IDLN_TYPE_INTEGER == IDL_NODE_TYPE(real_type));
-
-    if (success) {
-        gboolean is_signed = IDL_TYPE_INTEGER(real_type).f_signed;
-        format = is_signed ? "%" IDL_LL "d" : "%" IDL_LL "u";
-
-        switch(IDL_TYPE_INTEGER(real_type).f_type) {
-            case IDL_INTEGER_TYPE_SHORT:
-                if (is_signed)
-                    type_str = "short";
-                else
-                    type_str = "int";
-                break;
-
-            case IDL_INTEGER_TYPE_LONG:
-                if (is_signed) {
-                    type_str = "int";
-                } else {
-                    type_str = "long";
-                    is_long = TRUE;
-                }
-                break;
-            
-            default:
-                /* Whoops, it's some other kind of number */
-                success = FALSE;
-                break;
-        }
-    } else {
-        IDL_tree_error(state->tree,
-                       "const declaration \'%s\' must be of type short or long",
-                       name);
-        return FALSE;
-    }
-
-    if (!success) {
-        XPIDL_WARNING((state->tree, IDL_WARNING1,
-                       "A constant \"%s\" was not of type short or long."
-                       "  It was ignored.", name));
-        return FALSE;
-    }
-
-    if (doc_comments != NULL) {
-        write_indent(state->file);
-        printlist(state->file, doc_comments);
-    }
-
-    write_indent(state->file);
-    fprintf(state->file, "%s %s = ", type_str,
-            subscriptIdentifier(state, (char*) name));
-    fprintf(state->file, format, IDL_INTEGER(declaration->const_exp).value);
-    fprintf(state->file, "%s;\n\n", is_long ? "L" : "");
-
-    return TRUE;
-
-}
-
-#define ATTR_IDENT(tree) (IDL_IDENT(IDL_LIST(IDL_ATTR_DCL((tree)).simple_declarations).data))
-#define ATTR_PROPS(tree) (IDL_LIST(IDL_ATTR_DCL((tree)).simple_declarations).data)
-#define ATTR_TYPE_DECL(tree) (IDL_ATTR_DCL((tree)).param_type_spec)
-
-
-static gboolean
-attribute_declaration(TreeState *state)
-{
-    char *attribute_name;
-    GSList *doc_comments;
-    gboolean read_only;
-
-    if (!verify_attribute_declaration(state->tree))
-        return FALSE;
-
-    attribute_name = ATTR_IDENT(state->tree).str;
-    read_only = IDL_ATTR_DCL(state->tree).f_readonly;
-
-#ifdef OUTPUT_SWT_NOSCRIPT_METHODS
-    if (IDL_tree_property_get(ATTR_PROPS(state->tree), "notxpcom"))
-        return TRUE;
-    if (IDL_tree_property_get(ATTR_PROPS(state->tree), "noscript") &&
-        !print_noscript_method(state))
-        return TRUE;
-#else
-    if (IDL_tree_property_get(ATTR_PROPS(state->tree), "notxpcom") ||
-        IDL_tree_property_get(ATTR_PROPS(state->tree), "noscript"))
-        return TRUE;
-#endif
-
-    doc_comments =
-        IDL_IDENT(IDL_LIST(IDL_ATTR_DCL
-                           (state->tree).simple_declarations).data).comments;
-
-    /*
-     * Add deprecated tags if the interface is deprecated
-     */
-    if (IDL_tree_property_get(ATTR_PROPS(state->tree), "deprecated")) {
-        doc_comments = add_deprecated(doc_comments);
-    }
-
-    if (doc_comments != NULL) {
-        write_indent(state->file);
-        printlist(state->file, doc_comments);
-    }
-
-    /*
-     * Write the proper Java return value for the get operation
-     */
-    write_indent(state->file);
-    state->tree = ATTR_TYPE_DECL(state->tree);
-    if (!xpcom_to_java_type(state, NULL)) {
-        return FALSE;
-    }
-    
-    /*
-     * Write the name of the accessor ("get") method.
-     */
-    fprintf(state->file, " get%c%s();\n\n",
-            toupper(attribute_name[0]), attribute_name + 1);
-
-    if (!read_only) {
-        if (doc_comments != NULL) {
-            write_indent(state->file);
-            printlist(state->file, doc_comments);
-        }
-
-        /*
-         * Write attribute access method name and return type
-         */
-        write_indent(state->file);
-        fprintf(state->file, "void set%c%s(",
-                toupper(attribute_name[0]), 
-                attribute_name+1);
-        
-        /*
-         * Write the proper Java type for the set operation
-         */
-        if (!xpcom_to_java_type(state, NULL)) {
-            return FALSE;
-        }
-
-        /*
-         * Write the name of the formal parameter.
-         */
-        fprintf(state->file, " a%c%s);\n\n", toupper(attribute_name[0]),
-                attribute_name + 1);
-    }
-
-    return TRUE;
-}
-
-
-static gboolean
-enum_declaration(TreeState *state)
-{
-    XPIDL_WARNING((state->tree, IDL_WARNING1,
-                   "enums not supported, enum \'%s\' ignored",
-                   IDL_IDENT(IDL_TYPE_ENUM(state->tree).ident).str));
-    return TRUE;
-}
-
-backend *
-xpidl_java_dispatch(void)
-{
-    static backend result;
-    static nodeHandler table[IDLN_LAST];
-    static gboolean initialized = FALSE;
-
-    result.emit_prolog = java_prolog;
-    result.emit_epilog = java_epilog;
-
-    if (!initialized) {
-        table[IDLN_INTERFACE] = interface_declaration;
-        table[IDLN_LIST] = process_list;
-
-        table[IDLN_OP_DCL] = method_declaration;
-        table[IDLN_ATTR_DCL] = attribute_declaration;
-        table[IDLN_CONST_DCL] = constant_declaration;
-
-        table[IDLN_TYPE_DCL] = type_declaration;
-        table[IDLN_FORWARD_DCL] = forward_declaration;
-
-        table[IDLN_TYPE_ENUM] = enum_declaration;
-
-        initialized = TRUE;
-    }
-
-    result.dispatch_table = table;
-    return &result;
-}
-
-char* subscriptIdentifier(TreeState *state, char *str)
-{
-    char *sstr = NULL;
-    char *keyword = g_hash_table_lookup(KEYWORDS(state), str);
-    if (keyword) {
-        sstr = g_strdup_printf("_%s", keyword);
-        return sstr;
-    }
-    return str;
-}
-
deleted file mode 100644
--- a/xpcom/typelib/xpidl/xpidl_typelib.c
+++ /dev/null
@@ -1,1257 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * Generate typelib files for use with InterfaceInfo.
- * http://www.mozilla.org/scriptable/typelib_file.html
- */
-
-#include "xpidl.h"
-#include <xpt_xdr.h>
-#include <xpt_struct.h>
-#include <time.h>               /* XXX XP? */
-
-struct priv_data {
-    XPTHeader *header;
-    uint16 ifaces;
-    GHashTable *interface_map;
-    XPTInterfaceDescriptor *current;
-    XPTArena *arena;
-    uint16 next_method;
-    uint16 next_const;
-    uint16 next_type;   /* used for 'additional_types' for idl arrays */
-};
-
-#define HEADER(state)     (((struct priv_data *)state->priv)->header)
-#define IFACES(state)     (((struct priv_data *)state->priv)->ifaces)
-#define IFACE_MAP(state)  (((struct priv_data *)state->priv)->interface_map)
-#define CURRENT(state)    (((struct priv_data *)state->priv)->current)
-#define ARENA(state)      (((struct priv_data *)state->priv)->arena)
-#define NEXT_METH(state)  (((struct priv_data *)state->priv)->next_method)
-#define NEXT_CONST(state) (((struct priv_data *)state->priv)->next_const)
-#define NEXT_TYPE(state)  (((struct priv_data *)state->priv)->next_type)
-
-#ifdef DEBUG_shaver
-/* #define DEBUG_shaver_sort */
-#endif
-
-typedef struct {
-    char     *full_name;
-    char     *name;
-    char     *name_space;
-    char     *iid;
-    gboolean is_forward_dcl;
-} NewInterfaceHolder;
-
-static NewInterfaceHolder*
-CreateNewInterfaceHolder(char *name, char *name_space, char *iid, 
-                         gboolean is_forward_dcl)
-{
-    NewInterfaceHolder *holder = calloc(1, sizeof(NewInterfaceHolder));
-    if (holder) {
-        holder->is_forward_dcl = is_forward_dcl;
-        if (name)
-            holder->name = xpidl_strdup(name);
-        if (name_space)
-            holder->name_space = xpidl_strdup(name_space);
-        if (holder->name && holder->name_space) {
-            holder->full_name = calloc(1, strlen(holder->name) +
-                                          strlen(holder->name_space) + 2);
-        }
-        if (holder->full_name) {
-            strcpy(holder->full_name, holder->name_space);
-            strcat(holder->full_name, ".");
-            strcat(holder->full_name, holder->name);
-        }
-        else
-            holder->full_name = holder->name;
-        if (iid)
-            holder->iid = xpidl_strdup(iid);
-    }
-    return holder;
-}
-
-static void
-DeleteNewInterfaceHolder(NewInterfaceHolder *holder)
-{
-    if (holder) {
-        if (holder->full_name && holder->full_name != holder->name)
-            free(holder->full_name);
-        if (holder->name)
-            free(holder->name);
-        if (holder->name_space)
-            free(holder->name_space);
-        if (holder->iid)
-            free(holder->iid);
-        free(holder);
-    }
-}
-
-/*
- * If p is an ident for an interface, and we don't have an entry in the
- * interface map yet, add one.
- */
-static gboolean
-add_interface_maybe(IDL_tree_func_data *tfd, gpointer user_data)
-{
-    TreeState *state = user_data;
-    IDL_tree up;
-    if (IDL_NODE_TYPE(tfd->tree) == IDLN_IDENT) {
-        IDL_tree_type node_type = IDL_NODE_TYPE((up = IDL_NODE_UP(tfd->tree)));
-        if (node_type == IDLN_INTERFACE || node_type == IDLN_FORWARD_DCL) {
-
-            /* We only want to add a new entry if there is no entry by this 
-             * name or if the previously found entry was just a forward 
-             * declaration and the new entry is not.
-             */
-
-            char *iface = IDL_IDENT(tfd->tree).str;
-            NewInterfaceHolder *old_holder = (NewInterfaceHolder *) 
-                    g_hash_table_lookup(IFACE_MAP(state), iface);
-            if (old_holder && old_holder->is_forward_dcl &&
-                node_type != IDLN_FORWARD_DCL)
-            {
-                g_hash_table_remove(IFACE_MAP(state), iface);
-                DeleteNewInterfaceHolder(old_holder);
-                old_holder = NULL;
-            }
-            if (!old_holder) {
-                /* XXX should we parse here and store a struct nsID *? */
-                char *iid = (char *)IDL_tree_property_get(tfd->tree, "uuid");
-                char *name_space = (char *)
-                            IDL_tree_property_get(tfd->tree, "namespace");
-                NewInterfaceHolder *holder =
-                        CreateNewInterfaceHolder(iface, name_space, iid,
-                                     (gboolean) node_type == IDLN_FORWARD_DCL);
-                if (!holder)
-                    return FALSE;
-                g_hash_table_insert(IFACE_MAP(state),
-                                    holder->full_name, holder);
-                IFACES(state)++;
-#ifdef DEBUG_shaver_ifaces
-                fprintf(stderr, "adding interface #%d: %s/%s\n", IFACES(state),
-                        iface, iid[0] ? iid : "<unresolved>");
-#endif
-            }
-        } else {
-#ifdef DEBUG_shaver_ifaces
-            fprintf(stderr, "ident %s isn't an interface (%s)\n",
-                    IDL_IDENT(tfd->tree).str, IDL_NODE_TYPE_NAME(up));
-#endif
-        }
-    }
-
-    return TRUE;
-}
-
-/* Find all the interfaces referenced in the tree (uses add_interface_maybe) */
-static gboolean
-find_interfaces(IDL_tree_func_data *tfd, gpointer user_data)
-{
-    IDL_tree node = NULL;
-
-    switch (IDL_NODE_TYPE(tfd->tree)) {
-      case IDLN_ATTR_DCL:
-        node = IDL_ATTR_DCL(tfd->tree).param_type_spec;
-        break;
-      case IDLN_OP_DCL:
-         IDL_tree_walk_in_order(IDL_OP_DCL(tfd->tree).parameter_dcls, find_interfaces,
-                               user_data);
-        node = IDL_OP_DCL(tfd->tree).op_type_spec;
-        break;
-      case IDLN_PARAM_DCL:
-        node = IDL_PARAM_DCL(tfd->tree).param_type_spec;
-        break;
-      case IDLN_INTERFACE:
-        node = IDL_INTERFACE(tfd->tree).inheritance_spec;
-        if (node)
-            xpidl_list_foreach(node, add_interface_maybe, user_data);
-        node = IDL_INTERFACE(tfd->tree).ident;
-        break;
-      case IDLN_FORWARD_DCL:
-        node = IDL_FORWARD_DCL(tfd->tree).ident;
-        break;
-      default:
-        node = NULL;
-    }
-
-    if (node && IDL_NODE_TYPE(node) == IDLN_IDENT) {
-        IDL_tree_func_data new_tfd;
-        new_tfd.tree = node;
-        add_interface_maybe(&new_tfd, user_data);
-    }
-
-    return TRUE;
-}
-
-#ifdef DEBUG_shaver
-/* for calling from gdb */
-static void
-print_IID(struct nsID *iid, FILE *file)
-{
-    char iid_buf[UUID_LENGTH];
-
-    xpidl_sprint_iid(iid, iid_buf);
-    fprintf(file, "%s\n", iid_buf);
-}
-#endif
-
-/* fill the interface_directory IDE table from the interface_map */
-static gboolean
-fill_ide_table(gpointer key, gpointer value, gpointer user_data)
-{
-    TreeState *state = user_data;
-    NewInterfaceHolder *holder = (NewInterfaceHolder *) value;
-    struct nsID id;
-    XPTInterfaceDirectoryEntry *ide;
-
-    XPT_ASSERT(holder);
-
-#ifdef DEBUG_shaver_ifaces
-    fprintf(stderr, "filling %s\n", holder->full_name);
-#endif
-
-    if (holder->iid) {
-        if (strlen(holder->iid) != 36) {
-            IDL_tree_error(state->tree, "IID %s is the wrong length\n",
-                           holder->iid);
-            return FALSE;
-        }
-        if (!xpidl_parse_iid(&id, holder->iid)) {
-            IDL_tree_error(state->tree, "cannot parse IID %s\n", holder->iid);
-            return FALSE;
-        }
-    } else {
-        memset(&id, 0, sizeof(id));
-    }
-
-    ide = &(HEADER(state)->interface_directory[IFACES(state)]);
-    if (!XPT_FillInterfaceDirectoryEntry(ARENA(state), ide, &id, holder->name,
-                                         holder->name_space, NULL)) {
-        IDL_tree_error(state->tree, "INTERNAL: XPT_FillIDE failed for %s\n",
-                       holder->full_name);
-        return FALSE;
-    }
-
-    IFACES(state)++;
-    DeleteNewInterfaceHolder(holder);
-    return TRUE;
-}
-
-static int
-compare_IDEs(const void *ap, const void *bp)
-{
-    const XPTInterfaceDirectoryEntry *a = ap, *b = bp;
-    const nsID *aid = &a->iid, *bid = &b->iid;
-    const char *ans, *bns;
-
-    int i;
-#define COMPARE(field) if (aid->field > bid->field) return 1; \
-                       if (bid->field > aid->field) return -1;
-    COMPARE(m0);
-    COMPARE(m1);
-    COMPARE(m2);
-    for (i = 0; i < 8; i++) {
-        COMPARE(m3[i]);
-    }
-
-    /* defend against NULL name_space by using empty string. */
-    ans = a->name_space ? a->name_space : "";
-    bns = b->name_space ? b->name_space : "";
-
-    if (a->name_space && b->name_space) {
-        if ((i = strcmp(a->name_space, b->name_space)))
-            return i;
-    } else {
-        if (a->name_space || b->name_space) {
-            if (a->name_space)
-                return -1;
-            return 1;
-        }
-    }
-    /* these had better not be NULL... */
-    return strcmp(a->name, b->name);
-#undef COMPARE
-}
-
-/* sort the IDE block as per the typelib spec: IID order, unresolved first */
-static void
-sort_ide_block(TreeState *state)
-{
-    XPTInterfaceDirectoryEntry *ide;
-    int i;
-
-    /* boy, I sure hope qsort works correctly everywhere */
-#ifdef DEBUG_shaver_sort
-    fputs("before sort:\n", stderr);
-    for (i = 0; i < IFACES(state); i++) {
-        fputs("  ", stderr);
-        print_IID(&HEADER(state)->interface_directory[i].iid, stderr);
-        fputc('\n', stderr);
-    }
-#endif
-    qsort(HEADER(state)->interface_directory, IFACES(state),
-          sizeof(*ide), compare_IDEs);
-#ifdef DEBUG_shaver_sort
-    fputs("after sort:\n", stderr);
-    for (i = 0; i < IFACES(state); i++) {
-        fputs("  ", stderr);
-        print_IID(&HEADER(state)->interface_directory[i].iid, stderr);
-        fputc('\n', stderr);
-    }
-#endif
-
-    for (i = 0; i < IFACES(state); i++) {
-        ide = HEADER(state)->interface_directory + i;
-        g_hash_table_insert(IFACE_MAP(state), ide->name, (void *)(i + 1));
-    }
-
-    return;
-}
-
-static gboolean
-typelib_list(TreeState *state)
-{
-    IDL_tree iter;
-    for (iter = state->tree; iter; iter = IDL_LIST(iter).next) {
-        state->tree = IDL_LIST(iter).data;
-        if (!xpidl_process_node(state))
-            return FALSE;
-    }
-    return TRUE;
-}
-
-static gboolean
-typelib_prolog(TreeState *state)
-{
-    state->priv = calloc(1, sizeof(struct priv_data));
-    if (!state->priv)
-        return FALSE;
-    IFACES(state) = 0;
-    IFACE_MAP(state) = g_hash_table_new(g_str_hash, g_str_equal);
-    if (!IFACE_MAP(state)) {
-        /* XXX report error */
-        free(state->priv);
-        return FALSE;
-    }
-    /* find all interfaces, top-level and referenced by others */
-    IDL_tree_walk_in_order(state->tree, find_interfaces, state);
-    ARENA(state) = XPT_NewArena(1024, sizeof(double), "main xpidl arena");
-    HEADER(state) = XPT_NewHeader(ARENA(state), IFACES(state), 
-                                  major_version, minor_version);
-
-    /* fill IDEs from hash table */
-    IFACES(state) = 0;
-    g_hash_table_foreach_remove(IFACE_MAP(state), fill_ide_table, state);
-
-    /* if any are left then we must have failed in fill_ide_table */
-    if (g_hash_table_size(IFACE_MAP(state)))
-        return FALSE;
-
-    /* sort the IDEs by IID order and store indices in the interface map */
-    sort_ide_block(state);
-
-    return TRUE;
-}
-
-static gboolean
-typelib_epilog(TreeState *state)
-{
-    XPTState *xstate = XPT_NewXDRState(XPT_ENCODE, NULL, 0);
-    XPTCursor curs, *cursor = &curs;
-    PRUint32 i, len, header_sz;
-    PRUint32 oldOffset;
-    PRUint32 newOffset;
-    char *data;
-
-    /* Write any annotations */
-    if (emit_typelib_annotations) {
-        PRUint32 annotation_len, written_so_far;
-        char *annotate_val, *timestr;
-        time_t now;
-        static char *annotation_format = 
-            "Created from %s.idl\nCreation date: %sInterfaces:";
-
-        /* fill in the annotations, listing resolved interfaces in order */
-
-        (void)time(&now);
-        timestr = ctime(&now);
-
-        /* Avoid dependence on nspr; no PR_smprintf and friends. */
-
-        /* How large should the annotation string be? */
-        annotation_len = strlen(annotation_format) + strlen(state->basename) +
-            strlen(timestr);
-        for (i = 0; i < HEADER(state)->num_interfaces; i++) {
-            XPTInterfaceDirectoryEntry *ide;
-            ide = &HEADER(state)->interface_directory[i];
-            if (ide->interface_descriptor) {
-                annotation_len += strlen(ide->name) + 1;
-            }
-        }
-
-        annotate_val = (char *) malloc(annotation_len);
-        written_so_far = sprintf(annotate_val, annotation_format,
-                                 state->basename, timestr);
-        
-        for (i = 0; i < HEADER(state)->num_interfaces; i++) {
-            XPTInterfaceDirectoryEntry *ide;
-            ide = &HEADER(state)->interface_directory[i];
-            if (ide->interface_descriptor) {
-                written_so_far += sprintf(annotate_val + written_so_far, " %s",
-                                          ide->name);
-            }
-        }
-
-        HEADER(state)->annotations =
-            XPT_NewAnnotation(ARENA(state), 
-                              XPT_ANN_LAST | XPT_ANN_PRIVATE,
-                              XPT_NewStringZ(ARENA(state), "xpidl 0.99.9"),
-                              XPT_NewStringZ(ARENA(state), annotate_val));
-        free(annotate_val);
-    } else {
-        HEADER(state)->annotations =
-            XPT_NewAnnotation(ARENA(state), XPT_ANN_LAST, NULL, NULL);
-    }
-
-    if (!HEADER(state)->annotations) {
-        /* XXX report out of memory error */
-        return FALSE;
-    }
-
-    /* Write the typelib */
-    header_sz = XPT_SizeOfHeaderBlock(HEADER(state));
-
-    if (!xstate ||
-        !XPT_MakeCursor(xstate, XPT_HEADER, header_sz, cursor))
-        goto destroy_header;
-    oldOffset = cursor->offset;
-    if (!XPT_DoHeader(ARENA(state), cursor, &HEADER(state)))
-        goto destroy;
-    newOffset = cursor->offset;
-    XPT_GetXDRDataLength(xstate, XPT_HEADER, &len);
-    HEADER(state)->file_length = len;
-    XPT_GetXDRDataLength(xstate, XPT_DATA, &len);
-    HEADER(state)->file_length += len;
-    XPT_SeekTo(cursor, oldOffset);
-    if (!XPT_DoHeaderPrologue(ARENA(state), cursor, &HEADER(state), NULL))
-        goto destroy;
-    XPT_SeekTo(cursor, newOffset);
-    XPT_GetXDRData(xstate, XPT_HEADER, &data, &len);
-    fwrite(data, len, 1, state->file);
-    XPT_GetXDRData(xstate, XPT_DATA, &data, &len);
-    fwrite(data, len, 1, state->file);
-
- destroy:
-    XPT_DestroyXDRState(xstate);
- destroy_header:
-    /* XXX XPT_DestroyHeader(HEADER(state)) */
-
-    XPT_FreeHeader(ARENA(state), HEADER(state));
-    XPT_DestroyArena(ARENA(state));
-
-    /* XXX should destroy priv_data here */
-
-    return TRUE;
-}
-
-static XPTInterfaceDirectoryEntry *
-FindInterfaceByName(XPTInterfaceDirectoryEntry *ides, uint16 num_interfaces,
-                    const char *name)
-{
-    uint16 i;
-    for (i = 0; i < num_interfaces; i++) {
-        if (!strcmp(ides[i].name, name))
-            return &ides[i];
-    }
-    return NULL;
-}
-
-static gboolean
-typelib_interface(TreeState *state)
-{
-    IDL_tree iface = state->tree, iter;
-    char *name = IDL_IDENT(IDL_INTERFACE(iface).ident).str;
-    XPTInterfaceDirectoryEntry *ide;
-    XPTInterfaceDescriptor *id;
-    uint16 parent_id = 0;
-    PRUint8 interface_flags = 0;
-
-    if (!verify_interface_declaration(iface))
-        return FALSE;
-
-    if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable"))
-        interface_flags |= XPT_ID_SCRIPTABLE;
-
-    if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "function"))
-        interface_flags |= XPT_ID_FUNCTION;
-
-    if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "builtinclass"))
-        interface_flags |= XPT_ID_BUILTINCLASS;
-
-    ide = FindInterfaceByName(HEADER(state)->interface_directory,
-                              HEADER(state)->num_interfaces, name);
-    if (!ide) {
-        IDL_tree_error(iface, "ERROR: didn't find interface %s in "
-                       "IDE block. Giving up.\n", name);
-        return FALSE;
-    }
-
-    if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
-        char *parent;
-        if (IDL_LIST(iter).next) {
-            IDL_tree_error(iface,
-                           "ERROR: more than one parent interface for %s\n",
-                           name);
-            return FALSE;
-        }
-        parent = IDL_IDENT(IDL_LIST(iter).data).str;
-        parent_id = (uint16)(uint32)g_hash_table_lookup(IFACE_MAP(state),
-                                                        parent);
-        if (!parent_id) {
-            IDL_tree_error(iface,
-                           "ERROR: no index found for %s. Giving up.\n",
-                           parent);
-            return FALSE;
-        }
-    }
-
-    id = XPT_NewInterfaceDescriptor(ARENA(state), parent_id, 0, 0, 
-                                    interface_flags);
-    if (!id)
-        return FALSE;
-
-    CURRENT(state) = ide->interface_descriptor = id;
-#ifdef DEBUG_shaver_ifaces
-    fprintf(stderr, "DBG: starting interface %s @ %p\n", name, id);
-#endif
-
-    NEXT_METH(state) = 0;
-    NEXT_CONST(state) = 0;
-    NEXT_TYPE(state) = 0;
-
-    state->tree = IDL_INTERFACE(iface).body;
-    if (state->tree && !xpidl_process_node(state))
-        return FALSE;
-#ifdef DEBUG_shaver_ifaces
-    fprintf(stderr, "DBG: ending interface %s\n", name);
-#endif
-    return TRUE;
-}
-
-static gboolean
-find_arg_with_name(TreeState *state, const char *name, int16 *argnum)
-{
-    int16 count;
-    IDL_tree params;
-
-    XPT_ASSERT(state);
-    XPT_ASSERT(name);
-    XPT_ASSERT(argnum);
-
-    params = IDL_OP_DCL(IDL_NODE_UP(IDL_NODE_UP(state->tree))).parameter_dcls;
-    for (count = 0;
-         params != NULL && IDL_LIST(params).data != NULL;
-         params = IDL_LIST(params).next, count++)
-    {
-        const char *cur_name = IDL_IDENT(
-                IDL_PARAM_DCL(IDL_LIST(params).data).simple_declarator).str;
-        if (!strcmp(cur_name, name)) {
-            /* XXX ought to verify that this is the right type here */
-            /* XXX for iid_is this must be an iid */
-            /* XXX for size_is and length_is this must be a uint32 */
-            *argnum = count;
-            return TRUE;
-        }
-    }
-    return FALSE;
-}
-
-/* return value is for success or failure */
-static gboolean
-get_size_and_length(TreeState *state, IDL_tree type, 
-                    int16 *size_is_argnum, int16 *length_is_argnum,
-                    gboolean *has_size_is, gboolean *has_length_is)
-{
-    *has_size_is = FALSE;
-    *has_length_is = FALSE;
-
-    if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) {
-        IDL_tree sd = IDL_PARAM_DCL(state->tree).simple_declarator;
-        const char *size_is;
-        const char *length_is;
-
-        /* only if size_is is found does any of this matter */
-        size_is = IDL_tree_property_get(sd, "size_is");
-        if (!size_is)
-            return TRUE;
-
-        if (!find_arg_with_name(state, size_is, size_is_argnum)) {
-            IDL_tree_error(state->tree, "can't find matching argument for "
-                           "[size_is(%s)]\n", size_is);
-            return FALSE;
-        }
-        *has_size_is = TRUE;
-
-        /* length_is is optional */
-        length_is = IDL_tree_property_get(sd, "length_is");
-        if (length_is) {
-            *has_length_is = TRUE;
-            if (!find_arg_with_name(state, length_is, length_is_argnum)) {
-                IDL_tree_error(state->tree, "can't find matching argument for "
-                               "[length_is(%s)]\n", length_is);
-                return FALSE;
-            }
-        }
-    }
-    return TRUE;
-}
-
-static gboolean
-fill_td_from_type(TreeState *state, XPTTypeDescriptor *td, IDL_tree type)
-{
-    IDL_tree up;
-    int16 size_is_argnum;
-    int16 length_is_argnum;
-    gboolean has_size_is;
-    gboolean has_length_is;
-    gboolean is_array = FALSE;
-
-    if (type) {
-
-        /* deal with array */
-
-        if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) {
-            IDL_tree sd = IDL_PARAM_DCL(state->tree).simple_declarator;
-            if (IDL_tree_property_get(sd, "array")) {
-
-                is_array = TRUE;
-
-                /* size_is is required! */
-                if (!get_size_and_length(state, type, 
-                                         &size_is_argnum, &length_is_argnum,
-                                         &has_size_is, &has_length_is)) {
-                    /* error was reported by helper function */
-                    return FALSE;
-                }
-
-                if (!has_size_is) {
-                   IDL_tree_error(state->tree, "[array] requires [size_is()]\n");
-                    return FALSE;
-                }
-
-                td->prefix.flags = TD_ARRAY | XPT_TDP_POINTER;
-                td->argnum = size_is_argnum;
-
-                if (has_length_is)
-                    td->argnum2 = length_is_argnum;
-                else
-                    td->argnum2 = size_is_argnum;
-
-                /* 
-                * XXX - NOTE - this will be broken for multidimensional 
-                * arrays because of the realloc XPT_InterfaceDescriptorAddTypes
-                * uses. The underlying 'td' can change as we recurse in to get
-                * additional dimensions. Luckily, we don't yet support more
-                * than on dimension in the arrays
-                */
-                /* setup the additional_type */                
-                if (!XPT_InterfaceDescriptorAddTypes(ARENA(state), 
-                                                     CURRENT(state), 1)) {
-                    g_error("out of memory\n");
-                    return FALSE;
-                }
-                td->type.additional_type = NEXT_TYPE(state);
-                td = &CURRENT(state)->additional_types[NEXT_TYPE(state)];
-                NEXT_TYPE(state)++ ;
-            }
-        }
-
-handle_typedef:
-        switch (IDL_NODE_TYPE(type)) {
-          case IDLN_TYPE_INTEGER: {
-              gboolean sign = IDL_TYPE_INTEGER(type).f_signed;
-              switch(IDL_TYPE_INTEGER(type).f_type) {
-                case IDL_INTEGER_TYPE_SHORT:
-                  td->prefix.flags = sign ? TD_INT16 : TD_UINT16;
-                  break;
-                case IDL_INTEGER_TYPE_LONG:
-                  td->prefix.flags = sign ? TD_INT32 : TD_UINT32;
-                  break;
-                case IDL_INTEGER_TYPE_LONGLONG:
-                  td->prefix.flags = sign ? TD_INT64 : TD_UINT64;
-                  break;
-              }
-              break;
-          }
-          case IDLN_TYPE_CHAR:
-            td->prefix.flags = TD_CHAR;
-            break;
-          case IDLN_TYPE_WIDE_CHAR:
-            td->prefix.flags = TD_WCHAR;
-            break;
-          case IDLN_TYPE_STRING:
-            if (is_array) {
-                td->prefix.flags = TD_PSTRING | XPT_TDP_POINTER;
-            } else {
-                if (!get_size_and_length(state, type, 
-                                         &size_is_argnum, &length_is_argnum,
-                                         &has_size_is, &has_length_is)) {
-                    /* error was reported by helper function */
-                    return FALSE;
-                }
-                if (has_size_is) {
-                    td->prefix.flags = TD_PSTRING_SIZE_IS | XPT_TDP_POINTER;
-                    td->argnum = size_is_argnum;
-                    if (has_length_is)
-                        td->argnum2 = length_is_argnum;
-                    else
-                        td->argnum2 = size_is_argnum;
-                } else {
-                    td->prefix.flags = TD_PSTRING | XPT_TDP_POINTER;
-                }
-            }
-            break;
-          case IDLN_TYPE_WIDE_STRING:
-            if (is_array) {
-                td->prefix.flags = TD_PWSTRING | XPT_TDP_POINTER;
-            } else {
-                if (!get_size_and_length(state, type, 
-                                         &size_is_argnum, &length_is_argnum,
-                                         &has_size_is, &has_length_is)) {
-                    /* error was reported by helper function */
-                    return FALSE;
-                }
-                if (has_size_is) {
-                    td->prefix.flags = TD_PWSTRING_SIZE_IS | XPT_TDP_POINTER;
-                    td->argnum = size_is_argnum;
-                    if (has_length_is)
-                        td->argnum2 = length_is_argnum;
-                    else
-                        td->argnum2 = size_is_argnum;
-                } else {
-                    td->prefix.flags = TD_PWSTRING | XPT_TDP_POINTER;
-                }
-            }
-            break;
-          case IDLN_TYPE_BOOLEAN:
-            td->prefix.flags = TD_BOOL;
-            break;
-          case IDLN_TYPE_OCTET:
-            td->prefix.flags = TD_UINT8;
-            break;
-          case IDLN_TYPE_FLOAT:
-            switch (IDL_TYPE_FLOAT (type).f_type) {
-              case IDL_FLOAT_TYPE_FLOAT:
-                td->prefix.flags = TD_FLOAT;
-                break;
-              case IDL_FLOAT_TYPE_DOUBLE:
-                td->prefix.flags = TD_DOUBLE;
-                break;
-              /* XXX 'long double' just ignored, or what? */
-              default: break;
-            }
-            break;
-          case IDLN_IDENT:
-            if (!(up = IDL_NODE_UP(type))) {
-                IDL_tree_error(state->tree,
-                               "ERROR: orphan ident %s in param list\n",
-                               IDL_IDENT(type).str);
-                return FALSE;
-            }
-            switch (IDL_NODE_TYPE(up)) {
-                /* This whole section is abominably ugly */
-              case IDLN_FORWARD_DCL:
-              case IDLN_INTERFACE: {
-                XPTInterfaceDirectoryEntry *ide, *ides;
-                uint16 num_ifaces;
-                char *className;
-                const char *iid_is;
-handle_iid_is:
-                ides = HEADER(state)->interface_directory;
-                num_ifaces = HEADER(state)->num_interfaces;
-                /* might get here via the goto, so re-check type */
-                if (IDL_NODE_TYPE(up) == IDLN_INTERFACE)
-                    className = IDL_IDENT(IDL_INTERFACE(up).ident).str;
-                else if (IDL_NODE_TYPE(up) == IDLN_FORWARD_DCL)
-                    className = IDL_IDENT(IDL_FORWARD_DCL(up).ident).str;
-                else
-                    className = IDL_IDENT(IDL_NATIVE(up).ident).str;
-                iid_is = NULL;
-
-                if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) {
-                    iid_is =
-                        IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator,
-                                              "iid_is");
-                }
-                if (iid_is) {
-                    int16 argnum;
-                    if (!find_arg_with_name(state, iid_is, &argnum)) {
-                        IDL_tree_error(state->tree,
-                                       "can't find matching argument for "
-                                       "[iid_is(%s)]\n", iid_is);
-                        return FALSE;
-                    }
-                    td->prefix.flags = TD_INTERFACE_IS_TYPE | XPT_TDP_POINTER;
-                    td->argnum = argnum;
-                } else {
-                    td->prefix.flags = TD_INTERFACE_TYPE | XPT_TDP_POINTER;
-                    ide = FindInterfaceByName(ides, num_ifaces, className);
-                    if (!ide || ide < ides || ide > ides + num_ifaces) {
-                        IDL_tree_error(state->tree,
-                                       "unknown iface %s in param\n",
-                                       className);
-                        return FALSE;
-                    }
-                    td->type.iface = ide - ides + 1;
-#ifdef DEBUG_shaver_index
-                    fprintf(stderr, "DBG: index %d for %s\n",
-                            td->type.iface, className);
-#endif
-                }
-                break;
-              }
-              case IDLN_NATIVE: {
-                  char *ident;
-
-                  /* jband - adding goto for iid_is when type is native */
-                  if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL &&
-                      IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator,
-                                              "iid_is"))
-                      goto handle_iid_is;
-
-                  ident = IDL_IDENT(type).str;
-                  if (IDL_tree_property_get(type, "nsid")) {
-                      td->prefix.flags = TD_PNSIID;
-                      if (IDL_tree_property_get(type, "ref"))
-                          td->prefix.flags |= XPT_TDP_POINTER | XPT_TDP_REFERENCE;
-                      else if (IDL_tree_property_get(type,"ptr"))
-                          td->prefix.flags |= XPT_TDP_POINTER;
-                  } else if (IDL_tree_property_get(type, "domstring")) {
-                      td->prefix.flags = TD_DOMSTRING | XPT_TDP_POINTER;
-                      if (IDL_tree_property_get(type, "ref"))
-                          td->prefix.flags |= XPT_TDP_REFERENCE;
-                  } else if (IDL_tree_property_get(type, "astring")) {
-                      td->prefix.flags = TD_ASTRING | XPT_TDP_POINTER;
-                      if (IDL_tree_property_get(type, "ref"))
-                          td->prefix.flags |= XPT_TDP_REFERENCE;
-                  } else if (IDL_tree_property_get(type, "utf8string")) {
-                      td->prefix.flags = TD_UTF8STRING | XPT_TDP_POINTER;
-                      if (IDL_tree_property_get(type, "ref"))
-                          td->prefix.flags |= XPT_TDP_REFERENCE;
-                  } else if (IDL_tree_property_get(type, "cstring")) {
-                      td->prefix.flags = TD_CSTRING | XPT_TDP_POINTER;
-                      if (IDL_tree_property_get(type, "ref"))
-                          td->prefix.flags |= XPT_TDP_REFERENCE;
-                  } else if (IDL_tree_property_get(type, "jsval")) {
-                      td->prefix.flags = TD_JSVAL;
-                      if (IDL_tree_property_get(type, "ptr"))
-                          td->prefix.flags |= XPT_TDP_POINTER;
-                  } else {
-                      td->prefix.flags = TD_VOID | XPT_TDP_POINTER;
-                  }
-                  break;
-                }
-              default:
-                if (IDL_NODE_TYPE(IDL_NODE_UP(up)) == IDLN_TYPE_DCL) {
-                    /* restart with the underlying type */
-                    IDL_tree new_type;
-                    new_type = IDL_TYPE_DCL(IDL_NODE_UP(up)).type_spec;
-#ifdef DEBUG_shaver_misc
-                    fprintf(stderr, "following %s typedef to %s\n",
-                            IDL_IDENT(type).str, IDL_NODE_TYPE_NAME(new_type));
-#endif
-                    /* 
-                    *  Do a nice messy goto rather than recursion so that
-                    *  we can avoid screwing up the *array* information.
-                    */
-/*                    return fill_td_from_type(state, td, new_type); */
-                    if (new_type) {
-                        type = new_type;
-                        goto handle_typedef;
-                    } else {
-                        /* do what we would do in recursion if !type */
-                        td->prefix.flags = TD_VOID;
-                        return TRUE;
-                    }
-                }
-                IDL_tree_error(state->tree,
-                               "can't handle %s ident in param list\n",
-#ifdef DEBUG_shaver
-                               /* XXX is this safe to use on Win now? */
-                               IDL_NODE_TYPE_NAME(IDL_NODE_UP(type))
-#else
-                               "that type of"
-#endif
-                               );
-#ifdef DEBUG_shaver
-                XPT_ASSERT(0);
-#endif
-                return FALSE;
-            }
-            break;
-          default:
-            IDL_tree_error(state->tree, "can't handle %s in param list\n",
-#ifdef DEBUG_shaver
-                           /* XXX is this safe to use on Win now? */
-                           IDL_NODE_TYPE_NAME(IDL_NODE_UP(type))
-#else
-                        "that type"
-#endif
-            );
-            return FALSE;
-        }
-    } else {
-        td->prefix.flags = TD_VOID;
-    }
-
-    return TRUE;
-}
-
-static gboolean
-fill_pd_from_type(TreeState *state, XPTParamDescriptor *pd, uint8 flags,
-                  IDL_tree type)
-{
-    pd->flags = flags;
-    return fill_td_from_type(state, &pd->type, type);
-}
-
-static gboolean
-fill_pd_from_param(TreeState *state, XPTParamDescriptor *pd, IDL_tree tree)
-{
-    uint8 flags = 0;
-    gboolean is_dipper_type = DIPPER_TYPE(IDL_PARAM_DCL(tree).param_type_spec);
-
-    switch (IDL_PARAM_DCL(tree).attr) {
-      case IDL_PARAM_IN:
-        flags = XPT_PD_IN;
-        break;
-      case IDL_PARAM_OUT:
-        flags = XPT_PD_OUT;
-        break;
-      case IDL_PARAM_INOUT:
-        flags = XPT_PD_IN | XPT_PD_OUT;
-        break;
-    }
-
-    if (IDL_tree_property_get(IDL_PARAM_DCL(tree).simple_declarator,
-                              "retval")) {
-        if (flags != XPT_PD_OUT) {
-            IDL_tree_error(tree, "can't have [retval] with in%s param "
-                           "(only out)\n",
-                           flags & XPT_PD_OUT ? "out" : "");
-            return FALSE;
-        }
-        flags |= XPT_PD_RETVAL;
-    }
-
-    if (is_dipper_type && (flags & XPT_PD_OUT)) {
-        flags &= ~XPT_PD_OUT; 
-        flags |= XPT_PD_IN | XPT_PD_DIPPER;
-    }
-
-    if (IDL_tree_property_get(IDL_PARAM_DCL(tree).simple_declarator,
-                              "shared")) {
-        if (flags & XPT_PD_IN) {
-            IDL_tree_error(tree, "can't have [shared] with in%s param "
-                           "(only out)\n",
-                           flags & XPT_PD_OUT ? "out" : "");
-            return FALSE;
-        }
-        flags |= XPT_PD_SHARED;
-    }
-
-    if (IDL_tree_property_get(IDL_PARAM_DCL(tree).simple_declarator,
-                              "optional")) {
-        flags |= XPT_PD_OPTIONAL;
-    }
-
-    /* stick param where we can see it later */
-    state->tree = tree;
-    return fill_pd_from_type(state, pd, flags,
-                             IDL_PARAM_DCL(tree).param_type_spec);
-}
-
-/* XXXshaver common with xpidl_header.c */
-#define ATTR_IDENT(tree) (IDL_IDENT(IDL_LIST(IDL_ATTR_DCL(tree).simple_declarations).data))
-#define ATTR_TYPE_DECL(tree) (IDL_ATTR_DCL(tree).param_type_spec)
-#define ATTR_TYPE(tree) (IDL_NODE_TYPE(ATTR_TYPE_DECL(tree)))
-
-static gboolean
-fill_pd_as_nsresult(XPTParamDescriptor *pd)
-{
-    pd->type.prefix.flags = TD_UINT32; /* TD_NSRESULT */
-    return TRUE;
-}
-
-static gboolean
-typelib_attr_accessor(TreeState *state, XPTMethodDescriptor *meth,
-                      gboolean getter, gboolean hidden, gboolean wantsJSContext)
-{
-    uint8 methflags = 0;
-    uint8 pdflags = 0;
-
-    methflags |= getter ? XPT_MD_GETTER : XPT_MD_SETTER;
-    methflags |= hidden ? XPT_MD_HIDDEN : 0;
-    methflags |= wantsJSContext ? XPT_MD_CONTEXT : 0;
-    if (!XPT_FillMethodDescriptor(ARENA(state), meth, methflags,
-                                  ATTR_IDENT(state->tree).str, 1))
-        return FALSE;
-
-    if (getter) {
-        if (DIPPER_TYPE(ATTR_TYPE_DECL(state->tree))) {
-            pdflags |= (XPT_PD_RETVAL | XPT_PD_IN | XPT_PD_DIPPER);
-        } else {
-            pdflags |= (XPT_PD_RETVAL | XPT_PD_OUT);
-        }
-    } else {
-        pdflags |= XPT_PD_IN;
-    }
-
-    if (!fill_pd_from_type(state, meth->params, pdflags,
-                           ATTR_TYPE_DECL(state->tree)))
-        return FALSE;
-
-    fill_pd_as_nsresult(meth->result);
-    NEXT_METH(state)++;
-    return TRUE;
-}
-
-static gboolean
-typelib_attr_dcl(TreeState *state)
-{
-    XPTInterfaceDescriptor *id = CURRENT(state);
-    XPTMethodDescriptor *meth;
-    gboolean read_only = IDL_ATTR_DCL(state->tree).f_readonly;
-
-    /* XXX this only handles the first ident; elsewhere too... */
-    IDL_tree ident =
-        IDL_LIST(IDL_ATTR_DCL(state->tree).simple_declarations).data;
-
-    /* If it's marked [noscript], mark it as hidden in the typelib. */
-    gboolean hidden = (IDL_tree_property_get(ident, "noscript") != NULL);
-
-    gboolean wantsJSContext =
-        (IDL_tree_property_get(ident, "implicit_jscontext") != NULL);
-
-    if (!verify_attribute_declaration(state->tree))
-        return FALSE;
-
-    if (!XPT_InterfaceDescriptorAddMethods(ARENA(state), id, 
-                                           (PRUint16) (read_only ? 1 : 2)))
-        return FALSE;
-
-    meth = &id->method_descriptors[NEXT_METH(state)];
-
-    return typelib_attr_accessor(state, meth, TRUE, hidden, wantsJSContext) &&
-        (read_only ||
-         typelib_attr_accessor(state, meth + 1, FALSE, hidden, wantsJSContext));
-}
-
-static gboolean
-typelib_op_dcl(TreeState *state)
-{
-    XPTInterfaceDescriptor *id = CURRENT(state);
-    XPTMethodDescriptor *meth;
-    struct _IDL_OP_DCL *op = &IDL_OP_DCL(state->tree);
-    IDL_tree iter;
-    uint16 num_args = 0;
-    uint8 op_flags = 0;
-    gboolean op_notxpcom = (IDL_tree_property_get(op->ident, "notxpcom")
-                            != NULL);
-    gboolean op_noscript = (IDL_tree_property_get(op->ident, "noscript")
-                            != NULL);
-    gboolean op_context = (IDL_tree_property_get(op->ident,
-                                                 "implicit_jscontext") != NULL);
-    gboolean op_opt_argc = (IDL_tree_property_get(op->ident, "optional_argc")
-                            != NULL);
-
-    if (!verify_method_declaration(state->tree))
-        return FALSE;
-
-    if (!XPT_InterfaceDescriptorAddMethods(ARENA(state), id, 1))
-        return FALSE;
-
-    meth = &id->method_descriptors[NEXT_METH(state)];
-
-    for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next)
-        num_args++;             /* count params */
-    if (op->op_type_spec && !op_notxpcom)
-        num_args++;             /* fake param for _retval */
-
-    if (op_noscript)
-        op_flags |= XPT_MD_HIDDEN;
-    if (op_notxpcom)
-        op_flags |= XPT_MD_NOTXPCOM;
-    if (op_opt_argc)
-        op_flags |= XPT_MD_OPT_ARGC;
-    if (op_context)
-        op_flags |= XPT_MD_CONTEXT;
-
-    /* XXXshaver constructor? */
-
-#ifdef DEBUG_shaver_method
-    fprintf(stdout, "DBG: adding method %s (nargs %d)\n",
-            IDL_IDENT(op->ident).str, num_args);
-#endif
-    if (!XPT_FillMethodDescriptor(ARENA(state), meth, op_flags, 
-                                  IDL_IDENT(op->ident).str,
-                                  (uint8) num_args))
-        return FALSE;
-
-    for (num_args = 0, iter = op->parameter_dcls; iter;
-         iter = IDL_LIST(iter).next, num_args++) {
-        XPTParamDescriptor *pd = &meth->params[num_args];
-        if (!fill_pd_from_param(state, pd, IDL_LIST(iter).data))
-            return FALSE;
-    }
-
-    /* stick retval param where we can see it later */
-    state->tree = op->op_type_spec;
-
-    /* XXX unless [notxpcom] */
-    if (!op_notxpcom) {
-        if (op->op_type_spec) {
-            uint8 pdflags = DIPPER_TYPE(op->op_type_spec) ?
-                                (XPT_PD_RETVAL | XPT_PD_IN | XPT_PD_DIPPER) :
-                                (XPT_PD_RETVAL | XPT_PD_OUT);
-    
-            if (!fill_pd_from_type(state, &meth->params[num_args],
-                                   pdflags, op->op_type_spec))
-                return FALSE;
-        }
-
-        if (!fill_pd_as_nsresult(meth->result))
-            return FALSE;
-    } else {
-#ifdef DEBUG_shaver_notxpcom
-        fprintf(stderr, "%s is notxpcom\n", IDL_IDENT(op->ident).str);
-#endif
-        if (!fill_pd_from_type(state, meth->result, XPT_PD_RETVAL,
-                               op->op_type_spec))
-            return FALSE;
-    }
-    NEXT_METH(state)++;
-    return TRUE;
-}
-
-static gboolean
-typelib_const_dcl(TreeState *state)
-{
-    struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree);
-    const char *name = IDL_IDENT(dcl->ident).str;
-    gboolean is_long;
-    gboolean sign;
-    IDL_tree real_type;
-    XPTInterfaceDescriptor *id;
-    XPTConstDescriptor *cd;
-    IDL_longlong_t value;
-
-    if (!verify_const_declaration(state->tree))
-        return FALSE;
-
-    /* Could be a typedef; try to map it to the real type. */
-    real_type = find_underlying_type(dcl->const_type);
-    real_type = real_type ? real_type : dcl->const_type;
-    is_long = (IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG);
-
-    id = CURRENT(state);
-    if (!XPT_InterfaceDescriptorAddConsts(ARENA(state), id, 1))
-        return FALSE;
-    cd = &id->const_descriptors[NEXT_CONST(state)];
-    
-    cd->name = IDL_IDENT(dcl->ident).str;
-#ifdef DEBUG_shaver_const
-    fprintf(stderr, "DBG: adding const %s\n", cd->name);
-#endif
-    if (!fill_td_from_type(state, &cd->type, dcl->const_type))
-        return FALSE;
-    
-    value = IDL_INTEGER(dcl->const_exp).value;
-    sign = IDL_TYPE_INTEGER(dcl->const_type).f_signed;
-    if (is_long) {
-        if (sign)
-            cd->value.i32 = value;
-        else
-            cd->value.ui32 = value;
-    } else {
-        if (sign)
-            cd->value.i16 = value;
-        else
-            cd->value.ui16 = value;
-    }
-    NEXT_CONST(state)++;
-    return TRUE;
-}
-
-static gboolean
-typelib_enum(TreeState *state)
-{
-    XPIDL_WARNING((state->tree, IDL_WARNING1,
-                   "enums not supported, enum \'%s\' ignored",
-                   IDL_IDENT(IDL_TYPE_ENUM(state->tree).ident).str));
-    return TRUE;
-}
-
-backend *
-xpidl_typelib_dispatch(void)
-{
-    static backend result;
-    static nodeHandler table[IDLN_LAST];
-    static gboolean initialized = FALSE;
-
-    result.emit_prolog = typelib_prolog;
-    result.emit_epilog = typelib_epilog;
-
-    if (!initialized) {
-        /* Initialize non-NULL elements */
-        table[IDLN_LIST] = typelib_list;
-        table[IDLN_ATTR_DCL] = typelib_attr_dcl;
-        table[IDLN_OP_DCL] = typelib_op_dcl;
-        table[IDLN_INTERFACE] = typelib_interface;
-        table[IDLN_CONST_DCL] = typelib_const_dcl;
-        table[IDLN_TYPE_ENUM] = typelib_enum;
-        table[IDLN_NATIVE] = check_native;
-        initialized = TRUE;
-    }
-
-    result.dispatch_table = table;
-    return &result;
-}
-
-
-
deleted file mode 100644
--- a/xpcom/typelib/xpidl/xpidl_util.c
+++ /dev/null
@@ -1,958 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * Utility functions called by various backends.
- */ 
-
-#include "xpidl.h"
-
-#ifdef XP_WIN
-#define strdup _strdup
-#endif
-
-/* XXXbe static */ char OOM[] = "ERROR: out of memory\n";
-
-void *
-xpidl_malloc(size_t nbytes)
-{
-    void *p = malloc(nbytes);
-    if (!p) {
-        fputs(OOM, stderr);
-        exit(1);
-    }
-    return p;
-}
-
-char *
-xpidl_strdup(const char *s)
-{
-    char *ns = strdup(s);
-    if (!ns) {
-        fputs(OOM, stderr);
-        exit(1);
-    }
-    return ns;
-}
-
-void
-xpidl_write_comment(TreeState *state, int indent)
-{
-    fprintf(state->file, "%*s/* ", indent, "");
-    IDL_tree_to_IDL(state->tree, state->ns, state->file,
-                    IDLF_OUTPUT_NO_NEWLINES |
-                    IDLF_OUTPUT_NO_QUALIFY_IDENTS |
-                    IDLF_OUTPUT_PROPERTIES);
-    fputs(" */\n", state->file);
-}
-
-/*
- * Print an iid to into a supplied buffer; the buffer should be at least
- * UUID_LENGTH bytes.
- */
-gboolean
-xpidl_sprint_iid(nsID *id, char iidbuf[])
-{
-    int printed;
-
-    printed = sprintf(iidbuf,
-                       "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-                       (PRUint32) id->m0, (PRUint32) id->m1,(PRUint32) id->m2,
-                       (PRUint32) id->m3[0], (PRUint32) id->m3[1],
-                       (PRUint32) id->m3[2], (PRUint32) id->m3[3],
-                       (PRUint32) id->m3[4], (PRUint32) id->m3[5],
-                       (PRUint32) id->m3[6], (PRUint32) id->m3[7]);
-
-#ifdef SPRINTF_RETURNS_STRING
-    return (printed && strlen((char *)printed) == 36);
-#else
-    return (printed == 36);
-#endif
-}
-
-/* We only parse the {}-less format. */
-static const char nsIDFmt2[] =
-  "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
-
-/*
- * Parse a uuid string into an nsID struct.  We cannot link against libxpcom,
- * so we re-implement nsID::Parse here.
- */
-gboolean
-xpidl_parse_iid(nsID *id, const char *str)
-{
-    PRInt32 count = 0;
-    PRUint32 n0, n1, n2;
-    PRUint32 n3[8];
-    PRUint32 i;
-
-    XPT_ASSERT(str != NULL);
-    
-    if (strlen(str) != 36) {
-        return FALSE;
-    }
-     
-#ifdef DEBUG_shaver_iid
-    fprintf(stderr, "parsing iid   %s\n", str);
-#endif
-
-    count = sscanf(str, nsIDFmt2,
-                   &n0, &n1, &n2,
-                   &n3[0],&n3[1],&n3[2],&n3[3],
-                   &n3[4],&n3[5],&n3[6],&n3[7]);
-
-    id->m0 = n0;
-    id->m1 = (PRUint16) n1;
-    id->m2 = (PRUint16) n2;
-    for (i = 0; i < 8; i++) {
-      id->m3[i] = (PRUint8) n3[i];
-    }
-
-#ifdef DEBUG_shaver_iid
-    if (count == 11) {
-        fprintf(stderr, "IID parsed to ");
-        print_IID(id, stderr);
-        fputs("\n", stderr);
-    }
-#endif
-    return (gboolean)(count == 11);
-}
-
-gboolean
-verify_const_declaration(IDL_tree const_tree) {
-    struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(const_tree);
-    const char *name = IDL_IDENT(dcl->ident).str;
-    IDL_tree real_type;
-
-    /* const -> list -> interface */
-    if (!IDL_NODE_UP(IDL_NODE_UP(const_tree)) ||
-        IDL_NODE_TYPE(IDL_NODE_UP(IDL_NODE_UP(const_tree)))
-        != IDLN_INTERFACE) {
-        IDL_tree_error(const_tree,
-                       "const declaration \'%s\' outside interface",
-                       name);
-        return FALSE;
-    }
-
-    /* Could be a typedef; try to map it to the real type. */
-    real_type = find_underlying_type(dcl->const_type);
-    real_type = real_type ? real_type : dcl->const_type;
-    if (IDL_NODE_TYPE(real_type) == IDLN_TYPE_INTEGER &&
-        (IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_SHORT ||
-         IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG))
-    {
-        if (!IDL_TYPE_INTEGER(real_type).f_signed &&
-            IDL_INTEGER(dcl->const_exp).value < 0)
-        {
-#ifndef G_HAVE_GINT64
-            /*
-             * For platforms without longlong support turned on we can get
-             * confused by the high bit of the long value and think that it
-             * represents a negative value in an unsigned declaration.
-             * In that case we don't know if it is the programmer who is 
-             * confused or the compiler. So we issue a warning instead of 
-             * an error.
-             */
-            if (IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG)
-            {
-                XPIDL_WARNING((const_tree, IDL_WARNING1,
-                              "unsigned const declaration \'%s\' "
-                              "initialized with (possibly) negative constant",
-                              name));
-                return TRUE;
-            }
-#endif
-            IDL_tree_error(const_tree,
-                           "unsigned const declaration \'%s\' initialized with "
-                           "negative constant",
-                           name);
-            return FALSE;
-        }
-    } else {
-        IDL_tree_error(const_tree,
-                       "const declaration \'%s\' must be of type short or long",
-                       name);
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-
-
-/*
- * This method consolidates error checking needed when coercing the XPIDL compiler 
- * via the -t flag to generate output for a specific version of XPConnect.
- */
-static gboolean
-verify_type_fits_version(IDL_tree in_tree, IDL_tree error_tree)
-{
-    if (major_version == 1 && minor_version == 1)
-    {
-        /* XPIDL Version 1.1 checks */
-
-        /* utf8string, cstring, and astring types are not supported */
-        if (IDL_tree_property_get(in_tree, "utf8string") != NULL ||
-            IDL_tree_property_get(in_tree, "cstring")    != NULL ||
-            IDL_tree_property_get(in_tree, "astring")    != NULL)
-        {
-            IDL_tree_error(error_tree,
-                           "Cannot use [utf8string], [cstring] and [astring] "
-                           "types when generating version 1.1 typelibs\n");
-            return FALSE;
-        }
-    }
-    return TRUE;
-}
-
-static gboolean
-IsNot_AlphaUpper(char letter)
-{
-    return letter < 'A' || letter > 'Z';
-}
-
-static gboolean
-IsNot_AlphaLower(char letter)
-{
-    return letter < 'a' || letter > 'z';
-}
-
-static gboolean
-matches_IFoo(const char* substring)
-{
-    if (substring[0] != 'I')
-        return FALSE;
-    if (IsNot_AlphaUpper(substring[1]))
-        return FALSE;
-    if (IsNot_AlphaLower(substring[2]))
-        return FALSE;
-    return TRUE;
-}
-
-static gboolean
-matches_nsIFoo(const char* attribute_name)
-{
-    if (IsNot_AlphaLower(attribute_name[0]))
-        return FALSE;
-    if (IsNot_AlphaLower(attribute_name[1]))
-        return FALSE;
-    if (matches_IFoo(attribute_name + 2))
-        return TRUE;
-    if (IsNot_AlphaLower(attribute_name[2]))
-        return FALSE;
-    return matches_IFoo(attribute_name + 3);
-}
-
-/**
- * Returns TRUE if the method is probably scriptable, FALSE otherwise.
- * The first parameter may also be an attr_tree parameter, since these two are
- * the same with respect to discovering the interface node.
- */
-gboolean
-is_method_scriptable(IDL_tree method_tree, IDL_tree ident)
-{
-    IDL_tree iface;
-    gboolean scriptable_interface;
-    
-    /*
-     * Look up the tree to find the interface. If we can't find the interface,
-     * then the caller is being called on an incorrect tree. If we find it, we
-     * see if it's [scriptable] and duly note it.
-     */
-    if (IDL_NODE_UP(method_tree) && IDL_NODE_UP(IDL_NODE_UP(method_tree)) &&
-        IDL_NODE_TYPE(iface = IDL_NODE_UP(IDL_NODE_UP(method_tree))) 
-        == IDLN_INTERFACE)
-    {
-        scriptable_interface =
-            (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable")
-             != NULL);
-    } else {
-        IDL_tree_error(method_tree,
-                       "is_method_scriptable called on a non-interface?");
-        return FALSE;
-    }
-
-    /* If the interface isn't scriptable, the method sure can't be... */
-    if (!scriptable_interface)
-      return FALSE;
-
-    /* [notxpcom] implies [noscript] */
-    if (IDL_tree_property_get(ident, "notxpcom") != NULL)
-      return FALSE;
-
-    /* [noscript] methods obviously aren't scriptable */
-    if (IDL_tree_property_get(ident, "noscript") != NULL)
-      return FALSE;
-
-    /* The interface is scriptable, so therefore the method is, if the
-     * interfaces are accessible. That's good enough for this method.
-     */
-    return TRUE;
-}
-
-gboolean
-verify_attribute_declaration(IDL_tree attr_tree)
-{
-    IDL_tree iface;
-    IDL_tree ident;
-    IDL_tree attr_type;
-
-    /* We don't support attributes named IID, conflicts with static GetIID 
-     * member. The conflict is due to certain compilers (VC++) choosing a
-     * different vtable order, placing GetIID at the beginning regardless
-     * of its placement
-     */
-    if (strcmp(
-        IDL_IDENT(
-            IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).data).str, 
-        "IID") == 0) {
-        IDL_tree_error(attr_tree,
-                       "Attributes named IID not supported, causes vtable "
-                       "ordering problems");
-        return FALSE;
-    }
-
-    /*
-     * Grab the first of the list of idents and hope that it'll
-     * say scriptable or no.
-     */
-    ident = IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).data;
-
-    /*
-     * If the interface isn't scriptable, or the attribute is marked noscript,
-     * there's no need to check. This also verifies that we've been called on
-     * an interface.
-     */
-    if (!is_method_scriptable(attr_tree, ident))
-        return TRUE;
-
-    if (IDL_tree_property_get(ident, "nostdcall") != NULL) {
-        IDL_tree_error(attr_tree,
-                       "[nostdcall] attribute must not be scriptable");
-        return FALSE;
-    }
-
-    /*
-     * If it should be scriptable, check that the type is non-native. nsid,
-     * domstring, utf8string, cstring, astring are exempted.
-     */
-    attr_type = IDL_ATTR_DCL(attr_tree).param_type_spec;
-
-    if (attr_type != NULL)
-    {
-        if (UP_IS_NATIVE(attr_type) &&
-            IDL_tree_property_get(attr_type, "nsid") == NULL &&
-            IDL_tree_property_get(attr_type, "domstring") == NULL &&
-            IDL_tree_property_get(attr_type, "utf8string") == NULL &&
-            IDL_tree_property_get(attr_type, "cstring") == NULL &&
-            IDL_tree_property_get(attr_type, "astring") == NULL &&
-            IDL_tree_property_get(attr_type, "jsval") == NULL)
-        {
-            IDL_tree_error(attr_tree,
-                           "attributes in [scriptable] interfaces that are "
-                           "non-scriptable because they refer to native "
-                           "types must be marked [noscript]\n");
-            return FALSE;
-        }
-        /*
-         * We currently don't support properties of type nsid that aren't 
-         * pointers or references, unless they are marked [notxpcom} and 
-         * must be read-only 
-         */
-         
-        if ((IDL_tree_property_get(ident, "notxpcom") == NULL || !(IDL_ATTR_DCL(attr_tree).f_readonly)) &&
-            IDL_tree_property_get(attr_type,"nsid") != NULL &&
-            IDL_tree_property_get(attr_type,"ptr") == NULL &&
-            IDL_tree_property_get(attr_type,"ref") == NULL)
-        {
-            IDL_tree_error(attr_tree,
-                           "Feature not currently supported: "
-                           "attributes with a type of nsid must be marked "
-                           "either [ptr] or [ref], or "
-                           "else must be marked [notxpcom] "
-                           "and must be read-only\n");
-            return FALSE;
-        }
-
-        /*
-         * canIGoHomeNow is a bad name for an attribute.
-         * /^[a-z]{2,3}I[A-Z][a-z]/ => bad, reserved for
-         * interface flattening.
-         */
-        if (matches_nsIFoo(IDL_IDENT(IDL_LIST(IDL_ATTR_DCL(attr_tree).
-                simple_declarations).data).str)) {
-            XPIDL_WARNING((attr_tree, IDL_WARNING1,
-                 "Naming an attribute nsIFoo causes "
-                 "problems for interface flattening"));
-        }
-
-        /* 
-         * Run additional error checks on the attribute type if targetting an 
-         * older version of XPConnect.
-         */
-
-        if (!verify_type_fits_version(attr_type, attr_tree))
-            return FALSE;
-    }
-
-    if (IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).next != NULL)
-    {
-        IDL_tree_error(attr_tree,
-            "multiple attributes in a single declaration is not supported\n");
-        return FALSE;
-    }
-    return TRUE;
-}
-
-/*
- * Find the underlying type of an identifier typedef.
- * 
- * All the needed tree-walking seems pretty shaky; isn't there something in
- * libIDL to automate this?
- */
-IDL_tree /* IDL_TYPE_DCL */
-find_underlying_type(IDL_tree typedef_ident)
-{
-    IDL_tree up;
-
-    if (typedef_ident == NULL || IDL_NODE_TYPE(typedef_ident) != IDLN_IDENT)
-        return NULL;
-
-    up = IDL_NODE_UP(typedef_ident);
-    if (up == NULL || IDL_NODE_TYPE(up) != IDLN_LIST)
-        return NULL;
-    up = IDL_NODE_UP(up);
-    if (up == NULL || IDL_NODE_TYPE(up) != IDLN_TYPE_DCL)
-        return NULL;
-
-    return IDL_TYPE_DCL(up).type_spec;
-}
-
-static IDL_tree /* IDL_PARAM_DCL */
-find_named_parameter(IDL_tree method_tree, const char *param_name)
-{
-    IDL_tree iter;
-    for (iter = IDL_OP_DCL(method_tree).parameter_dcls; iter;
-         iter = IDL_LIST(iter).next)
-    {
-        IDL_tree param = IDL_LIST(iter).data;
-        IDL_tree simple_decl = IDL_PARAM_DCL(param).simple_declarator;
-        const char *current_name = IDL_IDENT(simple_decl).str;
-        if (strcmp(current_name, param_name) == 0)
-            return param;
-    }
-    return NULL;
-}
-
-typedef enum ParamAttrType {
-    IID_IS,
-    LENGTH_IS,
-    SIZE_IS
-} ParamAttrType;
-
-/*
- * Check that parameters referred to by attributes such as size_is exist and
- * refer to parameters of the appropriate type.
- */
-static gboolean
-check_param_attribute(IDL_tree method_tree, IDL_tree param,
-                      ParamAttrType whattocheck)
-{
-    const char *method_name = IDL_IDENT(IDL_OP_DCL(method_tree).ident).str;
-    const char *referred_name = NULL;
-    IDL_tree param_type = IDL_PARAM_DCL(param).param_type_spec;
-    IDL_tree simple_decl = IDL_PARAM_DCL(param).simple_declarator;
-    const char *param_name = IDL_IDENT(simple_decl).str;
-    const char *attr_name;
-    const char *needed_type;
-
-    if (whattocheck == IID_IS) {
-        attr_name = "iid_is";
-        needed_type = "IID";
-    } else if (whattocheck == LENGTH_IS) {
-        attr_name = "length_is";
-        needed_type = "unsigned long (or PRUint32)";
-    } else if (whattocheck == SIZE_IS) {
-        attr_name = "size_is";
-        needed_type = "unsigned long (or PRUint32)";
-    } else {
-        XPT_ASSERT("asked to check an unknown attribute type!");
-        return TRUE;
-    }
-    
-    referred_name = IDL_tree_property_get(simple_decl, attr_name);
-    if (referred_name != NULL) {
-        IDL_tree referred_param = find_named_parameter(method_tree,
-                                                       referred_name);
-        IDL_tree referred_param_type;
-        if (referred_param == NULL) {
-            IDL_tree_error(method_tree,
-                           "attribute [%s(%s)] refers to missing "
-                           "parameter \"%s\"",
-                           attr_name, referred_name, referred_name);
-            return FALSE;
-        }
-        if (referred_param == param) {
-            IDL_tree_error(method_tree,
-                           "attribute [%s(%s)] refers to its own parameter",
-                           attr_name, referred_name);
-            return FALSE;
-        }
-        
-        referred_param_type = IDL_PARAM_DCL(referred_param).param_type_spec;
-        if (whattocheck == IID_IS) {
-            /* require IID type */
-            if (IDL_tree_property_get(referred_param_type, "nsid") == NULL) {
-                IDL_tree_error(method_tree,
-                               "target \"%s\" of [%s(%s)] attribute "
-                               "must be of %s type",
-                               referred_name, attr_name, referred_name,
-                               needed_type);
-                return FALSE;
-            }
-        } else if (whattocheck == LENGTH_IS || whattocheck == SIZE_IS) {
-            /* require PRUint32 type */
-            IDL_tree real_type;
-
-            /* Could be a typedef; try to map it to the real type. */
-            real_type = find_underlying_type(referred_param_type);
-            real_type = real_type ? real_type : referred_param_type;
-
-            if (IDL_NODE_TYPE(real_type) != IDLN_TYPE_INTEGER ||
-                IDL_TYPE_INTEGER(real_type).f_signed != FALSE ||
-                IDL_TYPE_INTEGER(real_type).f_type != IDL_INTEGER_TYPE_LONG)
-            {
-                IDL_tree_error(method_tree,
-                               "target \"%s\" of [%s(%s)] attribute "
-                               "must be of %s type",
-                               referred_name, attr_name, referred_name,
-                               needed_type);
-
-                return FALSE;
-            }
-        }
-    }
-
-    return TRUE;
-}
-
-/*
- * Common method verification code, called by *op_dcl in the various backends.
- */
-gboolean
-verify_method_declaration(IDL_tree method_tree)
-{
-    struct _IDL_OP_DCL *op = &IDL_OP_DCL(method_tree);
-    IDL_tree iface;
-    IDL_tree iter;
-    gboolean notxpcom;
-    gboolean scriptable_method;
-    gboolean seen_retval = FALSE;
-    gboolean hasoptional = PR_FALSE;
-    const char *method_name = IDL_IDENT(IDL_OP_DCL(method_tree).ident).str;
-
-    /* We don't support attributes named IID, conflicts with static GetIID 
-     * member. The conflict is due to certain compilers (VC++) choosing a
-     * different vtable order, placing GetIID at the beginning regardless
-     * of its placement
-     */
-    if (strcmp(method_name, "GetIID") == 0) {
-        IDL_tree_error(method_tree,
-                       "Methods named GetIID not supported, causes vtable "
-                       "ordering problems");
-        return FALSE;
-    }
-    if (op->f_varargs) {
-        /* We don't currently support varargs. */
-        IDL_tree_error(method_tree, "varargs are not currently supported");
-        return FALSE;
-    }
-
-    /* 
-     * Decide if we are a scriptable method, or if we were are notxpcom.
-     * In doing so, we also verify that we've been called on an interface.
-     */
-    scriptable_method = is_method_scriptable(method_tree, op->ident);
-    notxpcom = IDL_tree_property_get(op->ident, "notxpcom") != NULL;
-
-    /* Loop through the parameters and check. */
-    for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) {
-        IDL_tree param = IDL_LIST(iter).data;
-        IDL_tree param_type =
-            IDL_PARAM_DCL(param).param_type_spec;
-        IDL_tree simple_decl =
-            IDL_PARAM_DCL(param).simple_declarator;
-        const char *param_name = IDL_IDENT(simple_decl).str;
-        
-        /*
-         * Reject this method if it should be scriptable and some parameter is
-         * native that isn't marked with either nsid, domstring, utf8string, 
-         * cstring, astring or iid_is.
-         */
-        if (scriptable_method &&
-            UP_IS_NATIVE(param_type) &&
-            IDL_tree_property_get(param_type, "nsid") == NULL &&
-            IDL_tree_property_get(simple_decl, "iid_is") == NULL &&
-            IDL_tree_property_get(param_type, "domstring") == NULL &&
-            IDL_tree_property_get(param_type, "utf8string") == NULL &&
-            IDL_tree_property_get(param_type, "cstring") == NULL &&
-            IDL_tree_property_get(param_type, "astring") == NULL &&
-            IDL_tree_property_get(param_type, "jsval") == NULL)
-        {
-            IDL_tree_error(method_tree,
-                           "methods in [scriptable] interfaces that are "
-                           "non-scriptable because they refer to native "
-                           "types (parameter \"%s\") must be marked "
-                           "[noscript]", param_name);
-            return FALSE;
-        }
-
-        /* 
-         * nsid's parameters that aren't ptr's or ref's are not currently 
-         * supported in xpcom or non-xpcom (marked with [notxpcom]) methods 
-         * as input parameters
-         */
-        if (!(notxpcom && IDL_PARAM_DCL(param).attr != IDL_PARAM_IN) &&
-            IDL_tree_property_get(param_type, "nsid") != NULL &&
-            IDL_tree_property_get(param_type, "ptr") == NULL &&
-            IDL_tree_property_get(param_type, "ref") == NULL) 
-        {
-            IDL_tree_error(method_tree,
-                           "Feature currently not supported: "
-                           "parameter \"%s\" is of type nsid and "
-                           "must be marked either [ptr] or [ref] "
-                           "or method \"%s\" must be marked [notxpcom] "
-                           "and must not be an input parameter",
-                           param_name,
-                           method_name);
-            return FALSE;
-        }
-        /*
-         * Sanity checks on return values.
-         */
-        if (IDL_tree_property_get(simple_decl, "retval") != NULL) {
-            if (IDL_LIST(iter).next != NULL) {
-                IDL_tree_error(method_tree,
-                               "only the last parameter can be marked [retval]");
-                return FALSE;
-            }
-            if (op->op_type_spec) {
-                IDL_tree_error(method_tree,
-                               "can't have [retval] with non-void return type");
-                return FALSE;
-            }
-            /* In case XPConnect relaxes the retval-is-last restriction. */
-            if (seen_retval) {
-                IDL_tree_error(method_tree,
-                               "can't have more than one [retval] parameter");
-                return FALSE;
-            }
-            seen_retval = TRUE;
-        }
-
-        /*
-         * Confirm that [shared] attributes are only used with string, wstring,
-         * or native (but not nsid, domstring, utf8string, cstring or astring) 
-         * and can't be used with [array].
-         */
-        if (IDL_tree_property_get(simple_decl, "shared") != NULL) {
-            IDL_tree real_type;
-            real_type = find_underlying_type(param_type);
-            real_type = real_type ? real_type : param_type;
-
-            if (IDL_tree_property_get(simple_decl, "array") != NULL) {
-                IDL_tree_error(method_tree,
-                               "[shared] parameter \"%s\" cannot "
-                               "be of array type", param_name);
-                return FALSE;
-            }                
-
-            if (!(IDL_NODE_TYPE(real_type) == IDLN_TYPE_STRING ||
-                  IDL_NODE_TYPE(real_type) == IDLN_TYPE_WIDE_STRING ||
-                  (UP_IS_NATIVE(real_type) &&
-                   !IDL_tree_property_get(real_type, "nsid") &&
-                   !IDL_tree_property_get(real_type, "domstring")  &&
-                   !IDL_tree_property_get(real_type, "utf8string") &&
-                   !IDL_tree_property_get(real_type, "cstring")    &&
-                   !IDL_tree_property_get(real_type, "astring")    &&
-                   !IDL_tree_property_get(real_type, "jsval"))))
-            {
-                IDL_tree_error(method_tree,
-                               "[shared] parameter \"%s\" must be of type "
-                               "string, wstring or native", param_name);
-                return FALSE;
-            }
-        }
-
-        /*
-         * confirm that once an optional argument is used, all remaining
-         * arguments are marked as optional or retval.
-         */
-        if (IDL_tree_property_get(simple_decl, "optional") != NULL) {
-            hasoptional = PR_TRUE;
-        }
-        else if (hasoptional && IDL_tree_property_get(simple_decl, "retval") == NULL) {
-            IDL_tree_error(method_tree,
-                           "non-optional non-retval parameter used after one marked [optional]");
-            return FALSE;
-        }
-
-        /*
-         * inout is not allowed with "domstring", "UTF8String", "CString" 
-         * and "AString" types
-         */
-        if (IDL_PARAM_DCL(param).attr == IDL_PARAM_INOUT &&
-            UP_IS_NATIVE(param_type) &&
-            (IDL_tree_property_get(param_type, "domstring")  != NULL ||
-             IDL_tree_property_get(param_type, "utf8string") != NULL ||
-             IDL_tree_property_get(param_type, "cstring")    != NULL ||
-             IDL_tree_property_get(param_type, "astring")    != NULL )) {
-            IDL_tree_error(method_tree,
-                           "[domstring], [utf8string], [cstring], [astring] "
-                           "types cannot be used as inout parameters");
-            return FALSE;
-        }
-
-
-        /*
-         * arrays of domstring, utf8string, cstring, astring types not allowed
-         */
-        if (IDL_tree_property_get(simple_decl, "array") != NULL &&
-            UP_IS_NATIVE(param_type) &&
-            (IDL_tree_property_get(param_type, "domstring")  != NULL ||
-             IDL_tree_property_get(param_type, "utf8string") != NULL ||
-             IDL_tree_property_get(param_type, "cstring")    != NULL ||
-             IDL_tree_property_get(param_type, "astring")    != NULL)) {
-            IDL_tree_error(method_tree,
-                           "[domstring], [utf8string], [cstring], [astring] "
-                           "types cannot be used in array parameters");
-            return FALSE;
-        }                
-
-        if (!check_param_attribute(method_tree, param, IID_IS) ||
-            !check_param_attribute(method_tree, param, LENGTH_IS) ||
-            !check_param_attribute(method_tree, param, SIZE_IS))
-            return FALSE;
-
-        /* 
-         * Run additional error checks on the parameter type if targetting an 
-         * older version of XPConnect.
-         */
-
-        if (!verify_type_fits_version(param_type, method_tree))
-            return FALSE;
-        
-    }
-
-    if (IDL_tree_property_get(op->ident, "optional_argc") != NULL &&
-        !hasoptional) {
-        IDL_tree_error(method_tree,
-                       "[optional_argc] method must contain [optional] "
-                       "arguments");
-        return FALSE;
-    }
-
-    if (IDL_tree_property_get(op->ident, "nostdcall") != NULL &&
-        scriptable_method) {
-        IDL_tree_error(method_tree,
-                       "[nostdcall] method must not be scriptable");
-        return FALSE;
-    }
-
-    /* XXX q: can return type be nsid? */
-    /* Native return type? */
-    if (scriptable_method &&
-        op->op_type_spec != NULL && UP_IS_NATIVE(op->op_type_spec) &&
-        IDL_tree_property_get(op->op_type_spec, "nsid") == NULL &&
-        IDL_tree_property_get(op->op_type_spec, "domstring") == NULL &&
-        IDL_tree_property_get(op->op_type_spec, "utf8string") == NULL &&
-        IDL_tree_property_get(op->op_type_spec, "cstring") == NULL &&
-        IDL_tree_property_get(op->op_type_spec, "astring") == NULL &&
-        IDL_tree_property_get(op->op_type_spec, "jsval") == NULL)
-    {
-        IDL_tree_error(method_tree,
-                       "methods in [scriptable] interfaces that are "
-                       "non-scriptable because they return native "
-                       "types must be marked [noscript]");
-        return FALSE;
-    }
-
-
-    /* 
-     * nsid's parameters that aren't ptr's or ref's are not currently 
-     * supported in xpcom
-     */
-    if (!notxpcom &&
-        op->op_type_spec != NULL &&
-        IDL_tree_property_get(op->op_type_spec, "nsid") != NULL &&
-        IDL_tree_property_get(op->op_type_spec, "ptr") == NULL &&
-        IDL_tree_property_get(op->op_type_spec, "ref") == NULL) 
-    {
-        IDL_tree_error(method_tree,
-                       "Feature currently not supported: "
-                       "return value is of type nsid and "
-                       "must be marked either [ptr] or [ref], "
-                       "or else method \"%s\" must be marked [notxpcom] ",
-                       method_name);
-        return FALSE;
-    }
-
-    /* 
-     * Run additional error checks on the return type if targetting an 
-     * older version of XPConnect.
-     */
-
-    if (op->op_type_spec != NULL &&
-        !verify_type_fits_version(op->op_type_spec, method_tree))
-    {
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-/*
- * Verify that a native declaration has an associated C++ expression, i.e. that
- * it's of the form native <idl-name>(<c++-name>)
- */
-gboolean
-check_native(TreeState *state)
-{
-    char *native_name;
-    /* require that native declarations give a native type */
-    if (IDL_NATIVE(state->tree).user_type) 
-        return TRUE;
-    native_name = IDL_IDENT(IDL_NATIVE(state->tree).ident).str;
-    IDL_tree_error(state->tree,
-                   "``native %s;'' needs C++ type: ``native %s(<C++ type>);''",
-                   native_name, native_name);
-    return FALSE;
-}
-
-/*
- * Print a GSList as char strings to a file.
- */
-void
-printlist(FILE *outfile, GSList *slist)
-{
-    guint i;
-    guint len = g_slist_length(slist);
-
-    for(i = 0; i < len; i++) {
-        fprintf(outfile, 
-                "%s\n", (char *)g_slist_nth_data(slist, i));
-    }
-}
-
-void
-xpidl_list_foreach(IDL_tree p, IDL_tree_func foreach, gpointer user_data)
-{
-    IDL_tree_func_data tfd;
-
-    while (p) {
-        struct _IDL_LIST *list = &IDL_LIST(p);
-        tfd.tree = list->data;
-        if (!foreach(&tfd, user_data))
-            return;
-        p = list->next;
-    }
-}
-
-/*
- * Verify that the interface declaration is correct
- */
-gboolean
-verify_interface_declaration(IDL_tree interface_tree)
-{
-    gboolean scriptable =
-      IDL_tree_property_get(IDL_INTERFACE(interface_tree).ident,
-                            "scriptable") != NULL;
-    gboolean builtinclass =
-      IDL_tree_property_get(IDL_INTERFACE(interface_tree).ident,
-                            "builtinclass") != NULL;
-
-    IDL_tree iter;
-    /* 
-     * If we have the scriptable attribute then make sure all of our direct
-     * parents have it as well.
-     * NOTE: We don't recurse since all interfaces will come through here
-     */
-    if (scriptable || !builtinclass) {
-        for (iter = IDL_INTERFACE(interface_tree).inheritance_spec; iter; 
-            iter = IDL_LIST(iter).next) {
-            if (scriptable &&
-                IDL_tree_property_get(
-                  IDL_INTERFACE(iter).ident, "scriptable") == 0) {
-                XPIDL_WARNING((interface_tree,IDL_WARNING1,
-                    "%s is scriptable but inherits from the non-scriptable interface %s\n",
-                    IDL_IDENT(IDL_INTERFACE(interface_tree).ident).str,
-                    IDL_IDENT(IDL_INTERFACE(iter).ident).str));
-            }
-            if (!builtinclass &&
-                IDL_tree_property_get(
-                  IDL_INTERFACE(iter).ident, "builtinclass")) {
-                IDL_tree_error(interface_tree,
-                               "%s is not [builtinclass] but extends "
-                               "[builtinclass] interface %s",
-                               IDL_IDENT(IDL_INTERFACE(interface_tree).ident).str,
-                               IDL_IDENT(IDL_INTERFACE(iter).ident).str);
-                return FALSE;
-            }
-        }
-    }
-    return TRUE;
-}
-
-/*
- * Return a pointer to the start of the base filename of path
- */
-const char *
-xpidl_basename(const char * path)
-{
-    const char * result = g_basename(path);
-    /* 
-     *If this is windows then we'll handle either / or \ as a separator
-     * g_basename only handles \ for windows
-     */
-#if defined(XP_WIN32)
-    const char * slash = strrchr(path, '/');
-    /* If we found a slash and its after the current default OS separator */
-    if (slash != NULL && (slash > result))
-        result = slash + 1;
-#endif
-    return result;
-}