Update import

This commit is contained in:
vczh
2021-10-24 00:26:11 -07:00
parent 6cc57dfb86
commit c96ab5fb82
12 changed files with 1172 additions and 1166 deletions
+141 -140
View File
File diff suppressed because it is too large Load Diff
+111 -111
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1091,14 +1091,14 @@ WorkflowCompiler (Compile)
extern Ptr<workflow::WfModule> Workflow_GenerateInstanceClass(GuiResourcePrecompileContext& precompileContext, const WString& moduleName, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors, vint passIndex);
#define WORKFLOW_ENVIRONMENT_VARIABLE_ADD\
FOREACH_INDEXER(GlobalStringKey, envVar, index, repr->environmentVariables.Keys())\
for (auto [envVar, index] : indexed(repr->environmentVariables.Keys()))\
{\
auto value = repr->environmentVariables.Values()[index];\
resolvingResult.envVars.Add(envVar, value);\
}\
#define WORKFLOW_ENVIRONMENT_VARIABLE_REMOVE\
FOREACH_INDEXER(GlobalStringKey, envVar, index, repr->environmentVariables.Keys())\
for (auto [envVar, index] : indexed(repr->environmentVariables.Keys()))\
{\
auto value = repr->environmentVariables.Values()[index];\
resolvingResult.envVars.Remove(envVar, value.Obj());\
+3 -3
View File
@@ -133,15 +133,15 @@ Compiled Workflow Type Resolver (Workflow)
WfAssemblyLoadErrors loadErrors;
if (!compiled->Initialize(true, loadErrors))
{
FOREACH(WString, loadError, loadErrors.duplicatedTypes)
for (auto loadError : loadErrors.duplicatedTypes)
{
errors.Add({ {resource},L"Failed to add an existing type: " + loadError });
}
FOREACH(WString, loadError, loadErrors.unresolvedTypes)
for (auto loadError : loadErrors.unresolvedTypes)
{
errors.Add({ {resource},L"Unable to resolve type: " + loadError });
}
FOREACH(WString, loadError, loadErrors.unresolvedMembers)
for (auto loadError : loadErrors.unresolvedMembers)
{
errors.Add({ {resource},L"Unable to resolve member: " + loadError });
}
+24 -24
View File
@@ -496,7 +496,7 @@ WindowsDirect2DParagraph (Initialization)
~WindowsDirect2DParagraph()
{
CloseCaret();
FOREACH(Color, color, usedColors)
for (auto color : usedColors)
{
renderTarget->DestroyDirect2DBrush(color);
}
@@ -5925,7 +5925,7 @@ UniscribeLine
ClearUniscribeData();
vint current=0;
List<vint> fragmentStarts;
FOREACH(Ptr<UniscribeFragment>, fragment, documentFragments)
for (auto fragment : documentFragments)
{
fragmentStarts.Add(current);
lineText+=fragment->text;
@@ -6009,7 +6009,7 @@ UniscribeLine
bool skip=false;
{
vint elementCurrent=0;
FOREACH(Ptr<UniscribeFragment>, elementFragment, documentFragments)
for (auto elementFragment : documentFragments)
{
vint elementLength=elementFragment->text.Length();
if(elementFragment->inlineObjectProperties)
@@ -6106,7 +6106,7 @@ UniscribeLine
}
else
{
FOREACH(Ptr<UniscribeRun>, run, scriptRuns)
for (auto run : scriptRuns)
{
run->fragmentBounds.Clear();
}
@@ -6286,9 +6286,9 @@ UniscribeLine
vint minY=top;
vint maxX=0;
vint maxY=top;
FOREACH(Ptr<UniscribeRun>, run, scriptRuns)
for (auto run : scriptRuns)
{
FOREACH(UniscribeRun::RunFragmentBounds, fragmentBounds, run->fragmentBounds)
for (auto fragmentBounds : run->fragmentBounds)
{
Rect bounds=fragmentBounds.bounds;
if(minX>bounds.Left()) minX=bounds.Left();
@@ -6304,7 +6304,7 @@ UniscribeLine
void UniscribeLine::Render(UniscribeRun::IRendererCallback* callback, vint offsetX, vint offsetY, bool renderBackground)
{
FOREACH(Ptr<UniscribeRun>, run, scriptRuns)
for (auto run : scriptRuns)
{
for(vint i=0;i<run->fragmentBounds.Count();i++)
{
@@ -6335,7 +6335,7 @@ UniscribeParagraph (Initialization)
void UniscribeParagraph::ClearUniscribeData()
{
FOREACH(Ptr<UniscribeFragment>, fragment, documentFragments)
for (auto fragment : documentFragments)
{
GetWindowsGDIResourceManager()->DestroyGdiFont(fragment->fontStyle);
fragment->fontObject=0;
@@ -6351,7 +6351,7 @@ UniscribeParagraph (Initialization)
built=true;
ClearUniscribeData();
Dictionary<WString, Ptr<WinFont>> fonts;
FOREACH(Ptr<UniscribeFragment>, fragment, documentFragments)
for (auto fragment : documentFragments)
{
if(!fragment->fontObject)
{
@@ -6371,7 +6371,7 @@ UniscribeParagraph (Initialization)
{
Regex regexLine(L"\r\n");
Ptr<UniscribeLine> line;
FOREACH(Ptr<UniscribeFragment>, fragment, documentFragments)
for (auto fragment : documentFragments)
{
if(fragment->inlineObjectProperties)
{
@@ -6415,13 +6415,13 @@ UniscribeParagraph (Initialization)
}
}
FOREACH(Ptr<UniscribeLine>, line, lines)
for (auto line : lines)
{
line->BuildUniscribeData(dc);
}
vint lineStart=0;
FOREACH(Ptr<UniscribeLine>, line, lines)
for (auto line : lines)
{
line->startFromParagraph=lineStart;
lineStart+=line->lineText.Length()+2;
@@ -6440,7 +6440,7 @@ UniscribeParagraph (Initialization)
paragraphAlignment=alignment;
vint cy=0;
FOREACH(Ptr<UniscribeLine>, line, lines)
for (auto line : lines)
{
line->Layout(availableWidth, alignment, cy, cy);
}
@@ -6450,7 +6450,7 @@ UniscribeParagraph (Initialization)
vint minY=0;
vint maxX=0;
vint maxY=0;
FOREACH(Ptr<UniscribeLine>, line, lines)
for (auto line : lines)
{
Rect bounds=line->bounds;
if(minX>bounds.Left()) minX=bounds.Left();
@@ -6460,9 +6460,9 @@ UniscribeParagraph (Initialization)
}
vint offsetY=0;
FOREACH(Ptr<UniscribeLine>, line, lines)
for (auto line : lines)
{
FOREACH(Ptr<UniscribeFragment>, fragment, line->documentFragments)
for (auto fragment : line->documentFragments)
{
vint size=fragment->fontStyle.size/3;
if(size>offsetY)
@@ -6477,7 +6477,7 @@ UniscribeParagraph (Initialization)
void UniscribeParagraph::Render(UniscribeRun::IRendererCallback* callback, bool renderBackground)
{
auto offset = callback->GetParagraphOffset();
FOREACH(Ptr<UniscribeLine>, line, lines)
for (auto line : lines)
{
line->Render(callback, offset.x, offset.y, renderBackground);
}
@@ -9076,7 +9076,7 @@ WindowsForm
auto flag = flagDisposed;
bool skip = false;
{
FOREACH(Ptr<INativeMessageHandler>, handler, messageHandlers)
for (auto handler : messageHandlers)
{
handler->BeforeHandle(hwnd, uMsg, wParam, lParam, skip);
CHECK_DISPOSED;
@@ -9090,7 +9090,7 @@ WindowsForm
CHECK_DISPOSED;
if (GetWindowsFormFromHandle(hwnd))
{
FOREACH(Ptr<INativeMessageHandler>, handler, messageHandlers)
for (auto handler : messageHandlers)
{
handler->AfterHandle(hwnd, uMsg, wParam, lParam, skip, result);
CHECK_DISPOSED;
@@ -9826,7 +9826,7 @@ WindowsController
{
if (rootWindowOnly)
{
FOREACH(WindowsForm*, window, windows.Values())
for (auto window : windows.Values())
{
if (window->GetWindowMode() == INativeWindow::Normal)
{
@@ -9870,7 +9870,7 @@ WindowsController
{
if (hwnd == mainWindowHandle && uMsg == WM_DESTROY)
{
FOREACH(WindowsForm*, window, windows.Values())
for (auto window : windows.Values())
{
if (window->IsVisible())
{
@@ -9886,7 +9886,7 @@ WindowsController
return window->GetWindowMode() == INativeWindow::Normal;
})
);
FOREACH(WindowsForm*, window, normalWindows)
for (auto window : normalWindows)
{
DestroyNativeWindow(window);
}
@@ -13071,7 +13071,7 @@ WindowsAsyncService
}
}
FOREACH(TaskItem, item, items)
for (auto item : items)
{
item.proc();
if(item.semaphore)
@@ -13079,7 +13079,7 @@ WindowsAsyncService
item.semaphore->Release();
}
}
FOREACH(Ptr<DelayItem>, item, executableDelayItems)
for (auto item : executableDelayItems)
{
if(item->executeInMainThread)
{
+174 -67
View File
@@ -2466,7 +2466,8 @@ Interfaces
/// <summary>
/// An enumerable interface representing all types that provide multiple values in order.
/// range-based for-loop is not supported on enumerable yet, current we have "FOREACH" and "FOREACH_INDEXER" for iterating values.
/// range-based for-loop is available on enumerable yet.
/// by applying the indexed function on the collection, a tuple of value and index is returned, structured binding could apply.
/// <see cref="CopyFrom`*"/> functions work for all enumerable implementation.
/// <see cref="LazyList`1"/> provides high-level operations for enumerables, you can create a lazy list by calling <see cref="From`*"/> on any enumerables.
/// </summary>
@@ -2482,17 +2483,17 @@ Interfaces
/// CopyFrom(ys, xs);
///
/// // print ys
/// FOREACH(vint, y, ys)
/// for (auto y : ys)
/// Console::Write(itow(y) + L" ");
/// Console::WriteLine(L"");
///
/// // print ys, added by the position
/// FOREACH_INDEXER(vint, y, i, ys)
/// for (auto [y, i] : indexed(ys))
/// Console::Write(itow(y + i) + L" ");
/// Console::WriteLine(L"");
///
/// // print all odd numbers in ys
/// FOREACH(vint, y, From(ys).Where([](int a){return a % 2 == 1;}))
/// for (auto y : From(ys).Where([](int a){return a % 2 == 1;}))
/// Console::Write(itow(y) + L" ");
/// Console::WriteLine(L"");
/// }
@@ -2509,7 +2510,7 @@ Interfaces
/// </summary>
/// <remarks>
/// In most of the cases, you do not need to call this function.
/// "FOREACH", "FOREACH_INDEXER", <see cref="CopyFrom`*"/> and <see cref="LazyList`1"/> do all the jobs for you.
/// "for (auto x : xs);", "for (auto [x, i] : indexed(xs));", <see cref="CopyFrom`*"/> and <see cref="LazyList`1"/> do all the jobs for you.
/// </remarks>
/// <returns>The enumerator.</returns>
virtual IEnumerator<T>* CreateEnumerator()const=0;
@@ -4694,75 +4695,148 @@ namespace vl
{
namespace collections
{
/***********************************************************************
ForEachIterator
***********************************************************************/
template<typename T>
class ForEachIterator : public Object
struct RangeBasedForLoopEnding
{
public:
virtual bool Next(T& variable)const=0;
operator bool()const
{
return true;
}
};
/***********************************************************************
ForEachIterator for IEnumerable
Range-Based For-Loop Iterator
***********************************************************************/
template<typename T>
class EnumerableForEachIterator : public ForEachIterator<T>
struct RangeBasedForLoopIterator
{
protected:
Ptr<IEnumerator<T>> enumerator;
private:
IEnumerator<T>* iterator;
public:
EnumerableForEachIterator(const IEnumerable<T>& enumerable)
:enumerator(enumerable.CreateEnumerator())
RangeBasedForLoopIterator(const IEnumerable<T>& enumerable)
: iterator(enumerable.CreateEnumerator())
{
operator++();
}
EnumerableForEachIterator(const EnumerableForEachIterator<T>& enumerableIterator)
:enumerator(enumerableIterator.enumerator)
~RangeBasedForLoopIterator()
{
if (iterator) delete iterator;
}
bool Next(T& variable)const
void operator++()
{
if(enumerator->Next())
if (!iterator->Next())
{
variable=enumerator->Current();
return true;
}
else
{
return false;
delete iterator;
iterator = nullptr;
}
}
const T& operator*() const
{
return iterator->Current();
}
bool operator==(RangeBasedForLoopEnding) const
{
return iterator == nullptr;
}
};
template<typename T>
EnumerableForEachIterator<T> CreateForEachIterator(const IEnumerable<T>& enumerable)
RangeBasedForLoopIterator<T> begin(const IEnumerable<T>& enumerable)
{
return enumerable;
return { enumerable };
}
template<typename T>
RangeBasedForLoopEnding end(const IEnumerable<T>& enumerable)
{
return {};
}
/***********************************************************************
FOREACH and FOREACH_INDEXER
Range-Based For-Loop Iterator with Index
***********************************************************************/
#define FOREACH(TYPE, VARIABLE, COLLECTION)\
SCOPE_VARIABLE(const ::vl::collections::ForEachIterator<TYPE>&, __foreach_iterator__, ::vl::collections::CreateForEachIterator(COLLECTION))\
for(TYPE VARIABLE;__foreach_iterator__.Next(VARIABLE);)
template<typename T>
struct RangeBasedForLoopIteratorWithIndex
{
struct Tuple
{
const T& value;
vint index;
#define FOREACH_INDEXER(TYPE, VARIABLE, INDEXER, COLLECTION)\
SCOPE_VARIABLE(const ::vl::collections::ForEachIterator<TYPE>&, __foreach_iterator__, ::vl::collections::CreateForEachIterator(COLLECTION))\
SCOPE_VARIABLE(vint, INDEXER, 0)\
for(TYPE VARIABLE;__foreach_iterator__.Next(VARIABLE);INDEXER++)
Tuple(const T& _value, vint _index)
: value(_value)
, index(_index)
{
}
};
private:
IEnumerator<T>* iterator;
vint index;
public:
RangeBasedForLoopIteratorWithIndex(const IEnumerable<T>& enumerable)
: iterator(enumerable.CreateEnumerator())
, index(-1)
{
operator++();
}
~RangeBasedForLoopIteratorWithIndex()
{
if (iterator) delete iterator;
}
void operator++()
{
if (!iterator->Next())
{
delete iterator;
iterator = nullptr;
}
index++;
}
Tuple operator*() const
{
return { iterator->Current(),index };
}
bool operator==(RangeBasedForLoopEnding) const
{
return iterator == nullptr;
}
};
template<typename T>
struct EnumerableWithIndex
{
const IEnumerable<T>& enumerable;
EnumerableWithIndex(const IEnumerable<T>& _enumerable)
: enumerable(_enumerable)
{
}
};
template<typename T>
EnumerableWithIndex<T> indexed(const IEnumerable<T>& enumerable)
{
return { enumerable };
}
template<typename T>
RangeBasedForLoopIteratorWithIndex<T> begin(const EnumerableWithIndex<T>& enumerable)
{
return { enumerable.enumerable };
}
template<typename T>
RangeBasedForLoopEnding end(const EnumerableWithIndex<T>& enumerable)
{
return {};
}
}
}
@@ -7003,8 +7077,8 @@ Functions:
From(array) => [T]
Range(start, count) => [vint]
FOREACH(X, a, XList)
FOREACH_INDEXER(X, a, index, XList)
for (auto x : xs);
for (auto [x, i] : indexed(xs));
***********************************************************************/
#ifndef VCZH_COLLECTIONS_OPERATION
@@ -7079,9 +7153,9 @@ Quick Sort
/// Returns zero when two arguments equal.
/// </param>
template<typename T>
void Sort(T* items, vint length, const Func<vint(T, T)>& orderer)
void Sort(T* items, vint length, const Func<vint64_t(T, T)>& orderer)
{
SortLambda<T, Func<vint(T, T)>>(items, length, orderer);
SortLambda<T, Func<vint64_t(T, T)>>(items, length, orderer);
}
/***********************************************************************
@@ -7175,7 +7249,7 @@ LazyList
/// {
/// vint xs[] = {1, 2, 3, 4, 5};
/// auto ys = From(xs).Select([](vint x){ return x * 2; });
/// FOREACH(vint, y, ys) Console::Write(itow(y) + L" ");
/// for (auto y : ys) Console::Write(itow(y) + L" ");
/// }
/// ]]></example>
template<typename F>
@@ -7193,7 +7267,7 @@ LazyList
/// {
/// vint xs[] = {1, 2, 3, 4, 5};
/// auto ys = From(xs).Where([](vint x){ return x % 2 == 0; });
/// FOREACH(vint, y, ys) Console::Write(itow(y) + L" ");
/// for (auto y : ys) Console::Write(itow(y) + L" ");
/// }
/// ]]></example>
template<typename F>
@@ -7246,7 +7320,7 @@ LazyList
/// {
/// vint xs[] = {1, 2, 3, 4, 5};
/// auto ys = From(xs).OrderBy([](vint x, vint y){ return x - y; });
/// FOREACH(vint, y, ys) Console::Write(itow(y) + L" ");
/// for (auto y : ys) Console::Write(itow(y) + L" ");
/// }
/// ]]></example>
template<typename F>
@@ -7319,9 +7393,9 @@ LazyList
template<typename I, typename F>
I Aggregate(I init, F f)const
{
FOREACH(T, t, *this)
for (auto& t : *this)
{
init=f(init, t);
init = f(init, t);
}
return init;
}
@@ -7482,7 +7556,7 @@ LazyList
/// vint xs[] = {1, 2, 3, 4, 5};
/// vint ys[] = {6, 7, 8, 9, 10};
/// auto zs = From(xs).Concat(From(ys));
/// FOREACH(vint, z, zs) Console::Write(itow(z) + L" ");
/// for (auto z : zs) Console::Write(itow(z) + L" ");
/// }
/// ]]></example>
LazyList<T> Concat(const IEnumerable<T>& remains)const
@@ -7498,7 +7572,7 @@ LazyList
/// {
/// vint xs[] = {1, 2, 3, 4, 5};
/// auto ys = From(xs).Take(3);
/// FOREACH(vint, y, ys) Console::Write(itow(y) + L" ");
/// for (auto y : ys) Console::Write(itow(y) + L" ");
/// }
/// ]]></example>
LazyList<T> Take(vint count)const
@@ -7514,7 +7588,7 @@ LazyList
/// {
/// vint xs[] = {1, 2, 3, 4, 5};
/// auto ys = From(xs).Skip(3);
/// FOREACH(vint, y, ys) Console::Write(itow(y) + L" ");
/// for (auto y : ys) Console::Write(itow(y) + L" ");
/// }
/// ]]></example>
LazyList<T> Skip(vint count)const
@@ -7530,7 +7604,7 @@ LazyList
/// {
/// vint xs[] = {1, 2, 3, 4, 5};
/// auto ys = From(xs).Repeat(3);
/// FOREACH(vint, y, ys) Console::Write(itow(y) + L" ");
/// for (auto y : ys) Console::Write(itow(y) + L" ");
/// }
/// ]]></example>
LazyList<T> Repeat(vint count)const
@@ -7545,7 +7619,7 @@ LazyList
/// {
/// vint xs[] = {1, 2, 2, 3, 3, 3, 4, 4, 5};
/// auto ys = From(xs).Distinct();
/// FOREACH(vint, y, ys) Console::Write(itow(y) + L" ");
/// for (auto y : ys) Console::Write(itow(y) + L" ");
/// }
/// ]]></example>
LazyList<T> Distinct()const
@@ -7560,7 +7634,7 @@ LazyList
/// {
/// vint xs[] = {1, 2, 3, 4, 5};
/// auto ys = From(xs).Reverse();
/// FOREACH(vint, y, ys) Console::Write(itow(y) + L" ");
/// for (auto y : ys) Console::Write(itow(y) + L" ");
/// }
/// ]]></example>
LazyList<T> Reverse()const
@@ -7583,7 +7657,7 @@ LazyList
/// vint xs[] = {1, 2, 3, 4, 5, 6, 7};
/// vint ys[] = {60, 70, 80, 90, 100};
/// auto zs = From(xs).Pairwise(From(ys)).Select([](Pair<vint, vint> p){ return p.key + p.value; });
/// FOREACH(vint, z, zs) Console::Write(itow(z) + L" ");
/// for (auto z : zs) Console::Write(itow(z) + L" ");
/// }
/// ]]></example>
template<typename U>
@@ -7601,7 +7675,7 @@ LazyList
/// vint xs[] = {1, 2, 3, 4, 5};
/// vint ys[] = {3, 4, 5, 6, 7};
/// auto zs = From(xs).Intersect(From(ys));
/// FOREACH(vint, z, zs) Console::Write(itow(z) + L" ");
/// for (auto z : zs) Console::Write(itow(z) + L" ");
/// }
/// ]]></example>
LazyList<T> Intersect(const IEnumerable<T>& remains)const
@@ -7618,7 +7692,7 @@ LazyList
/// vint xs[] = {1, 2, 3, 4, 5};
/// vint ys[] = {3, 4, 5, 6, 7};
/// auto zs = From(xs).Except(From(ys));
/// FOREACH(vint, z, zs) Console::Write(itow(z) + L" ");
/// for (auto z : zs) Console::Write(itow(z) + L" ");
/// }
/// ]]></example>
LazyList<T> Except(const IEnumerable<T>& remains)const
@@ -7635,7 +7709,7 @@ LazyList
/// vint xs[] = {1, 2, 3, 4, 5};
/// vint ys[] = {3, 4, 5, 6, 7};
/// auto zs = From(xs).Union(From(ys));
/// FOREACH(vint, z, zs) Console::Write(itow(z) + L" ");
/// for (auto z : zs) Console::Write(itow(z) + L" ");
/// }
/// ]]></example>
LazyList<T> Union(const IEnumerable<T>& remains)const
@@ -7691,7 +7765,7 @@ LazyList
/// vint factors[] = {1, 10, 100};
/// return From(factors).Select([=](vint f){ return f * x; }).Evaluate(true);
/// });
/// FOREACH(vint, y, ys) Console::Write(itow(y) + L" ");
/// for (auto y : ys) Console::Write(itow(y) + L" ");
/// }
/// ]]></example>
template<typename F>
@@ -7717,10 +7791,10 @@ LazyList
/// vint xs[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
/// auto ys = From(xs).GroupBy([](vint x){ return x % 3; });
/// using TY = Pair<vint, LazyList<vint>>;
/// FOREACH(TY, y, ys)
/// for (auto y : ys)
/// {
/// Console::Write(itow(y.key) + L":");
/// FOREACH(vint, z, y.value) Console::Write(L" " + itow(z));
/// for (auto z : y.value) Console::Write(L" " + itow(z));
/// Console::WriteLine(L"");
/// }
/// }
@@ -7805,6 +7879,39 @@ LazyList
{
return FromArray(items);
}
/***********************************************************************
Range-Based For-Loop Iterator with Index for LazyList<T>
***********************************************************************/
template<typename T>
struct LazyListWithIndex
{
LazyList<T> lazyList;
LazyListWithIndex(const LazyList<T>& _lazyList)
: lazyList(_lazyList)
{
}
};
template<typename T>
LazyListWithIndex<T> indexed(const LazyList<T>& lazyList)
{
return { lazyList };
}
template<typename T>
RangeBasedForLoopIteratorWithIndex<T> begin(const LazyListWithIndex<T>& enumerable)
{
return { enumerable.lazyList };
}
template<typename T>
RangeBasedForLoopEnding end(const LazyListWithIndex<T>& enumerable)
{
return {};
}
}
}
+6 -6
View File
@@ -553,7 +553,7 @@ File
{
EncoderStream encoderStream(fileStream, *encoder);
StreamWriter writer(encoderStream);
FOREACH(WString, line, lines)
for (auto line : lines)
{
writer.WriteLine(line);
}
@@ -805,14 +805,14 @@ Folder
{
List<Folder> folders;
GetFolders(folders);
FOREACH(Folder, folder, folders)
for (auto folder : folders)
{
if (!folder.Delete(true)) return false;
}
List<File> files;
GetFiles(files);
FOREACH(File, file, files)
for (auto file : files)
{
if (!file.Delete()) return false;
}
@@ -1121,7 +1121,7 @@ Utilities
{
// concatincate response body
vint totalSize = 0;
FOREACH(BufferPair, p, availableBuffers)
for (auto p : availableBuffers)
{
totalSize += p.length;
}
@@ -1131,7 +1131,7 @@ Utilities
char* utf8 = new char[totalSize];
{
char* temp = utf8;
FOREACH(BufferPair, p, availableBuffers)
for (auto p : availableBuffers)
{
memcpy(temp, p.buffer, p.length);
temp += p.length;
@@ -1140,7 +1140,7 @@ Utilities
memcpy(&response.body[0], utf8, totalSize);
delete[] utf8;
}
FOREACH(BufferPair, p, availableBuffers)
for (auto p : availableBuffers)
{
delete[] p.buffer;
}
+123 -123
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1385,7 +1385,7 @@ GenericTypeInfo
WString GenericTypeInfo::GetTypeFriendlyName()
{
WString result = elementType->GetTypeFriendlyName() + L"<";
FOREACH_INDEXER(Ptr<ITypeInfo>, type, i, genericArguments)
for (auto [type, i] : indexed(genericArguments))
{
if (i>0) result += L", ";
result += type->GetTypeFriendlyName();
@@ -3988,7 +3988,7 @@ MetaonlyTypeInfo
default:;
}
WString result = elementType->GetTypeFriendlyName() + L"<";
FOREACH_INDEXER(Ptr<MetaonlyTypeInfo>, type, i, genericArguments)
for (auto [type, i] : indexed(genericArguments))
{
if (i > 0) result += L", ";
result += type->GetTypeFriendlyName();
+11 -11
View File
@@ -94,7 +94,7 @@ Data Structure
/// {
/// Regex regex(L"^/.*?((?C/S+)(/.*?))+$");
/// auto match = regex.MatchHead(L"C++ and C# are my favorite programing languages");
/// FOREACH(RegexString, capture, match->Captures())
/// for (auto capture : match->Captures())
/// {
/// Console::WriteLine(capture.Value());
/// }
@@ -108,7 +108,7 @@ Data Structure
/// {
/// Regex regex(L"^/.*?((<lang>C/S+)(/.*?))+$");
/// auto match = regex.MatchHead(L"C++ and C# are my favorite programing languages");
/// FOREACH(RegexString, capture, match->Groups().Get(L"lang"))
/// for (auto capture : match->Groups().Get(L"lang"))
/// {
/// Console::WriteLine(capture.Value());
/// }
@@ -278,7 +278,7 @@ Regex
/// Regex regex(L"C/S+");
/// RegexMatch::List matches;
/// regex.Search(L"C++ and C# are my favorite programing languages", matches);
/// FOREACH(Ptr<RegexMatch>, match, matches)
/// for (auto match : matches)
/// {
/// Console::WriteLine(match->Result().Value());
/// }
@@ -295,7 +295,7 @@ Regex
/// Regex regex(L"C/S+");
/// RegexMatch::List matches;
/// regex.Split(L"C++ and C# are my favorite programing languages", false, matches);
/// FOREACH(Ptr<RegexMatch>, match, matches)
/// for (auto match : matches)
/// {
/// Console::WriteLine(match->Result().Value());
/// }
@@ -312,7 +312,7 @@ Regex
/// Regex regex(L"C/S+");
/// RegexMatch::List matches;
/// regex.Cut(L"C++ and C# are my favorite programing languages", false, matches);
/// FOREACH(Ptr<RegexMatch>, match, matches)
/// for (auto match : matches)
/// {
/// Console::WriteLine(match->Result().Value());
/// }
@@ -567,7 +567,7 @@ Tokenizer
/// RegexLexerColorizer colorizer = lexer.Colorize();
///
/// void* lastInterTokenState = nullptr;
/// FOREACH_INDEXER(const wchar_t*, line, index, From(lines))
/// for (auto [line, index] : indexed(From(lines)))
/// {
/// Console::WriteLine(L"Begin line " + itow(index));
/// argument.processingText = line;
@@ -625,7 +625,7 @@ Tokenizer
/// WString input = L"I have 2 books.";
/// auto tokenResult = lexer.Parse(input);
///
/// FOREACH(RegexToken, token, tokenResult)
/// for (auto token : tokenResult)
/// {
/// // input must be in a variable
/// // because token.reading points to a position from input.Buffer();
@@ -668,7 +668,7 @@ Tokenizer
/// List<RegexToken> filtered;
/// tokenResult.ReadToEnd(filtered, [](vint token) { return token < 0 || token == 2; });
///
/// FOREACH(RegexToken, token, tokenResult)
/// for (auto token : tokenResult)
/// {
/// // input must be in a variable
/// // because token.reading points to a position from input.Buffer();
@@ -825,7 +825,7 @@ Tokenizer
/// RegexLexerWalker walker = lexer.Walk();
///
/// WString tests[] = { L".", L"2", L"2.", L"2.5", L"2.5." };
/// FOREACH(WString, test, From(tests))
/// for (auto test : From(tests))
/// {
/// if (walker.IsClosedToken(test.Buffer(), test.Length()))
/// {
@@ -875,7 +875,7 @@ Tokenizer
/// RegexLexerWalker walker = lexer.Walk();
///
/// WString tests[] = { L".", L"2", L"2.", L"2.5", L"2.5." };
/// FOREACH(WString, test, From(tests))
/// for (auto test : From(tests))
/// {
/// if (walker.IsClosedToken(test))
/// {
@@ -934,7 +934,7 @@ Tokenizer
/// RegexLexer lexer(tokenDefs, proc);
/// RegexLexerColorizer colorizer = lexer.Colorize();
///
/// FOREACH_INDEXER(const wchar_t*, line, index, From(lines))
/// /// for (auto [line, index] : indexed(From(lines)))
/// {
/// Console::WriteLine(L"Begin line " + itow(index));
/// argument.processingText = line;
File diff suppressed because it is too large Load Diff
+36 -36
View File
@@ -56,7 +56,7 @@ WfRuntimeCallStackInfo
if (!context)
{
Dictionary<WString, Value> map;
FOREACH_INDEXER(WString, name, index, names)
for (auto [name, index] : indexed(names))
{
map.Add(name, context->variables[index]);
}
@@ -660,19 +660,19 @@ namespace vl
void Initialize(WfWriterContextPrepare& prepare)
{
FOREACH_INDEXER(ITypeDescriptor*, td, index, prepare.tds)
for (auto [td, index] : indexed(prepare.tds))
{
tdIndex.Add(td, index);
}
FOREACH_INDEXER(IMethodInfo*, mi, index, prepare.mis)
for (auto [mi, index] : indexed(prepare.mis))
{
miIndex.Add(mi, index);
}
FOREACH_INDEXER(IPropertyInfo*, pi, index, prepare.pis)
for (auto [pi, index] : indexed(prepare.pis))
{
piIndex.Add(pi, index);
}
FOREACH_INDEXER(IEventInfo*, ei, index, prepare.eis)
for (auto [ei, index] : indexed(prepare.eis))
{
eiIndex.Add(ei, index);
}
@@ -806,19 +806,19 @@ Serialization (CollectMetadata)
static void CollectMetadata(WfTypeImpl* typeImpl, WfWriterContextPrepare& prepare)
{
FOREACH(Ptr<WfClass>, td, typeImpl->classes)
for (auto td : typeImpl->classes)
{
CollectTd(td.Obj(), prepare);
}
FOREACH(Ptr<WfInterface>, td, typeImpl->interfaces)
for (auto td : typeImpl->interfaces)
{
CollectTd(td.Obj(), prepare);
}
FOREACH(Ptr<WfStruct>, td, typeImpl->structs)
for (auto td : typeImpl->structs)
{
CollectTd(td.Obj(), prepare);
}
FOREACH(Ptr<WfEnum>, td, typeImpl->enums)
for (auto td : typeImpl->enums)
{
CollectTd(td.Obj(), prepare);
}
@@ -869,15 +869,15 @@ Serialization (CollectMetadata)
}
}
FOREACH(IMethodInfo*, mi, prepare.mis)
for (auto mi : prepare.mis)
{
CollectTd(mi, prepare);
}
FOREACH(IPropertyInfo*, pi, prepare.pis)
for (auto pi : prepare.pis)
{
CollectTd(pi, prepare);
}
FOREACH(IEventInfo*, ei, prepare.eis)
for (auto ei : prepare.eis)
{
CollectTd(ei, prepare);
}
@@ -1858,19 +1858,19 @@ Serialization (TypeImpl)
static void IO(WfReader& reader, WfTypeImpl& value)
{
// fill types
FOREACH(Ptr<WfClass>, td, value.classes)
for (auto td : value.classes)
{
IOClass(reader, td.Obj());
}
FOREACH(Ptr<WfInterface>, td, value.interfaces)
for (auto td : value.interfaces)
{
IOInterface(reader, td.Obj());
}
FOREACH(Ptr<WfStruct>, td, value.structs)
for (auto td : value.structs)
{
IOStruct(reader, td.Obj());
}
FOREACH(Ptr<WfEnum>, td, value.enums)
for (auto td : value.enums)
{
IOEnum(reader, td.Obj());
}
@@ -1879,19 +1879,19 @@ Serialization (TypeImpl)
static void IO(WfWriter& writer, WfTypeImpl& value)
{
// fill types
FOREACH(Ptr<WfClass>, td, value.classes)
for (auto td : value.classes)
{
IOClass(writer, td.Obj());
}
FOREACH(Ptr<WfInterface>, td, value.interfaces)
for (auto td : value.interfaces)
{
IOInterface(writer, td.Obj());
}
FOREACH(Ptr<WfStruct>, td, value.structs)
for (auto td : value.structs)
{
IOStruct(writer, td.Obj());
}
FOREACH(Ptr<WfEnum>, td, value.enums)
for (auto td : value.enums)
{
IOEnum(writer, td.Obj());
}
@@ -2215,7 +2215,7 @@ Serialization (Assembly)
vint piCount = prepare.pis.Count();
vint eiCount = prepare.eis.Count();
writer << tdCount << miCount << piCount << eiCount;
FOREACH(ITypeDescriptor*, td, prepare.tds)
for (auto td : prepare.tds)
{
writer << td;
}
@@ -2226,15 +2226,15 @@ Serialization (Assembly)
GetGlobalTypeManager()->AddTypeLoader(value.typeImpl);
}
FOREACH(IMethodInfo*, mi, prepare.mis)
for (auto mi : prepare.mis)
{
writer << mi;
}
FOREACH(IPropertyInfo*, pi, prepare.pis)
for (auto pi : prepare.pis)
{
writer << pi;
}
FOREACH(IEventInfo*, ei, prepare.eis)
for (auto ei : prepare.eis)
{
writer << ei;
}
@@ -4988,7 +4988,7 @@ WfEvent
if (index != -1)
{
auto& values = record->handlers.GetByIndex(index);
FOREACH(Ptr<EventHandlerImpl>, handler, values)
for (auto handler : values)
{
handler->proxy->Invoke(arguments);
}
@@ -5570,7 +5570,7 @@ WfInterfaceInstance
arguments[0] = Value::From(_proxy);
#ifdef VCZH_DESCRIPTABLEOBJECT_WITH_METADATA
InitializeAggregation(baseCtors.Count());
FOREACH_INDEXER(IMethodInfo*, ctor, index, baseCtors)
for (auto [ctor, index] : indexed(baseCtors))
{
Ptr<DescriptableObject> ptr;
{
@@ -5616,11 +5616,11 @@ WfTypeImpl
}
globalContext = _globalContext;
FOREACH(Ptr<WfClass>, td, classes)
for (auto td : classes)
{
td->SetGlobalContext(globalContext);
}
FOREACH(Ptr<WfInterface>, td, interfaces)
for (auto td : interfaces)
{
td->SetGlobalContext(globalContext);
}
@@ -5637,7 +5637,7 @@ WfTypeImpl
void WfTypeImpl::Load(reflection::description::ITypeManager* manager)
{
FOREACH(Ptr<WfClass>, td, classes)
for (auto td : classes)
{
if (td->GetBaseTypeDescriptorCount() == 0)
{
@@ -5645,7 +5645,7 @@ WfTypeImpl
}
manager->SetTypeDescriptor(td->GetTypeName(), td);
}
FOREACH(Ptr<WfInterface>, td, interfaces)
for (auto td : interfaces)
{
if (td->GetBaseTypeDescriptorCount() == 0)
{
@@ -5653,11 +5653,11 @@ WfTypeImpl
}
manager->SetTypeDescriptor(td->GetTypeName(), td);
}
FOREACH(Ptr<WfStruct>, td, structs)
for (auto td : structs)
{
manager->SetTypeDescriptor(td->GetTypeName(), td);
}
FOREACH(Ptr<WfEnum>, td, enums)
for (auto td : enums)
{
manager->SetTypeDescriptor(td->GetTypeName(), td);
}
@@ -5665,19 +5665,19 @@ WfTypeImpl
void WfTypeImpl::Unload(reflection::description::ITypeManager* manager)
{
FOREACH(Ptr<WfClass>, td, classes)
for (auto td : classes)
{
manager->SetTypeDescriptor(td->GetTypeName(), nullptr);
}
FOREACH(Ptr<WfInterface>, td, interfaces)
for (auto td : interfaces)
{
manager->SetTypeDescriptor(td->GetTypeName(), nullptr);
}
FOREACH(Ptr<WfStruct>, td, structs)
for (auto td : structs)
{
manager->SetTypeDescriptor(td->GetTypeName(), nullptr);
}
FOREACH(Ptr<WfEnum>, td, enums)
for (auto td : enums)
{
manager->SetTypeDescriptor(td->GetTypeName(), nullptr);
}