-+ ui:\r
+72/73:\r
\r
+- tuples: gracefully handle changing shape\r
+- keep a list of getter/setter words\r
+- default constructor\r
+- move tuple to generic vocab\r
+- update plugin docs\r
+- extract word keeps indent\r
+- word preview for remote words\r
+- support USING:\r
+- special completion for USE:/IN:\r
+- prettyprint: detect circular structure\r
+- vectors: ensure its ok with bignum indices\r
+- parsing words don't print readably\r
- if gadgets are moved, added or deleted, update hand.\r
- keyboard focus\r
- keyboard gestures\r
- text fields\r
-- finish check boxes\r
-\r
-+ compiler:\r
-\r
+- code gc\r
- type inference fails with some assembler words;\r
displaced, register and other predicates need to inherit from list\r
not cons, and need stronger branch partial eval\r
-- more accurate type inference in some cases\r
+- print warning on null class\r
- optimize away dispatch\r
-- goal: to compile hash* optimally\r
-- type check/not-check entry points for compiled words\r
-- getenv/setenv: if literal arg, compile as a load/store\r
-- compile tuple dispatch\r
+- layouts with gaps\r
+- alignment of gadgets inside their bounding boxes needs thought\r
+- WordPreview calls markTokens() -> NPE\r
+- faster completion\r
+- ppc register decls\r
+- rename f* words to stream-*\r
\r
-+ oop:\r
+- ffi unicode strings: null char security hole\r
+- utf16 string boxing\r
+- slot compile problem\r
+- nulls at the end of utf16 strings\r
\r
-- make see work with union, builtin, predicate\r
-- doc comments of generics\r
-- proper ordering for classes\r
-- tuples: gracefully handle changing shape\r
-- keep a list of getter/setter words\r
-- default constructor\r
-- move tuple to generic vocab\r
-\r
-+ ffi:\r
++ compiler/ffi:\r
\r
- value type structs\r
-- unicode strings\r
- out parameters\r
-- figure out how to load an image referring to missing libraries\r
- is signed -vs- unsigned pointers an issue?\r
- bitfields in C structs\r
- SDL_Rect** type\r
- struct membres that are not *\r
- FFI float types\r
\r
-+ listener/plugin:\r
-\r
-- command to turn repl session into a source file\r
-- update plugin docs\r
-- extract word keeps indent\r
-- word preview for remote words\r
-- WordPreview calls markTokens() -> NPE\r
-- listener should be multithreaded\r
-- faster completion\r
-- NPE in ErrorHighlight\r
-- maple-like: press enter at old commands to evaluate there\r
-- completion in the listener\r
-- special completion for USE:/IN:\r
-- support USING:\r
-- command to prettyprint word def at caret, or selection\r
-\r
+ i/o:\r
\r
- stream server can hang because of exception handler limitations\r
- better i/o scheduler\r
- nicer way to combine two paths\r
- add a socket timeout\r
-- rename f* words to stream-*\r
+- unix ffi i/o\r
\r
+ kernel:\r
\r
-- ppc register decls\r
- cat, reverse-cat primitives\r
-\r
-+ misc:\r
-\r
+- generational gc\r
+- make see work with union, builtin, predicate\r
+- doc comments of generics\r
+- proper ordering for classes\r
- make-vector and make-string should not need a reverse step\r
-- perhaps /i should work with all numbers\r
-- jedit ==> jedit-word, jedit takes a file name\r
-- browser responder for word links in HTTPd\r
- worddef props\r
-- prettyprint: detect circular structure\r
-- vectors: ensure its ok with bignum indices\r
-- parsing words don't print readably\r
-\r
-+ httpd:\r
-\r
-- log with date\r
-- file responder; last-modified field\r
\r
cpu "x86" = [\r
[\r
- "/library/compiler/x86/assembler.factor"\r
- "/library/compiler/x86/stack.factor"\r
- "/library/compiler/x86/generator.factor"\r
- "/library/compiler/x86/fixnum.factor"\r
+ "/library/compiler/x86/assembler.factor"\r
+ "/library/compiler/x86/stack.factor"\r
+ "/library/compiler/x86/generator.factor"\r
+ "/library/compiler/x86/fixnum.factor"\r
\r
"/library/ui/line-editor.factor"\r
"/library/ui/console.factor"\r
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: alien
-USE: assembler
-USE: compiler
-USE: errors
-USE: hashtables
-USE: kernel
-USE: lists
-USE: math
-USE: namespaces
-USE: parser
-USE: strings
-USE: words
+USING: assembler compiler errors hashtables kernel lists math
+namespaces parser strings words ;
! Some code for interfacing with C structures.
"unbox_c_string" "unboxer" set
] "char*" define-c-type
+[
+ [ alien-4 ] "getter" set
+ [ set-alien-4 ] "setter" set
+ cell "width" set
+ "box_utf16_string" "boxer" set
+ "unbox_utf16_string" "unboxer" set
+] "ushort*" define-c-type
+
[
[ alien-4 0 = not ] "getter" set
[ 1 0 ? set-alien-4 ] "setter" set
! See http://factor.sf.net/license.txt for BSD license.
IN: generic
USING: words parser kernel namespaces lists strings
-kernel-internals math hashtables errors ;
+kernel-internals math hashtables errors vectors ;
: make-tuple ( class -- tuple )
dup "tuple-size" word-property <tuple>
] ifte
] [
drop f
- ] ifte ; inline
+ ] ifte ;
-: lookup-method ( class selector -- method )
- "methods" word-property hash* ; inline
+: alist>quot ( default alist -- quot )
+ #! Turn an association list that maps values to quotations
+ #! into a quotation that executes a quotation depending on
+ #! the value on the stack.
+ [
+ [
+ unswons
+ \ dup , unswons literal, \ = , \ drop swons ,
+ alist>quot , \ ifte ,
+ ] make-list
+ ] when* ;
+
+: (hash>quot) ( default hash -- quot )
+ [
+ \ dup , \ hashcode , dup bucket-count , \ rem ,
+ buckets>list [ alist>quot ] map-with list>vector ,
+ \ dispatch ,
+ ] make-list ;
+
+: hash>quot ( default hash -- quot )
+ #! Turn a hash table that maps values to quotations into a
+ #! quotation that executes a quotation depending on the
+ #! value on the stack.
+ dup hash-size 4 <= [
+ hash>alist alist>quot
+ ] [
+ (hash>quot)
+ ] ifte ;
-: tuple-dispatch ( object selector -- )
- over class over lookup-method [
- cdr call ( method is defined )
+: default-tuple-method ( generic -- quot )
+ #! If the generic does not define a specific method for a
+ #! tuple, execute the return value of this.
+ dup "methods" word-property
+ tuple over hash dup [
+ 2nip
] [
- object over lookup-method [
- cdr call
+ drop object over hash dup [
+ 2nip
] [
- over tuple-delegate [
- rot drop swap execute ( check delegate )
- ] [
- undefined-method ( no delegate )
- ] ifte*
- ] ?ifte
- ] ?ifte ;
+ 2drop [ dup tuple-delegate ] swap
+ dup unit swap
+ unit [ car ] cons [ undefined-method ] append
+ \ ?ifte 3list append
+ ] ifte
+ ] ifte ;
+
+: tuple-dispatch-quot ( generic -- quot )
+ #! Generate a quotation that performs tuple class dispatch
+ #! for methods defined on the given generic.
+ dup default-tuple-method \ drop swons
+ swap "methods" word-property hash>quot
+ [ dup class ] swap append ;
: add-tuple-dispatch ( word vtable -- )
- >r unit [ car tuple-dispatch ] cons tuple r> set-vtable ;
+ >r tuple-dispatch-quot tuple r> set-vtable ;
: clone-tuple ( tuple -- tuple )
#! Make a shallow copy of a tuple, without cloning its
meta-r set drop ;
: filter-terminators ( list -- list )
- [ [ d-in get meta-d get and ] bind ] subset [
- "No branch has a stack effect" throw
- ] unless* ;
+ #! Remove branches that unconditionally throw errors.
+ [ [ active? ] bind ] subset ;
: unify-effects ( list -- )
- filter-terminators dup datastack-effect callstack-effect ;
+ filter-terminators [
+ dup datastack-effect callstack-effect
+ ] [
+ terminate
+ ] ifte* ;
SYMBOL: cloned
d-in [ deep-clone-vector ] change
dataflow-graph off ;
-: terminator? ( obj -- ? )
- dup word? [ "terminator" word-property ] [ drop f ] ifte ;
-
-: handle-terminator ( quot -- )
- [ terminator? ] some? [
- meta-d off meta-r off d-in off
- ] when ;
-
: propagate-type ( [[ value class ]] -- )
#! Type propagation is chained.
[
] when* ;
: infer-branch ( value -- namespace )
+ #! Return a namespace with inferencer variables:
+ #! meta-d, meta-r, d-in. They are set to f if
+ #! terminate was called.
<namespace> [
uncons propagate-type
dup value-recursion recursive-state set
copy-inference
literal-value dup infer-quot
- #values values-node
- handle-terminator
+ active? [
+ #values values-node
+ handle-terminator
+ ] [
+ drop
+ ] ifte
] extend ;
: (infer-branches) ( branchlist -- list )
#! Apply the object's stack effect to the inferencer state.
dup word? [ apply-word ] [ apply-literal ] ifte ;
+: active? ( -- ? )
+ #! Is this branch not terminated?
+ d-in get meta-d get and ;
+
+: terminate ( -- )
+ #! Ignore this branch's stack effect.
+ meta-d off meta-r off d-in off ;
+
+: terminator? ( obj -- ? )
+ #! Does it throw an error?
+ dup word? [ "terminator" word-property ] [ drop f ] ifte ;
+
+: handle-terminator ( quot -- )
+ #! If the quotation throws an error, do not count its stack
+ #! effect.
+ [ terminator? ] some? [ terminate ] when ;
+
: infer-quot ( quot -- )
#! Recursive calls to this word are made for nested
#! quotations.
- [ apply-object ] each ;
+ active? [
+ [ unswons apply-object infer-quot ] when*
+ ] [
+ drop
+ ] ifte ;
: check-return ( -- )
#! Raise an error if word leaves values on return stack.
\ >string \ string infer-check
] "infer" set-word-property
-! \ slot [
-! [ object fixnum ] ensure-d
+! : literal-slot ( -- )
! dataflow-drop, pop-d literal-value
! peek-d value-class builtin-supertypes dup length 1 = [
! cons \ slot [ [ object ] [ object ] ] (consume/produce)
! ] [
! "slot called without static type knowledge" throw
-! ] ifte
+! ] ifte ;
+!
+! : computed-slot ( -- )
+! \ slot dup "infer-effect" word-property consume/produce ;
+!
+! \ slot [
+! [ object fixnum ] ensure-d
+! peek-d literal? [ literal-slot ] [ computed-slot ] ifte
! ] "infer" set-word-property
: type-value-map ( value -- )
#! we infer its stack effect inside a new block.
gensym [ word-parameter infer-quot effect ] with-block ;
-: infer-compound ( word -- effect )
+: infer-compound ( word -- )
#! Infer a word's stack effect in a separate inferencer
#! instance.
[
- recursive-state get init-inference
- dup dup inline-compound drop present-effect
- [ "infer-effect" set-word-property ] keep
- ] with-scope consume/produce ;
+ [
+ recursive-state get init-inference
+ dup dup inline-compound drop present-effect
+ [ "infer-effect" set-word-property ] keep
+ ] with-scope consume/produce
+ ] [
+ [
+ >r branches-can-fail? [
+ drop
+ ] [
+ t "no-effect" set-word-property
+ ] ifte r> rethrow
+ ] when*
+ ] catch ;
GENERIC: (apply-word)
M: compound (apply-word) ( word -- )
#! Infer a compound word's stack effect.
- dup "inline" word-property [
- inline-compound 2drop
+ dup "no-effect" word-property [
+ no-effect
] [
- infer-compound
+ dup "inline" word-property [
+ inline-compound 2drop
+ ] [
+ infer-compound
+ ] ifte
] ifte ;
M: promise (apply-word) ( word -- )
gensym dup [
drop pop-d dup
value-recursion recursive-state set
- literal-value infer-quot
- ] with-block drop ;
+ literal-value
+ dup infer-quot
+ ] with-block drop handle-terminator ;
\ call [ infer-call ] "infer" set-word-property
! These hacks will go away soon
\ * [ [ number number ] [ number ] ] "infer-effect" set-word-property
\ - [ [ number number ] [ number ] ] "infer-effect" set-word-property
+\ = [ [ object object ] [ object ] ] "infer-effect" set-word-property
\ undefined-method t "terminator" set-word-property
\ undefined-method [ [ object word ] [ ] ] "infer-effect" set-word-property
-! :folding=indent:collapseFolds=1:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: files
-USE: kernel
-USE: hashtables
-USE: lists
-USE: namespaces
-USE: presentation
-USE: stdio
-USE: strings
-USE: unparser
+USING: kernel hashtables lists namespaces presentation stdio
+strings unparser ;
: exists? ( file -- ? )
stat >boolean ;
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
+IN: files
+USING: io-internals errors hashtables kernel stdio strings
+namespaces generic ;
+
+! We need this early during bootstrap.
+: path+ ( path path -- path )
+ #! Combine two paths. This will be implemented later.
+ "/" swap cat3 ;
+
IN: stdio
DEFER: stdio
IN: streams
-USING: io-internals errors hashtables kernel stdio strings
-namespaces generic ;
TUPLE: fd-stream in out ;
"resource-path" get [ "." ] unless* ;
: <resource-stream> ( path -- stream )
- resource-path swap cat2 <file-reader> ;
+ resource-path swap path+ <file-reader> ;
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: math
-USE: kernel
-USE: math
-USE: math-internals
+USING: kernel math math-internals ;
! Inverse trigonometric functions:
! acos asec asin acosec atan acot
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: errors
DEFER: throw
IN: math-internals
-USE: generic
-USE: kernel
-USE: kernel-internals
-USE: math
+USING: generic kernel kernel-internals math ;
: (rect>) ( xr xi -- x )
#! Does not perform a check that the arguments are reals.
(rect>)
] [
"Complex number must have real components" throw drop
- ] ifte ; inline
+ ] ifte ;
: >rect ( x -- xr xi ) dup real swap imaginary ; inline
: 2>rect ( x y -- xr yr xi yi )
[ swap real swap real ] 2keep
- swap imaginary swap imaginary ; inline
+ swap imaginary swap imaginary ;
M: complex number= ( x y -- ? )
2>rect number= [ number= ] [ 2drop f ] ifte ;
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
-! Copyright (C) 2003, 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: math
USE: kernel
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: math-internals
-USE: generic
-USE: kernel
-USE: math
+USING: generic kernel math ;
M: float number= float= ;
M: float < float< ;
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: errors
DEFER: throw
IN: math-internals
-USE: generic
-USE: kernel
-USE: math
+USING: generic kernel math ;
: fraction> ( a b -- a/b )
dup 1 number= [
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
! Copyright (C) 2003, 2005 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! See http://factor.sf.net/license.txt for BSD license.
IN: math
-USE: generic
-USE: kernel
-USE: math-internals
+USING: generic kernel math-internals ;
! Math operations
2GENERIC: number= ( x y -- ? )
: rem ( x y -- x%y )
#! Like modulus, but always gives a positive result.
- [ mod ] keep over 0 < [ + ] [ drop ] ifte ; inline
+ [ mod ] keep over 0 < [ + ] [ drop ] ifte ;
: sgn ( n -- -1/0/1 )
#! Push the sign of a real number.
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: math
-USE: math
-USE: math-internals
-USE: kernel
+USING: math math-internals kernel ;
! Power-related functions:
! exp log sqrt pow
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: math
-USE: generic
-USE: kernel
-USE: kernel-internals
-USE: math
-USE: math-internals
+USING: generic kernel kernel-internals math math-internals ;
GENERIC: numerator ( a/b -- a )
M: integer numerator ;
2>fraction number= [ number= ] [ 2drop f ] ifte ;
: scale ( a/b c/d -- a*d b*c )
- 2>fraction >r * swap r> * swap ; inline
+ 2>fraction >r * swap r> * swap ;
: ratio+d ( a/b c/d -- b*d )
denominator swap denominator * ; inline
-! :folding=indent:collapseFolds=0:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: math
-USE: kernel
-USE: math
-USE: math-internals
+USING: kernel math math-internals ;
! Trigonometric functions:
! cos sec sin cosec tan cot
! Copyright (C) 2003, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: namespaces
-USING: hashtables kernel kernel-internals lists vectors math ;
+USING: hashtables kernel kernel-internals lists strings vectors
+math ;
! Other languages have classes, objects, variables, etc.
! Factor has similar concepts.
#! was called.
make-rlist reverse ; inline
+: make-string ( quot -- string )
+ #! Call a quotation. The quotation can call , to prepend
+ #! objects to the list that is returned when the quotation
+ #! is done.
+ make-list cat ; inline
+
+: make-rstring ( quot -- string )
+ #! Return a string whose entries are in the same order that ,
+ #! was called.
+ make-rlist cat ; inline
+
: make-vector ( quot -- list )
#! Return a vector whose entries are in the same order that
#! , was called.
! See http://factor.sf.net/license.txt for BSD license.
IN: strings USING: kernel lists math namespaces strings ;
-: make-string ( quot -- string )
- #! Call a quotation. The quotation can call , to prepend
- #! objects to the list that is returned when the quotation
- #! is done.
- make-list cat ; inline
-
-: make-rstring ( quot -- string )
- #! Return a string whose entries are in the same order that ,
- #! was called.
- make-rlist cat ; inline
-
: fill ( count char -- string )
#! Push a string that consists of the same character
#! repeated.
-! :folding=indent:collapseFolds=1:
-
-! $Id$
-!
-! Copyright (C) 2005 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: sdl-ttf
USE: alien
FIELD: int i
END-STRUCT
-: TTF_SizeText ( font text w h -- ? )
- "bool" "sdl-ttf" "TTF_SizeText" [ "void*" "char*" "int-box*" "int-box*" ] alien-invoke ;
+: TTF_SizeUNICODE ( font text w h -- ? )
+ "bool" "sdl-ttf" "TTF_SizeUNICODE" [ "void*" "ushort*" "int-box*" "int-box*" ] alien-invoke ;
+
+: TTF_RenderUNICODE_Solid ( font text fg -- surface )
+ "surface*" "sdl-ttf" "TTF_RenderUNICODE_Solid" [ "void*" "ushort*" "int" ] alien-invoke ;
-: TTF_RenderText_Solid ( font text fg -- surface )
- "surface*" "sdl-ttf" "TTF_RenderText_Solid" [ "void*" "char*" "int" ] alien-invoke ;
+: TTF_RenderGlyph_Solid ( font text fg -- surface )
+ "surface*" "sdl-ttf" "TTF_RenderText_Solid" [ "void*" "ushort" "int" ] alien-invoke ;
-: TTF_RenderText_Shaded ( font text fg bg -- surface )
- "surface*" "sdl-ttf" "TTF_RenderText_Shaded" [ "void*" "char*" "int" "int" ] alien-invoke ;
+: TTF_RenderUNICODE_Shaded ( font text fg bg -- surface )
+ "surface*" "sdl-ttf" "TTF_RenderUNICODE_Shaded" [ "void*" "ushort*" "int" "int" ] alien-invoke ;
: TTF_RenderGlyph_Shaded ( font text fg bg -- surface )
"surface*" "sdl-ttf" "TTF_RenderGlyph_Shaded" [ "void*" "ushort" "int" "int" ] alien-invoke ;
-: TTF_RenderText_Blended ( font text fg -- surface )
- "surface*" "sdl-ttf" "TTF_RenderText_Blended" [ "void*" "char*" "int" ] alien-invoke ;
+: TTF_RenderUNICODE_Blended ( font text fg -- surface )
+ "surface*" "sdl-ttf" "TTF_RenderUNICODE_Blended" [ "void*" "ushort*" "int" ] alien-invoke ;
: TTF_RenderGlyph_Blended ( font text fg -- surface )
"surface*" "sdl-ttf" "TTF_RenderGlyph_Blended" [ "void*" "ushort" "int" ] alien-invoke ;
] with-scope ; inline
: event-loop ( event -- )
- dup SDL_WaitEvent 1 = [
+ dup SDL_WaitEvent [
dup event-type SDL_QUIT = [
drop
] [
over str-length 0 = [
2drop 3drop 0
] [
- TTF_RenderText_Blended
+ TTF_RenderUNICODE_Blended
[ draw-surface ] keep
[ surface-w ] keep
SDL_FreeSurface
dup str-length 0 = [
drop TTF_FontHeight 0 swap
] [
- <int-box> <int-box> [ TTF_SizeText drop ] 2keep
+ <int-box> <int-box> [ TTF_SizeUNICODE drop ] 2keep
swap int-box-i swap int-box-i
] ifte ;
WRAPPER: quuux-tuple
[ 3 ] [ <quux-tuple> <quuux-tuple> delegation-test ] unit-test
+
+GENERIC: delegation-test-2
+TUPLE: quux-tuple-2 ;
+C: quux-tuple-2 ;
+M: quux-tuple-2 delegation-test-2 drop 4 ;
+WRAPPER: quuux-tuple-2
+
+[ 4 ] [ <quux-tuple-2> <quuux-tuple-2> delegation-test-2 ] unit-test
-! :folding=indent:collapseFolds=1:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: jedit
-USE: kernel
-USE: lists
-USE: namespaces
-USE: parser
-USE: streams
-USE: stdio
-USE: strings
-USE: unparser
-USE: words
+USING: files kernel lists namespaces parser streams stdio
+strings unparser words ;
: jedit-server-file ( -- path )
"jedit-server-file" get
read parse-number
] with-stream ;
-: bool, ( ? -- str )
- "true" "false" ? , ;
-
-: list>bsh-array, ( list -- code )
- "new String[] {" ,
- [ unparse , "," , ] each
- "null}" , ;
-
-: make-jedit-request ( files dir params -- code )
+: make-jedit-request ( files params -- code )
[
- [
- "EditServer.handleClient(" ,
- "restore" get bool, "," ,
- "newView" get bool, "," ,
- "newPlainView" get bool, "," ,
- ( If the dir is not set, we don't want to send f )
- dup [ unparse ] [ drop "null" ] ifte , "," ,
- list>bsh-array, ");\n" ,
- ] make-string
- ] bind ;
+ "EditServer.handleClient(false,false,false,null," ,
+ "new String[] {" ,
+ [ unparse , "," , ] each
+ "null});\n" ,
+ ] make-string ;
: send-jedit-request ( request -- )
jedit-server-info swap "localhost" swap <client> [
write flush
] with-stream ;
-: jedit-line/file ( line dir file -- )
- rot "+line:" swap unparse cat2 unit cons swap
- <namespace> [
- "restore" off
- "newView" off
- "newPlainView" off
- ] extend make-jedit-request send-jedit-request ;
+: jedit-line/file ( file line -- )
+ unparse "+line:" swap cat2 2list
+ make-jedit-request send-jedit-request ;
-: word-file ( path -- dir file )
- dup [
- "resource:/" ?str-head [
- resource-path swap
- ] [
- f swap
- ] ifte
- ] [
- f
- ] ifte ;
-
-: word-line/file ( word -- line dir file )
- #! Note that line numbers here start from 1
- dup "line" word-property swap "file" word-property
- word-file ;
+: jedit-file ( file -- )
+ unit make-jedit-request send-jedit-request ;
: jedit ( word -- )
- word-line/file dup [
- jedit-line/file
+ #! Note that line numbers here start from 1
+ dup word-file dup [
+ swap "line" word-property jedit-line/file
] [
- 3drop "Unknown source" print
+ 2drop "Unknown source" print
] ifte ;
-! :folding=indent:collapseFolds=1:
-
-! $Id$
-!
-! Copyright (C) 2003, 2004 Slava Pestov.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!
-! 1. Redistributions of source code must retain the above copyright notice,
-! this list of conditions and the following disclaimer.
-!
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-! this list of conditions and the following disclaimer in the documentation
-! and/or other materials provided with the distribution.
-!
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+! Copyright (C) 2003, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
IN: words
-USE: generic
-USE: inspector
-USE: lists
-USE: kernel
-USE: namespaces
-USE: prettyprint
-USE: stdio
-USE: strings
-USE: unparser
-USE: math
-USE: hashtables
+USING: files generic inspector lists kernel namespaces
+prettyprint stdio streams strings unparser math hashtables
+parser ;
GENERIC: word-uses? ( of in -- ? )
M: word word-uses? 2drop f ;
: words. ( vocab -- )
words . ;
+
+: word-file ( word -- file )
+ "file" word-property dup [
+ "resource:/" ?str-head [
+ resource-path swap path+
+ ] when
+ ] when ;
+
+: reload ( word -- )
+ #! Reload the source file the word originated from.
+ word-file run-resource ;
] ifte
] [
2drop
- ] ifte ;
+ ] ifte ; inline
: screen-pos ( gadget -- point )
#! The position of the gadget on the screen.
return to_c_string(untag_string(dpop()));
}
+/* FFI calls this */
+uint16_t* unbox_utf16_string(void)
+{
+ /* Return pointer to first character */
+ return (uint16_t*)(untag_string(dpop()) + 1);
+}
+
void primitive_string_nth(void)
{
F_STRING* string = untag_string(dpop());
F_STRING* from_c_string(const BYTE* c_string);
void primitive_memory_to_string(void);
DLLEXPORT BYTE* unbox_c_string(void);
+DLLEXPORT uint16_t* unbox_utf16_string(void);
#define SREF(string,index) ((CELL)string + sizeof(F_STRING) + index * CHARS)