From ecf59b716844aa429e51be4dfcbc73c93bb44980 Mon Sep 17 00:00:00 2001 From: "U-CUTLER\\dharmatech" <dharmatech@cutler.(none)> Date: Mon, 31 Mar 2008 15:27:32 -0600 Subject: [PATCH 1/5] Move ldap to unmaintained --- {extra => unmaintained}/ldap/authors.txt | 0 {extra => unmaintained}/ldap/conf/addentry.ldif | 0 {extra => unmaintained}/ldap/conf/createdit.ldif | 0 {extra => unmaintained}/ldap/conf/slapd.conf | 0 {extra => unmaintained}/ldap/ldap-tests.factor | 0 {extra => unmaintained}/ldap/ldap.factor | 0 {extra => unmaintained}/ldap/libldap/authors.txt | 0 {extra => unmaintained}/ldap/libldap/libldap.factor | 0 {extra => unmaintained}/ldap/libldap/tags.txt | 0 {extra => unmaintained}/ldap/summary.txt | 0 {extra => unmaintained}/ldap/tags.txt | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename {extra => unmaintained}/ldap/authors.txt (100%) rename {extra => unmaintained}/ldap/conf/addentry.ldif (100%) rename {extra => unmaintained}/ldap/conf/createdit.ldif (100%) rename {extra => unmaintained}/ldap/conf/slapd.conf (100%) rename {extra => unmaintained}/ldap/ldap-tests.factor (100%) rename {extra => unmaintained}/ldap/ldap.factor (100%) rename {extra => unmaintained}/ldap/libldap/authors.txt (100%) rename {extra => unmaintained}/ldap/libldap/libldap.factor (100%) rename {extra => unmaintained}/ldap/libldap/tags.txt (100%) rename {extra => unmaintained}/ldap/summary.txt (100%) rename {extra => unmaintained}/ldap/tags.txt (100%) diff --git a/extra/ldap/authors.txt b/unmaintained/ldap/authors.txt similarity index 100% rename from extra/ldap/authors.txt rename to unmaintained/ldap/authors.txt diff --git a/extra/ldap/conf/addentry.ldif b/unmaintained/ldap/conf/addentry.ldif similarity index 100% rename from extra/ldap/conf/addentry.ldif rename to unmaintained/ldap/conf/addentry.ldif diff --git a/extra/ldap/conf/createdit.ldif b/unmaintained/ldap/conf/createdit.ldif similarity index 100% rename from extra/ldap/conf/createdit.ldif rename to unmaintained/ldap/conf/createdit.ldif diff --git a/extra/ldap/conf/slapd.conf b/unmaintained/ldap/conf/slapd.conf similarity index 100% rename from extra/ldap/conf/slapd.conf rename to unmaintained/ldap/conf/slapd.conf diff --git a/extra/ldap/ldap-tests.factor b/unmaintained/ldap/ldap-tests.factor similarity index 100% rename from extra/ldap/ldap-tests.factor rename to unmaintained/ldap/ldap-tests.factor diff --git a/extra/ldap/ldap.factor b/unmaintained/ldap/ldap.factor similarity index 100% rename from extra/ldap/ldap.factor rename to unmaintained/ldap/ldap.factor diff --git a/extra/ldap/libldap/authors.txt b/unmaintained/ldap/libldap/authors.txt similarity index 100% rename from extra/ldap/libldap/authors.txt rename to unmaintained/ldap/libldap/authors.txt diff --git a/extra/ldap/libldap/libldap.factor b/unmaintained/ldap/libldap/libldap.factor similarity index 100% rename from extra/ldap/libldap/libldap.factor rename to unmaintained/ldap/libldap/libldap.factor diff --git a/extra/ldap/libldap/tags.txt b/unmaintained/ldap/libldap/tags.txt similarity index 100% rename from extra/ldap/libldap/tags.txt rename to unmaintained/ldap/libldap/tags.txt diff --git a/extra/ldap/summary.txt b/unmaintained/ldap/summary.txt similarity index 100% rename from extra/ldap/summary.txt rename to unmaintained/ldap/summary.txt diff --git a/extra/ldap/tags.txt b/unmaintained/ldap/tags.txt similarity index 100% rename from extra/ldap/tags.txt rename to unmaintained/ldap/tags.txt From 7cb9be06e5c303d0c390a44e8e034b180bc93fcd Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Tue, 1 Apr 2008 16:46:22 -0500 Subject: [PATCH 2/5] redo singletons --- extra/singleton/singleton-docs.factor | 12 ------------ extra/singleton/singleton-tests.factor | 5 ++++- extra/singleton/singleton.factor | 15 +++++++++++---- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/extra/singleton/singleton-docs.factor b/extra/singleton/singleton-docs.factor index 92ddcc494a..7acf97a436 100644 --- a/extra/singleton/singleton-docs.factor +++ b/extra/singleton/singleton-docs.factor @@ -12,15 +12,3 @@ HELP: SINGLETON: } { $see-also POSTPONE: PREDICATE: } ; - -HELP: SINGLETONS: -{ $syntax "SINGLETONS: classes... ;" -} { $values - { "classes" "new singletons to define" } -} { $description - "Defines a new singleton for each class in the list." -} { $examples - { $example "USE: singleton" "SINGLETONS: foo bar baz ;" "" } -} { $see-also - POSTPONE: SINGLETON: -} ; diff --git a/extra/singleton/singleton-tests.factor b/extra/singleton/singleton-tests.factor index 1698181ed3..da2a74f8d1 100644 --- a/extra/singleton/singleton-tests.factor +++ b/extra/singleton/singleton-tests.factor @@ -1,4 +1,4 @@ -USING: kernel singleton tools.test ; +USING: kernel singleton tools.test prettyprint io.streams.string ; IN: singleton.tests [ ] [ SINGLETON: bzzt ] unit-test @@ -7,3 +7,6 @@ IN: singleton.tests GENERIC: zammo ( obj -- ) [ ] [ M: bzzt zammo drop "yes!" ; ] unit-test [ "yes!" ] [ bzzt zammo ] unit-test +[ ] [ SINGLETON: omg ] unit-test +[ t ] [ omg singleton? ] unit-test +[ "USING: singleton ;\nIN: singleton.tests\nSINGLETON: omg\n" ] [ [ omg see ] with-string-writer ] unit-test diff --git a/extra/singleton/singleton.factor b/extra/singleton/singleton.factor index 9ec9f2f4a3..99319fdfdb 100755 --- a/extra/singleton/singleton.factor +++ b/extra/singleton/singleton.factor @@ -1,16 +1,23 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: classes.predicate kernel namespaces parser quotations -sequences words ; +sequences words prettyprint prettyprint.backend prettyprint.sections +compiler.units classes ; +USE: tools.walker IN: singleton +PREDICATE: singleton < predicate-class + [ "predicate-definition" word-prop ] + [ [ eq? ] curry ] bi sequence= ; + : define-singleton ( token -- ) create-class-in - \ word + dup save-location + \ singleton over [ eq? ] curry define-predicate-class ; : SINGLETON: scan define-singleton ; parsing -: SINGLETONS: - ";" parse-tokens [ define-singleton ] each ; parsing +M: singleton see-class* ( class -- ) + <colon \ SINGLETON: pprint-word pprint-word ; From 9e32613f5ca6933c1d1016f8ae0e555c7d1b8b61 Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Tue, 1 Apr 2008 16:51:48 -0500 Subject: [PATCH 3/5] rename singletons --- extra/{ => classes}/singleton/authors.txt | 0 extra/{ => classes}/singleton/singleton-docs.factor | 2 +- extra/{ => classes}/singleton/singleton-tests.factor | 4 ++-- extra/{ => classes}/singleton/singleton.factor | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) rename extra/{ => classes}/singleton/authors.txt (100%) rename extra/{ => classes}/singleton/singleton-docs.factor (96%) rename extra/{ => classes}/singleton/singleton-tests.factor (70%) rename extra/{ => classes}/singleton/singleton.factor (95%) diff --git a/extra/singleton/authors.txt b/extra/classes/singleton/authors.txt similarity index 100% rename from extra/singleton/authors.txt rename to extra/classes/singleton/authors.txt diff --git a/extra/singleton/singleton-docs.factor b/extra/classes/singleton/singleton-docs.factor similarity index 96% rename from extra/singleton/singleton-docs.factor rename to extra/classes/singleton/singleton-docs.factor index 7acf97a436..95b5b6af18 100644 --- a/extra/singleton/singleton-docs.factor +++ b/extra/classes/singleton/singleton-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax kernel words ; -IN: singleton +IN: classes.singleton HELP: SINGLETON: { $syntax "SINGLETON: class" diff --git a/extra/singleton/singleton-tests.factor b/extra/classes/singleton/singleton-tests.factor similarity index 70% rename from extra/singleton/singleton-tests.factor rename to extra/classes/singleton/singleton-tests.factor index da2a74f8d1..453a2a0ea5 100644 --- a/extra/singleton/singleton-tests.factor +++ b/extra/classes/singleton/singleton-tests.factor @@ -1,5 +1,5 @@ USING: kernel singleton tools.test prettyprint io.streams.string ; -IN: singleton.tests +IN: classes.singleton.tests [ ] [ SINGLETON: bzzt ] unit-test [ t ] [ bzzt bzzt? ] unit-test @@ -9,4 +9,4 @@ GENERIC: zammo ( obj -- ) [ "yes!" ] [ bzzt zammo ] unit-test [ ] [ SINGLETON: omg ] unit-test [ t ] [ omg singleton? ] unit-test -[ "USING: singleton ;\nIN: singleton.tests\nSINGLETON: omg\n" ] [ [ omg see ] with-string-writer ] unit-test +[ "USING: singleton ;\nIN: classes.singleton.tests\nSINGLETON: omg\n" ] [ [ omg see ] with-string-writer ] unit-test diff --git a/extra/singleton/singleton.factor b/extra/classes/singleton/singleton.factor similarity index 95% rename from extra/singleton/singleton.factor rename to extra/classes/singleton/singleton.factor index 99319fdfdb..61a519679c 100755 --- a/extra/singleton/singleton.factor +++ b/extra/classes/singleton/singleton.factor @@ -3,8 +3,7 @@ USING: classes.predicate kernel namespaces parser quotations sequences words prettyprint prettyprint.backend prettyprint.sections compiler.units classes ; -USE: tools.walker -IN: singleton +IN: classes.singleton PREDICATE: singleton < predicate-class [ "predicate-definition" word-prop ] From b4adebb6910278f1ca140552510f5278abd7f25e Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Tue, 1 Apr 2008 16:53:32 -0500 Subject: [PATCH 4/5] update usages of singleton --- extra/db/types/types.factor | 2 +- extra/http/server/auth/providers/db/db.factor | 84 ++++++++--------- .../http/server/sessions/storage/db/db.factor | 92 +++++++++---------- 3 files changed, 89 insertions(+), 89 deletions(-) diff --git a/extra/db/types/types.factor b/extra/db/types/types.factor index 9babfbcdb0..98bc451a6f 100755 --- a/extra/db/types/types.factor +++ b/extra/db/types/types.factor @@ -4,7 +4,7 @@ USING: arrays assocs db kernel math math.parser sequences continuations sequences.deep sequences.lib words namespaces tools.walker slots slots.private classes mirrors classes.tuple combinators calendar.format symbols -singleton ; +classes.singleton ; IN: db.types HOOK: modifier-table db ( -- hash ) diff --git a/extra/http/server/auth/providers/db/db.factor b/extra/http/server/auth/providers/db/db.factor index 1e84e544b8..deab40e8d4 100755 --- a/extra/http/server/auth/providers/db/db.factor +++ b/extra/http/server/auth/providers/db/db.factor @@ -1,42 +1,42 @@ -! Copyright (C) 2008 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: db db.tuples db.types accessors -http.server.auth.providers kernel continuations -singleton ; -IN: http.server.auth.providers.db - -user "USERS" -{ - { "username" "USERNAME" { VARCHAR 256 } +assigned-id+ } - { "realname" "REALNAME" { VARCHAR 256 } } - { "password" "PASSWORD" { VARCHAR 256 } +not-null+ } - { "email" "EMAIL" { VARCHAR 256 } } - { "ticket" "TICKET" { VARCHAR 256 } } - { "profile" "PROFILE" FACTOR-BLOB } -} define-persistent - -: init-users-table user ensure-table ; - -SINGLETON: users-in-db - -: find-user ( username -- user ) - <user> - swap >>username - select-tuple ; - -M: users-in-db get-user - drop - find-user ; - -M: users-in-db new-user - drop - [ - dup username>> find-user [ - drop f - ] [ - dup insert-tuple - ] if - ] with-transaction ; - -M: users-in-db update-user - drop update-tuple ; +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: db db.tuples db.types accessors +http.server.auth.providers kernel continuations +classes.singleton ; +IN: http.server.auth.providers.db + +user "USERS" +{ + { "username" "USERNAME" { VARCHAR 256 } +assigned-id+ } + { "realname" "REALNAME" { VARCHAR 256 } } + { "password" "PASSWORD" { VARCHAR 256 } +not-null+ } + { "email" "EMAIL" { VARCHAR 256 } } + { "ticket" "TICKET" { VARCHAR 256 } } + { "profile" "PROFILE" FACTOR-BLOB } +} define-persistent + +: init-users-table user ensure-table ; + +SINGLETON: users-in-db + +: find-user ( username -- user ) + <user> + swap >>username + select-tuple ; + +M: users-in-db get-user + drop + find-user ; + +M: users-in-db new-user + drop + [ + dup username>> find-user [ + drop f + ] [ + dup insert-tuple + ] if + ] with-transaction ; + +M: users-in-db update-user + drop update-tuple ; diff --git a/extra/http/server/sessions/storage/db/db.factor b/extra/http/server/sessions/storage/db/db.factor index 471b7fa6df..e573b22ba1 100755 --- a/extra/http/server/sessions/storage/db/db.factor +++ b/extra/http/server/sessions/storage/db/db.factor @@ -1,46 +1,46 @@ -! Copyright (C) 2008 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: assocs accessors http.server.sessions.storage -alarms kernel http.server db.tuples db.types singleton -math.parser ; -IN: http.server.sessions.storage.db - -SINGLETON: sessions-in-db - -TUPLE: session id namespace ; - -session "SESSIONS" -{ - { "id" "ID" INTEGER +native-id+ } - { "namespace" "NAMESPACE" FACTOR-BLOB } -} define-persistent - -: init-sessions-table session ensure-table ; - -: <session> ( id -- session ) - session construct-empty - swap dup [ string>number ] when >>id ; - -M: sessions-in-db get-session ( id storage -- namespace/f ) - drop - dup [ - <session> - select-tuple dup [ namespace>> ] when - ] when ; - -M: sessions-in-db update-session ( namespace id storage -- ) - drop - <session> - swap >>namespace - update-tuple ; - -M: sessions-in-db delete-session ( id storage -- ) - drop - <session> - delete-tuple ; - -M: sessions-in-db new-session ( namespace storage -- id ) - drop - f <session> - swap >>namespace - [ insert-tuple ] [ id>> number>string ] bi ; +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: assocs accessors http.server.sessions.storage +alarms kernel http.server db.tuples db.types math.parser +classes.singleton ; +IN: http.server.sessions.storage.db + +SINGLETON: sessions-in-db + +TUPLE: session id namespace ; + +session "SESSIONS" +{ + { "id" "ID" INTEGER +native-id+ } + { "namespace" "NAMESPACE" FACTOR-BLOB } +} define-persistent + +: init-sessions-table session ensure-table ; + +: <session> ( id -- session ) + session construct-empty + swap dup [ string>number ] when >>id ; + +M: sessions-in-db get-session ( id storage -- namespace/f ) + drop + dup [ + <session> + select-tuple dup [ namespace>> ] when + ] when ; + +M: sessions-in-db update-session ( namespace id storage -- ) + drop + <session> + swap >>namespace + update-tuple ; + +M: sessions-in-db delete-session ( id storage -- ) + drop + <session> + delete-tuple ; + +M: sessions-in-db new-session ( namespace storage -- id ) + drop + f <session> + swap >>namespace + [ insert-tuple ] [ id>> number>string ] bi ; From 23768dd482037e93cc4764d3bbbfc9eb31e496a7 Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Tue, 1 Apr 2008 17:06:36 -0500 Subject: [PATCH 5/5] remove singleton? from sequences.lib fix bootstrap error --- extra/math/polynomials/polynomials.factor | 2 +- extra/math/text/english/english.factor | 2 +- extra/random/unix/unix.factor | 2 +- extra/sequences/lib/lib-tests.factor | 3 --- extra/sequences/lib/lib.factor | 3 --- 5 files changed, 3 insertions(+), 9 deletions(-) diff --git a/extra/math/polynomials/polynomials.factor b/extra/math/polynomials/polynomials.factor index d6ac71e629..0b0d3520ef 100644 --- a/extra/math/polynomials/polynomials.factor +++ b/extra/math/polynomials/polynomials.factor @@ -22,7 +22,7 @@ PRIVATE> : p= ( p p -- ? ) pextend = ; : ptrim ( p -- p ) - dup singleton? [ [ zero? ] right-trim ] unless ; + dup length 1 = [ [ zero? ] right-trim ] unless ; : 2ptrim ( p p -- p p ) [ ptrim ] bi@ ; : p+ ( p p -- p ) pextend v+ ; diff --git a/extra/math/text/english/english.factor b/extra/math/text/english/english.factor index b77ac725ab..cba8c28310 100755 --- a/extra/math/text/english/english.factor +++ b/extra/math/text/english/english.factor @@ -79,7 +79,7 @@ SYMBOL: and-needed? ] if ; : recombine ( seq -- str ) - dup singleton? [ + dup length 1 = [ first 3digits>text ] [ dup set-conjunction "" swap diff --git a/extra/random/unix/unix.factor b/extra/random/unix/unix.factor index f3f55007f0..3be2697bdf 100644 --- a/extra/random/unix/unix.factor +++ b/extra/random/unix/unix.factor @@ -1,5 +1,5 @@ USING: alien.c-types io io.files io.nonblocking kernel -namespaces random io.encodings.binary singleton init +namespaces random io.encodings.binary init accessors system ; IN: random.unix diff --git a/extra/sequences/lib/lib-tests.factor b/extra/sequences/lib/lib-tests.factor index 6e6a924382..99565e966c 100755 --- a/extra/sequences/lib/lib-tests.factor +++ b/extra/sequences/lib/lib-tests.factor @@ -46,9 +46,6 @@ IN: sequences.lib.tests [ { 1 -1 5 2 4 } [ < ] monotonic-split [ >array ] map ] unit-test [ { { 1 1 1 1 } { 2 2 } { 3 } { 4 } { 5 } { 6 6 6 } } ] [ { 1 1 1 1 2 2 3 4 5 6 6 6 } [ = ] monotonic-split [ >array ] map ] unit-test -[ f ] [ { } singleton? ] unit-test -[ t ] [ { "asdf" } singleton? ] unit-test -[ f ] [ { "asdf" "bsdf" } singleton? ] unit-test [ 2 ] [ V{ 10 20 30 } [ delete-random drop ] keep length ] unit-test [ V{ } [ delete-random drop ] keep length ] must-fail diff --git a/extra/sequences/lib/lib.factor b/extra/sequences/lib/lib.factor index d246b16b8d..945ba1a3b7 100755 --- a/extra/sequences/lib/lib.factor +++ b/extra/sequences/lib/lib.factor @@ -98,9 +98,6 @@ MACRO: firstn ( n -- ) v, [ pick ,, call [ v, ] unless ] curry 2each ,v ] { } make ; -: singleton? ( seq -- ? ) - length 1 = ; - : delete-random ( seq -- value ) [ length random ] keep [ nth ] 2keep delete-nth ;