Skip to content

Commit

Permalink
3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
slaakko committed May 8, 2020
1 parent 7a64a52 commit a649572
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 9 deletions.
4 changes: 4 additions & 0 deletions cmajor/config/devenv.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<path>D:\work\cmajorm\cmajor\system\platform\windows\System.cms</path>
<openFiles />
</recentProject>
<recentProject>
<path>D:\work\cmajorm\cmajor\projects\stream_operator_test\stream_operator_test.cms</path>
<openFiles />
</recentProject>
<recentProject>
<path>D:/work/cmajorm/cmajor/projects/tools/spring/spring.cms</path>
<openFiles />
Expand Down
36 changes: 34 additions & 2 deletions cmajor/doc/release/3.5.0/release.notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,40 @@ <h1>Cmajor 3.5.0 for Windows x64 and Linux</h1>
<h2>Release notes</h2>

<ul>
<li>The previous 3.4.0 version was broken.
<li><p>The previous 3.4.0 version was broken.
It printed an error message about missing SOULNG_ROOT environment variable.
Sorry for the inconvenience for those who downloaded it and tried to use it.
In this version this has been fixed.</li>
In this version this has been fixed.</p></li>
<li><p>Default TextWriter output operators for Pair&lt;T, U> and for the following containers:
List&lt;T>, Set&lt;T, C>, Map&lt;Key, Value, KeyCompare>, HashSet&lt;T, H, C> and HashMap&lt;K, T, H, C>.
The TextWriter output operator for Pair&lt;T, U> is defined as follows:</p>

<pre><code>public TextWriter&amp; operator&lt;&lt;&lt;T, U&gt;(TextWriter&amp; writer, const Pair&lt;T, U&gt;&amp; pair)
{
return writer &lt;&lt; "(" &lt;&lt; pair.first &lt;&lt; ", " &lt;&lt; pair.second &lt;&lt; ")";
}
</code></pre>

<ul>
<li>The default output operator for Pair&lt;T, U> prints the first and second members of the pair inside parentheses separated by a comma.</li>
<li>The default output operator for List&lt;T> prints the elements of the list inside brackets "[" and "]" and separated by commas.</li>
<li>The default output operator for Set&lt;T> prints the elements of the set inside braces "{" and "}" and separated by commas.</li>
<li>The default output operator for Map&lt;Key, Value, KeyCompare> prints the elements (pairs) of the map inside braces "{" and "}" and separated by commas.</li>
<li>The default output operator for HashSet&lt;T, H, C> prints the elements of the hashset inside braces "{" and "}" and separated by commas.</li>
<li>The default output operator for HashMap&lt;K, T, H, C> prints the elements (pairs) of the hashmap inside braces "{" and "}" and separated by commas.</li>
</ul>

<p>If you want to define your own output operator for one of those container types, you can do so by deriving
your own container type from that container type and define the output operator for that type.
For example, deriving a class template from List&lt;T> called MyList&lt;T> and defining an output operator for it:</p>

<p><pre><code>public class MyList&lt;T&gt; : List&lt;T&gt;
{
}
public TextWriter&amp; operator&lt;&lt;&lt;T&gt;(TextWriter&amp; writer, const MyList&lt;T&gt;&amp; myList)
{
// print myList
return writer;
}
</code></pre></li>
</ul></p>
6 changes: 3 additions & 3 deletions cmajor/soulng/util/Unicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,7 @@ std::unique_ptr<CharacterTable> CharacterTable::instance;
const uint8_t headerMagic[8] =
{
static_cast<uint8_t>('C'), static_cast<uint8_t>('M'), static_cast<uint8_t>('A'), static_cast<uint8_t>('J'),
static_cast<uint8_t>('U'), static_cast<uint8_t>('C'), static_cast<uint8_t>('D'), current_soulng_ucd_version
static_cast<uint8_t>('U'), static_cast<uint8_t>('C'), static_cast<uint8_t>('D'), current_cmajor_ucd_version
};

std::string CmajorRoot()
Expand Down Expand Up @@ -2118,12 +2118,12 @@ void CharacterTable::ReadHeader(BinaryReader& reader)
{
if (magic[i] != headerMagic[i])
{
throw UnicodeException("invalid soulng_ucd.bin header magic: 'CMAJUCD' expected");
throw UnicodeException("invalid cmajor_ucd.bin header magic: 'CMAJUCD' expected");
}
}
if (magic[7] != headerMagic[7])
{
throw UnicodeException("invalid soulng_ucd.bin version: version " + std::string(1, headerMagic[7]) + " expected, version " + std::string(1, magic[7]) + " read");
throw UnicodeException("invalid cmajor_ucd.bin version: version " + std::string(1, headerMagic[7]) + " expected, version " + std::string(1, magic[7]) + " read");
}
extendedHeaderStart = reader.ReadUInt();
extendedHeaderEnd = reader.ReadUInt();
Expand Down
8 changes: 4 additions & 4 deletions cmajor/soulng/util/Unicode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,10 +1026,10 @@ class UTIL_API ExtendedCharacterInfoHeader
std::vector<uint32_t> extendedPageStarts;
};

