#include "GuiInstanceLoader.h"
#include "WorkflowCodegen/GuiInstanceLoader_WorkflowCodegen.h"
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
::
description
;
using
namespace
workflow
;
using
namespace
workflow
::
analyzer
;
using
namespace
controls
;
using
namespace
controls
::
list
;
using
namespace
templates
;
class
GuiTemplatePropertyDeserializer
:
public
,
public
{
protected
:
<
>
;
bool
(
*
)
{
if
(
->
() ==
::
)
{
auto
=
->
();
if
(
genericType
->
() ==
::
&&
genericType
->
() ==
2
)
{
if
(
genericType
->
()->
() ==
description
::
<
>())
{
if
(
genericType
->
(
1
)->
() ==
description
::
<
>())
{
auto
=
genericType
->
(
0
);
if
(
returnType
->
() ==
::
)
{
if
(
returnType
->
()->
()->
(
description
::
<
>()))
{
return
true
;
}
}
}
}
}
}
return
false
;
}
bool
IsDataVisualizerFactoryType
(
*
)
{
return
->
() ==
::
&&
->
() ==
description
::
<
list
::
>();
}
bool
(
*
)
{
return
->
() ==
::
&&
->
() ==
description
::
<
list
::
>();
}
public
:
GuiTemplatePropertyDeserializer
()
{
<
>::
();
}
bool
(
const
::
&
,
description
::
*
)
override
{
return
(
) ||
IsDataVisualizerFactoryType
(
) ||
(
);
}
description
::
*
(
const
::
&
,
description
::
*
)
override
{
return
.
();
}
static
void
(
types
::
&
,
,
<
*>&
,
,
::
&
)
{
<
>
;
(
,
typeNames
);
if
(
typeNames
.
() ==
0
)
{
.
(
({
.
},
,
L"Precompile: Template list \""
+
+
L"\" cannot be empty."
));
}
FOREACH(WString, controlTemplateName, typeNames)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
typeNames
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
controlTemplateName
);)
{
auto
=
description
::
(
controlTemplateName
);
if
(!
controlTemplateTd
)
{
auto index = INVLOC.FindFirst(controlTemplateName, L":", Locale::None);
auto
=
vl
::
::
().
(
controlTemplateName
,
L":"
,
::
);
;
auto
=
controlTemplateName
;
if
(
index
.key != -
1
)
{
namespaceName
=
::
(
controlTemplateName
.
(
index
.key));
typeName
=
controlTemplateName
.
(
controlTemplateName
.
() -
index
.key -
index
.value);
}
auto
=
FindInstanceLoadingSource
(
.
,
namespaceName
,
typeName
);
if
(
auto
=
()->
(
source
.
))
{
controlTemplateTd
=
typeInfo
();
}
}
if
(
controlTemplateTd
)
{
.
(
controlTemplateTd
);
}
else
{
.
(
({
.
},
,
L"Precompile: Type \""
+
controlTemplateName
+
L"\" does not exist."
));
continue
;
}
}
}
static
<
>
(
types
::
&
,
<
*>&
,
*
,
*
,
,
::
&
)
{
auto
=
<
>();
funcCreateTemplate
=
::
;
funcCreateTemplate
(
);
auto
=
<
>();
argViewModel
(
<
>::
().
());
argViewModel
.
=
L"<viewModel>"
;
funcCreateTemplate
.
(
argViewModel
);
auto
=
<
>();
funcCreateTemplate
block
;
*
=
nullptr
;
FOREACH(ITypeDescriptor*, controlTemplateTd, controlTemplateTds)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
controlTemplateTd
);)
{
if
(!
controlTemplateTd
->
(
->
()))
{
.
(
({
.
},
,
L"Precompile: Type \""
+
controlTemplateTd
->
() +
L"\" cannot be used here because it requires \""
+
->
()->
() +
L"\" or its derived classes."
));
}
if
(
stopControlTemplateTd
)
{
.
(
({
.
},
,
L"Precompile: Type \""
+
controlTemplateTd
->
() +
L"\" will never be tried, because \""
+
stopControlTemplateTd
->
() +
L"\", which is listed before, has a default constructor. So whatever the view model is, it will be the last choice."
));
continue
;
}
*
=
nullptr
;
{
auto
=
controlTemplateTd
->
();
if
(!
ctors
||
ctors
->
() !=
1
)
{
.
(
({
.
},
,
L"Precompile: To use type \""
+
controlTemplateTd
->
() +
L"\" as a control template or item template, it should have exactly one constructor."
));
continue
;
}
auto
=
ctors
->
(
0
);
if
(
ctor
->
() >
1
)
{
.
(
({
.
},
,
L"Precompile: To use type \""
+
controlTemplateTd
->
() +
L"\" as a control template or item template, its constructor cannot have more than one parameter."
));
continue
;
}
if
(
ctor
->
() !=
0
)
{
viewModelType
=
ctor
->
(
0
)->
();
}
}
if
(!
viewModelType
)
{
stopControlTemplateTd
=
controlTemplateTd
;
}
auto
=
<
>();
block
.
(
subBlock
);
<
>
;
{
auto
=
<
>(
controlTemplateTd
,
::
);
auto
=
<
>(
elementType
);
controlTemplateType
pointerType
;
}
<
>
;
if
(
viewModelType
)
{
auto
=
<
>();
refViewModel
.
=
L"<viewModel>"
;
auto
=
<
>();
condition
=
::
;
condition
refViewModel
;
condition
(
viewModelType
);
auto
=
<
>();
subBlock
.
(
ifStat
);
ifStat
condition
;
returnStatBlock
<
>();
ifStat
returnStatBlock
;
}
else
{
returnStatBlock
subBlock
;
}
{
auto
=
<
>();
createControlTemplate
(
controlTemplateType
.
());
if
(
viewModelType
)
{
auto
=
<
>();
refViewModel
.
=
L"<viewModel>"
;
auto
=
<
>();
cast
=
::
;
cast
refViewModel
;
cast
(
viewModelType
);
createControlTemplate
.
(
cast
);
}
auto
=
<
>();
returnStat
createControlTemplate
;
returnStatBlock
.
(
returnStat
);
}
}
if
(!
stopControlTemplateTd
)
{
auto
=
<
>();
value
.
=
L"Cannot find a matched control template to create."
;
auto
=
<
WfRaiseExceptionStatement
>();
raiseStat
value
;
block
.
(
raiseStat
);
}
auto
=
<
>();
expr
funcCreateTemplate
;
return
expr
;
}
static
<
>
CreateDataVisualizerFactory
(
types
::
&
,
<
*>&
,
,
::
&
)
{
auto
=
<
GuiGridVisualizerTemplate
*>::
();
<
>
;
FOREACH_INDEXER(ITypeDescriptor*, controlTemplateTd, index, controlTemplateTds)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
controlTemplateTd
);
index
++)
{
<
*>
;
tds
.
(
controlTemplateTd
);
auto
=
(
,
tds
,
templateType
.
(),
templateType
.
(),
,
);
auto
=
<
>();
createStyle
(
<
<
list
::
>>::
().
());
createStyle
.
(
refFactory
);
if
(
index
>
0
)
{
createStyle
.
(
previousFactory
);
}
else
{
auto
=
<
>();
nullExpr
=
::
;
createStyle
.
(
nullExpr
);
}
previousFactory
createStyle
;
}
return
previousFactory
;
}
static
<
>
(
types
::
&
,
<
*>&
,
,
::
&
)
{
auto
=
<
*>::
();
auto
=
(
,
,
templateType
.
(),
templateType
.
(),
,
);
auto
=
<
>();
createStyle
(
<
<
list
::
>>::
().
());
createStyle
.
(
refFactory
);
return
createStyle
;
}
<
workflow
::
>
(
GuiResourcePrecompileContext
&
,
types
::
&
,
const
::
&
,
description
::
*
,
<
workflow
::
>
,
,
::
&
)
override
{
auto
=
.
<
>();
<
*>
;
(
,
stringExpr
.
,
tds
,
,
);
if
(
IsDataVisualizerFactoryType
(
))
{
return
CreateDataVisualizerFactory
(
,
tds
,
,
);
}
else
if
(
(
))
{
return
(
,
tds
,
,
);
}
else
{
auto
=
->
()->
(
0
);
auto
=
returnTemplateType
;
if
(
.
==
::
)
{
auto
=
.
.
();
if
(
td
!=
nullptr
&&
td
->
(
description
::
<
>()))
{
auto
=
td
->
(
L"GetControlTemplateObject"
,
true
);
=
methodGroup
->GetMethodCount();
for
(
=
0
;
i
<
count
;
i
++)
{
auto
=
methodGroup
->GetMethod(
i
);
if
(
methodInfo
->GetParameterCount() ==
1
)
{
auto
=
methodInfo
->GetReturn();
if
(
returnType
->GetDecorator() ==
::
)
{
if
(
returnType
->GetTypeDescriptor()->CanConvertTo(
description
::
<
>()))
{
expectedTemplateType
=
returnType
;
}
}
}
}
}
}
return
(
,
tds
,
returnTemplateType
,
expectedTemplateType
,
,
);
}
}
};
class
GuiItemPropertyDeserializer
:
public
,
public
{
protected
:
<
>
;
bool
(
*
)
{
if
(
->
() ==
::
)
{
auto
=
->
();
if
(
genericType
->
() ==
::
&&
genericType
->
() ==
2
)
{
if
(
genericType
->
()->
() ==
description
::
<
>())
{
if
(
genericType
->
(
1
)->
() ==
description
::
<
>())
{
return
true
;
}
}
}
}
return
false
;
}
bool
IsWritableItemPropertyType
(
*
)
{
if
(
->
() ==
::
)
{
auto
=
->
();
if
(
genericType
->
() ==
::
&&
genericType
->
() ==
4
)
{
if
(
genericType
->
()->
() ==
description
::
<
>())
{
if
(
genericType
->
(
1
)->
() ==
description
::
<
>()
&&
genericType
->
(
3
)->
() ==
description
::
<
bool
>())
{
if
(
(
genericType
->
(
0
),
genericType
->
(
2
)))
{
return
true
;
}
}
}
}
}
return
false
;
}
public
:
GuiItemPropertyDeserializer
()
{
<
>::
();
}
bool
(
const
::
&
,
description
::
*
)
override
{
return
(
) ||
IsWritableItemPropertyType
(
);
}
description
::
*
(
const
::
&
,
description
::
*
)
override
{
return
.
();
}
<
workflow
::
>
(
GuiResourcePrecompileContext
&
,
types
::
&
,
const
::
&
,
description
::
*
,
<
workflow
::
>
,
,
::
&
)
override
{
auto
=
.
<
>();
<
>
;
{
propertyExpression
(
, {
.
},
stringExpr
.
,
,
);
if
(!
propertyExpression
)
{
return
nullptr
;
}
};
=
.
.
().
(
::
(
L"ItemType"
));
if
(
indexItemType
== -
1
)
{
auto
=
L"Precompile: env.ItemType must be specified before deserializing \""
+
stringExpr
.
+
L"\" to value of type \""
+
->
()
+
L"\"."
;
.
(
({
.
},
,
error
));
return
nullptr
;
}
<
>
;
{
const
auto
&
=
.
.
(
indexItemType
);
auto
=
values
values
.
() -
1
];
itemType
(
, {
.
},
itemTypeValue
,
itemTypeValue
,
);
if
(!
itemType
)
{
return
nullptr
;
}
};
=
.
.
().
(
::
(
L"ItemName"
));
(
L"item"
,
false
);
if
(
indexItemName
!= -
1
)
{
const
auto
&
=
.
.
(
indexItemName
);
itemName
values
values
.
() -
1
]
;
}
if
(
auto
=
propertyExpression
.
<
>())
{
if
(
refExpr
.
!=
itemName
)
{
auto
=
<
>();
refItem
.
itemName
;
auto
=
<
>();
member
refItem
;
member
.
refExpr
.
;
propertyExpression
member
;
}
}
bool
=
IsWritableItemPropertyType
(
);
auto
=
<
>();
*
=
nullptr
;
funcDecl
=
::
;
{
auto
=
->
();
funcDecl
(
genericType
->
(
0
));
{
auto
=
<
>();
argument
.
=
L"<item>"
;
argument
(
genericType
->
(
1
));
funcDecl
.
(
argument
);
}
if
(
isWritableItemProperty
)
{
{
auto
=
<
>();
argument
.
=
L"<value>"
;
argument
=
((
acceptValueType
=
genericType
->
(
2
)));
funcDecl
.
(
argument
);
}
{
auto
=
<
>();
argument
.
=
L"<update>"
;
argument
(
genericType
->
(
3
));
funcDecl
.
(
argument
);
}
}
}
auto
=
<
>();
funcDecl
funcBlock
;
{
auto
=
<
>();
refItem
.
=
L"<item>"
;
auto
=
<
>();
refCast
=
::
;
refCast
itemType
;
refCast
refItem
;
auto
=
<
>();
varDecl
.
itemName
;
varDecl
refCast
;
auto
=
<
>();
varStat
varDecl
;
funcBlock
.
(
varStat
);
}
<
>
;
{
returnStat
<
>();
returnStat
propertyExpression
;
}
if
(
isWritableItemProperty
)
{
auto
=
<
>();
funcBlock
.
(
ifStat
);
{
auto
=
<
>();
refUpdate
.
=
L"<update>"
;
ifStat
refUpdate
;
}
{
auto
=
<
>();
ifStat
block
;
{
auto
=
<
>();
refValue
.
=
L"<value>"
;
auto
=
<
>();
assignExpr
=
::
;
assignExpr
(
propertyExpression
,
true
);
if
(
acceptValueType
->
()->
() ==
::
)
{
auto
=
<
WfExpectedTypeCastExpression
>();
castExpr
=
::
;
castExpr
refValue
;
assignExpr
castExpr
;
}
else
{
assignExpr
refValue
;
}
auto
=
<
>();
stat
assignExpr
;
block
.
(
stat
);
}
{
auto
=
<
>();
block
.
(
returnStat
);
auto
=
->
()->
(
0
);
returnStat
(
returnType
);
}
}
{
auto
=
<
>();
ifStat
block
;
block
.
(
returnStat
);
}
}
else
{
funcBlock
.
(
returnStat
);
}
auto
=
<
>();
funcExpr
funcDecl
;
return
funcExpr
;
}
};
class
GuiDataProcessorDeserializer
:
public
,
public
{
protected
:
<
>
;
public
:
GuiDataProcessorDeserializer
()
{
<
>::
();
}
bool
(
const
::
&
,
description
::
*
)
override
{
return
->
() ==
description
::
<
>()
||
->
() ==
description
::
<
>();
}
description
::
*
(
const
::
&
,
description
::
*
)
override
{
return
.
();
}
<
workflow
::
>
(
GuiResourcePrecompileContext
&
,
types
::
&
,
const
::
&
,
description
::
*
,
<
workflow
::
>
,
,
::
&
)
override
{
auto
=
.
<
>();
<
>
;
{
propertyExpression
(
, {
.
},
stringExpr
.
,
,
);
if
(!
propertyExpression
)
{
return
nullptr
;
}
};
=
.
.
().
(
::
(
L"ItemType"
));
if
(
indexItemType
== -
1
)
{
auto
=
L"Precompile: env.ItemType must be specified before deserializing \""
+
stringExpr
.
+
L"\" to value of type \""
+
->
()
+
L"\"."
;
.
(
({
.
},
,
error
));
return
nullptr
;
}
<
>
;
{
const
auto
&
=
.
.
(
indexItemType
);
auto
=
values
values
.
() -
1
];
itemType
(
, {
.
},
itemTypeValue
,
itemTypeValue
,
);
if
(!
itemType
)
{
return
nullptr
;
}
};
auto
=
<
>();
newExpr
(
);
{
auto
=
<
>();
newExpr
.
(
decl
);
decl
<
>();
decl
=
::
;
decl
.
=
L"SetCallback"
;
decl
(
<
void
>::
().
());
{
auto
=
<
>();
argument
(
<
*>::
().
());
argument
.
=
L"value"
;
decl
.
(
argument
);
}
auto
=
<
>();
decl
block
;
}
{
auto
=
<
>();
newExpr
.
(
decl
);
decl
<
>();
decl
=
::
;
<
>
;
if
(
->
() ==
description
::
<
>())
{
decl
.
=
L"Filter"
;
decl
(
<
bool
>::
().
());
argumentNames
.
(
L"<row>"
);
}
else
{
decl
.
=
L"Compare"
;
decl
(
<
>::
().
());
argumentNames
.
(
L"<row1>"
);
argumentNames
.
(
L"<row2>"
);
}
FOREACH(WString, name, argumentNames)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
argumentNames
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
name
);)
{
auto
=
<
>();
argument
(
<
>::
().
());
argument
.
name
;
decl
.
(
argument
);
}
auto
=
<
>();
decl
block
;
auto
=
<
>();
inferExpr
propertyExpression
;
{
auto
=
<
>();
inferExpr
funcType
;
funcType
(
decl
);
for
(
=
0
;
i
<
decl
.
();
i
++)
{
funcType
.
(
(
itemType
));
}
}
auto
=
<
>();
callExpr
inferExpr
;
FOREACH_INDEXER(WString, name, index, argumentNames)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
argumentNames
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
name
);
index
++)
{
auto
=
<
>();
refExpr
.
name
;
auto
=
<
>();
castExpr
=
::
;
castExpr
= (
index
==
0
?
itemType
:
(
itemType
));
castExpr
refExpr
;
callExpr
.
(
castExpr
);
}
auto
=
<
>();
stat
callExpr
;
block
.
(
stat
);
}
return
newExpr
;
}
};
class
GuiPredefinedInstanceDeserializersPlugin
:
public
,
public
{
public
:
GUI_PLUGIN_NAME(GacUI_Instance_Deserializers)
vl
::
()
override
{
return
L"GacUI_Instance_Deserializers"
; }
void
(
vl
::
collections
::
<
>&
)
override
{
GUI_PLUGIN_DEPEND(GacUI_Instance);
}
void
()
override
{
IGuiInstanceLoaderManager
*
=
();
manager
->
(
new
GuiTemplatePropertyDeserializer
);
manager
->
(
new
GuiItemPropertyDeserializer
);
manager
->
(
new
GuiDataProcessorDeserializer
);
}
void
()
override
{
}
};
GUI_REGISTER_PLUGIN(GuiPredefinedInstanceDeserializersPlugin)
class
GuiRegisterPluginClass_GuiPredefinedInstanceDeserializersPlugin
{
public
:
GuiRegisterPluginClass_GuiPredefinedInstanceDeserializersPlugin
() {
vl
::
presentation
::
controls
::
()->
(
new
GuiPredefinedInstanceDeserializersPlugin
); } }
instance_GuiRegisterPluginClass_GuiPredefinedInstanceDeserializersPlugin
;
}
}