From ffc441ad6383152d827f7c538e9fe96095b9665d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Tue, 29 Sep 2015 22:21:26 +0200 Subject: [PATCH] VM: looks like ERROR_C_STRING is never thrown, so it can be removed --- basis/alien/data/data-docs.factor | 2 -- basis/debugger/debugger-docs.factor | 3 --- basis/debugger/debugger.factor | 4 ---- core/kernel/kernel.factor | 27 +++++++++++++-------------- vm/errors.hpp | 1 - 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/basis/alien/data/data-docs.factor b/basis/alien/data/data-docs.factor index ae8556fa7d..1ba03b07e5 100644 --- a/basis/alien/data/data-docs.factor +++ b/basis/alien/data/data-docs.factor @@ -183,8 +183,6 @@ ARTICLE: "c-strings" "C strings" $nl "Passing a Factor string to a C function expecting a " { $link c-string } " allocates a " { $link byte-array } " in the Factor heap; the string is then converted to the requested format and a raw pointer is passed to the function." $nl -"If the conversion fails, for example if the string contains null bytes or characters with values higher than 255, a " { $link c-string-error. } " is thrown." -$nl "Care must be taken if the C function expects a pointer to a string with its length represented by another parameter rather than a null terminator. Passing the result of calling " { $link length } " on the string object will not suffice. This is because a Factor string of " { $emphasis "n" } " characters will not necessarily encode to " { $emphasis "n" } " bytes. The correct idiom for C functions which take a string with a length is to first encode the string using " { $link encode } ", and then pass the resulting byte array together with the length of this byte array." $nl "Sometimes a C function has a parameter type of " { $link void* } ", and various data types, among them strings, can be passed in. In this case, strings are not automatically converted to aliens, and instead you must call one of these words:" diff --git a/basis/debugger/debugger-docs.factor b/basis/debugger/debugger-docs.factor index e673fb0b2f..bccb38f97e 100644 --- a/basis/debugger/debugger-docs.factor +++ b/basis/debugger/debugger-docs.factor @@ -122,9 +122,6 @@ HELP: signal-error. HELP: array-size-error. { $error-description "Thrown by " { $link } ", " { $link } ", " { $link } " and " { $link } " if the specified capacity is negative or too large." } ; -HELP: c-string-error. -{ $error-description "Thrown by " { $link alien-invoke } " and various primitives if a string containing null bytes, or characters with values higher than 255 is passed in where a C string is expected. See " { $link "c-strings" } "." } ; - HELP: ffi-error. { $error-description "Thrown by " { $link dlopen } " and " { $link dlsym } " if a problem occurs while loading a native library or looking up a symbol. See " { $link "alien" } "." } ; diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index e95253d055..50a13b5008 100755 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -104,9 +104,6 @@ HOOK: signal-error. os ( obj -- ) : fixnum-range-error. ( obj -- ) "Cannot convert to fixnum: " write third . ; -: c-string-error. ( obj -- ) - "Cannot convert to C string: " write third . ; - : ffi-error. ( obj -- ) "FFI error" print drop ; @@ -169,7 +166,6 @@ PREDICATE: vm-error < array [ signal-error. ] [ array-size-error. ] [ fixnum-range-error. ] - [ c-string-error. ] [ ffi-error. ] [ undefined-symbol-error. ] [ datastack-underflow. ] diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index c38206198c..611ba18d97 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -423,7 +423,7 @@ CONSTANT: CONTEXT-OBJ-IN-CALLBACK-P 3 ! basis/debugger/debugger.factor ! vm/errors.hpp -CONSTANT: kernel-error-count 21 +CONSTANT: kernel-error-count 20 CONSTANT: ERROR-EXPIRED 0 CONSTANT: ERROR-IO 1 @@ -433,19 +433,18 @@ CONSTANT: ERROR-DIVIDE-BY-ZERO 4 CONSTANT: ERROR-SIGNAL 5 CONSTANT: ERROR-ARRAY-SIZE 6 CONSTANT: ERROR-OUT-OF-FIXNUM-RANGE 7 -CONSTANT: ERROR-C-STRING 8 -CONSTANT: ERROR-FFI 9 -CONSTANT: ERROR-UNDEFINED-SYMBOL 10 -CONSTANT: ERROR-DATASTACK-UNDERFLOW 11 -CONSTANT: ERROR-DATASTACK-OVERFLOW 12 -CONSTANT: ERROR-RETAINSTACK-UNDERFLOW 13 -CONSTANT: ERROR-RETAINSTACK-OVERFLOW 14 -CONSTANT: ERROR-CALLSTACK-UNDERFLOW 15 -CONSTANT: ERROR-CALLSTACK-OVERFLOW 16 -CONSTANT: ERROR-MEMORY 17 -CONSTANT: ERROR-FP-TRAP 18 -CONSTANT: ERROR-INTERRUPT 19 -CONSTANT: ERROR-CALLBACK-SPACE-OVERFLOW 20 +CONSTANT: ERROR-FFI 8 +CONSTANT: ERROR-UNDEFINED-SYMBOL 9 +CONSTANT: ERROR-DATASTACK-UNDERFLOW 10 +CONSTANT: ERROR-DATASTACK-OVERFLOW 11 +CONSTANT: ERROR-RETAINSTACK-UNDERFLOW 12 +CONSTANT: ERROR-RETAINSTACK-OVERFLOW 13 +CONSTANT: ERROR-CALLSTACK-UNDERFLOW 14 +CONSTANT: ERROR-CALLSTACK-OVERFLOW 15 +CONSTANT: ERROR-MEMORY 16 +CONSTANT: ERROR-FP-TRAP 17 +CONSTANT: ERROR-INTERRUPT 18 +CONSTANT: ERROR-CALLBACK-SPACE-OVERFLOW 19 PRIMITIVE: callstack-for ( context -- array ) PRIMITIVE: retainstack-for ( context -- array ) diff --git a/vm/errors.hpp b/vm/errors.hpp index b43938e0a6..c865a82757 100644 --- a/vm/errors.hpp +++ b/vm/errors.hpp @@ -12,7 +12,6 @@ enum vm_error_type { ERROR_SIGNAL, ERROR_ARRAY_SIZE, ERROR_OUT_OF_FIXNUM_RANGE, - ERROR_C_STRING, ERROR_FFI, ERROR_UNDEFINED_SYMBOL, ERROR_DATASTACK_UNDERFLOW,