Bug 687766 part 2: Nuke binary xpidl. r=khuey
authorMatheus Kerschbaum <matjk7@gmail.com>
Tue, 27 Sep 2011 10:10:06 +0200
changeset 78994 d1fb12e773621252e07b6a6e5c7103018b434bfb
parent 78993 587115c590ff0da824e1248aa9052be002384f1c
child 78995 da0d9bc38cadc8d762e1f25c297a1ae18895e8d9
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)
reviewerskhuey
bugs687766
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
Bug 687766 part 2: Nuke binary xpidl. r=khuey
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
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;
-}