Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
xpidl.h File Reference
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <string.h>
#include <libIDL/IDL.h>
#include <xpt_struct.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  backend
struct  ModeData
struct  IncludePathEntry
struct  TreeState
struct  java_priv_data

Defines

#define XPIDL_WARNING(x)   IDL_tree_warning x
#define UUID_LENGTH   37
#define UP_IS_AGGREGATE(node)
#define UP_IS_NATIVE(node)
#define STARRED_TYPE(node)
#define DIPPER_TYPE(node)

Typedefs

typedef struct TreeState
typedef gboolean(* nodeHandler )(TreeState *)
typedef struct backend backend
typedef backend *(* backendFactory )()
typedef struct ModeData ModeData
typedef struct IncludePathEntry IncludePathEntry

Functions

backendxpidl_header_dispatch (void)
backendxpidl_typelib_dispatch (void)
backendxpidl_doc_dispatch (void)
backendxpidl_java_dispatch (void)
int xpidl_process_idl (char *filename, IncludePathEntry *include_path, char *file_basename, ModeData *mode)
void xpidl_list_foreach (IDL_tree p, IDL_tree_func foreach, gpointer user_data)
voidxpidl_malloc (size_t nbytes)
char * xpidl_strdup (const char *s)
const char * xpidl_basename (const char *path)
gboolean xpidl_process_node (TreeState *state)
void xpidl_write_comment (TreeState *state, int indent)
gboolean xpidl_sprint_iid (nsID *iid, char iidbuf[])
gboolean xpidl_parse_iid (nsID *id, const char *str)
IDL_tree find_underlying_type (IDL_tree typedef_ident)
gboolean verify_const_declaration (IDL_tree const_tree)
gboolean verify_attribute_declaration (IDL_tree method_tree)
gboolean verify_method_declaration (IDL_tree method_tree)
gboolean verify_interface_declaration (IDL_tree method_tree)
gboolean check_native (TreeState *state)
void printlist (FILE *outfile, GSList *slist)

Variables

gboolean enable_debug
gboolean enable_warnings
gboolean verbose_mode
gboolean emit_typelib_annotations
gboolean explicit_output_filename
PRUint8 major_version
PRUint8 minor_version

Class Documentation

struct backend

Definition at line 102 of file xpidl.h.

Collaboration diagram for backend:
Class Members
nodeHandler * dispatch_table
nodeHandler emit_epilog
nodeHandler emit_prolog
struct ModeData

Definition at line 116 of file xpidl.h.

Collaboration diagram for ModeData:
Class Members
backendFactory factory
char * mode
char * modeInfo
char * suffix
struct IncludePathEntry

Definition at line 123 of file xpidl.h.

Collaboration diagram for IncludePathEntry:
Class Members
char * directory
struct IncludePathEntry * next
struct TreeState

Definition at line 128 of file xpidl.h.

Class Members
GSList * base_includes
char * basename
nodeHandler * dispatch
FILE * file
char * filename
IDL_ns ns
char * package
void * priv
IDL_tree tree
struct java_priv_data

Definition at line 142 of file xpidl.h.

Collaboration diagram for java_priv_data:
Class Members
gboolean bCountingMethods
gboolean bHasBaseClass
char * filename
GHashTable * keywords
GHashTable * nonIDLIfaces
int numMethods
GHashTable * typedefTable

Define Documentation

#define DIPPER_TYPE (   node)
Value:
(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"))

Definition at line 233 of file xpidl.h.

#define STARRED_TYPE (   node)
Value:
(IDL_NODE_TYPE(node) == IDLN_TYPE_STRING ||        \
                            IDL_NODE_TYPE(node) == IDLN_TYPE_WIDE_STRING ||   \
                            (IDL_NODE_TYPE(node) == IDLN_IDENT &&             \
                             UP_IS_AGGREGATE(node)))

Definition at line 228 of file xpidl.h.

#define UP_IS_AGGREGATE (   node)
Value:
(IDL_NODE_UP(node) &&                                                     \
     (IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_INTERFACE ||                   \
      IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_FORWARD_DCL))

Definition at line 218 of file xpidl.h.

#define UP_IS_NATIVE (   node)
Value:
(IDL_NODE_UP(node) &&                                                     \
     IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_NATIVE)

Definition at line 223 of file xpidl.h.

#define UUID_LENGTH   37

Definition at line 198 of file xpidl.h.

#define XPIDL_WARNING (   x)    IDL_tree_warning x

Definition at line 74 of file xpidl.h.


Typedef Documentation

typedef struct backend backend
typedef backend*(* backendFactory)()

Definition at line 109 of file xpidl.h.

typedef struct ModeData ModeData
typedef gboolean(* nodeHandler)(TreeState *)

Definition at line 97 of file xpidl.h.

typedef struct TreeState

Definition at line 92 of file xpidl.h.


Function Documentation

gboolean check_native ( TreeState state)

Definition at line 767 of file xpidl_util.c.

{
    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;
}
IDL_tree find_underlying_type ( IDL_tree  typedef_ident)

Definition at line 368 of file xpidl_util.c.

{
    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;
}
void printlist ( FILE outfile,
GSList *  slist 
)

Definition at line 784 of file xpidl_util.c.

{
    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));
    }
}

Here is the call graph for this function:

gboolean verify_attribute_declaration ( IDL_tree  method_tree)

Definition at line 250 of file xpidl_util.c.

