}
-func (P *Printer) DoFuncDecl(d *ast.FuncDecl) {
+func (P *Printer) funcDecl(d *ast.FuncDecl, with_body bool) {
P.Token(d.Pos_, token.FUNC);
P.separator = blank;
if recv := d.Recv; recv != nil {
}
P.Expr(d.Ident);
P.Signature(d.Sig);
- if d.Body != nil {
+ if with_body && d.Body != nil {
P.separator = blank;
P.Block(d.Body, true);
}
}
+func (P *Printer) DoFuncDecl(d *ast.FuncDecl) {
+ P.funcDecl(d, true);
+}
+
+
func (P *Printer) DoDeclList(d *ast.DeclList) {
if !*def || d.Tok == token.IMPORT || d.Tok == token.VAR {
P.Token(d.Pos, d.Tok);
}
+// ----------------------------------------------------------------------------
+// Interface
+
+func (P *Printer) Interface(p *ast.Program) {
+ for i := 0; i < len(p.Decls); i++ {
+ decl := p.Decls[i];
+ // TODO use type switch
+ if fun, is_fun := decl.(*ast.FuncDecl); is_fun {
+ P.funcDecl(fun, false);
+ }
+ }
+}
+
+
// ----------------------------------------------------------------------------
// Program
if P.html {
err := templ.Apply(text, "<!--", template.Substitution {
- "PACKAGE-->" : func() { /* P.Expr(prog.Ident); */ },
+ "PACKAGE-->" : func() { P.Printf("%s", prog.Ident.Str); },
+ "INTERFACE-->" : func() { P.Interface(prog); },
"BODY-->" : func() { P.Program(prog); },
});
if err != nil {