示例#1
0
    public static int Main(string[] argv)
    {
        Hdf h = new Hdf();

          h.setValue("foo.1","1");
          h.setValue("foo.2","2");

          h.registerFileLoad(new Hdf.loadFileDelegate(loadFileHandler));

          h.readFile("test.hdf");

          Console.WriteLine("foo.2 = {0}", h.getValue("foo.2","def"));

          CSTContext cs = new CSTContext(h);

          Console.WriteLine("parsing file");
          h.setValue("hdf.loadpaths.0", ".");
          cs.registerFileLoad(new CSTContext.loadFileDelegate(loadFileHandler));
          try {
          cs.parseFile("test.cst");
          } catch (NeoException e) {
          Console.WriteLine("error: {0}", e.reason);
          Console.WriteLine("tb: {0}", e.full_traceback);
          }

          // cs.parseString(" foo.1 = <?cs var:foo.1 ?> ");
          // cs.parseString("this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ this is a big tesT............ .");

          Console.WriteLine("render file");
          Console.WriteLine(cs.render());
          return 0;
    }
示例#2
0
文件: CS.cs 项目: jeske/StepsDB-alpha
 public unsafe CSTContext(Hdf hdf)
 {
     fixed (CSPARSE **csp_ptr = &csp) {
        cs_init(csp_ptr, hdf.hdf_root);
      }
      // Console.WriteLine("CSt.Cst() hdf_root = {0}", (int)hdf.hdf_root);
 }
示例#3
0
   public static unsafe int Main(string[] argv) {
      Hdf h = new Hdf();

      h.setValue("foo.1","1");
      h.setValue("foo.2","2");
      Console.WriteLine("foo.2 = {0}", h.getValue("foo.2","def"));

      CSTContext cs = new CSTContext(h);
//      cs.parseFile("test.cst");
      Console.WriteLine(cs.render());
      
      return 0;
   }
示例#4
0
   public static unsafe int Main(string[] argv) {
      Console.WriteLine("C# Clearsilver wrapper performance test");
      Hdf h = new Hdf();

      h.setValue("foo.1","1");
      h.setValue("foo.2","2");

      int call_count = 100000;
      int start = Environment.TickCount;
      for (int i=0;i<call_count;i++) {
         h.setValue(String.Format("foo.{0}",i),"5");
      }
      int end = Environment.TickCount;

      Console.WriteLine("call count = {0}, time = {1} ms - time per call {2} ns", 
           call_count, end-start, (((float)end-start)/call_count) * 1000);
      

      CSTContext cs = new CSTContext(h);
//      cs.parseFile("test.cst");
      Console.WriteLine(cs.render());
      
      return 0;
   }
示例#5
0
文件: CS.cs 项目: blong42/clearsilver
 unsafe public CSTContext(Hdf hdf) {
   fixed (CSPARSE **csp_ptr = &csp) {
     cs_init(csp_ptr, hdf.hdf_root);
   }
 } 
示例#6
0
文件: CS.cs 项目: jeske/Clearsilver
 unsafe CSFILELOAD thunk_delegate;  // we have to hold onto the delegate to make sure the pinned thunk sticks around
 private unsafe NEOERR* csFileLoad(void* ctx, HDF* raw_hdf, STR* pFilename, STR** contents) {
     // Console.WriteLine("csFileLoad delegate called");
     IntPtr buf = IntPtr.Zero;
     try {
         Hdf hdf = new Hdf(raw_hdf);
         string filename = Marshal.PtrToStringAnsi((IntPtr)pFilename);
         byte[] data = cur_delegate(hdf, filename);
         byte[] end_null = new byte[] { 0 };               
         buf = NeoUtil.neo_malloc(data.Length + 1); // +1 so we can null terminate
         Marshal.Copy(data, 0, buf, data.Length);
         Marshal.Copy(end_null, 0, (IntPtr)((uint)buf + data.Length), 1); // write the end_null
         *contents = (STR*)buf;
     } catch (Exception e) {
         // Console.WriteLine("csFileLoad Thunk Exception + " + e);
         // should return a neo error
         if (buf != IntPtr.Zero) {
             NeoUtil.neo_free(buf);                   
         }
         return NeoErr.nERR(e.ToString());
     } 
     return (NEOERR*) IntPtr.Zero;
 }
示例#7
0
 public static byte[] loadFileHandler(Hdf hdf, string fname)
 {
     Console.WriteLine("my load file handler for: " + fname);
        return File.ReadAllBytes(fname);
 }