use of cn.bran.japid.classmeta.InnerClassMeta in project Japid by branaway.
the class InnerClassMetaTest method testPrintout.
@Test
public void testPrintout() {
InnerClassMeta icm = new InnerClassMeta("my.Display", 2, "String title, String hi", "p (\"The real title is: \"); pln(title);");
System.out.println(icm.toString());
}
use of cn.bran.japid.classmeta.InnerClassMeta in project Japid by branaway.
the class InnerClassMetaTest method testInvalidCallback.
@Test
public void testInvalidCallback() {
try {
InnerClassMeta icm = new InnerClassMeta("my.Display", 2, "hi", "p (\"The real title is: \"); pln(title);");
fail("shoud have caught it");
} catch (RuntimeException e) {
System.out.println(e);
}
}
use of cn.bran.japid.classmeta.InnerClassMeta in project Japid by branaway.
the class JapidAbstractCompiler method endRegularTag.
/**
* @param tag
*/
protected void endRegularTag(Tag tag) {
if (tag.hasBody) {
InnerClassMeta bodyInner = this.getTemplateClassMetaData().addCallTagBodyInnerClass(tag.tagName, tag.tagIndex, tag.callbackArgs, tag.getBodyText());
if (bodyInner == null)
throw new RuntimeException("compiler bug? " + tag.tagName + " not allowed to have instance of this tag");
String tagVar = tag.getTagVarName();
String tagClassName = tag.tagName;
if (tagClassName.equals("this")) {
// call itself
tagClassName = this.getTemplateClassMetaData().getClassName();
}
// String tagline = "final " + tagClassName + " " + tagVar + " = new " + tagClassName + "(getOut()); "
// + tagVar;
String tagline = "new " + tagClassName + "(" + getTemplateClassMetaData().getClassName() + ".this)";
// tagline += ".setOut(getOut()); " + tagVar;
if (tag.argsNamed()) {
tagline += ".render( " + makeLineMarker(tag.startLine) + "\n" + bodyInner.getAnonymous(makeLineMarker(tag.startLine)) + ", " + (WebUtils.asBoolean(tag.args) ? tag.args : "") + ");";
} else {
tagline += ".render(" + makeLineMarker(tag.startLine) + "\n" + (WebUtils.asBoolean(tag.args) ? tag.args + ", " : "") + bodyInner.getAnonymous(makeLineMarker(tag.startLine)) + ");";
}
// tagline += makeLineMarker(tag.startLine);
print(tagline);
} else {
// for simple tag call without call back:
this.getTemplateClassMetaData().addCallTagBodyInnerClass(tag.tagName, tag.tagIndex, null, null);
// the calling statement has been added in the regularTagInvoke()
// method
}
// is inside of a tag of own scope and retract the tag inner body class
TagInTag def = getTagInTag();
if (def != null) {
this.getTemplateClassMetaData().removeLastCallTagBodyInnerClass();
}
}
use of cn.bran.japid.classmeta.InnerClassMeta in project japid42 by branaway.
the class JapidAbstractCompiler method endRegularTag.
/**
* @param tag
*/
protected void endRegularTag(Tag tag) {
if (tag.hasBody) {
InnerClassMeta bodyInner = this.getTemplateClassMetaData().addCallTagBodyInnerClass(tag.tagName, tag.tagIndex, tag.callbackArgs, tag.getBodyText());
if (bodyInner == null)
throw new RuntimeException("compiler bug? " + tag.tagName + " not allowed to have instance of this tag");
String tagVar = tag.getTagVarName();
String tagClassName = tag.tagName;
if (tagClassName.equals("this")) {
// call itself
tagClassName = this.getTemplateClassMetaData().getClassName();
}
// String tagline = "final " + tagClassName + " " + tagVar + " = new " + tagClassName + "(getOut()); "
// + tagVar;
String tagline = "new " + tagClassName + "(" + getTemplateClassMetaData().getClassName() + ".this)";
// tagline += ".setOut(getOut()); " + tagVar;
if (tag.argsNamed()) {
tagline += ".render( " + makeLineMarker(tag.startLine) + "\n" + bodyInner.getAnonymous(makeLineMarker(tag.startLine)) + ", " + (WebUtils.asBoolean(tag.args) ? tag.args : "") + ");";
} else {
tagline += ".render(" + makeLineMarker(tag.startLine) + "\n" + (WebUtils.asBoolean(tag.args) ? tag.args + ", " : "") + bodyInner.getAnonymous(makeLineMarker(tag.startLine)) + ");";
}
// tagline += makeLineMarker(tag.startLine);
print(tagline);
} else {
// for simple tag call without call back:
this.getTemplateClassMetaData().addCallTagBodyInnerClass(tag.tagName, tag.tagIndex, null, null);
// the calling statement has been added in the regularTagInvoke()
// method
}
// is inside of a tag of own scope and retract the tag inner body class
TagInTag def = getTagInTag();
if (def != null) {
this.getTemplateClassMetaData().removeLastCallTagBodyInnerClass();
}
}
Aggregations