#include "WfCpp.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
;
using
namespace
reflection
::
description
;
void
::(
stream
::
& ,
<
> ,
const
& ,
const
& )
{
.
(
+
L"class "
+
+
L";"
);
}
void
::(
stream
::
& ,
<
> ,
collections
::
<
>& )
{
auto
=
->
.
()].
();
;
auto
=
(
,
(
td
),
,
name
);
(
,
,
name
,
prefix
);
}
class
:
public
empty_visitor
::
{
public
:
<
<
>>& ;
(
<
<
>>& )
:unprocessed(
)
{
}
void
(
* )
override
{
FOREACH(Ptr<WfDeclaration>, decl, node->expandedDeclarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
decl
);)
{
decl
(
this
);
}
}
void
(
* )
override
{
FOREACH(Ptr<WfDeclaration>, decl, node->expandedDeclarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
decl
);)
{
decl
(
this
);
}
}
void
(
* )
override
{
.
(
);
}
};
void
::(
stream
::
& ,
<
> ,
const
& ,
const
& )
{
auto
=
->
.
()].
();
.
(
+
L"class "
+
+
L" : "
);
switch
(
)
{
case
::
:
{
=
td
->
GetBaseTypeDescriptorCount
();
bool
=
<
>(
0
,
count
)
.
([=](
)
{
auto
=
td
->
(
index
);
return
baseTd
->
() ==
::
&&
baseTd
!=
description
::
<
>();
});
if
(!
hasClassBase
)
{
.
(
L"public ::vl::Object, "
);
}
for
(
=
0
;
i
<
count
;
i
++)
{
auto
=
td
->
(
i
);
switch
(
baseTd
->
())
{
case
::
:
if
(
baseTd
!=
description
::
<
>())
{
.
(
L"public "
+
(
baseTd
) +
L", "
);
}
break
;
case
::
:
.
(
L"public virtual "
+
(
baseTd
) +
L", "
);
break
;
default
:;
}
}
}
break
;
case
::
:
{
=
td
->
GetBaseTypeDescriptorCount
();
for
(
=
0
;
i
<
count
;
i
++)
{
.
(
L"public virtual "
+
(
td
->
(
i
)) +
L", "
);
}
}
break
;
}
.
(
L"public ::vl::reflection::Description<"
+
+
L">"
);
.
(
+
L"{"
);
{
<
<
>> ;
unprocessed
.
(
);
FOREACH(Ptr<WfAttribute>, attribute, attributeEvaluator->GetAttributes(decl->attributes, L"cpp", L"Friend"))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
(
,
L"cpp"
,
L"Friend"
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
attribute
);)
{
auto
=
(
attribute
);
CHECK_ERROR(attValue.type == runtime::WfInsType::Unknown && attValue.typeDescriptor != nullptr, L"Unexpected value in attribute: @cpp.Friend.");
do
{
if
(!(
attValue
.
==
runtime
::
::
&&
attValue
.
!=
nullptr
))
throw
(
L"Unexpected value in attribute: @cpp.Friend."
);}
while
(
0
);
auto
=
attValue
.
;
auto
=
->
td
];
if
(
scopeName
.
() ==
0
)
{
.
(
+
L"\tfriend class "
+
(
td
) +
L";"
);
}
else
{
auto
=
scopeName
0
].
<
>();
unprocessed
.
(
friendDecl
);
}
}
auto
=
(
->
.
()].
());
for
(
=
0
;
i
<
unprocessed
.
();
i
++)
{
auto
=
unprocessed
i
];
if
(
current
)
{
auto
=
(
->
current
.
()].
());
bool
=
false
;
if
(
currentTypeName
.
() >
declTypeName
.
() +
2
)
{
if
(
currentTypeName
.
(
declTypeName
.
() +
2
) ==
declTypeName
+
L"::"
)
{
isInternalClass
=
true
;
}
}
if
(!
isInternalClass
)
{
.
(
+
L"\tfriend class "
+
currentTypeName
+
L";"
);
}
}
=
.
().
(
current
.
());
if
(
index
!= -
1
)
{
<
> ;
(
closureNames
,
(
.
(
index
))
.
([&](
<
> )
{
return
(
closure
.
<
>() ?
L"class ::"
:
L"struct ::"
) +
+
L"::"
+
closure
.
()]
;
})
);
FOREACH(WString, closureName, closureNames)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>& = ::
vl
::
collections
::
(
closureNames
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
closureName
);)
{
.
(
+
L"\tfriend "
+
closureName
+
L";"
);
}
}
WriteHeader_Class_FindClassDeclVisitor
(
unprocessed
);
FOREACH(Ptr<WfDeclaration>, memberDecl, current->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
current
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
memberDecl
);)
{
memberDecl
(&
visitor
);
}
}
}
.
(
L"#ifdef VCZH_DESCRIPTABLEOBJECT_WITH_METADATA"
);
.
(
+
L"\tfriend struct ::vl::reflection::description::CustomTypeDescriptorSelector<"
+
+
L">;"
);
.
(
L"#endif"
);
const
=
0
;
const
=
1
;
const
=
2
;
= -
1
;
{
=
.
().
(
.
());
if
(
index
!= -
1
)
{
if
(
accessor
!=
PUBLIC
)
{
accessor
=
PUBLIC
;
.
(
+
L"public:"
);
}
FOREACH(Ptr<WfEnumDeclaration>, decl, enumDecls.GetByIndex(index))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
.
(
index
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
decl
);)
{
(
,
decl
,
(
decl
.
),
+
L"\t"
,
false
);
.
(
L""
);
}
}
}
{
=
.
().
(
.
());
if
(
index
!= -
1
)
{
if
(
accessor
!=
PUBLIC
)
{
accessor
=
PUBLIC
;
.
(
+
L"public:"
);
}
FOREACH(Ptr<WfStructDeclaration>, decl, structDecls.GetByIndex(index))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
.
(
index
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
decl
);)
{
(
,
decl
,
(
decl
.
),
+
L"\t"
,
false
);
.
(
L""
);
}
}
}
{
=
.
().
(
.
());
if
(
index
!= -
1
)
{
if
(
accessor
!=
PUBLIC
)
{
accessor
=
PUBLIC
;
.
(
+
L"public:"
);
}
FOREACH(Ptr<WfClassDeclaration>, decl, classDecls.GetByIndex(index))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
.
(
index
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
decl
);)
{
(
,
decl
,
(
decl
.
),
+
L"\t"
);
}
.
(
L""
);
FOREACH(Ptr<WfClassDeclaration>, decl, classDecls.GetByIndex(index))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
.
(
index
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
decl
);)
{
(
,
decl
,
(
decl
.
),
+
L"\t"
);
}
}
}
FOREACH(Ptr<WfDeclaration>, memberDecl, decl->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
memberDecl
);)
{
=
PUBLIC
;
if
(
(
memberDecl
,
L"cpp"
,
L"Private"
))
{
memberAccessor
=
PRIVATE
;
}
else
if
(
(
memberDecl
,
L"cpp"
,
L"Protected"
))
{
memberAccessor
=
PROTECTED
;
}
if
(
accessor
!=
memberAccessor
)
{
accessor
=
memberAccessor
;
switch
(
accessor
)
{
case
PRIVATE
:
.
(
+
L"private:"
);
break
;
case
PROTECTED
:
.
(
+
L"protected:"
);
break
;
case
PUBLIC
:
.
(
+
L"public:"
);
break
;
}
}
(
this
,
,
(
.
),
memberDecl
,
+
L"\t"
,
false
);
}
if
(
IsClassHasUserImplMethods
(
,
false
))
{
auto
=
->
.
()].
();
auto
=
(
td
);
.
(
L""
);
.
(
+
L"/* USER_CONTENT_BEGIN(custom members of "
+
classFullName
+
L") */"
);
.
(
+
L"/* USER_CONTENT_END() */"
);
}
.
(
+
L"};"
);
}
::(
stream
::
& ,
<
> ,
collections
::
<
>& )
{
auto
=
->
.
()].
();
;
auto
=
(
,
(
td
),
,
name
);
(
,
,
name
,
prefix
);
return
prefix
;
}
bool
::
(
stream
::
&
,
<
>
,
<
>
,
collections
::
<
>&
)
{
<
>
;
(
,
nss2
);
auto
=
(
,
,
nss2
);
auto
=
->
.
()].
();
auto
=
(
td
);
return
(
this
,
,
.
(),
(
),
(
.
),
classFullName
,
,
prefix
);
}
void
::
(
stream
::
&
,
<
>
,
collections
::
<
>&
)
{
<
<
>>
;
classes
.
(
);
=
0
;
while
(
processed
<
classes
.
())
{
auto
=
classes
processed
++];
.
(
L"/***********************************************************************"
);
.
(
L"Class ("
+
(
->
current
.
()].
()) +
L")"
);
.
(
L"***********************************************************************/"
);
.
(
L""
);
FOREACH(Ptr<WfDeclaration>, memberDecl, current->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
current
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
memberDecl
);)
{
if
(
(
,
current
,
memberDecl
,
))
{
.
(
L""
);
}
}
=
.
().
(
current
.
());
if
(
index
!= -
1
)
{
(
classes
,
.
(
index
),
true
);
}
}
}
}
}
}