2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / gnu / gcj / runtime / natStringBuffer.cc
blob2777b9ed8ebe0048dbddd5f48893ab9a3a451eaa
1 // natStringBuffer.cc - Implementation of java.lang.StringBuffer native methods.
3 /* Copyright (C) 2001 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
11 #include <config.h>
12 #include <gcj/cni.h>
13 #include <gnu/gcj/runtime/StringBuffer.h>
14 #include <java/lang/String.h>
16 gnu::gcj::runtime::StringBuffer *
17 gnu::gcj::runtime::StringBuffer::append (jint num)
19 // Use an array large enough for "-2147483648"; i.e. 11 chars.
20 jchar buffer[11];
21 int i = _Jv_FormatInt (buffer+11, num);
22 jint needed = count + i;
23 ensureCapacity_unsynchronized (needed);
24 jchar* dst = elements (value) + count;
25 jchar* src = buffer+11-i;
26 while (--i >= 0)
27 *dst++ = *src++;
28 count = needed;
29 return this;
32 java::lang::String *
33 gnu::gcj::runtime::StringBuffer::toString ()
35 return new java::lang::String (this);