4 * Copyright (C) 2002 Sun Microsystems, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 * Mark McLoughlin <mark@skynet.ie>
27 #include "forb-idl-backend.h"
28 #include "forb-idl2.h"
34 prepend_from_env_var (GSList *paths,
41 if (!(val = getenv ("GNOME2_PATH")))
44 strv = g_strsplit (val, ";", -1);
45 for (i = 0; strv [i]; i++)
46 paths = g_slist_prepend (
47 paths, g_strconcat (strv [i], "/lib/forb-2.0/idl-backends", NULL));
55 static ForbIDLBackendFunc
56 load_language_backend (const char *path,
59 ForbIDLBackendFunc retval = NULL;
64 modname = g_strconcat ("forb-idl-backend-", language, NULL);
65 modpath = g_module_build_path (path, modname);
68 if (!(module = g_module_open (modpath, G_MODULE_BIND_LAZY))) {
73 if (!g_module_symbol (module, "forb_idl_backend_func", (gpointer *) &retval))
74 g_warning ("backend %s has no \"forb_idl_backend_func\" defined", modpath);
82 forb_idl_backend_output (OIDL_Run_Info *rinfo,
85 ForbIDLBackendFunc func = NULL;
86 ForbIDLBackendContext context;
90 paths = prepend_from_env_var (paths, "GNOME2_PATH");
91 paths = prepend_from_env_var (paths, "FORB_BACKENDS_PATH");
93 paths = g_slist_prepend (paths, g_strdup (FORB_BACKENDS_DIR));
95 if (rinfo->backend_directory)
96 paths = g_slist_prepend (paths, g_strdup (rinfo->backend_directory));
98 for (l = paths; l; l = l->next) {
99 func = load_language_backend (l->data, rinfo->output_language);
107 g_slist_free (paths);
110 g_warning("idl-compiler backend not found.");
115 context.filename = rinfo->input_filename;
116 context.do_stubs = (rinfo->enabled_passes & OUTPUT_STUBS ? 1 : 0);
117 context.do_skels = (rinfo->enabled_passes & OUTPUT_SKELS ? 1 : 0);
118 context.do_common = (rinfo->enabled_passes & OUTPUT_COMMON ? 1 : 0);
120 return func (&context);