Merge branch 'master' of git://factorcode.org/git/factor
commit
6d296b6504
|
@ -35,6 +35,7 @@ $nl
|
||||||
"You can ask a class for its superclass:"
|
"You can ask a class for its superclass:"
|
||||||
{ $subsection superclass }
|
{ $subsection superclass }
|
||||||
{ $subsection superclasses }
|
{ $subsection superclasses }
|
||||||
|
{ $subsection subclass-of? }
|
||||||
"Class predicates can be used to test instances directly:"
|
"Class predicates can be used to test instances directly:"
|
||||||
{ $subsection "class-predicates" }
|
{ $subsection "class-predicates" }
|
||||||
"There is a universal class which all objects are an instance of, and an empty class with no instances:"
|
"There is a universal class which all objects are an instance of, and an empty class with no instances:"
|
||||||
|
@ -102,7 +103,21 @@ HELP: superclasses
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
{ superclass superclasses } related-words
|
HELP: subclass-of?
|
||||||
|
{ $values
|
||||||
|
{ "class" class }
|
||||||
|
{ "superclass" class }
|
||||||
|
{ "?" boolean }
|
||||||
|
}
|
||||||
|
{ $description "Outputs a boolean value indicating whether " { $snippet "class" } " is at any level a subclass of " { $snippet "superclass" } "." }
|
||||||
|
{ $examples
|
||||||
|
{ $example "USING: classes classes.tuple prettyprint words ;"
|
||||||
|
"tuple-class \\ class subclass-of? ."
|
||||||
|
"t"
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
{ superclass superclasses subclass-of? } related-words
|
||||||
|
|
||||||
HELP: members
|
HELP: members
|
||||||
{ $values { "class" class } { "seq" "a sequence of union members, or " { $link f } } }
|
{ $values { "class" class } { "seq" "a sequence of union members, or " { $link f } } }
|
||||||
|
|
|
@ -59,6 +59,9 @@ M: predicate reset-word
|
||||||
: superclasses ( class -- supers )
|
: superclasses ( class -- supers )
|
||||||
[ superclass ] follow reverse ;
|
[ superclass ] follow reverse ;
|
||||||
|
|
||||||
|
: subclass-of? ( class superclass -- ? )
|
||||||
|
swap superclasses member? ;
|
||||||
|
|
||||||
: members ( class -- seq )
|
: members ( class -- seq )
|
||||||
#! Output f for non-classes to work with algebra code
|
#! Output f for non-classes to work with algebra code
|
||||||
dup class? [ "members" word-prop ] [ drop f ] if ;
|
dup class? [ "members" word-prop ] [ drop f ] if ;
|
||||||
|
|
|
@ -23,6 +23,24 @@ HELP: file-name
|
||||||
{ $example "USING: io.pathnames prettyprint ;" "\"/usr/libexec/awk/\" file-name ." "\"awk\"" }
|
{ $example "USING: io.pathnames prettyprint ;" "\"/usr/libexec/awk/\" file-name ." "\"awk\"" }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
HELP: file-extension
|
||||||
|
{ $values { "path" "a pathname string" } { "extension" string } }
|
||||||
|
{ $description "Outputs the extension of " { $snippet "path" } ", or " { $link f } " if the filename has no extension." }
|
||||||
|
{ $examples
|
||||||
|
{ $example "USING: io.pathnames prettyprint ;" "\"/usr/bin/gcc\" file-extension ." "f" }
|
||||||
|
{ $example "USING: io.pathnames prettyprint ;" "\"/home/csi/gui.vbs\" file-extension ." "\"vbs\"" }
|
||||||
|
} ;
|
||||||
|
|
||||||
|
HELP: file-stem
|
||||||
|
{ $values { "path" "a pathname string" } { "stem" string } }
|
||||||
|
{ $description "Outputs the " { $link file-name } " of " { $snippet "filename" } " with the file extension removed, if any." }
|
||||||
|
{ $examples
|
||||||
|
{ $example "USING: io.pathnames prettyprint ;" "\"/usr/bin/gcc\" file-stem ." "\"gcc\"" }
|
||||||
|
{ $example "USING: io.pathnames prettyprint ;" "\"/home/csi/gui.vbs\" file-stem ." "\"gui\"" }
|
||||||
|
} ;
|
||||||
|
|
||||||
|
{ file-name file-stem file-extension } related-words
|
||||||
|
|
||||||
HELP: path-components
|
HELP: path-components
|
||||||
{ $values { "path" "a pathnames string" } { "seq" sequence } }
|
{ $values { "path" "a pathnames string" } { "seq" sequence } }
|
||||||
{ $description "Splits a pathname on the " { $link path-separator } " into its its component strings." } ;
|
{ $description "Splits a pathname on the " { $link path-separator } " into its its component strings." } ;
|
||||||
|
@ -86,6 +104,8 @@ ARTICLE: "io.pathnames" "Pathname manipulation"
|
||||||
"Pathname manipulation:"
|
"Pathname manipulation:"
|
||||||
{ $subsection parent-directory }
|
{ $subsection parent-directory }
|
||||||
{ $subsection file-name }
|
{ $subsection file-name }
|
||||||
|
{ $subsection file-stem }
|
||||||
|
{ $subsection file-extension }
|
||||||
{ $subsection last-path-separator }
|
{ $subsection last-path-separator }
|
||||||
{ $subsection path-components }
|
{ $subsection path-components }
|
||||||
{ $subsection prepend-path }
|
{ $subsection prepend-path }
|
||||||
|
|
|
@ -118,7 +118,10 @@ PRIVATE>
|
||||||
] if
|
] if
|
||||||
] unless ;
|
] unless ;
|
||||||
|
|
||||||
: file-extension ( filename -- extension )
|
: file-stem ( path -- stem )
|
||||||
|
file-name "." split1-last drop ;
|
||||||
|
|
||||||
|
: file-extension ( path -- extension )
|
||||||
file-name "." split1-last nip ;
|
file-name "." split1-last nip ;
|
||||||
|
|
||||||
: path-components ( path -- seq )
|
: path-components ( path -- seq )
|
||||||
|
|
|
@ -26,8 +26,10 @@ PREDICATE: writer-method < method-body "writing" word-prop ;
|
||||||
[ drop define ]
|
[ drop define ]
|
||||||
3bi ;
|
3bi ;
|
||||||
|
|
||||||
: reader-quot ( slot-spec -- quot )
|
GENERIC# reader-quot 1 ( class slot-spec -- quot )
|
||||||
[
|
|
||||||
|
M: object reader-quot
|
||||||
|
nip [
|
||||||
dup offset>> ,
|
dup offset>> ,
|
||||||
\ slot ,
|
\ slot ,
|
||||||
dup class>> object bootstrap-word eq?
|
dup class>> object bootstrap-word eq?
|
||||||
|
@ -51,8 +53,12 @@ PREDICATE: writer-method < method-body "writing" word-prop ;
|
||||||
: define-reader ( class slot-spec -- )
|
: define-reader ( class slot-spec -- )
|
||||||
[ nip name>> define-reader-generic ]
|
[ nip name>> define-reader-generic ]
|
||||||
[
|
[
|
||||||
[ name>> reader-word ] [ reader-quot ] [ reader-props ] tri
|
{
|
||||||
define-typecheck
|
[ drop ]
|
||||||
|
[ nip name>> reader-word ]
|
||||||
|
[ reader-quot ]
|
||||||
|
[ nip reader-props ]
|
||||||
|
} 2cleave define-typecheck
|
||||||
] 2bi ;
|
] 2bi ;
|
||||||
|
|
||||||
: writer-word ( name -- word )
|
: writer-word ( name -- word )
|
||||||
|
@ -83,8 +89,10 @@ ERROR: bad-slot-value value class ;
|
||||||
: writer-quot/fixnum ( slot-spec -- )
|
: writer-quot/fixnum ( slot-spec -- )
|
||||||
[ [ >fixnum ] dip ] % writer-quot/check ;
|
[ [ >fixnum ] dip ] % writer-quot/check ;
|
||||||
|
|
||||||
: writer-quot ( slot-spec -- quot )
|
GENERIC# writer-quot 1 ( class slot-spec -- quot )
|
||||||
[
|
|
||||||
|
M: object writer-quot
|
||||||
|
nip [
|
||||||
{
|
{
|
||||||
{ [ dup class>> object bootstrap-word eq? ] [ writer-quot/object ] }
|
{ [ dup class>> object bootstrap-word eq? ] [ writer-quot/object ] }
|
||||||
{ [ dup class>> "coercer" word-prop ] [ writer-quot/coerce ] }
|
{ [ dup class>> "coercer" word-prop ] [ writer-quot/coerce ] }
|
||||||
|
@ -101,8 +109,12 @@ ERROR: bad-slot-value value class ;
|
||||||
|
|
||||||
: define-writer ( class slot-spec -- )
|
: define-writer ( class slot-spec -- )
|
||||||
[ nip name>> define-writer-generic ] [
|
[ nip name>> define-writer-generic ] [
|
||||||
[ name>> writer-word ] [ writer-quot ] [ writer-props ] tri
|
{
|
||||||
define-typecheck
|
[ drop ]
|
||||||
|
[ nip name>> writer-word ]
|
||||||
|
[ writer-quot ]
|
||||||
|
[ nip writer-props ]
|
||||||
|
} 2cleave define-typecheck
|
||||||
] 2bi ;
|
] 2bi ;
|
||||||
|
|
||||||
: setter-word ( name -- word )
|
: setter-word ( name -- word )
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Joe Groff
|
|
@ -0,0 +1,10 @@
|
||||||
|
USING: classes.tuple.change-tracking tools.test ;
|
||||||
|
IN: classes.tuple.change-tracking.tests
|
||||||
|
|
||||||
|
TUPLE: resource < change-tracking-tuple
|
||||||
|
{ pathname string } ;
|
||||||
|
|
||||||
|
: <resource> ( pathname -- resource ) f swap resource boa ;
|
||||||
|
|
||||||
|
[ t ] [ "foo" <resource> "bar" >>pathname changed?>> ] unit-test
|
||||||
|
[ f ] [ "foo" <resource> [ 123 >>pathname ] [ drop ] recover changed?>> ] unit-test
|
|
@ -0,0 +1,23 @@
|
||||||
|
! (c)2009 Joe Groff bsd license
|
||||||
|
USING: accessors classes classes.tuple fry kernel sequences slots ;
|
||||||
|
IN: classes.tuple.change-tracking
|
||||||
|
|
||||||
|
TUPLE: change-tracking-tuple
|
||||||
|
{ changed? boolean } ;
|
||||||
|
|
||||||
|
PREDICATE: change-tracking-tuple-class < tuple-class
|
||||||
|
change-tracking-tuple subclass-of? ;
|
||||||
|
|
||||||
|
: changed? ( tuple -- changed? ) changed?>> ; inline
|
||||||
|
: clear-changed ( tuple -- tuple ) f >>changed? ; inline
|
||||||
|
|
||||||
|
: filter-changed ( sequence -- sequence' ) [ changed? ] filter ; inline
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
|
M: change-tracking-tuple-class writer-quot ( class slot-spec -- )
|
||||||
|
[ call-next-method ]
|
||||||
|
[ name>> "changed?" = [ '[ _ [ t >>changed? drop ] bi ] ] unless ] bi ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Tuple classes that keep track of when they've been modified
|
|
@ -221,7 +221,7 @@ BEFORE: bunny-world begin-world
|
||||||
bunny-uniforms boa ;
|
bunny-uniforms boa ;
|
||||||
|
|
||||||
: draw-bunny ( world -- )
|
: draw-bunny ( world -- )
|
||||||
T{ depth-state { comparison cmp-less } } set-gpu-state*
|
T{ depth-state { comparison cmp-less } } set-gpu-state
|
||||||
|
|
||||||
[
|
[
|
||||||
sobel>> framebuffer>> {
|
sobel>> framebuffer>> {
|
||||||
|
@ -247,7 +247,7 @@ BEFORE: bunny-world begin-world
|
||||||
sobel-uniforms boa ;
|
sobel-uniforms boa ;
|
||||||
|
|
||||||
: draw-sobel ( world -- )
|
: draw-sobel ( world -- )
|
||||||
T{ depth-state { comparison f } } set-gpu-state*
|
T{ depth-state { comparison f } } set-gpu-state
|
||||||
|
|
||||||
sobel>> {
|
sobel>> {
|
||||||
{ "primitive-mode" [ drop triangle-strip-mode ] }
|
{ "primitive-mode" [ drop triangle-strip-mode ] }
|
||||||
|
@ -260,7 +260,7 @@ BEFORE: bunny-world begin-world
|
||||||
[ draw-bunny ] [ draw-sobel ] bi ;
|
[ draw-bunny ] [ draw-sobel ] bi ;
|
||||||
|
|
||||||
: draw-loading ( world -- )
|
: draw-loading ( world -- )
|
||||||
T{ depth-state { comparison f } } set-gpu-state*
|
T{ depth-state { comparison f } } set-gpu-state
|
||||||
|
|
||||||
loading>> {
|
loading>> {
|
||||||
{ "primitive-mode" [ drop triangle-strip-mode ] }
|
{ "primitive-mode" [ drop triangle-strip-mode ] }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
! (c)2009 Joe Groff bsd license
|
! (c)2009 Joe Groff bsd license
|
||||||
USING: byte-arrays classes gpu.buffers help.markup help.syntax
|
USING: alien byte-arrays classes gpu.buffers help.markup help.syntax
|
||||||
images kernel math ;
|
images kernel math ;
|
||||||
IN: gpu.textures
|
IN: gpu.textures
|
||||||
|
|
||||||
|
@ -228,7 +228,11 @@ HELP: texture-cube-map
|
||||||
{ texture-cube-map <texture-cube-map> } related-words
|
{ texture-cube-map <texture-cube-map> } related-words
|
||||||
|
|
||||||
HELP: texture-data
|
HELP: texture-data
|
||||||
{ $class-description { $snippet "texture-data" } " tuples are used to feed image data to " { $link allocate-texture } " and " { $link update-texture } ". In addition to providing a " { $snippet "ptr" } " to CPU memory or a GPU " { $link buffer-ptr } ", the " { $link texture-data } " object also specifies the " { $link component-order } " and " { $link component-type } " of the referenced data." }
|
{ $class-description { $snippet "texture-data" } " tuples are used to feed image data to " { $link allocate-texture } " and " { $link update-texture } "."
|
||||||
|
{ $list
|
||||||
|
{ "The " { $snippet "ptr" } " slot references either CPU memory (as a " { $link byte-array } " or " { $link alien } ") or a GPU " { $link buffer-ptr } " that contains the image data." }
|
||||||
|
{ "The " { $snippet "component-order" } " and " { $snippet "component-type" } " slots determine the " { $link component-order } " and " { $link component-type } " of the referenced data." }
|
||||||
|
} }
|
||||||
{ $notes "Using a " { $link buffer-ptr } " as the " { $snippet "ptr" } " of a " { $snippet "texture-data" } " object requires OpenGL 2.1 or later or the " { $snippet "GL_ARB_pixel_buffer_object" } " extension." } ;
|
{ $notes "Using a " { $link buffer-ptr } " as the " { $snippet "ptr" } " of a " { $snippet "texture-data" } " object requires OpenGL 2.1 or later or the " { $snippet "GL_ARB_pixel_buffer_object" } " extension." } ;
|
||||||
|
|
||||||
{ texture-data <texture-data> } related-words
|
{ texture-data <texture-data> } related-words
|
||||||
|
@ -254,15 +258,15 @@ HELP: texture-filter
|
||||||
{ $class-description { $snippet "texture-filter" } " values are used in a " { $link texture-parameters } " tuple to determine how a texture should be sampled between pixels or between levels of detail. " { $link filter-linear } " selects linear filtering, while " { $link filter-nearest } " selects nearest-neighbor sampling." } ;
|
{ $class-description { $snippet "texture-filter" } " values are used in a " { $link texture-parameters } " tuple to determine how a texture should be sampled between pixels or between levels of detail. " { $link filter-linear } " selects linear filtering, while " { $link filter-nearest } " selects nearest-neighbor sampling." } ;
|
||||||
|
|
||||||
HELP: texture-parameters
|
HELP: texture-parameters
|
||||||
{ $class-description "When a " { $link texture } " is created, the following " { $snippet "texture-parameter" } "s are set to control how the texture is sampled:"
|
{ $class-description "A " { $snippet "texture-parameters" } " tuple is supplied when constructing a " { $link texture } " to control the wrapping, filtering, and level-of-detail handling of the texture. These tuples have the following slots:"
|
||||||
{ $list
|
{ $list
|
||||||
{ "The " { $snippet "wrap" } " slot determines how texture coordinates outside the 0.0 to 1.0 range are mapped to the texture image. The slot either contains a single " { $link texture-wrap } " value, which will apply to all three axes, or a sequence of up to three values, which will apply to the S, T, and R axes, respectively." }
|
{ "The " { $snippet "wrap" } " slot determines how texture coordinates outside the 0.0 to 1.0 range are mapped to the texture image. The slot either contains a single " { $link texture-wrap } " value, which will apply to all three axes, or a sequence of up to three values, which will apply to the S, T, and R axes, respectively." }
|
||||||
{ "The " { $snippet "min-filter" } " and " { $snippet "min-mipmap-filter" } " determine how the texture image is filtered when sampled below its highest level of detail, the former controlling filtering between pixels within a level of detail and the latter filtering between levels of detail. A setting of " { $link filter-linear } " uses linear, bilinear, or trilinear filtering among sampled pixels, while a setting of " { $link filter-nearest } " uses nearest-neighbor sampling. The " { $snippet "min-mipmap-filter" } " slot may additionally be set to " { $link f } " to disable mipmapping and only sample the highest level of detail." }
|
{ "The " { $snippet "min-filter" } " and " { $snippet "min-mipmap-filter" } " determine how the texture image is filtered when sampled below its highest level of detail, the former filtering between pixels within a level of detail and the latter filtering between levels of detail. A setting of " { $link filter-linear } " uses linear, bilinear, or trilinear filtering among the sampled pixels, while a setting of " { $link filter-nearest } " uses nearest-neighbor sampling. The " { $snippet "min-mipmap-filter" } " slot may additionally be set to " { $link f } " to disable mipmapping and only sample the highest level of detail." }
|
||||||
{ "The " { $snippet "mag-filter" } " analogously determines how the texture image is filtered when sampled above its highest level of detail." }
|
{ "The " { $snippet "mag-filter" } " analogously determines how the texture image is filtered when sampled above its highest level of detail." }
|
||||||
{ "The " { $snippet "min-lod" } " and " { $snippet "max-lod" } " slots contain integer values that will clamp the range of levels of detail that will be sampled from the texture." }
|
{ "The " { $snippet "min-lod" } " and " { $snippet "max-lod" } " slots contain integer values that will clamp the range of levels of detail that will be sampled from the texture." }
|
||||||
{ "The " { $snippet "lod-bias" } " slot contains an integer value that will offset the levels of detail that would normally be sampled from the texture." }
|
{ "The " { $snippet "lod-bias" } " slot contains an integer value that will offset the levels of detail that would normally be sampled from the texture." }
|
||||||
{ "The " { $snippet "base-level" } " slot contains an integer value that identifies the highest level of detail for the image, typically zero." }
|
{ "The " { $snippet "base-level" } " slot contains an integer value that identifies the highest level of detail for the image, typically zero." }
|
||||||
{ "The " { $snippet "max-level" } " slot contains an integer value that identifies the lowest level of detail for the image. This value will automatically be clamped to the maximum of the base-2 logarithm of the dimensions of the highest level of detail image." }
|
{ "The " { $snippet "max-level" } " slot contains an integer value that identifies the lowest level of detail for the image. This value will automatically be clamped to the maximum of the base-2 logarithms of the dimensions of the highest level of detail image." }
|
||||||
} } ;
|
} } ;
|
||||||
|
|
||||||
{ texture-parameters set-texture-parameters } related-words
|
{ texture-parameters set-texture-parameters } related-words
|
||||||
|
|
|
@ -26,14 +26,14 @@ TUPLE: cube-map-face
|
||||||
{ axis cube-map-axis read-only } ;
|
{ axis cube-map-axis read-only } ;
|
||||||
C: <cube-map-face> cube-map-face
|
C: <cube-map-face> cube-map-face
|
||||||
|
|
||||||
UNION: texture-data-target
|
|
||||||
texture-1d texture-2d texture-3d cube-map-face ;
|
|
||||||
UNION: texture-1d-data-target
|
UNION: texture-1d-data-target
|
||||||
texture-1d ;
|
texture-1d ;
|
||||||
UNION: texture-2d-data-target
|
UNION: texture-2d-data-target
|
||||||
texture-2d texture-rectangle texture-1d-array cube-map-face ;
|
texture-2d texture-rectangle texture-1d-array cube-map-face ;
|
||||||
UNION: texture-3d-data-target
|
UNION: texture-3d-data-target
|
||||||
texture-3d texture-2d-array ;
|
texture-3d texture-2d-array ;
|
||||||
|
UNION: texture-data-target
|
||||||
|
texture-1d-data-target texture-2d-data-target texture-3d-data-target ;
|
||||||
|
|
||||||
M: texture dispose
|
M: texture dispose
|
||||||
[ [ delete-texture ] when* f ] change-handle drop ;
|
[ [ delete-texture ] when* f ] change-handle drop ;
|
||||||
|
|
Loading…
Reference in New Issue