Author: sh-sh-sh
Date: Wed Sep 12 17:28:00 2007
New Revision: 40882
URL: http://svn.opensuse.org/viewcvs/yast?rev=40882&view=rev
Log:
merged mvidner's 'UI as namespace' changes
Added:
branches/tmp/sh/mod-ui/core/libycp/src/Xmlcode.cc
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/Xmlcode.h
branches/tmp/sh/mod-ui/core/libyui/doc/YCPDialogParser.xml
branches/tmp/sh/mod-ui/core/libyui/doc/namespace
branches/tmp/sh/mod-ui/core/libyui/src/UIBuiltinCalls.h
branches/tmp/sh/mod-ui/core/libyui/src/UIBuiltinTable.h
branches/tmp/sh/mod-ui/core/libyui/src/Y2CCUI.cc
branches/tmp/sh/mod-ui/core/libyui/src/Y2CCUI.h
branches/tmp/sh/mod-ui/core/libyui/src/Y2UINamespace.cc
branches/tmp/sh/mod-ui/core/libyui/src/Y2UINamespace.h
Removed:
branches/tmp/sh/mod-ui/core/libyui/src/UI.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI_bindings.cc
Modified:
branches/tmp/sh/mod-ui/core/agents-perl/ag_background
branches/tmp/sh/mod-ui/core/base/src/Makefile.am
branches/tmp/sh/mod-ui/core/base/tools/ycpc/Makefile.am
branches/tmp/sh/mod-ui/core/base/tools/ycpc/ycpc.cc
branches/tmp/sh/mod-ui/core/liby2/src/Y2ComponentBroker.cc
branches/tmp/sh/mod-ui/core/liby2/src/Y2PluginComponent.cc
branches/tmp/sh/mod-ui/core/liby2/src/genericfrontend.cc
branches/tmp/sh/mod-ui/core/liby2/src/include/y2/Y2PluginComponent.h
branches/tmp/sh/mod-ui/core/libycp/src/Bytecode.cc
branches/tmp/sh/mod-ui/core/libycp/src/Import.cc
branches/tmp/sh/mod-ui/core/libycp/src/Makefile.am
branches/tmp/sh/mod-ui/core/libycp/src/Point.cc
branches/tmp/sh/mod-ui/core/libycp/src/StaticDeclaration.cc
branches/tmp/sh/mod-ui/core/libycp/src/SymbolTable.cc
branches/tmp/sh/mod-ui/core/libycp/src/Type.cc
branches/tmp/sh/mod-ui/core/libycp/src/YBlock.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPBoolean.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPBuiltinMisc.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPByteblock.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPCode.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPExternal.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPFloat.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPInteger.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPList.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPMap.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPPath.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPString.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPSymbol.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPTerm.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCPVoid.cc
branches/tmp/sh/mod-ui/core/libycp/src/YCode.cc
branches/tmp/sh/mod-ui/core/libycp/src/YExpression.cc
branches/tmp/sh/mod-ui/core/libycp/src/YStatement.cc
branches/tmp/sh/mod-ui/core/libycp/src/YSymbolEntry.cc
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/Bytecode.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/Makefile.am
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/Point.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/StaticDeclaration.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/SymbolTable.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/Type.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YBlock.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPBoolean.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPByteblock.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPCode.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPElement.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPExternal.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPFloat.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPInteger.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPList.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPMap.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPPath.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPString.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPSymbol.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPTerm.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPValue.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCPVoid.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YCode.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YExpression.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YStatement.h
branches/tmp/sh/mod-ui/core/libycp/src/include/ycp/YSymbolEntry.h
branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am
branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
branches/tmp/sh/mod-ui/core/libyui/src/YUIComponent.cc
branches/tmp/sh/mod-ui/core/libyui/src/YUIComponent.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI_core.cc
branches/tmp/sh/mod-ui/core/wfm/src/Makefile.am
branches/tmp/sh/mod-ui/core/wfm/src/Y2CCWFM.cc
branches/tmp/sh/mod-ui/core/wfm/src/Y2WFMComponent.cc
branches/tmp/sh/mod-ui/core/wfm/testsuite/Makefile.am
branches/tmp/sh/mod-ui/core/wfm/testsuite/runc.cc
branches/tmp/sh/mod-ui/ncurses/src/Makefile.am
branches/tmp/sh/mod-ui/ncurses/src/Y2CCNCursesUI.h
branches/tmp/sh/mod-ui/ncurses/src/pkg/ (props changed)
branches/tmp/sh/mod-ui/ncurses/src/pkg/Makefile.am
branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPackageSelector.cc
branches/tmp/sh/mod-ui/ncurses/testsuite/Makefile.am
branches/tmp/sh/mod-ui/qt/src/Makefile.am
branches/tmp/sh/mod-ui/qt/src/Y2CCQt.h
branches/tmp/sh/mod-ui/qt/src/pkg/Makefile.am
Modified: branches/tmp/sh/mod-ui/core/agents-perl/ag_background
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/agents-perl/ag_background?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/agents-perl/ag_background (original)
+++ branches/tmp/sh/mod-ui/core/agents-perl/ag_background Wed Sep 12 17:28:00 2007
@@ -91,6 +91,12 @@
ycp::Return("");
}
+my $exit = 0;
+
+sub ReadExitCode {
+ $exit = $? >> 8; # high 8 bits are exit value
+}
+
# install SIGCHLD handler
$SIG{CHLD} = \&Handler;
@@ -112,8 +118,6 @@
my $pipe_defined = 0;
my $pipe_defined_err = 0;
-my $exit = 0;
-
$| = 1;
# main loop
@@ -235,6 +239,7 @@
}
elsif ($path eq '.status')
{
+ ReadExitCode();
ycp::Return($exit);
}
elsif ($path eq '.newout')
@@ -368,7 +373,7 @@
}
close(RD);
- $exit = $? >> 8; # high 8 bits are exit value
+ ReadExitCode();
}
else
{
@@ -417,7 +422,7 @@
}
close(ERR);
- $exit = $? >> 8; # high 8 bits are exit value
+ ReadExitCode();
}
else
{
Modified: branches/tmp/sh/mod-ui/core/base/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/base/src/Makefile.am?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/base/src/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/core/base/src/Makefile.am Wed Sep 12 17:28:00 2007
@@ -10,7 +10,6 @@
../../wfm/src/libpy2wfm.la \
../../libycp/src/libycp.la \
../../liby2/src/liby2.la \
- ../../libyui/src/libyui.la \
../../libscr/src/libscr.la
# ../../scr/src/libpy2scr.la
Modified: branches/tmp/sh/mod-ui/core/base/tools/ycpc/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/base/tools/ycpc/Makefile.am?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/base/tools/ycpc/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/core/base/tools/ycpc/Makefile.am Wed Sep 12 17:28:00 2007
@@ -17,7 +17,7 @@
bin_PROGRAMS = ycpc
ycpc_SOURCES = ycpc.cc
ycpc_LDADD = $(top_builddir)/libycp/src/libycp.la \
- $(top_builddir)/libyui/src/libyui.la \
+ $(top_builddir)/libyui/src/libpy2UI.la \
$(top_builddir)/wfm/src/libpy2wfm.la \
$(top_builddir)/liby2/src/liby2.la \
$(top_builddir)/libscr/src/libscr.la \
Modified: branches/tmp/sh/mod-ui/core/base/tools/ycpc/ycpc.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/base/tools/ycpc/ycpc.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/base/tools/ycpc/ycpc.cc (original)
+++ branches/tmp/sh/mod-ui/core/base/tools/ycpc/ycpc.cc Wed Sep 12 17:28:00 2007
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include
#include
#include <../../libycp/src/parser.h>
@@ -29,7 +30,6 @@
#include
#include
-#include
#include
#include
@@ -55,12 +55,13 @@
static int recursive = 0; // recursively all files
static int parse = 0; // just parse source code
static int compile = 0; // just compile source to bytecode
+static int to_xml = 0; // output XML instead of bytecode
static int read_n_print = 0; // read and print bytecode
static int read_n_run = 0; // read and run bytecode
static int freshen = 0; // freshen recompilation
static int force = 0; // force recompilation
static int no_implicit_namespaces = 0; // don't preload implicit namespaces
-static char *ui_name = 0;
+static const char *ui_name = 0;
#define UI_QT_NAME "qt"
#define UI_NCURSES_NAME "ncurses"
@@ -915,11 +916,11 @@
int len = ofname.size ();
if (len > 4 && ofname.substr (len-4, 4) == ".ycp")
{
- ofname = ofname.replace (len-4, 4, ".ybc");
+ ofname = ofname.replace (len-4, 4, to_xml ? ".xml" : ".ybc");
}
else
{
- ofname += ".ybc";
+ ofname += to_xml ? ".xml" : ".ybc";
}
}
progress ("compiling to '%s'\n", ofname.c_str ());
@@ -929,7 +930,14 @@
if (c != NULL )
{
progress ("saving ...\n");
- return Bytecode::writeFile (c, ofname) ? 0 : 1;
+ int result = 0;
+ if (to_xml) {
+ result = Xmlcode::writeFile (c, ofname);
+ }
+ else {
+ result = Bytecode::writeFile (c, ofname);
+ }
+ return result ? 0 : 1;
}
return 2;
@@ -1178,10 +1186,11 @@
{"test", 0, 0, 't'}, // lots of output
{"ui", 1, 0, 'u' }, // UI to start in combination with 'r'
{"version", 0, 0, 'v'}, // show version and exit
+ {"xml", 0, 0, 'x'}, // output XML insteaf of Bytecode
{0, 0, 0, 0}
};
- int c = getopt_long (argc, argv, "h?vVnpqrtRdEcFfI:M:o:l:u:", options, &option_index);
+ int c = getopt_long (argc, argv, "h?vxVnpqrtRdEcFfI:M:o:l:u:", options, &option_index);
if (c == EOF) break;
switch (c)
@@ -1269,6 +1278,9 @@
case 'u':
ui_name = strdup (optarg);
break;
+ case 'x':
+ to_xml = 1;
+ break;
default:
fprintf (stderr, "Try `%s -h' for more information.\n", argv[0]);
exit(1);
@@ -1298,7 +1310,6 @@
// register builtins
SCR scr;
WFM wfm;
- UI ui;
if ((compile == parse) // both are zero
&& (compile == freshen)
Modified: branches/tmp/sh/mod-ui/core/liby2/src/Y2ComponentBroker.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/liby2/src/Y2ComponentBroker.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/liby2/src/Y2ComponentBroker.cc (original)
+++ branches/tmp/sh/mod-ui/core/liby2/src/Y2ComponentBroker.cc Wed Sep 12 17:28:00 2007
@@ -121,11 +121,12 @@
{
string comp_name = exi->second;
- Y2Component *comp = Y2ComponentBroker::createComponent (comp_name.c_str (), true);
+ // the ui stuff is a mess, must prefer servers
+ Y2Component *comp = createServer (comp_name.c_str ());
if (! comp)
{
- // no client component, try server as well
- comp = Y2ComponentBroker::createComponent (comp_name.c_str (), false);
+ // no server component, try client as well
+ comp = Y2ComponentBroker::createClient (comp_name.c_str ());
}
if (comp)
Modified: branches/tmp/sh/mod-ui/core/liby2/src/Y2PluginComponent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/liby2/src/Y2PluginComponent.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/liby2/src/Y2PluginComponent.cc (original)
+++ branches/tmp/sh/mod-ui/core/liby2/src/Y2PluginComponent.cc Wed Sep 12 17:28:00 2007
@@ -128,6 +128,23 @@
}
+Y2Namespace*
+Y2PluginComponent::import (const char* name_space)
+{
+ if (!handle)
+ {
+ loadPlugin ();
+ }
+
+ if (!comp)
+ {
+ return 0;
+ }
+
+ return comp->import (name_space);
+}
+
+
void
Y2PluginComponent::result (const YCPValue& result)
{
Modified: branches/tmp/sh/mod-ui/core/liby2/src/genericfrontend.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/liby2/src/genericfrontend.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/liby2/src/genericfrontend.cc (original)
+++ branches/tmp/sh/mod-ui/core/liby2/src/genericfrontend.cc Wed Sep 12 17:28:00 2007
@@ -109,14 +109,12 @@
* @param m the message to be logged
*/
#if BLOCXX_LIBRARY_VERSION >= 5
- virtual void doProcessLogMessage(const blocxx::String & f,
+ virtual void doProcessLogMessage(const blocxx::String & /*f*/,
const blocxx::LogMessage& m) const
- {
- (void)f;
#else
virtual void doProcessLogMessage(const blocxx::LogMessage& m) const
- {
#endif
+ {
loglevel_t level = LOG_DEBUG;
if (m.category == blocxx::Logger::STR_FATAL_CATEGORY
|| m.category == blocxx::Logger::STR_ERROR_CATEGORY)
@@ -165,156 +163,18 @@
};
static logger_initializer initialize_logger;
-
-int
-main (int argc, char **argv)
+void
+parse_client_and_options (int argc, char ** argv, int& arg, char *& client_name, YCPList& arglist)
{
- if (!argv[0])
- {
- fprintf (stderr, "Missing argv[0]. It is a NULL pointer.");
- exit (5);
- }
-
- progname = basename (argv[0]); // get program name
-
- // Ignore SIGPIPE. No use in signals. Signals can't be assigned to
- // components
- signal(SIGPIPE, SIG_IGN);
-
- // Give some output for the SIGSEGV
- // and other signals too, #238172
- // Note that USR1 and USR2 are handled by the logger.
- signal (SIGHUP, signal_handler);
- signal (SIGINT, signal_handler);
- signal (SIGQUIT, signal_handler);
- signal (SIGILL , signal_handler);
- signal (SIGABRT, signal_handler);
- signal (SIGFPE, signal_handler);
- signal (SIGSEGV, signal_handler);
- signal (SIGTERM, signal_handler);
-
- if (argc < 2) {
- fprintf (stderr, "\nToo few arguments");
- print_usage();
- exit (1);
- }
-
- if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) {
- print_help ();
- exit (0);
- }
-
- // client _AND_ server must be given
- if (argc < 3)
- {
- fprintf (stderr, "\nPlease give client and server as arguments");
- print_usage();
- exit(5);
- }
-
- // Scan all options for -l/--logfile. They must be honored BEFORE
- // the logger is used the first time.
- for (int arg = 1; arg < argc; arg++)
- {
- if (!strcmp(argv[arg], "-l") || !strcmp(argv[arg], "--logfile"))
- {
- arg++; // switch to filename
-
- if (arg >= argc)
- {
- print_error ("Option %s is missing an argument", argv[arg-1]);
- exit(5);
- }
-
- set_log_filename( argv[arg] ); // set logfile given in command line
- }
- if (!strcmp(argv[arg], "-c") || !strcmp(argv[arg], "--logconf"))
- {
- arg++; // switch to filename
-
- if (arg >= argc)
- {
- print_error ("Option %s is missing an argument", argv[arg-1]);
- exit(5);
- }
-
- set_log_conf( argv[arg] );
- }
- }
-
- // set a defined umask
- umask (0022);
-
- YCPPathSearch::initialize();
-
- ostringstream argdump;
- for (int arg = 1; arg < argc; arg++)
- {
- argdump << " '" << argv[arg] << "'";
- }
-
- y2milestone ("Launched YaST2 component '%s'%s", progname, argdump.str().c_str());
-
- // Now evaluate command line options in sequence
-
- int arg = 1;
-
- // The first argument might be the log option or MUST be the client name
- if (!strcmp(argv[arg], "-l") || !strcmp(argv[arg], "--logfile"))
- {
- // Logfile already done at program start --> ignore here
- arg+=2; // skip over logfilename
- }
- if (!strcmp(argv[arg], "-c") || !strcmp(argv[arg], "--logconf"))
- {
- // Logfile already done at program start --> ignore here
- arg+=2; // skip over logfilename
- }
- // The first argument might be the log option or MUST be the client name
- if (!strcmp(argv[arg], "-l") || !strcmp(argv[arg], "--logfile"))
- {
- // Logfile already done at program start --> ignore here
- arg+=2; // skip over logfilename
- }
-
-
- // Check for namespace exceptions registration
- while (!strcmp(argv[arg], "-n"))
- {
- arg++;
- char *pos = index (argv[arg], '=');
- if (pos == NULL)
- {
- print_error ("Option %s argument must be in format namespace=component", argv[arg-1]);
- exit (5);
- }
- *pos = 0;
- Y2ComponentBroker::registerNamespaceException (argv[arg], pos+1);
- *pos = '=';
- arg++;
- }
-
- // now create client
- char *client_name = argv[arg];
- if (!client_name) {
+ if (!argv[arg]) {
print_usage ();
exit (1);
}
- Y2Component *client = Y2ComponentBroker::createClient (client_name);
- if (!client)
- {
- print_error ("No such client module %s", client_name);
- print_usage ();
- exit (5);
- }
-
+ client_name = argv[arg];
arg++; // next argument (first client option)
// Prepare client options
-
- YCPList arglist;
-
while (arg < argc)
{
if (!strcmp(argv[arg], "-l") || !strcmp(argv[arg], "--logfile"))
@@ -412,7 +272,11 @@
arg++; // switch to next argument
} // Parsing client options
+}
+void
+parse_server_and_options (int argc, char ** argv, int& arg, char *& server_name, YCPList& preload)
+{
if (arg >= argc)
{
fprintf(stderr, "No server module given\n");
@@ -421,23 +285,15 @@
}
// now create server
- char *server_name = argv[arg];
- if (!server_name) {
+ if (!argv[arg]) {
print_usage ();
exit (1);
}
- Y2Component *server = Y2ComponentBroker::createServer (server_name);
- if (!server) {
- print_error ("No such server module %s", server_name);
- print_usage();
- exit(5);
- }
-
+ server_name = argv[arg];
arg++; // next argument (first server option)
// Prepare server and general options
- YCPList preload; // prepare preload files from option -p
while (arg < argc)
{
@@ -507,9 +363,159 @@
arg++; // switch to next argument
} // parsing server options
+}
+
+int
+main (int argc, char **argv)
+{
+ if (!argv[0])
+ {
+ fprintf (stderr, "Missing argv[0]. It is a NULL pointer.");
+ exit (5);
+ }
+
+ progname = basename (argv[0]); // get program name
+
+ // Ignore SIGPIPE. No use in signals. Signals can't be assigned to
+ // components
+ signal(SIGPIPE, SIG_IGN);
+
+ // Give some output for the SIGSEGV
+ // and other signals too, #238172
+ // Note that USR1 and USR2 are handled by the logger.
+ signal (SIGHUP, signal_handler);
+ signal (SIGINT, signal_handler);
+ signal (SIGQUIT, signal_handler);
+ signal (SIGILL , signal_handler);
+ signal (SIGABRT, signal_handler);
+ signal (SIGFPE, signal_handler);
+ signal (SIGSEGV, signal_handler);
+ signal (SIGTERM, signal_handler);
+
+ if (argc < 2) {
+ fprintf (stderr, "\nToo few arguments");
+ print_usage();
+ exit (1);
+ }
+
+ if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) {
+ print_help ();
+ exit (0);
+ }
+
+ // client _AND_ server must be given
+ if (argc < 3)
+ {
+ fprintf (stderr, "\nPlease give client and server as arguments");
+ print_usage();
+ exit(5);
+ }
+
+ // Scan all options for -l/--logfile. They must be honored BEFORE
+ // the logger is used the first time.
+ for (int arg = 1; arg < argc; arg++)
+ {
+ if (!strcmp(argv[arg], "-l") || !strcmp(argv[arg], "--logfile"))
+ {
+ arg++; // switch to filename
+
+ if (arg >= argc)
+ {
+ print_error ("Option %s is missing an argument", argv[arg-1]);
+ exit(5);
+ }
+
+ set_log_filename( argv[arg] ); // set logfile given in command line
+ }
+ if (!strcmp(argv[arg], "-c") || !strcmp(argv[arg], "--logconf"))
+ {
+ arg++; // switch to filename
+
+ if (arg >= argc)
+ {
+ print_error ("Option %s is missing an argument", argv[arg-1]);
+ exit(5);
+ }
+
+ set_log_conf( argv[arg] );
+ }
+ }
+
+ // set a defined umask
+ umask (0022);
+
+ YCPPathSearch::initialize();
+
+ ostringstream argdump;
+ for (int arg = 1; arg < argc; arg++)
+ {
+ argdump << " '" << argv[arg] << "'";
+ }
+
+ y2milestone ("Launched YaST2 component '%s'%s", progname, argdump.str().c_str());
+
+ // Now evaluate command line options in sequence
+
+ int arg = 1;
+
+ // The first argument might be the log option or MUST be the client name
+ if (!strcmp(argv[arg], "-l") || !strcmp(argv[arg], "--logfile"))
+ {
+ // Logfile already done at program start --> ignore here
+ arg+=2; // skip over logfilename
+ }
+ if (!strcmp(argv[arg], "-c") || !strcmp(argv[arg], "--logconf"))
+ {
+ // Logfile already done at program start --> ignore here
+ arg+=2; // skip over logfilename
+ }
+ // The first argument might be the log option or MUST be the client name
+ if (!strcmp(argv[arg], "-l") || !strcmp(argv[arg], "--logfile"))
+ {
+ // Logfile already done at program start --> ignore here
+ arg+=2; // skip over logfilename
+ }
+
+
+ // Check for namespace exceptions registration
+ while (!strcmp(argv[arg], "-n"))
+ {
+ arg++;
+ char *pos = index (argv[arg], '=');
+ if (pos == NULL)
+ {
+ print_error ("Option %s argument must be in format namespace=component", argv[arg-1]);
+ exit (5);
+ }
+ *pos = 0;
+ Y2ComponentBroker::registerNamespaceException (argv[arg], pos+1);
+ *pos = '=';
+ arg++;
+ }
+
+ // "arg" and these two are output params
+ char * client_name;
+ YCPList arglist;
+ parse_client_and_options (argc, argv, arg, client_name, arglist);
+
+ // "arg" and these two are output params
+ char * server_name;
+ YCPList preload; // prepare preload files from option -p
+ parse_server_and_options (argc, argv, arg, server_name, preload);
+
+ // now create server
+
+ Y2ComponentBroker::registerNamespaceException ("UI", server_name);
+ Y2Component *server = Y2ComponentBroker::getNamespaceComponent ("UI");
+ if (!server) {
+ print_error ("No such server module %s", server_name);
+ print_usage();
+ exit(5);
+ }
+
// Put argument into a nice new array and give them to the server
char **server_argv = new char *[argc-arg+2];
- server_argv[0] = server_name;
+ server_argv[0] = strdup (server_name);
for (int i = arg; i < argc; i++)
server_argv[i-arg+1] = argv[i];
argv[argc] = NULL;
@@ -523,6 +529,16 @@
server->evaluate(preload->value(i));
}
+ // now create client
+
+ Y2Component *client = Y2ComponentBroker::createClient (client_name);
+ if (!client)
+ {
+ print_error ("No such client module %s", client_name);
+ print_usage ();
+ exit (5);
+ }
+
// The environment variable YAST_IS_RUNNING is checked in rpm
// post install scripts. Might be useful for other scripts as
// well.
Modified: branches/tmp/sh/mod-ui/core/liby2/src/include/y2/Y2PluginComponent.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/liby2/src/include/y2/Y2PluginComponent.h?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/liby2/src/include/y2/Y2PluginComponent.h (original)
+++ branches/tmp/sh/mod-ui/core/liby2/src/include/y2/Y2PluginComponent.h Wed Sep 12 17:28:00 2007
@@ -102,6 +102,8 @@
* Returns the SCRAgent of the Y2Component or NULL if it doesn't have one.
*/
SCRAgent* getSCRAgent ();
+
+ Y2Namespace* import (const char* name_space);
/**
* Tells this server, that the client doesn't need it's services
Modified: branches/tmp/sh/mod-ui/core/libycp/src/Bytecode.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/Bytecode.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/Bytecode.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/Bytecode.cc Wed Sep 12 17:28:00 2007
@@ -845,8 +845,7 @@
YCodePtr res = 0;
- try
- {
+ // there used to be a try/catch here but it was moved to readFile
switch (code)
{
@@ -1059,13 +1058,6 @@
break;
}
- }
- catch (const Bytecode::Invalid&)
- {
- // there are memory leaks all over the place now
- y2error ("Caught invalid bytecode");
- }
-
return res;
}
@@ -1158,8 +1150,17 @@
#if DO_DEBUG
// y2debug ("Header accepted");
#endif
-
- return readCode (instream);
+
+ try
+ {
+ return readCode (instream);
+ }
+ catch (const Bytecode::Invalid&)
+ {
+ // there are memory leaks all over the place now
+ y2error ("Caught invalid bytecode in '%s'", filename.c_str());
+ return 0;
+ }
}
y2error ("Unsupported version %d.%d.%d"
Modified: branches/tmp/sh/mod-ui/core/libycp/src/Import.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/Import.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/Import.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/Import.cc Wed Sep 12 17:28:00 2007
@@ -98,6 +98,8 @@
return -1;
}
+ y2debug ("Component found: %s", comp->name().c_str());
+
name_space = comp->import (cname); // do the bytecode import
if (name_space == NULL)
{
Modified: branches/tmp/sh/mod-ui/core/libycp/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/Makefile.am?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/Makefile.am Wed Sep 12 17:28:00 2007
@@ -21,6 +21,7 @@
libycpvalues_la_SOURCES = \
Bytecode.cc Import.cc Point.cc \
+ Xmlcode.cc \
YCPBoolean.cc \
YCPElement.cc YCPByteblock.cc YCPFloat.cc \
YCPInteger.cc YCPList.cc \
Modified: branches/tmp/sh/mod-ui/core/libycp/src/Point.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/Point.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/Point.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/Point.cc Wed Sep 12 17:28:00 2007
@@ -45,6 +45,7 @@
#include "ycp/Point.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include "ycp/Scanner.h"
#include "ycp/y2log.h"
@@ -169,4 +170,20 @@
}
+std::ostream &
+Point::toXml (std::ostream & str, int indent ) const
+{
+ str << Xmlcode::spaces( indent ) << "<point line=" << m_line << ">";
+#if DO_DEBUG
+ y2debug ("Point::toStream (%s)", toString().c_str());
+#endif
+ Xmlcode::writeEntry (str, m_entry);
+ if (m_point)
+ {
+ m_point->toXml( str, indent );
+ }
+ return str << "</point>";
+}
+
+
// EOF
Modified: branches/tmp/sh/mod-ui/core/libycp/src/StaticDeclaration.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/StaticDeclaration.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/StaticDeclaration.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/StaticDeclaration.cc Wed Sep 12 17:28:00 2007
@@ -34,6 +34,7 @@
#include "ycp/YBlock.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include "ycp/Import.h"
#include "ycp/Point.h"
@@ -49,7 +50,7 @@
// list of namespace prefixes to mark as 'predefined'
// They will be auto-loaded by the scanner on first appearance
//
-static char *predefined[] = {
+static const char *predefined[] = {
"UI", "WFM", "SCR", "Pkg", 0
};
//------------------------------------------------------------------------
@@ -61,7 +62,7 @@
#if DO_DEBUG
y2debug ("m_declTable %p", m_declTable);
#endif
- char **pptr = predefined;
+ const char **pptr = predefined;
SymbolEntryPtr sentry;
Point *point = new Point ("<predefined>");
while (*pptr != 0)
@@ -513,6 +514,27 @@
}
+// write declaration to stream (name and type)
+std::ostream &
+StaticDeclaration::writeXmlDeclaration (std::ostream & str, const declaration_t *decl) const
+{
+ string ns;
+
+ const declaration_t *d = decl;
+ while( d->name_space != 0 )
+ {
+ d = d->name_space;
+ if (!ns.empty()) ns += "::";
+ ns = std::string(d->name);
+ }
+
+ if (!ns.empty()) str << " ns=\"" << ns << "\"";
+ str << " name=\"" << Xmlcode::xmlify( decl->name ) << "\"";
+ decl->type->toXml( str, 0 );
+ return str;
+}
+
+
// read declaration from stream (return declaration matching name and type _exactly_)
declaration_t *
StaticDeclaration::readDeclaration (bytecodeistream & str) const
@@ -526,7 +548,10 @@
if (decl == 0)
{
ycp2error ("No match for '%s (%s)'", name, type->toString().c_str());
- str.setstate (std::ostream::failbit);
+ ycp2error ("That is a builtin function, so your bytecode");
+ ycp2error ("needs to be recompiled using a recent yast2-core.");
+ delete [] name;
+ throw Bytecode::Invalid();
}
delete [] name;
return decl;
Modified: branches/tmp/sh/mod-ui/core/libycp/src/SymbolTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/SymbolTable.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/SymbolTable.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/SymbolTable.cc Wed Sep 12 17:28:00 2007
@@ -23,6 +23,7 @@
#include "ycp/SymbolTable.h"
#include "y2/SymbolEntry.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include "ycp/Point.h"
#ifndef DO_DEBUG
@@ -179,6 +180,26 @@
}
+std::ostream &
+TableEntry::toXml (std::ostream & str, int indent ) const
+{
+ str << Xmlcode::spaces( indent ) << "<tableentry>\n";
+ str << Xmlcode::spaces( indent+2 );
+ Xmlcode::writeEntry (str, m_entry);
+ str << endl;
+ m_point->toXml (str, indent+2 );
+ if ((m_entry->category() == SymbolEntry::c_function) // write function prototype if it's global
+ && m_entry->isGlobal())
+ {
+// y2debug ("TableEntry::toStream: write global function prototype");
+
+ // FIXME: why do we this here???
+ ((YFunctionPtr)(((YSymbolEntryPtr)m_entry)->code()))->toXml( str, indent );
+ }
+ return str << endl << Xmlcode::spaces( indent ) << "</tableentry>";
+}
+
+
void
TableEntry::remove ()
{
@@ -478,6 +499,60 @@
return str;
}
+
+std::ostream &
+SymbolTable::writeXmlUsage (std::ostream & str, int indent ) const
+{
+ if (m_used == 0)
+ return str;
+
+ std::vector xrefs;
+
+ std::map::iterator it;
+
+ for (it = m_used->begin(); it != m_used->end(); it++)
+ {
+ TableEntry *tentry = it->second;
+ tentry->sentry()->setPosition (xrefs.size());
+#if DO_DEBUG
+ y2debug ("%d -> %s", xrefs.size(), tentry->sentry()->toString().c_str());
+#endif
+ xrefs.push_back (tentry);
+ }
+
+ int rsize = xrefs.size();
+ if (rsize == 0)
+ return str;
+
+ bool xref_debug = (getenv (XREFDEBUG) != 0);
+
+ if (xref_debug) y2milestone ("Need %d symbols from table %p\n", rsize, this);
+#if DO_DEBUG
+ else y2debug ("Need %d symbols from table %p\n", rsize, this);
+#endif
+
+ str << Xmlcode::spaces( indent ) << "<usage>\n";
+
+ int position = 0;
+ while (position < rsize)
+ {
+ SymbolEntryPtr sentry = xrefs[position]->sentry();
+
+ if (xref_debug) y2milestone("XRef %p::%s @ %d\n", this, sentry->toString().c_str(), position);
+#if DO_DEBUG
+ else y2debug("XRef %p::%s @ %d\n", this, sentry->toString().c_str(), position);
+#endif
+ str << Xmlcode::spaces( indent+2 ) << "<name>" << sentry->name() << "</name>";
+ sentry->type()->toXml( str, 0 );
+ str << endl;
+
+ sentry->setPosition (-position - 1); // negative position -> Xref
+ position++;
+ }
+
+ return str << Xmlcode::spaces( indent ) << "</usage>\n";
+}
+
//-------------------------------------------------------------------
int
Modified: branches/tmp/sh/mod-ui/core/libycp/src/Type.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/Type.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/Type.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/Type.cc Wed Sep 12 17:28:00 2007
@@ -20,6 +20,7 @@
#include "ycp/y2log.h"
#include "ycp/Type.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include "ycp/YCPMap.h" // for YCPMapIterator
#include "ycp/YCPCode.h" // for YT_Code in matchvalue()
@@ -137,7 +138,7 @@
/**
- * write out to stream
+ * write out to bytecode stream
*/
std::ostream &
@@ -152,6 +153,16 @@
return str;
}
+
+std::ostream &
+Type::toXml( std::ostream & str, int indent ) const
+{
+ str << " type=\"" << toXmlString() << "\"";
+ if (m_const) str << " const=\"1\"";
+ if (m_reference) str << " reference=\"1\"";
+ return str;
+}
+
//----------------------------------------------------------------
// Type
@@ -193,6 +204,44 @@
}
+string
+Type::toXmlString () const
+{
+ string ret;
+ switch (m_kind)
+ {
+ case UnspecT: ret = "unspec"; break;
+ case ErrorT: ret = "ERR"; break;
+ case AnyT: ret = "any"; break;
+ case BooleanT: ret = "boolean"; break;
+ case ByteblockT: ret = "byteblock"; break;
+ case FloatT: ret = "float"; break;
+ case IntegerT: ret = "integer"; break;
+ case LocaleT: ret = "locale"; break;
+ case PathT: ret = "path"; break;
+ case StringT: ret = "string"; break;
+ case SymbolT: ret = "symbol"; break;
+ case TermT: ret = "term"; break;
+ case VoidT: ret = "void"; break;
+ case WildcardT: ret = "..."; break;
+
+ case FlexT: ret = "flex"; break;
+ case VariableT: ret = "var"; break;
+ case BlockT: ret = "block"; break;
+ case ListT: ret = "list"; break;
+ case MapT: ret = "map"; break;
+ case TupleT: ret = "tuple"; break;
+ case FunctionT: ret = "function"; break;
+
+ case NilT: ret = "nil"; break;
+ case NFlexT: ret = "nflex"; break;
+ // no default:, let gcc warn
+ }
+ if (ret.empty()) ret = "<UNHANDLED>";
+ return preToString() + ret + postToString();
+}
+
+
// match basic (non-constructed) types
//
// returns 0 if match
Added: branches/tmp/sh/mod-ui/core/libycp/src/Xmlcode.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/Xmlcode.cc?rev=40882&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/Xmlcode.cc (added)
+++ branches/tmp/sh/mod-ui/core/libycp/src/Xmlcode.cc Wed Sep 12 17:28:00 2007
@@ -0,0 +1,883 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | |( _| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| ( C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: Xmlcode.cc
+
+ Author: Klaus Kaempf
+ Maintainer: Klaus Kaempf
+
+ Cloned from Bytecode.cc
+
+ This file contains code to output YCode as XML.
+
+ It primary use is to have an easily parseable representation
+ of the abstract syntax tree coming from the YCP parser.
+ This XML representation could then be used to convert it
+ to C, Ruby, Python, Java, C#, whatever, code.
+
+ See also http://idea.opensuse.org/content/ideas/ycp-to-ruby-translator
+
+ The functions to read XML (and construct YCode from it) are
+ not needed and therefore disabled. If the need arises in
+ the future to parse XML, define XMLCODE_INPUT_SUPPORTED to 1
+ and fix the missing pieces ;-)
+/-*/
+
+#ifndef DO_DEBUG
+#define DO_DEBUG 0
+#endif
+
+// No, input is not supported
+#define XMLCODE_INPUT_SUPPORTED 0
+
+// MAJOR and MINOR number must the the same in header, RELEASE is assumed to
+// provide a backward compatibility
+#define YaST_BYTECODE_HEADER "YaST xmlcode "
+#define YaST_BYTECODE_MAJOR "1"
+#define YaST_BYTECODE_MINOR "4"
+#define YaST_BYTECODE_RELEASE "0"
+
+#include "ycp/Xmlcode.h"
+#include "YCP.h"
+#include "ycp/YCode.h"
+#include "ycp/YExpression.h"
+#include "ycp/YStatement.h"
+#include "ycp/YBlock.h"
+
+#include "y2/Y2Namespace.h"
+
+#include "ycp/y2log.h"
+#include "ycp/pathsearch.h"
+
+#include <fstream>
+#include
+#include
+#include
+
+
+static int
+readInt( xmlcodeistream & str)
+{
+ int i = 0;
+
+ char c;
+
+ for( ;;)
+ {
+ str.get( c);
+ if( !isdigit( c))
+ break;
+ i *= 10;
+ i +=( c - '0');
+ }
+
+ return i;
+}
+
+
+xmlcodeistream::xmlcodeistream( string filename)
+ : std::ifstream( filename.c_str( ))
+ , m_major( -1)
+ , m_minor( -1)
+ , m_release( -1)
+{
+ if( !is_open( ))
+ {
+ y2error( "Failed to open '%s': %s", filename.c_str(), strerror( errno));
+ return;
+ }
+ // read YaST_BYTECODE_HEADER
+
+ char header[sizeof(YaST_BYTECODE_HEADER)+1];
+ int headerlen = strlen( YaST_BYTECODE_HEADER);
+ read( header, headerlen);
+ header[headerlen] = 0;
+ if( strcmp( header, YaST_BYTECODE_HEADER) != 0)
+ {
+ y2error( "Not a xmlcode file '%s'[%s]", filename.c_str(), header);
+ return;
+ }
+
+ m_major = readInt( *this);
+ m_minor = readInt( *this);
+ m_release = readInt( *this);
+}
+
+bool xmlcodeistream::isVersion( int major, int minor, int release)
+{
+ return( major == m_major)
+ &&( minor == m_minor)
+ &&( release == m_release);
+}
+
+bool xmlcodeistream::isVersionAtMost( int major, int minor, int release)
+{
+ if( m_major > major)
+ {
+ return false;
+ }
+
+ if( m_major == major)
+ {
+ if( m_minor > minor)
+ {
+ return false;
+ }
+
+ if( ( m_minor == minor) &&( m_release > release))
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+int Xmlcode::m_namespace_nesting_level = -1;
+int Xmlcode::m_namespace_nesting_array_size = 0;
+int Xmlcode::m_namespace_tare_level = 0;
+Xmlcode::namespaceentry_t *Xmlcode::m_namespace_nesting_array = 0;
+
+void
+Xmlcode::namespaceInit( )
+{
+#if DO_DEBUG
+ y2debug( "Reinitialize namespaces");
+#endif
+ if( Xmlcode::m_namespace_nesting_array)
+ {
+ free( Xmlcode::m_namespace_nesting_array);
+ }
+
+ Xmlcode::m_namespace_nesting_array = 0;
+ Xmlcode::m_namespace_nesting_level = -1;
+ Xmlcode::m_namespace_nesting_array_size = 0;
+ Xmlcode::m_namespace_tare_level = 0;
+}
+
+// ------------------------------------------------------------------
+// xmlcode I/O
+
+static int
+to_hexc( unsigned char v )
+{
+ if( v < 10 ) return '0' + v;
+ if( v < 16 ) return 'A' + v - 10;
+ return -1;
+}
+
+std::ostream &
+Xmlcode::writeBytep( std::ostream & str, const unsigned char * bytep, unsigned int len)
+{
+ unsigned int i = 0;
+ str << "<bytes>";
+ while( i < len ) {
+ str << to_hexc(( *bytep & 0xf0) >> 4 ) << to_hexc( *bytep & 0x0f );
+ bytep++;
+ }
+ return str << "</bytes>";
+}
+
+
+unsigned char *
+Xmlcode::readBytep( xmlcodeistream & str)
+{
+ return 0;
+}
+
+
+// ------------------------------------------------------------------
+// Type I/O
+
+std::ostream &
+Xmlcode::writeType( std::ostream & str, constTypePtr type)
+{
+ return type->toXml( str, 0 );
+}
+
+
+TypePtr
+Xmlcode::readType( xmlcodeistream & str)
+{
+#if DO_DEBUG
+y2debug( "Xmlcode::readType(%d)", kind);
+#endif
+#if XMLCODE_INPUT_SUPPORTED
+ int kind = readInt32( str);
+ switch( (Type::tkind)kind)
+ {
+ case Type::UnspecT:
+ case Type::ErrorT:
+ case Type::AnyT:
+ case Type::BooleanT:
+ case Type::ByteblockT:
+ case Type::FloatT:
+ case Type::IntegerT:
+ case Type::LocaleT:
+ case Type::PathT:
+ case Type::StringT:
+ case Type::SymbolT:
+ case Type::TermT:
+ case Type::VoidT:
+ case Type::WildcardT:
+ case Type::FlexT:
+ case Type::NilT:
+ return TypePtr( new Type( (Type::tkind)kind, str) );
+ break;
+
+ case Type::NFlexT: return TypePtr( new NFlexType( str) ); break;
+ case Type::VariableT: return TypePtr( new VariableType( str) ); break;
+ case Type::BlockT: return TypePtr( new BlockType( str) ); break;
+ case Type::ListT: return TypePtr( new ListType( str) ); break;
+ case Type::MapT: return TypePtr( new MapType( str) ); break;
+ case Type::TupleT: return TypePtr( new TupleType( str) ); break;
+ case Type::FunctionT: return TypePtr( new FunctionType( str) ); break;
+ }
+ y2error( "Unhandled type kind %d", kind);
+#endif
+ return Type::Error->clone();
+}
+
+// ------------------------------------------------------------------
+// ycodelist_t * I/O
+
+std::ostream &
+Xmlcode::writeYCodelist( std::ostream & str, const ycodelist_t *codelist )
+{
+ const ycodelist_t *codep = codelist;
+
+ while( codep)
+ {
+ str << "<element>";
+ if( !codep->code->toXml( str, 0 ) )
+ {
+ y2error( "Error writing codelist");
+ break;
+ }
+ codep = codep->next;
+ str << "</element>";
+ }
+
+ return str;
+}
+
+
+bool
+Xmlcode::readYCodelist( xmlcodeistream & str, ycodelist_t **anchor)
+{
+
+ return str.good();
+}
+
+
+// ------------------------------------------------------------------
+// namespace stack handling
+
+// find Id matching namespace
+int
+Xmlcode::namespaceId( const Y2Namespace *name_space)
+{
+ for( int i = m_namespace_tare_level; i <= m_namespace_nesting_level; i++)
+ {
+ if( m_namespace_nesting_array[i].name_space == name_space)
+ {
+ return i - m_namespace_tare_level;
+ }
+ }
+ y2error( "No ID for %p, level %d", name_space, m_namespace_nesting_level);
+ return -1;
+}
+
+
+// retrieve namespace for ID
+const Y2Namespace *
+Xmlcode::namespacePtr( int namespace_id)
+{
+ // for entries without a name_space( foreach)
+ if( namespace_id < 0) return 0;
+
+ namespace_id += m_namespace_tare_level;
+ if( namespace_id <= m_namespace_nesting_level) // local namespace
+ {
+ return m_namespace_nesting_array[namespace_id].name_space;
+ }
+ y2error( "Block id %d > nesting_level %d", namespace_id - m_namespace_tare_level, m_namespace_nesting_level - m_namespace_tare_level);
+ return 0;
+}
+
+
+// push namespace to stack
+// the stack resembles the nesting of namespaces
+int
+Xmlcode::pushNamespace( const Y2Namespace *name_space, bool with_xrefs)
+{
+ if( name_space == 0)
+ {
+ y2error( "Xmlcode::pushNamespace( %p) NULL", name_space);
+ return -1;
+ }
+
+ m_namespace_nesting_level++;
+ if( m_namespace_nesting_array_size <= m_namespace_nesting_level)
+ {
+ m_namespace_nesting_array_size += 16;
+ m_namespace_nesting_array =( namespaceentry_t *)realloc( m_namespace_nesting_array, sizeof( namespaceentry_t) * m_namespace_nesting_array_size);
+ }
+#if DO_DEBUG
+ y2debug( "Xmlcode::pushNamespace( %p), level %d, size %d, tare %d", name_space, m_namespace_nesting_level, m_namespace_nesting_array_size, m_namespace_tare_level);
+#endif
+ m_namespace_nesting_array[m_namespace_nesting_level].name_space = name_space;
+ m_namespace_nesting_array[m_namespace_nesting_level].with_xrefs = with_xrefs;
+ if( with_xrefs)
+ {
+ name_space->table()->openXRefs();
+ }
+
+ return m_namespace_nesting_level-m_namespace_tare_level;
+}
+
+
+// pop namespace from stack
+// the stack resembles the nesting of namespaces
+int
+Xmlcode::popNamespace( const Y2Namespace *name_space)
+{
+#if DO_DEBUG
+ y2debug( "Xmlcode::popNamespace( %p), level %d, size %d, tare %d", name_space, m_namespace_nesting_level, m_namespace_nesting_array_size, m_namespace_tare_level);
+#endif
+ if( name_space == 0)
+ {
+ y2error( "Xmlcode::popNamespace( %p) NULL", name_space);
+ return -1;
+ }
+
+ if( m_namespace_nesting_level < m_namespace_tare_level)
+ {
+ y2error( "Xmlcode::popNamespace( %p) empty stack", name_space);
+ }
+ else if( m_namespace_nesting_array[m_namespace_nesting_level].name_space != name_space)
+ {
+ y2error( "Xmlcode::popNamespace( %p) not top of stack [%d]%p", name_space, m_namespace_nesting_level, m_namespace_nesting_array[m_namespace_nesting_level].name_space);
+ }
+ else
+ {
+ if( m_namespace_nesting_array[m_namespace_nesting_level].with_xrefs)
+ {
+ name_space->table()->closeXRefs();
+ }
+ m_namespace_nesting_level--;
+ }
+ return 0;
+}
+
+
+// pop all from id stack until given namespace is reached and popped too
+void
+Xmlcode::popUptoNamespace( const Y2Namespace *name_space)
+{
+#if DO_DEBUG
+ y2debug( "Xmlcode::popUptoNamespace( %p), level %d, size %d, tare %d", name_space, m_namespace_nesting_level, m_namespace_nesting_array_size, m_namespace_tare_level);
+#endif
+ if( name_space == 0)
+ {
+ y2error( "Xmlcode::popUptoNamespace( %p) NULL", name_space);
+ return;
+ }
+
+ while( m_namespace_nesting_level >= m_namespace_tare_level)
+ {
+ const Y2Namespace *top_space = m_namespace_nesting_array[m_namespace_nesting_level].name_space;
+ if( m_namespace_nesting_array[m_namespace_nesting_level].with_xrefs)
+ {
+ top_space->table()->closeXRefs();
+ }
+ m_namespace_nesting_level--;
+ if( top_space == name_space)
+ {
+ return;
+ }
+ }
+ y2error( "Xmlcode::popUptoNamespace( %p) empty stack", name_space);
+ return;
+}
+
+
+// reset current namespace stack to 'empty' for module loading
+// returns a tare id needed later
+int
+Xmlcode::tareStack( )
+{
+ int tare = m_namespace_nesting_level - m_namespace_tare_level + 1;
+#if DO_DEBUG
+// y2debug( "Xmlcode::tareStack() level %d, size %d, current tare %d, tare_id %d", m_namespace_nesting_level, m_namespace_nesting_array_size, m_namespace_tare_level, tare);
+#endif
+ m_namespace_tare_level = m_namespace_nesting_level + 1;
+ return tare;
+}
+
+
+void
+Xmlcode::untareStack( int tare_id)
+{
+#if DO_DEBUG
+// y2debug( "Xmlcode::untareStack() level %d, size %d, current tare %d, tare_id %d", m_namespace_nesting_level, m_namespace_nesting_array_size, m_namespace_tare_level, tare_id);
+#endif
+ m_namespace_tare_level -= tare_id;
+ return;
+}
+
+// ------------------------------------------------------------------
+// SymbolEntry pointer( !) handling
+// the SymbolEntries itself are 'owned' by YBlock and referenced via pointers
+// to SymbolEntry. These functions handle Xml I/O for SymbolEntry pointers.
+//
+// position is the index in namespace's m_senvironment[] for _local_ symbols
+// position is the index in module table's m_xrefs[] for _external_ symbols, see YSImport
+//
+std::ostream &
+Xmlcode::writeEntry( std::ostream & str, const SymbolEntryPtr sentry)
+{
+ const Y2Namespace *name_space = sentry->nameSpace();
+ string ns = name_space->name();
+ str << "position();
+ str << "\" name=\"" << sentry->name() << "\"/>";
+ return str;
+}
+
+
+SymbolEntryPtr
+Xmlcode::readEntry( xmlcodeistream & str)
+{
+ return 0;
+}
+
+// ------------------------------------------------------------------
+// YCode read
+
+
+// read code from stream
+YCodePtr
+Xmlcode::readCode( xmlcodeistream & str)
+{
+ char code;
+ if( !str.get( code))
+ {
+ y2error( "Can't read from stream");
+ return 0;
+ }
+#if DO_DEBUG
+// y2debug( "Xmlcode::readCode( %d:%s)", code, YCode::toString( (YCode::ykind)code).c_str());
+#endif
+ YCodePtr res = 0;
+
+#if XMLCODE_INPUT_SUPPORTED
+ if( code < YCode::ycConstant)
+ {
+ return new YConst( (YCode::ykind)code, str);
+ }
+
+ // compatibility with 9.1/SLES
+ if( str.isVersion( 1,3,2) && code > YCode::yeExpression)
+ {
+ // yeFunctionPointer did not exist then
+ code++;
+ }
+
+ try
+ {
+
+ switch( code)
+ {
+ case YCode::ycConstant:
+ {
+ // this constant is a placeholder, typically used by
+ // language bindings that cannot provide type information
+ y2error( "Unable to read constant, check the compilation of the module");
+ return 0;
+ }
+ case YCode::ycLocale:
+ {
+ res = new YLocale( str);
+ }
+ break;
+ case YCode::ycFunction:
+ {
+ res = new YFunction( str);
+ }
+ break;
+ case YCode::yePropagate:
+ {
+ res = new YEPropagate( str);
+ }
+ break;
+ case YCode::yeUnary:
+ {
+ res = new YEUnary( str);
+ }
+ break;
+ case YCode::yeBinary:
+ {
+ res = new YEBinary( str);
+ }
+ break;
+ case YCode::yeTriple:
+ {
+ res = new YETriple( str);
+ }
+ break;
+ case YCode::yeCompare:
+ {
+ res = new YECompare( str);
+ }
+ break;
+ case YCode::yeLocale:
+ {
+ res = new YELocale( str);
+ }
+ break;
+ case YCode::yeList:
+ {
+ res = new YEList( str);
+ }
+ break;
+ case YCode::yeMap:
+ {
+ res = new YEMap( str);
+ }
+ break;
+ case YCode::yeTerm:
+ {
+ res = new YETerm( str);
+ }
+ break;
+ case YCode::yeIs:
+ {
+ res = new YEIs( str);
+ }
+ break;
+ case YCode::yeBracket:
+ {
+ res = new YEBracket( str);
+ }
+ break;
+ case YCode::yeBlock:
+ {
+ res = new YBlock( str);
+ }
+ break;
+ case YCode::yeReturn:
+ {
+ res = new YEReturn( str);
+ }
+ break;
+ case YCode::yeVariable:
+ {
+ res = new YEVariable( str);
+ }
+ break;
+ case YCode::yeReference:
+ {
+ res = new YEReference( str);
+ }
+ break;
+ case YCode::yeBuiltin:
+ {
+ res = new YEBuiltin( str);
+ }
+ break;
+ case YCode::yeFunction:
+ {
+ res = YECall::readCall( str);
+ }
+ break;
+ case YCode::yeFunctionPointer:
+ {
+ res = new YEFunctionPointer( str);
+ }
+ break;
+ case YCode::ysTypedef:
+ {
+ res = new YSTypedef( str);
+ }
+ break;
+ case YCode::ysVariable:
+ {
+ res = new YSVariable( str);
+ }
+ break;
+ case YCode::ysFunction:
+ {
+ res = new YSFunction( str);
+ }
+ break;
+ case YCode::ysAssign:
+ {
+ res = new YSAssign( str);
+ }
+ break;
+ case YCode::ysBracket:
+ {
+ res = new YSBracket( str);
+ }
+ break;
+ case YCode::ysIf:
+ {
+ res = new YSIf( str);
+ }
+ break;
+ case YCode::ysWhile:
+ {
+ res = new YSWhile( str);
+ }
+ break;
+ case YCode::ysDo:
+ {
+ res = new YSDo( str);
+ }
+ break;
+ case YCode::ysRepeat:
+ {
+ res = new YSRepeat( str);
+ }
+ break;
+ case YCode::ysExpression:
+ {
+ res = new YSExpression( str);
+ }
+ break;
+ case YCode::ysReturn:
+ {
+ res = new YSReturn( str);
+ }
+ break;
+ case YCode::ysBreak:
+ {
+ res = new YSBreak( str);
+ }
+ break;
+ case YCode::ysContinue:
+ {
+ res = new YSContinue( str);
+ }
+ break;
+ case YCode::ysTextdomain:
+ {
+ res = new YSTextdomain( str);
+ }
+ break;
+ case YCode::ysInclude:
+ {
+ res = new YSInclude( str);
+ }
+ break;
+ case YCode::ysFilename:
+ {
+ res = new YSFilename( str);
+ }
+ break;
+ case YCode::ysImport:
+ {
+ res = new YSImport( str);
+ }
+ break;
+ case YCode::ysBlock:
+ {
+ res = new YSBlock( str);
+ }
+ break;
+ case YCode::ysSwitch:
+ {
+ res = new YSSwitch( str);
+ }
+ break;
+ default:
+ {
+ y2error( "Unknown code %d", code);
+ }
+ break;
+ }
+
+ }
+ catch( const Xmlcode::Invalid&)
+ {
+ // there are memory leaks all over the place now
+ y2error( "Caught invalid xmlcode");
+ }
+#endif
+ return res;
+}
+
+
+// ------------------------------------------------------------------
+// File I/O
+
+// static member
+map * Xmlcode::m_xmlcodeCache = NULL;
+
+// read file from module path
+
+YBlockPtr
+Xmlcode::readModule( const string & mname)
+{
+#if DO_DEBUG
+// y2debug( "Xmlcode::readModule( %s) ", mname.c_str( ));
+#endif
+
+ // TODO better error reporting?
+ // like: could not find foo.ycp in /modules, /a/modules.
+ // It will return an empty string on failure
+
+ string filename = YCPPathSearch::findModule( mname);
+ if( filename.empty())
+ {
+ ycperror( "Module '%s' not found", mname.c_str());
+ return 0;
+ }
+
+ if( ! m_xmlcodeCache)
+ {
+ m_xmlcodeCache = new map ;
+ }
+
+ // check the cache
+ if( m_xmlcodeCache->find( mname) != m_xmlcodeCache->end( ))
+ {
+#if DO_DEBUG
+// y2debug( "Xmlcode cache hit: %s", mname.c_str( ));
+#endif
+
+ return m_xmlcodeCache->find( mname)->second;
+ }
+
+ int tare_id = Xmlcode::tareStack( ); // current nesting level is 0 for this module
+ YBlockPtr block =( YBlockPtr)Xmlcode::readFile( filename);
+
+ if( block == NULL)
+ {
+ return NULL;
+ }
+
+ Xmlcode::untareStack( tare_id);
+
+ if( !block->isModule())
+ {
+ y2error( "'%s' is no module", filename.c_str());
+ return NULL;
+ }
+
+ m_xmlcodeCache->insert( std::make_pair( mname, block));
+
+ return block;
+}
+
+
+// read YCode from file, return YCode( 0 in case of failure)
+YCodePtr
+Xmlcode::readFile( const string & filename)
+{
+#if DO_DEBUG
+// y2debug( "Xmlcode::readFile( %s)", filename.c_str());
+#endif
+ xmlcodeistream instream( filename);
+ if( !instream.is_open( ))
+ {
+ y2error( "Failed to open '%s': %s", filename.c_str(), strerror( errno));
+ return 0;
+ }
+ // check YaST_BYTECODE_HEADER
+ if(
+ instream.isVersion(
+ atoi( YaST_BYTECODE_MAJOR)
+ , atoi( YaST_BYTECODE_MINOR)
+ , atoi( YaST_BYTECODE_RELEASE))
+ ||
+ instream.isVersion( 1,3,2) ) // 9.1/SLES9
+ {
+#if DO_DEBUG
+// y2debug( "Header accepted");
+#endif
+
+ return readCode( instream);
+ }
+
+ y2error( "Unsupported version %d.%d.%d"
+ , instream.major( )
+ , instream.minor( )
+ , instream.release( ));
+ return 0;
+}
+
+
+// write YCode to file, return false on error( i.e. file not existing - see errno)
+bool
+Xmlcode::writeFile( const YCodePtr code, const string & filename)
+{
+ // clear errno first
+ errno = 0;
+
+ std::ofstream outstream( filename.c_str());
+ if( !outstream.is_open( ))
+ {
+ y2error( "Failed to write '%s': %s", filename.c_str(), strerror( errno));
+ return false;
+ }
+
+ outstream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ outstream << "\n";
+ code->toXml( outstream, 2 );
+ outstream << "</ycp>\n";
+ return ! outstream.fail( );
+}
+
+
+// indentation
+
+string
+Xmlcode::spaces( int count )
+{
+ count >>= 1;
+ if (count <= 0) return "";
+
+ // 2 4 6 8 10 12 14 16 18 20
+ static string s[10] = { " ", " ", " ", "\t", "\t ", "\t ", "\t ", "\t\t", "\t\t ", "\t\t " };
+
+ if( count > 10 ) {
+ return s[9] + spaces( count*2 - 20 );
+ }
+ return s[count - 1];
+}
+
+string
+Xmlcode::xmlify( const string & s )
+{
+ string result;
+
+ const char *cptr = s.c_str();
+ const char *next;
+ while( (next = strpbrk( cptr, "&<>'\"" )) ) {
+ result += string( cptr, next - cptr );
+ switch (*next) {
+ case '&': result += "&"; break;
+ case '<': result += "<"; break;
+ case '>': result += ">"; break;
+ case '"': result += """; break;
+ case '\'': result += "'"; break;
+ }
+ cptr = next + 1;
+ }
+ result += string( cptr );
+ return result;
+
+}
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YBlock.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YBlock.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YBlock.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YBlock.cc Wed Sep 12 17:28:00 2007
@@ -36,6 +36,7 @@
#include "ycp/Point.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include "ycp/Scanner.h"
#include "ycp/y2log.h"
@@ -516,6 +517,51 @@
}
+std::ostream &
+YBlock::toXmlSwitch( map cases, int defaultcase, std::ostream & str, int indent ) const
+{
+ // first, create reverse map of cases
+ int statementcount = statementCount ();
+ YCPValue values[statementcount];
+
+ for (int i = 0; i < statementcount; i++)
+ values[i] = YCPNull ();
+
+ for (map::iterator it = cases.begin ();
+ it != cases.end (); it++ )
+ {
+ values[ it->second ] = it->first;
+ }
+
+ // s += environmentToString ();
+
+ stmtlist_t *stmt = m_statements;
+ int index = 0;
+ while (stmt)
+ {
+ str << Xmlcode::spaces( indent );
+ if (index == defaultcase)
+ {
+ str << "<default>\n";
+ stmt->stmt->toXml( str, indent+2 );
+ str << endl << "</default>";
+ }
+ else if (! values[index].isNull ())
+ {
+ str << "<case>";
+ values[index]->toXml( str, 0 );
+ str << endl;
+ stmt->stmt->toXml( str, indent+2 );
+ str << endl << "</case>";
+ }
+ stmt = stmt->next;
+ index++;
+ }
+
+ return str;
+}
+
+
YCPValue
YBlock::evaluate (bool cse)
{
@@ -965,6 +1011,92 @@
}
+std::ostream &
+YBlock::toXml( std::ostream & str, int indent ) const
+{
+ str << Xmlcode::spaces( indent ) << "\n";
+
+ indent += 2;
+
+ Xmlcode::pushNamespace (nameSpace());
+
+ if (symbolCount() > 0)
+ {
+ str << Xmlcode::spaces( indent ) << "<symbols>\n";
+
+ for (unsigned int i = 0; i < symbolCount(); i++)
+ {
+ YSymbolEntryPtr entry = (YSymbolEntryPtr)symbolEntry (i);
+ entry->toXml( str, indent+2 ); // write SymbolEntry
+ str << endl;
+ }
+ str << Xmlcode::spaces( indent ) << "</symbols>\n";
+
+#if 0
+ // if its a module, write the table
+
+ if (isModule())
+ {
+ yTElist_t *tptr = m_tenvironment;
+
+ if (tptr) {
+ str << Xmlcode::spaces( indent ) << "<table>\n";
+
+ while (tptr)
+ {
+ tptr->tentry->toXml( str, indent+2 ); // write the table entries
+ str << endl;
+ tptr = tptr->next;
+ }
+ str << Xmlcode::spaces( indent ) << "</table>\n";
+ }
+ }
+#endif
+ }
+
+#if 0
+ m_point->toXml( str, indent );
+ str << endl;
+#endif
+
+ stmtlist_t *stmt = m_statements;
+ if( stmt ) {
+ str << Xmlcode::spaces( indent ) << "<statements>\n";
+
+ while (stmt) // write statements
+ {
+ str << Xmlcode::spaces( indent+2 ) << "<stmt>";
+ stmt->stmt->toXml (str, 0 ); // YSImport will push it's namespace
+ str << "</stmt>" << endl;
+ stmt = stmt->next;
+ }
+
+ str << Xmlcode::spaces( indent ) << "</statements>\n";
+ }
+ Xmlcode::popUptoNamespace (nameSpace());
+
+ str << Xmlcode::spaces( indent-2 ) << "</block>\n";
+
+ return str;
+}
+
+
bool
YBlock::isIncluded (string includefile) const
{
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YCPBoolean.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YCPBoolean.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YCPBoolean.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YCPBoolean.cc Wed Sep 12 17:28:00 2007
@@ -20,6 +20,7 @@
#include
#include "YCPBoolean.h"
#include "Bytecode.h"
+#include "Xmlcode.h"
// YCPBooleanRep
@@ -58,6 +59,13 @@
}
+std::ostream &
+YCPBooleanRep::toXml (std::ostream & str, int indent ) const
+{
+ return str << "";
+}
+
+
YCPValueType
YCPBooleanRep::valuetype() const
{
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YCPBuiltinMisc.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YCPBuiltinMisc.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YCPBuiltinMisc.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YCPBuiltinMisc.cc Wed Sep 12 17:28:00 2007
@@ -78,11 +78,11 @@
/**
* @builtin random
* @short Random number generator.
- * @description Returns random integer in the interval (0,MAX).
+ * @description Returns a random integer in the interval [0,MAX).
* <tt>srandom</tt> must be activated to get really random
* numbers.
* @param integer MAX
- * @return integer Returns integer in the interval (0,MAX).
+ * @return integer Returns integer in the interval [0,MAX).
* @usage random(100) -> 82
* @usage random(100) -> 36
*/
@@ -90,6 +90,7 @@
if (max.isNull ())
return YCPNull ();
+ // see NOTES in man 3 rand,
// <1,10> 1+(int) (10.0*rand()/(RAND_MAX+1.0));
int ret = (int) (max->value () * rand () / (RAND_MAX + 1.0));
return YCPInteger (ret);
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YCPByteblock.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YCPByteblock.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YCPByteblock.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YCPByteblock.cc Wed Sep 12 17:28:00 2007
@@ -20,6 +20,7 @@
#include
#include "YCPByteblock.h"
#include "Bytecode.h"
+#include "Xmlcode.h"
using std::min;
@@ -136,6 +137,12 @@
return Bytecode::writeBytep (str, bytes, len);
}
+std::ostream &
+YCPByteblockRep::toXml (std::ostream & str, int indent ) const
+{
+ return Xmlcode::writeBytep (str, bytes, len);
+}
+
// --------------------------------------------------------
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YCPCode.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YCPCode.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YCPCode.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YCPCode.cc Wed Sep 12 17:28:00 2007
@@ -23,6 +23,7 @@
#include "ycp/y2log.h"
#include "ycp/YCPCode.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
//---------------------------------------------------------------------------
// YCPCodeRep
@@ -89,6 +90,14 @@
return m_code->toStream (str);
}
+std::ostream &
+YCPCodeRep::toXml (std::ostream & str, int indent ) const
+{
+ str << "<ycpcode>";
+ m_code->toXml( str, indent );
+ return str << "</ycpcode>";
+}
+
// --------------------------------------------------------
YCPCode::YCPCode (bytecodeistream & str)
@@ -153,6 +162,12 @@
return Bytecode::writeEntry (str, m_entry);
}
+std::ostream &
+YCPEntryRep::toXml( std::ostream & str, int indent ) const
+{
+ return Xmlcode::writeEntry (str, m_entry);
+}
+
//---------------------------------------------------------------------------
@@ -210,6 +225,25 @@
return str;
}
+std::ostream &
+YCPReferenceRep::toXml( std::ostream & str, int indent ) const
+{
+ // this is not used, instead YEVariable is used for xml
+ return str;
+}
+
+
+
+std::ostream &
+YCPBreakRep::toXml( std::ostream & str, int indent ) const
+{
+ return str << "<break/>";
+}
+std::ostream &
+YCPReturnRep::toXml( std::ostream & str, int indent ) const
+{
+ return str << "<return/>";
+}
// EOF
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YCPExternal.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YCPExternal.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YCPExternal.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YCPExternal.cc Wed Sep 12 17:28:00 2007
@@ -77,6 +77,13 @@
return str;
}
+std::ostream &
+YCPExternalRep::toXml (std::ostream & str, int indent ) const
+{
+ y2error ("Trying to store an external payload in xml");
+ return str;
+}
+
// ----------------------------------------------
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YCPFloat.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YCPFloat.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YCPFloat.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YCPFloat.cc Wed Sep 12 17:28:00 2007
@@ -22,6 +22,7 @@
#include "ycp/y2log.h"
#include "ycp/YCPFloat.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
// YCPFloatRep
@@ -98,6 +99,12 @@
return Bytecode::writeString (str, toString());
}
+std::ostream &
+YCPFloatRep::toXml (std::ostream & str, int indent ) const
+{
+ return str << "";
+}
+
// --------------------------------------------------------
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YCPInteger.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YCPInteger.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YCPInteger.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YCPInteger.cc Wed Sep 12 17:28:00 2007
@@ -111,6 +111,13 @@
}
+std::ostream &
+YCPIntegerRep::toXml (std::ostream & str, int indent ) const
+{
+ return str << "";
+}
+
+
// ----------------------------------------------
static long long fromStream (bytecodeistream & str)
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YCPList.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YCPList.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YCPList.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YCPList.cc Wed Sep 12 17:28:00 2007
@@ -23,6 +23,7 @@
#include "ycp/YCPList.h"
#include <algorithm>
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include "ycp/YCPCodeCompare.h"
#include "ycp/ExecutionEnvironment.h"
@@ -278,6 +279,20 @@
}
+std::ostream &
+YCPListRep::toXml (std::ostream & str, int indent ) const
+{
+ str << "";
+ for (unsigned index = 0; index < elements.size(); index++)
+ {
+ str << "<element>";
+ elements[index]->toXml( str, 0 );
+ str << "</element>";
+ }
+ return str << "</list>";
+}
+
+
// --------------------------------------------------------
YCPList::YCPList(bytecodeistream & str)
Modified: branches/tmp/sh/mod-ui/core/libycp/src/YCPMap.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libycp/src/YCPMap.cc?rev=40882&r1=40881&r2=40882&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libycp/src/YCPMap.cc (original)
+++ branches/tmp/sh/mod-ui/core/libycp/src/YCPMap.cc Wed Sep 12 17:28:00 2007
@@ -20,6 +20,7 @@
#include "ycp/y2log.h"
#include "ycp/YCPMap.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include "ycp/ExecutionEnvironment.h"
extern ExecutionEnvironment ee;
@@ -220,6 +221,21 @@
}
+std::ostream &
+YCPMapRep::toXml (std::ostream & str, int indent ) const
+{
+ str << "