#include "WfCpp.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
;
using
namespace
reflection
::
description
;
void
(
*
,
<
*>&
)
{
(
,
(
->
->
.
())
.
([](
<
>
,
<
>
)
{
return
::
(
a
(),
b
());
})
.
([](
<
>
)
{
return
td
.
();
})
);
}
void
::(
stream
::
& )
{
.
(
L"/***********************************************************************"
);
.
(
L"Reflection"
);
.
(
L"***********************************************************************/"
);
.
(
L""
);
<
*> ;
(
this
,
tds
);
.
(
L"namespace vl"
);
.
(
L"{"
);
.
(
L"\tnamespace reflection"
);
.
(
L"\t{"
);
.
(
L"\t\tnamespace description"
);
.
(
L"\t\t{"
);
.
(
L"#ifndef VCZH_DEBUG_NO_REFLECTION"
);
FOREACH(ITypeDescriptor*, td, tds)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>& = ::
vl
::
collections
::
(
tds
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
* ;
__foreach_iterator__
.
(
td
);)
{
.
(
L"\t\t\tDECL_TYPE_INFO("
);
.
(
(
td
));
.
(
L")"
);
}
<
*> ;
(
tdInterfaces
,
(
tds
)
.Where([](
* )
{
return
td
->
() ==
::
;
})
);
{
=
0
;
while
(
processed
<
tdInterfaces
.
())
{
=
tdInterfaces
.
();
for
(
=
processed
;
i
<
count
;
i
++)
{
auto
=
tdInterfaces
i
];
if
(
<
>(
0
,
td
->
GetBaseTypeDescriptorCount
())
.
([&](
)
{
return
tdInterfaces
.
(
td
->
(
baseIndex
)) <
processed
;
}))
{
tdInterfaces
.
(
i
);
tdInterfaces
.
(
processed
++,
td
);
}
}
}
}
if
(
tdInterfaces
.
() >
0
)
{
.
(
L""
);
.
(
L"#ifdef VCZH_DESCRIPTABLEOBJECT_WITH_METADATA"
);
FOREACH(ITypeDescriptor*, td, tdInterfaces)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>& = ::
vl
::
collections
::
(
tdInterfaces
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
* ;
__foreach_iterator__
.
(
td
);)
{
<
*> ;
(
baseTds
,
<
>(
0
,
td
->
GetBaseTypeDescriptorCount
())
.
([&](
)
{
return
td
->
(
index
);
})
.
([&](
* )
{
return
baseTd
->
() !=
::
;
})
);
.
(
L""
);
if
(
baseTds
.
() >
0
)
{
.
(
L"\t\t\tBEGIN_INTERFACE_PROXY_SHAREDPTR("
);
.
(
(
td
));
FOREACH(ITypeDescriptor*, baseTd, baseTds)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>& = ::
vl
::
collections
::
(
baseTds
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
* ;
__foreach_iterator__
.
(
baseTd
);)
{
.
(
L", "
);
.
(
(
baseTd
));
}
.
(
L")"
);
}
else
{
.
(
L"\t\t\tBEGIN_INTERFACE_PROXY_NOPARENT_SHAREDPTR("
);
.
(
(
td
));
.
(
L")"
);
}
=
td
->
();
for
(
=
0
;
i
<
methodGroupCount
;
i
++)
{
auto
=
td
->
(
i
);
=
methodGroup
->
();
for
(
=
0
;
j
<
methodCount
;
j
++)
{
auto
=
methodGroup
->
(
j
);
if
(!
methodInfo
->
())
{
.
(
L"\t\t\t\t"
);
(
,
methodInfo
,
(
methodInfo
->
()),
true
);
.
(
L" override"
);
.
(
L"\t\t\t\t{"
);
if
(
methodInfo
->
()->
() ==
description
::
<
void
>())
{
.
(
L"\t\t\t\t\tINVOKE_INTERFACE_PROXY"
);
}
else
{
.
(
L"\t\t\t\t\tINVOKEGET_INTERFACE_PROXY"
);
}
if
(
methodInfo
->
() >
0
)
{
.
(
L"("
);
.
(
(
methodInfo
->
()));
=
methodInfo
->
();
for
(
=
0
;
k
<
parameterCount
;
k
++)
{
.
(
L", "
);
.
(
(
methodInfo
->
(
k
)->
()));
}
.
(
L");"
);
}
else
{
.
(
L"_NOPARAMS("
);
.
(
(
methodInfo
->
()));
.
(
L");"
);
}
.
(
L"\t\t\t\t}"
);
}
}
}
.
(
L"\t\t\tEND_INTERFACE_PROXY("
);
.
(
(
td
));
.
(
L")"
);
}
.
(
L"#endif"
);
}
.
(
L"#endif"
);
.
(
L""
);
.
(
L"\t\t\textern bool Load"
);
.
(
);
.
(
L"Types();"
);
.
(
L"\t\t}"
);
.
(
L"\t}"
);
.
(
L"}"
);
}
void
::
(
stream
::
&
)
{
.
(
L"/***********************************************************************"
);
.
(
L"Reflection"
);
.
(
L"***********************************************************************/"
);
.
(
L""
);
<
*>
;
(
this
,
tds
);
.
(
L"namespace vl"
);
.
(
L"{"
);
.
(
L"\tnamespace reflection"
);
.
(
L"\t{"
);
.
(
L"\t\tnamespace description"
);
.
(
L"\t\t{"
);
.
(
L"#ifndef VCZH_DEBUG_NO_REFLECTION"
);
FOREACH(ITypeDescriptor*, td, tds)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
tds
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
td
);)
{
.
(
L"\t\t\tIMPL_CPP_TYPE_INFO("
);
=
(
td
);
if
(
type
.
() >
2
&&
type
.
(
0
,
2
) ==
L"::"
)
{
type
type
.
(
2
,
type
.
() -
2
);
}
.
(
type
);
.
(
L")"
);
}
.
(
L""
);
.
(
L"#ifdef VCZH_DESCRIPTABLEOBJECT_WITH_METADATA"
);
.
(
L"#define _ ,"
);
FOREACH(ITypeDescriptor*, td, tds)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
tds
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
td
);)
{
switch
(
td
->
())
{
case
::
:
case
::
:
{
.
(
L"\t\t\tBEGIN_ENUM_ITEM"
);
if
(
td
->
() ==
::
)
{
.
(
L"_MERGABLE"
);
}
.
(
L"("
);
.
(
(
td
));
.
(
L")"
);
auto
=
td
->
();
=
enumType
->
();
for
(
=
0
;
i
<
count
;
i
++)
{
.
(
L"\t\t\t\tENUM_CLASS_ITEM("
);
.
(
(
enumType
->
(
i
)));
.
(
L")"
);
}
.
(
L"\t\t\tEND_ENUM_ITEM("
);
.
(
(
td
));
.
(
L")"
);
}
break
;
case
::
:
{
.
(
L"\t\t\tBEGIN_STRUCT_MEMBER("
);
.
(
(
td
));
.
(
L")"
);
=
td
->
();
for
(
=
0
;
i
<
count
;
i
++)
{
.
(
L"\t\t\t\tSTRUCT_MEMBER("
);
.
(
(
td
->
(
i
)->
()));
.
(
L")"
);
}
.
(
L"\t\t\tEND_STRUCT_MEMBER("
);
.
(
(
td
));
.
(
L")"
);
}
break
;
case
::
:
case
::
:
{
if
(
td
->
() ==
::
)
{
.
(
L"\t\t\tBEGIN_INTERFACE_MEMBER("
);
}
else
{
.
(
L"\t\t\tBEGIN_CLASS_MEMBER("
);
}
.
(
(
td
));
.
(
L")"
);
=
td
->
GetBaseTypeDescriptorCount
();
for
(
=
0
;
i
<
baseCount
;
i
++)
{
.
(
L"\t\t\t\tCLASS_MEMBER_BASE("
);
.
(
(
td
->
(
i
)));
.
(
L")"
);
}
if
(
td
->
() ==
::
)
{
auto
=
td
->
();
=
methodGroup
->
();
for
(
=
0
;
j
<
methodCount
;
j
++)
{
auto
=
methodGroup
->
(
j
);
=
methodInfo
->
();
.
(
L"\t\t\t\tCLASS_MEMBER_CONSTRUCTOR("
);
.
(
(
methodInfo
->
()));
.
(
L"("
);
for
(
=
0
;
k
<
parameterCount
;
k
++)
{
if
(
k
>
0
)
{
.
(
L", "
);
}
.
(
(
methodInfo
->
(
k
)->
()));
}
.
(
L")"
);
if
(
parameterCount
>
0
)
{
.
(
L", {"
);
for
(
=
0
;
k
<
parameterCount
;
k
++)
{
if
(
k
>
0
)
{
.
(
L" _"
);
}
.
(
L" L\""
);
.
(
(
methodInfo
->
(
k
)->
()));
.
(
L"\""
);
}
.
(
L" })"
);
}
else
{
.
(
L", NO_PARAMETER)"
);
}
}
}
=
td
->
();
for
(
=
0
;
i
<
methodGroupCount
;
i
++)
{
auto
=
td
->
(
i
);
=
methodGroup
->
();
for
(
=
0
;
j
<
methodCount
;
j
++)
{
auto
=
methodGroup
->
(
j
);
if
(
methodInfo
->
())
{
.
(
L"\t\t\t\tCLASS_MEMBER_STATIC_METHOD"
);
}
else
{
.
(
L"\t\t\t\tCLASS_MEMBER_METHOD"
);
}
if
(
methodCount
>
1
)
{
.
(
L"_OVERLOAD"
);
}
.
(
L"("
);
.
(
(
methodInfo
->
()));
=
methodInfo
->
();
if
(
parameterCount
>
0
)
{
.
(
L", {"
);
for
(
=
0
;
k
<
parameterCount
;
k
++)
{
if
(
k
>
0
)
{
.
(
L" _"
);
}
.
(
L" L\""
);
.
(
(
methodInfo
->
(
k
)->
()));
.
(
L"\""
);
}
.
(
L" }"
);
}
else
{
.
(
L", NO_PARAMETER"
);
}
if
(
methodCount
>
1
)
{
.
(
L", "
);
auto
=
methodInfo
->
() ?
(
L"(*)"
,
false
) :
L"("
+
(
td
) +
L"::*)"
;
.
(
(
methodInfo
,
typeDecorator
));
}
.
(
L")"
);
}
}
=
td
->
();
for
(
=
0
;
i
<
eventCount
;
i
++)
{
auto
=
td
->
(
i
);
.
(
L"\t\t\t\tCLASS_MEMBER_EVENT("
);
.
(
(
eventInfo
->
()));
.
(
L")"
);
}
=
td
->
();
for
(
=
0
;
i
<
propertyCount
;
i
++)
{
auto
=
td
->
(
i
);
if
(
auto
=
propertyInfo
->
())
{
if
(
auto
=
propertyInfo
->
())
{
if
(
auto
=
propertyInfo
->
())
{
.
(
L"\t\t\t\tCLASS_MEMBER_PROPERTY_EVENT("
);
.
(
(
propertyInfo
->
()));
.
(
L", "
);
.
(
(
getter
->
()));
.
(
L", "
);
.
(
(
setter
->
()));
.
(
L", "
);
.
(
(
eventInfo
->
()));
.
(
L")"
);
}
else
{
.
(
L"\t\t\t\tCLASS_MEMBER_PROPERTY_EVENT_READONLY("
);
.
(
(
propertyInfo
->
()));
.
(
L", "
);
.
(
(
getter
->
()));
.
(
L", "
);
.
(
(
eventInfo
->
()));
.
(
L")"
);
}
}
else
{
if
(
auto
=
propertyInfo
->
())
{
.
(
L"\t\t\t\tCLASS_MEMBER_PROPERTY("
);
.
(
(
propertyInfo
->
()));
.
(
L", "
);
.
(
(
getter
->
()));
.
(
L", "
);
.
(
(
setter
->
()));
.
(
L")"
);
}
else
{
.
(
L"\t\t\t\tCLASS_MEMBER_PROPERTY_READONLY("
);
.
(
(
propertyInfo
->
()));
.
(
L", "
);
.
(
(
getter
->
()));
.
(
L")"
);
}
}
}
else
{
.
(
L"\t\t\t\tCLASS_MEMBER_FIELD("
);
.
(
(
propertyInfo
->
()));
.
(
L")"
);
}
}
if
(
td
->
() ==
::
)
{
.
(
L"\t\t\tEND_INTERFACE_MEMBER("
);
}
else
{
.
(
L"\t\t\tEND_CLASS_MEMBER("
);
}
.
(
(
td
));
.
(
L")"
);
}
break
;
default
:;
}
.
(
L""
);
}
.
(
L"#undef _"
);
.
(
L"\t\t\tclass "
);
.
(
);
.
(
L"TypeLoader : public Object, public ITypeLoader"
);
.
(
L"\t\t\t{"
);
.
(
L"\t\t\tpublic:"
);
.
(
L"\t\t\t\tvoid Load(ITypeManager* manager)"
);
.
(
L"\t\t\t\t{"
);
FOREACH(ITypeDescriptor*, td, tds)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
tds
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
td
);)
{
.
(
L"\t\t\t\t\tADD_TYPE_INFO("
);
.
(
(
td
));
.
(
L")"
);
}
.
(
L"\t\t\t\t}"
);
.
(
L""
);
.
(
L"\t\t\t\tvoid Unload(ITypeManager* manager)"
);
.
(
L"\t\t\t\t{"
);
.
(
L"\t\t\t\t}"
);
.
(
L"\t\t\t};"
);
.
(
L"#endif"
);
.
(
L"#endif"
);
.
(
L""
);
.
(
L"\t\t\tbool Load"
);
.
(
);
.
(
L"Types()"
);
.
(
L"\t\t\t{"
);
.
(
L"#ifdef VCZH_DESCRIPTABLEOBJECT_WITH_METADATA"
);
.
(
L"\t\t\t\tif (auto manager = GetGlobalTypeManager())"
);
.
(
L"\t\t\t\t{"
);
.
(
L"\t\t\t\t\treturn manager->AddTypeLoader(MakePtr<"
);
.
(
);
.
(
L"TypeLoader>());"
);
.
(
L"\t\t\t\t}"
);
.
(
L"#endif"
);
.
(
L"\t\t\t\treturn false;"
);
.
(
L"\t\t\t}"
);
.
(
L"\t\t}"
);
.
(
L"\t}"
);
.
(
L"}"
);
}
}
}
}