{
    IDL_tree iface;
    IDL_tree ident;
    IDL_tree attr_type;
    gboolean scriptable_interface;

    /* 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 it's 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;
    }
    /* 
     * Verify that we've been called on an interface, and decide if the
     * interface was marked [scriptable].
     */
    if (IDL_NODE_UP(attr_tree) && IDL_NODE_UP(IDL_NODE_UP(attr_tree)) &&
        IDL_NODE_TYPE(iface = IDL_NODE_UP(IDL_NODE_UP(attr_tree))) 
        == IDLN_INTERFACE)
    {
        scriptable_interface =
            (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable")
             != NULL);
    } else {
        IDL_tree_error(attr_tree,
                    "verify_attribute_declaration called on a non-interface?");
        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.
     */
    if (!scriptable_interface ||
        IDL_tree_property_get(ident, "noscript") != NULL)
        return TRUE;

    /*
     * 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_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;
        }

        /* 
         * 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;
}

Here is the call graph for this function:

gboolean verify_const_declaration ( IDL_tree  const_tree)

Definition at line 163 of file xpidl_util.c.

                                              {
    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;
}

Here is the call graph for this function:

gboolean verify_interface_declaration ( IDL_tree  method_tree)

Definition at line 813 of file xpidl_util.c.

{
    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 fall through here
     */
    if (IDL_tree_property_get(IDL_INTERFACE(interface_tree).ident, 
        "scriptable")) {
        for (iter = IDL_INTERFACE(interface_tree).inheritance_spec; iter; 
            iter = IDL_LIST(iter).next) {
            if (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));
            }
        }
    }
    return TRUE;
}
gboolean verify_method_declaration ( IDL_tree  method_tree)

Definition at line 498 of file xpidl_util.c.

{
    struct _IDL_OP_DCL *op = &IDL_OP_DCL(method_tree);
    IDL_tree iface;
    IDL_tree iter;
    gboolean notxpcom;
    gboolean scriptable_interface;
    gboolean scriptable_method;
    gboolean seen_retval = 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 it's 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;
    }

    /* 
     * Verify that we've been called on an interface, and decide if the
     * interface was marked [scriptable].
     */
    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,
                       "verify_method_declaration called on a non-interface?");
        return FALSE;
    }

    /*
     * Require that any method in an interface marked as [scriptable], that
     * *isn't* scriptable because it refers to some native type, be marked
     * [noscript] or [notxpcom].
     *
     * Also check that iid_is points to nsid, and length_is, size_is points
     * to unsigned long.
     */
    notxpcom = IDL_tree_property_get(op->ident, "notxpcom") != NULL;

    scriptable_method = scriptable_interface &&
        !notxpcom &&
        IDL_tree_property_get(op->ident, "noscript") == 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_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_error(method_tree,
                               "[shared] parameter \"%s\" must be of type "
                               "string, wstring or native", param_name);
                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;
        
    }
    
    /* 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_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;
}

Here is the call graph for this function:

const char* xpidl_basename ( const char *  path)

Definition at line 841 of file xpidl_util.c.

{
    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;
}

Definition at line 288 of file xpidl_doc.c.

{
    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;
}

Here is the call graph for this function:

Definition at line 1169 of file xpidl_header.c.

{
    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;
}

Here is the call graph for this function:

Definition at line 982 of file xpidl_java.c.

{
    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;
}

Here is the call graph for this function:

void xpidl_list_foreach ( IDL_tree  p,
IDL_tree_func  foreach,
gpointer  user_data 
)

Definition at line 796 of file xpidl_util.c.

{
    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;
    }
}

Here is the call graph for this function:

void* xpidl_malloc ( size_t  nbytes)

Definition at line 47 of file xpidl_util.c.

{
    void *p = malloc(nbytes);
    if (!p) {
        fputs(OOM, stderr);
        exit(1);
    }
    return p;
}

Here is the call graph for this function:

gboolean xpidl_parse_iid ( nsID id,
const char *  str 
)

Definition at line 124 of file xpidl_util.c.

{
    PRInt32 count = 0;
    PRInt32 n1, n2, n3[8];
    PRInt32 n0, 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 = (PRInt32) n0;
    id->m1 = (PRInt16) n1;
    id->m2 = (PRInt16) n2;
    for (i = 0; i < 8; i++) {
      id->m3[i] = (PRInt8) 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);
}

Here is the call graph for this function:

int xpidl_process_idl ( char *  filename,
IncludePathEntry include_path,
char *  file_basename,
ModeData mode 
)

Definition at line 660 of file xpidl_idl.c.

{
    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 {
/* 
 *This combination seems a little strange, what about OS/2?
 * Assume it's some build issue
 */
#if defined(XP_UNIX) || defined(XP_WIN)
            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;
}

Here is the call graph for this function:

gboolean xpidl_process_node ( TreeState state)

Definition at line 56 of file xpidl_idl.c.

{
    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;
}
gboolean xpidl_sprint_iid ( nsID iid,
char  iidbuf[] 
)

Definition at line 96 of file xpidl_util.c.

{
    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
}
char* xpidl_strdup ( const char *  s)

Definition at line 70 of file xpidl_util.c.

{
    char *ns = strdup(s);
    if (!ns) {
        fputs(OOM, stderr);
        exit(1);
    }
    return ns;
}

Here is the call graph for this function:

Definition at line 1206 of file xpidl_typelib.c.

{
    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;
}

Here is the call graph for this function:

void xpidl_write_comment ( TreeState state,
int  indent 
)

Definition at line 81 of file xpidl_util.c.

{
    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);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 66 of file xpidl.c.

gboolean enable_debug

Definition at line 63 of file xpidl.c.

gboolean enable_warnings

Definition at line 64 of file xpidl.c.

Definition at line 67 of file xpidl.c.

Definition at line 70 of file xpidl.c.

Definition at line 71 of file xpidl.c.

gboolean verbose_mode

Definition at line 65 of file xpidl.c.