Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2009-05-01 02:44:50 -05:00
commit 3b840c652c
16 changed files with 95 additions and 49 deletions

1
Makefile Normal file → Executable file
View File

@ -10,7 +10,6 @@ VERSION = 0.92
BUNDLE = Factor.app BUNDLE = Factor.app
LIBPATH = -L/usr/X11R6/lib LIBPATH = -L/usr/X11R6/lib
CFLAGS = -Wall -Werror CFLAGS = -Wall -Werror
FFI_TEST_CFLAGS = -fPIC
ifdef DEBUG ifdef DEBUG
CFLAGS += -g -DFACTOR_DEBUG CFLAGS += -g -DFACTOR_DEBUG

2
basis/alien/libraries/libraries-docs.factor Normal file → Executable file
View File

@ -15,7 +15,7 @@ HELP: libraries
{ $description "A global hashtable that keeps a list of open libraries. Use the " { $link add-library } " word to construct a library and add it with a single call." } ; { $description "A global hashtable that keeps a list of open libraries. Use the " { $link add-library } " word to construct a library and add it with a single call." } ;
HELP: library HELP: library
{ $values { "name" "a string" } { "library" "a hashtable" } } { $values { "name" "a string" } { "library" assoc } }
{ $description "Looks up a library by its logical name. The library object is a hashtable with the following keys:" { $description "Looks up a library by its logical name. The library object is a hashtable with the following keys:"
{ $list { $list
{ { $snippet "name" } " - the full path of the C library binary" } { { $snippet "name" } " - the full path of the C library binary" }

22
basis/io/styles/styles-docs.factor Normal file → Executable file
View File

@ -1,17 +1,17 @@
USING: help.markup help.syntax io.streams.plain io strings USING: help.markup help.syntax io.streams.plain io strings
hashtables kernel quotations colors ; hashtables kernel quotations colors assocs ;
IN: io.styles IN: io.styles
HELP: stream-format HELP: stream-format
{ $values { "str" string } { "style" "a hashtable" } { "stream" "an output stream" } } { $values { "str" string } { "style" assoc } { "stream" "an output stream" } }
{ $contract "Writes formatted text to the stream. If the stream does buffering, output may not be performed immediately; use " { $link stream-flush } " to force output." { $contract "Writes formatted text to the stream. If the stream does buffering, output may not be performed immediately; use " { $link stream-flush } " to force output."
$nl $nl
"The " { $snippet "style" } " hashtable holds character style information. See " { $link "character-styles" } "." } "The " { $snippet "style" } " assoc holds character style information. See " { $link "character-styles" } "." }
{ $notes "Most code only works on one stream at a time and should instead use " { $link format } "; see " { $link "stdio" } "." } { $notes "Most code only works on one stream at a time and should instead use " { $link format } "; see " { $link "stdio" } "." }
$io-error ; $io-error ;
HELP: make-block-stream HELP: make-block-stream
{ $values { "style" "a hashtable" } { "stream" "an output stream" } { "stream'" "an output stream" } } { $values { "style" assoc } { "stream" "an output stream" } { "stream'" "an output stream" } }
{ $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "." { $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "."
$nl $nl
"Unlike " { $link make-span-stream } ", this creates a new paragraph block in the output." "Unlike " { $link make-span-stream } ", this creates a new paragraph block in the output."
@ -21,7 +21,7 @@ $nl
$io-error ; $io-error ;
HELP: stream-write-table HELP: stream-write-table
{ $values { "table-cells" "a sequence of sequences of table cells" } { "style" "a hashtable" } { "stream" "an output stream" } } { $values { "table-cells" "a sequence of sequences of table cells" } { "style" assoc } { "stream" "an output stream" } }
{ $contract "Prints a table of cells produced by " { $link with-cell } "." { $contract "Prints a table of cells produced by " { $link with-cell } "."
$nl $nl
"The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." } "The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." }
@ -29,13 +29,13 @@ $nl
$io-error ; $io-error ;
HELP: make-cell-stream HELP: make-cell-stream
{ $values { "style" hashtable } { "stream" "an output stream" } { "stream'" object } } { $values { "style" assoc } { "stream" "an output stream" } { "stream'" object } }
{ $contract "Creates an output stream which writes to a table cell object." } { $contract "Creates an output stream which writes to a table cell object." }
{ $notes "Most code only works on one stream at a time and should instead use " { $link with-cell } "; see " { $link "stdio" } "." } { $notes "Most code only works on one stream at a time and should instead use " { $link with-cell } "; see " { $link "stdio" } "." }
$io-error ; $io-error ;
HELP: make-span-stream HELP: make-span-stream
{ $values { "style" "a hashtable" } { "stream" "an output stream" } { "stream'" "an output stream" } } { $values { "style" assoc } { "stream" "an output stream" } { "stream'" "an output stream" } }
{ $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "." { $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "."
$nl $nl
"Unlike " { $link make-block-stream } ", the stream output is inline, and not nested in a paragraph block." } "Unlike " { $link make-block-stream } ", the stream output is inline, and not nested in a paragraph block." }
@ -43,19 +43,19 @@ $nl
$io-error ; $io-error ;
HELP: format HELP: format
{ $values { "str" string } { "style" "a hashtable" } } { $values { "str" string } { "style" assoc } }
{ $description "Writes formatted text to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." } { $description "Writes formatted text to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
{ $notes "Details are in the documentation for " { $link stream-format } "." } { $notes "Details are in the documentation for " { $link stream-format } "." }
$io-error ; $io-error ;
HELP: with-nesting HELP: with-nesting
{ $values { "style" "a hashtable" } { "quot" quotation } } { $values { "style" assoc } { "quot" quotation } }
{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to a nested paragraph stream, with formatting information applied." } { $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to a nested paragraph stream, with formatting information applied." }
{ $notes "Details are in the documentation for " { $link make-block-stream } "." } { $notes "Details are in the documentation for " { $link make-block-stream } "." }
$io-error ; $io-error ;
HELP: tabular-output HELP: tabular-output
{ $values { "style" "a hashtable" } { "quot" quotation } } { $values { "style" assoc } { "quot" quotation } }
{ $description "Calls a quotation which emits a series of equal-length table rows using " { $link with-row } ". The results are laid out in a tabular fashion on " { $link output-stream } "." { $description "Calls a quotation which emits a series of equal-length table rows using " { $link with-row } ". The results are laid out in a tabular fashion on " { $link output-stream } "."
$nl $nl
"The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." } "The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." }
@ -85,7 +85,7 @@ HELP: write-cell
$io-error ; $io-error ;
HELP: with-style HELP: with-style
{ $values { "style" "a hashtable" } { "quot" quotation } } { $values { "style" assoc } { "quot" quotation } }
{ $description "Calls the quotation in a new dynamic scope where calls to " { $link write } ", " { $link format } " and other stream output words automatically inherit style settings from " { $snippet "style" } "." } { $description "Calls the quotation in a new dynamic scope where calls to " { $link write } ", " { $link format } " and other stream output words automatically inherit style settings from " { $snippet "style" } "." }
{ $notes "Details are in the documentation for " { $link make-span-stream } "." } { $notes "Details are in the documentation for " { $link make-span-stream } "." }
$io-error ; $io-error ;

3
basis/macros/macros-docs.factor Normal file → Executable file
View File

@ -49,6 +49,7 @@ $nl
{ $subsection POSTPONE: MACRO: } { $subsection POSTPONE: MACRO: }
"A slightly lower-level facility, " { $emphasis "compiler transforms" } ", allows an ordinary word definition to co-exist with a version that performs compile-time expansion." "A slightly lower-level facility, " { $emphasis "compiler transforms" } ", allows an ordinary word definition to co-exist with a version that performs compile-time expansion."
{ $subsection define-transform } { $subsection define-transform }
"An example is the " { $link member? } " word. If the input sequence is a literal, the compile transform kicks in and converts the " { $link member? } " call into a series of conditionals. Otherwise, if the input sequence is not literal, a call to the definition of " { $link member? } " is generated." ; "An example is the " { $link member? } " word. If the input sequence is a literal, the compile transform kicks in and converts the " { $link member? } " call into a series of conditionals. Otherwise, if the input sequence is not literal, a call to the definition of " { $link member? } " is generated."
{ $see-also "generalizations" "fry" } ;
ABOUT: "macros" ABOUT: "macros"

36
basis/refs/refs-docs.factor Normal file → Executable file
View File

@ -1,14 +1,18 @@
! Copyright (C) 2007 Slava Pestov, 2009 Alex Chapman ! Copyright (C) 2007 Slava Pestov, 2009 Alex Chapman
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: boxes help.markup help.syntax kernel math namespaces ; USING: boxes help.markup help.syntax kernel math namespaces assocs ;
IN: refs IN: refs
ARTICLE: "refs" "References" ARTICLE: "refs" "References"
"References provide a uniform way of accessing and changing values. Some examples of referenced values are variables, tuple slots, and keys or values of assocs. References can be read, written, and deleted. References are defined in the " { $vocab-link "refs" } " vocabulary, and new reference types can be made by implementing the " { $link "refs-protocol" } "." "References provide a uniform way of accessing and changing values. Some examples of referenced values are variables, tuple slots, and keys or values of assocs. References can be read, written, and deleted. References are defined in the " { $vocab-link "refs" } " vocabulary, and new reference types can be made by implementing a protocol."
{ $subsection get-ref } { $subsection "refs-protocol" }
{ $subsection set-ref } { $subsection "refs-impls" }
{ $subsection set-ref* } { $subsection "refs-utils" }
{ $subsection delete-ref } "References are used by the " { $link "ui-inspector" } "." ;
ABOUT: "refs"
ARTICLE: "refs-impls" "Reference implementations"
"References to objects:" "References to objects:"
{ $subsection obj-ref } { $subsection obj-ref }
{ $subsection <obj-ref> } { $subsection <obj-ref> }
@ -27,20 +31,24 @@ ARTICLE: "refs" "References"
{ $subsection slot-ref } { $subsection slot-ref }
{ $subsection <slot-ref> } { $subsection <slot-ref> }
"Using boxes as references:" "Using boxes as references:"
{ $subsection "box-refs" } { $subsection "box-refs" } ;
"References are used by the UI inspector." ;
ABOUT: "refs" ARTICLE: "refs-utils" "Reference utilities"
{ $subsection ref-on }
{ $subsection ref-off }
{ $subsection ref-inc }
{ $subsection ref-dec }
{ $subsection set-ref* } ;
ARTICLE: "refs-protocol" "Reference Protocol" ARTICLE: "refs-protocol" "Reference protocol"
"To use a class of objects as references you must implement the reference protocol for that class, and mark your class as an instance of the " { $link ref } " mixin class. All references must implement these two words:" "To use a class of objects as references you must implement the reference protocol for that class, and mark your class as an instance of the " { $link ref } " mixin class. All references must implement these two words:"
{ $subsection get-ref } { $subsection get-ref }
{ $subsection set-ref } { $subsection set-ref }
"References may also implement:" "References may also implement:"
{ $subsection delete-ref } ; { $subsection delete-ref } ;
ARTICLE: "box-refs" "Using Boxes as References" ARTICLE: "box-refs" "Boxes as references"
"Boxes are elements of the " { $link ref } " mixin class, so any box may be used as a reference. Bear in mind that boxes will still throw an error if you call " { $link get-ref } " on an empty box." ; { $link "boxes" } " are elements of the " { $link ref } " mixin class, so any box may be used as a reference. Bear in mind that boxes will still throw an error if you call " { $link get-ref } " on an empty box." ;
HELP: ref HELP: ref
{ $class-description "A mixin class whose instances encapsulate a value which can be read, written, and deleted. Instantiable members of this class include:" { $link obj-ref } ", " { $link var-ref } ", " { $link global-var-ref } ", " { $link slot-ref } ", " { $link box } ", " { $link key-ref } ", and " { $link value-ref } "." } ; { $class-description "A mixin class whose instances encapsulate a value which can be read, written, and deleted. Instantiable members of this class include:" { $link obj-ref } ", " { $link var-ref } ", " { $link global-var-ref } ", " { $link slot-ref } ", " { $link box } ", " { $link key-ref } ", and " { $link value-ref } "." } ;
@ -89,14 +97,14 @@ HELP: key-ref
{ $class-description "Instances of this class identify a key in an associative structure. New key references are created by calling " { $link <key-ref> } "." } ; { $class-description "Instances of this class identify a key in an associative structure. New key references are created by calling " { $link <key-ref> } "." } ;
HELP: <key-ref> HELP: <key-ref>
{ $values { "assoc" "an assoc" } { "key" object } { "key-ref" key-ref } } { $values { "assoc" assoc } { "key" object } { "key-ref" key-ref } }
{ $description "Creates a reference to a key stored in an assoc." } ; { $description "Creates a reference to a key stored in an assoc." } ;
HELP: value-ref HELP: value-ref
{ $class-description "Instances of this class identify a value associated to a key in an associative structure. New value references are created by calling " { $link <value-ref> } "." } ; { $class-description "Instances of this class identify a value associated to a key in an associative structure. New value references are created by calling " { $link <value-ref> } "." } ;
HELP: <value-ref> HELP: <value-ref>
{ $values { "assoc" "an assoc" } { "key" object } { "value-ref" value-ref } } { $values { "assoc" assoc } { "key" object } { "value-ref" value-ref } }
{ $description "Creates a reference to the value associated with " { $snippet "key" } " in " { $snippet "assoc" } "." } ; { $description "Creates a reference to the value associated with " { $snippet "key" } " in " { $snippet "assoc" } "." } ;
{ get-ref set-ref delete-ref set-ref* } related-words { get-ref set-ref delete-ref set-ref* } related-words

7
basis/stack-checker/errors/errors-docs.factor Normal file → Executable file
View File

@ -84,8 +84,11 @@ HELP: inconsistent-recursive-call-error
} ; } ;
ARTICLE: "inference-errors" "Stack checker errors" ARTICLE: "inference-errors" "Stack checker errors"
"These conditions are thrown by " { $link "inference" } ", as well as the " { $link "compiler" } "." "These " { $link "inference" } " failure conditions are reported in one of two ways:"
$nl { $list
{ { $link "tools.inference" } " throws them as errors" }
{ "The " { $link "compiler" } " reports them via " { $link "tools.errors" } }
}
"Error thrown when insufficient information is available to calculate the stack effect of a combinator call (see " { $link "inference-combinators" } "):" "Error thrown when insufficient information is available to calculate the stack effect of a combinator call (see " { $link "inference-combinators" } "):"
{ $subsection literal-expected } { $subsection literal-expected }
"Error thrown when a word's stack effect declaration does not match the composition of the stack effects of its factors:" "Error thrown when a word's stack effect declaration does not match the composition of the stack effects of its factors:"

1
basis/tuple-arrays/summary.txt Executable file
View File

@ -0,0 +1 @@
Efficient arrays of tuples with value semantics for elements

1
basis/tuple-arrays/tags.txt Executable file
View File

@ -0,0 +1 @@
collections

2
core/combinators/combinators-docs.factor Normal file → Executable file
View File

@ -290,7 +290,6 @@ $nl
"The above are syntax sugar. The underlying words are a bit more verbose but allow non-constant effects to be passed in:" "The above are syntax sugar. The underlying words are a bit more verbose but allow non-constant effects to be passed in:"
{ $subsection call-effect } { $subsection call-effect }
{ $subsection execute-effect } { $subsection execute-effect }
{ $subsection "call-unsafe" }
"The combinator variants that do not take an effect declaration can only be used if the compiler is able to infer the stack effect by other means. See " { $link "inference-combinators" } "." "The combinator variants that do not take an effect declaration can only be used if the compiler is able to infer the stack effect by other means. See " { $link "inference-combinators" } "."
{ $subsection "call-unsafe" } { $subsection "call-unsafe" }
{ $see-also "effects" "inference" } ; { $see-also "effects" "inference" } ;
@ -306,6 +305,7 @@ ARTICLE: "combinators" "Combinators"
{ $subsection "combinators.smart" } { $subsection "combinators.smart" }
"More combinators are defined for working on data structures, such as " { $link "sequences-combinators" } " and " { $link "assocs-combinators" } "." "More combinators are defined for working on data structures, such as " { $link "sequences-combinators" } " and " { $link "assocs-combinators" } "."
{ $subsection "combinators-quot" } { $subsection "combinators-quot" }
{ $subsection "generalizations" }
{ $see-also "quotations" } ; { $see-also "quotations" } ;
ABOUT: "combinators" ABOUT: "combinators"

0
core/combinators/combinators-tests.factor Normal file → Executable file
View File

2
core/hashtables/hashtables-docs.factor Normal file → Executable file
View File

@ -116,7 +116,7 @@ HELP: ?set-at
{ $description "If the third input is an assoc, stores the key/value pair into that assoc, or else creates a new hashtable with the key/value pair as its only entry." } ; { $description "If the third input is an assoc, stores the key/value pair into that assoc, or else creates a new hashtable with the key/value pair as its only entry." } ;
HELP: >hashtable HELP: >hashtable
{ $values { "assoc" "an assoc" } { "hashtable" "a hashtable" } } { $values { "assoc" assoc } { "hashtable" hashtable } }
{ $description "Constructs a hashtable from any assoc." } ; { $description "Constructs a hashtable from any assoc." } ;
HELP: rehash HELP: rehash

12
core/namespaces/namespaces-docs.factor Normal file → Executable file
View File

@ -1,6 +1,6 @@
USING: help.markup help.syntax kernel kernel.private USING: help.markup help.syntax kernel kernel.private
sequences words namespaces.private quotations vectors sequences words namespaces.private quotations vectors
math.parser math words.symbol ; math.parser math words.symbol assocs ;
IN: namespaces IN: namespaces
ARTICLE: "namespaces-combinators" "Namespace combinators" ARTICLE: "namespaces-combinators" "Namespace combinators"
@ -119,19 +119,19 @@ HELP: with-variable
} ; } ;
HELP: make-assoc HELP: make-assoc
{ $values { "quot" quotation } { "exemplar" "an assoc" } { "hash" "a new hashtable" } } { $values { "quot" quotation } { "exemplar" assoc } { "hash" "a new assoc" } }
{ $description "Calls the quotation in a new namespace of the same type as " { $snippet "exemplar" } ", and outputs this namespace when the quotation returns. Useful for quickly building assocs." } ; { $description "Calls the quotation in a new namespace of the same type as " { $snippet "exemplar" } ", and outputs this namespace when the quotation returns. Useful for quickly building assocs." } ;
HELP: bind HELP: bind
{ $values { "ns" "a hashtable" } { "quot" quotation } } { $values { "ns" assoc } { "quot" quotation } }
{ $description "Calls the quotation in the dynamic scope of " { $snippet "ns" } ". When variables are looked up by the quotation, " { $snippet "ns" } " is checked first, and setting variables in the quotation stores them in " { $snippet "ns" } "." } ; { $description "Calls the quotation in the dynamic scope of " { $snippet "ns" } ". When variables are looked up by the quotation, " { $snippet "ns" } " is checked first, and setting variables in the quotation stores them in " { $snippet "ns" } "." } ;
HELP: namespace HELP: namespace
{ $values { "namespace" "an assoc" } } { $values { "namespace" assoc } }
{ $description "Outputs the current namespace. Calls to " { $link set } " modify this namespace." } ; { $description "Outputs the current namespace. Calls to " { $link set } " modify this namespace." } ;
HELP: global HELP: global
{ $values { "g" "an assoc" } } { $values { "g" assoc } }
{ $description "Outputs the global namespace. The global namespace is always checked last when looking up variable values." } ; { $description "Outputs the global namespace. The global namespace is always checked last when looking up variable values." } ;
HELP: get-global HELP: get-global
@ -156,7 +156,7 @@ HELP: set-namestack
{ $description "Replaces the name stack with a copy of the given vector." } ; { $description "Replaces the name stack with a copy of the given vector." } ;
HELP: >n HELP: >n
{ $values { "namespace" "an assoc" } } { $values { "namespace" assoc } }
{ $description "Pushes a namespace on the name stack." } ; { $description "Pushes a namespace on the name stack." } ;
HELP: ndrop HELP: ndrop

View File

@ -1,4 +1,4 @@
USING: kernel help.markup help.syntax sequences quotations ; USING: kernel help.markup help.syntax sequences quotations assocs ;
IN: sets IN: sets
ARTICLE: "sets" "Set-theoretic operations on sequences" ARTICLE: "sets" "Set-theoretic operations on sequences"
@ -42,7 +42,7 @@ HELP: adjoin
{ $side-effects "seq" } ; { $side-effects "seq" } ;
HELP: conjoin HELP: conjoin
{ $values { "elt" object } { "assoc" "an assoc" } } { $values { "elt" object } { "assoc" assoc } }
{ $description "Stores a key/value pair, both equal to " { $snippet "elt" } ", into the assoc." } { $description "Stores a key/value pair, both equal to " { $snippet "elt" } ", into the assoc." }
{ $examples { $examples
{ $example { $example
@ -54,7 +54,7 @@ HELP: conjoin
{ $side-effects "assoc" } ; { $side-effects "assoc" } ;
HELP: unique HELP: unique
{ $values { "seq" "a sequence" } { "assoc" "an assoc" } } { $values { "seq" "a sequence" } { "assoc" assoc } }
{ $description "Outputs a new assoc where the keys and values are equal." } { $description "Outputs a new assoc where the keys and values are equal." }
{ $examples { $examples
{ $example "USING: sets prettyprint ;" "{ 1 1 2 2 3 3 } unique ." "H{ { 1 1 } { 2 2 } { 3 3 } }" } { $example "USING: sets prettyprint ;" "{ 1 1 2 2 3 3 } unique ." "H{ { 1 1 } { 2 2 } { 3 3 } }" }

View File

@ -2,10 +2,37 @@ USING: kernel io strings byte-arrays sequences namespaces math
parser crypto.hmac tools.test ; parser crypto.hmac tools.test ;
IN: crypto.hmac.tests IN: crypto.hmac.tests
[ "\u000092\u000094rz68\u0000bb\u00001c\u000013\u0000f4\u00008e\u0000f8\u000015\u00008b\u0000fc\u00009d" ] [ 16 11 <string> "Hi There" byte-array>md5-hmac >string ] unit-test [
[ "u\u00000cx>j\u0000b0\u0000b5\u000003\u0000ea\u0000a8n1\n]\u0000b78" ] [ "Jefe" "what do ya want for nothing?" byte-array>md5-hmac >string ] unit-test "\u000092\u000094rz68\u0000bb\u00001c\u000013\u0000f4\u00008e\u0000f8\u000015\u00008b\u0000fc\u00009d"
[ "V\u0000be4R\u00001d\u000014L\u000088\u0000db\u0000b8\u0000c73\u0000f0\u0000e8\u0000b3\u0000f6" ] [ 16 HEX: aa <string> 50 HEX: dd <repetition> >byte-array byte-array>md5-hmac >string ] unit-test ] [
16 11 <string> "Hi There" sequence>md5-hmac >string ] unit-test
[ "g[\u00000b:\eM\u0000dfN\u000012Hr\u0000dal/c+\u0000fe\u0000d9W\u0000e9" ] [ 16 11 <string> "Hi There" >byte-array byte-array>sha1-hmac >string ] unit-test [ "u\u00000cx>j\u0000b0\u0000b5\u000003\u0000ea\u0000a8n1\n]\u0000b78" ]
[ "\u0000ef\u0000fc\u0000dfj\u0000e5\u0000eb/\u0000a2\u0000d2t\u000016\u0000d5\u0000f1\u000084\u0000df\u00009c%\u00009a|y" ] [ "Jefe" "what do ya want for nothing?" >byte-array byte-array>sha1-hmac >string ] unit-test [ "Jefe" "what do ya want for nothing?" sequence>md5-hmac >string ] unit-test
[ "\u0000d70YM\u000016~5\u0000d5\u000095o\u0000d8\0=\r\u0000b3\u0000d3\u0000f4m\u0000c7\u0000bb" ] [ 16 HEX: aa <string> 50 HEX: dd <repetition> >byte-array byte-array>sha1-hmac >string ] unit-test
[
"V\u0000be4R\u00001d\u000014L\u000088\u0000db\u0000b8\u0000c73\u0000f0\u0000e8\u0000b3\u0000f6"
]
[
16 HEX: aa <string>
50 HEX: dd <repetition> sequence>md5-hmac >string
] unit-test
[
"g[\u00000b:\eM\u0000dfN\u000012Hr\u0000dal/c+\u0000fe\u0000d9W\u0000e9"
] [
16 11 <string> "Hi There" sequence>sha1-hmac >string
] unit-test
[
"\u0000ef\u0000fc\u0000dfj\u0000e5\u0000eb/\u0000a2\u0000d2t\u000016\u0000d5\u0000f1\u000084\u0000df\u00009c%\u00009a|y"
] [
"Jefe" "what do ya want for nothing?" sequence>sha1-hmac >string
] unit-test
[
"\u0000d70YM\u000016~5\u0000d5\u000095o\u0000d8\0=\r\u0000b3\u0000d3\u0000f4m\u0000c7\u0000bb"
] [
16 HEX: aa <string>
50 HEX: dd <repetition> sequence>sha1-hmac >string
] unit-test

View File

@ -6,6 +6,8 @@ io.streams.byte-array kernel math math.vectors memoize sequences
io.encodings.binary ; io.encodings.binary ;
IN: crypto.hmac IN: crypto.hmac
<PRIVATE
: sha1-hmac ( Ko Ki -- hmac ) : sha1-hmac ( Ko Ki -- hmac )
initialize-sha1 process-sha1-block initialize-sha1 process-sha1-block
stream>sha1 get-sha1 stream>sha1 get-sha1
@ -24,6 +26,7 @@ IN: crypto.hmac
[ bitxor ] 2map ; [ bitxor ] 2map ;
MEMO: ipad ( -- seq ) 64 HEX: 36 <array> ; MEMO: ipad ( -- seq ) 64 HEX: 36 <array> ;
MEMO: opad ( -- seq ) 64 HEX: 5c <array> ; MEMO: opad ( -- seq ) 64 HEX: 5c <array> ;
: init-hmac ( K -- o i ) : init-hmac ( K -- o i )
@ -31,13 +34,15 @@ MEMO: opad ( -- seq ) 64 HEX: 5c <array> ;
[ opad seq-bitxor ] keep [ opad seq-bitxor ] keep
ipad seq-bitxor ; ipad seq-bitxor ;
PRIVATE>
: stream>sha1-hmac ( K stream -- hmac ) : stream>sha1-hmac ( K stream -- hmac )
[ init-hmac sha1-hmac ] with-input-stream ; [ init-hmac sha1-hmac ] with-input-stream ;
: file>sha1-hmac ( K path -- hmac ) : file>sha1-hmac ( K path -- hmac )
binary <file-reader> stream>sha1-hmac ; binary <file-reader> stream>sha1-hmac ;
: byte-array>sha1-hmac ( K string -- hmac ) : sequence>sha1-hmac ( K sequence -- hmac )
binary <byte-reader> stream>sha1-hmac ; binary <byte-reader> stream>sha1-hmac ;
: stream>md5-hmac ( K stream -- hmac ) : stream>md5-hmac ( K stream -- hmac )
@ -46,5 +51,5 @@ MEMO: opad ( -- seq ) 64 HEX: 5c <array> ;
: file>md5-hmac ( K path -- hmac ) : file>md5-hmac ( K path -- hmac )
binary <file-reader> stream>md5-hmac ; binary <file-reader> stream>md5-hmac ;
: byte-array>md5-hmac ( K string -- hmac ) : sequence>md5-hmac ( K sequence -- hmac )
binary <byte-reader> stream>md5-hmac ; binary <byte-reader> stream>md5-hmac ;

1
vm/Config.unix Normal file → Executable file
View File

@ -18,6 +18,7 @@ else
endif endif
# CFLAGS += -fPIC # CFLAGS += -fPIC
FFI_TEST_CFLAGS = -fPIC
# LINKER = gcc -shared -o # LINKER = gcc -shared -o
# LINK_WITH_ENGINE = '-Wl,-rpath,$$ORIGIN' -lfactor # LINK_WITH_ENGINE = '-Wl,-rpath,$$ORIGIN' -lfactor