Package org.jruby

Examples of org.jruby.RubyHash$EntryMatchType


        for (Iterator iter = additionalDirectories.iterator(); iter.hasNext();) {
            addPath((String) iter.next());
        }

        // add $RUBYLIB paths
       RubyHash env = (RubyHash) runtime.getObject().fastGetConstant("ENV");
       RubyString env_rubylib = runtime.newString("RUBYLIB");
       if (env.has_key_p(env_rubylib).isTrue()) {
           String rubylib = env.op_aref(runtime.getCurrentContext(), env_rubylib).toString();
           String[] paths = rubylib.split(File.pathSeparator);
           for (int i = 0; i < paths.length; i++) {
               addPath(paths[i]);
           }
       }
View Full Code Here


            case ClassIndex.FLOAT:
                write('f');
                RubyFloat.marshalTo((RubyFloat)value, this);
                return;
            case ClassIndex.HASH: {
                RubyHash hash = (RubyHash)value;

                if(hash.getIfNone().isNil()){
                    write('{');
                }else if (hash.hasDefaultProc()) {
                    throw hash.getRuntime().newTypeError("can't dump hash with default proc");
                } else {
                    write('}');
                }

                RubyHash.marshalTo(hash, this);
View Full Code Here

    public void load(Ruby runtime, boolean wrap) {
        RubyModule configModule = runtime.defineModule("Config");
       
        configModule.defineAnnotatedMethods(RbConfigLibrary.class);
       
        RubyHash configHash = RubyHash.newHash(runtime);
        configModule.defineConstant("CONFIG", configHash);
        runtime.getObject().defineConstant("RbConfig", configModule);

        String[] versionParts = Constants.RUBY_VERSION.split("\\.");
        setConfig(configHash, "MAJOR", versionParts[0]);
        setConfig(configHash, "MINOR", versionParts[1]);
        setConfig(configHash, "TEENY", versionParts[2]);
        setConfig(configHash, "ruby_version", versionParts[0] + '.' + versionParts[1]);
        // Rubygems is too specific on host cpu so until we have real need lets default to universal
        //setConfig(configHash, "arch", System.getProperty("os.arch") + "-java" + System.getProperty("java.specification.version"));
        setConfig(configHash, "arch", "universal-java" + System.getProperty("java.specification.version"));

        String normalizedHome;
        if (Ruby.isSecurityRestricted()) {
            normalizedHome = "SECURITY RESTRICTED";
        } else {
            normalizedHome = runtime.getJRubyHome();
        }
        setConfig(configHash, "bindir", new NormalizedFile(normalizedHome, "bin").getPath());
        setConfig(configHash, "RUBY_INSTALL_NAME", jrubyScript());
        setConfig(configHash, "ruby_install_name", jrubyScript());
        setConfig(configHash, "SHELL", jrubyShell());
        setConfig(configHash, "prefix", normalizedHome);
        setConfig(configHash, "exec_prefix", normalizedHome);

        setConfig(configHash, "host_os", getOSName());
        setConfig(configHash, "host_vendor", System.getProperty("java.vendor"));
        setConfig(configHash, "host_cpu", Platform.ARCH);
       
        setConfig(configHash, "target_os", getOSName());
       
        setConfig(configHash, "target_cpu", Platform.ARCH);
       
        String jrubyJarFile = "jruby.jar";
        URL jrubyPropertiesUrl = Ruby.getClassLoader().getResource(Constants.JRUBY_PROPERTIES);
        if (jrubyPropertiesUrl != null) {
            Pattern jarFile = Pattern.compile("jar:file:.*?([a-zA-Z0-9.\\-]+\\.jar)!" + Constants.JRUBY_PROPERTIES);
            Matcher jarMatcher = jarFile.matcher(jrubyPropertiesUrl.toString());
            jarMatcher.find();
            if (jarMatcher.matches()) {
                jrubyJarFile = jarMatcher.group(1);
            }
        }
        setConfig(configHash, "LIBRUBY", jrubyJarFile);
        setConfig(configHash, "LIBRUBY_SO", jrubyJarFile);
       
        setConfig(configHash, "build", Constants.BUILD);
        setConfig(configHash, "target", Constants.TARGET);
       
        String libdir = System.getProperty("jruby.lib");
        if (libdir == null) {
            libdir = new NormalizedFile(normalizedHome, "lib").getPath();
        } else {
            try {
            // Our shell scripts pass in non-canonicalized paths, but even if we didn't
            // anyone who did would become unhappy because Ruby apps expect no relative
            // operators in the pathname (rubygems, for example).
                libdir = new NormalizedFile(libdir).getCanonicalPath();
            } catch (IOException e) {
                libdir = new NormalizedFile(libdir).getAbsolutePath();
            }
        }
        String rubyLibDir = new NormalizedFile(libdir, "ruby/1.8").getPath();
        String siteDir = new NormalizedFile(libdir, "ruby/site_ruby").getPath();
        String siteLibDir = new NormalizedFile(libdir, "ruby/site_ruby/1.8").getPath();
        String siteArchDir = new NormalizedFile(libdir, "ruby/site_ruby/1.8/java").getPath();
        String archDir = new NormalizedFile(libdir, "ruby/1.8/java").getPath();

        setConfig(configHash, "libdir", libdir);
        setConfig(configHash, "rubylibdir",     rubyLibDir);
        setConfig(configHash, "sitedir",        siteDir);
        setConfig(configHash, "sitelibdir",     siteLibDir);
        setConfig(configHash, "sitearchdir",    siteArchDir);
        setConfig(configHash, "archdir",   archDir);
        setConfig(configHash, "topdir",   archDir);
        setConfig(configHash, "configure_args", "");
        setConfig(configHash, "datadir", new NormalizedFile(normalizedHome, "share").getPath());
        setConfig(configHash, "mandir", new NormalizedFile(normalizedHome, "man").getPath());
        setConfig(configHash, "sysconfdir", new NormalizedFile(normalizedHome, "etc").getPath());
        setConfig(configHash, "localstatedir", new NormalizedFile(normalizedHome, "var").getPath());
        setConfig(configHash, "DLEXT", "jar");

        if (Platform.IS_WINDOWS) {
            setConfig(configHash, "EXEEXT", ".exe");
        } else {
            setConfig(configHash, "EXEEXT", "");
        }
       
        RubyHash mkmfHash = RubyHash.newHash(runtime);
       

        setConfig(mkmfHash, "libdir", libdir);
        setConfig(mkmfHash, "arch", "java");
        setConfig(mkmfHash, "rubylibdir",     rubyLibDir);
View Full Code Here

            case YARVInstructions.DUPARRAY:
                push(bytecodes[ip].o_op0.dup());
                break;
            case YARVInstructions.NEWHASH:
                int hsize = (int)bytecodes[ip].l_op0;
                RubyHash h = RubyHash.newHash(runtime);
                IRubyObject v,k;
                for(int i = hsize; i>0; i -= 2) {
                    v = pop();
                    k = pop();
                    h.op_aset(context, k, v);
                }
                push(h);
                break;
            case YARVInstructions.PUTNOT:
                push(peek().isTrue() ? runtime.getFalse() : runtime.getTrue());
View Full Code Here

      rv.append(RubyString.newString(runtime, str));
    }
  }

  void tag(String prefix, String name, RubyHash attr, RubySymbol flavor) {
    RubyHash tag = RubyHash.newHash(runtime);
    tag.op_aset(
      runtime.getCurrentContext(),
      RubySymbol.newSymbol(runtime, "prefix"),
      RubyString.newString(runtime, prefix)
    );
    tag.op_aset(
      runtime.getCurrentContext(),
      RubySymbol.newSymbol(runtime, "name"),
      RubyString.newString(runtime, name)
    );
    tag.op_aset(
      runtime.getCurrentContext(),
      RubySymbol.newSymbol(runtime, "attrs"),
      attr
    );
    tag.op_aset(
      runtime.getCurrentContext(),
      RubySymbol.newSymbol(runtime, "flavor"),
      flavor
    );
    rv.append(tag);
View Full Code Here

    String disposable_string;

    String name = "";
    String prefix = "";
    RubySymbol flavor = RubySymbol.newSymbol(runtime, "tasteless".intern());
    RubyHash attributes = RubyHash.newHash(runtime);

    int tagstart = 0;
    int mark_pfx = 0;
    int mark_stg = 0;
    int mark_attr = 0;
    int mark_nat = 0;
    int mark_vat = 0;

    String nat = "";
    String vat = "";

    int cs;
    int p = 0;
    int pe = data.length;
    int eof = pe;
    int act;
    int ts;
    int te;

    rv = RubyArray.newArray(runtime);
    char[] remainder = data;

   
// line 351 "JavaScanner.java"
  {
  cs = parser_start;
  ts = -1;
  te = -1;
  act = 0;
  }

// line 175 "JavaScanner.rl"
   
// line 361 "JavaScanner.java"
  {
  int _klen;
  int _trans = 0;
  int _acts;
  int _nacts;
  int _keys;
  int _goto_targ = 0;

  _goto: while (true) {
  switch ( _goto_targ ) {
  case 0:
  if ( p == pe ) {
    _goto_targ = 4;
    continue _goto;
  }
  if ( cs == 0 ) {
    _goto_targ = 5;
    continue _goto;
  }
case 1:
  _acts = _parser_from_state_actions[cs];
  _nacts = (int) _parser_actions[_acts++];
  while ( _nacts-- > 0 ) {
    switch ( _parser_actions[_acts++] ) {
  case 15:
// line 1 "NONE"
  {ts = p;}
  break;
// line 390 "JavaScanner.java"
    }
  }

  _match: do {
  _keys = _parser_key_offsets[cs];
  _trans = _parser_index_offsets[cs];
  _klen = _parser_single_lengths[cs];
  if ( _klen > 0 ) {
    int _lower = _keys;
    int _mid;
    int _upper = _keys + _klen - 1;
    while (true) {
      if ( _upper < _lower )
        break;

      _mid = _lower + ((_upper-_lower) >> 1);
      if ( data[p] < _parser_trans_keys[_mid] )
        _upper = _mid - 1;
      else if ( data[p] > _parser_trans_keys[_mid] )
        _lower = _mid + 1;
      else {
        _trans += (_mid - _keys);
        break _match;
      }
    }
    _keys += _klen;
    _trans += _klen;
  }

  _klen = _parser_range_lengths[cs];
  if ( _klen > 0 ) {
    int _lower = _keys;
    int _mid;
    int _upper = _keys + (_klen<<1) - 2;
    while (true) {
      if ( _upper < _lower )
        break;

      _mid = _lower + (((_upper-_lower) >> 1) & ~1);
      if ( data[p] < _parser_trans_keys[_mid] )
        _upper = _mid - 2;
      else if ( data[p] > _parser_trans_keys[_mid+1] )
        _lower = _mid + 2;
      else {
        _trans += ((_mid - _keys)>>1);
        break _match;
      }
    }
    _trans += _klen;
  }
  } while (false);

  _trans = _parser_indicies[_trans];
case 3:
  cs = _parser_trans_targs[_trans];

  if ( _parser_trans_actions[_trans] != 0 ) {
    _acts = _parser_trans_actions[_trans];
    _nacts = (int) _parser_actions[_acts++];
    while ( _nacts-- > 0 )
  {
      switch ( _parser_actions[_acts++] )
      {
  case 0:
// line 4 "JavaScanner.rl"
  { mark_pfx = p; }
  break;
  case 1:
// line 5 "JavaScanner.rl"
  {
    prefix = input.substring(mark_pfx, p);
  }
  break;
  case 2:
// line 8 "JavaScanner.rl"
  {
    if ( !prefix.equals(tag_prefix) ) {
      // have to manually add ':' / Sep
      // pass the text through & reset state
      pass_through(input.substring(tagstart, p) + ":");
      prefix = "";
      {cs = 49; _goto_targ = 2; if (true) continue _goto;}
    }
  }
  break;
  case 3:
// line 18 "JavaScanner.rl"
  { mark_stg = p; }
  break;
  case 4:
// line 19 "JavaScanner.rl"
  { name = input.substring(mark_stg, p); }
  break;
  case 5:
// line 20 "JavaScanner.rl"
  { mark_attr = p; }
  break;
  case 6:
// line 21 "JavaScanner.rl"
  {
    attributes.op_aset(
      runtime.getCurrentContext(),
      RubyString.newString(runtime, nat),
      RubyString.newString(runtime, vat)
    );
  }
View Full Code Here

        if (!(entries instanceof RubyHash)) {
            throw runtime.newArgumentError("expected a hash for the second argument");
        }

        RubyHash hash = (RubyHash) entries;
        try {
            FileOutputStream file = newFile(jar_path);
            try {
                ZipOutputStream zip = new ZipOutputStream(file);
                addEntries(context, zip, hash);
View Full Code Here

      for (RubyVariableMeta var : meta.getRubyVariables()) {
        data.container.put(var.getName(), step.environmentSubstitute(var.getValue()));
      }

      // put all script tabs into scope
      RubyHash tabs = new RubyHash(data.runtime);

      for (RubyScriptMeta tab : meta.getScripts()) {
        tabs.put(tab.getTitle(), new ScriptTab(tab, data));
      }

      data.container.put("$tabs", tabs);

      // temporary place for the output a script might produce
View Full Code Here

    if (!Const.isEmpty(gemHomeString)) {

      File gemHomePath = new File(gemHomeString);
      gemHomePath = gemHomePath.getAbsoluteFile();

      RubyHash configHash = (RubyHash) data.container.parse("require 'rbconfig'; RbConfig::CONFIG").run();
      configHash.put("default_gem_home", gemHomePath.getAbsolutePath());
    }
  }
View Full Code Here

      data.container.put("$error", new ErrorStreamWriter(this));
    }

    // put the target steps into ruby scope
    RubyHash targetSteps = new RubyHash(data.runtime);

    int t = 0;
    for (StreamInterface stream : meta.getStepIOMeta().getTargetStreams()) {
      StepStreamWriter writer = new StepStreamWriter(this, stream.getStepname());
      targetSteps.put(meta.getTargetSteps().get(t).getRoleName(), writer);
      t++;
    }

    data.container.put("$target_steps", targetSteps);
View Full Code Here

TOP

Related Classes of org.jruby.RubyHash$EntryMatchType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.