2005-01-29 14:18:28 -05:00
|
|
|
! Copyright (C) 2004, 2005 Slava Pestov.
|
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2005-05-19 15:16:25 -04:00
|
|
|
IN: kernel-internals
|
|
|
|
|
USING: kernel math strings ;
|
|
|
|
|
|
|
|
|
|
: (sbuf>string) underlying dup rehash-string ;
|
|
|
|
|
|
2005-04-02 02:39:33 -05:00
|
|
|
IN: strings
|
2005-05-19 15:16:25 -04:00
|
|
|
USING: generic sequences ;
|
2005-04-02 02:39:33 -05:00
|
|
|
|
2005-06-10 16:08:00 -04:00
|
|
|
M: string resize resize-string ;
|
2005-05-05 16:51:38 -04:00
|
|
|
|
2005-05-14 17:18:45 -04:00
|
|
|
DEFER: sbuf?
|
|
|
|
|
BUILTIN: sbuf 13 sbuf?
|
2005-05-05 22:30:58 -04:00
|
|
|
[ 1 length set-capacity ]
|
|
|
|
|
[ 2 underlying set-underlying ] ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2005-05-05 22:30:58 -04:00
|
|
|
M: sbuf set-length ( n sbuf -- )
|
2005-06-10 16:08:00 -04:00
|
|
|
growable-check 2dup expand set-capacity ;
|
2005-04-19 20:28:01 -04:00
|
|
|
|
2005-05-05 22:30:58 -04:00
|
|
|
M: sbuf nth ( n sbuf -- ch )
|
|
|
|
|
bounds-check underlying char-slot ;
|
2004-08-10 23:48:08 -04:00
|
|
|
|
2005-05-05 22:30:58 -04:00
|
|
|
M: sbuf set-nth ( ch n sbuf -- )
|
|
|
|
|
growable-check 2dup ensure underlying
|
|
|
|
|
>r >r >fixnum r> r> set-char-slot ;
|
2004-08-10 23:48:08 -04:00
|
|
|
|
2005-05-18 16:26:22 -04:00
|
|
|
M: sbuf >string sbuf>string ;
|