core: rename MIXIN:
parent
99ed27a833
commit
7226b2b45d
|
@ -115,7 +115,7 @@ GENERIC: heap-size ( name -- size )
|
||||||
|
|
||||||
M: abstract-c-type heap-size size>> ;
|
M: abstract-c-type heap-size size>> ;
|
||||||
|
|
||||||
MIXIN: value-type
|
mixin: value-type
|
||||||
|
|
||||||
MACRO: alien-value ( c-type -- quot: ( c-ptr offset -- value ) )
|
MACRO: alien-value ( c-type -- quot: ( c-ptr offset -- value ) )
|
||||||
[ c-type-getter ] [ c-type-boxer-quot ] bi append ;
|
[ c-type-getter ] [ c-type-boxer-quot ] bi append ;
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: accessors arrays kernel math sequences sequences.private
|
||||||
vectors ;
|
vectors ;
|
||||||
in: assocs
|
in: assocs
|
||||||
|
|
||||||
MIXIN: assoc
|
mixin: assoc
|
||||||
|
|
||||||
GENERIC: at* ( key assoc -- value/f ? )
|
GENERIC: at* ( key assoc -- value/f ? )
|
||||||
GENERIC: value-at* ( value assoc -- key/f ? )
|
GENERIC: value-at* ( value assoc -- key/f ? )
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: accessors byte-arrays byte-vectors io io.backend io.files
|
||||||
kernel math math.parser sequences ;
|
kernel math math.parser sequences ;
|
||||||
in: checksums
|
in: checksums
|
||||||
|
|
||||||
MIXIN: checksum
|
mixin: checksum
|
||||||
|
|
||||||
TUPLE: checksum-state
|
TUPLE: checksum-state
|
||||||
{ bytes-read integer }
|
{ bytes-read integer }
|
||||||
|
|
|
@ -36,7 +36,7 @@ INTERSECTION: generic-class generic class ;
|
||||||
|
|
||||||
UNION: union-with-one-member a ;
|
UNION: union-with-one-member a ;
|
||||||
|
|
||||||
MIXIN: mixin-with-one-member
|
mixin: mixin-with-one-member
|
||||||
INSTANCE: union-with-one-member mixin-with-one-member
|
INSTANCE: union-with-one-member mixin-with-one-member
|
||||||
|
|
||||||
! class<=
|
! class<=
|
||||||
|
@ -127,7 +127,7 @@ INSTANCE: union-with-one-member mixin-with-one-member
|
||||||
{ t } [ a union-with-one-member class<= ] unit-test
|
{ t } [ a union-with-one-member class<= ] unit-test
|
||||||
{ f } [ union-with-one-member class-not integer class<= ] unit-test
|
{ f } [ union-with-one-member class-not integer class<= ] unit-test
|
||||||
|
|
||||||
MIXIN: empty-mixin
|
mixin: empty-mixin
|
||||||
|
|
||||||
{ f } [ empty-mixin class-not null class<= ] unit-test
|
{ f } [ empty-mixin class-not null class<= ] unit-test
|
||||||
{ f } [ empty-mixin null class<= ] unit-test
|
{ f } [ empty-mixin null class<= ] unit-test
|
||||||
|
|
|
@ -10,7 +10,7 @@ PREDICATE: class < word "class" word-prop ;
|
||||||
|
|
||||||
PREDICATE: defining-class < word "defining-class" word-prop ;
|
PREDICATE: defining-class < word "defining-class" word-prop ;
|
||||||
|
|
||||||
MIXIN: classoid
|
mixin: classoid
|
||||||
INSTANCE: class classoid
|
INSTANCE: class classoid
|
||||||
INSTANCE: defining-class classoid
|
INSTANCE: defining-class classoid
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ in: classes.intersection.tests
|
||||||
|
|
||||||
TUPLE: a ;
|
TUPLE: a ;
|
||||||
TUPLE: a1 < a ; TUPLE: a2 < a ; TUPLE: a3 < a2 ;
|
TUPLE: a1 < a ; TUPLE: a2 < a ; TUPLE: a3 < a2 ;
|
||||||
MIXIN: b
|
mixin: b
|
||||||
INSTANCE: a3 b
|
INSTANCE: a3 b
|
||||||
INSTANCE: a1 b
|
INSTANCE: a1 b
|
||||||
INTERSECTION: c a2 b ;
|
INTERSECTION: c a2 b ;
|
||||||
|
|
|
@ -5,13 +5,13 @@ vectors words ;
|
||||||
in: classes.mixin.tests
|
in: classes.mixin.tests
|
||||||
|
|
||||||
! Test mixins
|
! Test mixins
|
||||||
MIXIN: sequence-mixin
|
mixin: sequence-mixin
|
||||||
|
|
||||||
INSTANCE: array sequence-mixin
|
INSTANCE: array sequence-mixin
|
||||||
INSTANCE: vector sequence-mixin
|
INSTANCE: vector sequence-mixin
|
||||||
INSTANCE: slice sequence-mixin
|
INSTANCE: slice sequence-mixin
|
||||||
|
|
||||||
MIXIN: assoc-mixin
|
mixin: assoc-mixin
|
||||||
|
|
||||||
INSTANCE: hashtable assoc-mixin
|
INSTANCE: hashtable assoc-mixin
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ M: assoc-mixin collection-size assoc-size ;
|
||||||
DEFER: mx1
|
DEFER: mx1
|
||||||
FORGET: mx1
|
FORGET: mx1
|
||||||
|
|
||||||
MIXIN: mx1
|
mixin: mx1
|
||||||
|
|
||||||
INSTANCE: integer mx1
|
INSTANCE: integer mx1
|
||||||
|
|
||||||
|
@ -84,12 +84,12 @@ use: io.streams.string
|
||||||
] times
|
] times
|
||||||
|
|
||||||
! Method flattening interfered with mixin update
|
! Method flattening interfered with mixin update
|
||||||
MIXIN: flat-mx-1
|
mixin: flat-mx-1
|
||||||
TUPLE: flat-mx-1-1 ; INSTANCE: flat-mx-1-1 flat-mx-1
|
TUPLE: flat-mx-1-1 ; INSTANCE: flat-mx-1-1 flat-mx-1
|
||||||
TUPLE: flat-mx-1-2 ; INSTANCE: flat-mx-1-2 flat-mx-1
|
TUPLE: flat-mx-1-2 ; INSTANCE: flat-mx-1-2 flat-mx-1
|
||||||
TUPLE: flat-mx-1-3 ; INSTANCE: flat-mx-1-3 flat-mx-1
|
TUPLE: flat-mx-1-3 ; INSTANCE: flat-mx-1-3 flat-mx-1
|
||||||
TUPLE: flat-mx-1-4 ; INSTANCE: flat-mx-1-4 flat-mx-1
|
TUPLE: flat-mx-1-4 ; INSTANCE: flat-mx-1-4 flat-mx-1
|
||||||
MIXIN: flat-mx-2 INSTANCE: flat-mx-2 flat-mx-1
|
mixin: flat-mx-2 INSTANCE: flat-mx-2 flat-mx-1
|
||||||
TUPLE: flat-mx-2-1 ; INSTANCE: flat-mx-2-1 flat-mx-2
|
TUPLE: flat-mx-2-1 ; INSTANCE: flat-mx-2-1 flat-mx-2
|
||||||
|
|
||||||
{ t } [ T{ flat-mx-2-1 } flat-mx-1? ] unit-test
|
{ t } [ T{ flat-mx-2-1 } flat-mx-1? ] unit-test
|
||||||
|
@ -104,11 +104,11 @@ TUPLE: flat-mx-2-1 ; INSTANCE: flat-mx-2-1 flat-mx-2
|
||||||
|
|
||||||
{ t } [ "blah" "classes.mixin.tests" lookup-word mixin-class? ] unit-test
|
{ t } [ "blah" "classes.mixin.tests" lookup-word mixin-class? ] unit-test
|
||||||
|
|
||||||
MIXIN: empty-mixin
|
mixin: empty-mixin
|
||||||
|
|
||||||
{ f } [ "hi" empty-mixin? ] unit-test
|
{ f } [ "hi" empty-mixin? ] unit-test
|
||||||
|
|
||||||
MIXIN: move-instance-declaration-mixin
|
mixin: move-instance-declaration-mixin
|
||||||
|
|
||||||
{ } [ "IN: classes.mixin.tests.a USE: strings USE: classes.mixin.tests INSTANCE: string move-instance-declaration-mixin" <string-reader> "move-mixin-test-1" parse-stream drop ] unit-test
|
{ } [ "IN: classes.mixin.tests.a USE: strings USE: classes.mixin.tests INSTANCE: string move-instance-declaration-mixin" <string-reader> "move-mixin-test-1" parse-stream drop ] unit-test
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ MIXIN: move-instance-declaration-mixin
|
||||||
|
|
||||||
{ { string } } [ move-instance-declaration-mixin class-members ] unit-test
|
{ { string } } [ move-instance-declaration-mixin class-members ] unit-test
|
||||||
|
|
||||||
MIXIN: silly-mixin
|
mixin: silly-mixin
|
||||||
symbol: not-a-class
|
symbol: not-a-class
|
||||||
|
|
||||||
[ [ \ not-a-class \ silly-mixin add-mixin-instance ] with-compilation-unit ] must-fail
|
[ [ \ not-a-class \ silly-mixin add-mixin-instance ] with-compilation-unit ] must-fail
|
||||||
|
@ -129,7 +129,7 @@ TUPLE: a-class ;
|
||||||
[ [ \ a-class \ not-a-mixin add-mixin-instance ] with-compilation-unit ] must-fail
|
[ [ \ a-class \ not-a-mixin add-mixin-instance ] with-compilation-unit ] must-fail
|
||||||
|
|
||||||
! Changing a mixin member's metaclass should not remove it from the mixin
|
! Changing a mixin member's metaclass should not remove it from the mixin
|
||||||
MIXIN: metaclass-change-mixin
|
mixin: metaclass-change-mixin
|
||||||
TUPLE: metaclass-change ;
|
TUPLE: metaclass-change ;
|
||||||
INSTANCE: metaclass-change metaclass-change-mixin
|
INSTANCE: metaclass-change metaclass-change-mixin
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: accessors assocs kernel namespaces sequences sets ;
|
USING: accessors assocs kernel namespaces sequences sets ;
|
||||||
in: definitions
|
in: definitions
|
||||||
|
|
||||||
MIXIN: definition-mixin
|
mixin: definition-mixin
|
||||||
|
|
||||||
ERROR: no-compilation-unit definition ;
|
ERROR: no-compilation-unit definition ;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ M: callable count-inputs [ count-inputs ] map-sum ;
|
||||||
M: fry-specifier count-inputs drop 1 ;
|
M: fry-specifier count-inputs drop 1 ;
|
||||||
M: object count-inputs drop 0 ;
|
M: object count-inputs drop 0 ;
|
||||||
|
|
||||||
MIXIN: fried
|
mixin: fried
|
||||||
PREDICATE: fried-callable < callable
|
PREDICATE: fried-callable < callable
|
||||||
count-inputs 0 > ;
|
count-inputs 0 > ;
|
||||||
INSTANCE: fried-callable fried
|
INSTANCE: fried-callable fried
|
||||||
|
|
|
@ -503,7 +503,7 @@ M: amb-union-4 amb-generic-4 drop "4" ;
|
||||||
T{ amb-tuple-b f 3 } amb-tuple-b \ amb-generic-4 method-for-class execute( a -- b ) assert=
|
T{ amb-tuple-b f 3 } amb-tuple-b \ amb-generic-4 method-for-class execute( a -- b ) assert=
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
MIXIN: amb-mixin-5
|
mixin: amb-mixin-5
|
||||||
INSTANCE: amb-tuple-a amb-mixin-5
|
INSTANCE: amb-tuple-a amb-mixin-5
|
||||||
INSTANCE: amb-tuple-d amb-mixin-5
|
INSTANCE: amb-tuple-d amb-mixin-5
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ M: amb-union-6 amb-generic-6 drop "6" ;
|
||||||
T{ amb-tuple-b f 3 } amb-tuple-b \ amb-generic-6 method-for-class execute( a -- b ) assert=
|
T{ amb-tuple-b f 3 } amb-tuple-b \ amb-generic-6 method-for-class execute( a -- b ) assert=
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
MIXIN: amb-mixin-7
|
mixin: amb-mixin-7
|
||||||
INSTANCE: amb-tuple-b amb-mixin-7
|
INSTANCE: amb-tuple-b amb-mixin-7
|
||||||
INSTANCE: amb-tuple-d amb-mixin-7
|
INSTANCE: amb-tuple-d amb-mixin-7
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: accessors kernel math math.private sequences
|
||||||
sequences.private ;
|
sequences.private ;
|
||||||
in: growable
|
in: growable
|
||||||
|
|
||||||
MIXIN: growable
|
mixin: growable
|
||||||
|
|
||||||
SLOT: length
|
SLOT: length
|
||||||
SLOT: underlying
|
SLOT: underlying
|
||||||
|
|
|
@ -20,8 +20,8 @@ GENERIC: refill ( port handle -- event/f )
|
||||||
|
|
||||||
HOOK: wait-for-fd io-backend ( handle event -- )
|
HOOK: wait-for-fd io-backend ( handle event -- )
|
||||||
|
|
||||||
MIXIN: file-reader
|
mixin: file-reader
|
||||||
MIXIN: file-writer
|
mixin: file-writer
|
||||||
|
|
||||||
M: file-reader stream-element-type drop +byte+ ; inline
|
M: file-reader stream-element-type drop +byte+ ; inline
|
||||||
M: file-writer stream-element-type drop +byte+ ; inline
|
M: file-writer stream-element-type drop +byte+ ; inline
|
||||||
|
|
|
@ -34,8 +34,8 @@ GENERIC: stream-length ( stream -- n/f )
|
||||||
[ stream-write ] [ stream-nl ] bi ; inline
|
[ stream-write ] [ stream-nl ] bi ; inline
|
||||||
|
|
||||||
! Default streams
|
! Default streams
|
||||||
MIXIN: input-stream
|
mixin: input-stream
|
||||||
MIXIN: output-stream
|
mixin: output-stream
|
||||||
symbol: error-stream
|
symbol: error-stream
|
||||||
|
|
||||||
: readln ( -- str/f ) input-stream get stream-readln ; inline
|
: readln ( -- str/f ) input-stream get stream-readln ; inline
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: kernel io ;
|
USING: kernel io ;
|
||||||
in: io.streams.plain
|
in: io.streams.plain
|
||||||
|
|
||||||
MIXIN: plain-writer
|
mixin: plain-writer
|
||||||
|
|
||||||
M: plain-writer stream-nl
|
M: plain-writer stream-nl
|
||||||
CHAR: \n swap stream-write1 ;
|
CHAR: \n swap stream-write1 ;
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: accessors kernel kernel.private math math.order
|
||||||
math.private slots.private ;
|
math.private slots.private ;
|
||||||
in: sequences
|
in: sequences
|
||||||
|
|
||||||
MIXIN: sequence
|
mixin: sequence
|
||||||
|
|
||||||
GENERIC: length ( seq -- n ) flushable
|
GENERIC: length ( seq -- n ) flushable
|
||||||
GENERIC: set-length ( n seq -- )
|
GENERIC: set-length ( n seq -- )
|
||||||
|
@ -59,7 +59,7 @@ M: integer bounds-check? ( n seq -- ? )
|
||||||
: bounds-check ( n seq -- n seq )
|
: bounds-check ( n seq -- n seq )
|
||||||
2dup bounds-check? [ bounds-error ] unless ; inline
|
2dup bounds-check? [ bounds-error ] unless ; inline
|
||||||
|
|
||||||
MIXIN: immutable-sequence
|
mixin: immutable-sequence
|
||||||
|
|
||||||
ERROR: immutable element index sequence ;
|
ERROR: immutable element index sequence ;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ PRIVATE>
|
||||||
[ length 1 - ] keep over 0 <
|
[ length 1 - ] keep over 0 <
|
||||||
[ 2drop f ] [ nth-unsafe ] if ; inline
|
[ 2drop f ] [ nth-unsafe ] if ; inline
|
||||||
|
|
||||||
MIXIN: virtual-sequence
|
mixin: virtual-sequence
|
||||||
GENERIC: virtual-exemplar ( seq -- seq' )
|
GENERIC: virtual-exemplar ( seq -- seq' )
|
||||||
GENERIC: virtual@ ( n seq -- n' seq' )
|
GENERIC: virtual@ ( n seq -- n' seq' )
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: assocs hashtables kernel math sequences vectors ;
|
||||||
in: sets
|
in: sets
|
||||||
|
|
||||||
! Set protocol
|
! Set protocol
|
||||||
MIXIN: set
|
mixin: set
|
||||||
|
|
||||||
GENERIC: adjoin ( elt set -- )
|
GENERIC: adjoin ( elt set -- )
|
||||||
GENERIC: ?adjoin ( elt set -- ? )
|
GENERIC: ?adjoin ( elt set -- ? )
|
||||||
|
|
Loading…
Reference in New Issue