#include "WfCpp.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
;
using
namespace
reflection
::
description
;
void
::
(
<
,
<
>>&
,
<
,
<
>>&
)
{
(
,
(
)
.Select([](
<
<
>,
>
)
{
return
<
,
<
>>(
pair
.
,
pair
.
);
})
);
(
,
(
)
.Select([](
<
<
>,
>
)
{
return
<
,
<
>>(
pair
.
,
pair
.
);
})
);
}
void
::(
stream
::
& )
{
<
,
<
>> ;
<
,
<
>> ;
(
reversedLambdaExprs
,
reversedClassExprs
);
.
(
L"/***********************************************************************"
);
.
(
L"Global Variables and Functions"
);
.
(
L"***********************************************************************/"
);
.
(
L""
);
.
(
L"namespace "
+
);
.
(
L"{"
);
.
(
L"\tclass "
+
);
.
(
L"\t{"
);
.
(
L"\tpublic:"
);
if
(
.
() >
0
)
{
.
(
L""
);
FOREACH(Ptr<WfVariableDeclaration>, decl, varDecls)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
decl
);)
{
auto
=
->
decl
.
()].
();
auto
=
scope
->
decl
.
]
0
];
auto
=
symbol
;
.
(
L"\t\t"
+
(
typeInfo
.
()) +
L" "
+
(
decl
.
));
auto
=
(
typeInfo
.
());
if
(
defaultValue
!=
L""
)
{
.
(
L" = "
);
.
(
defaultValue
);
}
.
(
L";"
);
}
}
if
(
.
() >
0
)
{
.
(
L""
);
FOREACH(Ptr<WfFunctionDeclaration>, decl, funcDecls)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
decl
);)
{
.
(
L"\t\t"
);
(
,
decl
,
(
decl
.
),
true
);
.
(
L";"
);
}
}
.
(
L""
);
.
(
L"\t\tstatic "
+
+
L"& Instance();"
);
.
(
L"\t};"
);
if
(
reversedLambdaExprs
.
() +
reversedClassExprs
.
() >
0
)
{
.
(
L""
);
.
(
L"/***********************************************************************"
);
.
(
L"Closures"
);
.
(
L"***********************************************************************/"
);
FOREACH(Ptr<WfExpression>, expr, reversedLambdaExprs.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
reversedLambdaExprs
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
expr
);)
{
.
(
L""
);
WriteHeader_LambdaExprDecl
(
,
expr
);
}
FOREACH(Ptr<WfNewInterfaceExpression>, expr, reversedClassExprs.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
reversedClassExprs
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
expr
);)
{
.
(
L""
);
WriteHeader_ClassExprDecl
(
,
expr
);
}
}
.
(
L"}"
);
}
void
::
(
stream
::
&
)
{
<
,
<
>>
;
<
,
<
>>
;
(
reversedLambdaExprs
,
reversedClassExprs
);
.
(
L"/***********************************************************************"
);
.
(
L"Global Variables"
);
.
(
L"***********************************************************************/"
);
.
(
L""
);
=
+
L"_"
+
;
.
(
L"BEGIN_GLOBAL_STORAGE_CLASS("
+
storageName
+
L")"
);
.
(
L"\t"
+
+
L"::"
+
+
L" instance;"
);
.
(
L"\tINITIALIZE_GLOBAL_STORAGE_CLASS"
);
if
(
.
() >
0
)
{
.
(
L""
);
FOREACH(Ptr<WfVariableDeclaration>, decl, varDecls)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
decl
);)
{
auto
=
->
decl
.
()].
();
auto
=
scope
->
decl
.
]
0
];
auto
=
symbol
;
if
(
decl
)
{
.
(
L"\t\tinstance."
+
(
decl
.
) +
L" = "
);
(
this
,
,
decl
,
typeInfo
.
());
.
(
L";"
);
}
}
}
.
(
L"\tFINALIZE_GLOBAL_STORAGE_CLASS"
);
if
(
.
() >
0
)
{
.
(
L""
);
FOREACH(Ptr<WfVariableDeclaration>, decl, varDecls)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
decl
);)
{
auto
=
->
decl
.
()].
();
auto
=
scope
->
decl
.
]
0
];
auto
=
symbol
;
switch
(
typeInfo
())
{
case
::
:
case
::
:
.
(
L"\t\tinstance."
+
(
decl
.
) +
L" = nullptr;"
);
break
;
case
::
:
.
(
L"\t\tinstance."
+
(
decl
.
) +
L" = "
);
(
typeInfo
.
());
.
(
L"();"
);
break
;
default
:
if
(
typeInfo
() ==
description
::
<
>())
{
.
(
L"\t\tinstance."
+
(
decl
.
) +
L" = ::vl::WString::Empty;"
);
}
else
if
(
typeInfo
() ==
description
::
<
>())
{
.
(
L"\t\tinstance."
+
(
decl
.
) +
L" = ::vl::reflection::description::Value();"
);
}
}
}
}
.
(
L"END_GLOBAL_STORAGE_CLASS("
+
storageName
+
L")"
);
.
(
L""
);
.
(
L"namespace "
);
.
(
);
.
(
L"{"
);
.
(
L"/***********************************************************************"
);
.
(
L"Global Functions"
);
.
(
L"***********************************************************************/"
);
FOREACH(Ptr<WfFunctionDeclaration>, decl, funcDecls)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
decl
);)
{
.
(
L""
);
.
(
L"\t"
);
auto
=
(
,
decl
,
+
L"::"
+
(
decl
.
),
true
);
.
(
L""
);
(
,
decl
,
L"\t"
,
returnType
);
}
.
(
L""
);
.
(
L"\t"
+
+
L"& "
+
+
L"::Instance()"
);
.
(
L"\t{"
);
.
(
L"\t\treturn Get"
+
storageName
+
L"().instance;"
);
.
(
L"\t}"
);
if
(
reversedLambdaExprs
.
() +
reversedClassExprs
.
() >
0
)
{
.
(
L""
);
.
(
L"/***********************************************************************"
);
.
(
L"Closures"
);
.
(
L"***********************************************************************/"
);
FOREACH(Ptr<WfExpression>, expr, reversedLambdaExprs.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
reversedLambdaExprs
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
expr
);)
{
.
(
L""
);
.
(
L"\t//-------------------------------------------------------------------"
);
.
(
L""
);
(
,
expr
);
}
if
(
reversedClassExprs
.
() >
0
)
{
.
(
L""
);
FOREACH(Ptr<WfNewInterfaceExpression>, expr, reversedClassExprs.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
reversedClassExprs
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
expr
);)
{
.
(
L"\t//-------------------------------------------------------------------"
);
.
(
L""
);
(
,
expr
);
}
}
}
.
(
L"}"
);
}
}
}
}