remove xpt_* files for reading from the XPT files draft
authorAndrew McCreight <continuation@gmail.com>
Wed, 28 Feb 2018 12:51:39 -0800
changeset 762241 0411d7053af9845c8837bd90aa86d33feb372c83
parent 762240 9e602b48c3fa45d493b4a7166f0599d452f9cff4
child 762242 29a1104dd0bf4bb590ae8a92913128e0bcc82a88
push id101107
push userbmo:continuation@gmail.com
push dateThu, 01 Mar 2018 22:22:59 +0000
milestone60.0a1
remove xpt_* files for reading from the XPT files MozReview-Commit-ID: 6NJdaCWRBhU
xpcom/reflect/xptinfo/xptiprivate.h
xpcom/typelib/xpt/moz.build
xpcom/typelib/xpt/xpt_struct.cpp
xpcom/typelib/xpt/xpt_xdr.cpp
xpcom/typelib/xpt/xpt_xdr.h
--- a/xpcom/reflect/xptinfo/xptiprivate.h
+++ b/xpcom/reflect/xptinfo/xptiprivate.h
@@ -10,17 +10,16 @@
 
 #include "nscore.h"
 #include <new>
 #include "nsISupports.h"
 
 // this after nsISupports, to pick up IID
 // so that xpt stuff doesn't try to define it itself...
 #include "xpt_struct.h"
-#include "xpt_xdr.h"
 
 #include "nsIInterfaceInfo.h"
 #include "nsIInterfaceInfoManager.h"
 #include "xptinfo.h"
 #include "ShimInterfaceInfo.h"
 
 #include "nsIServiceManager.h"
 #include "nsIFile.h"
@@ -73,16 +72,17 @@
 #endif
 
 /***************************************************************************/
 
 class xptiInterfaceInfo;
 class xptiInterfaceEntry;
 class xptiTypelibGuts;
 
+struct XPTArena;
 extern XPTArena* gXPTIStructArena;
 
 /***************************************************************************/
 
 /***************************************************************************/
 
 // No virtuals.
 // These are always constructed in the struct arena using placement new.
--- a/xpcom/typelib/xpt/moz.build
+++ b/xpcom/typelib/xpt/moz.build
@@ -5,24 +5,21 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 Library('xpt')
 
 DIRS += ['tools']
 
 UNIFIED_SOURCES += [
     'xpt_arena.cpp',
-    'xpt_struct.cpp',
-    'xpt_xdr.cpp',
 ]
 
 EXPORTS += [
     'xpt_arena.h',
     'xpt_struct.h',
-    'xpt_xdr.h',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '!/xpcom/base',
     '/xpcom/base',
 ]
