Commit MetaInfo

Revisioncb900322ded388d091e79f890b2aa818e30a0b7e (tree)
Time2013-05-12 12:26:38
Author <exeal@user...>

Log Message

.

Change Summary

Incremental Difference

diff -r 45f9de52a43c -r cb900322ded3 ascension/ascension/corelib/encoder.hpp
--- a/ascension/ascension/corelib/encoder.hpp Sun May 12 12:25:13 2013 +0900
+++ b/ascension/ascension/corelib/encoder.hpp Sun May 12 12:26:38 2013 +0900
@@ -10,6 +10,7 @@
1010 #include <ascension/config.hpp> // ASCENSION_NO_*_ENCODINGS
1111 #include <ascension/corelib/basic-types.hpp>
1212 #include <ascension/corelib/string-piece.hpp>
13+#include <array>
1314 #include <memory> // std.unique_ptr
1415 #include <locale> // std.locale, std.codecvt
1516 #include <vector>
@@ -544,8 +545,8 @@
544545 void buildUnicodeToByteTable();
545546 private:
546547 const Char** const byteToUnicode_;
547- Byte* unicodeToByte_[0x100];
548- static const Byte UNMAPPABLE_16x16_UNICODE_TABLE[0x100];
548+ std::array<Byte*, 0x100> unicodeToByte_;
549+ static const std::array<const Byte, 0x100> UNMAPPABLE_16x16_UNICODE_TABLE;
549550 };
550551
551552 /// Generates ISO IR C0 character sequence 0x00 through 0x0F.
diff -r 45f9de52a43c -r cb900322ded3 ascension/ascension/win32/com/dispatch-impl.hpp
--- a/ascension/ascension/win32/com/dispatch-impl.hpp Sun May 12 12:25:13 2013 +0900
+++ b/ascension/ascension/win32/com/dispatch-impl.hpp Sun May 12 12:26:38 2013 +0900
@@ -80,7 +80,7 @@
8080 hr = typeLibrary->GetTypeInfoOfGuid(*iid, typeInformation_.initialize());
8181 assert(SUCCEEDED(hr));
8282 }
83- SmartPointer<ITypeInfo> get() const /*throw()*/ {return typeInformation_;}
83+ SmartPointer<ITypeInfo> get() const BOOST_NOEXCEPT {return typeInformation_;}
8484 private:
8585 SmartPointer<ITypeInfo> typeInformation_;
8686 };
@@ -101,7 +101,7 @@
101101 assert(SUCCEEDED(hr));
102102 }
103103 /// Returns an @c ITypeInfo instance.
104- SmartPointer<ITypeInfo> get() const /*throw()*/ {return typeInformation_;}
104+ SmartPointer<ITypeInfo> get() const BOOST_NOEXCEPT {return typeInformation_;}
105105 private:
106106 SmartPointer<ITypeInfo> typeInformation_;
107107 };
@@ -114,15 +114,15 @@
114114 class TypeInformationFromExecutable {
115115 public:
116116 TypeInformationFromExecutable() {
117- WCHAR programName[MAX_PATH];
118- const DWORD n = ::GetModuleFileNameW(nullptr, programName, ASCENSION_COUNTOF(programName));
119- if(n != 0 && n != ASCENSION_COUNTOF(programName)) {
117+ std::array<WCHAR, MAX_PATH> programName;
118+ const DWORD n = ::GetModuleFileNameW(nullptr, programName.data(), programName.size());
119+ if(n != 0 && n != programName.size()) {
120120 SmartPointer<ITypeLib> typeLibrary;
121- if(SUCCEEDED(::LoadTypeLib(programName, typeLibrary.initialize())))
121+ if(SUCCEEDED(::LoadTypeLib(programName.data(), typeLibrary.initialize())))
122122 typeLibrary->GetTypeInfoOfGuid(*iid, typeInformation_.initialize());
123123 }
124124 }
125- SmartPointer<ITypeInfo> get() const /*throw()*/ {return typeInformation_;}
125+ SmartPointer<ITypeInfo> get() const BOOST_NOEXCEPT {return typeInformation_;}
126126 private:
127127 SmartPointer<ITypeInfo> typeInformation_;
128128 };
diff -r 45f9de52a43c -r cb900322ded3 ascension/src/corelib/encoder.cpp
--- a/ascension/src/corelib/encoder.cpp Sun May 12 12:25:13 2013 +0900
+++ b/ascension/src/corelib/encoder.cpp Sun May 12 12:26:38 2013 +0900
@@ -698,7 +698,7 @@
698698
699699 // implementation.sbcs.BidirectionalMap ///////////////////////////////////////////////////////////
700700
701-const Byte sbcs::BidirectionalMap::UNMAPPABLE_16x16_UNICODE_TABLE[0x100] = {
701+const array<const Byte, 0x100> sbcs::BidirectionalMap::UNMAPPABLE_16x16_UNICODE_TABLE = {
702702 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
703703 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
704704 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -715,25 +715,25 @@
715715 * 16×16-characters
716716 */
717717 sbcs::BidirectionalMap::BidirectionalMap(const Char** byteToCharacterWire) BOOST_NOEXCEPT : byteToUnicode_(byteToCharacterWire) {
718- fill_n(unicodeToByte_, ASCENSION_COUNTOF(unicodeToByte_), static_cast<Byte*>(nullptr));
718+ unicodeToByte_.fill(nullptr);
719719 buildUnicodeToByteTable(); // eager?
720720 }
721721
722722 /// Destructor.
723723 sbcs::BidirectionalMap::~BidirectionalMap() BOOST_NOEXCEPT {
724724 for(size_t i = 0; i < ASCENSION_COUNTOF(unicodeToByte_); ++i) {
725- if(unicodeToByte_[i] != UNMAPPABLE_16x16_UNICODE_TABLE)
725+ if(unicodeToByte_[i] != UNMAPPABLE_16x16_UNICODE_TABLE.data())
726726 delete[] unicodeToByte_[i];
727727 }
728728 }
729729
730730 void sbcs::BidirectionalMap::buildUnicodeToByteTable() {
731731 assert(unicodeToByte_[0] == 0);
732- fill_n(unicodeToByte_, ASCENSION_COUNTOF(unicodeToByte_), const_cast<Byte*>(UNMAPPABLE_16x16_UNICODE_TABLE));
732+ unicodeToByte_.fill(const_cast<Byte*>(UNMAPPABLE_16x16_UNICODE_TABLE.data()));
733733 for(int i = 0x00; i < 0xff; ++i) {
734734 const Char ucs = wireAt(byteToUnicode_, static_cast<Byte>(i));
735735 Byte*& p = unicodeToByte_[ucs >> 8];
736- if(p == UNMAPPABLE_16x16_UNICODE_TABLE) {
736+ if(p == UNMAPPABLE_16x16_UNICODE_TABLE.data()) {
737737 p = new Byte[0x100];
738738 fill_n(p, 0x100, UNMAPPABLE_BYTE);
739739 }
diff -r 45f9de52a43c -r cb900322ded3 ascension/src/kernel/undo.cpp
--- a/ascension/src/kernel/undo.cpp Sun May 12 12:25:13 2013 +0900
+++ b/ascension/src/kernel/undo.cpp Sun May 12 12:26:38 2013 +0900
@@ -717,12 +717,12 @@
717717 void Document::replace(const Region& region, basic_istream<Char>& in, Position* endOfInsertedString /* = nullptr */) {
718718 // TODO: this implementation is provisional and not exception-safe.
719719 Position e;
720- Char buffer[0x8000];
720+ array<Char, 0x8000> buffer;
721721 for(Region r(region); in; r.first = r.second = e) {
722- in.read(buffer, ASCENSION_COUNTOF(buffer));
722+ in.read(buffer.data(), buffer.size());
723723 if(in.gcount() == 0)
724724 break;
725- replace(r, StringPiece(buffer, static_cast<StringPiece::size_type>(in.gcount())), &e);
725+ replace(r, StringPiece(buffer.data(), static_cast<StringPiece::size_type>(in.gcount())), &e);
726726 }
727727 if(endOfInsertedString != 0)
728728 *endOfInsertedString = e;
diff -r 45f9de52a43c -r cb900322ded3 ascension/src/text-editor/command.cpp
--- a/ascension/src/text-editor/command.cpp Sun May 12 12:25:13 2013 +0900
+++ b/ascension/src/text-editor/command.cpp Sun May 12 12:26:38 2013 +0900
@@ -463,16 +463,16 @@
463463 Caret& caret = viewer.caret();
464464 const String& lineString = document.line(line(eos));
465465 const CodePoint c = text::utf::decodeLast(begin(lineString), begin(lineString) + offsetInLine(eos));
466- Char buffer[7];
466+ array<Char, 7> buffer;
467467 #if(_MSC_VER < 1400)
468- swprintf(buffer, L"%lX", c);
468+ swprintf(buffer.data(), L"%lX", c);
469469 #else
470- swprintf(buffer, ASCENSION_COUNTOF(buffer), L"%lX", c);
470+ swprintf(buffer.data(), buffer.size(), L"%lX", c);
471471 #endif // _MSC_VER < 1400
472472 AutoFreeze af(&viewer);
473473 caret.select(Position(line(eos), offsetInLine(eos) - ((c > 0xffff) ? 2 : 1)), eos);
474474 try {
475- caret.replaceSelection(buffer, false);
475+ caret.replaceSelection(buffer.data(), false);
476476 } catch(const DocumentInput::ChangeRejectedException&) {
477477 return false;
478478 }
diff -r 45f9de52a43c -r cb900322ded3 ascension/src/viewer/caret-windows.cpp
--- a/ascension/src/viewer/caret-windows.cpp Sun May 12 12:25:13 2013 +0900
+++ b/ascension/src/viewer/caret-windows.cpp Sun May 12 12:26:38 2013 +0900
@@ -258,10 +258,10 @@
258258
259259 // ANSI text format and locale
260260 UINT codePage = CP_ACP;
261- wchar_t codePageString[6];
262- if(0 != ::GetLocaleInfoW(caret.clipboardLocale(), LOCALE_IDEFAULTANSICODEPAGE, codePageString, ASCENSION_COUNTOF(codePageString))) {
261+ array<wchar_t, 6> codePageString;
262+ if(0 != ::GetLocaleInfoW(caret.clipboardLocale(), LOCALE_IDEFAULTANSICODEPAGE, codePageString.data(), codePageString.size())) {
263263 wchar_t* eob;
264- codePage = wcstoul(codePageString, &eob, 10);
264+ codePage = wcstoul(codePageString.data(), &eob, 10);
265265 }
266266 format.cfFormat = CF_TEXT;
267267 int nativeLength = ::WideCharToMultiByte(codePage, 0, text.c_str(), static_cast<int>(text.length()), nullptr, 0, nullptr, nullptr);
diff -r 45f9de52a43c -r cb900322ded3 ascension/src/viewer/default-mouse-input-strategy.cpp
--- a/ascension/src/viewer/default-mouse-input-strategy.cpp Sun May 12 12:25:13 2013 +0900
+++ b/ascension/src/viewer/default-mouse-input-strategy.cpp Sun May 12 12:26:38 2013 +0900
@@ -107,8 +107,8 @@
107107 * @throw UnknownValueException @a type is unknown
108108 */
109109 const widgetapi::Cursor& AutoScrollOriginMark::cursorForScrolling(CursorType type) {
110- static unique_ptr<widgetapi::Cursor> instances[3];
111- if(type >= ASCENSION_COUNTOF(instances))
110+ static array<unique_ptr<widgetapi::Cursor>, 3> instances;
111+ if(static_cast<size_t>(type) >= instances.size())
112112 throw UnknownValueException("type");
113113 if(instances[type].get() == nullptr) {
114114 static const uint8_t AND_LINE_3_TO_11[] = {
diff -r 45f9de52a43c -r cb900322ded3 ascension/src/viewer/ruler.cpp
--- a/ascension/src/viewer/ruler.cpp Sun May 12 12:25:13 2013 +0900
+++ b/ascension/src/viewer/ruler.cpp Sun May 12 12:26:38 2013 +0900
@@ -35,16 +35,16 @@
3535
3636 void drawLineNumber(PaintContext& context, const Point& origin, Index lineNumber, const NumberSubstitution& ns) {
3737 // format number string
38- wchar_t s[128]; // oops, is this sufficient?
38+ array<wchar_t, 128> s; // TODO: Oops, is this sufficient?
3939 // TODO: std.swprintf may be slow.
4040 // TODO: use 'ns' parameter.
4141 #if defined(_MSC_VER) && (_MSC_VER < 1400)
42- const int length = swprintf(s, L"%lu", lineNumber);
42+ const int length = swprintf(s.data(), L"%lu", lineNumber);
4343 #else
44- const int length = swprintf(s, ASCENSION_COUNTOF(s), L"%lu", lineNumber);
44+ const int length = swprintf(s.data(), s.size(), L"%lu", lineNumber);
4545 #endif // _MSC_VER < 1400
4646
47- context.fillText(s, origin);
47+ context.fillText(s.data(), origin);
4848 }
4949
5050 /**
diff -r 45f9de52a43c -r cb900322ded3 ascension/src/viewer/viewer-windows.cpp
--- a/ascension/src/viewer/viewer-windows.cpp Sun May 12 12:25:13 2013 +0900
+++ b/ascension/src/viewer/viewer-windows.cpp Sun May 12 12:26:38 2013 +0900
@@ -590,9 +590,9 @@
590590 ULONG fetched;
591591 dout << L"DragEnter received a data object exposes the following formats.\n";
592592 for(formats->Reset(); formats->Next(1, &format, &fetched) == S_OK; ) {
593- WCHAR name[256];
594- if(::GetClipboardFormatNameW(format.cfFormat, name, ASCENSION_COUNTOF(name) - 1) != 0)
595- dout << L"\t" << name << L"\n";
593+ array<WCHAR, 256> name;
594+ if(::GetClipboardFormatNameW(format.cfFormat, name.data(), name.size() - 1) != 0)
595+ dout << L"\t" << name.data() << L"\n";
596596 else
597597 dout << L"\t" << L"(unknown format : " << format.cfFormat << L")\n";
598598 if(format.ptd != nullptr)
Show on old repository browser