Author: kkaempf
Date: Wed Jul 4 11:47:40 2007
New Revision: 39159
URL: http://svn.opensuse.org/viewcvs/yast?rev=39159&view=rev
Log:
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.
Added:
trunk/core/libycp/src/Xmlcode.cc
trunk/core/libycp/src/include/ycp/Xmlcode.h
Modified:
trunk/core/libycp/src/Makefile.am
trunk/core/libycp/src/Point.cc
trunk/core/libycp/src/StaticDeclaration.cc
trunk/core/libycp/src/SymbolTable.cc
trunk/core/libycp/src/Type.cc
trunk/core/libycp/src/YBlock.cc
trunk/core/libycp/src/YCPBoolean.cc
trunk/core/libycp/src/YCPByteblock.cc
trunk/core/libycp/src/YCPCode.cc
trunk/core/libycp/src/YCPExternal.cc
trunk/core/libycp/src/YCPFloat.cc
trunk/core/libycp/src/YCPInteger.cc
trunk/core/libycp/src/YCPList.cc
trunk/core/libycp/src/YCPMap.cc
trunk/core/libycp/src/YCPPath.cc
trunk/core/libycp/src/YCPString.cc
trunk/core/libycp/src/YCPSymbol.cc
trunk/core/libycp/src/YCPTerm.cc
trunk/core/libycp/src/YCPVoid.cc
trunk/core/libycp/src/YCode.cc
trunk/core/libycp/src/YExpression.cc
trunk/core/libycp/src/YStatement.cc
trunk/core/libycp/src/YSymbolEntry.cc
trunk/core/libycp/src/include/ycp/Point.h
trunk/core/libycp/src/include/ycp/StaticDeclaration.h
trunk/core/libycp/src/include/ycp/SymbolTable.h
trunk/core/libycp/src/include/ycp/Type.h
trunk/core/libycp/src/include/ycp/YBlock.h
trunk/core/libycp/src/include/ycp/YCPBoolean.h
trunk/core/libycp/src/include/ycp/YCPByteblock.h
trunk/core/libycp/src/include/ycp/YCPCode.h
trunk/core/libycp/src/include/ycp/YCPElement.h
trunk/core/libycp/src/include/ycp/YCPExternal.h
trunk/core/libycp/src/include/ycp/YCPFloat.h
trunk/core/libycp/src/include/ycp/YCPInteger.h
trunk/core/libycp/src/include/ycp/YCPList.h
trunk/core/libycp/src/include/ycp/YCPMap.h
trunk/core/libycp/src/include/ycp/YCPPath.h
trunk/core/libycp/src/include/ycp/YCPString.h
trunk/core/libycp/src/include/ycp/YCPSymbol.h
trunk/core/libycp/src/include/ycp/YCPTerm.h
trunk/core/libycp/src/include/ycp/YCPValue.h
trunk/core/libycp/src/include/ycp/YCPVoid.h
trunk/core/libycp/src/include/ycp/YCode.h
trunk/core/libycp/src/include/ycp/YExpression.h
trunk/core/libycp/src/include/ycp/YStatement.h
trunk/core/libycp/src/include/ycp/YSymbolEntry.h
Modified: trunk/core/libycp/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/Makefile.am?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/Makefile.am (original)
+++ trunk/core/libycp/src/Makefile.am Wed Jul 4 11:47:40 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: trunk/core/libycp/src/Point.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/Point.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/Point.cc (original)
+++ trunk/core/libycp/src/Point.cc Wed Jul 4 11:47:40 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: trunk/core/libycp/src/StaticDeclaration.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/StaticDeclaration.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/StaticDeclaration.cc (original)
+++ trunk/core/libycp/src/StaticDeclaration.cc Wed Jul 4 11:47:40 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,29 @@
}
+// write declaration to stream (name and type)
+std::ostream &
+StaticDeclaration::writeXmlDeclaration (std::ostream & str, const declaration_t *decl) const
+{
+ str << "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 << "</static>";
+}
+
+
// read declaration from stream (return declaration matching name and type _exactly_)
declaration_t *
StaticDeclaration::readDeclaration (bytecodeistream & str) const
Modified: trunk/core/libycp/src/SymbolTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/SymbolTable.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/SymbolTable.cc (original)
+++ trunk/core/libycp/src/SymbolTable.cc Wed Jul 4 11:47:40 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: trunk/core/libycp/src/Type.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/Type.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/Type.cc (original)
+++ trunk/core/libycp/src/Type.cc Wed Jul 4 11:47:40 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,17 @@
return str;
}
+
+std::ostream &
+Type::toXml( std::ostream & str, int indent ) const
+{
+ str << "";
+ return str;
+}
+
//----------------------------------------------------------------
// Type
@@ -193,6 +205,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: trunk/core/libycp/src/Xmlcode.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/Xmlcode.cc?rev=39159&view=auto
==============================================================================
--- trunk/core/libycp/src/Xmlcode.cc (added)
+++ trunk/core/libycp/src/Xmlcode.cc Wed Jul 4 11:47:40 2007
@@ -0,0 +1,893 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ 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 )
+{
+ u_int32_t count = 0;
+ const ycodelist_t *codep = codelist;
+
+ while( codep)
+ {
+ count++;
+ codep = codep->next;
+ }
+
+#if DO_DEBUG
+ y2debug( "Xmlcode::writeYCodelist %d entries", count);
+#endif
+ str << "<parameters>";
+ codep = codelist;
+ while( codep)
+ {
+ str << "<parameter>";
+ if( !codep->code->toXml( str, 0 ) )
+ {
+ y2error( "Error writing codelist");
+ break;
+ }
+ codep = codep->next;
+ str << "</parameter>";
+ }
+
+ return str << "</parameters>";
+}
+
+
+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 << "\">" << sentry->name() << "</entry>";
+ 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 << "<ycp>\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;
+ }
+ cptr = next + 1;
+ }
+ result += string( cptr );
+ return result;
+
+}
Modified: trunk/core/libycp/src/YBlock.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YBlock.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YBlock.cc (original)
+++ trunk/core/libycp/src/YBlock.cc Wed Jul 4 11:47:40 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,49 @@
}
+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";
+ str << stmt->stmt->toXml( str, indent+2 ) << endl;
+ str << "</default>";
+ }
+ else if (! values[index].isNull ())
+ {
+ str << "<case>" << values[index]->toXml( str, 0 ) << endl;
+ str << stmt->stmt->toXml( str, indent+2 ) << endl;
+ str << "</case>";
+ }
+ stmt = stmt->next;
+ index++;
+ }
+
+ return str;
+}
+
+
YCPValue
YBlock::evaluate (bool cse)
{
@@ -965,6 +1009,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->toXml (str, indent+2 ); // YSImport will push it's namespace
+ str << 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: trunk/core/libycp/src/YCPBoolean.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPBoolean.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPBoolean.cc (original)
+++ trunk/core/libycp/src/YCPBoolean.cc Wed Jul 4 11:47:40 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 << "<bool>" << ( v ? "true" : "false" ) << "</bool>";
+}
+
+
YCPValueType
YCPBooleanRep::valuetype() const
{
Modified: trunk/core/libycp/src/YCPByteblock.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPByteblock.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPByteblock.cc (original)
+++ trunk/core/libycp/src/YCPByteblock.cc Wed Jul 4 11:47:40 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: trunk/core/libycp/src/YCPCode.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPCode.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPCode.cc (original)
+++ trunk/core/libycp/src/YCPCode.cc Wed Jul 4 11:47:40 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: trunk/core/libycp/src/YCPExternal.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPExternal.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPExternal.cc (original)
+++ trunk/core/libycp/src/YCPExternal.cc Wed Jul 4 11:47:40 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: trunk/core/libycp/src/YCPFloat.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPFloat.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPFloat.cc (original)
+++ trunk/core/libycp/src/YCPFloat.cc Wed Jul 4 11:47:40 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 << "<float>" << toString() << "</float>";
+}
+
// --------------------------------------------------------
Modified: trunk/core/libycp/src/YCPInteger.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPInteger.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPInteger.cc (original)
+++ trunk/core/libycp/src/YCPInteger.cc Wed Jul 4 11:47:40 2007
@@ -111,6 +111,13 @@
}
+std::ostream &
+YCPIntegerRep::toXml (std::ostream & str, int indent ) const
+{
+ return str << "<int>" << v << "</int>";
+}
+
+
// ----------------------------------------------
static long long fromStream (bytecodeistream & str)
Modified: trunk/core/libycp/src/YCPList.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPList.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPList.cc (original)
+++ trunk/core/libycp/src/YCPList.cc Wed Jul 4 11:47:40 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 << "<list>";
+ 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: trunk/core/libycp/src/YCPMap.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPMap.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPMap.cc (original)
+++ trunk/core/libycp/src/YCPMap.cc Wed Jul 4 11:47:40 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,19 @@
}
+std::ostream &
+YCPMapRep::toXml (std::ostream & str, int indent ) const
+{
+ str << "<map>";
+ for(YCPMapIterator pos = begin(); pos != end(); ++pos )
+ {
+ str << "<key>"; pos.key()->toXml( str, 0 ); str << "</key>";
+ str << "<val>"; pos.value()->toXml( str, 0 ); str << "</val>";
+ }
+ return str << "</map>";
+}
+
+
// --------------------------------------------------------
YCPMap::YCPMap(bytecodeistream & str)
Modified: trunk/core/libycp/src/YCPPath.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPPath.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPPath.cc (original)
+++ trunk/core/libycp/src/YCPPath.cc Wed Jul 4 11:47:40 2007
@@ -20,6 +20,7 @@
#include "ycp/y2log.h"
#include "ycp/YCPPath.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include
// YCPPathRep
@@ -330,6 +331,16 @@
}
std::ostream &
+YCPPathRep::Component::toXml (std::ostream & str, int indent ) const
+{
+ str << "";
+ str << component.asString();
+ return str << "</component>";
+}
+
+std::ostream &
YCPPathRep::toStream (std::ostream & str) const
{
#if 0
@@ -347,6 +358,26 @@
#endif
}
+std::ostream &
+YCPPathRep::toXml (std::ostream & str, int indent ) const
+{
+ str << "<path>";
+#if 0
+ if (Xmlcode::writeInt32 (str, components.size()))
+ {
+ for (unsigned c = 0; c < components.size(); c++)
+ {
+ if (!components[c].toStream (str))
+ break;
+ }
+ }
+ return str;
+#else
+ str << toString();
+#endif
+ return str << "</path>";
+}
+
// --------------------------------------------------------
Modified: trunk/core/libycp/src/YCPString.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPString.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPString.cc (original)
+++ trunk/core/libycp/src/YCPString.cc Wed Jul 4 11:47:40 2007
@@ -23,6 +23,7 @@
#include "ycp/y2log.h"
#include "ycp/YCPString.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
// YCPStringRep
@@ -122,6 +123,13 @@
}
+std::ostream &
+YCPStringRep::toXml (std::ostream & str, int indent ) const
+{
+ return str << "<string>" << Xmlcode::xmlify(v) << "</string>";
+}
+
+
// --------------------------------------------------------
static string
Modified: trunk/core/libycp/src/YCPSymbol.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPSymbol.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPSymbol.cc (original)
+++ trunk/core/libycp/src/YCPSymbol.cc Wed Jul 4 11:47:40 2007
@@ -20,6 +20,7 @@
#include "ycp/y2log.h"
#include "ycp/YCPSymbol.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
// YCPSymbolRep
@@ -81,6 +82,14 @@
return Bytecode::writeUstring (str, v);
}
+std::ostream &
+YCPSymbolRep::toXml (std::ostream & str, int indent ) const
+{
+ str << "<symbol>";
+ str << v.asString();
+ return str << "</symbol>";
+}
+
// --------------------------------------------------------
Modified: trunk/core/libycp/src/YCPTerm.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPTerm.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPTerm.cc (original)
+++ trunk/core/libycp/src/YCPTerm.cc Wed Jul 4 11:47:40 2007
@@ -22,6 +22,7 @@
#include "ycp/y2log.h"
#include "ycp/YCPTerm.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
// YCPTermRep
YCPTermRep::YCPTermRep(const string& s)
@@ -163,6 +164,14 @@
return l->toStream (str);
}
+std::ostream &
+YCPTermRep::toXml (std::ostream & str, int indent ) const
+{
+ str << "";
+ l->toXml( str, indent );
+ return str << "</term>";
+}
+
// --------------------------------------------------------
Modified: trunk/core/libycp/src/YCPVoid.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPVoid.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPVoid.cc (original)
+++ trunk/core/libycp/src/YCPVoid.cc Wed Jul 4 11:47:40 2007
@@ -58,6 +58,12 @@
return str;
}
+std::ostream &
+YCPVoidRep::toXml (std::ostream & str, int indent ) const
+{
+ return str << "<void/>";
+}
+
// --------------------------------------------------------
Modified: trunk/core/libycp/src/YCode.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCode.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCode.cc (original)
+++ trunk/core/libycp/src/YCode.cc Wed Jul 4 11:47:40 2007
@@ -40,6 +40,7 @@
#include "ycp/YBlock.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include "ycp/y2log.h"
#include "ycp/ExecutionEnvironment.h"
@@ -196,6 +197,17 @@
}
+std::ostream &
+YCode::toXml (std::ostream & str, int indent ) const
+{
+ ykind k = kind ();
+#if DO_DEBUG
+ y2debug ("YCode::toStream (%d:%s)", (int)k, YCode::toString (k).c_str());
+#endif
+ return str << "<ycode code=" << k << "/>";
+}
+
+
YCPValue
YCode::evaluate (bool /*cse*/)
{
@@ -390,6 +402,18 @@
return m_value->toStream (str);
}
+std::ostream &
+YConst::toXml (std::ostream & str, int indent ) const
+{
+ if (m_kind == ycConstant) {
+ y2error ("Internal error, a constant not supposed to be written to xml");
+ }
+ if (m_value.isNull())
+ return str << "<null/>";
+
+ return m_value->toXml (str, 0 );
+}
+
constTypePtr
YConst::type () const
@@ -483,6 +507,14 @@
return Bytecode::writeCharp (str, m_domain->first);
}
+std::ostream &
+YLocale::toXml (std::ostream & str, int indent ) const
+{
+ str << "first << "\">";
+ str << m_locale;
+ return str << "</locale>";
+}
+
string
YLocale::toString() const
{
@@ -732,6 +764,14 @@
}
+std::ostream &
+YFunction::toXmlDefinition (std::ostream & str, int indent ) const
+{
+ // see toXml(...)
+ return str;
+}
+
+
// writing a function to a stream is done in two (well, in fact three) parts
// 1. the SymbolEntry (done when writing the block this function is defined in)
// 2. the declaration block
@@ -762,6 +802,33 @@
}
+std::ostream &
+YFunction::toXml (std::ostream & str, int indent ) const
+{
+ bool need_declaration = ((m_declaration != 0) && (m_declaration->symbolCount() > 0));
+ bool need_definition = (m_definition != 0);
+
+ if (need_declaration || need_definition) {
+ if (need_declaration)
+ {
+ Xmlcode::pushNamespace (m_declaration->nameSpace()); // keep the declaration accessible during definition write
+ str << Xmlcode::spaces( indent+2 ) << "<declaration>\n";
+ m_declaration->toXml (str, indent+4 );
+ str << Xmlcode::spaces( indent+2 ) << "</declaration>\n";
+ }
+ str << Xmlcode::spaces( indent+2 ) << "<definition>\n";
+ m_definition->toXml (str, indent+4 );
+ str << Xmlcode::spaces( indent+2 ) << "</definition>\n";
+ if (need_declaration)
+ {
+ Xmlcode::popNamespace (m_declaration->nameSpace());
+ }
+ }
+
+ return str;
+}
+
+
constTypePtr
YFunction::type () const
{
Modified: trunk/core/libycp/src/YExpression.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YExpression.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YExpression.cc (original)
+++ trunk/core/libycp/src/YExpression.cc Wed Jul 4 11:47:40 2007
@@ -37,6 +37,7 @@
#include "ycp/SymbolTable.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#ifndef DO_DEBUG
#define DO_DEBUG 0
@@ -143,6 +144,14 @@
return str;
}
+std::ostream &
+YEVariable::toXml( std::ostream & str, int indent ) const
+{
+ str << "";
+ str << m_entry->toString (false /*definition*/);
+ return str << "";
+}
+
// ------------------------------------------------------------------
// reference (-> SymbolEntry)
@@ -207,6 +216,15 @@
}
+std::ostream &
+YEReference::toXml (std::ostream & str, int indent ) const
+{
+ str << "<yereference>";
+ Xmlcode::writeEntry (str, m_entry);
+ return str << "</yereference>";
+}
+
+
constTypePtr
YEReference::type () const
{
@@ -369,6 +387,14 @@
return Bytecode::writeYCodelist (str, m_parameters);
}
+std::ostream &
+YETerm::toXml (std::ostream & str, int indent ) const
+{
+ str << "";
+ Xmlcode::writeYCodelist (str, m_parameters);
+ return str << "</yeterm>";
+}
+
// ------------------------------------------------------------------
@@ -398,23 +424,31 @@
{
}
-
-string
-YECompare::toString () const
+static string
+compare_op_string( YECompare::c_op op )
{
- string s = "(" + m_left->toString();
- switch (m_op)
+ switch (op)
{
- case C_EQ: s += " == "; break;
- case C_NEQ: s += " != "; break;
- case C_LT: s += " < "; break;
- case C_GE: s += " >= "; break;
- case C_LE: s += " <= "; break;
- case C_GT: s += " > "; break;
+ case YECompare::C_EQ: return "=="; break;
+ case YECompare::C_NEQ: return "!="; break;
+ case YECompare::C_LT: return "<"; break;
+ case YECompare::C_GE: return ">="; break;
+ case YECompare::C_LE: return "<="; break;
+ case YECompare::C_GT: return ">"; break;
default:
- s += " ?compare? ";
break;
}
+ return "?compare?";
+}
+
+
+string
+YECompare::toString () const
+{
+ string s = "(" + m_left->toString();
+ s += " ";
+ s += compare_op_string( m_op );
+ s += " ";
s += m_right->toString();
return s + ")";
}
@@ -490,6 +524,16 @@
}
+std::ostream &
+YECompare::toXml (std::ostream & str, int indent ) const
+{
+ str << "";
+ str << "<lhs>"; m_left->toXml( str, 0 ); str << "</lhs>";
+ str << "<rhs>"; m_right->toXml( str, 0 ); str << "</rhs>";
+ return str << "</compare>";
+}
+
+
// ------------------------------------------------------------------
// locale expression (-> singular, plural, count)
@@ -592,6 +636,16 @@
}
+std::ostream &
+YELocale::toXml (std::ostream & str, int indent ) const
+{
+ str << "first << "\">";
+ str << "<singular>" << m_singular << "</singular>";
+ str << "<plural>" << m_plural << "</plural>";
+ return str << "</locale>";
+}
+
+
// ------------------------------------------------------------------
// list expression (-> value, next list value)
@@ -725,6 +779,15 @@
}
+std::ostream &
+YEList::toXml (std::ostream & str, int indent ) const
+{
+ str << "<list>";
+ Xmlcode::writeYCodelist( str, m_first );
+ return str << "</list>";
+}
+
+
constTypePtr
YEList::type () const
{
@@ -883,6 +946,21 @@
}
+std::ostream &
+YEMap::toXml( std::ostream & str, int indent ) const
+{
+ str << "<map>";
+ mapval_t *mapp = m_first;
+ while (mapp)
+ {
+ str << "<key>"; mapp->key->toXml( str, 0 ); str << "</key>";
+ str << "<val>"; mapp->value->toXml( str, 0 ); str << "</val>";
+ mapp = mapp->next;
+ }
+ return str << "</map>";
+}
+
+
constTypePtr
YEMap::type () const
{
@@ -1090,6 +1168,17 @@
return m_value->toStream (str);
}
+std::ostream &
+YEPropagate::toXml (std::ostream & str, int indent ) const
+{
+ str << "<yepropagate>";
+ str << "<from>"; m_from->toXml( str, 0); str << "</from>";
+ str << "<to>"; m_to->toXml( str, 0 ); str << "</to>";
+ m_value->toXml( str, 0 );
+ return str << "</yepropagate>";
+}
+
+
// ------------------------------------------------------------------
// unary expression (-> declaration_t, arg)
@@ -1181,6 +1270,18 @@
}
+std::ostream &
+YEUnary::toXml (std::ostream & str, int indent ) const
+{
+ str << "<yeunary>";
+ extern StaticDeclaration static_declarations;
+
+ static_declarations.writeXmlDeclaration( str, m_decl );
+ m_arg->toXml( str, 0 );
+ return str << "</yeunary>";
+}
+
+
// ------------------------------------------------------------------
// binary expression (-> declaration_t, arg1, arg2)
@@ -1284,6 +1385,19 @@
}
+std::ostream &
+YEBinary::toXml (std::ostream & str, int indent ) const
+{
+ str << "<yebinary>";
+ extern StaticDeclaration static_declarations;
+
+ static_declarations.writeXmlDeclaration (str, m_decl);
+ m_arg1->toXml( str, 0 );
+ m_arg2->toXml( str, 0 );
+ return str << "</yebinary>";
+}
+
+
constTypePtr
YEBinary::type () const
{
@@ -1390,6 +1504,17 @@
}
+std::ostream &
+YETriple::toXml (std::ostream & str, int indent ) const
+{
+ str << "<yetriple>";
+ str << "<cond>"; m_expr->toXml( str, 0); str << "</cond>";
+ str << "<true>"; m_true->toXml( str, 0 ); str << "</true>";
+ str << "<false>"; m_false->toXml( str, 0); str << "</false>";
+ return str << "</yetriple>";
+}
+
+
// ------------------------------------------------------------------
// is (expression, type)
@@ -1484,6 +1609,16 @@
}
+std::ostream &
+YEIs::toXml (std::ostream & str, int indent ) const
+{
+ str << "<yeis>";
+ str << "<type>"; m_type->toXml( str, 0); str << "</type>";
+ str << "<expr>"; m_expr->toXml( str, 0); str << "</expr>";
+ return str << "</yeis>";
+}
+
+
// ------------------------------------------------------------------
// Return (expression)
@@ -1530,6 +1665,14 @@
return m_expr->toStream (str);
}
+std::ostream &
+YEReturn::toXml (std::ostream & str, int indent ) const
+{
+ str << "<yereturn>";
+ m_expr->toXml( str, 0 );
+ return str << "</yereturn>";
+}
+
// ------------------------------------------------------------------
// bracket expression: identifier [ arg, arg, ...] : default
@@ -1693,6 +1836,23 @@
}
+std::ostream &
+YEBracket::toXml (std::ostream & str, int indent ) const
+{
+ str << "<yebracket>";
+ str << "<var>";
+ m_var->toXml( str, 0 );
+ str << "</var><arg>";
+ m_arg->toXml( str, 0 );
+ str << "</arg><def>";
+ m_def->toXml( str, 0 );
+ str << "</def><type>";
+ m_resultType->toXml( str, 0);
+ str << "</type>";
+ return str << "</yebracket>";
+}
+
+
// ------------------------------------------------------------------
// builtin function ref (-> declaration_t, type, parameters)
@@ -1765,6 +1925,24 @@
}
+std::ostream &
+YEBuiltin::toXml( std::ostream & str, int indent ) const
+{
+ str << "name << "\">";
+
+ if (m_parameterblock != 0)
+ {
+ Xmlcode::pushNamespace( m_parameterblock->nameSpace() );
+ }
+ Xmlcode::writeYCodelist( str, m_parameters );
+ if (m_parameterblock != 0)
+ {
+ Xmlcode::popNamespace( m_parameterblock->nameSpace() );
+ }
+ return str << "</call>";
+}
+
+
YEBuiltin::~YEBuiltin ()
{
ycodelist_t *parm = m_parameters;
@@ -2739,6 +2917,23 @@
}
+std::ostream &
+YECall::toXml (std::ostream & str, int indent ) const
+{
+ str << "nameSpace()->name() << "\" name=\"" << m_sentry->name() << "\">";
+ if (m_next_param_id > 0) {
+ str << "<parameters>";
+
+ for (uint i = 0 ; i < m_next_param_id; i++)
+ {
+ m_parameters[i]->toXml( str, 0 );
+ }
+ str << "</parameters>";
+ }
+ return str << "</call>";
+}
+
+
constTypePtr
YECall::type () const
{
Modified: trunk/core/libycp/src/YStatement.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YStatement.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YStatement.cc (original)
+++ trunk/core/libycp/src/YStatement.cc Wed Jul 4 11:47:40 2007
@@ -31,6 +31,7 @@
#include "ycp/YBlock.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
#include "ycp/y2log.h"
#include "ycp/ExecutionEnvironment.h"
@@ -114,6 +115,12 @@
return Bytecode::writeInt32 (str, m_line);
}
+std::ostream &
+YStatement::toXml( std::ostream & str, int indent ) const
+{
+ return str << "<statement line=" << m_line << "/>";
+}
+
// ------------------------------------------------------------------
// "break"
@@ -152,6 +159,12 @@
return YStatement::toStream (str);
}
+std::ostream &
+YSBreak::toXml (std::ostream & str, int indent ) const
+{
+ return str << "<break/>";
+}
+
// ------------------------------------------------------------------
// "continue"
@@ -190,6 +203,12 @@
return YStatement::toStream (str);
}
+std::ostream &
+YSContinue::toXml (std::ostream & str, int indent ) const
+{
+ return str << "<continue/>";
+}
+
// ------------------------------------------------------------------
// expression as statement
@@ -232,6 +251,15 @@
}
+std::ostream &
+YSExpression::toXml( std::ostream & str, int indent ) const
+{
+ str << "<expression>";
+ m_expr->toXml( str, indent );
+ return str << "</expression>";
+}
+
+
YCPValue
YSExpression::evaluate (bool cse)
{
@@ -282,6 +310,13 @@
}
+std::ostream &
+YSBlock::toXml (std::ostream & str, int indent ) const
+{
+ return m_block->toXml( str, indent );
+}
+
+
YCPValue
YSBlock::evaluate (bool cse)
{
@@ -379,6 +414,16 @@
}
+std::ostream &
+YSReturn::toXml (std::ostream & str, int indent ) const
+{
+ str << "<return>";
+ if (m_value != 0)
+ m_value->toXml( str, 0 );
+ return str << "</return>";
+}
+
+
YCPValue
YSReturn::evaluate (bool cse)
{
@@ -478,6 +523,17 @@
}
+std::ostream &
+YSFunction::toXml( std::ostream & str, int indent ) const
+{
+ str << "name() << "\">\n";
+
+ function()->toXml( str, indent+2 );
+
+ return str << Xmlcode::spaces( indent ) << "";
+}
+
+
// ------------------------------------------------------------------
// typedef (-> type string)
@@ -514,6 +570,15 @@
}
+std::ostream &
+YSTypedef::toXml( std::ostream & str, int indent ) const
+{
+ str << "";
+ m_type->toXml( str, 0 );
+ return str << "</typedef>";
+}
+
+
// FIXME: needed ?
YCPValue
@@ -569,6 +634,18 @@
}
+std::ostream &
+YSAssign::toXml( std::ostream & str, int indent ) const
+{
+ str << "<assign>";
+ str << "<lhs>";
+ str << m_entry->toString (false /*definition*/);
+ str << "</lhs><rhs>";
+ m_code->toXml( str, 0 );
+ return str << "</rhs></assign>";
+}
+
+
YCPValue
YSAssign::evaluate (bool cse)
{
@@ -668,6 +745,20 @@
}
+std::ostream &
+YSBracket::toXml( std::ostream & str, int indent ) const
+{
+ str << "<bracket>";
+ str << "<lhs>";
+ Xmlcode::writeEntry( str, m_entry );
+ str << "<arg>"; m_arg->toXml( str, 0 ); str << "</arg>";
+ str << "</lhs><rhs>";
+ m_code->toXml( str, 0 );
+ str << "</rhs>";
+ return str << "</bracket>";
+}
+
+
// commit bracket assign recursively
YCPValue
@@ -918,6 +1009,31 @@
}
+std::ostream &
+YSIf::toXml (std::ostream & str, int indent ) const
+{
+ str << "<if>";
+
+ m_condition->toXml( str, 0 );
+
+ if (m_true)
+ {
+ str << endl << Xmlcode::spaces( indent+2 ) << "<then>\n";
+ m_true->toXml( str, indent+4 );
+ str << Xmlcode::spaces( indent+2 ) << "</then>\n";
+ str << Xmlcode::spaces( indent );
+ }
+ if (m_false)
+ {
+ str << endl << Xmlcode::spaces( indent+2 ) << "<else>\n";
+ m_false->toXml( str, indent+4 );
+ str << Xmlcode::spaces( indent+2 ) << "</else>\n";
+ str << Xmlcode::spaces( indent );
+ }
+ return str << "</if>";
+}
+
+
YCPValue
YSIf::evaluate (bool cse)
{
@@ -1019,6 +1135,20 @@
}
+std::ostream &
+YSWhile::toXml (std::ostream & str, int indent ) const
+{
+ str << "<while>\n";
+ str << Xmlcode::spaces( indent+2 ) << "<cond>"; str << m_condition->toXml(str, 0 ); str << "</cond>\n";
+ if (m_loop) {
+ str << Xmlcode::spaces( indent+2 ) << "<do>";
+ m_loop->toXml(str, indent );
+ str << Xmlcode::spaces( indent+2 ) << "</do>\n";
+ }
+ return str << Xmlcode::spaces( indent ) << "</while>";
+}
+
+
YCPValue
YSWhile::evaluate (bool cse)
{
@@ -1150,6 +1280,23 @@
}
+std::ostream &
+YSRepeat::toXml (std::ostream & str, int indent ) const
+{
+ str << "<repeat>\n";
+ if (m_loop != 0)
+ {
+ str << Xmlcode::spaces( indent+2 ) << "<do>\n";
+ m_loop->toXml( str, indent+4 );
+ str << Xmlcode::spaces( indent+2 ) << "</do>\n";
+ }
+ str << Xmlcode::spaces( indent+2 ) << "<until>";
+ m_condition->toXml( str, 0 );
+ str << "</until>\n";
+ return str << Xmlcode::spaces( indent ) << "</repeat>";
+}
+
+
string
YSRepeat::toString () const
{
@@ -1290,6 +1437,23 @@
}
+std::ostream &
+YSDo::toXml( std::ostream & str, int indent ) const
+{
+ str << "<do>";
+ if (m_loop != 0)
+ {
+ str << "<do>";
+ m_loop->toXml( str, indent );
+ str << "</do>";
+ }
+ str << "<while>";
+ m_condition->toXml( str, indent );
+ str << "</while>";
+ return str << "</do>";
+}
+
+
YCPValue
YSDo::evaluate (bool cse)
{
@@ -1393,6 +1557,13 @@
}
+std::ostream &
+YSTextdomain::toXml (std::ostream & str, int indent ) const
+{
+ return str << "<textdomain>" << m_domain.asString() << "</textdomain>";
+}
+
+
YCPValue
YSTextdomain::evaluate (bool /*cse*/)
{
@@ -1449,6 +1620,15 @@
}
+std::ostream &
+YSInclude::toXml( std::ostream & str, int indent ) const
+{
+ str << "" << m_filename.asString() << "</include>";
+}
+
+
YCPValue
YSInclude::evaluate (bool cse)
{
@@ -1598,6 +1778,14 @@
}
+std::ostream &
+YSImport::toXml( std::ostream & str, int indent ) const
+{
+ Xmlcode::pushNamespace (nameSpace()); // see YBlock::toXml(str) for popUptoNamespace()
+ return str << "<import>" << m_name.asString() << "</import>";
+}
+
+
YCPValue
YSImport::evaluate (bool cse)
{
@@ -1654,6 +1842,13 @@
}
+std::ostream &
+YSFilename::toXml(std::ostream & str, int indent ) const
+{
+ return str << "<filename>" << m_filename.asString() << "</filename>";
+}
+
+
YCPValue
YSFilename::evaluate (bool cse)
{
@@ -1750,6 +1945,20 @@
}
+std::ostream &
+YSSwitch::toXml( std::ostream & str, int indent ) const
+{
+ str << "<switch>";
+
+ str << "<condition>";
+ m_condition->toXml( str, 0 );
+ str << "</condition>\n";
+
+ m_block->toXmlSwitch( m_cases, m_defaultcase, str, indent+2 );
+ return str << endl << Xmlcode::spaces( indent ) << "</switch>";
+}
+
+
YCPValue
YSSwitch::evaluate (bool cse)
{
Modified: trunk/core/libycp/src/YSymbolEntry.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YSymbolEntry.cc?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/YSymbolEntry.cc (original)
+++ trunk/core/libycp/src/YSymbolEntry.cc Wed Jul 4 11:47:40 2007
@@ -32,6 +32,7 @@
#include "ycp/SymbolTable.h"
#include "ycp/StaticDeclaration.h"
#include "ycp/Bytecode.h"
+#include "ycp/Xmlcode.h"
IMPL_DERIVED_POINTER(YSymbolEntry, SymbolEntry);
@@ -261,6 +262,31 @@
}
+std::ostream &
+YSymbolEntry::toXml (std::ostream & str, int indent ) const
+{
+ str << Xmlcode::spaces( indent ) << "toXmlString(); str << "\"";
+ str << ">";
+ str << m_name.asString();
+#if 0
+ if (m_category == c_variable)
+ {
+ if (m_payload.m_code != 0) // formal arguments don't have a payload (a default value)
+ {
+ str << "<payload>";
+ m_payload.m_code->toXml( str, indent+2 );
+ str << "</payload>";
+ }
+ }
+#endif
+ return str << "";
+ // value is never written
+}
+
+
void
YSymbolEntry::setDeclaration (declaration_t *decl)
{
Modified: trunk/core/libycp/src/include/ycp/Point.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/Point.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/Point.h (original)
+++ trunk/core/libycp/src/include/ycp/Point.h Wed Jul 4 11:47:40 2007
@@ -79,5 +79,6 @@
std::string toString (void) const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
};
#endif // Point_h
Modified: trunk/core/libycp/src/include/ycp/StaticDeclaration.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/StaticDeclaration.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/StaticDeclaration.h (original)
+++ trunk/core/libycp/src/include/ycp/StaticDeclaration.h Wed Jul 4 11:47:40 2007
@@ -108,6 +108,7 @@
// write declaration to stream (name and type)
std::ostream & writeDeclaration (std::ostream & str, const declaration_t *decl) const;
+ std::ostream & writeXmlDeclaration (std::ostream & str, const declaration_t *decl) const;
// read declaration from stream (return declaration matching name and type _exactly_)
declaration_t *readDeclaration (bytecodeistream & str) const;
Modified: trunk/core/libycp/src/include/ycp/SymbolTable.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/SymbolTable.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/SymbolTable.h (original)
+++ trunk/core/libycp/src/include/ycp/SymbolTable.h Wed Jul 4 11:47:40 2007
@@ -90,6 +90,7 @@
string toStringSymbols () const;
void makeDefinition (int line); // convert declaration to definition (exchanges m_point)
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
// remove yourself from the SymbolTable.
void remove ();
@@ -195,6 +196,7 @@
// write usage to stream, see YSImport
std::ostream &writeUsage (std::ostream & str) const;
+ std::ostream &writeXmlUsage( std::ostream & str, int indent ) const;
//---------------------------------------------------------------
// string
Modified: trunk/core/libycp/src/include/ycp/Type.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/Type.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/Type.h (original)
+++ trunk/core/libycp/src/include/ycp/Type.h Wed Jul 4 11:47:40 2007
@@ -30,6 +30,7 @@
class FunctionType;
class bytecodeistream;
+class xmlcodeistream;
/// YCP type
class Type : public Rep
@@ -182,12 +183,18 @@
* Converts a type code to its YCP notation.
*/
virtual string toString () const;
+ virtual string toXmlString () const;
/**
- * write out to stream
+ * write bytecode out to stream
*/
virtual std::ostream & toStream (std::ostream & str) const;
+ /**
+ * write xml out to stream
+ */
+ virtual std::ostream & toXml (std::ostream & str, int indent ) const;
+
/*
* is base or constructed type
*/
Added: trunk/core/libycp/src/include/ycp/Xmlcode.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/Xmlcode.h?rev=39159&view=auto
==============================================================================
--- trunk/core/libycp/src/include/ycp/Xmlcode.h (added)
+++ trunk/core/libycp/src/include/ycp/Xmlcode.h Wed Jul 4 11:47:40 2007
@@ -0,0 +1,139 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: Xmlcode.h
+
+ Primitive xmlcode I/O functions.
+ Acts as a namespace wrapper.
+
+ Author: Klaus Kaempf
+ Maintainer: Klaus Kaempf
+
+/-*/
+// -*- c++ -*-
+
+#ifndef Xmlcode_h
+#define Xmlcode_h
+
+#include "ycp/YCPValue.h"
+#include "ycp/YCode.h"
+#include "ycp/YStatement.h"
+#include "ycp/YBlock.h"
+#include "ycp/Type.h"
+
+class Y2Namespace;
+
+#include <iosfwd>
+#include <string>
+#include <map>
+
+#include <fstream>
+
+/// An istream that remembers some data about the xmlcode.
+class xmlcodeistream : public std::ifstream
+{
+ int m_major, m_minor, m_release;
+ public:
+ xmlcodeistream (string filename);
+ bool isVersion (int major, int minor, int revision);
+ bool isVersionAtMost (int major, int minor, int revision);
+
+ int major () const { return m_major; }
+ int minor () const { return m_minor; }
+ int release () const { return m_release; }
+};
+
+/// *.ybc I/O
+class Xmlcode {
+ static int m_namespace_nesting_level;
+ static int m_namespace_nesting_array_size;
+ static int m_namespace_tare_level;
+
+ /// references to namespaces
+ struct namespaceentry_t {
+ const Y2Namespace *name_space;
+ bool with_xrefs; ///< external references... ???
+ };
+ static namespaceentry_t *m_namespace_nesting_array;
+ static map* m_xmlcodeCache;
+
+ public:
+ /** Thrown instead of unsetting YCode::valid */
+ class Invalid {};
+
+ static string spaces( int count );
+
+ static string xmlify( const string & s );
+
+ // bytepointer I/O
+ static std::ostream & writeBytep (std::ostream & streamref, const unsigned char * bytep, unsigned int len);
+ static unsigned char * readBytep (xmlcodeistream & streamref);
+
+ // Type I/O
+ static std::ostream & writeType (std::ostream & str, constTypePtr type);
+ static TypePtr readType (xmlcodeistream & str);
+
+ // ycodelist_t * I/O
+ static std::ostream & writeYCodelist (std::ostream & str, const ycodelist_t *codelist);
+ static bool readYCodelist (xmlcodeistream & str, ycodelist_t **anchor);
+
+ //-----------------------------------------------------------
+ // block nesting handling
+ //
+ static void namespaceInit ();
+ // retrieve ID (nesting level) for namespace
+ static int namespaceId (const Y2Namespace *name_space);
+ // retrieve namespace for ID
+ static const Y2Namespace *namespacePtr (int namespace_id);
+
+ // push given namespace to id stack, return new id, -1 on error
+ static int pushNamespace (const Y2Namespace *name_space, bool with_xrefs = false);
+
+ // pop given namespace from id stack, return namespace id, -1 on error
+ static int popNamespace (const Y2Namespace *name_space);
+
+ // pop all from id stack until given namespace is reached and popped too
+ static void popUptoNamespace (const Y2Namespace *name_space);
+
+ // reset current namespace stack to 'empty' for module loading
+ // returns a tare id needed later
+ static int tareStack ();
+ static void untareStack (int tare_id);
+
+ //-----------------------------------------------------------
+ // SymbolEntry pointer (!) handling
+ // the SymbolEntries itself are 'owned' by Y2Namespace (YBlock in YCP) and referenced via pointers
+ // to SymbolEntry. These functions handle stream I/O for SymbolEntry pointers.
+ static std::ostream &writeEntry (std::ostream & str, const SymbolEntryPtr entry);
+ static SymbolEntryPtr readEntry (xmlcodeistream & str);
+
+ //-----------------------------------------------------------
+ // YCode read.
+ // Must be implemented outside of YCode since we have derived classes to allocate...
+ // see YCode for write
+ static YCodePtr readCode (xmlcodeistream & str);
+
+ // File I/O
+ // reading and writing complete files is done via separate functions
+ // which add/check a 'magic value' header denoting "YCode" and its version.
+
+ // read YCode from file in Module path, return YBlock (NULL in case of error)
+ static YBlockPtr readModule (const string & mname);
+
+ // read YCode from file, return YCode (YError in case of failure)
+ static YCodePtr readFile (const string & filename);
+
+ // write YCode to file, return true on success (check errno for errors)
+ static bool writeFile (const YCodePtr code, const string & filename);
+};
+
+#endif // Xmlcode_h
Modified: trunk/core/libycp/src/include/ycp/YBlock.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YBlock.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YBlock.h (original)
+++ trunk/core/libycp/src/include/ycp/YBlock.h Wed Jul 4 11:47:40 2007
@@ -281,6 +281,8 @@
// write block to stream
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml( std::ostream & str, int indent ) const;
+ std::ostream & toXmlSwitch( map cases, int defaultcase, std::ostream & str, int indent ) const;
};
Modified: trunk/core/libycp/src/include/ycp/YCPBoolean.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPBoolean.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPBoolean.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPBoolean.h Wed Jul 4 11:47:40 2007
@@ -76,6 +76,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_BOOLEAN. See @ref YCPValueRep#valuetype.
Modified: trunk/core/libycp/src/include/ycp/YCPByteblock.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPByteblock.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPByteblock.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPByteblock.h Wed Jul 4 11:47:40 2007
@@ -85,6 +85,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Compares two bytes blocks.
Modified: trunk/core/libycp/src/include/ycp/YCPCode.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPCode.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPCode.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPCode.h Wed Jul 4 11:47:40 2007
@@ -73,6 +73,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_CODE. See @ref YCPValueRep#type.
@@ -146,6 +147,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const { return str; };
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_BREAK. See @ref YCPValueRep#type.
@@ -213,6 +215,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const { return str; };
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_BREAK. See @ref YCPValueRep#type.
@@ -279,6 +282,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_ENTRY. See @ref YCPValueRep#type.
@@ -350,6 +354,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_Reference. See @ref YCPValueRep#type.
Modified: trunk/core/libycp/src/include/ycp/YCPElement.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPElement.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPElement.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPElement.h Wed Jul 4 11:47:40 2007
@@ -115,6 +115,9 @@
std::ostream & toStream (std::ostream & str ) const { \
return element->toStream (str); \
} \
+ std::ostream & toXml (std::ostream & str, int indent ) const { \
+ return element->toXml( str, indent ); \
+ } \
YCPValueType valuetype () const { return (static_cast(element))->valuetype (); }
@@ -274,6 +277,7 @@
* Writes the value to a stream in bytecode format.
*/
virtual std::ostream & toStream (std::ostream & str) const = 0;
+ virtual std::ostream & toXml (std::ostream & str, int indent ) const = 0;
/**
* Returns a shallow copy of this elementRep. Redefine this method
Modified: trunk/core/libycp/src/include/ycp/YCPExternal.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPExternal.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPExternal.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPExternal.h Wed Jul 4 11:47:40 2007
@@ -73,6 +73,7 @@
* store the data in persistent stream.
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_EXTERNAL. See @ref YCPValueRep#valuetype.
Modified: trunk/core/libycp/src/include/ycp/YCPFloat.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPFloat.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPFloat.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPFloat.h Wed Jul 4 11:47:40 2007
@@ -84,6 +84,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_FLOAT. See @ref YCPValueRep#type.
Modified: trunk/core/libycp/src/include/ycp/YCPInteger.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPInteger.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPInteger.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPInteger.h Wed Jul 4 11:47:40 2007
@@ -74,6 +74,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_INTEGER. See @ref YCPValueRep#type.
Modified: trunk/core/libycp/src/include/ycp/YCPList.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPList.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPList.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPList.h Wed Jul 4 11:47:40 2007
@@ -171,6 +171,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_LIST. See @ref YCPValueRep#type.
Modified: trunk/core/libycp/src/include/ycp/YCPMap.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPMap.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPMap.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPMap.h Wed Jul 4 11:47:40 2007
@@ -129,6 +129,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_MAP. See @ref YCPValueRep#valuetype.
Modified: trunk/core/libycp/src/include/ycp/YCPPath.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPPath.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPPath.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPPath.h Wed Jul 4 11:47:40 2007
@@ -51,6 +51,7 @@
}
string toString() const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
};
vector<Component> components;
@@ -149,6 +150,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_PATH. See @ref YCPValueRep#valuetype.
Modified: trunk/core/libycp/src/include/ycp/YCPString.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPString.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPString.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPString.h Wed Jul 4 11:47:40 2007
@@ -86,6 +86,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_STRING. See @ref YCPValueRep#valuetype.
Modified: trunk/core/libycp/src/include/ycp/YCPSymbol.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPSymbol.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPSymbol.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPSymbol.h Wed Jul 4 11:47:40 2007
@@ -84,6 +84,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_SYMBOL. See @ref YCPValueRep#valuetype.
Modified: trunk/core/libycp/src/include/ycp/YCPTerm.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPTerm.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPTerm.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPTerm.h Wed Jul 4 11:47:40 2007
@@ -127,6 +127,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Mapping for the term's list isEmpty() function
Modified: trunk/core/libycp/src/include/ycp/YCPValue.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPValue.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPValue.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPValue.h Wed Jul 4 11:47:40 2007
@@ -262,6 +262,7 @@
*/
YCPOrder compare(const YCPValue &v, bool rl = false) const;
+ virtual std::ostream & toXml (std::ostream & str, int indent ) const = 0;
};
Modified: trunk/core/libycp/src/include/ycp/YCPVoid.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPVoid.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPVoid.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPVoid.h Wed Jul 4 11:47:40 2007
@@ -52,6 +52,7 @@
* Output value as bytecode to stream
*/
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/**
* Returns YT_VOID. See @ref YCPValueRep#valuetype.
Modified: trunk/core/libycp/src/include/ycp/YCode.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCode.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCode.h (original)
+++ trunk/core/libycp/src/include/ycp/YCode.h Wed Jul 4 11:47:40 2007
@@ -152,6 +152,7 @@
* see Bytecode for read
*/
virtual std::ostream & toStream (std::ostream & str) const = 0;
+ virtual std::ostream & toXml (std::ostream & str, int indent ) const = 0;
/**
* returns true if the YCode represents a constant
@@ -211,6 +212,7 @@
virtual ykind kind() const;
string toString() const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/** yes */
virtual bool isConstant () const { return true; }
YCPValue evaluate (bool cse = false);
@@ -257,6 +259,7 @@
const char *domain () const;
string toString() const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type() const { return Type::Locale; }
@@ -312,8 +315,10 @@
string toStringDeclaration () const;
string toString () const;
- std::ostream & toStreamDefinition (std::ostream & str) const;
- std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toStreamDefinition (std::ostream & str ) const;
+ std::ostream & toXmlDefinition (std::ostream & str, int indent ) const;
+ std::ostream & toStream (std::ostream & str ) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
virtual YCPValue evaluate (bool cse = false);
constTypePtr type() const;
};
Modified: trunk/core/libycp/src/include/ycp/YExpression.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YExpression.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YExpression.h (original)
+++ trunk/core/libycp/src/include/ycp/YExpression.h Wed Jul 4 11:47:40 2007
@@ -72,6 +72,7 @@
virtual bool isReferenceable () const { return true; }
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return m_entry->type(); }
};
@@ -92,6 +93,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const;
};
@@ -114,6 +116,7 @@
const char *name () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return Type::Term; }
};
@@ -144,6 +147,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return Type::Boolean; }
};
@@ -166,6 +170,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return Type::Locale; }
};
@@ -187,6 +192,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const;
int count () const;
YCodePtr value (int index) const;
@@ -212,6 +218,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const;
};
@@ -234,6 +241,7 @@
bool canPropagate(const YCPValue& value, constTypePtr to_type) const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return m_to; }
};
@@ -256,6 +264,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return ((constFunctionTypePtr)m_decl->type)->returnType (); }
};
@@ -280,6 +289,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const;
};
@@ -304,6 +314,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return m_true->type ()->commontype (m_false->type ()); }
};
@@ -324,6 +335,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return Type::Boolean; }
};
@@ -343,6 +355,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return m_expr->type(); }
};
@@ -365,6 +378,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const { return m_resultType; }
YCodePtr def () const { return m_def; }
};
@@ -407,6 +421,7 @@
string toString () const;
YCPValue evaluate (bool cse = false);
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type () const;
constTypePtr completeType () const;
YBlockPtr parameterBlock () const;
@@ -451,6 +466,7 @@
virtual constTypePtr finalize ();
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
constTypePtr type() const;
string qualifiedName () const;
Modified: trunk/core/libycp/src/include/ycp/YStatement.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YStatement.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YStatement.h (original)
+++ trunk/core/libycp/src/include/ycp/YStatement.h Wed Jul 4 11:47:40 2007
@@ -72,6 +72,7 @@
~YStatement () {};
virtual string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
/** yes */
virtual bool isStatement () const { return true; }
int line () const { return m_line; };
@@ -94,6 +95,7 @@
virtual ykind kind () const { return ysBreak; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
};
@@ -112,6 +114,7 @@
virtual ykind kind () const { return ysContinue; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
};
@@ -132,6 +135,7 @@
virtual ykind kind () const { return ysExpression; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -153,6 +157,7 @@
virtual ykind kind () const { return ysBlock; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -177,6 +182,7 @@
void clearValue (); // needed if justReturn triggers
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -199,6 +205,7 @@
virtual ykind kind () const { return ysTypedef; }
string toString() const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -229,6 +236,7 @@
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -253,6 +261,7 @@
virtual ykind kind () const { return ysAssign; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
};
@@ -294,6 +303,7 @@
virtual ykind kind () const { return ysBracket; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
// recursively extract list arg at idx, get value from current at idx
// and replace with value. re-generating the list/map/term during unwind
YCPValue commit (YCPValue current, int idx, YCPList arg, YCPValue value);
@@ -320,6 +330,7 @@
virtual ykind kind () const { return ysIf; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -343,6 +354,7 @@
virtual ykind kind () const { return ysWhile; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -366,6 +378,7 @@
virtual ykind kind () const { return ysRepeat; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -389,6 +402,7 @@
virtual ykind kind () const { return ysDo; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -410,6 +424,7 @@
virtual ykind kind () const { return ysTextdomain; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
const char *domain () const { return m_domain->c_str(); };
@@ -435,6 +450,7 @@
virtual ykind kind () const { return ysInclude; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
string filename () const { return m_filename; };
@@ -458,6 +474,7 @@
string name () const;
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -479,6 +496,7 @@
virtual ykind kind () const { return ysFilename; }
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
};
@@ -508,6 +526,7 @@
string name () const;
string toString () const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
YCPValue evaluate (bool cse = false);
constTypePtr type () const { return Type::Void; };
constTypePtr conditionType () const { return m_condition->type (); };
Modified: trunk/core/libycp/src/include/ycp/YSymbolEntry.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YSymbolEntry.h?rev=39159&r1=39158&r2=39159&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YSymbolEntry.h (original)
+++ trunk/core/libycp/src/include/ycp/YSymbolEntry.h Wed Jul 4 11:47:40 2007
@@ -103,6 +103,7 @@
virtual string toString (bool with_type = true) const;
std::ostream & toStream (std::ostream & str) const;
+ std::ostream & toXml (std::ostream & str, int indent ) const;
};
#endif // YSymbolEntry_h
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org