Monday, 6 June 2011

XMF Source Code

The source code of XMF is now available for browsing via my home page. Look under XMF -> Source Code where there are two browser trees labelled com.ceteva.xmf.machine and com.ceteva.xmf.system. The first contains the source code of the XMF VM (in Java) and the second contains the source code of XMF (in XMF under xmf-src). Note that the Java source viewer will only work when navigating from a file within the source tree due to browser security issues.

The browser trees were created by running the following XMF code over a root directory:
context Root
 @Operation list(out,root,prefix,indent)
  let path = root + "/" + prefix then
      dir = Directory(path,Seq{".*xmf",".*java",".*txt"})
  in dir.build(1);
     format(out,"~V<li><a href='#'>~S</a>~%",Seq{indent,dir.name.splitBy("/",0,0)->last});
     format(out,"~V<ul>~%",Seq{indent+2});
     @For x in dir.contents() do
      let name = x.name.splitBy("/",0,0)->last
      in if not Set{".svn","META-INF"}->includes(name)
         then
          if x.isKindOf(Directory)
          then list(out,root,prefix + "/" + name ,indent+2)
          else 
           if name.hasSuffix("java")
           then format(out,"~V<li class='item'><a onclick='display_java('~S');'>~S</a></li>~%",Seq{indent+2,prefix+"/"+name,name})
           else
            format(out,"~V<li class='item'><a href='~S' target='FILES'>~S</a></li>~%",Seq{indent+2,prefix+"/"+name,name})
           end
          end
         end
     end
    end;
    format(out,"~V</ul>~%~V</li>~%",Seq{indent+2,indent})    
  end
 end

No comments:

Post a Comment