begin  quoting James G. Sack (jim) as of Sat, Sep 30, 2006 at 09:41:32PM -0700:
> Stewart Stremler wrote:
[snip]
> > Should I write up a version of the circular buffer in Objective-C? You
> > can contrast and compare. :)
> 
> Hey!, I'd like to see that.

Okay.

First attempt is at:

http://www.stremler.net/temp/CBufObjC.tar

Basically, no documentation, comments, etc., and no fixed unit-test,
just a stupid little command-line driver. I've only ever noodled with
Objective-C, so the code is rather amateurish. 

I didn't use any Foundation classes, as that would require you to use
OS X, NeXT , or to install GNUStep; this _ought_ to compile with any
GCC (Which used to, at least, include the ObjC compiler).

Here's the sample run:

Script started on Sun Oct 01 09:23:04 2006
straumli> ls
CBuffer.h       CVS/            SimpleString.h  main.m          
CBuffer.m       Makefile        SimpleString.m  typescript      
straumli> make
gcc -Wno-import -c -Wall -g CBuffer.m
gcc -Wno-import -c -Wall -g SimpleString.m
gcc -Wno-import -c -Wall -g main.m
gcc -Wno-import -Wall -g -L/usr/local/lib -L/usr/gnu/lib -o buffer main.o 
CBuffer.o SimpleString.o -lobjc -lrt
straumli>  ./buffer +a +b +c - - - - +d +e +f \? +g +h +i +j +k \! - - - -
Can take 7 puts.
Put 'a' successfully!
Put 'b' successfully!
Put 'c' successfully!
Got 'a'
Got 'b'
Got 'c'
Get failed!
Put 'd' successfully!
Put 'e' successfully!
Put 'f' successfully!
Have 4 available.
Put 'g' successfully!
Put 'h' successfully!
Put 'i' successfully!
Put 'j' successfully!
Failed to put 'k'!
size = 8
head = 2
tail = 3
(0) = 357c0
(1) = 357d0
(2) = 0
(3) = 35790
(4) = 35760
(5) = 35780
(6) = 357a0
(7) = 357b0
Got 'd'
Got 'e'
Got 'f'
Got 'g'
size = 8
head = 2
tail = 7
(0) = 357c0
(1) = 357d0
(2) = 0
(3) = 0
(4) = 0
(5) = 0
(6) = 0
(7) = 357b0
straumli> exit
script done on Sun Oct 01 09:23:16 2006

-- 
_ |\_
 \|

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to