]> gitweb.factorcode.org Git - factor.git/commitdiff
alien: replacing the alien-*-error family of errors with callsite-not-compiled
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 3 Aug 2016 08:53:48 +0000 (10:53 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Thu, 4 Aug 2016 09:51:59 +0000 (11:51 +0200)
All the errors did the same thing anyway. Also adding a summary method
to it.

basis/debugger/debugger.factor
core/alien/alien-docs.factor
core/alien/alien-tests.factor
core/alien/alien.factor

index 3621132a131dde762288e4ea3d82e5d0e646e63b..9609782772ffc478af88ac7b1b08a97dc377eabd 100755 (executable)
@@ -1,16 +1,14 @@
 ! Copyright (C) 2004, 2011 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.strings arrays assocs classes
+USING: accessors alien alien.strings arrays assocs classes
 classes.builtin classes.mixin classes.tuple classes.tuple.parser
-combinators combinators.short-circuit compiler.errors
-compiler.units continuations definitions destructors
-effects.parser fry generic generic.math generic.parser
-generic.single grouping io io.encodings io.styles kernel
-kernel.private lexer libc make math math.order math.parser
-math.ratios namespaces parser prettyprint sequences
-sequences.private slots source-files.errors strings
-strings.parser summary system vocabs vocabs.loader vocabs.parser
-words ;
+combinators combinators.short-circuit compiler.errors compiler.units
+continuations definitions destructors effects.parser fry generic
+generic.math generic.parser generic.single grouping io io.encodings
+io.styles kernel kernel.private lexer libc make math math.order
+math.parser math.ratios namespaces parser prettyprint sequences
+sequences.private slots source-files.errors strings strings.parser
+summary system vocabs vocabs.loader vocabs.parser words ;
 IN: debugger
 
 GENERIC: error-help ( error -- topic )
@@ -384,4 +382,7 @@ M: wrong-values summary drop "Quotation's stack effect does not match call site"
 
 M: stack-effect-omits-dashes summary drop "Stack effect must contain “--”" ;
 
+M: callsite-not-compiled summary
+    drop "Caller not compiled with the optimizing compiler" ;
+
 { "threads" "debugger" } "debugger.threads" require-when
index d7040710bb56336cd52b7f112931f31ebf5d01e5..883f60889b8b5ff90f4a4af3d1c0899e1993fb22 100644 (file)
@@ -11,6 +11,9 @@ HELP: callee-cleanup?
 HELP: cdecl
 { $description "This symbol is passed as the " { $snippet "abi" } " argument to " { $link alien-indirect } ", " { $link alien-callback } ", " { $link alien-assembly } ", and " { $link add-library } " to indicate that the standard C calling convention should be used, where the caller cleans up the stack frame after calling the function. This symbol only has meaning on 32-bit x86 platforms." } ;
 
+HELP: callsite-not-compiled
+{ $error-description "Thrown if the word calling the given word was not compiled with the optimizing compiler. This can happen when experimenting with the word in this listener. To fix the problem, place the word call in a word; word definitions are automatically compiled with the optimizing compiler. Only a few words relating to calling FFI functions throws this error." } ;
+
 HELP: stdcall
 { $description "This symbol is passed as the " { $snippet "abi" } " argument to " { $link alien-indirect } ", " { $link alien-callback } ", " { $link alien-assembly } ", and " { $link add-library } " to indicate that the Windows API calling convention should be used, where the called function cleans up its own stack frame before returning to the caller. This symbol only has meaning on 32-bit x86 platforms." } ;
 
@@ -91,29 +94,11 @@ HELP: <alien>
 HELP: c-ptr
 { $class-description "Class of objects consisting of aliens, byte arrays and " { $link f } ". These objects all can be used as values of " { $link pointer } " C types." } ;
 
-HELP: alien-invoke-error
-{ $error-description "Thrown if the word calling " { $link alien-invoke } " was not compiled with the optimizing compiler. This may be a result of one of several failure conditions:"
-    { $list
-        { "This can happen when experimenting with " { $link alien-invoke } " in this listener. To fix the problem, place the " { $link alien-invoke } " call in a word; word definitions are automatically compiled with the optimizing compiler." }
-        { "The return type or parameter list references an unknown C type." }
-        { "The symbol or library could not be found." }
-        { "One of the four inputs to " { $link alien-invoke } " is not a literal value. To call functions which are not known at compile-time, use " { $link alien-indirect } "." }
-    }
-} ;
-
 HELP: alien-invoke
 { $values { "args..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "library" "a logical library name" } { "function" "a C function name" } { "parameters" "a sequence of C parameter types" } { "return..." "the return value of the function, if not " { $link void } } }
 { $description "Calls a C library function with the given name. Input parameters are taken from the data stack, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected." }
 { $notes "C type names are documented in " { $link "c-types-specs" } "." }
-{ $errors "Throws an " { $link alien-invoke-error } " if the word calling " { $link alien-invoke } " was not compiled with the optimizing compiler." } ;
-
-HELP: alien-indirect-error
-{ $error-description "Thrown if the word calling " { $link alien-indirect } " was not compiled with the optimizing compiler. This may be a result of one of two failure conditions:"
-    { $list
-        { "This can happen when experimenting with " { $link alien-indirect } " in this listener. To fix the problem, place the " { $link alien-indirect } " call in a word; word definitions are automatically compiled with the optimizing compiler." }
-        { "One of the three inputs to " { $link alien-indirect } " is not a literal value." }
-    }
-} ;
+{ $errors "Throws an " { $link callsite-not-compiled } " if the word calling " { $link alien-invoke } " was not compiled with the optimizing compiler." } ;
 
 HELP: alien-indirect
 { $values { "args..." "zero or more objects passed to the C function" } { "funcptr" "a C function pointer" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $link cdecl } " or " { $link stdcall } } { "return..." "the return value of the function, if not " { $link void } } }
@@ -121,15 +106,7 @@ HELP: alien-indirect
     "Invokes a C function pointer passed on the data stack. Input parameters are taken from the data stack following the function pointer, and the return value is pushed on the data stack after the function returns. A return type of " { $link void } " indicates that no value is to be expected."
 }
 { $notes "C type names are documented in " { $link "c-types-specs" } "." }
-{ $errors "Throws an " { $link alien-indirect-error } " if the word calling " { $link alien-indirect } " is not compiled." } ;
-
-HELP: alien-callback-error
-{ $error-description "Thrown if the word calling " { $link alien-callback } " was not compiled with the optimizing compiler. This may be a result of one of two failure conditions:"
-    { $list
-        { "This can happen when experimenting with " { $link alien-callback } " in this listener. To fix the problem, place the " { $link alien-callback } " call in a word; word definitions are automatically compiled with the optimizing compiler." }
-        { "One of the four inputs to " { $link alien-callback } " is not a literal value." }
-    }
-} ;
+{ $errors "Throws an " { $link callsite-not-compiled } " if the word calling " { $link alien-indirect } " is not compiled." } ;
 
 HELP: alien-callback
 { $values { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $link cdecl } " or " { $link stdcall } } { "quot" quotation } { "alien" alien } }
