public Object unmarshalFrom(Ruby runtime, RubyClass type, UnmarshalStream unmarshalStream)
            throws IOException {
          RubySystemCallError exc = (RubySystemCallError) type.allocate();

          unmarshalStream.registerLinkTarget(exc);
          unmarshalStream.defaultVariablesUnmarshal(exc);

          exc.message = (IRubyObject) exc.removeInternalVariable("mesg");
          exc.errno = (IRubyObject) exc.removeInternalVariable("errno");
          exc.set_backtrace((IRubyObject) exc.removeInternalVariable("bt"));

          return exc;
        }
Exemple #2
0
 private IRubyObject userUnmarshal(MarshalState state) throws IOException {
   String className = unmarshalObject(false).asJavaString();
   ByteList marshaled = unmarshalString();
   RubyClass classInstance = findClass(className);
   RubyString data = RubyString.newString(getRuntime(), marshaled);
   if (state.isIvarWaiting()) {
     defaultVariablesUnmarshal(data);
     state.setIvarWaiting(false);
   }
   IRubyObject unmarshaled = classInstance.smartLoadOldUser(data);
   registerLinkTarget(unmarshaled);
   return unmarshaled;
 }
Exemple #3
0
        public Object unmarshalFrom(Ruby runtime, RubyClass type, UnmarshalStream unmarshalStream)
            throws IOException {
          RubyRange range = (RubyRange) type.allocate();

          unmarshalStream.registerLinkTarget(range);

          unmarshalStream.defaultVariablesUnmarshal(range);

          range.begin = (IRubyObject) range.removeInternalVariable("begin");
          range.end = (IRubyObject) range.removeInternalVariable("end");
          range.isExclusive = ((IRubyObject) range.removeInternalVariable("excl")).isTrue();

          return range;
        }
Exemple #4
0
  private IRubyObject unmarshalObjectDirectly(int type, MarshalState state, boolean callProc)
      throws IOException {
    IRubyObject rubyObj = null;
    switch (type) {
      case 'I':
        MarshalState childState = new MarshalState(true);
        rubyObj = unmarshalObject(childState);
        if (childState.isIvarWaiting()) {
          defaultVariablesUnmarshal(rubyObj);
        }
        return rubyObj;
      case '0':
        rubyObj = runtime.getNil();
        break;
      case 'T':
        rubyObj = runtime.getTrue();
        break;
      case 'F':
        rubyObj = runtime.getFalse();
        break;
      case '"':
        rubyObj = RubyString.unmarshalFrom(this);
        break;
      case 'i':
        rubyObj = RubyFixnum.unmarshalFrom(this);
        break;
      case 'f':
        rubyObj = RubyFloat.unmarshalFrom(this);
        break;
      case '/':
        rubyObj = RubyRegexp.unmarshalFrom(this);
        break;
      case ':':
        rubyObj = RubySymbol.unmarshalFrom(this);
        break;
      case '[':
        rubyObj = RubyArray.unmarshalFrom(this);
        break;
      case '{':
        rubyObj = RubyHash.unmarshalFrom(this, false);
        break;
      case '}':
        // "hashdef" object, a hash with a default
        rubyObj = RubyHash.unmarshalFrom(this, true);
        break;
      case 'c':
        rubyObj = RubyClass.unmarshalFrom(this);
        break;
      case 'm':
        rubyObj = RubyModule.unmarshalFrom(this);
        break;
      case 'e':
        RubySymbol moduleName = (RubySymbol) unmarshalObject();
        RubyModule tp = null;
        try {
          tp = runtime.getClassFromPath(moduleName.asJavaString());
        } catch (RaiseException e) {
          if (runtime.getModule("NameError").isInstance(e.getException())) {
            throw runtime.newArgumentError("undefined class/module " + moduleName.asJavaString());
          }
          throw e;
        }

        rubyObj = unmarshalObject();

        tp.extend_object(rubyObj);
        tp.callMethod(runtime.getCurrentContext(), "extended", rubyObj);
        break;
      case 'l':
        rubyObj = RubyBignum.unmarshalFrom(this);
        break;
      case 'S':
        rubyObj = RubyStruct.unmarshalFrom(this);
        break;
      case 'o':
        rubyObj = defaultObjectUnmarshal();
        break;
      case 'u':
        rubyObj = userUnmarshal(state);
        break;
      case 'U':
        rubyObj = userNewUnmarshal();
        break;
      case 'C':
        rubyObj = uclassUnmarshall();
        break;
      default:
        throw getRuntime().newArgumentError("dump format error(" + (char) type + ")");
    }

    if (callProc) {
      return doCallProcForObj(rubyObj);
    }

    return rubyObj;
  }