#include "GuiInstanceRepresentation.h"
#include "GuiInstanceLoader.h"
#include "InstanceQuery/GuiInstanceQuery.h"
#include "../Resources/GuiParserManager.h"
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
parsing
;
using
namespace
parsing
::
xml
;
using
namespace
templates
;
using
namespace
stream
;
void
::
(
<
>
)
{
=
;
;
}
<
>
::
()
{
auto
=
<
>();
::
(
repr
);
repr
;
return
repr
;
}
void
::
(
<
parsing
::
xml
::
>
)
{
if
(!
)
{
auto
=
<
>();
xmlText
.
;
.
(
xmlText
);
}
}
void
::
(
<
>
)
{
::
(
);
FOREACH_INDEXER(GlobalStringKey, name, index, setters.Keys())
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__
.
(
name
);
index
++)
{
auto
=
.
()
index
];
auto
=
<
>();
dst
src
;
dst
src
;
FOREACH(Ptr<GuiValueRepr>, value, src->values)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
src
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
value
);)
{
dst
.
(
value
());
}
.
(
name
,
dst
);
}
FOREACH_INDEXER(GlobalStringKey, name, index, eventHandlers.Keys())
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__
.
(
name
);
index
++)
{
auto
=
.
()
index
];
auto
=
<
>();
dst
src
;
dst
src
;
dst
=
src
;
dst
src
;
dst
src
;
.
(
name
,
dst
);
}
FOREACH_INDEXER(GlobalStringKey, name, index, environmentVariables.Keys())
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__
.
(
name
);
index
++)
{
auto
=
.
()
index
];
auto
=
<
>();
dst
src
;
dst
=
src
;
dst
src
;
dst
src
;
.
(
name
,
dst
);
}
;
}
<
>
::
()
{
auto
=
<
>();
::
(
repr
);
repr
=
;
return
repr
;
}
void
::
(
<
parsing
::
xml
::
>
)
{
if
(!
)
{
if
(
!=
::
)
{
auto
=
<
>();
attName
.
=
L"ref.Name"
;
attName
.
.
();
.
(
attName
);
}
for
(
=
0
;
i
<
.
();
i
++)
{
auto
=
.
()
i
];
auto
=
.
()
i
];
if
(
key
==
::
)
{
FOREACH(Ptr<GuiValueRepr>, repr, value->values)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
value
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
repr
);)
{
repr
(
);
}
}
else
if
(
(
value
).Any([](
<
>
) {
return
!
value
; }))
{
bool
=
(
value
)
.Any([](
<
>
)
{
return
!
value
&& !
value
.
<
>();
});
if
(
containsElement
)
{
auto
=
<
>();
xmlProp
.
=
L"att."
+
key
.
();
if
(
value
!=
::
)
{
xmlProp
.
+=
L"-"
+
value
.
();
}
FOREACH(Ptr<GuiValueRepr>, repr, value->values)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
value
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
repr
);)
{
if
(!
repr
.
<
>())
{
repr
(
xmlProp
);
}
}
.
(
xmlProp
);
}
else
{
FOREACH(Ptr<GuiValueRepr>, repr, value->values)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
value
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
repr
);)
{
if
(
auto
=
repr
.
<
>())
{
if
(!
textRepr
)
{
auto
=
<
>();
att
.
key
.
();
if
(
value
!=
::
)
{
att
.
+=
L"-"
+
value
.
();
}
att
.
textRepr
text
;
.
(
att
);
break
;
}
}
}
}
}
}
for
(
=
0
;
i
<
.
();
i
++)
{
auto
=
.
()
i
];
auto
=
.
()
i
];
if
(!
value
)
{
auto
=
<
>();
xmlEvent
.
=
L"ev."
+
key
.
();
if
(
value
!=
::
)
{
xmlEvent
.
+=
L"-"
+
value
.
();
}
.
(
xmlEvent
);
auto
=
<
>();
xmlText
.
value
;
xmlEvent
.
(
xmlText
);
}
}
for
(
=
0
;
i
<
.
();
i
++)
{
auto
=
.
()
i
];
auto
=
.
()
i
];
if
(!
value
)
{
auto
=
<
>();
xmlEnvVar
.
=
L"env."
+
key
.
();
.
(
xmlEnvVar
);
auto
=
<
>();
xmlText
.
value
;
xmlEnvVar
.
(
xmlText
);
}
}
}
}
<
>
::
()
{
auto
=
<
>();
::
(
repr
);
repr
=
;
repr
;
repr
;
repr
;
return
repr
;
}
void
::
(
<
parsing
::
xml
::
>
)
{
if
(!
)
{
auto
=
<
>();
if
(
==
::
)
{
xmlCtor
.
.
();
}
else
{
xmlCtor
.
=
.
() +
L":"
+
.
();
}
if
(
)
{
auto
=
<
>();
attStyle
.
=
L"ref.Style"
;
attStyle
.
.
();
.
(
attStyle
);
}
::
(
xmlCtor
);
.
(
xmlCtor
);
}
}
void
::
(
<
>
,
::
&
,
<
parsing
::
xml
::
>
,
::
&
)
{
if
(
auto
=
()->
<
>(
L"INSTANCE-ELEMENT-NAME"
))
{
if
(
.
() ==
1
)
{
if
(
<
>
=
0
].
<
>())
{
<
>
=
new
;
value
text
.
;
value
{ {
},
text
.
.
};
.
(
value
);
}
else
if
(
<
>
=
0
].
<
>())
{
<
>
=
new
;
value
text
.
;
value
{ {
},
text
.
.
};
value
.
+=
9
;
.
(
value
);
}
}
FOREACH(Ptr<XmlElement>, element, XmlGetElements(xml))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
(
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
element
);)
{
if
(
auto
=
parser
->Parse({
},
element
.
,
element
.
,
))
{
if
(
name
->IsCtorName())
{
auto
=
(
,
element
,
);
if
(
ctor
)
{
.
(
ctor
);
}
}
else
if
(!
name
->IsPropertyElementName() && !
name
->IsEventElementName())
{
.
(
({ {
},
element
.
},
L"Unknown element name: \""
+
element
.
+
L"\"."
));
}
}
}
}
}
void
::
(
<
>
,
::
&
,
<
parsing
::
xml
::
>
,
::
&
)
{
if
(
auto
=
()->
<
>(
L"INSTANCE-ELEMENT-NAME"
))
{
<
::
>
=
new
::
;
(
,
defaultValue
,
,
);
if
(
defaultValue
.
() >
0
)
{
.
(
::
,
defaultValue
);
}
FOREACH(Ptr<XmlElement>, element, XmlGetElements(xml))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
(
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
element
);)
{
if
(
auto
=
parser
->Parse({
},
element
.
,
element
.
.
,
))
{
if
(
name
->IsPropertyElementName())
{
if
(
.
().
(
::
(
name
->name)))
{
.
(
({ {
},
element
.
},
L"Duplicated property \""
+
name
->name +
L"\"."
));
}
else
{
<
::
>
=
new
::
;
sv
=
::
(
name
->binding);
sv
{ {
},
element
.
};
if
(
name
->binding ==
L"set"
)
{
<
>
=
new
;
(
,
setter
,
element
,
);
sv
.
(
setter
);
}
else
{
(
,
sv
,
element
,
);
}
if
(
sv
.
() >
0
)
{
.
(
::
(
name
->name),
sv
);
}
}
}
}
}
}
}
void
::
(
<
>
,
::
&
,
<
parsing
::
xml
::
>
,
::
&
)
{
if
(
auto
=
()->
<
>(
L"INSTANCE-ELEMENT-NAME"
))
{
FOREACH(Ptr<XmlElement>, element, XmlGetElements(xml))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
(
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
element
);)
{
if
(
auto
=
parser
->Parse({
},
element
.
,
element
.
.
,
))
{
if
(
name
->IsEventElementName())
{
if
(
.
().
(
::
(
name
->name)))
{
.
(
({ {
},
element
.
},
L"Duplicated event \""
+
name
->name +
L"\"."
));
}
else
{
if
(
element
.
() ==
1
)
{
if
(
<
>
=
element
0
].
<
>())
{
auto
=
<
::
>();
value
=
::
(
name
->binding);
value
text
.
;
value
{ {
},
element
.
};
value
{ {
},
text
.
.
};
.
(
::
(
name
->name),
value
);
if
(
text
.
.
.
!=
text
.
.
.
)
{
.
(
({ {
},
element
.
},
L"Multiple lines script should be contained in a CDATA section."
));
}
goto
EVENT_SUCCESS;
}
else
if
(
<
>
=
element
0
].
<
>())
{
auto
=
<
::
>();
value
=
::
(
name
->binding);
value
text
.
;
value
{ {
},
element
.
};
value
{ {
},
text
.
.
};
value
.
+=
9
;
.
(
::
(
name
->name),
value
);
}
goto
EVENT_SUCCESS;
}
.
(
({ {
},
element
.
},
L"Event script should be contained in a text or CDATA section."
));
EVENT_SUCCESS:;
}
}
}
}
}
}
void
::
(
<
>
,
<
>
,
<
parsing
::
xml
::
>
,
::
&
)
{
if
(
auto
=
()->
<
>(
L"INSTANCE-ELEMENT-NAME"
))
{
{ {
},
.
};
FOREACH(Ptr<XmlAttribute>, att, xml->attributes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
att
);)
{
if
(
auto
=
parser
->Parse({
},
att
.
,
att
.
.
,
))
{
if
(
name
->IsReferenceAttributeName())
{
if
(
name
->name ==
L"Name"
)
{
::
(
att
.
);
}
}
else
if
(
name
->IsEnvironmentAttributeName())
{
if
(
.
().
(
::
(
name
->name)))
{
.
(
({ {
},
att
.
.
},
L"Duplicated environment variable \""
+
name
->name +
L"\"."
));
}
else
{
auto
=
<
::
>();
value
att
.
;
value
{ {
},
att
.
};
value
{ {
},
att
.
.
};
value
.
+=
1
;
.
(
::
(
name
->name),
value
);
}
}
else
if
(
name
->IsPropertyAttributeName())
{
if
(
.
().
(
::
(
name
->name)))
{
.
(
({ {
},
att
.
.
},
L"Duplicated property \""
+
name
->name +
L"\"."
));
}
else
{
auto
=
<
::
>();
sv
=
::
(
name
->binding);
sv
{ {
},
att
.
};
.
(
::
(
name
->name),
sv
);
<
>
=
new
;
value
text
att
.
;
value
{ {
},
att
.
.
};
value
.
+=
1
;
sv
.
(
value
);
}
}
else
if
(
name
->IsEventAttributeName())
{
if
(
.
().
(
::
(
name
->name)))
{
.
(
({ {
},
att
.
.
},
L"Duplicated event \""
+
name
->name +
L"\"."
));
}
else
{
auto
=
<
::
>();
value
=
::
(
name
->binding);
value
att
.
;
value
{ {
},
att
.
};
value
{ {
},
att
.
.
};
value
.
+=
1
;
.
(
::
(
name
->name),
value
);
}
}
else
{
.
(
({ {
},
att
.
.
},
L"Unknown attribute name: \""
+
att
.
+
L"\"."
));
}
}
}
(
,
,
,
);
(
,
,
,
);
}
}
<
>
::
(
<
>
,
<
parsing
::
xml
::
>
,
::
&
)
{
if
(
auto
=
()->
<
>(
L"INSTANCE-ELEMENT-NAME"
))
{
if
(
auto
=
parser
->Parse({
},
.
,
.
.
,
))
{
if
(
ctorName
->IsCtorName())
{
<
>
=
new
;
ctor
=
::
(
ctorName
->namespaceName);
ctor
=
::
(
ctorName
->name);
FOREACH(Ptr<XmlAttribute>, att, xml->attributes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
att
);)
{
if
(
auto
=
parser
->Parse({
},
att
.
,
att
.
.
,
))
{
if
(
attName
->IsReferenceAttributeName())
{
if
(
attName
->name ==
L"Style"
)
{
ctor
att
.
;
}
}
}
}
(
,
ctor
,
,
);
return
ctor
;
}
else
{
.
(
({ {
},
.
},
L"Wrong constructor name \""
+
.
+
L"\"."
));
}
}
}
return
0
;
}
<
>
::
(
<
>
,
<
parsing
::
xml
::
>
,
::
&
)
{
<
>
=
new
;
context
{ {
},
.
};
if
(
.
==
L"Instance"
)
{
if
(
auto
=
(
,
L"ref.CodeBehind"
))
{
context
=
codeBehindAttr
->value.value ==
L"true"
;
}
if
(
auto
=
(
,
L"ref.Class"
))
{
context
=
classAttr
->value.value;
context
= { {
},
classAttr
->codeRange.start };
}
if
(
auto
=
(
,
L"ref.Styles"
))
{
(
styleAttr
->value.value,
context
);
context
= { {
},
styleAttr
->codeRange.start };
}
<
<
>>
;
(
namespaceAttributes
,
);
if
(!
(
,
L"xmlns"
))
{
<
>
=
new
;
att
.
=
L"xmlns"
;
att
.
=
L"presentation::controls::Gui*;"
L"presentation::elements::Gui*Element;"
L"presentation::compositions::Gui*Composition;"
L"presentation::compositions::Gui*;"
L"presentation::templates::Gui*;"
L"system::*;"
L"system::reflection::*;"
L"presentation::*;"
L"presentation::Gui*;"
L"presentation::controls::*;"
L"presentation::controls::list::*;"
L"presentation::controls::tree::*;"
L"presentation::elements::*;"
L"presentation::elements::Gui*;"
L"presentation::elements::text::*;"
L"presentation::compositions::*;"
L"presentation::templates::*;"
L"presentation::theme::*"
;
namespaceAttributes
.
(
att
);
}
FOREACH(Ptr<XmlAttribute>, att, namespaceAttributes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
namespaceAttributes
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
att
);)
{
=
att
.
;
if
(
attName
.
() >=
5
&&
attName
.
(
5
) ==
L"xmlns"
)
{
;
if
(
attName
.
() >
6
)
{
if
(
attName
.
(
6
) ==
L"xmlns:"
)
{
ns
::
(
attName
.
(
6
,
attName
.
() -
6
));
}
else
{
continue
;
}
}
<
>
;
=
context
.
().
(
ns
);
if
(
index
== -
1
)
{
info
new
;
info
ns
;
info
{ {
},
att
.
};
context
.
(
ns
,
info
);
}
else
{
info
context
.
()
index
];
}
<
>
;
(
att
.
,
patterns
);
FOREACH(WString, pattern, patterns)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
patterns
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
pattern
);)
{
<
>
=
new
;
Pair<vint, vint> star = INVLOC.FindFirst(pattern, L"*", Locale::None);
<
,
>
=
vl
::
::
().
(
pattern
,
L"*"
,
::
);
if
(
star
.
== -
1
)
{
ns
pattern
;
}
else
{
ns
pattern
.
(
0
,
star
.
);
ns
pattern
.
(
star
.
+
star
.
,
pattern
.
() -
star
.
-
star
.
);
}
info
.
(
ns
);
}
}
}
FOREACH(Ptr<XmlElement>, element, XmlGetElements(xml->rootElement))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
(
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
element
);)
{
if
(
element
.
==
L"ref.Parameter"
)
{
auto
=
(
element
,
L"Name"
);
auto
=
(
element
,
L"Class"
);
if
(
attName
&&
attClass
)
{
auto
=
<
>();
parameter
=
::
(
attName
->value.value);
parameter
=
::
(
attClass
->value.value);
parameter
{ {
},
element
.
};
parameter
= { {
},
attClass
->value.codeRange.start };
parameter
.
+=
1
;
context
.
(
parameter
);
}
else
{
.
(
({ {
},
element
.
},
L"ref.Parameter requires the following attributes existing at the same time: Name, Class."
));
}
}
else
if
(
element
.
==
L"ref.LocalizedStrings"
)
{
auto
=
(
element
,
L"Name"
);
auto
=
(
element
,
L"Class"
);
auto
=
(
element
,
L"Default"
);
if
(
attName
&&
attClass
)
{
auto
=
<
>();
localized
=
::
(
attName
->value.value);
localized
=
::
(
attClass
->value.value);
localized
{ {
},
element
.
};
localized
= { {
},
attClass
->value.codeRange.start };
localized
.
+=
1
;
if
(
attDefault
)
{
localized
=
attDefault
->value.value ==
L"true"
;
}
context
.
(
localized
);
}
else
{
.
(
({ {
},
element
.
},
L"ref.LocalizedStrings requires the following attributes existing at the same time: Name, Class."
));
}
}
#define COLLECT_SCRIPT(NAME, SCRIPT, POSITION)\
(element->name.value == L"ref." #NAME)\
{\
if (element->subNodes.Count() == 1)\
{\
if (auto cdata = element->subNodes[0].Cast<XmlCData>())\
{\
context->SCRIPT = cdata->content.value;\
context->POSITION = { {resource},cdata->codeRange.start };\
context->POSITION.column += 9; /* <![CDATA[ */\
goto NAME##_SCRIPT_SUCCESS;\
}\
}\
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"Script should be contained in a CDATA section."));\
NAME##_SCRIPT_SUCCESS:;\
}\
else if COLLECT_SCRIPT(Members, memberScript, memberPosition)
else
if
(
element
.
==
L"ref."
"Members"
) {
if
(
element
.
() ==
1
) {
if
(
auto
=
element
0
].
<
>()) {
context
cdata
.
;
context
{ {
},
cdata
.
};
context
.
+=
9
;
goto
Members_SCRIPT_SUCCESS; } }
.
(
({ {
},
element
.
},
L"Script should be contained in a CDATA section."
)); Members_SCRIPT_SUCCESS:; }
else if COLLECT_SCRIPT(Ctor, ctorScript, ctorPosition)
else
if
(
element
.
==
L"ref."
"Ctor"
) {
if
(
element
.
() ==
1
) {
if
(
auto
=
element
0
].
<
>()) {
context
cdata
.
;
context
{ {
},
cdata
.
};
context
.
+=
9
;
goto
Ctor_SCRIPT_SUCCESS; } }
.
(
({ {
},
element
.
},
L"Script should be contained in a CDATA section."
)); Ctor_SCRIPT_SUCCESS:; }
else if COLLECT_SCRIPT(Dtor, dtorScript, dtorPosition)
else
if
(
element
.
==
L"ref."
"Dtor"
) {
if
(
element
.
() ==
1
) {
if
(
auto
=
element
0
].
<
>()) {
context
cdata
.
;
context
{ {
},
cdata
.
};
context
.
+=
9
;
goto
Dtor_SCRIPT_SUCCESS; } }
.
(
({ {
},
element
.
},
L"Script should be contained in a CDATA section."
)); Dtor_SCRIPT_SUCCESS:; }
#undef COLLECT_SCRIPT
else
if
(!
context
)
{
context
(
,
element
,
);
}
}
}
else
{
.
(
({ {
},
.
},
L"The root element of instance should be \"Instance\"."
));
}
return
context
?
context
:
nullptr
;
}
<
parsing
::
xml
::
>
::
()
{
auto
=
<
>();
xmlInstance
.
=
L"Instance"
;
{
auto
=
<
>();
attCodeBehind
.
=
L"ref.CodeBehind"
;
attCodeBehind
.
=
?
L"true"
:
L"false"
;
xmlInstance
.
(
attCodeBehind
);
}
auto
=
<
>();
attClass
.
=
L"ref.Class"
;
attClass
.
;
xmlInstance
.
(
attClass
);
for
(
=
0
;
i
<
.
();
i
++)
{
auto
=
.
()
i
];
auto
=
.
()
i
];
auto
=
<
>();
xmlns
.
=
L"xmlns"
;
if
(
key
!=
::
)
{
xmlns
.
+=
L":"
+
key
.
();
}
xmlInstance
.
(
xmlns
);
for
(
=
0
;
j
<
value
.
();
j
++)
{
auto
=
value
j
];
if
(
j
!=
0
)
{
xmlns
.
+=
L";"
;
}
xmlns
.
+=
ns
+
L"*"
+
ns
;
}
}
FOREACH(Ptr<GuiInstanceParameter>, parameter, parameters)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
parameter
);)
{
auto
=
<
>();
xmlParameter
.
=
L"ref.Parameter"
;
xmlInstance
.
(
xmlParameter
);
auto
=
<
>();
attName
.
=
L"Name"
;
attName
.
parameter
.
();
xmlParameter
.
(
attName
);
auto
=
<
>();
attClass
.
=
L"Class"
;
attClass
.
parameter
.
();
xmlParameter
.
(
attClass
);
}
FOREACH(Ptr<GuiInstanceLocalized>, localized, localizeds)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
localized
);)
{
auto
=
<
>();
xmlParameter
.
=
L"ref.LocalizedStrings"
;
xmlInstance
.
(
xmlParameter
);
auto
=
<
>();
attName
.
=
L"Name"
;
attName
.
localized
.
();
xmlParameter
.
(
attName
);
auto
=
<
>();
attClass
.
=
L"Class"
;
attClass
.
localized
.
();
xmlParameter
.
(
attClass
);
auto
=
<
>();
attDefault
.
=
L"Default"
;
attDefault
.
=
localized
?
L"true"
:
L"false"
;
xmlParameter
.
(
attDefault
);
}
#define SERIALIZE_SCRIPT(NAME, SCRIPT)\
if (SCRIPT != L"")\
{\
auto xmlScript = MakePtr<XmlElement>();\
xmlScript->name.value = L"ref." #NAME;\
xmlInstance->subNodes.Add(xmlScript);\
auto text = MakePtr<XmlCData>();\
text->content.value = SCRIPT;\
xmlScript->subNodes.Add(text);\
}\
SERIALIZE_SCRIPT(Members, memberScript)
if
(
!=
L""
) {
auto
=
<
>();
xmlScript
.
=
L"ref."
"Members"
;
xmlInstance
.
(
xmlScript
);
auto
=
<
>();
text
.
;
xmlScript
.
(
text
); }
SERIALIZE_SCRIPT(Ctpr, ctorScript)
if
(
!=
L""
) {
auto
=
<
>();
xmlScript
.
=
L"ref."
"Ctpr"
;
xmlInstance
.
(
xmlScript
);
auto
=
<
>();
text
.
;
xmlScript
.
(
text
); }
SERIALIZE_SCRIPT(Dtor, dtorScript)
if
(
!=
L""
) {
auto
=
<
>();
xmlScript
.
=
L"ref."
"Dtor"
;
xmlInstance
.
(
xmlScript
);
auto
=
<
>();
text
.
;
xmlScript
.
(
text
); }
#undef SERIALIZE_SCRIPT
if
(
.
() >
0
)
{
auto
=
<
>();
attStyles
.
=
L"ref.Styles"
;
xmlInstance
.
(
attStyles
);
for
(
=
0
;
j
<
.
();
j
++)
{
if
(
j
!=
0
)
{
attStyles
.
+=
L";"
;
}
attStyles
.
j
];
}
}
(
xmlInstance
);
auto
=
<
>();
doc
xmlInstance
;
return
doc
;
}
bool
::
(
<
>
,
<
>
,
::
&
)
{
if
(!
)
{
=
true
;
<
<
>>
;
FOREACH(WString, uri, stylePaths)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
uri
);)
{
,
;
if
(
(
uri
,
protocol
,
path
))
{
if
(
auto
=
(
protocol
,
path
).
<
>())
{
(
styles
,
styleContext
,
true
);
}
else
{
.
(
({
},
,
L"Failed to find the style referred in attribute \"ref.Styles\": \""
+
uri
+
L"\"."
));
}
}
else
{
.
(
({
},
,
L"Invalid path in attribute \"ref.Styles\": \""
+
uri
+
L"\"."
));
}
}
FOREACH(Ptr<GuiInstanceStyle>, style, styles)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
styles
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
style
);)
{
<
<
>>
;
(
style
,
this
,
output
);
FOREACH(Ptr<GuiConstructorRepr>, ctor, output)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
output
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
ctor
);)
{
(
style
,
ctor
);
}
}
return
true
;
}
else
{
return
false
;
}
}
namespace
{
class
:
public
,
public
::
{
public
:
void
(
*
)
override
{
->
=
true
;
}
void
(
*
)
override
{
->
=
true
;
FOREACH(Ptr<GuiAttSetterRepr::SetterValue>, value, repr->setters.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
::
>>&
= ::
vl
::
collections
::
(
->
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
::
>
;
__foreach_iterator__
.
(
value
);)
{
FOREACH(Ptr<GuiValueRepr>, subValue, value->values)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
value
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
subValue
);)
{
subValue
(
this
);
}
}
FOREACH(Ptr<GuiAttSetterRepr::EventValue>, value, repr->eventHandlers.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
::
>>&
= ::
vl
::
collections
::
(
->
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
::
>
;
__foreach_iterator__
.
(
value
);)
{
value
=
true
;
}
FOREACH(Ptr<GuiAttSetterRepr::EnvVarValue>, value, repr->environmentVariables.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
::
>>&
= ::
vl
::
collections
::
(
->
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
::
>
;
__foreach_iterator__
.
(
value
);)
{
value
=
true
;
}
}
void
(
*
)
override
{
((
*)
);
}
};
}
using
namespace
visitors
;
<
>
::
(
<
>
,
<
parsing
::
xml
::
>
,
::
&
)
{
auto
=
<
>();
if
(
auto
=
(
,
L"ref.Path"
))
{
auto
=
pathAttr
->value.codeRange.start;
position
.column +=
1
;
auto
=
()->
<
>(
L"INSTANCE-QUERY"
);
auto
=
parser
->Parse({
},
pathAttr
->value.value,
position
,
);
if
(!
query
)
return
nullptr
;
style
=
query
;
}
else
{
.
(
({ {
},
.
},
L"Missing attribute \"ref.Path\" in <Style>."
));
}
style
<
>();
::
(
,
style
,
,
);
;
style
(&
visitor
);
return
style
;
}
<
parsing
::
xml
::
>
::
()
{
auto
=
<
>();
xmlStyle
.
=
L"Style"
;
auto
=
<
>();
attPath
.
=
L"ref.Path"
;
attPath
.
([&](
&
)
{
(
,
writer
);
});
xmlStyle
.
(
attPath
);
(
xmlStyle
);
return
xmlStyle
;
}
<
>
::
(
<
>
,
<
parsing
::
xml
::
>
,
::
&
)
{
auto
=
<
>();
if
(
.
==
L"Styles"
)
{
FOREACH(Ptr<XmlElement>, styleElement, XmlGetElements(xml->rootElement))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
(
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
styleElement
);)
{
if
(
styleElement
.
==
L"Style"
)
{
if
(
auto
=
::
(
,
styleElement
,
))
{
context
.
(
style
);
}
}
else
{
.
(
({ {
},
styleElement
.
},
L"Unknown element in <Styles>: \""
+
styleElement
.
+
L"\"."
));
}
}
}
else
{
.
(
({ {
},
.
},
L"The root element of instance styles should be \"Styles\"."
));
}
return
context
;
}
<
parsing
::
xml
::
>
::
()
{
auto
=
<
>();
xmlStyles
.
=
L"Styles"
;
FOREACH(Ptr<GuiInstanceStyle>, style, styles)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
style
);)
{
xmlStyles
.
(
style
());
}
auto
=
<
>();
doc
xmlStyles
;
return
doc
;
}
}
}