deleted file mode 100644
--- a/xpcom/typelib/xpt/xpt_struct.cpp
+++ /dev/null
@@ -1,470 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=8 sts=4 et sw=4 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* Implementation of XDR routines for typelib structures. */
-
-#include "xpt_xdr.h"
-#include "xpt_struct.h"
-#include <string.h>
-#include <stdint.h>
-#include <stdio.h>
-
-using mozilla::WrapNotNull;
-
-#define XPT_MAGIC "XPCOM\nTypeLib\r\n\032"
-#define XPT_MAGIC_STRING "XPCOM\\nTypeLib\\r\\n\\032"
-
-/*
- * Annotation records are variable-size records used to store secondary
- * information about the typelib, e.g. such as the name of the tool that
- * generated the typelib file, the date it was generated, etc.  The
- * information is stored with very loose format requirements so as to
- * allow virtually any private data to be stored in the typelib.
- *
- * There are two types of Annotations:
- *
- * EmptyAnnotation
- * PrivateAnnotation
- *
- * The tag field of the prefix discriminates among the variant record
- * types for Annotation's.  If the tag is 0, this record is an
- * EmptyAnnotation. EmptyAnnotation's are ignored - they're only used to
- * indicate an array of Annotation's that's completely empty.  If the tag
- * is 1, the record is a PrivateAnnotation.
- *
- * We don't actually store annotations; we just skip over them if they are
- * present.
- */
-
-#define XPT_ANN_LAST    0x80
-#define XPT_ANN_PRIVATE 0x40
-
-#define XPT_ANN_IS_LAST(flags) (flags & XPT_ANN_LAST)
-#define XPT_ANN_IS_PRIVATE(flags)(flags & XPT_ANN_PRIVATE)
-
-
-/***************************************************************************/
-/* Forward declarations. */
-
-static bool
-DoInterfaceDirectoryEntry(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                          XPTInterfaceDirectoryEntry *ide);
-
-static bool
-DoConstDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                  XPTConstDescriptor *cd, XPTInterfaceDescriptor *id);
-
-static bool
-DoMethodDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                   XPTMethodDescriptor *md, XPTInterfaceDescriptor *id);
-
-static bool
-SkipAnnotation(NotNull<XPTCursor*> cursor, bool *isLast);
-
-static bool
-DoInterfaceDescriptor(XPTArena *arena, NotNull<XPTCursor*> outer,
-                      const XPTInterfaceDescriptor **idp);
-
-static bool
-DoTypeDescriptorPrefix(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                       XPTTypeDescriptorPrefix *tdp);
-
-static bool
-DoTypeDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                 XPTTypeDescriptor *td, XPTInterfaceDescriptor *id);
-
-static bool
-DoParamDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                  XPTParamDescriptor *pd, XPTInterfaceDescriptor *id);
-
-/***************************************************************************/
-
-bool
-XPT_DoHeader(XPTArena *arena, NotNull<XPTCursor*> cursor, XPTHeader **headerp)
-{
-    unsigned int i;
-    uint32_t file_length = 0;
-    uint32_t ide_offset;
-
-    XPTHeader* header = XPT_NEWZAP(arena, XPTHeader);
-    if (!header)
-        return false;
-    *headerp = header;
-
-    uint8_t magic[16];
-    for (i = 0; i < sizeof(magic); i++) {
-        if (!XPT_Do8(cursor, &magic[i]))
-            return false;
-    }
-
-    if (strncmp((const char*)magic, XPT_MAGIC, 16) != 0) {
-        /* Require that the header contain the proper magic */
-        fprintf(stderr,
-                "libxpt: bad magic header in input file; "
-                "found '%s', expected '%s'\n",
-                magic, XPT_MAGIC_STRING);
-        return false;
-    }
-
-    uint8_t minor_version;
-    if (!XPT_Do8(cursor, &header->major_version) ||
-        !XPT_Do8(cursor, &minor_version)) {
-        return false;
-    }
-
-    if (header->major_version >= XPT_MAJOR_INCOMPATIBLE_VERSION) {
-        /* This file is newer than we are and set to an incompatible version
-         * number. We must set the header state thusly and return.
-         */
-        header->num_interfaces = 0;
-        return true;
-    }
-
-    if (!XPT_Do16(cursor, &header->num_interfaces) ||
-        !XPT_Do32(cursor, &file_length) ||
-        !XPT_Do32(cursor, &ide_offset)) {
-        return false;
-    }
-
-    /*
-     * Make sure the file length reported in the header is the same size as
-     * as our buffer unless it is zero (not set)
-     */
-    if (file_length != 0 &&
-        cursor->state->pool_allocated < file_length) {
-        fputs("libxpt: File length in header does not match actual length. File may be corrupt\n",
-            stderr);
-        return false;
-    }
-
-    uint32_t data_pool;
-    if (!XPT_Do32(cursor, &data_pool))
-        return false;
-
-    XPT_SetDataOffset(cursor->state, data_pool);
-
-    XPTInterfaceDirectoryEntry* interface_directory = nullptr;
-
-    if (header->num_interfaces) {
-        size_t n = header->num_interfaces * sizeof(XPTInterfaceDirectoryEntry);
-        interface_directory =
-            static_cast<XPTInterfaceDirectoryEntry*>(XPT_CALLOC8(arena, n));
-        if (!interface_directory)
-            return false;
-    }
-
-    /*
-     * Iterate through the annotations rather than recurring, to avoid blowing
-     * the stack on large xpt files. We don't actually store annotations, we
-     * just skip over them.
-     */
-    bool isLast;
-    do {
-        if (!SkipAnnotation(cursor, &isLast))
-            return false;
-    } while (!isLast);
-
-    /* shouldn't be necessary now, but maybe later */
-    XPT_SeekTo(cursor, ide_offset);
-
-    for (i = 0; i < header->num_interfaces; i++) {
-        if (!DoInterfaceDirectoryEntry(arena, cursor,
-                                       &interface_directory[i]))
-            return false;
-    }
-
-    header->interface_directory = interface_directory;
-
-    return true;
-}
-
-/* InterfaceDirectoryEntry records go in the header */
-bool
-DoInterfaceDirectoryEntry(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                          XPTInterfaceDirectoryEntry *ide)
-{
-    const char* dummy_name_space;
-
-    /* write the IID in our cursor space */
-    if (!XPT_DoIID(cursor, &(ide->iid)) ||
-
-        /* write the name string in the data pool, and the offset in our
-           cursor space */
-        !XPT_DoCString(arena, cursor, &(ide->name)) ||
-
-        /* don't write the name_space string in the data pool, because we don't
-         * need it. Do write the offset in our cursor space */
-        !XPT_DoCString(arena, cursor, &dummy_name_space, /* ignore = */ true) ||
-
-        /* do InterfaceDescriptors */
-        !DoInterfaceDescriptor(arena, cursor, &ide->interface_descriptor)) {
-        return false;
-    }
-
-    return true;
-}
-
-static bool
-InterfaceDescriptorAddType(XPTArena *arena,
-                           XPTInterfaceDescriptor *id,
-                           XPTTypeDescriptor *td)
-{
-    const XPTTypeDescriptor *old = id->additional_types;
-    XPTTypeDescriptor *new_;
-    size_t old_size = id->num_additional_types * sizeof(XPTTypeDescriptor);
-    size_t new_size = old_size + sizeof(XPTTypeDescriptor);
-
-    /* XXX should grow in chunks to minimize alloc overhead */
-    new_ = static_cast<XPTTypeDescriptor*>(XPT_CALLOC8(arena, new_size));
-    if (!new_)
-        return false;
-    if (old) {
-        memcpy(new_, old, old_size);
-    }
-
-    new_[id->num_additional_types] = *td;
-    id->additional_types = new_;
-
-    if (id->num_additional_types == UINT8_MAX)
-        return false;
-
-    id->num_additional_types += 1;
-    return true;
-}
-
-bool
-DoInterfaceDescriptor(XPTArena *arena, NotNull<XPTCursor*> outer,
-                      const XPTInterfaceDescriptor **idp)
-{
-    XPTInterfaceDescriptor *id;
-    XPTCursor curs;
-    NotNull<XPTCursor*> cursor = WrapNotNull(&curs);
-    uint32_t i, id_sz = 0;
-
-    id = XPT_NEWZAP(arena, XPTInterfaceDescriptor);
-    if (!id)
-        return false;
-    *idp = id;
-
-    if (!XPT_MakeCursor(outer->state, XPT_DATA, id_sz, cursor))
-        return false;
-
-    if (!XPT_Do32(outer, &cursor->offset))
-        return false;
-    if (!cursor->offset) {
-        *idp = NULL;
-        return true;
-    }
-    if(!XPT_Do16(cursor, &id->parent_interface) ||
-       !XPT_Do16(cursor, &id->num_methods)) {
-        return false;
-    }
-
-    XPTMethodDescriptor* method_descriptors = nullptr;
-
-    if (id->num_methods) {
-        size_t n = id->num_methods * sizeof(XPTMethodDescriptor);
-        method_descriptors =
-            static_cast<XPTMethodDescriptor*>(XPT_CALLOC8(arena, n));
-        if (!method_descriptors)
-            return false;
-    }
-
-    for (i = 0; i < id->num_methods; i++) {
-        if (!DoMethodDescriptor(arena, cursor, &method_descriptors[i], id))
-            return false;
-    }
-
-    id->method_descriptors = method_descriptors;
-
-    if (!XPT_Do16(cursor, &id->num_constants)) {
-        return false;
-    }
-
-    XPTConstDescriptor* const_descriptors = nullptr;
-
-    if (id->num_constants) {
-        size_t n = id->num_constants * sizeof(XPTConstDescriptor);
-        const_descriptors =
-            static_cast<XPTConstDescriptor*>(XPT_CALLOC8(arena, n));
-        if (!const_descriptors)
-            return false;
-    }
-
-    for (i = 0; i < id->num_constants; i++) {
-        if (!DoConstDescriptor(arena, cursor, &const_descriptors[i], id)) {
-            return false;
-        }
-    }
-
-    id->const_descriptors = const_descriptors;
-
-    if (!XPT_Do8(cursor, &id->flags)) {
-        return false;
-    }
-
-    return true;
-}
-
-bool
-DoConstDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                  XPTConstDescriptor *cd, XPTInterfaceDescriptor *id)
-{
-    bool ok = false;
-
-    if (!XPT_DoCString(arena, cursor, &cd->name) ||
-        !DoTypeDescriptor(arena, cursor, &cd->type, id)) {
-
-        return false;
-    }
-
-    switch (cd->type.Tag()) {
-      case TD_INT16:
-        ok = XPT_Do16(cursor, (uint16_t*) &cd->value.i16);
-        break;
-      case TD_INT32:
-        ok = XPT_Do32(cursor, (uint32_t*) &cd->value.i32);
-        break;
-      case TD_UINT16:
-        ok = XPT_Do16(cursor, &cd->value.ui16);
-        break;
-      case TD_UINT32:
-        ok = XPT_Do32(cursor, &cd->value.ui32);
-        break;
-      default:
-        MOZ_ASSERT(false, "illegal type");
-        break;
-    }
-
-    return ok;
-}
-
-bool
-DoMethodDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                   XPTMethodDescriptor *md, XPTInterfaceDescriptor *id)
-{
-    int i;
-
-    if (!XPT_Do8(cursor, &md->flags) ||
-        !XPT_DoCString(arena, cursor, &md->name) ||
-        !XPT_Do8(cursor, &md->num_args))
-        return false;
-
-    XPTParamDescriptor* params = nullptr;
-
-    if (md->num_args) {
-        size_t n = md->num_args * sizeof(XPTParamDescriptor);
-        params = static_cast<XPTParamDescriptor*>(XPT_CALLOC8(arena, n));
-        if (!params)
-            return false;
-    }
-
-    for(i = 0; i < md->num_args; i++) {
-        if (!DoParamDescriptor(arena, cursor, &params[i], id))
-            return false;
-    }
-
-    md->params = params;
-
-    // |result| appears in the on-disk format but it isn't used,
-    // because a method is either notxpcom, in which case it can't be
-    // called from script so the XPT information is irrelevant, or the
-    // result type is nsresult.
-    XPTParamDescriptor result;
-    if (!DoParamDescriptor(arena, cursor, &result, id))
-        return false;
-
-    return true;
-}
-
-bool
-DoParamDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                  XPTParamDescriptor *pd, XPTInterfaceDescriptor *id)
-{
-    if (!XPT_Do8(cursor, &pd->flags) ||
-        !DoTypeDescriptor(arena, cursor, &pd->type, id))
-        return false;
-
-    return true;
-}
-
-bool
-DoTypeDescriptorPrefix(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                       XPTTypeDescriptorPrefix *tdp)
-{
-    return XPT_Do8(cursor, &tdp->flags);
-}
-
-bool
-DoTypeDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
-                 XPTTypeDescriptor *td, XPTInterfaceDescriptor *id)
-{
-    if (!DoTypeDescriptorPrefix(arena, cursor, &td->prefix)) {
-        return false;
-    }
-
-    switch (td->Tag()) {
-      case TD_INTERFACE_TYPE:
-        uint16_t iface;
-        if (!XPT_Do16(cursor, &iface))
-            return false;
-        td->u.iface.iface_hi8 = (iface >> 8) & 0xff;
-        td->u.iface.iface_lo8 = iface & 0xff;
-        break;
-      case TD_INTERFACE_IS_TYPE:
-        if (!XPT_Do8(cursor, &td->u.interface_is.argnum))
-            return false;
-        break;
-      case TD_ARRAY: {
-        // argnum2 appears in the on-disk format but it isn't used.
-        uint8_t argnum2 = 0;
-        if (!XPT_Do8(cursor, &td->u.array.argnum) ||
-            !XPT_Do8(cursor, &argnum2))
-            return false;
-
-        XPTTypeDescriptor elementTypeDescriptor;
-        if (!DoTypeDescriptor(arena, cursor, &elementTypeDescriptor, id))
-            return false;
-        if (!InterfaceDescriptorAddType(arena, id, &elementTypeDescriptor))
-            return false;
-        td->u.array.additional_type = id->num_additional_types - 1;
-
-        break;
-      }
-      case TD_PSTRING_SIZE_IS:
-      case TD_PWSTRING_SIZE_IS: {
-        // argnum2 appears in the on-disk format but it isn't used.
-        uint8_t argnum2 = 0;
-        if (!XPT_Do8(cursor, &td->u.pstring_is.argnum) ||
-            !XPT_Do8(cursor, &argnum2))
-            return false;
-        break;
-      }
-      default:
-        /* nothing special */
-        break;
-    }
-    return true;
-}
-
-bool
-SkipAnnotation(NotNull<XPTCursor*> cursor, bool *isLast)
-{
-    uint8_t flags;
-    if (!XPT_Do8(cursor, &flags))
-        return false;
-
-    *isLast = XPT_ANN_IS_LAST(flags);
-
-    if (XPT_ANN_IS_PRIVATE(flags)) {
-        if (!XPT_SkipStringInline(cursor) ||
-            !XPT_SkipStringInline(cursor))
-            return false;
-    }
-
-    return true;
-}
-
deleted file mode 100644
--- a/xpcom/typelib/xpt/xpt_xdr.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=8 sts=4 et sw=4 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* Implementation of XDR primitives. */
-
-#include "xpt_xdr.h"
-#include "nscore.h"
-#include <string.h>             /* strchr */
-#include "mozilla/Assertions.h"
-#include "mozilla/EndianUtils.h"
-
-static size_t
-CursPoolOffsetRaw(NotNull<XPTCursor*> cursor)
-{
-    if (cursor->pool == XPT_HEADER) {
-        return cursor->offset;
-    }
-    MOZ_ASSERT(cursor->state->data_offset);
-    return cursor->offset + cursor->state->data_offset;
-}
-
-static size_t
-CursPoolOffset(NotNull<XPTCursor*> cursor)
-{
-    return CursPoolOffsetRaw(cursor) - 1;
-}
-
-static char*
-CursPoint(NotNull<XPTCursor*> cursor)
-{
-    return &cursor->state->pool_data[CursPoolOffset(cursor)];
-}
-
-static bool
-CheckCount(NotNull<XPTCursor*> cursor, uint32_t space)
-{
-    // Fail if we're in the data area and about to exceed the allocation.
-    // XXX Also fail if we're in the data area and !state->data_offset
-    if (cursor->pool == XPT_DATA &&
-        (CursPoolOffset(cursor) + space > cursor->state->pool_allocated)) {
-        MOZ_ASSERT(false);
-        fprintf(stderr, "FATAL: no room for %u in cursor\n", space);
-        return false;
-    }
-
-    return true;
-}
-
-void
-XPT_InitXDRState(XPTState* state, char *data, uint32_t len)
-{
-    state->next_cursor[0] = state->next_cursor[1] = 1;
-    state->pool_data = data;
-    state->pool_allocated = len;
-}
-
-/* All offsets are 1-based */
-void
-XPT_SetDataOffset(XPTState *state, uint32_t data_offset)
-{
-   state->data_offset = data_offset;
-}
-
-bool
-XPT_MakeCursor(XPTState *state, XPTPool pool, uint32_t len,
-               NotNull<XPTCursor*> cursor)
-{
-    cursor->state = state;
-    cursor->pool = pool;
-    cursor->bits = 0;
-    cursor->offset = state->next_cursor[pool];
-
-    if (!(CheckCount(cursor, len)))
-        return false;
-
-    /* this check should be in CHECK_CURSOR */
-    if (pool == XPT_DATA && !state->data_offset) {
-        fprintf(stderr, "no data offset for XPT_DATA cursor!\n");
-        return false;
-    }
-
-    state->next_cursor[pool] += len;
-
-    return true;
-}
-
-bool
-XPT_SeekTo(NotNull<XPTCursor*> cursor, uint32_t offset)
-{
-    /* XXX do some real checking and update len and stuff */
-    cursor->offset = offset;
-    return true;
-}
-
-bool
-XPT_SkipStringInline(NotNull<XPTCursor*> cursor)
-{
-    uint16_t length;
-    if (!XPT_Do16(cursor, &length))
-        return false;
-
-    uint8_t byte;
-    for (uint16_t i = 0; i < length; i++)
-        if (!XPT_Do8(cursor, &byte))
-            return false;
-
-    return true;
-}
-
-bool
-XPT_DoCString(XPTArena *arena, NotNull<XPTCursor*> cursor, const char **identp,
-              bool ignore)
-{
-    uint32_t offset = 0;
-    if (!XPT_Do32(cursor, &offset))
-        return false;
-
-    if (!offset) {
-        *identp = NULL;
-        return true;
-    }
-
-    XPTCursor my_cursor;
-    my_cursor.pool = XPT_DATA;
-    my_cursor.offset = offset;
-    my_cursor.state = cursor->state;
-    char* start = CursPoint(WrapNotNull(&my_cursor));
-
-    char* end = strchr(start, 0); /* find the end of the string */
-    if (!end) {
-        fprintf(stderr, "didn't find end of string on decode!\n");
-        return false;
-    }
-    int len = end - start;
-    MOZ_ASSERT(len > 0);
-
-    if (!ignore) {
-        char *ident = (char*)XPT_CALLOC1(arena, len + 1u);
-        if (!ident)
-            return false;
-
-        memcpy(ident, start, (size_t)len);
-        ident[len] = 0;
-        *identp = ident;
-    }
-
-    return true;
-}
-
-/*
- * IIDs are written in struct order, in the usual big-endian way.  From the
- * typelib file spec:
- *
- *   "For example, this IID:
- *     {00112233-4455-6677-8899-aabbccddeeff}
- *   is converted to the 128-bit value
- *     0x00112233445566778899aabbccddeeff
- *   Note that the byte storage order corresponds to the layout of the nsIID
- *   C-struct on a big-endian architecture."
- *
- * (http://www.mozilla.org/scriptable/typelib_file.html#iid)
- */
-bool
-XPT_DoIID(NotNull<XPTCursor*> cursor, nsID *iidp)
-{
-    int i;
-
-    if (!XPT_Do32(cursor, &iidp->m0) ||
-        !XPT_Do16(cursor, &iidp->m1) ||
-        !XPT_Do16(cursor, &iidp->m2))
-        return false;
-
-    for (i = 0; i < 8; i++)
-        if (!XPT_Do8(cursor, (uint8_t *)&iidp->m3[i]))
-            return false;
-
-    return true;
-}
-
-// MSVC apparently cannot handle functions as template parameters very well,
-// so we need to use a macro approach here.
-
-#define XPT_DOINT(T, func, valuep)                \
-    do {                                          \
-        const size_t sz = sizeof(T);              \
-                                                  \
-        if (!CheckCount(cursor, sz)) {            \
-            return false;                         \
-        }                                         \
-                                                  \
-        *valuep = func(CursPoint(cursor));        \
-        cursor->offset += sz;                     \
-        return true;                              \
-    } while(0)
-
-bool
-XPT_Do64(NotNull<XPTCursor*> cursor, int64_t *u64p)
-{
-    XPT_DOINT(int64_t, mozilla::BigEndian::readInt64, u64p);
-}
-
-/*
- * When we're handling 32- or 16-bit quantities, we handle a byte at a time to
- * avoid alignment issues.  Someone could come and optimize this to detect
- * well-aligned cases and do a single store, if they cared.  I might care
- * later.
- */
-bool
-XPT_Do32(NotNull<XPTCursor*> cursor, uint32_t *u32p)
-{
-    XPT_DOINT(uint32_t, mozilla::BigEndian::readUint32, u32p);
-}
-
-bool
-XPT_Do16(NotNull<XPTCursor*> cursor, uint16_t *u16p)
-{
-    XPT_DOINT(uint16_t, mozilla::BigEndian::readUint16, u16p);
-}
-
-#undef XPT_DOINT
-
-bool
-XPT_Do8(NotNull<XPTCursor*> cursor, uint8_t *u8p)
-{
-    if (!CheckCount(cursor, 1))
-        return false;
-
-    *u8p = *CursPoint(cursor);
-
-    cursor->offset++;
-
-    return true;
-}
-
-
deleted file mode 100644
--- a/xpcom/typelib/xpt/xpt_xdr.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=8 sts=4 et sw=4 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Basic APIs for streaming typelib structures from disk.
- */
-
-#ifndef __xpt_xdr_h__
-#define __xpt_xdr_h__
-
-#include "xpt_struct.h"
-#include "mozilla/NotNull.h"
-
-using mozilla::NotNull;
-
-struct XPTArena;
-struct XPTCursor;
-struct XPTState;
-
-bool
-XPT_SkipStringInline(NotNull<XPTCursor*> cursor);
-
-bool
-XPT_DoCString(XPTArena *arena, NotNull<XPTCursor*> cursor, const char **strp,
-              bool ignore = false);
-
-bool
-XPT_DoIID(NotNull<XPTCursor*> cursor, nsID *iidp);
-
-bool
-XPT_Do64(NotNull<XPTCursor*> cursor, int64_t *u64p);
-
-bool
-XPT_Do32(NotNull<XPTCursor*> cursor, uint32_t *u32p);
-
-bool
-XPT_Do16(NotNull<XPTCursor*> cursor, uint16_t *u16p);
-
-bool
-XPT_Do8(NotNull<XPTCursor*> cursor, uint8_t *u8p);
-
-bool
-XPT_DoHeader(XPTArena *arena, NotNull<XPTCursor*> cursor, XPTHeader **headerp);
-
-enum XPTPool {
-    XPT_HEADER = 0,
-    XPT_DATA = 1
-};
-
-struct XPTState {
-    uint32_t         data_offset;
-    uint32_t         next_cursor[2];
-    char             *pool_data;
-    uint32_t         pool_allocated;
-};
-
-struct XPTCursor {
-    XPTState    *state;
-    XPTPool     pool;
-    uint32_t    offset;
-    uint8_t     bits;
-};
-
-void
-XPT_InitXDRState(XPTState* state, char* data, uint32_t len);
-
-bool
-XPT_MakeCursor(XPTState *state, XPTPool pool, uint32_t len,
-               NotNull<XPTCursor*> cursor);
-
-bool
-XPT_SeekTo(NotNull<XPTCursor*> cursor, uint32_t offset);
-
-void
-XPT_SetDataOffset(XPTState *state, uint32_t data_offset);
-
-#endif /* __xpt_xdr_h__ */