const uint8_t soulng_ucd_version_1 = '1';
const uint8_t soulng_ucd_version_2 = '2';
const uint8_t soulng_ucd_version_3 = '3';
const uint8_t current_soulng_ucd_version = soulng_ucd_version_3;
const uint8_t cmajor_ucd_version_1 = '1';
const uint8_t cmajor_ucd_version_2 = '2';
const uint8_t cmajor_ucd_version_3 = '3';
const uint8_t current_cmajor_ucd_version = cmajor_ucd_version_3;

class UTIL_API CharacterTable
{
Expand Down
21 changes: 21 additions & 0 deletions cmajor/system/System.Base/HashMap.cm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Concepts;
using System.IO;

namespace System.Collections
{
Expand Down Expand Up @@ -102,4 +103,24 @@ namespace System.Collections
}
return true;
}

public TextWriter& operator<<<K, T, H, C>(TextWriter& writer, const HashMap<K, T, H, C>& hashMap)
{
writer << "{";
bool first = true;
for (const Pair<K, T>& element : hashMap)
{
if (first)
{
first = false;
}
else
{
writer << ", ";
}
writer << element;
}
writer << "}";
return writer;
}
}
22 changes: 22 additions & 0 deletions cmajor/system/System.Base/HashSet.cm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Concepts;
using System.IO;

namespace System.Collections
{
Expand Down Expand Up @@ -92,4 +93,25 @@ namespace System.Collections
}
return true;
}

public TextWriter& operator<<<T, H, C>(TextWriter& writer, const HashSet<T, H, C>& hashSet)
{
writer << "{";
bool first = true;
for (const T& element : hashSet)
{
if (first)
{
first = false;
}
else
{
writer << ", ";
}
writer << element;
}
writer << "}";
return writer;
}

}
21 changes: 21 additions & 0 deletions cmajor/system/System.Base/List.cm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Concepts;
using System.IO;

namespace System.Collections
{
Expand Down Expand Up @@ -369,4 +370,24 @@ namespace System.Collections
++items;
}
}

public TextWriter& operator<<<T>(TextWriter& writer, const List<T>& list)
{
writer << "[";
bool first = true;
for (const T& element : list)
{
if (first)
{
first = false;
}
else
{
writer << ", ";
}
writer << element;
}
writer << "]";
return writer;
}
}
21 changes: 21 additions & 0 deletions cmajor/system/System.Base/Map.cm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Concepts;
using System.IO;

namespace System.Collections
{
Expand Down Expand Up @@ -102,4 +103,24 @@ namespace System.Collections
{
return LexicographicalCompare(left.CBegin(), left.CEnd(), right.CBegin(), right.CEnd(), Less<Pair<Key, Value>>());
}

public TextWriter& operator<<<Key, Value, KeyCompare>(TextWriter& writer, const Map<Key, Value, KeyCompare>& map)
{
writer << "{";
bool first = true;
for (const Pair<Key, Value>& element : map)
{
if (first)
{
first = false;
}
else
{
writer << ", ";
}
writer << element;
}
writer << "}";
return writer;
}
}
6 changes: 6 additions & 0 deletions cmajor/system/System.Base/Pair.cm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// =================================

using System.Concepts;
using System.IO;

namespace System
{
Expand Down Expand Up @@ -47,4 +48,9 @@ namespace System
return p.second;
}
}

public TextWriter& operator<<<T, U>(TextWriter& writer, const Pair<T, U>& pair)
{
return writer << "(" << pair.first << ", " << pair.second << ")";
}
}
21 changes: 21 additions & 0 deletions cmajor/system/System.Base/Set.cm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Concepts;
using System.IO;

namespace System.Collections
{
Expand Down Expand Up @@ -94,4 +95,24 @@ namespace System.Collections
{
return LexicographicalCompare(left.CBegin(), left.CEnd(), right.CBegin(), right.CEnd(), C());
}

public TextWriter& operator<<<T, C>(TextWriter& writer, const Set<T, C>& set)
{
writer << "{";
bool first = true;
for (const T& element : set)
{
if (first)
{
first = false;
}
else
{
writer << ", ";
}
writer << element;
}
writer << "}";
return writer;
}
}

0 comments on commit a649572

Please sign in to comment.