outputBindingInfoAsData(cname, bd);
}
private void outputBindingInfoAsData(String cname, BindingDatabase bindingDataBase)
{
IASEmitter asEmitter = ((IMXMLBlockWalker) getMXMLWalker())
.getASEmitter();
writeNewline("/**");
writeNewline(" * @expose");
writeNewline(" */");
writeNewline(cname
+ ".prototype._bindings = [");
Set<BindingInfo> bindingInfo = bindingDataBase.getBindingInfo();
writeNewline(bindingInfo.size() + ","); // number of bindings
for (BindingInfo bi : bindingInfo)
{
String s;
s = bi.getSourceString();
if (s == null)
s = getSourceStringFromGetter(bi.getExpressionNodesForGetter());
if (s.contains("."))
{
String[] parts = s.split("\\.");
write(ASEmitterTokens.SQUARE_OPEN.getToken() + ASEmitterTokens.DOUBLE_QUOTE.getToken() +
parts[0] + ASEmitterTokens.DOUBLE_QUOTE.getToken());
int n = parts.length;
for (int i = 1; i < n; i++)
{
String part = parts[i];
write(", " + ASEmitterTokens.DOUBLE_QUOTE.getToken() + part + ASEmitterTokens.DOUBLE_QUOTE.getToken());
}
writeNewline(ASEmitterTokens.SQUARE_CLOSE.getToken() + ASEmitterTokens.COMMA.getToken());
}
else if (s == null || s.length() == 0)
{
List<IExpressionNode> getterNodes = bi.getExpressionNodesForGetter();
StringBuilder sb = new StringBuilder();
sb.append("function() { return ");
for (IExpressionNode getterNode : getterNodes)
{
sb.append(asEmitter.stringifyNode(getterNode));
}
sb.append("; },");
writeNewline(sb.toString());
}
else
writeNewline(ASEmitterTokens.DOUBLE_QUOTE.getToken() + s +
ASEmitterTokens.DOUBLE_QUOTE.getToken() + ASEmitterTokens.COMMA.getToken());
IExpressionNode destNode = bi.getExpressionNodeForDestination();
if (destNode != null)
{
StringBuilder sb = new StringBuilder();
sb.append(asEmitter.stringifyNode(destNode));
writeNewline(sb.toString());
}
else
writeNewline(ASEmitterTokens.NULL.getToken() + ASEmitterTokens.COMMA.getToken());