From 71bc5e9e1022690c7035a8581aac7186cc930bea Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 21 Jan 2009 19:55:33 -0600 Subject: [PATCH] Fix &: to throw an error if the symbol does not exist --- basis/alien/c-types/c-types-tests.factor | 4 ---- basis/alien/syntax/syntax.factor | 11 ++++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/basis/alien/c-types/c-types-tests.factor b/basis/alien/c-types/c-types-tests.factor index 31542b2699..40171f56e7 100644 --- a/basis/alien/c-types/c-types-tests.factor +++ b/basis/alien/c-types/c-types-tests.factor @@ -8,10 +8,6 @@ sequences system libc alien.strings io.encodings.utf8 ; [ { "blah" 123 } ] [ { "blah" xyz } expand-constants ] unit-test -: foo ( -- n ) &: fdafd [ 123 ] unless* ; - -[ 123 ] [ foo ] unit-test - [ -1 ] [ -1 *char ] unit-test [ -1 ] [ -1 *short ] unit-test [ -1 ] [ -1 *int ] unit-test diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index a02d2f3cb4..bed454e81d 100644 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -4,7 +4,7 @@ USING: accessors arrays alien alien.c-types alien.structs alien.arrays alien.strings kernel math namespaces parser sequences words quotations math.parser splitting grouping effects assocs combinators lexer strings.parser alien.parser -fry vocabs.parser ; +fry vocabs.parser words.constant ; IN: alien.syntax : DLL" lexer get skip-blank parse-string dlopen parsed ; parsing @@ -31,10 +31,11 @@ IN: alien.syntax : C-ENUM: ";" parse-tokens - dup length - [ [ create-in ] dip 1quotation define ] 2each ; + [ [ create-in ] dip define-constant ] each-index ; parsing +: address-of ( name library -- value ) + load-library dlsym [ "No such symbol" throw ] unless* ; + : &: - scan "c-library" get - '[ _ _ load-library dlsym ] over push-all ; parsing + scan "c-library" get '[ _ _ address-of ] over push-all ; parsing