Some const correctness in the Java pseudo core.
This commit is contained in:
@ -85,11 +85,12 @@ Iterator::~Iterator()
|
||||
// Collection
|
||||
// ----------------
|
||||
|
||||
void Collection::intoStringBuffer(misc::StringBuffer *sb)
|
||||
void
|
||||
Collection::intoStringBuffer( misc::StringBuffer *sb ) const
|
||||
{
|
||||
sb->append("{ ");
|
||||
bool first = true;
|
||||
for (Iterator it = iterator(); it.hasNext(); ) {
|
||||
for (Iterator it = const_cast< Collection * >( this )->iterator(); it.hasNext(); ) {
|
||||
if (!first)
|
||||
sb->append(", ");
|
||||
it.getNext()->intoStringBuffer(sb);
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
class Collection: public Collection0
|
||||
{
|
||||
public:
|
||||
void intoStringBuffer(misc::StringBuffer *sb);
|
||||
void intoStringBuffer(misc::StringBuffer *sb) const override;
|
||||
inline Iterator iterator() { Iterator it(createIterator()); return it; }
|
||||
virtual int size() = 0;
|
||||
};
|
||||
|
@ -26,7 +26,8 @@ namespace identity {
|
||||
|
||||
std::map< std::type_index, std::string > IdentifiableObject::classNames;
|
||||
|
||||
void IdentifiableObject::intoStringBuffer(misc::StringBuffer *sb)
|
||||
void
|
||||
IdentifiableObject::intoStringBuffer(misc::StringBuffer *sb) const
|
||||
{
|
||||
sb->append("<instance ");
|
||||
sb->appendPointer(this);
|
||||
|
@ -37,13 +37,13 @@ protected:
|
||||
void registerName (const char *className, std::type_index index);
|
||||
|
||||
public:
|
||||
void intoStringBuffer(misc::StringBuffer *sb) override;
|
||||
void intoStringBuffer(misc::StringBuffer *sb) const override;
|
||||
|
||||
/**
|
||||
* \brief Return the name, under which the class of this object was
|
||||
* registered.
|
||||
*/
|
||||
const char *getClassName() { return classNames.at( typeid( *this ) ).c_str(); }
|
||||
const char *getClassName() const { return classNames.at( typeid( *this ) ).c_str(); }
|
||||
};
|
||||
|
||||
} // namespace identity
|
||||
|
@ -581,7 +581,7 @@ public:
|
||||
inline void append(const char *str) { appendNoCopy(dStrdup(str)); }
|
||||
inline void appendInt(int n)
|
||||
{ char buf[32]; sprintf (buf, "%d", n); append (buf); }
|
||||
inline void appendPointer(void *p)
|
||||
inline void appendPointer(const void *p)
|
||||
{ char buf[32]; sprintf (buf, "%p", p); append (buf); }
|
||||
inline void appendBool(bool b) { append (b ? "true" : "false"); }
|
||||
void appendNoCopy(char *str);
|
||||
|
@ -75,17 +75,13 @@ Object *Object::clone()
|
||||
/**
|
||||
* \brief Use object::Object::intoStringBuffer to return a textual
|
||||
* representation of the object.
|
||||
*
|
||||
* The caller does not have to free the memory, object::Object is responsible
|
||||
* for this.
|
||||
*/
|
||||
const char *Object::toString()
|
||||
std::string
|
||||
Object::toString() const
|
||||
{
|
||||
/** \todo garbage! */
|
||||
misc::StringBuffer sb;
|
||||
intoStringBuffer(&sb);
|
||||
char *s = dStrdup(sb.getChars());
|
||||
return s;
|
||||
return sb.getChars();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +89,8 @@ const char *Object::toString()
|
||||
*
|
||||
* This is used by object::Object::toString.
|
||||
*/
|
||||
void Object::intoStringBuffer(misc::StringBuffer *sb)
|
||||
void
|
||||
Object::intoStringBuffer(misc::StringBuffer *sb) const
|
||||
{
|
||||
sb->append("<not further specified object ");
|
||||
sb->appendPointer(this);
|
||||
|
@ -28,8 +28,8 @@ public:
|
||||
virtual bool equals(Object *other);
|
||||
virtual int hashValue();
|
||||
virtual Object *clone();
|
||||
virtual void intoStringBuffer(misc::StringBuffer *sb);
|
||||
const char *toString();
|
||||
virtual void intoStringBuffer(misc::StringBuffer *sb) const;
|
||||
std::string toString() const;
|
||||
virtual size_t sizeOf();
|
||||
};
|
||||
|
||||
|
@ -41,7 +41,8 @@ Emitter::~Emitter ()
|
||||
}
|
||||
}
|
||||
|
||||
void Emitter::intoStringBuffer(misc::StringBuffer *sb)
|
||||
void
|
||||
Emitter::intoStringBuffer(misc::StringBuffer *sb) const
|
||||
{
|
||||
sb->append ("<emitter: ");
|
||||
container::intoStringBuffer( receivers, sb );
|
||||
@ -117,7 +118,7 @@ Receiver::~Receiver()
|
||||
}
|
||||
}
|
||||
|
||||
void Receiver::intoStringBuffer(misc::StringBuffer *sb)
|
||||
void Receiver::intoStringBuffer(misc::StringBuffer *sb) const
|
||||
{
|
||||
// emitters are not listed, to prevent recursion
|
||||
sb->append ("<receiver>");
|
||||
|
@ -241,7 +241,7 @@ public:
|
||||
Emitter();
|
||||
~Emitter();
|
||||
|
||||
void intoStringBuffer(misc::StringBuffer *sb);
|
||||
void intoStringBuffer(misc::StringBuffer *sb) const override;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -266,7 +266,7 @@ public:
|
||||
Receiver();
|
||||
~Receiver();
|
||||
|
||||
void intoStringBuffer(misc::StringBuffer *sb);
|
||||
void intoStringBuffer(misc::StringBuffer *sb) const override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user