natStringBuffer.cc 958 B

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