@@ -148,15 +125,7 @@ HELP: alien-callback
         "    int { int int } cdecl [ - ] alien-callback ;"
     }
 }
-{ $errors "Throws an " { $link alien-callback-error } " if the word calling " { $link alien-callback } " is not compiled." } ;
-
-HELP: alien-assembly-error
-{ $error-description "Thrown if the word calling " { $link alien-assembly } " was not compiled with the optimizing compiler. This may be a result of one of two failure conditions:"
-    { $list
-        { "This can happen when experimenting with " { $link alien-assembly } " in this listener. To fix the problem, place the " { $link alien-assembly } " call in a word; word definitions are automatically compiled with the optimizing compiler." }
-        { "One of the four inputs to " { $link alien-assembly } " is not a literal value." }
-    }
-} ;
+{ $errors "Throws an " { $link callsite-not-compiled } " if the word calling " { $link alien-callback } " is not compiled." } ;
 
 HELP: alien-assembly
 { $values { "args..." "zero or more objects passed to the C function" } { "return" "a C return type" } { "parameters" "a sequence of C parameter types" } { "abi" "one of " { $link cdecl } " or " { $link stdcall } } { "quot" quotation } { "return..." "the return value of the function, if not " { $link void } } }
@@ -173,7 +142,7 @@ HELP: alien-assembly
     $nl
 }
 { $notes "C type names are documented in " { $link "c-types-specs" } "." }
-{ $errors "Throws an " { $link alien-assembly-error } " if the word calling " { $link alien-assembly } " is not compiled." } ;
+{ $errors "Throws an " { $link callsite-not-compiled } " if the word calling " { $link alien-assembly } " is not compiled." } ;
 
 { alien-invoke alien-indirect alien-assembly alien-callback } related-words
 
index 28b2fe6d776ee22cf1eda989eb479fc014211ea6..0732e877edecee2275c82e5b33e0a5e942b9c373 100644 (file)
@@ -123,3 +123,6 @@ SYMBOL: foo
     fill-and-free-callback-heap
     call-cb
 ] unit-test
+
+[ void { } cdecl [ ] alien-assembly ] [ callsite-not-compiled? ] must-fail-with
+[ void f "flor" { } alien-invoke ] [ callsite-not-compiled? ] must-fail-with
index b60331d8cb3b6ea6d4a01258cd0bfe60da2a1d5e..b3f25ca95337c44583fb350de3576f8c6c9e622e 100755 (executable)
@@ -83,25 +83,19 @@ UNION: abi stdcall thiscall fastcall cdecl mingw ;
 : callee-cleanup? ( abi -- ? )
     { stdcall fastcall thiscall } member? ;
 
-ERROR: alien-callback-error ;
+ERROR: callsite-not-compiled word ;
 
-: alien-callback ( return parameters abi quot -- alien )
-    alien-callback-error ;
+: alien-assembly ( args... return parameters abi quot -- return... )
+    \ alien-assembly callsite-not-compiled ;
 
-ERROR: alien-indirect-error ;
+: alien-callback ( return parameters abi quot -- alien )
+    \ alien-callback callsite-not-compiled ;
 
 : alien-indirect ( args... funcptr return parameters abi -- return... )
-    alien-indirect-error ;
-
-ERROR: alien-invoke-error library symbol ;
+    \ alien-indirect callsite-not-compiled ;
 
 : alien-invoke ( args... return library function parameters -- return... )
-    2over alien-invoke-error ;
-
-ERROR: alien-assembly-error code ;
-
-: alien-assembly ( args... return parameters abi quot -- return... )
-    dup alien-assembly-error ;
+    \ alien-invoke callsite-not-compiled ;
 
 <PRIVATE