]> rtime.felk.cvut.cz Git - orte.git/blob - orte/idl-compiler/orte-idl-driver.c
85f8a043483cd1d596785884aac13f41e2c7e3cb
[orte.git] / orte / idl-compiler / orte-idl-driver.c
1 /**************************************************************************
2
3     orte-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: orte-idl-driver.c,v 1.2 2005/03/11 16:46:22 smolik Exp $
22
23 ***************************************************************************/
24
25 //#include "config.h"
26
27 #include "orte-idl2.h"
28 #include "orte-idl-c-backend.h"
29
30 #include <string.h>
31
32 static void
33 orte_idl_tree_fake_ops (IDL_tree tree, IDL_ns ns)
34 {
35         IDL_tree node;
36
37         if (!tree)
38                 return;
39
40         switch(IDL_NODE_TYPE(tree)) {
41         case IDLN_MODULE:
42                 orte_idl_tree_fake_ops (IDL_MODULE (tree).definition_list, ns);
43                 break;
44         case IDLN_INTERFACE:
45                 orte_idl_tree_fake_ops (IDL_INTERFACE (tree).body, ns);
46                 break;
47         case IDLN_LIST:
48                 for (node = tree; node; node = IDL_LIST (node).next)
49                         orte_idl_tree_fake_ops (IDL_LIST (node).data, ns);
50                 break;
51         case IDLN_ATTR_DCL:
52                 orte_idl_attr_fake_ops (tree, ns);
53                 break;
54         default:
55                 break;
56         }
57 }
58
59 gboolean
60 orte_idl_to_backend (const char    *filename,
61                       OIDL_Run_Info *rinfo)
62 {
63         IDL_ns   ns;
64         IDL_tree tree;
65         int      errcode;
66         gboolean retval;
67
68         errcode = IDL_parse_filename (
69                         filename, rinfo->cpp_args, NULL,
70                         &tree, &ns,
71                         (rinfo->show_cpp_errors ? IDLF_SHOW_CPP_ERRORS : 0) |
72                         (rinfo->is_pidl ? IDLF_XPIDL : 0) |
73                         (rinfo->onlytop ? IDLF_INHIBIT_INCLUDES : 0) |
74                         IDLF_TYPECODES |
75                         IDLF_SRCFILES |
76                         IDLF_CODEFRAGS,
77                         rinfo->idl_warn_level);
78
79         rinfo->ns = ns;
80
81         if (rinfo->debug_level > 3)
82                 orte_idl_print_node (tree, 0);
83
84         if (errcode != IDL_SUCCESS) {
85                 if (errcode == -1)
86                         g_warning ("Parse of %s failed: %s", filename, g_strerror (errno));
87
88                 return 0;
89         }
90
91         orte_idl_tree_fake_ops (tree, ns);
92
93         if (!strcmp (rinfo->output_language, "c")) 
94                 retval = orte_idl_output_c (tree, rinfo);
95 /*      else
96                 retval = orte_idl_backend_output (rinfo, tree);
97 */
98         return retval;
99 }