]> gitweb.factorcode.org Git - factor.git/commitdiff
tuple dispatch compiled, adding USING: to more files, inference terminator cleanup...
authorSlava Pestov <slava@factorcode.org>
Wed, 9 Feb 2005 03:02:44 +0000 (03:02 +0000)
committerSlava Pestov <slava@factorcode.org>
Wed, 9 Feb 2005 03:02:44 +0000 (03:02 +0000)
29 files changed:
TODO.FACTOR.txt
library/bootstrap/boot-stage2.factor
library/compiler/alien-types.factor
library/generic/tuple.factor
library/inference/branches.factor
library/inference/inference.factor
library/inference/types.factor
library/inference/words.factor
library/io/files.factor
library/io/stream-impl.factor
library/math/arc-trig-hyp.factor
library/math/complex.factor
library/math/constants.factor
library/math/float.factor
library/math/integer.factor
library/math/math.factor
library/math/pow.factor
library/math/ratio.factor
library/math/trig-hyp.factor
library/namespaces.factor
library/sbuf.factor
library/sdl/sdl-ttf.factor
library/sdl/sdl-utils.factor
library/test/tuple.factor
library/tools/jedit.factor
library/tools/word-tools.factor
library/ui/gadgets.factor
native/string.c
native/string.h

index 1cd6fb96c02a50a0aa48cbb35c2bbeb8bd5c473e..47916b3e9145760906913dc5fc76cc8dc99f0133 100644 (file)
@@ -1,86 +1,63 @@
-+ 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
index c7341c7feec9f95fb00f8a77bd1f71ccd4df8193..33df1d16fc3058cc038de1290c88db4bc21d745c 100644 (file)
@@ -146,10 +146,10 @@ os "win32" = [
 \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
index 1aad3c6033f68177aed84047ba1d05f33fc433eb..a978f30d133327aa7b9bafceec2596f36f83cdcc 100644 (file)
@@ -1,42 +1,8 @@
-! :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.
 
@@ -218,6 +184,14 @@ global [ <namespace> "c-types" set ] bind
     "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
index 265e345ef5d59120ed93f19177a70b1929e71a4c..a52b6eb8063173f2ed23afaa9fa8e71be17ed8e5 100644 (file)
@@ -2,7 +2,7 @@
 ! 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>
@@ -102,28 +102,63 @@ kernel-internals math hashtables errors ;
         ] 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
index 322ce0e1ee6c7d3763541145705e1390d643799a..00d53ac459bc62c3e2e5e24a1946dc98201957d9 100644 (file)
@@ -64,12 +64,15 @@ strings vectors words hashtables prettyprint ;
     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
 
@@ -93,14 +96,6 @@ 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.
     [
@@ -109,13 +104,20 @@ SYMBOL: cloned
     ] 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 )
index c46c0d2fa428226868593edb5666504b55dc5675..bf8d7bd9058f2e231aa09e5c1391562deaaba5f6 100644 (file)
@@ -162,10 +162,31 @@ DEFER: apply-word
     #! 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.
index c1d378964a1d6b7eceddbeea04fa82ebc199f0da..ff91178f5749842dc6e4e93ceb941d809729d0d0 100644 (file)
@@ -27,14 +27,20 @@ lists math namespaces strings vectors words stdio prettyprint ;
     \ >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 -- )
index 416322e07447e87660fe660da37ae1eed0bd8702..6a07495b72dcacc736e42f3c541bf698cfdabe84 100644 (file)
@@ -62,23 +62,37 @@ strings vectors words hashtables parser prettyprint ;
     #! 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 -- )
@@ -141,14 +155,16 @@ M: symbol (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
index 5740658fa77b54e4473afe877f0d08b1fcf34132..d66f7967f4661e16f7ad5c7e6eb587d9164f6616 100644 (file)
@@ -1,39 +1,8 @@
-! :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 ;
index 55db95240365868657c75a19866cecf8d717b856..0e25cc59314a65a6aa864fe10501edab34fb6a57 100644 (file)
@@ -1,11 +1,18 @@
 ! 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 ;
 
@@ -56,4 +63,4 @@ C: fd-stream ( in out -- stream )
     "resource-path" get [ "." ] unless* ;
 
 : <resource-stream> ( path -- stream )
-    resource-path swap cat2 <file-reader> ;
+    resource-path swap path+ <file-reader> ;
index 7b093f741b1e01964f4f2dbeb3a6f25b1973492b..3467a7d8d1915cc680c330ff4f2d4b8bf848a923 100644 (file)
@@ -1,34 +1,7 @@
-! :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
index 87e03626603db4f39e82a300779edc32bf8788bc..9f5e950c0fb90d90855d45b2279bfae91a8bfa6b 100644 (file)
@@ -1,38 +1,10 @@
-! :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.
@@ -54,7 +26,7 @@ M: complex imaginary 1 slot %real ;
         (rect>)
     ] [
         "Complex number must have real components" throw drop
-    ] ifte ; inline
+    ] ifte ;
 
 : >rect ( x -- xr xi ) dup real swap imaginary ; inline
 
@@ -88,7 +60,7 @@ IN: math-internals
 
 : 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 ;
