1998-12-03 09:33:59 +03:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
1998-11-28 19:52:24 +03:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Intramodule declarations.
|
|
|
|
*/
|
|
|
|
|
1998-11-24 00:02:31 +03:00
|
|
|
#ifndef __xpidl_h
|
|
|
|
#define __xpidl_h
|
|
|
|
|
1999-02-17 04:17:52 +03:00
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
1998-11-24 00:02:31 +03:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
1999-02-17 04:17:52 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <glib.h>
|
1999-06-10 12:21:35 +04:00
|
|
|
#include <string.h> /* After glib.h to avoid warnings about shadowing 'index'. */
|
1999-04-11 04:09:14 +04:00
|
|
|
|
|
|
|
#ifndef XP_MAC
|
1998-11-24 00:02:31 +03:00
|
|
|
#include <libIDL/IDL.h>
|
1999-04-11 04:09:14 +04:00
|
|
|
#else
|
|
|
|
#include <IDL.h>
|
|
|
|
#endif
|
1998-11-24 00:02:31 +03:00
|
|
|
|
1999-08-22 05:10:14 +04:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* ## idiom, which allows us to pass through varargs calls.
|
|
|
|
*/
|
|
|
|
#if !(LIBIDL_MAJOR_VERSION == 0 && LIBIDL_MINOR_VERSION == 6 && \
|
1999-10-27 04:37:39 +04:00
|
|
|
LIBIDL_MICRO_VERSION == 5) && !defined(DEBUG_shaver)
|
1999-08-22 05:10:14 +04:00
|
|
|
/*
|
1999-10-27 04:37:39 +04:00
|
|
|
* 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"))
|
1999-08-22 05:10:14 +04:00
|
|
|
*
|
1999-10-27 04:37:39 +04:00
|
|
|
* Probably best removed when we leave 6.5. */
|
1999-08-22 05:10:14 +04:00
|
|
|
#define XPIDL_WARNING(x) IDL_tree_warning##x
|
|
|
|
#else
|
1999-10-27 04:37:39 +04:00
|
|
|
extern void xpidl_tree_warning(IDL_tree p, int level, const char *fmt, ...);
|
|
|
|
#define XPIDL_WARNING(x) xpidl_tree_warning##x
|
1999-08-22 05:10:14 +04:00
|
|
|
#endif
|
|
|
|
|
1998-11-24 00:02:31 +03:00
|
|
|
/*
|
|
|
|
* Internal operation flags.
|
|
|
|
*/
|
|
|
|
extern gboolean enable_debug;
|
|
|
|
extern gboolean enable_warnings;
|
|
|
|
extern gboolean verbose_mode;
|
1999-09-11 09:20:39 +04:00
|
|
|
extern gboolean emit_typelib_annotations;
|
1998-11-24 00:02:31 +03:00
|
|
|
|
1999-02-04 02:55:33 +03:00
|
|
|
typedef struct TreeState TreeState;
|
1998-11-24 00:02:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A function to handle an IDL_tree type.
|
|
|
|
*/
|
|
|
|
typedef gboolean (*nodeHandler)(TreeState *);
|
|
|
|
|
1999-02-04 02:55:33 +03:00
|
|
|
/* Function that produces a table of nodeHandlers for a given mode */
|
|
|
|
typedef nodeHandler *(*nodeHandlerFactory)();
|
1998-11-24 00:02:31 +03:00
|
|
|
|
1999-02-17 04:17:52 +03:00
|
|
|
extern nodeHandler *xpidl_header_dispatch(void);
|
|
|
|
extern nodeHandler *xpidl_typelib_dispatch(void);
|
|
|
|
extern nodeHandler *xpidl_doc_dispatch(void);
|
1999-06-23 04:58:35 +04:00
|
|
|
extern nodeHandler *xpidl_java_dispatch(void);
|
1998-11-24 00:02:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* nodeHandler that reports an error.
|
|
|
|
*/
|
|
|
|
gboolean node_is_error(TreeState *state);
|
|
|
|
|
1999-02-04 02:55:33 +03:00
|
|
|
typedef struct ModeData {
|
|
|
|
char *mode;
|
|
|
|
char *modeInfo;
|
|
|
|
char *suffix;
|
|
|
|
nodeHandlerFactory factory;
|
|
|
|
} ModeData;
|
|
|
|
|
|
|
|
typedef struct IncludePathEntry {
|
1999-02-16 06:47:24 +03:00
|
|
|
char *directory;
|
1999-02-04 02:55:33 +03:00
|
|
|
struct IncludePathEntry *next;
|
|
|
|
} IncludePathEntry;
|
|
|
|
|
|
|
|
struct TreeState {
|
1999-02-16 06:47:24 +03:00
|
|
|
FILE *file;
|
1999-06-15 13:22:04 +04:00
|
|
|
/* Maybe supplied by -o. Not related to (g_)basename from string.h or glib */
|
1999-02-16 06:47:24 +03:00
|
|
|
char *basename;
|
|
|
|
IDL_ns ns;
|
|
|
|
IDL_tree tree;
|
|
|
|
GHashTable *includes;
|
1999-02-04 02:55:33 +03:00
|
|
|
IncludePathEntry *include_path;
|
1999-02-16 06:47:24 +03:00
|
|
|
nodeHandler *dispatch;
|
|
|
|
void *priv; /* mode-private data */
|
1999-02-04 02:55:33 +03:00
|
|
|
};
|
|
|
|
|
1998-11-24 00:02:31 +03:00
|
|
|
/*
|
1998-12-06 21:41:44 +03:00
|
|
|
* Process an IDL file, generating InterfaceInfo, documentation and headers as
|
1999-06-10 12:21:35 +04:00
|
|
|
* appropriate. Use file_basename instead of basename to avoid conflict
|
|
|
|
* warnings with basename from some versions of string.h.
|
1998-11-24 00:02:31 +03:00
|
|
|
*/
|
|
|
|
int
|
1998-12-14 21:47:39 +03:00
|
|
|
xpidl_process_idl(char *filename, IncludePathEntry *include_path,
|
1999-06-10 12:21:35 +04:00
|
|
|
char *file_basename, ModeData *mode);
|
1998-11-24 00:02:31 +03:00
|
|
|
|
1998-11-27 00:03:03 +03:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
1998-11-24 00:02:31 +03:00
|
|
|
/*
|
1999-02-16 08:10:40 +03:00
|
|
|
* Wrapper whines to stderr then exits after null return from malloc or strdup.
|
1998-11-24 00:02:31 +03:00
|
|
|
*/
|
1999-02-16 08:10:40 +03:00
|
|
|
void *
|
|
|
|
xpidl_malloc(size_t nbytes);
|
1998-11-24 00:02:31 +03:00
|
|
|
|
1999-02-16 08:10:40 +03:00
|
|
|
char *
|
|
|
|
xpidl_strdup(const char *s);
|
1998-11-24 00:02:31 +03:00
|
|
|
|
1999-02-16 08:10:40 +03:00
|
|
|
/*
|
|
|
|
* Process an XPIDL node and its kids, if any.
|
|
|
|
*/
|
1999-02-16 06:47:24 +03:00
|
|
|
gboolean
|
1999-02-16 08:10:40 +03:00
|
|
|
xpidl_process_node(TreeState *state);
|
1999-01-21 21:59:52 +03:00
|
|
|
|
1999-02-17 04:17:52 +03:00
|
|
|
/*
|
1999-02-22 03:24:34 +03:00
|
|
|
* Write a newline folllowed by an indented, one-line comment containing IDL
|
|
|
|
* source decompiled from state->tree.
|
1999-02-17 04:17:52 +03:00
|
|
|
*/
|
|
|
|
void
|
1999-02-22 03:24:34 +03:00
|
|
|
xpidl_write_comment(TreeState *state, int indent);
|
1999-02-17 04:17:52 +03:00
|
|
|
|
1999-08-02 15:19:30 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions for parsing and printing UUIDs.
|
|
|
|
*/
|
1999-08-02 13:46:57 +04:00
|
|
|
#include "xpt_struct.h"
|
1999-08-02 15:19:30 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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(struct nsID *iid, char iidbuf[]);
|
|
|
|
|
1999-08-02 13:46:57 +04:00
|
|
|
/*
|
|
|
|
* Parse a uuid string into an nsID struct. We cannot link against libxpcom,
|
|
|
|
* so we re-implement nsID::Parse here.
|
|
|
|
*/
|
|
|
|
gboolean
|
1999-08-02 15:19:30 +04:00
|
|
|
xpidl_parse_iid(nsID *id, const char *str);
|
1999-08-02 13:46:57 +04:00
|
|
|
|
1999-08-10 16:18:01 +04:00
|
|
|
|
|
|
|
/* 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)
|
|
|
|
|
|
|
|
/* is this type output in the form "<foo> *"? */
|
|
|
|
#define STARRED_TYPE(node) (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)))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform various validation checks on methods.
|
|
|
|
*/
|
|
|
|
gboolean
|
1999-08-19 17:02:08 +04:00
|
|
|
verify_method_declaration(IDL_tree method_tree);
|
1999-08-10 16:18:01 +04:00
|
|
|
|
1999-10-27 04:37:39 +04:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
1998-11-24 00:02:31 +03:00
|
|
|
#endif /* __xpidl_h */
|