Show
Ignore:
Timestamp:
04/09/2008 22:32:36 (8 months ago)
Author:
stepheneb
Message:

ragel 6.1 fixes for hpricot_scan.java.rl; update jruby object access

Applied the updates to the ragel code for 6.1 to hpricot_scan.java.rl.

Updated decrated method used to access IRubyObject object:

new IRubyObject[]{runtime.newSymbol("buffer_size")}

becomes:

runtime.getCurrentContext(),new IRubyObject[]{runtime.newSymbol("buffer_size")}

The include statements in the main ragel code didn't
work with paths starting with ext/ so I made them
into relative path references which did work.

Updates to the Rakefile to support easy
compilation of the C ragel source code
using different ragel compilation strategies.
This is the default setting:

DEFAULT_RAGEL_C_CODE_GENERATION = "really_fast goto_driven"

which is -G2

The result is no test failures in C and only
one in Java: test_latin1_entities.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ext/hpricot_scan/hpricot_scan.java.rl

    r163 r164  
    2121 
    2222       public void ELE(IRubyObject N) { 
    23          if (tokend > tokstart || text) { 
     23         if (te > ts || text) { 
    2424           IRubyObject raw_string = runtime.getNil(); 
    2525           ele_open = false; text = false; 
    26            if (tokstart != -1 && N != cdata && N != sym_text && N != procins && N != comment) {  
    27              raw_string = runtime.newString(new String(buf,tokstart,tokend-tokstart)); 
     26           if (ts != -1 && N != cdata && N != sym_text && N != procins && N != comment) {  
     27             raw_string = runtime.newString(new String(buf,ts,te-ts)); 
    2828           }  
    2929           rb_yield_tokens(N, tag[0], attr, raw_string, taint); 
     
    7979             mark = mark_aval; 
    8080           } 
    81            if(mark > tokstart) { 
     81           if(mark > ts) { 
    8282             if(N == tag) { 
    83                mark_tag  -= tokstart; 
     83               mark_tag  -= ts; 
    8484             } else if(N == akey) { 
    85                mark_akey -= tokstart; 
     85               mark_akey -= ts; 
    8686             } else if(N == aval) { 
    87                mark_aval -= tokstart; 
     87               mark_aval -= ts; 
    8888             } 
    8989           } 
     
    9595             attr = RubyHash.newHash(runtime); 
    9696           } 
    97            ((RubyHash)attr).aset(K,V); 
     97           ((RubyHash)attr).op_aset(runtime.getCurrentContext(),K,V); 
     98           // ((RubyHash)attr).aset(K,V); 
    9899         } 
    99100       } 
     
    115116           if(ele_open) {  
    116117             ele_open = false;  
    117              if(tokstart > -1) {  
    118                mark_tag = tokstart;  
     118             if(ts > -1) {  
     119               mark_tag = ts;  
    119120             }  
    120121           } else { 
     
    184185  } 
    185186 
    186   include hpricot_common "ext/hpricot_scan/hpricot_common.rl"; 
     187  include hpricot_common "hpricot_common.rl"; 
    187188 
    188189}%% 
     
    210211int cs, act, have = 0, nread = 0, curline = 1, p=-1; 
    211212boolean text = false; 
    212 int tokstart=-1, tokend; 
     213int ts=-1, te; 
     214int eof=-1; 
    213215char[] buf; 
    214216Ruby runtime; 
     
    300302    if ( done && ele_open ) { 
    301303      ele_open = false; 
    302       if(tokstart > -1) { 
    303         mark_tag = tokstart; 
    304         tokstart = -1; 
     304      if(ts > -1) { 
     305        mark_tag = ts; 
     306        ts = -1; 
    305307        text = true; 
    306308      } 
    307309    } 
    308310 
    309     if(tokstart == -1) { 
     311    if(ts == -1) { 
    310312      have = 0; 
    311       /* text nodes have no tokstart because each byte is parsed alone */ 
     313      /* text nodes have no ts because each byte is parsed alone */ 
    312314      if(mark_tag != -1 && text) { 
    313315        if (done) { 
     
    322324      mark_tag = 0; 
    323325    } else { 
    324       have = pe - tokstart; 
    325       System.arraycopy(buf,tokstart,buf,0,have); 
     326      have = pe - ts; 
     327      System.arraycopy(buf,ts,buf,0,have); 
    326328      SLIDE(tag); 
    327329      SLIDE(akey); 
    328330      SLIDE(aval); 
    329       tokend = (tokend - tokstart); 
    330       tokstart = 0; 
     331      te = (te - ts); 
     332      ts = 0; 
    331333    } 
    332334  } 
     
    359361public static void Init_hpricot_scan(Ruby runtime) { 
    360362  RubyModule mHpricot = runtime.defineModule("Hpricot"); 
    361   mHpricot.getMetaClass().attr_accessor(new IRubyObject[]{runtime.newSymbol("buffer_size")}); 
     363  mHpricot.getMetaClass().attr_accessor(runtime.getCurrentContext(),new IRubyObject[]{runtime.newSymbol("buffer_size")}); 
    362364  CallbackFactory fact = runtime.callbackFactory(HpricotScanService.class); 
    363365  mHpricot.getMetaClass().defineMethod("scan",fact.getSingletonMethod("__hpricot_scan",IRubyObject.class));