]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/forb/forb-idl/forb-idl-driver.c
adc860f45fd8baad4e4477931d7f984370ed7b34
[frescor/frsh-forb.git] / src / forb / forb-idl / forb-idl-driver.c
1 /**************************************************************************
2
3     forb-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: forb-idl-driver.c 1302 2002-09-04 10:38:18Z mmclouglin $
22
23 ***************************************************************************/
24
25 #include "config.h"
26
27 #include "forb-idl2.h"
28 #include "forb-idl-backend.h"
29 #include "forb-idl-c-backend.h"
30
31 #include <string.h>
32
33 static void
34 forb_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                 forb_idl_tree_fake_ops (IDL_MODULE (tree).definition_list, ns);
44                 break;
45         case IDLN_INTERFACE:
46                 forb_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                         forb_idl_tree_fake_ops (IDL_LIST (node).data, ns);
51                 break;
52         case IDLN_ATTR_DCL:
53                 forb_idl_attr_fake_ops (tree, ns);
54                 break;
55         default:
56                 break;
57         }
58 }
59
60 gboolean
61 forb_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                 forb_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         forb_idl_tree_fake_ops (tree, ns);
93
94         if (!strcmp (rinfo->output_language, "c")) 
95                 retval = forb_idl_output_c (tree, rinfo);
96 //      else
97 //              retval = forb_idl_backend_output (rinfo, tree);
98
99         return retval;
100 }