index cc73722929097e5f485c7ff1081916fe8f8740df..e0430a8535588f1840dc345a8d71b2120007b042 100644 (file)
@@ -1,30 +1,5 @@
-! :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
 
index b05d1be45f9f6d540f1155647f48cf802febf112..c37182f63aa28eceecc5fb7db3ddd5c3ac518b08 100644 (file)
@@ -1,34 +1,7 @@
-! :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< ;
index 520feaef3953e3c3715ccf0f9c1a3a9655d925ef..4787234df5485a71182c8bd92773fb3821809704 100644 (file)
@@ -1,37 +1,10 @@
-! :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= [
index a9cf93667043715906f94002ebdecac70175183e..2cb9bb145dd00b9a25e6a12eab60afa766f87153 100644 (file)
@@ -1,34 +1,7 @@
-! :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 -- ? )
@@ -92,7 +65,7 @@ M: number = ( n n -- ? ) number= ;
 
 : 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.
index a2d4529c556c1cfedc9d17f89380624e5e52b7d0..eaf68852bbc64d3333eedadf523fddc924635643 100644 (file)
@@ -1,34 +1,7 @@
-! :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
index 3ba3151547ee46d782bba5fe75b7c9c5fc12b682..18d793801fc6a301df421b3563f9adcc4eb49435 100644 (file)
@@ -1,36 +1,7 @@
-! :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 ;
@@ -50,7 +21,7 @@ M: ratio number= ( a/b c/d -- ? )
     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
index b1c4d2a367982fb46260321b9e376dc9f513212c..7c7bbf7c063bf03083074690b5a637bb5c95f7bf 100644 (file)
@@ -1,34 +1,7 @@
-! :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
index 1519c2fdd06b5f8fa66b0346fc5f9c9a9a9b5a14..2a94d0939bf8d6cf159d29d126301c93119de9f7 100644 (file)
@@ -1,7 +1,8 @@
 ! 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.
@@ -125,6 +126,17 @@ SYMBOL: list-buffer
     #! 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.
index 3a9ab2c8cfd3d3d261eb96c67580338f7ce6f0f3..a21fcd2566c2f8a65052978af9f1aea3a85cbdf5 100644 (file)
@@ -2,17 +2,6 @@
 ! 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.
index 3627e10e6efd60dc4389172f426253a9b294daad..6c2590247d49d61e34a236529043b4835cfd9e56 100644 (file)
@@ -1,30 +1,5 @@
-! :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
 
@@ -82,20 +57,23 @@ BEGIN-STRUCT: int-box
     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 ;
index 28bd0be72cc0e51f5e8bb92cdbf85cf46115980d..49c003bc2f6141c04907b840802dc2b6ba96f404 100644 (file)
@@ -103,7 +103,7 @@ SYMBOL: surface
     ] with-scope ; inline
 
 : event-loop ( event -- )
-    dup SDL_WaitEvent 1 = [
+    dup SDL_WaitEvent [
         dup event-type SDL_QUIT = [
             drop
         ] [
@@ -171,7 +171,7 @@ global [
     over str-length 0 = [
         2drop 3drop 0
     ] [
-        TTF_RenderText_Blended
+        TTF_RenderUNICODE_Blended
         [ draw-surface ] keep
         [ surface-w ] keep
         SDL_FreeSurface
@@ -181,7 +181,7 @@ global [
     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 ;
 
index 6dc28a26dd206a9adbf7ced8cc8b3b06f5b538a6..cd2e3ebe5e339b9609c9c0634384a859d3a01166 100644 (file)
@@ -23,3 +23,11 @@ M: quux-tuple delegation-test drop 4 ;
 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
index 5d30a9105b57585e965c75597bf60ad2cd1e98b7..b8dd959ed203d402a6a0a8c6890305e53347489f 100644 (file)
@@ -1,40 +1,8 @@
-! :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
@@ -47,26 +15,13 @@ USE: words
         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> [
@@ -75,33 +30,17 @@ USE: words
         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 ;
index 14a38b0943d38c808a97d9fc337b370133201d46..1bf8fb7c227011be0edfeeed81c7a50da1a05def 100644 (file)
@@ -1,42 +1,9 @@
-! :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 ;
@@ -107,3 +74,14 @@ M: generic word-uses? ( of in -- ? )
 
 : 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 ;
index 2bcfe53cc81017698a99860fe9f151567a65dad5..4aeb29e489bb589d36fbb8fee93d94c9f4fa7ad4 100644 (file)
@@ -67,7 +67,7 @@ C: gadget ( shape -- gadget )
         ] ifte
     ] [
         2drop
-    ] ifte ;
+    ] ifte ; inline
 
 : screen-pos ( gadget -- point )
     #! The position of the gadget on the screen.
index c790fdb3375eca9f8796d9c2f30bcdbcdc1c533f..e5a88bd7a590764fcd3a222f64c6728f1d14801c 100644 (file)
@@ -136,6 +136,13 @@ BYTE* unbox_c_string(void)
        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());
index db05d73bb685d335c3dc98f7f06dda35bb660cd2..1087193118201879a7f68e9357ef556c328354e0 100644 (file)
@@ -24,6 +24,7 @@ DLLEXPORT void box_c_string(const BYTE* c_string);
 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)