]> gitweb.factorcode.org Git - factor.git/commitdiff
Updated to work with the new vector/hashtable syntax
authorDoug Coleman <erg@trifocus.net>
Wed, 2 Nov 2005 08:30:38 +0000 (08:30 +0000)
committerDoug Coleman <erg@trifocus.net>
Wed, 2 Nov 2005 08:30:38 +0000 (08:30 +0000)
contrib/aim/aim.factor
contrib/aim/net-bytes.factor

index 9a00a90892294f170bc291137aa69de0cfada511..275a6fb95153743788d2607da42542039529ec07 100644 (file)
@@ -73,11 +73,6 @@ H{
     [[ 12 "Translate" ]] [[ 19 "SSI" ]] [[ 21 "ICQ" ]]
     [[ 34 "Unknown Family" ]] } ;
 
-: ch>lower ( int -- int ) dup LETTER? [ HEX: 20 + ] when ;
-: ch>upper ( int -- int ) dup letter? [ HEX: 20 - ] when ;
-: >lower ( seq -- seq ) [ ch>lower ] map ;
-: >upper ( seq -- seq ) [ ch>upper ] map ;
-
 : sanitize-name ( name -- name ) HEX: 20 swap remove >lower ;
 
 : hash-swap ( hash -- hash )
@@ -182,12 +177,14 @@ H{
     conn get swap with-unscoped-stream ;
 
 : read-aim ( -- bc )
-    [ [
-        head-byte drop
-        head-byte drop
-        head-short drop
-        head-short head-string
-    ] with-aim ] catch [ "Socket error" print throw ] when
+    [
+        [
+            head-byte drop
+            head-byte drop
+            head-short drop
+            head-short head-string
+        ] with-aim
+    ] catch [ "Socket error" print throw ] when
     "Received: " write dup hexdump ;
 
 : make-snac ( fam subtype flags req-id -- )
@@ -729,11 +726,11 @@ SYMBOL: type
 
         type get
         {
-            { [ dup 0 = ] [ drop name get bid get gid get { } clone f f <buddy> 
+            { [ dup 0 = ] [ drop name get bid get gid get V{ } clone f f <buddy> 
             dup name get sanitize-name buddy-hash-name get set-hash bid get buddy-hash-id get set-hash ] }
             { [ dup 1 = ] [ drop name get dup length 0 = [ drop ] [ gid get <group> 
             dup name get sanitize-name group-hash-name get set-hash gid get group-hash-id get set-hash ] if ] }
-            { [ dup 3 = ] [ drop name get bid get gid get { } clone f f <buddy>
+            { [ dup 3 = ] [ drop name get bid get gid get V{ } clone f f <buddy>
             dup name get sanitize-name banned-hash-name get set-hash bid get banned-hash-id get set-hash ] }
             { [ t ] [ drop "Unknown 19-6 type" print ] }
         } cond
index d803eef300818f7ff9f6aad198f850c3053ad4d4..999638a279b5f58b20e2161ee844329eb20b386d 100644 (file)
@@ -22,14 +22,12 @@ SYMBOL: unscoped-stack
     HEX: 000000ff bitand unparse % ] "" make ;
 
 
-
-
 ! doesn't compile
 ! : >nvector ( elems n -- )
     ! { } clone swap [ drop swap add ] each reverse ;
 
 : 4vector ( elems -- )
-    { } clone 4 [ drop swap add ] each reverse ;
+    V{ } clone 4 [ drop swap add ] each reverse ;
 
 ! TODO: make this work for types other than ""
 : papply ( seq seq -- seq )
@@ -38,7 +36,6 @@ SYMBOL: unscoped-stack
 : writeln ( string -- )
     write terpri ;
 
-! wrote this months and months ago..
 ! NEEDS REFACTORING, GOSH!
 ! Hexdump
 : (print-offset) ( lineno -- )
@@ -82,21 +79,15 @@ SYMBOL: unscoped-stack
     ] "" make write ;
 
 : hexdump ( str -- )
-! drop ;
     dup length (print-length) (print-bytes) ;
 
 
 
 : save-current-scope
-    unscoped-stack get [ { } clone unscoped-stack set ] unless
+    unscoped-stack get [ V{ } clone unscoped-stack set ] unless
     swap dup unscoped-stream set unscoped-stack get push ;
 
 : set-previous-scope
-    ! unscoped-stream get contents .
-    ! [
-        ! "UNREAD BYTES" writeln
-        ! hexdump
-    ! ] when
     unscoped-stack get dup length 1 > [ 
         [ pop ] keep nip peek unscoped-stream set ] [
         pop drop
@@ -167,16 +158,19 @@ SYMBOL: unscoped-stack
 : (head-u128) ( str -- u128 )
     16 swap head endian> ;
 
-
+! 8 bits
 : head-byte ( -- byte )
     1 unscoped-stream get stream-read first ;
 
+! 16 bits
 : head-short ( -- short )
     2 unscoped-stream get stream-read (head-short) ;
 
+! 32 bits
 : head-int ( -- int )
     4 unscoped-stream get stream-read (head-int) ;
 
+! 64 bits
 : head-longlong ( -- longlong )
     8 unscoped-stream get stream-read (head-longlong) ;