Examples of EBinary


Examples of erjang.EBinary

  public static EObject internal_name2native(EObject arg) {
    if (arg.testAtom() != null) {
      throw ERT.badarg(arg);
    }
    else if (arg.testBinary() != null) {
      EBinary bin = arg.testBinary();
      byte[] binbytes = bin.getByteArray();
      byte[] outbytes = new byte[binbytes.length + 1];
     
      System.arraycopy(binbytes, 0, outbytes, 0, binbytes.length);
      outbytes[outbytes.length - 1] = 0x0;
     
      return new EBinary(outbytes);
    }
    else {
      ESeq input = arg.testSeq();
      List<Byte> bytes = new ArrayList<Byte>();
      byte[] out;
     
      while (!input.isNil()) {
        Integer el = input.head().testSmall().intValue();
        bytes.add(el.byteValue());
        input = input.tail();
      }
      out = new byte[bytes.size() + 1];
      for (int i = 0; i < bytes.size(); ++i) {
        out[i] = bytes.get(i);
      }
      out[out.length - 1] = 0x0;
     
      return new EBinary(out);
    }
  }
View Full Code Here

Examples of erjang.EBinary

    }
  }
 
  @BIF
  public static EObject internal_native2name(EObject arg) {
    EBinary bin = arg.testBinary();
    byte[] binbytes;
   
    if (bin == null) {
      throw ERT.badarg(arg);
    }
    binbytes = bin.getByteArray();
    String out = new String(binbytes);
   
    return new EString(out);
  }
View Full Code Here

Examples of erjang.EBinary

    }
  };

  @BIF
  public static EObject bin_is_7bit(EObject o1) {
    EBinary bin;
    if ((bin = o1.testBinary()) != null) {
      return ERT.box( bin.is_7bit() );
    }
   
    return ERT.FALSE;
  }
View Full Code Here

Examples of erjang.EBinary

  //TODO: equality operators

  @Override
  public EBinary testBinary() {
    if (real_object instanceof byte[]) {
      return new EBinary((byte[]) real_object);
    }
    if (real_object instanceof String) {
      return new EBinary(((String) real_object).getBytes(IO.UTF8));
    }
    return null;
  }
View Full Code Here

Examples of erjang.EBinary

    return null;
  }

  @Override
  public EBitString testBitString() {
    EBinary bi;
    if ((bi=testBinary()) != null) {
      return bi;
    }
   
    if (testCons() == null
View Full Code Here

Examples of erjang.EBinary

    Options o = new Options();

    String pattern;
    ETuple4 tup = ETuple4.cast(obj1);
    if (tup != null && tup.elem1 == ECompiledRE.am_re_pattern) {
      EBinary b = tup.elem4.testBinary();
      byte[] byteArray = b.getByteArray();
      if (b != null && b.byteAt(0) == '/') {
       
        byte[] raw = byteArray;
        int end = raw.length - 1;
        for (int i = b.byteSize()-1; i > 0; i--) {
          if (b.byteAt(i*8) == '/') {
            end = i;
            break;
          }
        } 
         
View Full Code Here

Examples of erjang.EBinary

    if ((smd = section_map.get(LIT_T)) != null) {
      in.updateMessageDigest(context, smd.offset, smd.length);
    }
   
    byte[] digest = context.digest();
    this.module_md5 = new EBinary(digest);
  }
View Full Code Here

Examples of erjang.EBinary

        reply_posix_error(Posix.ENOENT);
        return;
      }
     
      if (ClassPathResource.isResource(name)) {
        EBinary data = ClassPathResource.read_file(name);
        if (data == null) {
          reply_posix_error(Posix.ENOENT);
        } else {
                                    if (isUnicodeDriverInterface()) {
View Full Code Here

Examples of erjang.EBinary

  @Override
  protected void output(EHandle caller, final ByteBuffer buf) throws IOException,
      Pausable {

    final int cmd = buf.getShort();
    final EBinary call_id = read_binary(buf);
   
    if (cmd == IJ) {
      int heap_size = buf.getInt();
      vm = sm_initialize(heap_size * 1024 * 1024);
      send_ok_response(call_id);
 
View Full Code Here

Examples of erjang.EBinary

  }


  private EBinary read_binary(ByteBuffer buf) {
    int str_len = buf.getInt();
    EBinary str = new EBinary(buf.array(),
        buf.position()+buf.arrayOffset(), str_len);
    buf.position(buf.position()+str_len);
    return str;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.