Author: mvidner
Date: Mon Aug 6 13:44:24 2007
New Revision: 39985
URL: http://svn.opensuse.org/viewcvs/yast?rev=39985&view=rev
Log:
Merged revisions 39051-39971 via svnmerge from
http://svn.opensuse.org/svn/yast/trunk/core
........
r39062 | mvidner | 2007-06-28 10:03:29 +0200 (Čt, 28 čen 2007) | 2 lines
Fixed docs for the "random" builtin.
........
r39159 | kkaempf | 2007-07-04 11:47:40 +0200 (St, 04 čec 2007) | 9 lines
Provide XML representation of abstract syntax tree.
This changeset adds 'toXML()' methods to all YCP and YCode
classes to support a more easily parseable representation
of YCP data structures and code.
The XML structures are considered experimental, if and
when a matching DTD will appear is unknown.
........
r39161 | kkaempf | 2007-07-04 11:53:34 +0200 (St, 04 čec 2007) | 4 lines
Add '-x' (resp. '--xml') command line option to ycpc.
This will trigger output of XML instead of YCP bytecode.
........
r39192 | kkaempf | 2007-07-05 18:27:28 +0200 (Čt, 05 čec 2007) | 5 lines
clean up XML output, use more properties
- constants are enclosed by
- symbol definitions are
- variable references are
........
r39224 | kkaempf | 2007-07-06 22:26:10 +0200 (Pá, 06 čec 2007) | 2 lines
drop <parameters>
........
r39225 | kkaempf | 2007-07-06 22:26:48 +0200 (Pá, 06 čec 2007) | 2 lines
fix xml representatio
........
r39226 | kkaempf | 2007-07-06 22:27:30 +0200 (Pá, 06 čec 2007) | 3 lines
enclose items with <element>...</element>
<val> -> <value>
........
r39227 | kkaempf | 2007-07-06 22:28:07 +0200 (Pá, 06 čec 2007) | 2 lines
handle as header
........
r39250 | kkaempf | 2007-07-09 14:46:30 +0200 (Po, 09 čec 2007) | 2 lines
clean up <locale> xml output
........
r39274 | kkaempf | 2007-07-10 13:47:18 +0200 (Út, 10 čec 2007) | 2 lines
enclose block statements in <stmt>
........
r39275 | kkaempf | 2007-07-10 13:48:12 +0200 (Út, 10 čec 2007) | 3 lines
parameter -> elements for YCodelist
simplify <entry>
........
r39276 | kkaempf | 2007-07-10 13:48:38 +0200 (Út, 10 čec 2007) | 2 lines
<expression> -> <expr>
........
r39279 | kkaempf | 2007-07-10 14:29:36 +0200 (Út, 10 čec 2007) | 2 lines
bump xml version
........
r39280 | kkaempf | 2007-07-10 14:30:32 +0200 (Út, 10 čec 2007) | 3 lines
fix yepropagate, yebracket and yeis type handling
parameter -> args for
........
r39281 | kkaempf | 2007-07-10 15:08:05 +0200 (Út, 10 čec 2007) | 2 lines
<val> -> <value> for YEMap
........
r39282 | kkaempf | 2007-07-10 15:19:28 +0200 (Út, 10 čec 2007) | 2 lines
fix <yemap> xml output to be compatible with <map> output
........
r39286 | kkaempf | 2007-07-10 16:20:41 +0200 (Út, 10 čec 2007) | 2 lines
fix closing tag
........
r39294 | kkaempf | 2007-07-10 17:49:24 +0200 (Út, 10 čec 2007) | 2 lines
fix start tag
........
r39345 | locilka | 2007-07-12 12:00:18 +0200 (Čt, 12 čec 2007) | 5 lines
- Fixed ag_background to always read the process exit status before
returning it (#285920).
- 2.15.7
........
r39348 | locilka | 2007-07-12 12:14:14 +0200 (Čt, 12 čec 2007) | 3 lines
back to 2.15.6
........
r39349 | kkaempf | 2007-07-12 12:32:33 +0200 (Čt, 12 čec 2007) | 2 lines
put list and map size to xml
........
r39350 | locilka | 2007-07-12 12:36:13 +0200 (Čt, 12 čec 2007) | 3 lines
Doesn't fail anymore
........
r39369 | kkaempf | 2007-07-12 16:26:19 +0200 (Čt, 12 čec 2007) | 2 lines
first attempt on expressions with symbols, like maplist, foreach, etc.
........
r39414 | kkaempf | 2007-07-15 13:09:01 +0200 (Ne, 15 čec 2007) | 2 lines
dont count elements in ycodelist
........
r39415 | kkaempf | 2007-07-15 13:10:17 +0200 (Ne, 15 čec 2007) | 2 lines
fix builtin xml output
........
r39467 | kkaempf | 2007-07-17 14:12:35 +0200 (Út, 17 čec 2007) | 2 lines
xml-ify path elements properly
........
r39470 | kkaempf | 2007-07-17 15:31:05 +0200 (Út, 17 čec 2007) | 2 lines
fix switch/case/default xml output
........
Added:
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Xmlcode.cc
- copied unchanged from r39470, trunk/core/libycp/src/Xmlcode.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/Xmlcode.h
- copied unchanged from r39470, trunk/core/libycp/src/include/ycp/Xmlcode.h
Modified:
branches/tmp/mvidner/ui-as-namespace/core/ (props changed)
branches/tmp/mvidner/ui-as-namespace/core/VERSION
branches/tmp/mvidner/ui-as-namespace/core/agents-perl/ag_background
branches/tmp/mvidner/ui-as-namespace/core/agents-perl/testsuite/Makefile.am
branches/tmp/mvidner/ui-as-namespace/core/base/tools/ycpc/ycpc.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Makefile.am
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Point.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/StaticDeclaration.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/SymbolTable.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Type.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YBlock.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPBoolean.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPBuiltinMisc.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPByteblock.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPCode.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPExternal.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPFloat.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPInteger.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPList.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPMap.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPPath.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPString.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPSymbol.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPTerm.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPVoid.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCode.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YExpression.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YStatement.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YSymbolEntry.cc
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/Point.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/StaticDeclaration.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/SymbolTable.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/Type.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YBlock.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPBoolean.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPByteblock.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPCode.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPElement.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPExternal.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPFloat.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPInteger.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPList.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPMap.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPPath.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPString.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPSymbol.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPTerm.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPValue.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCPVoid.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YCode.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YExpression.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YStatement.h
branches/tmp/mvidner/ui-as-namespace/core/libycp/src/include/ycp/YSymbolEntry.h
branches/tmp/mvidner/ui-as-namespace/core/package/yast2-core.changes
Modified: branches/tmp/mvidner/ui-as-namespace/core/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/VERSION?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/VERSION (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/VERSION Mon Aug 6 13:44:24 2007
@@ -1 +1 @@
-2.15.8
+2.15.6
Modified: branches/tmp/mvidner/ui-as-namespace/core/agents-perl/ag_background
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/agents-perl/ag_background?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/agents-perl/ag_background (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/agents-perl/ag_background Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/agents-perl/testsuite/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/agents-perl/testsuite/Makefile.am?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/agents-perl/testsuite/Makefile.am (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/agents-perl/testsuite/Makefile.am Mon Aug 6 13:44:24 2007
@@ -6,6 +6,4 @@
t-srcmgr1.exp \
t-srcmgr2.exp
-XFAIL_TESTS = t-srcmgr1.exp
-
EXTRA_DIST = test-common.exp $(TESTS)
Modified: branches/tmp/mvidner/ui-as-namespace/core/base/tools/ycpc/ycpc.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/base/tools/ycpc/ycpc.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/base/tools/ycpc/ycpc.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/base/tools/ycpc/ycpc.cc Mon Aug 6 13:44:24 2007
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include
#include
#include <../../libycp/src/parser.h>
@@ -54,6 +55,7 @@
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
@@ -914,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 ());
@@ -928,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;
@@ -1177,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)
@@ -1268,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);
Modified: branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Makefile.am?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Makefile.am (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Makefile.am Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/Point.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Point.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Point.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Point.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/StaticDeclaration.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/StaticDeclaration.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/StaticDeclaration.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/StaticDeclaration.cc Mon Aug 6 13:44:24 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"
@@ -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
Modified: branches/tmp/mvidner/ui-as-namespace/core/libycp/src/SymbolTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/SymbolTable.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/SymbolTable.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/SymbolTable.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/Type.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Type.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Type.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/Type.cc Mon Aug 6 13:44:24 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
Modified: branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YBlock.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YBlock.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YBlock.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YBlock.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/YCPBoolean.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPBoolean.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPBoolean.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPBoolean.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/YCPBuiltinMisc.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPBuiltinMisc.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPBuiltinMisc.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPBuiltinMisc.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/YCPByteblock.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPByteblock.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPByteblock.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPByteblock.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/YCPCode.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPCode.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPCode.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPCode.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/YCPExternal.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPExternal.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPExternal.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPExternal.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/YCPFloat.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPFloat.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPFloat.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPFloat.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/YCPInteger.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPInteger.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPInteger.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPInteger.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/YCPList.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPList.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPList.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPList.cc Mon Aug 6 13:44:24 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/mvidner/ui-as-namespace/core/libycp/src/YCPMap.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPMap.cc?rev=39985&r1=39984&r2=39985&view=diff
==============================================================================
--- branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPMap.cc (original)
+++ branches/tmp/mvidner/ui-as-namespace/core/libycp/src/YCPMap.cc Mon Aug 6 13:44:24 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 << "