Fix a few more chicken bugs
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7075 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f365398d8c
commit
3c8513346d
5 changed files with 23 additions and 7 deletions
|
|
@ -1,2 +1,3 @@
|
|||
(load-library 'contract "contract.so")
|
||||
(include "testsuite.ss")
|
||||
(include "../schemerunme/contract.scm")
|
||||
|
|
|
|||
12
SWIG/Examples/test-suite/chicken/testsuite.ss
Normal file
12
SWIG/Examples/test-suite/chicken/testsuite.ss
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(define (lookup-ext-tag tag)
|
||||
(cond
|
||||
((equal? tag '(quote swig-contract-assertion-failed))
|
||||
'( ((exn type) #f)) )
|
||||
(#t '())))
|
||||
|
||||
(define-macro (expect-throw tag-form form)
|
||||
`(if (condition-case (begin ,form #t)
|
||||
,@(lookup-ext-tag tag-form)
|
||||
((exn) (print "The form threw a different error than expected: " ',form) (exit 1))
|
||||
(var () (print "The form did not error as expected: " ',form) (exit 1)))
|
||||
(begin (print "The form returned normally when it was expected to throw an error: " ',form) (exit 1))))
|
||||
|
|
@ -11,4 +11,4 @@
|
|||
(expect-throw 'swig-contract-assertion-failed
|
||||
(test-prepost 4 -10))
|
||||
|
||||
(quit)
|
||||
(exit 0)
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ SWIG_Chicken_Barf(int code, C_char *msg, ...)
|
|||
c = 1;
|
||||
break;
|
||||
case SWIG_BARF1_CONTRACT_ASSERT:
|
||||
barfval = C_OUT_OF_RANGE_ERROR;
|
||||
barfval = C_BAD_ARGUMENT_TYPE_ERROR;
|
||||
c = 1;
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ static String *short_class_name = 0;
|
|||
static String *clos_class_methods = 0;
|
||||
static int in_class = 0;
|
||||
static int have_constructor = 0;
|
||||
static String *constructor_name = 0;
|
||||
static bool exporting_destructor = false;
|
||||
static int useclassprefix = 0;
|
||||
static String *closprefix = 0;
|
||||
|
|
@ -1002,14 +1003,14 @@ CHICKEN::classHandler(Node *n)
|
|||
|
||||
Printf(closcode, ")))\n");
|
||||
|
||||
String *newmethod = NewStringf("new-%s", short_class_name);
|
||||
|
||||
if (have_constructor) {
|
||||
Printv(closcode, "(define-method (initialize (obj ", class_name, ") initargs)\n",
|
||||
" (call-next-method)\n",
|
||||
" (swig-initialize obj initargs ", chickenPrimitiveName(newmethod), ")\n",
|
||||
" (swig-initialize obj initargs ", chickenPrimitiveName(constructor_name), ")\n",
|
||||
")\n",
|
||||
NIL);
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
Printv(closcode, "(define-method (initialize (obj ", class_name, ") initargs)\n",
|
||||
" (call-next-method)\n",
|
||||
|
|
@ -1017,8 +1018,6 @@ CHICKEN::classHandler(Node *n)
|
|||
NIL);
|
||||
}
|
||||
|
||||
Delete(newmethod);
|
||||
|
||||
Printf(closcode, "%s\n", clos_class_methods);
|
||||
Delete(clos_class_methods);
|
||||
clos_class_methods = 0;
|
||||
|
|
@ -1159,6 +1158,10 @@ CHICKEN::constructorHandler(Node *n)
|
|||
{
|
||||
Language::constructorHandler(n);
|
||||
have_constructor = 1;
|
||||
String *iname = Getattr(n,"sym:name");
|
||||
if (constructor_name) Delete(constructor_name);
|
||||
constructor_name = Swig_name_construct(iname);
|
||||
Replaceall(constructor_name, "_", "-");
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue