Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 96bf7e43 authored by frey_m's avatar frey_m
Browse files

apply patch

parent 2654cde8
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@
#include "Attributes/Reference.h"
#include "Attributes/opalstr.h"
#include "Attributes/StringArray.h"
#include "Attributes/UString.h"
#include "Attributes/TableRow.h"
#include "Attributes/TokenList.h"
#include "Attributes/TokenListArray.h"
......@@ -308,7 +309,8 @@ namespace Attributes {
if(attr.isBaseAllocated()) {
AttributeBase *base = &attr.getBase();
std::string expr;
if(dynamic_cast<String *>(&attr.getHandler())) {
if(dynamic_cast<String *>(&attr.getHandler())
|| dynamic_cast<UString *>(&attr.getHandler())) {
expr = dynamic_cast<SValue<std::string> *>(base)->evaluate();
} else if(SValue<SRefAttr<std::string> > *ref =
dynamic_cast<SValue<SRefAttr<std::string> > *>(base)) {
......@@ -370,6 +372,33 @@ namespace Attributes {
// ----------------------------------------------------------------------
// String array value.
Attribute makeUString(const std::string &name, const std::string &help) {
return Attribute(new UString(name, help), nullptr);
}
Attribute
makeUString(const std::string &name, const std::string &help, const std::string &initial) {
return Attribute(new UString(name, help), new SValue<std::string>(initial));
}
void setUString(Attribute &attr, const std::string &val) {
if(dynamic_cast<const UString *>(&attr.getHandler())) {
attr.set(new SValue<std::string>(val));
} else if(SValue<SRefAttr<std::string> > *ref =
dynamic_cast<SValue<SRefAttr<std::string> >*>(&attr.getBase())) {
const SRefAttr<std::string> &value = ref->evaluate();
value.set(val);
} else {
throw OpalException("Attributes::setString()", "Attribute \"" +
attr.getName() + "\" is not a string.");
}
}
// ----------------------------------------------------------------------
// String array value.
Attribute makeStringArray(const std::string &name, const std::string &help) {
return Attribute(new StringArray(name, help), nullptr);
}
......
......@@ -139,11 +139,22 @@ namespace Attributes {
/// Set string value.
extern void setString(Attribute &attr, const std::string &val);
/// Make uppercase string attribute.
// Initial value undefined.
extern Attribute makeUString(const std::string &name, const std::string &help);
/// Make uppercase string attribute.
// Initial value is defined.
extern Attribute
makeUString(const std::string &name, const std::string &help, const std::string &initial);
/// Set uppercase string value.
extern void setUString(Attribute &attr, const std::string &val);
/// Create a string array attribute.
// Initial value is empty array.
extern Attribute makeStringArray(const std::string &name, const std::string &help);
/// Get string array value.
extern std::vector<std::string> getStringArray(const Attribute &);
......@@ -187,4 +198,4 @@ namespace Attributes {
};
#endif // OPAL_Attributes_HH
#endif // OPAL_Attributes_HH
\ No newline at end of file
......@@ -12,6 +12,7 @@ set (_SRCS
TableRow.cpp
TokenList.cpp
TokenListArray.cpp
UString.cpp
)
include_directories (
......@@ -34,6 +35,7 @@ set (HDRS
TableRow.h
TokenListArray.h
TokenList.h
UString.h
)
install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Attributes")
......@@ -45,4 +47,4 @@ install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Attributes")
# cmake-tab-width: 4
# indent-tabs-mode: nil
# require-final-newline: nil
# End:
# End:
\ No newline at end of file
// ------------------------------------------------------------------------
// $RCSfile: UString.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: UString
// A class used to parse string attributes.
//
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:36 $
// $Author: Andreas Adelmann $
//
// ------------------------------------------------------------------------
#include "Attributes/UString.h"
#include "AbstractObjects/Expressions.h"
#include "Expressions/SValue.h"
#include "Utilities/OpalException.h"
#include "Utilities/ParseError.h"
#include "Utilities/Util.h"
using namespace Expressions;
// Class UString
// ------------------------------------------------------------------------
namespace Attributes {
UString::UString(const std::string &name, const std::string &help):
AttributeHandler(name, help, 0)
{}
UString::~UString()
{}
const std::string &UString::getType() const {
static const std::string type("string");
return type;
}
void UString::parse(Attribute &attr, Statement &stat, bool) const {
attr.set(new SValue<std::string>(Util::toUpper(parseString(stat, "UString value expected."))));
}
};
\ No newline at end of file
#ifndef OPAL_UString_HH
#define OPAL_UString_HH
// ------------------------------------------------------------------------
// $RCSfile: UString.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: UString
//
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:36 $
// $Author: Andreas Adelmann $
//
// ------------------------------------------------------------------------
#include "AbstractObjects/Attribute.h"
#include "AbstractObjects/AttributeHandler.h"
// Class UString
// ------------------------------------------------------------------------
namespace Attributes {
/// Parser for an attribute of type string.
class UString: public AttributeHandler {
public:
/// Constructor.
// Assign attribute name and help string.
UString(const std::string &name, const std::string &help);
virtual ~UString();
/// Return attribute type string ``string''.
virtual const std::string &getType() const;
/// Parse the attribute.
virtual void parse(Attribute &, Statement &, bool) const;
private:
// Not implemented.
UString();
UString(const UString &);
void operator=(const UString &);
};
};
#endif // OPAL_UString_HH
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment