VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl.h

Last change on this file was 103140, checked in by vboxsync, 4 months ago

libs/xpcom: Some warning fixes about externally visible functions which should be static, bugref:3409

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Netscape Public License
6 * Version 1.1 (the "License"); you may not use this file except in
7 * compliance with the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/NPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the NPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the NPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38/*
39 * Intramodule declarations.
40 */
41
42#ifndef __xpidl_h
43#define __xpidl_h
44
45#include <errno.h>
46#include <stddef.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <glib.h>
50#include <string.h> /* After glib.h to avoid warnings about shadowing 'index'. */
51
52#ifndef XP_MAC
53#include <libIDL/IDL.h>
54#else
55#include <IDL.h>
56#endif
57
58#include <xpt_struct.h>
59
60#define XPIDL_WARNING(x) IDL_tree_warning x
61
62/*
63 * Internal operation flags.
64 */
65extern gboolean enable_debug;
66extern gboolean enable_warnings;
67extern gboolean verbose_mode;
68extern gboolean emit_typelib_annotations;
69extern gboolean explicit_output_filename;
70
71extern PRUint8 major_version;
72extern PRUint8 minor_version;
73
74typedef struct TreeState TreeState;
75
76/*
77 * A function to handle an IDL_tree type.
78 */
79typedef gboolean (*nodeHandler)(TreeState *);
80
81/*
82 * Struct containing functions to define the behavior of a given output mode.
83 */
84typedef struct backend {
85 nodeHandler *dispatch_table; /* nodeHandlers table, indexed by node type. */
86 nodeHandler emit_prolog; /* called at beginning of output generation. */
87 nodeHandler emit_epilog; /* called at end. */
88} backend;
89
90/* Function that produces a struct of output-generation functions */
91typedef backend *(*backendFactory)();
92
93extern backend *xpidl_header_dispatch(void);
94extern backend *xpidl_typelib_dispatch(void);
95extern backend *xpidl_doc_dispatch(void);
96extern backend *xpidl_java_dispatch(void);
97
98typedef struct ModeData {
99 char *mode;
100 char *modeInfo;
101 char *suffix;
102 backendFactory factory;
103} ModeData;
104
105typedef struct IncludePathEntry {
106 char *directory;
107 struct IncludePathEntry *next;
108} IncludePathEntry;
109
110struct TreeState {
111 FILE *file;
112 /* Maybe supplied by -o. Not related to (g_)basename from string.h or glib */
113 char *basename;
114 IDL_ns ns;
115 IDL_tree tree;
116 GSList *base_includes;
117 nodeHandler *dispatch;
118 void *priv; /* mode-private data */
119#ifdef VBOX_XPIDL_EMULATE_GENJIFACES
120 char *real_outname;
121#endif
122
123};
124
125/*
126 * Process an IDL file, generating InterfaceInfo, documentation and headers as
127 * appropriate.
128 */
129int
130xpidl_process_idl(char *filename, IncludePathEntry *include_path,
131 char *file_basename, ModeData *mode);
132
133/*
134 * Iterate over an IDLN_LIST -- why is this not part of libIDL?
135 */
136void
137xpidl_list_foreach(IDL_tree p, IDL_tree_func foreach, gpointer user_data);
138
139/*
140 * Wrapper whines to stderr then exits after null return from malloc or strdup.
141 */
142void *
143xpidl_malloc(size_t nbytes);
144
145char *
146xpidl_strdup(const char *s);
147
148/*
149 * Return a newly allocated string to the start of the base filename of path.
150 * Free with g_free().
151 */
152char *
153xpidl_basename(const char * path);
154
155/*
156 * Process an XPIDL node and its kids, if any.
157 */
158gboolean
159xpidl_process_node(TreeState *state);
160
161/*
162 * Write a newline folllowed by an indented, one-line comment containing IDL
163 * source decompiled from state->tree.
164 */
165void
166xpidl_write_comment(TreeState *state, int indent);
167
168
169
170/*
171 * Functions for parsing and printing UUIDs.
172 */
173
174/*
175 * How large should the buffer supplied to xpidl_sprint_IID be?
176 */
177#define UUID_LENGTH 37
178
179/*
180 * Print an iid to into a supplied buffer; the buffer should be at least
181 * UUID_LENGTH bytes.
182 */
183gboolean
184xpidl_sprint_iid(nsID *iid, char iidbuf[]);
185
186/*
187 * Parse a uuid string into an nsID struct. We cannot link against libxpcom,
188 * so we re-implement nsID::Parse here.
189 */
190gboolean
191xpidl_parse_iid(nsID *id, const char *str);
192
193
194/* Try to common a little node-handling stuff. */
195
196/* is this node from an aggregate type (interface)? */
197#define UP_IS_AGGREGATE(node) \
198 (IDL_NODE_UP(node) && \
199 (IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_INTERFACE || \
200 IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_FORWARD_DCL))
201
202#define UP_IS_NATIVE(node) \
203 (IDL_NODE_UP(node) && \
204 IDL_NODE_TYPE(IDL_NODE_UP(node)) == IDLN_NATIVE)
205
206/* is this type output in the form "<foo> *"? */
207#define STARRED_TYPE(node) (IDL_NODE_TYPE(node) == IDLN_TYPE_STRING || \
208 IDL_NODE_TYPE(node) == IDLN_TYPE_WIDE_STRING || \
209 (IDL_NODE_TYPE(node) == IDLN_IDENT && \
210 UP_IS_AGGREGATE(node)))
211
212#define DIPPER_TYPE(node) \
213 (NULL != IDL_tree_property_get(node, "domstring") || \
214 NULL != IDL_tree_property_get(node, "utf8string") || \
215 NULL != IDL_tree_property_get(node, "cstring") || \
216 NULL != IDL_tree_property_get(node, "astring"))
217
218/*
219 * Find the underlying type of an identifier typedef. Returns NULL
220 * (and doesn't complain) on failure.
221 */
222IDL_tree /* IDL_TYPE_DCL */
223find_underlying_type(IDL_tree typedef_ident);
224
225/*
226 * Check that const declarations match their stated sign and are of the
227 * appropriate types.
228 */
229gboolean
230verify_const_declaration(IDL_tree const_tree);
231
232/*
233 * Check that scriptable attributes in scriptable interfaces actually are.
234 */
235gboolean
236verify_attribute_declaration(IDL_tree method_tree);
237
238/*
239 * Perform various validation checks on methods.
240 */
241gboolean
242verify_method_declaration(IDL_tree method_tree);
243
244/*
245 * Verifies the interface declaration
246 */
247gboolean
248verify_interface_declaration(IDL_tree method_tree);
249
250/*
251 * Verify that a native declaration has an associated C++ expression, i.e. that
252 * it's of the form native <idl-name>(<c++-name>)
253 */
254gboolean
255check_native(TreeState *state);
256
257void
258printlist(FILE *outfile, GSList *slist);
259
260#endif /* __xpidl_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use