/** * Convert the buffer to a {@link LuaString} * @return the value as a {@link LuaString} */ public final LuaString tostring() { realloc( length, 0 ); return LuaString.valueOf( bytes, offset, length ); }
/** * Convert the buffer to a {@link LuaString} * @return the value as a {@link LuaString} */ public final LuaString tostring() { realloc( length, 0 ); return LuaString.valueOf( bytes, offset, length ); }
/** * Convert the buffer to a {@link LuaString} * @return the value as a {@link LuaString} */ public final LuaString tostring() { realloc( length, 0 ); return LuaString.valueOf( bytes, offset, length ); }
/** Ensure there is enough room before and after the bytes. * @param nbefore number of unused bytes which must precede the data after this completes * @param nafter number of unused bytes which must follow the data after this completes */ public final void makeroom( int nbefore, int nafter ) { if ( value != null ) { LuaString s = value.strvalue(); value = null; length = s.m_length; offset = nbefore; bytes = new byte[nbefore+length+nafter]; System.arraycopy(s.m_bytes, s.m_offset, bytes, offset, length); } else if ( offset+length+nafter > bytes.length || offset<nbefore ) { int n = nbefore+length+nafter; int m = n<32? 32: n<length*2? length*2: n; realloc( m, nbefore==0? 0: m-length-nafter ); } }
/** Ensure there is enough room before and after the bytes. * @param nbefore number of unused bytes which must precede the data after this completes * @param nafter number of unused bytes which must follow the data after this completes */ public final void makeroom( int nbefore, int nafter ) { if ( value != null ) { LuaString s = value.strvalue(); value = null; length = s.m_length; offset = nbefore; bytes = new byte[nbefore+length+nafter]; System.arraycopy(s.m_bytes, s.m_offset, bytes, offset, length); } else if ( offset+length+nafter > bytes.length || offset<nbefore ) { int n = nbefore+length+nafter; int m = n<32? 32: n<length*2? length*2: n; realloc( m, nbefore==0? 0: m-length-nafter ); } }
/** Ensure there is enough room before and after the bytes. * @param nbefore number of unused bytes which must precede the data after this completes * @param nafter number of unused bytes which must follow the data after this completes */ public final void makeroom( int nbefore, int nafter ) { if ( value != null ) { LuaString s = value.strvalue(); value = null; length = s.m_length; offset = nbefore; bytes = new byte[nbefore+length+nafter]; System.arraycopy(s.m_bytes, s.m_offset, bytes, offset, length); } else if ( offset+length+nafter > bytes.length || offset<nbefore ) { int n = nbefore+length+nafter; int m = n<32? 32: n<length*2? length*2: n; realloc( m, nbefore==0? 0: m-length-nafter ); } }