source: trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl-driver.c

Last change on this file was 92, checked in by cinc, 19 years ago

Orbit2 modified for use with NOM

File size: 2.6 KB
Line 
1/**************************************************************************
2
3 orbit-idl-driver.c (Dispatch parsed tree to various backends)
4
5 Copyright (C) 1999 Elliot Lee
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 $Id: orbit-idl-driver.c,v 1.26 2002/09/04 10:38:18 mmclouglin Exp $
22
23***************************************************************************/
24
25#include "config.h"
26
27#include "orbit-idl2.h"
28#include "orbit-idl-backend.h"
29#include "orbit-idl-c-backend.h"
30
31#include <string.h>
32
33static void
34orbit_idl_tree_fake_ops (IDL_tree tree, IDL_ns ns)
35{
36 IDL_tree node;
37
38 if (!tree)
39 return;
40
41 switch(IDL_NODE_TYPE(tree)) {
42 case IDLN_MODULE:
43 orbit_idl_tree_fake_ops (IDL_MODULE (tree).definition_list, ns);
44 break;
45 case IDLN_INTERFACE:
46 orbit_idl_tree_fake_ops (IDL_INTERFACE (tree).body, ns);
47 break;
48 case IDLN_LIST:
49 for (node = tree; node; node = IDL_LIST (node).next)
50 orbit_idl_tree_fake_ops (IDL_LIST (node).data, ns);
51 break;
52 case IDLN_ATTR_DCL:
53 orbit_idl_attr_fake_ops (tree, ns);
54 break;
55 default:
56 break;
57 }
58}
59
60gboolean
61orbit_idl_to_backend (const char *filename,
62 OIDL_Run_Info *rinfo)
63{
64 IDL_ns ns;
65 IDL_tree tree;
66 int errcode;
67 gboolean retval;
68
69 errcode = IDL_parse_filename (
70 filename, rinfo->cpp_args, NULL,
71 &tree, &ns,
72 (rinfo->show_cpp_errors ? IDLF_SHOW_CPP_ERRORS : 0) |
73 (rinfo->is_pidl ? IDLF_XPIDL : 0) |
74 (rinfo->onlytop ? IDLF_INHIBIT_INCLUDES : 0) |
75 IDLF_TYPECODES |
76 IDLF_SRCFILES |
77 IDLF_CODEFRAGS,
78 rinfo->idl_warn_level);
79
80 rinfo->ns = ns;
81
82 if (rinfo->debug_level > 3)
83 orbit_idl_print_node (tree, 0);
84
85 if (errcode != IDL_SUCCESS) {
86 if (errcode == -1)
87 g_warning ("Parse of %s failed: %s", filename, g_strerror (errno));
88
89 return 0;
90 }
91
92 orbit_idl_tree_fake_ops (tree, ns);
93
94 if (!strcmp (rinfo->output_language, "c"))
95 retval = orbit_idl_output_c (tree, rinfo);
96 else
97 retval = orbit_idl_backend_output (rinfo, tree);
98
99 return retval;
100}
Note: See TracBrowser for help on using the repository browser.